Files
pipelines/app/tool/settings_probe.dart
T
alan abd696b0d9 feat(app): add native Settings connection and workspace screen
Add the Settings destination under lib/features/settings with an editable
websocket endpoint, truthful connection states, one ping per connect/mount,
workspace validation and persistence under new feature-owned keys. Material
and Cupertino controls, wrapping copy at large text, pending ping state, and
isolated probe tools plus widget/unit coverage.
2026-10-21 17:39:18 +01:00

72 lines
2.5 KiB
Dart

import 'dart:async';
import 'package:flutter/material.dart';
import 'package:pipelines_app/core/transport/pipelines_client.dart';
import 'package:pipelines_app/features/settings/settings.dart';
/// A fixture entry point for browser captures of the Settings screen. It does
/// not change `main.dart` or the shell, and it never uses the production
/// preferences store: all persisted values live in a [MemorySettingsStore].
///
/// Query parameters:
/// endpoint=ws://127.0.0.1:PORT/connect seed the URL field / connect target
/// workspace=/srv/pipelines seed the saved workspace
/// connect=1 explicitly connect after first frame
/// platform=ios render the Cupertino controls
/// theme=dark dark Material theme
/// scale=1.5 large-text check
void main() {
final params = Uri.base.queryParameters;
final endpoint = params['endpoint']?.trim();
final client = PipelinesClient();
final store = MemorySettingsStore(
workspace: params['workspace']?.trim() ?? '',
);
final isIOS = params['platform'] == 'ios';
final isDark = params['theme'] == 'dark';
final scale = double.tryParse(params['scale'] ?? '') ?? 1;
runApp(
MaterialApp(
title: 'Pipelines Settings probe',
theme: ThemeData(
platform: isIOS ? TargetPlatform.iOS : TargetPlatform.android,
brightness: isDark ? Brightness.dark : Brightness.light,
colorScheme: ColorScheme.fromSeed(
seedColor: Colors.blue,
brightness: isDark ? Brightness.dark : Brightness.light,
),
),
builder: (context, child) => MediaQuery(
data: MediaQuery.of(
context,
).copyWith(textScaler: TextScaler.linear(scale)),
child: child ?? const SizedBox.shrink(),
),
home: SettingsScreen(
client: client,
initialEndpoint: (endpoint == null || endpoint.isEmpty)
? null
: Uri.tryParse(endpoint),
store: store,
),
),
);
if (params['connect'] == '1') {
final target = (endpoint == null || endpoint.isEmpty)
? defaultServerUrl()
: endpoint;
if (target.isNotEmpty) {
WidgetsBinding.instance.addPostFrameCallback((_) {
unawaited(
client.connect(Uri.parse(target)).catchError((Object _) {
// The screen renders the client's truthful state; an invalid
// fixture endpoint must not take the probe down.
}),
);
});
}
}
}