feat(app): register native Settings on the shared live session
This commit is contained in:
@@ -18,13 +18,14 @@ enum RunSubscriptionState { pending, live, refused }
|
|||||||
/// `subscribe` on every connected transition because a new socket has no
|
/// `subscribe` on every connected transition because a new socket has no
|
||||||
/// watch, and drops it deliberately with `unsubscribe` when the app stops.
|
/// watch, and drops it deliberately with `unsubscribe` when the app stops.
|
||||||
class AppSession extends ChangeNotifier {
|
class AppSession extends ChangeNotifier {
|
||||||
AppSession({required this.endpoint, PipelinesClient? client})
|
AppSession({required Uri? endpoint, PipelinesClient? client})
|
||||||
: _client = client ?? PipelinesClient() {
|
: _initialEndpoint = endpoint,
|
||||||
|
_client = client ?? PipelinesClient() {
|
||||||
_states = _client.states.listen(_onState);
|
_states = _client.states.listen(_onState);
|
||||||
_frames = _client.frames.listen(_onFrame);
|
_frames = _client.frames.listen(_onFrame);
|
||||||
}
|
}
|
||||||
|
|
||||||
final Uri? endpoint;
|
final Uri? _initialEndpoint;
|
||||||
final PipelinesClient _client;
|
final PipelinesClient _client;
|
||||||
late final StreamSubscription<ConnectionState> _states;
|
late final StreamSubscription<ConnectionState> _states;
|
||||||
late final StreamSubscription<JsonMap> _frames;
|
late final StreamSubscription<JsonMap> _frames;
|
||||||
@@ -36,6 +37,10 @@ class AppSession extends ChangeNotifier {
|
|||||||
String? _subscribeRequest;
|
String? _subscribeRequest;
|
||||||
|
|
||||||
ApiGateway get gateway => _client;
|
ApiGateway get gateway => _client;
|
||||||
|
|
||||||
|
/// Settings controls the same transport; it must never create another socket.
|
||||||
|
PipelinesClient get client => _client;
|
||||||
|
Uri? get endpoint => _client.endpoint ?? _initialEndpoint;
|
||||||
ConnectionState get connection => _connection;
|
ConnectionState get connection => _connection;
|
||||||
bool get connected => _connection.kind == ConnectionKind.connected;
|
bool get connected => _connection.kind == ConnectionKind.connected;
|
||||||
|
|
||||||
@@ -62,7 +67,7 @@ class AppSession extends ChangeNotifier {
|
|||||||
/// Retries now: reopens a disconnected socket, or repeats a refused watch on
|
/// Retries now: reopens a disconnected socket, or repeats a refused watch on
|
||||||
/// a healthy one.
|
/// a healthy one.
|
||||||
Future<void> retry() async {
|
Future<void> retry() async {
|
||||||
if (connected) {
|
if (_client.state.kind == ConnectionKind.connected) {
|
||||||
resubscribe();
|
resubscribe();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import 'package:flutter/widgets.dart';
|
|||||||
import '../core/transport/pipelines_client.dart';
|
import '../core/transport/pipelines_client.dart';
|
||||||
import '../shell/adaptive_shell.dart';
|
import '../shell/adaptive_shell.dart';
|
||||||
import '../shell/destination.dart';
|
import '../shell/destination.dart';
|
||||||
|
import '../features/settings/settings_screen.dart';
|
||||||
import 'app.dart';
|
import 'app.dart';
|
||||||
import 'app_route.dart';
|
import 'app_route.dart';
|
||||||
import 'app_router.dart';
|
import 'app_router.dart';
|
||||||
@@ -106,6 +107,11 @@ class _PipelinesAppState extends State<PipelinesApp> {
|
|||||||
onRunSelected: (id) => _delegate.goTo(AppRoute.run(id)),
|
onRunSelected: (id) => _delegate.goTo(AppRoute.run(id)),
|
||||||
onBack: () => _delegate.goTo(AppRoute.runs),
|
onBack: () => _delegate.goTo(AppRoute.runs),
|
||||||
),
|
),
|
||||||
|
AppDestination.settings: (_) => SettingsScreen(
|
||||||
|
client: _session.client,
|
||||||
|
initialEndpoint: _session.endpoint,
|
||||||
|
embedded: true,
|
||||||
|
),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,8 @@ class RunsDestination extends StatelessWidget {
|
|||||||
animation: session,
|
animation: session,
|
||||||
builder: (context, _) {
|
builder: (context, _) {
|
||||||
final cupertino = usesCupertinoHost(context);
|
final cupertino = usesCupertinoHost(context);
|
||||||
if (server.requiresConfiguration || server.error != null) {
|
if ((server.requiresConfiguration || server.error != null) &&
|
||||||
|
session.endpoint == null) {
|
||||||
return _ConnectionScreen(
|
return _ConnectionScreen(
|
||||||
session: session,
|
session: session,
|
||||||
server: server,
|
server: server,
|
||||||
|
|||||||
@@ -39,6 +39,9 @@ class PipelinesClient implements ApiGateway {
|
|||||||
Stream<ConnectionState> get states => _states.stream;
|
Stream<ConnectionState> get states => _states.stream;
|
||||||
ConnectionState get state => _state;
|
ConnectionState get state => _state;
|
||||||
|
|
||||||
|
/// Last validated endpoint, including changes made through native Settings.
|
||||||
|
Uri? get endpoint => _endpoint;
|
||||||
|
|
||||||
Future<void> connect(Uri uri) async {
|
Future<void> connect(Uri uri) async {
|
||||||
if (_disposed) throw StateError('Client has been disposed');
|
if (_disposed) throw StateError('Client has been disposed');
|
||||||
final endpoint = ServerUrl.validate(uri.toString());
|
final endpoint = ServerUrl.validate(uri.toString());
|
||||||
|
|||||||
@@ -2,12 +2,9 @@ import 'package:flutter/cupertino.dart';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import 'settings_layout.dart';
|
import 'settings_layout.dart';
|
||||||
|
import 'settings_theme.dart';
|
||||||
|
|
||||||
/// Whether the current platform expects Cupertino controls. The app's theme is
|
export 'settings_theme.dart';
|
||||||
/// the single source of the platform answer, so dark mode and platform overrides
|
|
||||||
/// stay consistent with the rest of the shell.
|
|
||||||
bool usesCupertinoControls(BuildContext context) =>
|
|
||||||
Theme.of(context).platform == TargetPlatform.iOS;
|
|
||||||
|
|
||||||
/// A native text field with a label and one supporting line. Both platforms lay
|
/// A native text field with a label and one supporting line. Both platforms lay
|
||||||
/// the label out as wrapping text above the field; Material uses an outlined
|
/// the label out as wrapping text above the field; Material uses an outlined
|
||||||
@@ -40,7 +37,12 @@ class SettingsTextField extends StatelessWidget {
|
|||||||
// Material floating label is single-line and ellipsizes the workspace label
|
// Material floating label is single-line and ellipsizes the workspace label
|
||||||
// at narrow widths or large text, dropping required words.
|
// at narrow widths or large text, dropping required words.
|
||||||
final labelWidget = ExcludeSemantics(
|
final labelWidget = ExcludeSemantics(
|
||||||
child: Text(label, style: theme.textTheme.titleSmall),
|
child: Text(
|
||||||
|
label,
|
||||||
|
style: usesCupertinoControls(context)
|
||||||
|
? settingsTextStyle(context)
|
||||||
|
: theme.textTheme.titleSmall,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
if (!usesCupertinoControls(context)) {
|
if (!usesCupertinoControls(context)) {
|
||||||
return Column(
|
return Column(
|
||||||
@@ -85,9 +87,6 @@ class SettingsTextField extends StatelessWidget {
|
|||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
final supportingColor = hasError
|
|
||||||
? theme.colorScheme.error
|
|
||||||
: theme.colorScheme.onSurfaceVariant;
|
|
||||||
return Column(
|
return Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
@@ -109,7 +108,11 @@ class SettingsTextField extends StatelessWidget {
|
|||||||
const SizedBox(height: settingsFieldGap),
|
const SizedBox(height: settingsFieldGap),
|
||||||
Text(
|
Text(
|
||||||
hasError ? error : helper,
|
hasError ? error : helper,
|
||||||
style: theme.textTheme.bodySmall?.copyWith(color: supportingColor),
|
style: settingsTextStyle(
|
||||||
|
context,
|
||||||
|
error: hasError,
|
||||||
|
secondary: !hasError,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ class SettingsScreen extends StatefulWidget {
|
|||||||
this.initialEndpoint,
|
this.initialEndpoint,
|
||||||
this.store,
|
this.store,
|
||||||
this.ping,
|
this.ping,
|
||||||
|
this.embedded = false,
|
||||||
});
|
});
|
||||||
|
|
||||||
final transport.PipelinesClient client;
|
final transport.PipelinesClient client;
|
||||||
@@ -40,6 +41,9 @@ class SettingsScreen extends StatefulWidget {
|
|||||||
/// Test seam for the exact ping request. Production uses `client.call('ping')`.
|
/// Test seam for the exact ping request. Production uses `client.call('ping')`.
|
||||||
final PingCallback? ping;
|
final PingCallback? ping;
|
||||||
|
|
||||||
|
/// The application shell already owns the native navigation bar and safe area.
|
||||||
|
final bool embedded;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<SettingsScreen> createState() => _SettingsScreenState();
|
State<SettingsScreen> createState() => _SettingsScreenState();
|
||||||
}
|
}
|
||||||
@@ -123,6 +127,7 @@ class _SettingsScreenState extends State<SettingsScreen> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
if (widget.embedded) return content;
|
||||||
if (usesCupertinoControls(context)) {
|
if (usesCupertinoControls(context)) {
|
||||||
return CupertinoPageScaffold(
|
return CupertinoPageScaffold(
|
||||||
navigationBar: const CupertinoNavigationBar(middle: Text('Settings')),
|
navigationBar: const CupertinoNavigationBar(middle: Text('Settings')),
|
||||||
@@ -143,6 +148,6 @@ class _SectionTitle extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Text(title, style: Theme.of(context).textTheme.titleMedium);
|
return Text(title, style: settingsTextStyle(context, title: true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ class SettingsConnectionSection extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final theme = Theme.of(context);
|
|
||||||
return Column(
|
return Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
@@ -64,18 +63,14 @@ class SettingsConnectionSection extends StatelessWidget {
|
|||||||
const SizedBox(height: settingsFieldGap),
|
const SizedBox(height: settingsFieldGap),
|
||||||
Text(
|
Text(
|
||||||
controller.endpointSaveError,
|
controller.endpointSaveError,
|
||||||
style: theme.textTheme.bodySmall?.copyWith(
|
style: settingsTextStyle(context, error: true),
|
||||||
color: theme.colorScheme.error,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
if (controller.actionError.isNotEmpty) ...<Widget>[
|
if (controller.actionError.isNotEmpty) ...<Widget>[
|
||||||
const SizedBox(height: settingsFieldGap),
|
const SizedBox(height: settingsFieldGap),
|
||||||
Text(
|
Text(
|
||||||
controller.actionError,
|
controller.actionError,
|
||||||
style: theme.textTheme.bodySmall?.copyWith(
|
style: settingsTextStyle(context, error: true),
|
||||||
color: theme.colorScheme.error,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
const SizedBox(height: settingsTitleGap),
|
const SizedBox(height: settingsTitleGap),
|
||||||
@@ -102,13 +97,19 @@ class SettingsStatusCard extends StatelessWidget {
|
|||||||
final title = lines.isEmpty ? '' : lines.first;
|
final title = lines.isEmpty ? '' : lines.first;
|
||||||
final details = lines.length > 1 ? lines.sublist(1) : const <String>[];
|
final details = lines.length > 1 ? lines.sublist(1) : const <String>[];
|
||||||
final titleColor = switch (state.kind) {
|
final titleColor = switch (state.kind) {
|
||||||
transport.ConnectionKind.connected => theme.colorScheme.primary,
|
transport.ConnectionKind.connected =>
|
||||||
transport.ConnectionKind.disconnected => theme.colorScheme.error,
|
usesCupertinoControls(context)
|
||||||
_ => theme.colorScheme.onSurface,
|
? CupertinoTheme.of(context).primaryColor
|
||||||
|
: theme.colorScheme.primary,
|
||||||
|
transport.ConnectionKind.disconnected => settingsErrorColor(context),
|
||||||
|
_ => settingsTextStyle(context).color,
|
||||||
};
|
};
|
||||||
final titleWidget = Text(
|
final titleWidget = Text(
|
||||||
title,
|
title,
|
||||||
style: theme.textTheme.titleMedium?.copyWith(color: titleColor),
|
style: settingsTextStyle(
|
||||||
|
context,
|
||||||
|
title: true,
|
||||||
|
).copyWith(color: titleColor),
|
||||||
);
|
);
|
||||||
return SettingsCard(
|
return SettingsCard(
|
||||||
child: Column(
|
child: Column(
|
||||||
@@ -129,12 +130,7 @@ class SettingsStatusCard extends StatelessWidget {
|
|||||||
titleWidget,
|
titleWidget,
|
||||||
for (final line in details) ...<Widget>[
|
for (final line in details) ...<Widget>[
|
||||||
const SizedBox(height: settingsFieldGap),
|
const SizedBox(height: settingsFieldGap),
|
||||||
Text(
|
Text(line, style: settingsTextStyle(context, secondary: true)),
|
||||||
line,
|
|
||||||
style: theme.textTheme.bodyMedium?.copyWith(
|
|
||||||
color: theme.colorScheme.onSurfaceVariant,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@@ -156,7 +152,6 @@ class SettingsWorkspaceSection extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final theme = Theme.of(context);
|
|
||||||
final saveError = controller.workspaceSaveError;
|
final saveError = controller.workspaceSaveError;
|
||||||
final canSave = canSaveWorkspace(controller.workspaceDraft);
|
final canSave = canSaveWorkspace(controller.workspaceDraft);
|
||||||
return Column(
|
return Column(
|
||||||
@@ -193,16 +188,11 @@ class SettingsWorkspaceSection extends StatelessWidget {
|
|||||||
const SizedBox(height: settingsFieldGap),
|
const SizedBox(height: settingsFieldGap),
|
||||||
Text(
|
Text(
|
||||||
savedWorkspaceLine(controller.savedWorkspace),
|
savedWorkspaceLine(controller.savedWorkspace),
|
||||||
style: theme.textTheme.bodyMedium,
|
style: settingsTextStyle(context),
|
||||||
),
|
),
|
||||||
if (saveError.isNotEmpty) ...<Widget>[
|
if (saveError.isNotEmpty) ...<Widget>[
|
||||||
const SizedBox(height: settingsFieldGap),
|
const SizedBox(height: settingsFieldGap),
|
||||||
Text(
|
Text(saveError, style: settingsTextStyle(context, error: true)),
|
||||||
saveError,
|
|
||||||
style: theme.textTheme.bodySmall?.copyWith(
|
|
||||||
color: theme.colorScheme.error,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -0,0 +1,42 @@
|
|||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import '../../ui/adaptive/host.dart';
|
||||||
|
|
||||||
|
bool usesCupertinoControls(BuildContext context) =>
|
||||||
|
usesCupertinoHost(context) ||
|
||||||
|
Theme.of(context).platform == TargetPlatform.iOS;
|
||||||
|
|
||||||
|
Color settingsErrorColor(BuildContext context) => usesCupertinoControls(context)
|
||||||
|
? CupertinoColors.destructiveRed.resolveFrom(context)
|
||||||
|
: Theme.of(context).colorScheme.error;
|
||||||
|
|
||||||
|
/// Resolve native text roles from the actual host, not Material's fallback
|
||||||
|
/// light theme when mounted under a dark CupertinoApp.
|
||||||
|
TextStyle settingsTextStyle(
|
||||||
|
BuildContext context, {
|
||||||
|
bool title = false,
|
||||||
|
bool secondary = false,
|
||||||
|
bool error = false,
|
||||||
|
}) {
|
||||||
|
if (usesCupertinoControls(context)) {
|
||||||
|
final text = CupertinoTheme.of(context).textTheme;
|
||||||
|
return (title ? text.navTitleTextStyle : text.textStyle).copyWith(
|
||||||
|
color: error
|
||||||
|
? settingsErrorColor(context)
|
||||||
|
: (secondary ? CupertinoColors.secondaryLabel : CupertinoColors.label)
|
||||||
|
.resolveFrom(context),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
final theme = Theme.of(context);
|
||||||
|
final base = (title
|
||||||
|
? theme.textTheme.titleMedium
|
||||||
|
: theme.textTheme.bodyMedium)!;
|
||||||
|
return base.copyWith(
|
||||||
|
color: error
|
||||||
|
? theme.colorScheme.error
|
||||||
|
: secondary
|
||||||
|
? theme.colorScheme.onSurfaceVariant
|
||||||
|
: base.color,
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -12,7 +12,6 @@ class SettingsTrustWarning extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final theme = Theme.of(context);
|
|
||||||
final icon = usesCupertinoControls(context)
|
final icon = usesCupertinoControls(context)
|
||||||
? CupertinoIcons.exclamationmark_triangle
|
? CupertinoIcons.exclamationmark_triangle
|
||||||
: Icons.warning_amber_rounded;
|
: Icons.warning_amber_rounded;
|
||||||
@@ -20,7 +19,7 @@ class SettingsTrustWarning extends StatelessWidget {
|
|||||||
child: Row(
|
child: Row(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Icon(icon, color: theme.colorScheme.error),
|
Icon(icon, color: settingsErrorColor(context)),
|
||||||
const SizedBox(width: settingsControlGap),
|
const SizedBox(width: settingsControlGap),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Column(
|
child: Column(
|
||||||
@@ -28,16 +27,12 @@ class SettingsTrustWarning extends StatelessWidget {
|
|||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Text(
|
Text(
|
||||||
trustTitle,
|
trustTitle,
|
||||||
style: theme.textTheme.titleSmall?.copyWith(
|
style: settingsTextStyle(context, title: true, error: true),
|
||||||
color: theme.colorScheme.error,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
const SizedBox(height: settingsFieldGap),
|
const SizedBox(height: settingsFieldGap),
|
||||||
Text(
|
Text(
|
||||||
trustBody,
|
trustBody,
|
||||||
style: theme.textTheme.bodyMedium?.copyWith(
|
style: settingsTextStyle(context, secondary: true),
|
||||||
color: theme.colorScheme.onSurfaceVariant,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -26,18 +26,23 @@ class AdaptiveShell extends StatefulWidget {
|
|||||||
|
|
||||||
class _AdaptiveShellState extends State<AdaptiveShell> {
|
class _AdaptiveShellState extends State<AdaptiveShell> {
|
||||||
late AppDestination _selected;
|
late AppDestination _selected;
|
||||||
|
final Set<AppDestination> _visited = {};
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
_selected = widget.destination ?? AppDestination.pipelines;
|
_selected = widget.destination ?? AppDestination.pipelines;
|
||||||
|
_visited.add(_selected);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void didUpdateWidget(covariant AdaptiveShell oldWidget) {
|
void didUpdateWidget(covariant AdaptiveShell oldWidget) {
|
||||||
super.didUpdateWidget(oldWidget);
|
super.didUpdateWidget(oldWidget);
|
||||||
final destination = widget.destination;
|
final destination = widget.destination;
|
||||||
if (destination != null) _selected = destination;
|
if (destination != null) {
|
||||||
|
_selected = destination;
|
||||||
|
_visited.add(destination);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _select(AppDestination destination) {
|
void _select(AppDestination destination) {
|
||||||
@@ -46,7 +51,10 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
|
|||||||
callback(destination);
|
callback(destination);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setState(() => _selected = destination);
|
setState(() {
|
||||||
|
_selected = destination;
|
||||||
|
_visited.add(destination);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
List<T> _items<T>(T Function(AppDestination) build) =>
|
List<T> _items<T>(T Function(AppDestination) build) =>
|
||||||
@@ -60,9 +68,10 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
|
|||||||
final item = destinationDetails(destination);
|
final item = destinationDetails(destination);
|
||||||
return KeyedSubtree(
|
return KeyedSubtree(
|
||||||
key: ValueKey(destination),
|
key: ValueKey(destination),
|
||||||
child:
|
child: _visited.contains(destination)
|
||||||
widget.destinationBodies[destination]?.call(context) ??
|
? widget.destinationBodies[destination]?.call(context) ??
|
||||||
Center(child: Text('${item.label} — Not implemented')),
|
Center(child: Text('${item.label} — Not implemented'))
|
||||||
|
: const SizedBox.shrink(),
|
||||||
);
|
);
|
||||||
}).toList();
|
}).toList();
|
||||||
return LayoutBuilder(
|
return LayoutBuilder(
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
# Settings registered in the normal app
|
||||||
|
|
||||||
|
- `/settings` mounts the landed SettingsScreen with the app-owned client, not a
|
||||||
|
second socket. Embedded mode leaves the single native bar to the shell.
|
||||||
|
- Destinations are initialized on first visit and kept mounted thereafter; an
|
||||||
|
unvisited Settings screen issues no hidden ping or preference read.
|
||||||
|
- Session Retry uses the transport's current validated endpoint, including one
|
||||||
|
selected in Settings, rather than reverting to the bootstrap server. A native
|
||||||
|
missing-endpoint gate can be cleared by a successful Settings configuration.
|
||||||
|
- Real CupertinoApp dark-host capture exposed Material fallback text colours.
|
||||||
|
Settings now resolves typography/semantic colours from its actual native host.
|
||||||
|
The new dark-label regression failed before this correction and passes after.
|
||||||
|
No fixed font, palette or component dimensions were added.
|
||||||
|
|
||||||
|
## Verification
|
||||||
|
|
||||||
|
- 516 integrated Flutter tests pass; analyzer clean; normal-entry web build pass.
|
||||||
|
- Widget coverage mounts real Material and dark Cupertino app composition,
|
||||||
|
asserts one bar, no background Settings ping before visiting, shared socket,
|
||||||
|
and resolved server build after ping. Endpoint-change Retry has a regression.
|
||||||
|
- Extended normal-entry Runs CDP fixture answers real ping and drives Settings
|
||||||
|
in both hosts. Probe passes all existing history/drop/reconnect checks plus
|
||||||
|
Settings navigation and single-socket checks:20 captures. Both registered
|
||||||
|
phone screenshots inspected; dark Cupertino labels are readable after fix.
|
||||||
|
- Evidence in approved temp/settings-wired-browser and corresponding logs.
|
||||||
|
- Authenticated production-data interaction and Android/iOS remain unverified.
|
||||||
|
No real server endpoint/workspace preferences were changed by the fixtures.
|
||||||
@@ -22,6 +22,32 @@ List<String> types(FakeChannel channel) => [
|
|||||||
];
|
];
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
|
test('Retry preserves an endpoint changed through shared Settings', () async {
|
||||||
|
final endpoints = <Uri>[];
|
||||||
|
final client = PipelinesClient(
|
||||||
|
channelFactory: (uri) {
|
||||||
|
endpoints.add(uri);
|
||||||
|
return FakeChannel()..readyCompleter.complete();
|
||||||
|
},
|
||||||
|
);
|
||||||
|
final session = AppSession(
|
||||||
|
endpoint: Uri.parse('ws://original.test/connect'),
|
||||||
|
client: client,
|
||||||
|
);
|
||||||
|
addTearDown(session.dispose);
|
||||||
|
await session.start();
|
||||||
|
final changed = Uri.parse('ws://selected.test/connect');
|
||||||
|
await session.client.connect(changed);
|
||||||
|
await session.stop();
|
||||||
|
await session.retry();
|
||||||
|
expect(endpoints, [
|
||||||
|
Uri.parse('ws://original.test/connect'),
|
||||||
|
changed,
|
||||||
|
changed,
|
||||||
|
]);
|
||||||
|
expect(session.endpoint, changed);
|
||||||
|
});
|
||||||
|
|
||||||
test(
|
test(
|
||||||
'start subscribes once, stop unsubscribes, and the app owns the socket',
|
'start subscribes once, stop unsubscribes, and the app owns the socket',
|
||||||
() async {
|
() async {
|
||||||
|
|||||||
@@ -0,0 +1,86 @@
|
|||||||
|
import 'dart:convert';
|
||||||
|
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
import 'package:pipelines_app/application/pipelines_app.dart';
|
||||||
|
import 'package:pipelines_app/core/transport/pipelines_client.dart';
|
||||||
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
|
||||||
|
import '../core/transport/pipelines_client_test.dart' show FakeChannel;
|
||||||
|
import 'pipelines_app_test.dart' show webServer, requestOf;
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
for (final cupertino in [false, true]) {
|
||||||
|
testWidgets('Settings shares socket and one native bar ($cupertino)', (
|
||||||
|
tester,
|
||||||
|
) async {
|
||||||
|
SharedPreferences.setMockInitialValues({});
|
||||||
|
if (cupertino) {
|
||||||
|
tester.platformDispatcher.platformBrightnessTestValue = Brightness.dark;
|
||||||
|
addTearDown(tester.platformDispatcher.clearPlatformBrightnessTestValue);
|
||||||
|
}
|
||||||
|
final channel = FakeChannel()..readyCompleter.complete();
|
||||||
|
var sockets = 0;
|
||||||
|
final client = PipelinesClient(
|
||||||
|
channelFactory: (_) {
|
||||||
|
sockets++;
|
||||||
|
return channel;
|
||||||
|
},
|
||||||
|
);
|
||||||
|
final provider = PlatformRouteInformationProvider(
|
||||||
|
initialRouteInformation: RouteInformation(uri: Uri.parse('/pipelines')),
|
||||||
|
);
|
||||||
|
addTearDown(provider.dispose);
|
||||||
|
await tester.pumpWidget(
|
||||||
|
PipelinesApp(
|
||||||
|
server: webServer(),
|
||||||
|
client: client,
|
||||||
|
cupertino: cupertino,
|
||||||
|
routeInformationProvider: provider,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
await tester.pump();
|
||||||
|
expect(
|
||||||
|
requestOf(channel, 'ping'),
|
||||||
|
isNull,
|
||||||
|
reason: 'Unvisited settings must not issue hidden requests',
|
||||||
|
);
|
||||||
|
|
||||||
|
await tester.tap(find.text('Settings').last);
|
||||||
|
await tester.pump();
|
||||||
|
await tester.pump();
|
||||||
|
expect(provider.value.uri.path, '/settings');
|
||||||
|
expect(find.text('Server URL'), findsOneWidget);
|
||||||
|
if (cupertino) {
|
||||||
|
final title = tester.widget<Text>(find.text('Connection'));
|
||||||
|
expect(
|
||||||
|
title.style!.color!.computeLuminance(),
|
||||||
|
greaterThan(0.5),
|
||||||
|
reason: 'Cupertino dark host must not inherit light Material text',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
expect(find.text('Settings — Not implemented'), findsNothing);
|
||||||
|
expect(sockets, 1);
|
||||||
|
expect(
|
||||||
|
cupertino ? find.byType(CupertinoNavigationBar) : find.byType(AppBar),
|
||||||
|
findsOneWidget,
|
||||||
|
);
|
||||||
|
final ping = requestOf(channel, 'ping')!;
|
||||||
|
channel.incoming.add(
|
||||||
|
jsonEncode({
|
||||||
|
'id': ping['id'],
|
||||||
|
'type': 'pong',
|
||||||
|
'build': {'version': 'settings-fixture'},
|
||||||
|
'time': 'fixture time',
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
await tester.pump();
|
||||||
|
await tester.pump();
|
||||||
|
expect(find.textContaining('settings-fixture'), findsOneWidget);
|
||||||
|
expect(tester.takeException(), isNull);
|
||||||
|
await tester.pumpWidget(const SizedBox.shrink());
|
||||||
|
await tester.pump();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -119,6 +119,8 @@ try {
|
|||||||
if (!el.children.length && el.innerText) chunks.push(el.innerText);
|
if (!el.children.length && el.innerText) chunks.push(el.innerText);
|
||||||
}
|
}
|
||||||
for (const el of document.querySelectorAll('input, textarea')) {
|
for (const el of document.querySelectorAll('input, textarea')) {
|
||||||
|
const label = el.getAttribute('aria-label');
|
||||||
|
if (label) chunks.push(label);
|
||||||
if (el.value) chunks.push(String(el.value));
|
if (el.value) chunks.push(String(el.value));
|
||||||
}
|
}
|
||||||
if (document.body?.innerText) chunks.push(document.body.innerText);
|
if (document.body?.innerText) chunks.push(document.body.innerText);
|
||||||
@@ -369,6 +371,12 @@ try {
|
|||||||
await assertBody('Fixture live run');
|
await assertBody('Fixture live run');
|
||||||
captures.push(await capture('i1-gate-recovered-list-phone'));
|
captures.push(await capture('i1-gate-recovered-list-phone'));
|
||||||
|
|
||||||
|
await clickText('Settings');
|
||||||
|
await assertBody('Server URL');
|
||||||
|
await assertBody('Fixture settings build');
|
||||||
|
if ((await path()) !== '/settings') throw new Error('Settings did not update route');
|
||||||
|
captures.push(await capture('settings-cupertino-registered-phone'));
|
||||||
|
|
||||||
// Material host: the same deep link and route must render standard Material
|
// Material host: the same deep link and route must render standard Material
|
||||||
// controls (the Cupertino host was selected by the macOS browser above).
|
// controls (the Cupertino host was selected by the macOS browser above).
|
||||||
await send(
|
await send(
|
||||||
@@ -390,6 +398,16 @@ try {
|
|||||||
}
|
}
|
||||||
captures.push(await capture('i1-material-deeplink-run-1-phone'));
|
captures.push(await capture('i1-material-deeplink-run-1-phone'));
|
||||||
|
|
||||||
|
const beforeSettings = await (await fetch(`${fixture.url}/fixture/state`)).json();
|
||||||
|
await clickText('Settings');
|
||||||
|
await assertBody('Server URL');
|
||||||
|
await assertBody('Fixture settings build');
|
||||||
|
const afterSettings = await (await fetch(`${fixture.url}/fixture/state`)).json();
|
||||||
|
if (beforeSettings.subscribed !== afterSettings.subscribed || afterSettings.connections !== 1) {
|
||||||
|
throw new Error('Settings opened another connection instead of sharing the app socket');
|
||||||
|
}
|
||||||
|
captures.push(await capture('settings-material-registered-phone'));
|
||||||
|
|
||||||
const fixtureState = await (await fetch(`${fixture.url}/fixture/state`)).json();
|
const fixtureState = await (await fetch(`${fixture.url}/fixture/state`)).json();
|
||||||
if (fixtureState.subscribed < 2) throw new Error(`App never resubscribed: ${JSON.stringify(fixtureState)}`);
|
if (fixtureState.subscribed < 2) throw new Error(`App never resubscribed: ${JSON.stringify(fixtureState)}`);
|
||||||
if (fixtureState.listRuns < 2) throw new Error(`App never reloaded: ${JSON.stringify(fixtureState)}`);
|
if (fixtureState.listRuns < 2) throw new Error(`App never reloaded: ${JSON.stringify(fixtureState)}`);
|
||||||
|
|||||||
@@ -345,6 +345,14 @@ export async function startFixture({ root }) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (request.type === 'unsubscribe') return;
|
if (request.type === 'unsubscribe') return;
|
||||||
|
if (request.type === 'ping') {
|
||||||
|
client.send({
|
||||||
|
id: request.id, type: 'pong',
|
||||||
|
build: { version: 'Fixture settings build' },
|
||||||
|
time: '2026-10-21T12:00:00Z',
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (request.type === 'list_runs') {
|
if (request.type === 'list_runs') {
|
||||||
listRuns++;
|
listRuns++;
|
||||||
client.send({ id: request.id, type: 'runs', runs: RUNS, usage: null });
|
client.send({ id: request.id, type: 'runs', runs: RUNS, usage: null });
|
||||||
|
|||||||
Reference in New Issue
Block a user