Merge commit 'e0f0210bf7b0178a169d752df30e82b6f8cfa847' into pipelines/run-20261112-1022-readable-chat-title-in-narrow-headers-468d

This commit is contained in:
2026-11-12 11:10:10 +00:00
45 changed files with 2216 additions and 429 deletions
+2 -2
View File
@@ -52,8 +52,8 @@ class AppTerminals {
/// [shell] with the terminal panel, window or page around it, and the
/// app's floating [windows] above both.
/// [onChat]: the phone shortcut that reopens the terminal shows on the
/// Chat tab only.
/// [onChat]: whether the phone shortcut that reopens the terminal shows on
/// this page. Pages whose own bar carries Terminal pass false.
Widget surround(Widget shell, {bool onChat = true, Widget? windows}) =>
TerminalSurface(
hub: hub,
@@ -0,0 +1,11 @@
import '../core/api_gateway.dart';
import '../core/servers/server_scope.dart';
import 'server_endpoint.dart';
/// The scope that isolates a server's pending launch intents. Pipelines and
/// Runs must compute the same scope, or a lost reply could be retried under a
/// different key from the one the Pipelines tab would check.
String pendingRunScope(ApiGateway gateway, ServerEndpoint server) {
final identity = serverIdentity(gateway);
return identity == null ? server.uri?.toString() ?? '' : 'profile:$identity';
}
+18 -4
View File
@@ -41,7 +41,6 @@ import '../shell/windows/window_host.dart';
import '../shell/windows/window_kind.dart';
import '../shell/windows/window_manager.dart';
import '../shell/windows/window_store.dart';
import '../shell/windows/windows_menu_button.dart';
import 'app_terminals.dart';
import '../features/chat/chat_runtime.dart';
import '../features/chat/windows/chat_windows.dart';
@@ -706,6 +705,16 @@ class _PipelinesAppState extends State<PipelinesApp>
}
void _selectDestination(AppDestination destination) {
// Settings is shown from its own nav item and has no Back, so its route
// (filed under the Pipelines tab) must not trap the Pipelines item: that
// item leaves Settings for the Pipelines body it showed before.
if (destination == AppDestination.pipelines &&
_delegate.shellRoute.kind == AppRouteKind.settings) {
_delegate.goTo(
_bodyRoutes[AppDestination.pipelines] ?? AppRoute.pipelines,
);
return;
}
final last = _tabRoutes[destination];
_delegate.goTo(last ?? _routeOf(destination));
}
@@ -818,7 +827,11 @@ class _PipelinesAppState extends State<PipelinesApp>
valueListenable: _attentionCount,
builder: (context, count, _) => _terminals.surround(
_shellFor(route, count),
onChat: route.kind == AppRouteKind.chat,
// Every narrow Chat bar carries Terminal itself (the list's top bar
// and an open chat's bar, see terminalChatBarAction), so the floating
// bubble is off on every route. It otherwise covered the list's
// header and duplicated the open chat's Terminal entry.
onChat: false,
windows: WindowHost(manager: _windows, reservesRail: true),
),
);
@@ -841,9 +854,10 @@ class _PipelinesAppState extends State<PipelinesApp>
// The terminal button sits on the Chat tab's shell bar on wide layouts;
// a narrow layout has it in the chat's own bar instead. The keyboard
// shortcut still toggles the terminal everywhere.
// The Windows button (shown on every tab while the app has floating
// windows) is the shell's: it lists the manager's windows.
windowManager: _windows,
barActions: [
// Shown on every tab while the app has floating windows.
WindowsMenuButton(manager: _windows),
if (_destinationOf(route.kind) == AppDestination.chat)
?_terminals.barToggle(context),
],
@@ -1,10 +1,10 @@
import 'package:flutter/material.dart';
import '../core/servers/server_scope.dart';
import '../features/pipelines/screen.dart';
import '../ui/adaptive/top_bar_notices.dart';
import 'app_session.dart';
import 'connection_status.dart';
import 'pending_run_scope.dart';
import 'server_endpoint.dart';
/// The Pipelines destination: the read-only browser plus honest status.
@@ -82,9 +82,7 @@ class PipelinesDestination extends StatelessWidget {
Widget _pipelinesScreen() => PipelinesScreen(
gateway: session.gateway,
endpoint: serverIdentity(session.gateway) == null
? server.uri?.toString() ?? ''
: 'profile:${serverIdentity(session.gateway)}',
endpoint: pendingRunScope(session.gateway, server),
legacyEndpoints: legacyPendingEndpoints,
embedded: true,
active: active,
@@ -2,11 +2,13 @@ import 'package:flutter/material.dart';
import '../features/attention/notify/notification_controller.dart';
import '../features/attention/runtime/attention_controller.dart';
import '../features/pipelines/pending_run_store.dart';
import '../features/runs/screen.dart';
import '../features/runs/ui/run_pipeline_link.dart';
import '../ui/adaptive/top_bar_notices.dart';
import 'app_session.dart';
import 'connection_status.dart';
import 'pending_run_scope.dart';
import 'server_endpoint.dart';
/// The Runs destination: the loaded screen plus an honest connection status.
@@ -100,6 +102,9 @@ class RunsDestination extends StatelessWidget {
listRefreshToken: listRefreshToken,
notifications: notifications,
attention: attention,
pendingRunStore: SharedPreferencesPendingRunStore(
pendingRunScope(session.gateway, server),
),
onRunSelected: onRunSelected,
onBack: onBack,
onPipelineFilterChanged: onPipelineFilterChanged,
@@ -147,13 +147,11 @@ class _ChatBackgroundTasksState extends State<ChatBackgroundTasks> {
visualDensity: VisualDensity.compact,
),
onPressed: _open,
// The layers turn only while a task runs; automations stay still.
// A ring around the running count while tasks run; automations stay
// on their static schedule icon.
icon: automationOnly
? const Icon(Icons.schedule, size: 16)
: ChatTaskSpinner(
spinning: count > 0,
child: const Icon(Icons.layers_outlined, size: 16),
),
: ChatTaskSpinner(running: count),
label: caption(),
);
return Padding(
@@ -170,7 +168,7 @@ class _ChatBackgroundTasksState extends State<ChatBackgroundTasks> {
: 'Background work, $label; task list unavailable')
: 'Background work, $label',
child: Tooltip(
message: label,
message: count > 0 ? 'Background tasks ($count running)' : label,
excludeFromSemantics: true,
child: button,
),
@@ -1,71 +1,50 @@
import 'package:flutter/widgets.dart';
import 'package:flutter/material.dart';
/// Turns [child] once every [period] while [spinning]; static otherwise. With
/// reduced motion it never turns. Hidden UI is silenced by TickerMode.
class ChatTaskSpinner extends StatefulWidget {
const ChatTaskSpinner({
super.key,
required this.spinning,
required this.child,
});
/// Background-task glyph for the composer. While [running] is above zero it
/// shows a thin Material progress ring around the count; with reduced motion
/// the ring holds one static quarter segment instead of spinning. With no
/// running task it is the plain layers icon, with no ring. Always [size] square
/// so the button keeps the same dimensions in every state.
class ChatTaskSpinner extends StatelessWidget {
const ChatTaskSpinner({super.key, required this.running, this.size = 16});
final bool spinning;
final Widget child;
final int running;
final double size;
/// One full turn while tasks run.
static const Duration period = Duration(milliseconds: 2500);
/// Fraction of the ring drawn while reduced motion holds it still.
static const double reducedSegment = 0.25;
@override
State<ChatTaskSpinner> createState() => _ChatTaskSpinnerState();
}
class _ChatTaskSpinnerState extends State<ChatTaskSpinner>
with SingleTickerProviderStateMixin {
late final AnimationController _turns = AnimationController(
vsync: this,
duration: ChatTaskSpinner.period,
);
bool _reduced = false;
@override
void initState() {
super.initState();
_sync();
}
@override
void didChangeDependencies() {
super.didChangeDependencies();
_reduced = MediaQuery.maybeDisableAnimationsOf(context) ?? false;
_sync();
}
@override
void didUpdateWidget(covariant ChatTaskSpinner oldWidget) {
super.didUpdateWidget(oldWidget);
_sync();
}
void _sync() {
if (widget.spinning && !_reduced) {
if (!_turns.isAnimating) _turns.repeat();
} else {
_turns
..stop()
..value = 0;
}
}
@override
void dispose() {
_turns.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) => RotationTransition(
key: const Key('chat-background-tasks-spinner'),
turns: _turns,
child: widget.child,
);
Widget build(BuildContext context) {
final theme = Theme.of(context);
final reduced = MediaQuery.maybeDisableAnimationsOf(context) ?? false;
final content = running > 0
? Stack(
alignment: Alignment.center,
children: [
SizedBox.square(
dimension: size,
child: CircularProgressIndicator(
strokeWidth: 2,
color: theme.colorScheme.primary,
value: reduced ? reducedSegment : null,
),
),
FittedBox(
fit: BoxFit.scaleDown,
child: Text(
'$running',
key: const Key('chat-background-tasks-count'),
style: theme.textTheme.labelSmall,
),
),
],
)
: Icon(Icons.layers_outlined, size: size);
return SizedBox.square(
key: const Key('chat-background-tasks-spinner'),
dimension: size,
child: content,
);
}
}
@@ -11,6 +11,7 @@ import '../../../../ui/layout/content_width.dart';
import '../../../../core/api_gateway.dart';
import '../../../../shell/shell_bar.dart';
import '../../../../shell/shell_list_shortcuts.dart';
import '../../../terminal/terminal_open_action.dart';
import '../../data/chat_repository.dart';
import '../../domain/chat_colors.dart';
import '../../domain/chat_cycle.dart';
@@ -381,7 +382,7 @@ class _ChatSessionsScreenState extends State<ChatSessionsScreen> {
if (ShellBar.available(context)) {
return ShellBar(
active: widget.publishShellBar ?? widget.activeSessionId == null,
actions: _actions(),
actions: _actions(context),
// The Chat tab counts chats with messages not yet seen.
child: ShellBadge(
kind: ShellBadgeKind.unread,
@@ -396,7 +397,7 @@ class _ChatSessionsScreenState extends State<ChatSessionsScreen> {
alignment: AlignmentDirectional.centerEnd,
child: Row(
mainAxisSize: MainAxisSize.min,
children: _actions(),
children: _actions(context),
),
),
Expanded(child: body),
@@ -406,7 +407,7 @@ class _ChatSessionsScreenState extends State<ChatSessionsScreen> {
return Scaffold(
extendBodyBehindAppBar: true,
appBar: SegmentedBar(title: 'Chats', actions: _actions()),
appBar: SegmentedBar(title: 'Chats', actions: _actions(context)),
// The list scrolls behind the floating bar; New chat is the bar's
// own action, so there is no second create button.
body: body,
@@ -415,18 +416,24 @@ class _ChatSessionsScreenState extends State<ChatSessionsScreen> {
);
}
List<Widget> _actions() => [
ChatBarAction(
key: const Key('chat-new-chat'),
label: 'New chat',
onPressed: _newChat,
materialIcon: Icons.add,
),
ChatBarAction(
key: const Key('chat-refresh'),
label: 'Refresh',
onPressed: _controller.refresh,
materialIcon: Icons.refresh,
),
];
/// New chat, Refresh and, on a narrow layout, the terminal toggle (wide
/// layouts keep it on the shell bar, so it is null here).
List<Widget> _actions(BuildContext context) {
final terminal = terminalChatBarAction(context);
return [
ChatBarAction(
key: const Key('chat-new-chat'),
label: 'New chat',
onPressed: _newChat,
materialIcon: Icons.add,
),
ChatBarAction(
key: const Key('chat-refresh'),
label: 'Refresh',
onPressed: _controller.refresh,
materialIcon: Icons.refresh,
),
?terminal,
];
}
}
@@ -0,0 +1,42 @@
import 'package:flutter/material.dart';
import '../../../ui/motion/motion.dart';
/// The opacity of the surface scrim over an inactive split pane. The pane's
/// transcript and bars keep reading through it at about two thirds emphasis.
const double chatPaneDimOpacity = 0.35;
/// Covers a pane that is not the active one with the theme's surface colour,
/// so the active pane reads as the one in focus. The scrim ignores pointers:
/// taps reach the pane's content, and its activation listener still runs.
/// Reduced motion switches the scrim at once; otherwise it fades briefly.
class ChatPaneDim extends StatelessWidget {
const ChatPaneDim({super.key, required this.dimmed, required this.child});
final bool dimmed;
final Widget child;
@override
Widget build(BuildContext context) {
final surface = Theme.of(context).colorScheme.surface;
return Stack(
fit: StackFit.passthrough,
children: [
child,
Positioned.fill(
child: IgnorePointer(
child: AnimatedContainer(
key: const ValueKey('chat-pane-dim-scrim'),
duration: Motion.of(context, Motion.standard),
curve: Motion.curve,
// The clear end keeps the surface hue, so the fade never greys.
color: dimmed
? surface.withValues(alpha: chatPaneDimOpacity)
: surface.withValues(alpha: 0),
),
),
),
],
);
}
}
@@ -15,6 +15,7 @@ import 'chat_pane_move_motion.dart';
import 'chat_pane_move_shortcuts.dart';
import 'chat_pane_switch_motion.dart';
import 'chat_pane_backdrop.dart';
import 'chat_pane_dim.dart';
import 'chat_workspace_pane_scope.dart';
import 'chat_workspace_surface.dart';
import '../../../ui/input/keyboard_owner.dart';
@@ -509,8 +510,11 @@ class _ChatWorkspaceState extends State<ChatWorkspace>
onPreferredWidthChanged: (width) =>
_reportPaneExtraWidth(pane.id, width),
child: Builder(
builder: (paneContext) =>
widget.paneBuilder(paneContext, pane, active),
builder: (paneContext) => ChatPaneDim(
// A single pane is always the active one, so it never dims.
dimmed: widget.controller.paneCount > 1 && !active,
child: widget.paneBuilder(paneContext, pane, active),
),
),
),
),
+4 -3
View File
@@ -2,7 +2,7 @@ import '../../ui/adaptive/segmented_bar.dart';
import '../../shell/destination.dart';
import '../../shell/detail_page.dart';
import '../../shell/list_detail.dart';
import '../../shell/shell_rail_scope.dart';
import '../../shell/navigation_rail.dart';
import 'package:flutter/material.dart';
import '../../core/api_gateway.dart';
@@ -289,9 +289,10 @@ class _PipelinesScreenState extends State<PipelinesScreen> {
if (listShown && widget.onOpenSchedules != null)
_schedulesButton(context),
_refreshButton(context),
// A wide window's rail offers Settings; the gear stays on a phone.
// The phone's bar and the rail both offer Settings; the gear is only
// left where the floating tab bar (tabs only) is the shell's nav.
if (listShown &&
!ShellRailScope.isShown(context) &&
showsFloatingTabBarOnly(context) &&
widget.onOpenSettings != null)
_settingsButton(context),
],
@@ -1,21 +1,16 @@
import 'package:flutter/material.dart';
import '../../../core/api_gateway.dart';
import '../../../core/transport/connection_state.dart';
import '../../runs/data/runs_repository.dart';
import '../../../ui/adaptive/segmented_bar_overflow.dart';
import '../pipeline_models.dart';
import '../pipelines_controller.dart';
import '../run_pipeline_intent.dart';
import '../widgets/pipeline_bar_buttons.dart';
import 'run_pipeline_dialog.dart';
import 'run_pipeline_flow.dart';
import 'run_pipeline_wording.dart';
/// The pipeline detail's Run action.
///
/// Nothing is requested until the dialog's confirm. A confirmed attempt sends
/// the web's exact `run_pipeline` body against the pinned resolved version; a
/// lost reply keeps the intent so the next deliberate press checks by the same
/// request key before resending. Only the id the server names is opened.
const _runIcon = Icons.play_arrow_rounded;
/// The pipeline detail's Run action: a labelled button that opens the shared
/// start flow ([openRunPipelineFlow]).
class RunPipelineAction extends StatefulWidget {
const RunPipelineAction({
super.key,
@@ -26,8 +21,8 @@ class RunPipelineAction extends StatefulWidget {
this.inBar = false,
});
/// The compact icon-and-word button of a top bar's actions pill instead
/// of an inline button.
/// The compact button of a top bar's actions pill instead of an inline
/// button. A narrow bar moves it into its More menu, labelled.
final bool inBar;
final PipelinesController controller;
@@ -45,143 +40,38 @@ class RunPipelineAction extends StatefulWidget {
class _RunPipelineActionState extends State<RunPipelineAction> {
bool _dialogOpen = false;
int get _pipelineId => widget.detail.id;
int get _version => widget.detail.resolvedVersion;
Future<void> _open() async {
if (_dialogOpen) return;
_dialogOpen = true;
try {
final pending = await widget.controller.loadPendingRun(
_pipelineId,
_version,
);
if (!mounted) return;
await showRunPipelineDialog(
await openRunPipelineFlow(
context: context,
controller: widget.controller,
detail: widget.detail,
gateway: widget.gateway,
pending: pending,
onSubmit: _submit,
onPendingChanged: (intent) {
if (intent == null) {
widget.controller.clearPendingRun(_pipelineId, _version);
} else {
widget.controller.rememberPendingRun(intent);
}
},
onAccepted: _accepted,
onRunStarted: widget.onRunStarted,
);
} finally {
_dialogOpen = false;
}
}
void _accepted(JsonMap run) {
final id = runPipelineRunId(run);
if (id == null) return;
widget.controller.clearPendingRun(_pipelineId, _version);
widget.onRunStarted?.call(id);
}
Future<RunPipelineOutcome> _submit(RunPipelineIntent intent) async {
final repository = RunsRepository(widget.gateway);
final pending = widget.controller.pendingRunFor(
intent.pipelineId,
intent.version,
);
if (pending?.requestKey == intent.requestKey) {
// A previous send may have been admitted even though its reply was lost.
// Check before resending the same key; the server dedupes either way.
try {
final existing = await repository.runByRequestKey(intent.requestKey);
if (existing != null) return _accept(existing);
} catch (error) {
widget.controller.rememberPendingRun(intent);
return RunPipelineRefused(
'${describeRunPipelineError(error)}$runPipelineUnknownSuffix',
admissionUnknown: true,
);
}
}
try {
final run = await repository.startRun(
pipelineId: intent.pipelineId,
version: intent.version,
prompt: intent.prompt,
workspace: intent.workspace,
requestKey: intent.requestKey,
notifyMode: intent.notifyMode.wireValue,
outputFormat: intent.outputFormat.wireValue,
);
final accepted = _accept(run);
if (accepted is RunPipelineAccepted) return accepted;
// A reply without a usable run id is not navigable: read the admitted run
// by key rather than inventing an id or starting another run.
return _refuse(repository, intent, 'The server returned no run id.');
} on ProtocolError catch (error) {
return _refuse(repository, intent, describeRunPipelineError(error));
} on RunsRepositoryException catch (error) {
return _refuse(repository, intent, describeRunPipelineError(error));
} catch (error) {
widget.controller.rememberPendingRun(intent);
return RunPipelineRefused(
'${describeRunPipelineError(error)}$runPipelineUnknownSuffix',
admissionUnknown: true,
);
}
}
/// A reply is only accepted when it names a usable run id.
RunPipelineOutcome _accept(JsonMap run) {
if (runPipelineRunId(run) == null) {
return const RunPipelineRefused(
'The server returned no run id.',
admissionUnknown: false,
);
}
widget.controller.clearPendingRun(widget.detail.id, _version);
return RunPipelineAccepted(run);
}
/// A confirmed refusal: prove by key that no run was admitted before letting
/// the operator correct the fields and try with a fresh key.
Future<RunPipelineOutcome> _refuse(
RunsRepository repository,
RunPipelineIntent intent,
String message,
) async {
try {
final existing = await repository.runByRequestKey(intent.requestKey);
if (existing != null) return _accept(existing);
widget.controller.clearPendingRun(intent.pipelineId, intent.version);
return RunPipelineRefused(message, admissionUnknown: false);
} catch (_) {
// Admission cannot be proven either way: keep the intent immutable.
widget.controller.rememberPendingRun(intent);
return RunPipelineRefused(
'$message$runPipelineUnknownSuffix',
admissionUnknown: true,
);
}
}
@override
Widget build(BuildContext context) {
final label = const Text(runPipelineActionLabel);
if (widget.inBar) {
return pipelineBarIconButton(
context,
key: runPipelineActionKey,
label: 'Run ${widget.detail.displayName}',
icon: Icons.play_arrow_rounded,
onPressed: _open,
);
}
return FilledButton(
final button = FilledButton.icon(
key: runPipelineActionKey,
onPressed: _open,
child: label,
icon: const Icon(_runIcon),
label: const Text(runPipelineActionLabel),
);
if (!widget.inBar) return button;
return SegmentedOverflowAction(
overflowEntry: SegmentedOverflowEntry(
label: runPipelineActionLabel,
icon: _runIcon,
onPressed: _open,
),
child: button,
);
}
}
@@ -0,0 +1,155 @@
import 'package:flutter/material.dart';
import '../../../core/api_gateway.dart';
import '../../../core/transport/connection_state.dart';
import '../../runs/data/runs_repository.dart';
import '../pipeline_models.dart';
import '../pipelines_controller.dart';
import '../run_pipeline_intent.dart';
import 'run_pipeline_dialog.dart';
import 'run_pipeline_wording.dart';
/// The one Run start flow, shared by a pipeline's Run action and the Runs
/// tab's New run picker.
///
/// Nothing is requested until the dialog's confirm. A confirmed attempt sends
/// the web's exact `run_pipeline` body against the pinned resolved version; a
/// lost reply keeps the intent so the next deliberate press checks by the same
/// request key before resending. Only the id the server names is reported.
Future<void> openRunPipelineFlow({
required BuildContext context,
required PipelinesController controller,
required PipelineDetail detail,
required ApiGateway gateway,
ValueChanged<int>? onRunStarted,
}) async {
final pipelineId = detail.id;
final version = detail.resolvedVersion;
final pending = await controller.loadPendingRun(pipelineId, version);
if (!context.mounted) return;
await showRunPipelineDialog(
context: context,
detail: detail,
gateway: gateway,
pending: pending,
onSubmit: (intent) => _submit(controller, gateway, intent),
onPendingChanged: (intent) {
if (intent == null) {
controller.clearPendingRun(pipelineId, version);
} else {
controller.rememberPendingRun(intent);
}
},
onAccepted: (run) {
final id = runPipelineRunId(run);
if (id == null) return;
controller.clearPendingRun(pipelineId, version);
onRunStarted?.call(id);
},
);
}
Future<RunPipelineOutcome> _submit(
PipelinesController controller,
ApiGateway gateway,
RunPipelineIntent intent,
) async {
final repository = RunsRepository(gateway);
final pending = controller.pendingRunFor(intent.pipelineId, intent.version);
if (pending?.requestKey == intent.requestKey) {
// A previous send may have been admitted even though its reply was lost.
// Check before resending the same key; the server dedupes either way.
try {
final existing = await repository.runByRequestKey(intent.requestKey);
if (existing != null) {
return _accept(controller, intent, existing);
}
} catch (error) {
controller.rememberPendingRun(intent);
return RunPipelineRefused(
'${describeRunPipelineError(error)}$runPipelineUnknownSuffix',
admissionUnknown: true,
);
}
}
try {
final run = await repository.startRun(
pipelineId: intent.pipelineId,
version: intent.version,
prompt: intent.prompt,
workspace: intent.workspace,
requestKey: intent.requestKey,
notifyMode: intent.notifyMode.wireValue,
outputFormat: intent.outputFormat.wireValue,
);
final accepted = _accept(controller, intent, run);
if (accepted is RunPipelineAccepted) return accepted;
// A reply without a usable run id is not navigable: read the admitted run
// by key rather than inventing an id or starting another run.
return _refuse(
controller,
repository,
intent,
'The server returned no run id.',
);
} on ProtocolError catch (error) {
return _refuse(
controller,
repository,
intent,
describeRunPipelineError(error),
);
} on RunsRepositoryException catch (error) {
return _refuse(
controller,
repository,
intent,
describeRunPipelineError(error),
);
} catch (error) {
controller.rememberPendingRun(intent);
return RunPipelineRefused(
'${describeRunPipelineError(error)}$runPipelineUnknownSuffix',
admissionUnknown: true,
);
}
}
/// A reply is only accepted when it names a usable run id.
RunPipelineOutcome _accept(
PipelinesController controller,
RunPipelineIntent intent,
JsonMap run,
) {
if (runPipelineRunId(run) == null) {
return const RunPipelineRefused(
'The server returned no run id.',
admissionUnknown: false,
);
}
controller.clearPendingRun(intent.pipelineId, intent.version);
return RunPipelineAccepted(run);
}
/// A confirmed refusal: prove by key that no run was admitted before letting
/// the operator correct the fields and try with a fresh key.
Future<RunPipelineOutcome> _refuse(
PipelinesController controller,
RunsRepository repository,
RunPipelineIntent intent,
String message,
) async {
try {
final existing = await repository.runByRequestKey(intent.requestKey);
if (existing != null) return _accept(controller, intent, existing);
controller.clearPendingRun(intent.pipelineId, intent.version);
return RunPipelineRefused(message, admissionUnknown: false);
} catch (_) {
// Admission cannot be proven either way: keep the intent immutable.
controller.rememberPendingRun(intent);
return RunPipelineRefused(
'$message$runPipelineUnknownSuffix',
admissionUnknown: true,
);
}
}
+88 -13
View File
@@ -11,10 +11,15 @@ import '../attention/notify/notification_controller.dart';
import '../../ui/layout/content_width.dart';
import '../attention/runtime/attention_controller.dart';
import '../attention/runtime/attention_store.dart';
import '../pipelines/pending_run_store.dart';
import '../pipelines/pipeline_repository.dart';
import '../pipelines/pipelines_controller.dart';
import 'actions/decision_action.dart';
import 'data/runs_repository.dart';
import 'data/runs_sort_store.dart';
import 'domain/run_decisions.dart';
import 'ui/new_run_button.dart';
import 'ui/new_run_flow.dart';
import 'ui/run_pipeline_link.dart';
import 'ui/run_detail_view.dart';
import 'ui/run_search_selection.dart';
@@ -47,6 +52,7 @@ class RunsScreen extends StatefulWidget {
this.notifications,
this.attention,
this.sortStore = const SharedPreferencesRunsSortStore(),
this.pendingRunStore = const SharedPreferencesPendingRunStore(''),
});
final ApiGateway gateway;
@@ -94,12 +100,24 @@ class RunsScreen extends StatefulWidget {
/// Where the list's sort choice persists; tests inject a memory store.
final RunsSortStore sortStore;
/// Where a New run's pending launch intent persists, under the same endpoint
/// scope the Pipelines tab uses. Tests inject a memory store.
final PendingRunStore pendingRunStore;
@override
State<RunsScreen> createState() => _RunsScreenState();
}
/// The vertical band the New run button occupies over the list's bottom edge:
/// its margin, the extended button's height and its margin again.
const double _newRunBand = 88;
class _RunsScreenState extends State<RunsScreen> {
late final RunsController controller;
/// Starts a run from the New run picker. Its state is only the pending
/// launch intent; the pipeline itself is read when the operator picks one.
late final PipelinesController _launches;
num? _shownRunId;
int? _reportedPipelineId;
bool _applyingRoutePipeline = false;
@@ -118,6 +136,10 @@ class _RunsScreenState extends State<RunsScreen> {
RunsRepository(widget.gateway),
sortStore: widget.sortStore,
);
_launches = PipelinesController(
PipelinesRepository(widget.gateway),
pendingRunStore: widget.pendingRunStore,
);
// A deleted open run closes its detail; the route returns to the list.
controller.onOpenRunRemoved = () =>
widget.onBack?.call(controller.pipelineId);
@@ -234,6 +256,23 @@ class _RunsScreenState extends State<RunsScreen> {
widget.onBack?.call(controller.pipelineId);
}
/// The New run picker, then the same start flow a pipeline's Run opens.
void _startNewRun() => unawaited(
startNewRunFlow(
context: context,
controller: _launches,
gateway: widget.gateway,
onRunStarted: _newRunStarted,
),
);
/// An accepted launch re-reads the list so its row appears, then opens the
/// run the same way a row tap does.
void _newRunStarted(int id) {
unawaited(controller.resync());
_select(id);
}
@override
void dispose() {
controller.removeListener(_selectionChanged);
@@ -241,6 +280,7 @@ class _RunsScreenState extends State<RunsScreen> {
controller.removeListener(_detailChanged);
_page.dispose();
controller.dispose();
_launches.dispose();
super.dispose();
}
@@ -285,20 +325,55 @@ class _RunsScreenState extends State<RunsScreen> {
onClosed: _back,
builder: (context) => _detail(() => Navigator.of(context).maybePop()),
);
final list = AnimatedBuilder(
animation: controller,
builder: (context, _) => ContentWidth(
child: RunsList(
active: narrow ? !selected : true,
controller: controller,
onSelected: _select,
syncToken: widget.syncToken,
attentionStore: widget.attentionStore,
attentionNow: widget.attentionNow,
notifications: widget.notifications,
attention: widget.attention,
// The New run button floats over the list's bottom-right corner while the
// list is the visible view. The list reserves the button's band in its
// bottom padding, so its last row rests above the button, and the overlay
// lifts clear of the shell's bar like the list's own clearance does.
final list = Stack(
fit: StackFit.expand,
children: [
AnimatedBuilder(
animation: controller,
builder: (context, _) {
final showsButton = !(narrow && selected);
final media = MediaQuery.of(context);
return MediaQuery(
data: media.copyWith(
padding: media.padding.copyWith(
bottom:
media.padding.bottom + (showsButton ? _newRunBand : 0),
),
),
child: ContentWidth(
child: RunsList(
active: narrow ? !selected : true,
controller: controller,
onSelected: _select,
syncToken: widget.syncToken,
attentionStore: widget.attentionStore,
attentionNow: widget.attentionNow,
notifications: widget.notifications,
attention: widget.attention,
),
),
);
},
),
),
AnimatedBuilder(
animation: controller,
builder: (context, _) => narrow && selected
? const SizedBox.shrink()
: Positioned(
left: 16,
right: 16,
bottom: 16 + MediaQuery.paddingOf(context).bottom,
child: Align(
alignment: AlignmentDirectional.bottomEnd,
child: NewRunButton(onPressed: _startNewRun),
),
),
),
],
);
if (narrow) return list;
return ListDetailPanes(
@@ -0,0 +1,17 @@
import 'package:flutter/material.dart';
/// The Runs tab's New run action: an extended floating button that opens the
/// pipeline picker. It is labelled, so it needs no tooltip of its own.
class NewRunButton extends StatelessWidget {
const NewRunButton({super.key, required this.onPressed});
final VoidCallback onPressed;
@override
Widget build(BuildContext context) => FloatingActionButton.extended(
key: const Key('runs-new-run'),
onPressed: onPressed,
icon: const Icon(Icons.add),
label: const Text('New run'),
);
}
@@ -0,0 +1,40 @@
import 'package:flutter/material.dart';
import '../../../core/api_gateway.dart';
import '../../pipelines/pipeline_models.dart';
import '../../pipelines/pipeline_repository.dart';
import '../../pipelines/pipelines_controller.dart';
import '../../pipelines/ui/run_pipeline_flow.dart';
import '../../pipelines/ui/run_pipeline_wording.dart';
import 'new_run_picker.dart';
/// The Runs tab's New run: pick an active pipeline, read its latest version,
/// then the same start flow a pipeline's Run action opens.
Future<void> startNewRunFlow({
required BuildContext context,
required PipelinesController controller,
required ApiGateway gateway,
ValueChanged<int>? onRunStarted,
}) async {
final repository = PipelinesRepository(gateway);
final pipelineId = await pickPipelineForNewRun(context, repository);
if (pipelineId == null || !context.mounted) return;
final PipelineDetail detail;
try {
detail = await repository.getPipeline(pipelineId, 0);
} catch (error) {
if (!context.mounted) return;
ScaffoldMessenger.maybeOf(
context,
)?.showSnackBar(SnackBar(content: Text(describeRunPipelineError(error))));
return;
}
if (!context.mounted) return;
await openRunPipelineFlow(
context: context,
controller: controller,
detail: detail,
gateway: gateway,
onRunStarted: onRunStarted,
);
}
@@ -0,0 +1,143 @@
import 'package:flutter/material.dart';
import '../../pipelines/pipeline_models.dart';
import '../../pipelines/pipeline_repository.dart';
import '../../pipelines/ui/run_pipeline_wording.dart';
/// Whether an active pipeline matches a picker search by name. An empty query
/// matches every pipeline.
bool pipelineMatchesQuery(PipelineSummary pipeline, String query) {
final needle = query.trim().toLowerCase();
if (needle.isEmpty) return true;
return pipeline.displayName.toLowerCase().contains(needle);
}
/// Opens the searchable list of active pipelines. Resolves to the chosen
/// pipeline's id, or null when the picker is dismissed.
Future<int?> pickPipelineForNewRun(
BuildContext context,
PipelinesRepository repository,
) => showDialog<int>(
context: context,
builder: (_) => _PipelinePicker(repository: repository),
);
class _PipelinePicker extends StatefulWidget {
const _PipelinePicker({required this.repository});
final PipelinesRepository repository;
@override
State<_PipelinePicker> createState() => _PipelinePickerState();
}
class _PipelinePickerState extends State<_PipelinePicker> {
late Future<List<PipelineSummary>> _pipelines = _loadActive();
String _query = '';
/// Archived pipelines cannot run, so the picker offers only active ones.
Future<List<PipelineSummary>> _loadActive() async {
final all = await widget.repository.listPipelines();
return all.where((pipeline) => !pipeline.archived).toList(growable: false);
}
void _retry() => setState(() => _pipelines = _loadActive());
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
return Dialog(
child: ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 480, maxHeight: 560),
child: Padding(
padding: const EdgeInsets.all(16),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Text('Choose a pipeline', style: theme.textTheme.titleLarge),
const Padding(padding: EdgeInsets.only(top: 12)),
TextField(
key: const Key('new-run-search'),
decoration: const InputDecoration(
hintText: 'Search pipelines',
prefixIcon: Icon(Icons.search),
),
onChanged: (value) => setState(() => _query = value),
),
const Padding(padding: EdgeInsets.only(top: 8)),
Flexible(child: _body(context)),
],
),
),
),
);
}
Widget _body(BuildContext context) {
return FutureBuilder<List<PipelineSummary>>(
future: _pipelines,
builder: (context, snapshot) {
if (snapshot.connectionState != ConnectionState.done) {
return const Padding(
padding: EdgeInsets.all(24),
child: Center(child: CircularProgressIndicator()),
);
}
if (snapshot.hasError) {
return Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
describeRunPipelineError(snapshot.error!),
style: TextStyle(color: Theme.of(context).colorScheme.error),
),
TextButton(onPressed: _retry, child: const Text('Retry')),
],
);
}
final active = snapshot.data ?? const <PipelineSummary>[];
if (active.isEmpty) {
return const _Notice('No active pipelines.');
}
final matches = active
.where((pipeline) => pipelineMatchesQuery(pipeline, _query))
.toList(growable: false);
if (matches.isEmpty) {
return const _Notice('No pipeline matches the search.');
}
return ListView(
shrinkWrap: true,
children: [
for (final pipeline in matches)
ListTile(
key: ValueKey<String>('new-run-pipeline-${pipeline.id}'),
title: Text(
pipeline.displayName,
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
subtitle: Text(
'v${pipeline.version} · ${pipeline.stages} stages',
),
onTap: () => Navigator.of(context).pop(pipeline.id),
),
],
);
},
);
}
}
class _Notice extends StatelessWidget {
const _Notice(this.message);
final String message;
@override
Widget build(BuildContext context) => Padding(
padding: const EdgeInsets.all(16),
child: Text(message, style: TextStyle(color: Theme.of(context).hintColor)),
);
}
@@ -61,7 +61,7 @@ const walkthroughSteps = <WalkthroughStep>[
points: <String>[
'Pipelines tab: open a workflow and fill in its inputs.',
'Runs tab: follow a run as it works, then read what it produced.',
'Choose Run on a workflow to start one.',
'Press Run on a workflow, or New run on the Runs tab, to start one.',
],
),
WalkthroughStep(
+48 -2
View File
@@ -17,6 +17,8 @@ import 'shell_list_shortcuts.dart';
import 'shell_runs_pipelines_shortcut.dart';
import 'shell_search_shortcut_labels.dart';
import 'tab_history.dart';
import 'windows/window_manager.dart';
import 'windows/windows_menu_button.dart';
import '../ui/input/keyboard_owner.dart';
class AdaptiveShell extends StatefulWidget {
@@ -33,12 +35,18 @@ class AdaptiveShell extends StatefulWidget {
this.runningRunCount,
this.listPaneWidthStore = const SharedPreferencesListPaneWidthStore(),
this.barActions = const [],
this.windowManager,
});
/// Actions every destination's bar ends with (the Terminal toggle), after
/// the screen's own or Search.
final List<Widget> barActions;
/// The floating windows the bar's Windows button lists. The button is shown
/// only while one is open, so the bar draws no empty action island; null
/// (plain shells) shows none.
final WindowManager? windowManager;
/// Where each destination's dragged list-pane width is kept on this device.
final ListPaneWidthStore listPaneWidthStore;
@@ -77,6 +85,11 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
late AppDestination _selected;
final Set<AppDestination> _visited = {};
final TabHistory _history = TabHistory();
// The destination a shell control (rail, bar, floating bar) asked for and
// that is not shown yet. Settings reached this way is a destination; any
// other way in (a route, a deep link, the Pipelines gear) is a page to Back.
AppDestination? _navigatingTo;
bool _settingsPushed = false;
// Whether a navigator inside each destination (an open item's pane) has a
// page of its own for the system Back to close first.
final Map<AppDestination, bool> _nestedCanPop = {};
@@ -100,6 +113,9 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
super.initState();
_bar.onNavigate = _select;
_selected = widget.destination ?? AppDestination.pipelines;
// A first load that opens Settings (a deep link, a restored page) was not
// reached from a shell control, so its Back closes the page.
_settingsPushed = _selected == AppDestination.settings;
_visited.add(_selected);
HardwareKeyboard.instance.addHandler(_handleDestinationKeyEvent);
}
@@ -109,12 +125,23 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
super.didUpdateWidget(oldWidget);
final destination = widget.destination;
if (destination != null) {
if (destination != _selected) _noteShown(destination);
_history.record(_selected, destination);
_selected = destination;
_visited.add(destination);
}
}
/// Records that [destination] is becoming the shown one. Settings opened by
/// a shell control is a destination (no Back); opened any other way it is a
/// page that Back closes.
void _noteShown(AppDestination destination) {
if (destination == AppDestination.settings) {
_settingsPushed = _navigatingTo != AppDestination.settings;
}
_navigatingTo = null;
}
/// The entry every tab control calls when tapped: a destination shown
/// already is re-selected (see [AdaptiveShell.onDestinationReselected]), any
/// other is selected.
@@ -124,6 +151,13 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
reselected(destination);
return;
}
if (destination != _selected) {
_navigatingTo = destination;
// A selection the route never applies must not mark a later route.
WidgetsBinding.instance.addPostFrameCallback((_) {
if (mounted && _navigatingTo == destination) _navigatingTo = null;
});
}
_select(destination);
}
@@ -134,6 +168,7 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
return;
}
setState(() {
if (destination != _selected) _noteShown(destination);
_history.record(_selected, destination);
_selected = destination;
_visited.add(destination);
@@ -241,7 +276,11 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
SegmentedBar currentBar() =>
_segmentedBar(_bar.specFor(_selected), details.label, page: page);
final topBar = _ListPaneBar(
listenable: Listenable.merge([_bar.bar, _paneWidths]),
listenable: Listenable.merge([
_bar.bar,
_paneWidths,
?widget.windowManager,
]),
initial: currentBar(),
split: () => _bar.split(_selected),
preferredWidth: () => _paneWidths.widthFor(_selected.name),
@@ -440,9 +479,12 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
String label, {
required bool page,
}) {
final onBack = spec?.onBack ?? (page ? _closePage : null);
// Settings reached from a shell control has no Back: it is a destination.
final onBack =
spec?.onBack ?? (page && _settingsPushed ? _closePage : null);
final published = spec?.actions ?? const <Widget>[];
final onSearch = widget.onSearch;
final windows = widget.windowManager;
return SegmentedBar(
automaticallyImplyLeading: false,
leading: onBack == null
@@ -477,6 +519,10 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
tooltip: 'Search (${shellSearchShortcutLabels().join(', ')})',
icon: const Icon(Icons.search),
),
// The Windows button leads the shell's own actions, only while a
// floating window is listed; an empty button would draw an empty island.
if (windows != null && WindowsMenuButton.hasWindows(windows))
WindowsMenuButton(manager: windows),
...widget.barActions,
],
);
+4 -3
View File
@@ -2,10 +2,11 @@ import 'package:flutter/material.dart';
enum AppDestination { pipelines, runs, chat, search, settings }
/// The destinations the shell's tab bar (or, on a wide window, its rail) offers,
/// The tabs the shell's floating tab bar (or, on a wide window, its rail) offers,
/// in order. Settings is a destination the shell can show (its route is
/// `/settings`), but it opens as a page, from the rail's foot on a wide window
/// or the Pipelines bar's gear on a phone, instead of being a tab.
/// `/settings`) and the rail and phone bar offer it too; it is a page of the
/// Pipelines tab, not a tab. Only the floating bar's width leaves Settings to
/// the Pipelines bar's gear.
const List<AppDestination> shellTabDestinations = [
AppDestination.pipelines,
AppDestination.runs,
+42 -27
View File
@@ -22,6 +22,12 @@ const double kNavigationRailMinWindowWidth =
bool showsNavigationRail(BuildContext context) =>
MediaQuery.sizeOf(context).width >= kNavigationRailMinWindowWidth;
/// Whether the window shows the floating tab bar alone: wide enough for a list
/// beside an open item, too narrow for the rail. That bar lists the tabs only,
/// so there Settings is reached from the Pipelines bar's gear.
bool showsFloatingTabBarOnly(BuildContext context) =>
showsListBesideDetail(context) && !showsNavigationRail(context);
/// The wide layout's left-edge navigation: a Material [NavigationRail] with
/// an icon and a label per tab, the selected tab marked by the rail's
/// indicator, and Settings pinned to its bottom.
@@ -50,35 +56,44 @@ class ShellNavigationRail extends StatelessWidget {
@override
Widget build(BuildContext context) {
final index = shellTabDestinations.indexOf(selected);
return Padding(
padding: padding,
child: SizedBox(
width: kNavigationRailWidth,
child: NavigationRail(
key: const ValueKey('shell.navigation-rail'),
minWidth: kNavigationRailWidth,
labelType: NavigationRailLabelType.all,
selectedIndex: index < 0 ? null : index,
onDestinationSelected: (value) =>
onSelected(shellTabDestinations[value]),
destinations: [
for (final destination in shellTabDestinations)
NavigationRailDestination(
icon: KeyedSubtree(
key: ValueKey('shell.destination.${destination.name}'),
// The bar it replaces named each tab in a tooltip too.
child: Tooltip(
message: destinationDetails(destination).label,
child: icon(destination),
final surface = Theme.of(context).colorScheme.surface;
// The surface runs under the top inset too: the padding only moves the
// rail's content below the system's top, so no unpainted strip shows above
// the rail's background.
return ColoredBox(
key: const ValueKey('shell.navigation-rail.surface'),
color: surface,
child: Padding(
padding: padding,
child: SizedBox(
width: kNavigationRailWidth,
child: NavigationRail(
key: const ValueKey('shell.navigation-rail'),
backgroundColor: surface,
minWidth: kNavigationRailWidth,
labelType: NavigationRailLabelType.all,
selectedIndex: index < 0 ? null : index,
onDestinationSelected: (value) =>
onSelected(shellTabDestinations[value]),
destinations: [
for (final destination in shellTabDestinations)
NavigationRailDestination(
icon: KeyedSubtree(
key: ValueKey('shell.destination.${destination.name}'),
// The bar it replaces named each tab in a tooltip too.
child: Tooltip(
message: destinationDetails(destination).label,
child: icon(destination),
),
),
label: Text(destinationDetails(destination).label),
),
label: Text(destinationDetails(destination).label),
),
],
trailingAtBottom: true,
trailing: _SettingsRailItem(
selected: selected == AppDestination.settings,
onTap: () => onSelected(AppDestination.settings),
],
trailingAtBottom: true,
trailing: _SettingsRailItem(
selected: selected == AppDestination.settings,
onTap: () => onSelected(AppDestination.settings),
),
),
),
),
@@ -12,6 +12,11 @@ class WindowsMenuButton extends StatelessWidget {
final WindowManager manager;
/// Whether [manager] has a window to list: the shell bar keeps the button
/// out of its actions otherwise, so no empty action island is drawn.
static bool hasWindows(WindowManager manager) =>
manager.windows.any((w) => manager.kinds[w.kind] != null);
@override
Widget build(BuildContext context) => ListenableBuilder(
listenable: Listenable.merge([
+41
View File
@@ -0,0 +1,41 @@
# Background tasks ring (composer)
Replaces the rotating layers icon in the composer's background-tasks button.
## Behaviour
- `chat_task_spinner.dart`: `ChatTaskSpinner(running:)`, 16 px square in every state.
- `running > 0`: Material `CircularProgressIndicator` (indeterminate, stroke 2,
primary colour) with the running count centred inside (`FittedBox` scales
the digit down under large text scaling).
- reduced motion (`MediaQuery.disableAnimations`): the same ring holds one
static quarter segment (`value: 0.25`) instead of spinning.
- `running == 0`: static `Icons.layers_outlined`, no ring.
- `chat_background_tasks.dart`: automation-only state keeps its static schedule
icon. Tooltip with running tasks is `Background tasks (N running)`; without
running tasks it keeps the caption label (e.g. `1 automation`, `Tasks`).
Semantics label is unchanged.
- Button size, padding and caption are unchanged.
## Tests (memwatch, from app/)
| Run | Paths | Result |
|---|---|---|
| 1 | `chat_task_spinner_test`, `chat_background_tasks_test`, `chat_background_tasks_modal_test`, `chat_background_task_metadata_test`, `chat_background_tasks_gui_test`, `chat_background_tasks_controller_test`, `chat_automation_lifecycle_test` | FAIL 37/38 (`chat_background_tasks_test` "combined caption..." — my test's `find.descendant` on the count key; fixed) |
| 2 | same seven paths | PASS 38/38, exit 0 |
`tool/analyze.sh`: clean, exit 0.
Test expectation changes (all from the requested behaviour):
- `chat_task_spinner_test.dart` rewritten for the ring: indeterminate value,
stroke 2, primary colour (light and dark), count text, same 16 px size in
every state, reduced-motion static segment, tooltip on the composer button.
- `chat_background_tasks_test.dart`: tooltip `2 tasks, 12 automations` became
`Background tasks (2 running)`; the composer count now also appears inside the
ring, so the caption check expects two `2` texts and the ring's count is checked
by its key.
## Not verified here
- Light/dark captures and rendered checks were not done in this stage; ui-review owns them.
- No device or browser run.
+3 -3
View File
@@ -21,9 +21,9 @@
- **More menu Stop.** `chat_thread_view.dart` adds a `Stop` item to the header's
More menu while a turn runs (`key chat-thread-stop-menu`). It is shown on every
platform, so touch devices without a keyboard can stop.
- **Tasks spinner.** `chat_task_spinner.dart` turns the layers icon once per
2.5 s while at least one background task runs; static otherwise and under
reduced motion. Automation-only state keeps its static schedule icon.
- **Tasks spinner.** Superseded: `chat_task_spinner.dart` now draws a progress
ring with the running count instead of turning the layers icon. See
`notes/background-tasks-ring.md`.
## Focused tests (memwatch, from app/)
+40
View File
@@ -0,0 +1,40 @@
# Dim inactive chat panes
## Change
- `lib/features/chat/workspace/chat_pane_dim.dart` (new): `ChatPaneDim` lays an
`IgnorePointer` surface scrim over a pane's content. The scrim is the theme's
`colorScheme.surface` at `chatPaneDimOpacity` (0.35), so content reads at
about 65% emphasis in light and dark. Its colour fades over `Motion.standard`;
`Motion.of` returns zero under reduced motion, so the change is immediate.
- `lib/features/chat/workspace/chat_workspace.dart`: `_paneContent` wraps each
pane's built content in `ChatPaneDim(dimmed: paneCount > 1 && !active)`.
Pointer activation (the pane `Listener`), focus and the action bar's
existing tint (`ChatPaneActivity`) are unchanged. The scrim ignores pointers,
so a tap reaches the content beneath it and still activates the pane.
- The optional primary outline is not added. The active pane already has its
chat-coloured foreground border (`chat_screen_workspace.dart`).
## Tests
- `test/features/chat/workspace/chat_pane_dim_test.dart` (new, 7 tests):
two panes dim only the inactive one; three panes dim both inactive panes;
a single pane is never dimmed; a tap on an inactive input activates it and
focuses its editable text; a tap on bare space in an inactive pane activates
it; reduced motion gives a zero duration and an immediate switch; default
motion uses `Motion.standard`.
- Existing users of `ChatWorkspace` also run: `chat_workspace_test`,
`chat_pane_move_test`, `chat_center_stage_test`, `chat_switch_styles_test`,
`chat_mobile_panes_test`, `chat_peek_identity_test`, and
`test/features/settings/quick_switch_preview_test.dart`.
Command (from `app/`):
`tool/memwatch/full.sh 'test/features/chat/workspace/chat_pane_dim_test.dart test/features/chat/workspace/chat_workspace_test.dart test/features/chat/workspace/chat_pane_move_test.dart test/features/chat/workspace/chat_center_stage_test.dart test/features/chat/workspace/chat_switch_styles_test.dart test/features/chat/workspace/chat_mobile_panes_test.dart test/features/chat/workspace/chat_peek_identity_test.dart test/features/settings/quick_switch_preview_test.dart'`
Result: `PASS: 70 passed, 0 failed, 0 skipped; peak 1329 MB; 11s; exit 0`.
Analyzer (`tool/analyze.sh`): clean, exit 0.
## Not done here
- No captures. The 2- and 3-pane light and dark captures belong to ui-review
(`tool/capture/`), and no UI was built or run in this stage.
- No test or capture covers the chat screen's full path (`chat_screen_workspace.dart`).
The dim comes from `ChatWorkspace`, which that screen uses, so it applies there too.
@@ -0,0 +1,67 @@
# Phone chat list: terminal button over the Chats header
## Defect
At 430px the floating terminal shortcut (`TerminalShortcutBubble`, end 12,
top = safe top + 64) sat on the chat list's `Chats` section header at
[370,64,48,48]. It hid the header's count and collapse chevron and left a
stray glyph beside it. Evidence: `/tmp/ui-review/base-light-430x900/07-chat.png`,
`/tmp/ui-review/chatmenus-light-430x900/01-chatlist-more.png`.
Run 393 had removed a duplicate terminal icon from the narrow list bar, so the
list had only the floating bubble.
## Change
- `lib/features/chat/ui/sessions/chat_sessions_screen.dart`: `_actions(context)`
now appends `terminalChatBarAction(context)` after New chat and Refresh. It is
null on wide layouts (the shell bar keeps Terminal there) and with no
terminal surface, so it appears only on a narrow layout with a surface.
- `lib/application/pipelines_app.dart`: the floating bubble's `onChat` is now
`false` on every route. On a narrow layout every Chat-tab bar carries Terminal
itself (the list's top bar, and an open chat's bar via
`chat_thread_view.dart`'s `terminalChatBarAction`), so the bubble has no
remaining place. The earlier rule (`kind == chat && chatSessionId != null`)
still showed it on an open chat, duplicating that chat's Terminal entry.
- `lib/application/app_terminals.dart`: doc comment for `surround(onChat:)`
now says pages whose own bar carries Terminal pass false. No behaviour change.
Result on a phone: exactly one terminal entry on the chat list (top bar) and on
an open chat (its bar), and no floating control over any header.
## Focused tests (memwatch, from app/)
- `test/application/phone_chat_terminal_entries_test.dart`: new, 2 tests at
430x900 through the app shell. `/chat` and `/chat/abc123` each have no
`TerminalShortcutBubble` and exactly one Terminal `ChatBarAction`.
Against the previous `onChat` rule the open-chat test FAILS (the bubble is
shown), so it guards the reviewer's finding. Restored after that check.
- `test/features/chat/ui/sessions/chat_list_terminal_action_test.dart`: 4 tests.
Narrow top bar carries Terminal beside New chat and Refresh, and tapping it
toggles. The Chats heading sits below the bar. Wide has no list terminal.
No terminal surface has no list terminal.
- Users of the changed wiring, all in the same run:
- `test/application/pipelines_app_test.dart`
- `test/features/terminal/terminal_surface_test.dart`
- `test/features/chat/ui/sessions/chat_sessions_floating_bar_test.dart`
- `test/features/chat/ui/sessions/chat_sessions_screen_test.dart`
Combined run of these six plus the list test: PASS 28/28 (`memwatch: PASS`,
exit 0), run after the final edit.
- Not re-run in this pass: `test/features/chat/shell/chat_shell_terminal_test.dart`
and `chat_shell_terminal_session_test.dart` (listed as users in an earlier
pass). The `onChat` change does not touch the shell's wide path.
- `tool/analyze.sh`: clean (0 errors, 0 warnings, 0 infos) after the final edit.
## Not verified here
- No rendered capture. The before/after screenshots at 430x900 are for ui-review.
- The open-chat test checks the Terminal action by label, not by semantics
identifier. In the open chat's bar the identifier lookup found nothing even
though the action is present, so this is a limit of the probe, not evidence
of a missing entry. A capture is needed to confirm what is drawn.
## Open limitations
- `TerminalShortcutBubble` is now never shown by the app shell (`onChat` is
always false). It and `TerminalSurface`'s shortcut code remain, with their
own tests. Removing them is a follow-up if the owner agrees.
- A narrow Chat-tab route with no chat bar would now have no terminal entry at
all. None was found in the code, but this was not exhaustively checked.
- The bubble's old top edge on an open chat was not checked against that chat's
bar; with the bubble gone that check is moot.
+73
View File
@@ -0,0 +1,73 @@
# Rail top strip and empty top-right island
Two shell chrome defects on the wide layout (run 20261112-1022).
## Causes
- **White strip above the rail (96x8 at y=0).** On a wide window
`WindowMargins` adds `wideExtraTop` (16 - 8 = 8 px) to `MediaQuery` top
padding. `ShellNavigationRail` pads its rail by that top inset with a plain
`Padding`, so the 8 px above the rail's Material surface was never painted
and showed the canvas behind it (white in both themes).
- **Empty circular pill (top right of Search and Settings).**
`pipelines_app.dart` put `WindowsMenuButton` in `barActions` on every tab.
The button returns `SizedBox.shrink()` with no open window, but
`SegmentedBar` counted it as an action, so the trailing island was drawn
around nothing.
## Changes (app/)
- `lib/shell/navigation_rail.dart`: the rail is wrapped in a `ColoredBox`
(key `shell.navigation-rail.surface`) in the theme surface, and the
`NavigationRail` gets the same `backgroundColor`. The top inset still moves
the rail's content down; the inset itself is painted.
- `lib/shell/windows/windows_menu_button.dart`: new static
`WindowsMenuButton.hasWindows(manager)`, the single predicate for "a window
is listed".
- `lib/shell/adaptive_shell.dart`: new optional `windowManager` parameter.
The shell adds the Windows button to the bar's actions only when
`hasWindows` is true, and merges the manager into the top bar's listenable
so the island appears and disappears with windows.
- `lib/application/pipelines_app.dart`: the Windows button is no longer in
`barActions`; `windowManager: _windows` is passed to the shell instead.
## Tests (focused, run through tool/memwatch/full.sh)
Paths: `test/shell/navigation_rail_surface_test.dart`,
`test/shell/shell_bar_empty_actions_test.dart`,
`test/shell/navigation_rail_test.dart` (existing, affected by the rail
change), `test/shell/windows/window_conveniences_test.dart` (existing, uses
`WindowsMenuButton` directly).
- Result: `PASS: 28 passed, 0 failed, 0 skipped; peak 1128 MB; 4s; exit 0`.
- Rail surface, light and dark: the cover is at y=0, its colour equals the
theme surface, the rail's background equals it, the rail content starts at
the 8 px inset, and the strip above it is inside the cover.
- Action island: Search, Settings and Pipelines at 1000 px and 430 px draw no
`segmented.actions` island with no window; a shell with no window manager
draws none; the Windows button is the island only while a window is open
and goes away when it closes.
`tool/analyze.sh`: clean, exit 0.
Not run: the land gate and the full app suite (owned by the gate stage).
Pre-existing failures listed in the memory note were not checked here.
## Affected UI states (for ui-review to capture)
- Wide window (1600x1000), light and dark: rail top (should now be the
surface colour, not white), on every tab and on Settings.
- Wide and narrow (430x900), Search and Settings: no empty pill at top right.
- Wide window with one or more floating windows open: the Windows button is
shown in the top-right island.
Before-captures exist in `/tmp/ui-review/` (`base-dark-1600x1000/12-settings.png`,
`base-light-430x900/11-search.png`, and others). No after-captures were
taken in this stage, per the stage rules; ui-review owns capture.
## Limitations
- The "rail top colour equals rail surface" check is a widget-tree check
(colour and rect), not a pixel read from a rendered frame.
- `WindowMargins` (the source of the 8 px) is untouched; the fix is at the
rail, so the rail's content position is unchanged.
+72
View File
@@ -0,0 +1,72 @@
# Settings destination: Back only when pushed; one Settings entry per screen
Run 20261112-1022 (stage 01-implement). Not committed.
## Rule
- Settings opened from a shell control (rail item, phone bar item) is a
destination: no Back arrow. The Pipelines item leaves it for the Pipelines body.
- Settings opened any other way (a first load / deep link to `/settings`, a route
change that is not a shell control, the Pipelines gear) is a pushed page: Back
returns to Pipelines.
- The Pipelines bar's gear is kept only where the floating tab bar is the shell's
sole navigation (window width at least 600 and below the rail's 697; see
`showsFloatingTabBarOnly`). There the floating bar lists tabs only, so the gear
is the one Settings entry. The phone bar and the rail both offer Settings, so the
gear is gone there.
## Changed paths (app/)
- `lib/shell/adaptive_shell.dart`: `_navigatingTo` / `_settingsPushed`; `_noteShown`
is called on a shown-destination change; Back is built only when Settings is
pushed.
- `lib/shell/navigation_rail.dart`: `showsFloatingTabBarOnly(context)`.
- `lib/shell/destination.dart`: doc comment only.
- `lib/features/pipelines/screen.dart`: the bar's gear is shown only when
`showsFloatingTabBarOnly`; the rail check is gone. The non-shell paths keep the gear.
- `lib/application/pipelines_app.dart`: `_selectDestination` leaves Settings for the
Pipelines body (`_bodyRoutes`) instead of re-selecting the Settings route filed
under the Pipelines tab (the nav-only Settings has no Back, so without this the
Pipelines item would trap the user on Settings).
- Tests, new: `test/shell/settings_back_test.dart` (nav selection has no Back; route
push has Back and returns; first load has Back; nav after pushed clears Back);
`test/features/pipelines/pipelines_settings_gear_test.dart` (phone and rail: no
gear; floating band: gear present and its handler opens Settings).
- Tests, changed: `test/application/settings_page_test.dart`,
`test/application/tab_location_navigation_test.dart`,
`test/application/settings_registration_test.dart`,
`test/shell/navigation_rail_test.dart`. They now tap the nav item instead of the gear
and expect no Back on nav-opened Settings.
## Focused results (memwatch, from app/)
- New shell + gear tests and shell/rail/bar files: 54 passed, 0 failed.
(`settings_back_test`, `pipelines_settings_gear_test`, `navigation_rail_test`,
`shell_bar_test`, `tab_history_back_test`, `shell_navigation_bar_test`,
`split_destination_bar_test`, `pipelines_screen_filter_test`)
- Final run over all affected files (12 paths): 60 passed, 7 failed. The 7 are all
app-level tests that fail on HEAD for the same reason (see below). None is new.
- `settings_page_test`: "390 ... no gear ..." and "1200 ... rail ..."
- `tab_location_navigation_test`: "Settings is retained ...", "a delayed read ...",
"an explicit root URL ...", "Settings does not clear ..."
- `settings_registration_test`: "Settings shares socket and one native bar"
- Baseline check: a copy of app/ with HEAD's versions of the edited files fails the
same tests in the same way (`Expected: '/settings' Actual: '/pipelines'` after a
nav tap, and `Found 0 widgets with key 'segmented.more'` for the gear at 390).
`templates_wiring_test` passes on both.
- `tool/analyze.sh`: clean (0 errors, 0 warnings, 0 infos).
## Limitations
- App-level Settings navigation is not verified by these tests: a tap on the Settings
nav item does not change the route in this harness, on HEAD or on this change. The
behaviour is covered at shell level (`settings_back_test`) and by the gear test.
- System Back on a nav-opened Settings still closes to Pipelines (the shell's
PopScope is unchanged).
- The mid-width band keeps the gear by design (the floating bar has no Settings
entry). Adding Settings to the floating bar would remove it; not done here.
- Not built or captured here (ui-review owns that). States to re-capture:
- `base-light-430x900/12-settings.png` and `circle/01-hover.png`: Settings from the
nav has no Back arrow.
- `base-light-430x900/01-pipelines.png`: no Settings gear in the Pipelines header.
- A width between 600 and 696: the gear stays, and it opens Settings with Back.
+98
View File
@@ -0,0 +1,98 @@
# Starting a run: labelled entry points
## Change
- Pipeline detail: the icon-only play button in the top bar is now a labelled
`FilledButton.icon` "Run" (same key, `runPipelineActionKey`). In a narrow bar
it moves into the More menu with its label, via the existing
`SegmentedOverflowAction`.
- Runs: an extended "New run" button (`runs-new-run`) floats over the list's
bottom-right corner while the list is the visible view (phone list, or the
desktop list pane). It sits above the shell's bottom bar: the button's bottom
is lifted by the body's bottom padding, the same inset the list clears. While
it is shown, the list's bottom padding also reserves its band (`_newRunBand`
in `lib/features/runs/screen.dart`), so the last row should rest above the button (no test covers this; ui-review to confirm).
It opens a searchable picker of active pipelines (archived ones are
withheld), reads the chosen pipeline's latest version, then opens the same
start dialog the Run button opens.
- The start flow moved out of `RunPipelineAction` into
`lib/features/pipelines/ui/run_pipeline_flow.dart` (`openRunPipelineFlow`),
so both entry points share one submit, pending-intent and accept path.
- The pending-intent store on Runs uses the same endpoint scope as Pipelines
(`lib/application/pending_run_scope.dart`).
- Walkthrough step 3 now reads: "Press Run on a workflow, or New run on the
Runs tab, to start one."
## Fix for ui-review rejection (visit 1)
- Defect: on a phone the "New run" button sat beneath the bottom navigation
(semantics rect y=928-984 at 430x900), so it was hidden and a tap reached
Settings.
- Cause: the button was the last child of a column under the list, and the
shell's body extends under the bar (`extendBody`), so the bottom of the
column was under the bar.
- Fix: the button is now an overlay positioned above the body's bottom inset,
and the list reserves the band. Desktop uses the same overlay.
- Tried first and rejected: wrapping the list in a `Column` with the button as
a second child (in both an `Expanded` and an outer form). It fixed the phone
position but broke row selection on desktop (`list_detail_consistency_test`
"selected rows" at 640 wide: row 1 kept its selected flag after row 2 was
opened). The overlay keeps the list as a direct child and passes that test.
## Files
- Source: `lib/features/pipelines/ui/run_pipeline_action.dart`,
`lib/features/pipelines/ui/run_pipeline_flow.dart` (new),
`lib/features/runs/screen.dart`, `lib/features/runs/ui/new_run_button.dart`
(new), `lib/features/runs/ui/new_run_flow.dart` (new),
`lib/features/runs/ui/new_run_picker.dart` (new),
`lib/application/pending_run_scope.dart` (new),
`lib/application/pipelines_destination.dart`,
`lib/application/runs_destination.dart`,
`lib/features/walkthrough/walkthrough_steps.dart`.
- Tests: `test/features/runs/ui/new_run_test.dart` (new),
`test/features/pipelines/ui/run_pipeline_launch_test.dart` (one case added),
`test/features/runs/ui/runs_list_refresh_test.dart` (finder scoped to the list
rows; its expectations are unchanged).
## Regression coverage for the rejection
- `new_run_test.dart` "New run clears the bottom bar and opens the picker on a
phone": the screen sits in a scaffold with `extendBody` and a NavigationBar,
as the shell does. It asserts the button's bottom is at or above the bar's
top, and that a tap on the button opens the picker. Before the fix it failed
(button bottom 884, bar top 820).
## Focused results (visit 2)
Command: `tool/memwatch/full.sh` with 19 test files (the new-run and launch
tests plus every test file that builds RunsScreen, the Pipelines Run action, the
Pipelines screen, Settings, or the walkthrough).
- 119 passed, 1 failed. Verdict named only the intended paths.
- Failing: `test/application/run_start_wiring_test.dart` "an accepted launch
opens the returned run and re-reads the runs list exactly once". It also fails
on untouched `main` (checked in a temporary main worktree, since removed): it
times out waiting for `get_pipeline` after tapping `pipeline-row-1`.
- `list_detail_consistency_test.dart`: passes (it failed with the rejected
`Column` layout; see Fix above).
- `new_run_test.dart`: 5 passed, including the phone bottom-bar case.
- `tool/analyze.sh`: clean (exit 0).
## Affected UI states (for ui-review to re-capture; not captured here)
1. Pipeline detail, wide bar: labelled "Run" next to the list and more icons.
2. Pipeline detail, narrow phone bar: Run should move into More, labelled.
3. Runs list, phone (430x900): "New run" floats above the bottom bar, clear of
the last row at rest. This is the rejected state; it must be re-captured.
4. Runs list, desktop: "New run" floats over the list pane's bottom-right.
5. New run picker: default, searching, no match, no active pipelines, error+retry.
6. Start dialog reached from the picker.
7. Walkthrough step 3 copy.
Before captures: `/tmp/ui-review/pipe-light-430x900/01-pipeline-detail.png`
(play icon unlabelled) and `/tmp/ui-review/base-light-430x900/03-runs.png`
(no New run).
## Limitations
- No UI was built or captured in this stage (per the stage instructions);
rendering is unverified. The phone position is verified only by the widget
test's layout geometry under a scaffold that mirrors the shell.
- `_newRunBand` is a fixed reservation (16 + 56 + 16). If the extended button
grows with text scale, the last row may need more room. Measuring it would
need a size callback; not done.
- The Runs picker reads only the current endpoint scope. Pending intents stored
under legacy endpoints are not offered by New run (Pipelines still offers them).
- Not run on web, a device or the Fold.
@@ -0,0 +1,57 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/core/transport/pipelines_client.dart';
import 'package:pipelines_app/features/chat/ui/sessions/chat_adaptive.dart';
import 'package:pipelines_app/features/terminal/terminal_shortcut_bubble.dart';
import 'package:pipelines_app/features/terminal/terminal_toggle_button.dart';
import '../core/transport/pipelines_client_test.dart' show FakeChannel;
import 'pipelines_app_test.dart' show pumpApp;
/// On a phone the Chat tab has exactly one terminal entry: the bar's own
/// Terminal action. The floating shortcut bubble must not appear over the
/// chat list's header, nor beside an open chat's bar that already has it.
Future<void> _pumpAt(WidgetTester tester, String location) async {
tester.view.physicalSize = const Size(430, 900);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
final channel = FakeChannel()..readyCompleter.complete();
final client = PipelinesClient(channelFactory: (_) => channel);
final provider = PlatformRouteInformationProvider(
initialRouteInformation: RouteInformation(uri: Uri.parse(location)),
);
addTearDown(provider.dispose);
await pumpApp(tester, channel: channel, client: client, provider: provider);
await tester.pump();
await tester.pump();
}
/// The bar's Terminal actions on screen (a [ChatBarAction] carrying the
/// terminal toggle's label).
Finder _barTerminal() => find.byWidgetPredicate(
(w) => w is ChatBarAction && w.label == TerminalToggleButton.label,
);
void main() {
testWidgets('phone chat list: one terminal entry, no floating bubble', (
tester,
) async {
await _pumpAt(tester, '/chat');
expect(find.byType(TerminalShortcutBubble), findsNothing);
expect(_barTerminal(), findsOneWidget);
expect(tester.takeException(), isNull);
});
testWidgets('phone open chat: one terminal entry, no floating bubble', (
tester,
) async {
await _pumpAt(tester, '/chat/abc123');
expect(find.byType(TerminalShortcutBubble), findsNothing);
expect(_barTerminal(), findsOneWidget);
expect(tester.takeException(), isNull);
});
}
+50 -66
View File
@@ -7,15 +7,16 @@ import 'package:pipelines_app/features/settings/settings_screen.dart';
import 'package:pipelines_app/ui/adaptive/floating_destination_bar.dart';
import 'package:shared_preferences/shared_preferences.dart';
import '../bar_action.dart';
import '../core/transport/pipelines_client_test.dart' show FakeChannel;
import '../features/pipelines/fixtures.dart';
import 'pipelines_app_test.dart' show webServer;
import 'pipelines_replies.dart';
/// Settings is not a tab: it opens as a page (from the gear in the Pipelines
/// bar on a phone, from the rail's foot on a wide window), keeps its
/// `/settings` route (and deep link), and closes back to Pipelines. The tab bar keeps Pipelines selected meanwhile.
/// Settings is a navigation destination: the phone's bar and the wide rail
/// offer it, and the floating tab bar's width (between the list-detail and rail
/// widths) keeps the Pipelines bar's gear. Settings reached from a nav control
/// has no Back; reached as a pushed page (the gear, the /settings deep link) it
/// has Back, which returns to Pipelines.
void main() {
Future<PlatformRouteInformationProvider> pumpApp(
WidgetTester tester, {
@@ -50,61 +51,47 @@ void main() {
int selectedTab(WidgetTester tester) =>
tester.widget<NavigationBar>(find.byType(NavigationBar)).selectedIndex;
// A phone's Pipelines bar keeps the gear; a wide window's rail offers
// Settings instead (see the wide test below).
for (final size in [const Size(390, 844)]) {
testWidgets('${size.width}: the Pipelines bar gear opens Settings '
'as a page and Back returns', (tester) async {
final provider = await pumpApp(
tester,
location: '/pipelines',
size: size,
);
// Four tabs and Settings as the bar's last destination.
expect(
tester
.widget<NavigationBar>(find.byType(NavigationBar))
.destinations
.map((item) => (item as NavigationDestination).label),
['Pipelines', 'Runs', 'Chat', 'Search', 'Settings'],
);
expect(
find.byKey(const ValueKey('shell.destination.settings')),
findsOneWidget,
);
expect(find.byKey(const ValueKey('shell.back')), findsNothing);
testWidgets('390: the bar offers Settings and no gear; Settings from the bar '
'has no Back and the Pipelines item leaves it', (tester) async {
final provider = await pumpApp(
tester,
location: '/pipelines',
size: const Size(390, 844),
);
// Four tabs and Settings as the bar's last destination.
expect(
tester
.widget<NavigationBar>(find.byType(NavigationBar))
.destinations
.map((item) => (item as NavigationDestination).label),
['Pipelines', 'Runs', 'Chat', 'Search', 'Settings'],
);
expect(find.byKey(const Key('pipelines-open-settings')), findsNothing);
expect(find.byKey(const ValueKey('shell.back')), findsNothing);
await tapBarAction(
tester,
find.byKey(const Key('pipelines-open-settings')),
'Settings',
);
await tester.pump();
await tester.pump();
expect(provider.value.uri.path, '/settings');
expect(find.byType(SettingsScreen), findsOneWidget);
expect(find.text('Quick switch animation'), findsOneWidget);
await openSettingsSection(tester, 'Connection');
expect(find.text('Server URL'), findsOneWidget);
// A page of Pipelines: Back in its bar, Settings selected in the bar.
expect(find.byKey(const ValueKey('shell.back')), findsOneWidget);
expect(find.byKey(const ValueKey('shell.search')), findsNothing);
expect(selectedTab(tester), 4);
expect(tester.takeException(), isNull);
await tester.tap(find.byKey(const ValueKey('shell.destination.settings')));
await tester.pumpAndSettle();
expect(provider.value.uri.path, '/settings');
expect(find.byType(SettingsScreen), findsOneWidget);
expect(find.text('Quick switch animation'), findsOneWidget);
await openSettingsSection(tester, 'Connection');
expect(find.text('Server URL'), findsOneWidget);
// A destination: no Back, and Settings is the selected item of the bar.
expect(find.byKey(const ValueKey('shell.back')), findsNothing);
expect(find.byKey(const ValueKey('shell.search')), findsNothing);
expect(selectedTab(tester), 4);
expect(tester.takeException(), isNull);
await tester.tap(find.byKey(const ValueKey('shell.back')));
await tester.pump();
await tester.pump();
expect(provider.value.uri.path, '/pipelines');
expect(find.byKey(const Key('pipelines-open-settings')), findsWidgets);
expect(find.byKey(const ValueKey('shell.back')), findsNothing);
await tester.pumpWidget(const SizedBox.shrink());
await tester.pump();
});
}
await tester.tap(find.byKey(const ValueKey('shell.destination.pipelines')));
await tester.pumpAndSettle();
expect(provider.value.uri.path, '/pipelines');
expect(find.byKey(const ValueKey('shell.back')), findsNothing);
await tester.pumpWidget(const SizedBox.shrink());
await tester.pump();
});
testWidgets('1200: the rail offers Settings at its foot and no gear is '
'left in the Pipelines toolbar; Settings is a page and Back returns', (
'left in the Pipelines toolbar; Settings from the rail has no Back', (
tester,
) async {
final provider = await pumpApp(
@@ -129,21 +116,19 @@ void main() {
}
await tester.tap(find.byKey(const ValueKey('shell.destination.settings')));
await tester.pump();
await tester.pump();
await tester.pumpAndSettle();
expect(provider.value.uri.path, '/settings');
expect(find.byType(SettingsScreen), findsOneWidget);
// Settings is a page of Pipelines: the rail marks Settings, not a tab.
// Settings is a destination: the rail marks Settings, not a tab.
expect(
tester.widget<NavigationRail>(find.byType(NavigationRail)).selectedIndex,
isNull,
);
expect(find.byKey(const ValueKey('shell.back')), findsOneWidget);
expect(find.byKey(const ValueKey('shell.back')), findsNothing);
expect(tester.takeException(), isNull);
await tester.tap(find.byKey(const ValueKey('shell.back')));
await tester.pump();
await tester.pump();
await tester.tap(find.byKey(const ValueKey('shell.destination.pipelines')));
await tester.pumpAndSettle();
expect(provider.value.uri.path, '/pipelines');
expect(find.byKey(const Key('pipelines-open-settings')), findsNothing);
expect(
@@ -154,8 +139,8 @@ void main() {
await tester.pump();
});
testWidgets('the /settings deep link opens the Settings page and '
'the system Back closes it to Pipelines', (tester) async {
testWidgets('the /settings deep link opens Settings as a pushed page with '
'Back, and the system Back closes it to Pipelines', (tester) async {
final provider = await pumpApp(
tester,
location: '/settings',
@@ -168,8 +153,7 @@ void main() {
final handled = await tester.binding.handlePopRoute();
expect(handled, isTrue, reason: 'Back closes the page, not the app');
await tester.pump();
await tester.pump();
await tester.pumpAndSettle();
expect(provider.value.uri.path, '/pipelines');
await tester.pumpWidget(const SizedBox.shrink());
await tester.pump();
@@ -7,7 +7,6 @@ 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 '../bar_action.dart';
import '../core/transport/pipelines_client_test.dart' show FakeChannel;
import '../features/pipelines/fixtures.dart';
import 'pipelines_app_test.dart' show webServer, requestOf;
@@ -45,11 +44,7 @@ void main() {
);
await replyPipelines(tester, channel, PipelineFixture());
await tapBarAction(
tester,
find.byKey(const Key('pipelines-open-settings')),
'Settings',
);
await tester.tap(find.byKey(const ValueKey('shell.destination.settings')));
await tester.pump();
await tester.pump();
expect(provider.value.uri.path, '/settings');
@@ -11,7 +11,6 @@ import 'package:pipelines_app/features/settings/settings_screen.dart';
import 'package:pipelines_app/features/pipelines/screen.dart';
import 'package:pipelines_app/shell/destination.dart';
import '../bar_action.dart';
import '../core/transport/pipelines_client_test.dart' show FakeChannel;
import '../features/pipelines/fixtures.dart';
import 'pipelines_app_test.dart' show webServer;
@@ -63,13 +62,10 @@ void main() {
final app = await mount(tester);
await replyPipelines(tester, app.channel, PipelineFixture());
await tester.pumpAndSettle();
await tapBarAction(
tester,
find.byKey(const Key('pipelines-open-settings')),
'Settings',
);
await tester.pumpAndSettle();
await tab(tester, 'settings');
expect(app.provider.value.uri.path, '/settings');
// A destination opened from its nav item: no Back.
expect(find.byKey(const ValueKey('shell.back')), findsNothing);
final settingsState = tester.state(find.byType(SettingsScreen));
await tab(tester, 'chat');
expect(app.provider.value.uri.path, '/chat');
@@ -77,19 +73,12 @@ void main() {
expect(app.provider.value.uri.path, '/settings');
expect(tester.state(find.byType(SettingsScreen)), same(settingsState));
await tab(tester, 'pipelines');
expect(
app.provider.value.uri.path,
'/settings',
reason: 'tab retap is not Back',
);
await tester.tap(find.byKey(const ValueKey('shell.back')));
await tester.pump();
await tester.pump(const Duration(milliseconds: 500));
expect(
app.provider.value.uri.path,
'/pipelines',
reason: 'explicit Back still exits Settings',
reason: 'the Pipelines item leaves Settings for its list',
);
expect(find.byKey(const ValueKey('shell.back')), findsNothing);
expect(tester.takeException(), isNull);
});
testWidgets(
@@ -191,8 +180,8 @@ void main() {
await tab(tester, 'pipelines');
expect(app.provider.value.uri.path, '/settings');
expect(tester.widget<PipelinesScreen>(hidden).initialPipelineId, 1);
await tester.tap(find.byKey(const Key('shell.back')));
await tester.pumpAndSettle();
// Settings has no Back; the Pipelines item returns to the open pipeline.
await tab(tester, 'pipelines');
expect(app.provider.value.uri.path, '/pipelines/1');
expect(tester.state(find.byType(PipelinesScreen)), same(pipelineState));
expect(
@@ -673,11 +673,18 @@ void main() {
});
await tester.pump();
await tester.pump(const Duration(milliseconds: 500));
expect(find.byTooltip('2 tasks, 12 automations'), findsOneWidget);
expect(find.byTooltip('Background tasks (2 running)'), findsOneWidget);
final counter = find.byKey(const Key('chat-background-tasks-button'));
// One '2' is the count inside the ring, one is the compact caption.
expect(
tester
.widget<Text>(find.byKey(const Key('chat-background-tasks-count')))
.data,
'2',
);
expect(
find.descendant(of: counter, matching: find.text('2')),
findsOneWidget,
findsNWidgets(2),
);
expect(
find.descendant(of: counter, matching: find.text('12')),
@@ -6,19 +6,23 @@ import 'package:pipelines_app/core/api_gateway.dart';
import 'package:pipelines_app/features/chat/conversation/chat_background_tasks.dart';
import 'package:pipelines_app/features/chat/conversation/chat_task_spinner.dart';
RotationTransition _rotation(WidgetTester tester) =>
tester.widget<RotationTransition>(
find.byKey(const Key('chat-background-tasks-spinner')),
final _spinnerFinder = find.byKey(const Key('chat-background-tasks-spinner'));
CircularProgressIndicator _ring(WidgetTester tester) =>
tester.widget<CircularProgressIndicator>(
find.descendant(
of: _spinnerFinder,
matching: find.byType(CircularProgressIndicator),
),
);
Widget _spinner(bool spinning) => MaterialApp(
home: Scaffold(
body: ChatTaskSpinner(
spinning: spinning,
child: const Icon(Icons.layers_outlined, size: 16),
),
),
);
Widget _spinner(int running, {Brightness brightness = Brightness.light}) =>
MaterialApp(
theme: ThemeData(colorSchemeSeed: Colors.indigo, brightness: brightness),
home: Scaffold(
body: Center(child: ChatTaskSpinner(running: running)),
),
);
void _reducedMotion(bool reduced) =>
TestWidgetsFlutterBinding.ensureInitialized()
@@ -51,58 +55,99 @@ class _TasksGateway implements ApiGateway {
void main() {
tearDown(() => _reducedMotion(false));
testWidgets('turns once every period while spinning', (tester) async {
testWidgets(
'a running task shows an indeterminate primary ring with the count',
(tester) async {
_reducedMotion(false);
await tester.pumpWidget(_spinner(2));
final ring = _ring(tester);
expect(ring.value, isNull);
expect(ring.strokeWidth, 2);
expect(
ring.color,
ThemeData(colorSchemeSeed: Colors.indigo).colorScheme.primary,
);
expect(
find.descendant(of: _spinnerFinder, matching: find.text('2')),
findsOneWidget,
);
expect(
find.descendant(
of: _spinnerFinder,
matching: find.byIcon(Icons.layers_outlined),
),
findsNothing,
);
// The ring keeps turning: time advances the animation.
await tester.pump(const Duration(milliseconds: 300));
expect(tester.binding.transientCallbackCount, greaterThan(0));
await tester.pumpWidget(const SizedBox.shrink());
expect(tester.binding.transientCallbackCount, 0);
},
);
testWidgets('dark theme uses the dark primary for the ring', (tester) async {
_reducedMotion(false);
await tester.pumpWidget(_spinner(true));
expect(_rotation(tester).turns.value, 0);
await tester.pump(ChatTaskSpinner.period ~/ 4);
expect(_rotation(tester).turns.value, closeTo(0.25, 0.01));
// Past one full lap the turn starts again from the top.
await tester.pump(
ChatTaskSpinner.period ~/ 4 * 3 + const Duration(milliseconds: 100),
await tester.pumpWidget(_spinner(1, brightness: Brightness.dark));
expect(
_ring(tester).color,
ThemeData(
colorSchemeSeed: Colors.indigo,
brightness: Brightness.dark,
).colorScheme.primary,
);
expect(_rotation(tester).turns.value, closeTo(0.04, 0.01));
await tester.pumpWidget(const SizedBox.shrink());
expect(tester.binding.transientCallbackCount, 0);
});
testWidgets('stays still when not spinning, and stops when it stops', (
testWidgets('no running task shows the static icon with no ring', (
tester,
) async {
_reducedMotion(false);
await tester.pumpWidget(_spinner(false));
await tester.pump(const Duration(seconds: 2));
expect(_rotation(tester).turns.value, 0);
expect(tester.binding.transientCallbackCount, 0);
await tester.pumpWidget(_spinner(true));
await tester.pump(const Duration(milliseconds: 625));
expect(_rotation(tester).turns.value, greaterThan(0));
await tester.pumpWidget(_spinner(false));
await tester.pump();
expect(_rotation(tester).turns.value, 0);
await tester.pump(const Duration(seconds: 2));
expect(_rotation(tester).turns.value, 0);
await tester.pumpWidget(_spinner(0));
expect(
find.descendant(
of: _spinnerFinder,
matching: find.byType(CircularProgressIndicator),
),
findsNothing,
);
expect(
find.descendant(
of: _spinnerFinder,
matching: find.byIcon(Icons.layers_outlined),
),
findsOneWidget,
);
expect(tester.binding.transientCallbackCount, 0);
});
testWidgets('reduced motion keeps the icon static even while spinning', (
testWidgets('every state keeps the same square size', (tester) async {
_reducedMotion(false);
for (final running in [0, 1, 12]) {
await tester.pumpWidget(_spinner(running));
expect(tester.getSize(_spinnerFinder), const Size(16, 16));
}
});
testWidgets('reduced motion holds one static ring segment while running', (
tester,
) async {
_reducedMotion(true);
await tester.pumpWidget(_spinner(true));
await tester.pumpWidget(_spinner(3));
expect(_ring(tester).value, ChatTaskSpinner.reducedSegment);
await tester.pump(const Duration(seconds: 1));
expect(_rotation(tester).turns.value, 0);
expect(_ring(tester).value, ChatTaskSpinner.reducedSegment);
expect(tester.binding.transientCallbackCount, 0);
});
testWidgets('the tasks icon rotates only while a task runs', (tester) async {
testWidgets('the composer button shows the count ring and its tooltip', (
tester,
) async {
_reducedMotion(false);
final gateway = _TasksGateway();
addTearDown(gateway.close);
gateway.running = const [
{'id': 'sh1', 'status': 'running', 'command': 'go test ./...'},
{'id': 'sh2', 'status': 'running', 'command': 'make'},
];
await tester.pumpWidget(
MaterialApp(
@@ -111,12 +156,15 @@ void main() {
),
),
);
// The spinning icon repeats forever, so settle by pumping, never by waiting.
// The ring repeats forever, so settle by pumping, never by waiting.
await tester.pump();
await tester.pump();
expect(find.text('1 task'), findsOneWidget);
final before = _rotation(tester).turns.value;
await tester.pump(const Duration(milliseconds: 300));
expect(_rotation(tester).turns.value, greaterThan(before));
expect(find.text('2 tasks'), findsOneWidget);
expect(find.byTooltip('Background tasks (2 running)'), findsOneWidget);
expect(_ring(tester).value, isNull);
expect(
find.descendant(of: _spinnerFinder, matching: find.text('2')),
findsOneWidget,
);
});
}
@@ -0,0 +1,127 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/core/api_gateway.dart';
import 'package:pipelines_app/features/chat/ui/sessions/chat_sessions_screen.dart';
import 'package:pipelines_app/features/terminal/terminal_scope.dart';
import 'package:pipelines_app/features/terminal/terminal_toggle_button.dart';
import 'package:pipelines_app/ui/adaptive/segmented_bar.dart';
import 'package:pipelines_app/ui/layout/section_heading.dart';
import 'chat_test_harness.dart';
import 'fake_chat_gateway.dart';
/// The chat list's top bar carries Terminal beside New chat and Refresh on a
/// narrow layout, so the phone header below it has no floating terminal
/// shortcut over its count and collapse chevron.
class _Actions implements TerminalActions {
int toggles = 0;
@override
void toggle() => toggles++;
@override
bool get claimsTabKeys => false;
@override
Future<String?> openAt(ApiGateway gateway, String cwd) async => null;
}
const _terminalIdentifier = 'chat-terminal-toggle';
Future<void> _pumpList(
WidgetTester tester, {
required Size size,
TerminalActions? actions,
}) async {
tester.view.physicalSize = size;
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
final gateway = FakeChatGateway()
..sessionsReply = {'chat_sessions': sampleSessions()};
final list = ChatSessionsScreen(
gateway: gateway,
onOpen: (_) {},
localStore: MemoryChatSessionLocalStore(),
);
await tester.pumpWidget(
MaterialApp(
theme: ThemeData(platform: TargetPlatform.android),
home: MediaQuery(
data: MediaQueryData(size: size),
child: actions == null
? list
: TerminalScope(actions: actions, child: list),
),
),
);
await tester.pumpAndSettle();
}
void main() {
testWidgets('phone: Terminal sits in the top bar beside New chat and '
'Refresh, and is the only terminal entry on the list', (tester) async {
final actions = _Actions();
await _pumpList(tester, size: const Size(430, 900), actions: actions);
final bar = find.byType(SegmentedBar);
expect(
find.descendant(
of: bar,
matching: find.byKey(const Key('chat-new-chat')),
),
findsOneWidget,
);
expect(
find.descendant(of: bar, matching: find.byKey(const Key('chat-refresh'))),
findsOneWidget,
);
final terminal = find.descendant(
of: bar,
matching: find.bySemanticsIdentifier(_terminalIdentifier),
);
expect(terminal, findsOneWidget);
expect(find.byTooltip(TerminalToggleButton.label), findsOneWidget);
expect(find.byType(FloatingActionButton), findsNothing);
await tester.tap(terminal);
await tester.pump();
expect(actions.toggles, 1);
});
testWidgets('phone: the top bar sits above the Chats header, which keeps its '
'count and collapse chevron clear of it', (tester) async {
await _pumpList(tester, size: const Size(430, 900), actions: _Actions());
final bar = tester.getRect(find.byType(SegmentedBar));
final heading = find.descendant(
of: find.byKey(const ValueKey('chat-section-Chats')),
matching: find.byType(SectionHeading),
);
expect(heading, findsOneWidget);
final headerRect = tester.getRect(heading);
expect(
headerRect.top,
greaterThanOrEqualTo(bar.bottom),
reason: 'no top-bar control may cover the section header',
);
expect(tester.takeException(), isNull);
});
testWidgets('a wide layout keeps Terminal on the shell bar, not the list '
'bar', (tester) async {
await _pumpList(tester, size: const Size(1200, 800), actions: _Actions());
expect(find.bySemanticsIdentifier(_terminalIdentifier), findsNothing);
});
testWidgets('with no terminal surface the list bar has no terminal entry', (
tester,
) async {
await _pumpList(tester, size: const Size(430, 900));
expect(find.bySemanticsIdentifier(_terminalIdentifier), findsNothing);
expect(find.byKey(const Key('chat-new-chat')), findsOneWidget);
});
}
@@ -0,0 +1,182 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/chat/workspace/chat_pane_dim.dart';
import 'package:pipelines_app/features/chat/workspace/chat_workspace.dart';
import 'package:pipelines_app/ui/motion/motion.dart';
Widget host(
ChatWorkspaceController controller, {
bool disableAnimations = false,
}) => MaterialApp(
home: Scaffold(
body: SizedBox(
width: 1200,
height: 900,
child: Builder(
builder: (context) => MediaQuery(
data: MediaQuery.of(
context,
).copyWith(disableAnimations: disableAnimations),
child: ChatWorkspace(
controller: controller,
paneBuilder: (_, pane, active) =>
TextField(key: ValueKey('input-${pane.sessionId}')),
),
),
),
),
),
);
/// The dim overlay wrapping the pane that shows [session].
Finder dimOf(String session) => find.ancestor(
of: find.byKey(ValueKey('input-$session')),
matching: find.byType(ChatPaneDim),
);
/// The alpha of the scrim over [session]'s pane: zero when the pane is clear.
double scrimAlpha(WidgetTester tester, String session) {
final scrim = find.descendant(
of: dimOf(session),
matching: find.byKey(const ValueKey('chat-pane-dim-scrim')),
);
// AnimatedContainer builds a Container whose BoxDecoration holds the colour.
final container = tester.widget<Container>(
find.descendant(of: scrim, matching: find.byType(Container)),
);
final decoration = container.decoration as BoxDecoration?;
return (decoration?.color ?? container.color ?? const Color(0x00000000)).a;
}
void usePhoneSizedView(WidgetTester tester) {
tester.view.physicalSize = const Size(1200, 900);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
}
void main() {
testWidgets('two panes: the inactive pane is dimmed and the active is not', (
tester,
) async {
final controller = ChatWorkspaceController()
..open('one')
..splitActive('two', ChatSplitAxis.horizontal);
addTearDown(controller.dispose);
await tester.pumpWidget(host(controller));
await tester.pumpAndSettle();
expect(controller.activePane?.sessionId, 'two');
expect(scrimAlpha(tester, 'one'), closeTo(chatPaneDimOpacity, 0.001));
expect(scrimAlpha(tester, 'two'), 0);
});
testWidgets('three panes: every inactive pane is dimmed, the active is not', (
tester,
) async {
final controller = ChatWorkspaceController()
..open('one')
..splitActive('two', ChatSplitAxis.horizontal)
..splitActive('three', ChatSplitAxis.horizontal);
addTearDown(controller.dispose);
await tester.pumpWidget(host(controller));
await tester.pumpAndSettle();
expect(controller.activePane?.sessionId, 'three');
expect(scrimAlpha(tester, 'one'), closeTo(chatPaneDimOpacity, 0.001));
expect(scrimAlpha(tester, 'two'), closeTo(chatPaneDimOpacity, 0.001));
expect(scrimAlpha(tester, 'three'), 0);
});
testWidgets('a single pane is never dimmed', (tester) async {
final controller = ChatWorkspaceController()..open('one');
addTearDown(controller.dispose);
await tester.pumpWidget(host(controller));
await tester.pumpAndSettle();
expect(scrimAlpha(tester, 'one'), 0);
});
testWidgets('tapping an inactive pane activates it and focuses its input', (
tester,
) async {
usePhoneSizedView(tester);
final controller = ChatWorkspaceController()
..open('one')
..splitActive('two', ChatSplitAxis.horizontal);
addTearDown(controller.dispose);
await tester.pumpWidget(host(controller));
await tester.pumpAndSettle();
final first = controller.panes.first.id;
expect(controller.activePaneId, isNot(first));
await tester.tap(find.byKey(const ValueKey('input-one')));
await tester.pumpAndSettle();
expect(controller.activePaneId, first);
expect(scrimAlpha(tester, 'one'), 0);
expect(scrimAlpha(tester, 'two'), closeTo(chatPaneDimOpacity, 0.001));
final editable = tester.widget<EditableText>(
find.descendant(
of: find.byKey(const ValueKey('input-one')),
matching: find.byType(EditableText),
),
);
expect(editable.focusNode.hasFocus, isTrue);
});
testWidgets('a tap on bare space in an inactive pane activates it', (
tester,
) async {
usePhoneSizedView(tester);
final controller = ChatWorkspaceController()
..open('one')
..splitActive('two', ChatSplitAxis.horizontal);
addTearDown(controller.dispose);
await tester.pumpWidget(host(controller));
await tester.pumpAndSettle();
final first = controller.panes.first.id;
final corner = tester.getTopLeft(dimOf('one')) + const Offset(2, 2);
await tester.tapAt(corner);
await tester.pumpAndSettle();
expect(controller.activePaneId, first);
});
testWidgets('reduced motion switches the dim at once, without a fade', (
tester,
) async {
final controller = ChatWorkspaceController()
..open('one')
..splitActive('two', ChatSplitAxis.horizontal);
addTearDown(controller.dispose);
await tester.pumpWidget(host(controller, disableAnimations: true));
await tester.pumpAndSettle();
final scrim = find.byKey(const ValueKey('chat-pane-dim-scrim')).first;
expect(tester.widget<AnimatedContainer>(scrim).duration, Duration.zero);
controller.activate(controller.panes.first.id);
await tester.pump();
expect(scrimAlpha(tester, 'one'), 0);
expect(scrimAlpha(tester, 'two'), closeTo(chatPaneDimOpacity, 0.001));
});
testWidgets('motion is on by default: the dim fades over the standard time', (
tester,
) async {
final controller = ChatWorkspaceController()
..open('one')
..splitActive('two', ChatSplitAxis.horizontal);
addTearDown(controller.dispose);
await tester.pumpWidget(host(controller));
await tester.pumpAndSettle();
final scrim = find.byKey(const ValueKey('chat-pane-dim-scrim')).first;
expect(
tester.widget<AnimatedContainer>(scrim).duration,
Motion.standard,
);
});
}
@@ -0,0 +1,73 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/pipelines/screen.dart';
import 'package:pipelines_app/shell/adaptive_shell.dart';
import 'package:pipelines_app/shell/destination.dart';
import 'package:pipelines_app/ui/adaptive/floating_destination_bar.dart';
import 'fixtures.dart';
import 'test_helpers.dart';
/// The Pipelines bar's Settings gear inside the shell: it is kept only where the
/// floating tab bar is the shell's sole navigation (between the list-detail and
/// rail widths), because only there Settings has no nav entry. Elsewhere the
/// phone's bar or the rail offers Settings, so the bar has no gear.
void main() {
// Returns how many times the gear opened Settings.
Future<int Function()> pumpInShell(WidgetTester tester, Size size) async {
tester.view.physicalSize = size;
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
var opened = 0;
final gateway = gatewayFor(PipelineFixture());
await tester.pumpWidget(
MaterialApp(
home: AdaptiveShell(
destination: AppDestination.pipelines,
destinationBodies: {
// The app's Pipelines destination embeds the screen in the shell.
AppDestination.pipelines: (_) => PipelinesScreen(
gateway: gateway,
embedded: true,
onOpenSettings: () => opened++,
),
},
),
),
);
await tester.pumpAndSettle();
return () => opened;
}
testWidgets('a phone bar offers Settings, so the Pipelines bar has no gear', (
tester,
) async {
await pumpInShell(tester, const Size(390, 844));
expect(find.byType(NavigationBar), findsOneWidget);
expect(find.byKey(const Key('pipelines-open-settings')), findsNothing);
});
testWidgets('a rail offers Settings, so the Pipelines bar has no gear', (
tester,
) async {
await pumpInShell(tester, const Size(1200, 800));
expect(find.byType(NavigationRail), findsOneWidget);
expect(find.byKey(const Key('pipelines-open-settings')), findsNothing);
});
testWidgets('the floating tab bar lists tabs only, so the Pipelines bar '
'keeps the gear and it opens Settings', (tester) async {
final opened = await pumpInShell(tester, const Size(650, 844));
expect(find.byType(FloatingDestinationBar), findsOneWidget);
expect(find.byKey(const Key('pipelines-open-settings')), findsOneWidget);
// At this width the bar folds the gear into its More menu, so it is not
// hit-testable here; its handler is what opens Settings.
final gear = tester.widget<IconButton>(
find.byKey(const Key('pipelines-open-settings')),
);
expect(gear.tooltip, 'Settings');
gear.onPressed!();
expect(opened(), 1);
});
}
@@ -604,4 +604,28 @@ void main() {
expect(find.text('Nightly review'), findsWidgets);
expect(launches, 0);
});
testWidgets('the labelled Run button on the detail starts the flow', (
tester,
) async {
final fixture = PipelineFixture();
final navigated = <int>[];
final gateway = launchGateway(fixture, onLaunch: (_) => acceptedRun(79));
await pumpScreen(tester, gateway, navigated);
await openDetail(tester);
final run = find.byKey(runPipelineActionKey);
expect(
find.descendant(of: run, matching: find.text(runPipelineActionLabel)),
findsOneWidget,
);
await tester.tap(run);
await tester.pumpAndSettle();
await fillFields(tester);
await tester.tap(find.byKey(runPipelineConfirmKey));
await tester.pumpAndSettle();
expect(gateway.callsOf('run_pipeline'), hasLength(1));
expect(navigated, [79]);
});
}
+206
View File
@@ -0,0 +1,206 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:pipelines_app/core/api_gateway.dart';
import 'package:pipelines_app/features/pipelines/ui/run_pipeline_wording.dart';
import 'package:pipelines_app/features/runs/screen.dart';
import '../../pipelines/fixtures.dart';
JsonMap _acceptedRun(int id) => {
'type': 'run',
'run_detail': {'id': id, 'status': 'running', 'title': 'Run $id'},
};
/// Pipelines for the picker: the fixture's three active ones plus one archived
/// pipeline, which must never be offered for a new run.
List<Map<String, dynamic>> _pipelines(PipelineFixture fixture) => [
...fixture.summaries,
{
...pipelineSummary(id: 4, name: 'Retired build'),
'archived_at': '2026-10-01T10:00:00',
},
];
FakeGateway _gateway(PipelineFixture fixture, {required int launchedRunId}) =>
FakeGateway(
(type, fields) => switch (type) {
'list_runs' => runListReply(fixture.runs),
'list_pipelines' => pipelineListReply(_pipelines(fixture)),
'get_pipeline' => pipelineDetailReply(
fixture.detailFor(
fields['pipeline_id'] as int,
fields['version'] as int,
)!,
),
'chat_directories' => {
'type': 'chat_directories',
'chat_directories': ['/work/recent'],
},
'run_pipeline' => _acceptedRun(launchedRunId),
_ => errorReply('unexpected $type'),
},
);
/// Pumps the Runs screen. With [withNavigationBar] the screen sits in a
/// scaffold with `extendBody` and a bottom NavigationBar, as the shell does on
/// a phone, so the body scrolls under the bar.
Future<void> _pumpRuns(
WidgetTester tester,
FakeGateway gateway, {
required Size size,
required List<int> selected,
bool withNavigationBar = false,
}) async {
tester.view.physicalSize = size;
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
final screen = RunsScreen(gateway: gateway, onRunSelected: selected.add);
await tester.pumpWidget(
MaterialApp(
home: withNavigationBar
? Scaffold(
extendBody: true,
body: screen,
bottomNavigationBar: NavigationBar(
selectedIndex: 0,
onDestinationSelected: (_) {},
destinations: const [
NavigationDestination(
icon: Icon(Icons.play_arrow),
label: 'Runs',
),
NavigationDestination(
icon: Icon(Icons.settings),
label: 'Settings',
),
],
),
)
: Scaffold(body: screen),
),
);
await tester.pumpAndSettle();
}
void main() {
TestWidgetsFlutterBinding.ensureInitialized();
SharedPreferences.setMockInitialValues({});
for (final size in const [Size(430, 900), Size(1100, 900)]) {
testWidgets('New run is labelled on the Runs list at ${size.width} wide', (
tester,
) async {
final gateway = _gateway(PipelineFixture(), launchedRunId: 91);
await _pumpRuns(tester, gateway, size: size, selected: []);
final button = find.byKey(const Key('runs-new-run'));
expect(button, findsOneWidget);
expect(
find.descendant(of: button, matching: find.text('New run')),
findsOneWidget,
);
});
}
testWidgets('New run clears the bottom bar and opens the picker on a phone', (
tester,
) async {
final gateway = _gateway(PipelineFixture(), launchedRunId: 91);
await _pumpRuns(
tester,
gateway,
size: const Size(430, 900),
selected: [],
withNavigationBar: true,
);
final button = find.byKey(const Key('runs-new-run'));
final bar = find.byType(NavigationBar);
expect(button, findsOneWidget);
// The button sits wholly above the bar, not beneath it.
expect(
tester.getRect(button).bottom,
lessThanOrEqualTo(tester.getRect(bar).top),
);
// A tap at the button reaches the button, not the bar behind it.
await tester.tap(button);
await tester.pumpAndSettle();
expect(find.byKey(const Key('new-run-search')), findsOneWidget);
});
testWidgets(
'New run picks an active pipeline, starts it and opens the new run',
(tester) async {
final fixture = PipelineFixture();
final gateway = _gateway(fixture, launchedRunId: 91);
final selected = <int>[];
await _pumpRuns(
tester,
gateway,
size: const Size(1100, 900),
selected: selected,
);
await tester.tap(find.byKey(const Key('runs-new-run')));
await tester.pumpAndSettle();
// The picker lists active pipelines only; the archived one is withheld.
expect(find.byKey(const ValueKey('new-run-pipeline-1')), findsOneWidget);
expect(find.byKey(const ValueKey('new-run-pipeline-2')), findsOneWidget);
expect(find.byKey(const ValueKey('new-run-pipeline-4')), findsNothing);
// Search narrows the list by name.
await tester.enterText(find.byKey(const Key('new-run-search')), 'beta');
await tester.pump();
expect(find.byKey(const ValueKey('new-run-pipeline-1')), findsNothing);
expect(find.byKey(const ValueKey('new-run-pipeline-2')), findsOneWidget);
await tester.tap(find.byKey(const ValueKey('new-run-pipeline-2')));
await tester.pumpAndSettle();
// The chosen pipeline's latest version is read, then the start dialog
// opens for it: the same flow as the pipeline's own Run action.
expect(gateway.callsOf('get_pipeline').single.fields, {
'pipeline_id': 2,
'version': 0,
});
await tester.enterText(
find.byKey(runPipelinePromptKey),
'Ship the beta.',
);
await tester.enterText(find.byKey(runPipelineWorkspaceKey), '/work/beta');
await tester.pump();
await tester.tap(find.byKey(runPipelineConfirmKey));
await tester.pumpAndSettle();
final launch = gateway.callsOf('run_pipeline').single.fields;
expect(launch['pipeline_id'], 2);
expect(launch['version'], 1);
expect(selected, [91]);
},
);
testWidgets('dismissing the picker starts nothing', (tester) async {
final gateway = _gateway(PipelineFixture(), launchedRunId: 91);
final selected = <int>[];
await _pumpRuns(
tester,
gateway,
size: const Size(430, 900),
selected: selected,
);
await tester.tap(find.byKey(const Key('runs-new-run')));
await tester.pumpAndSettle();
await tester.tapAt(const Offset(4, 4));
await tester.pumpAndSettle();
expect(find.byKey(const Key('new-run-search')), findsNothing);
expect(gateway.callsOf('get_pipeline'), isEmpty);
expect(gateway.callsOf('run_pipeline'), isEmpty);
expect(selected, isEmpty);
});
}
@@ -4,6 +4,11 @@ import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/core/api_gateway.dart';
import 'package:pipelines_app/features/runs/screen.dart';
import 'package:pipelines_app/features/runs/ui/runs_list.dart';
/// The list's row titles only: the New run button carries the same words.
Finder _rowTitled(String title) =>
find.descendant(of: find.byType(RunsList), matching: find.text(title));
class _Gateway implements ApiGateway {
final listRequests = <Completer<JsonMap>>[];
@@ -53,7 +58,7 @@ void main() {
await tester.pump();
expect(gateway.listRequests, hasLength(2));
// No row is invented while the fresh read is outstanding.
expect(find.text('New run'), findsNothing);
expect(_rowTitled('New run'), findsNothing);
gateway.listRequests[1].complete({
'runs': [
{'id': 2, 'title': 'New run', 'status': 'running'},
@@ -63,7 +68,7 @@ void main() {
await tester.pump();
await tester.pump();
expect(find.text('New run'), findsOneWidget);
expect(_rowTitled('New run'), findsOneWidget);
expect(gateway.listRequests, hasLength(2));
expect(gateway.detailRequests, isEmpty);
});
@@ -0,0 +1,63 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/shell/destination.dart';
import 'package:pipelines_app/shell/navigation_rail.dart';
/// The rail's surface runs from the window's top edge. The system's top inset
/// is kept clear for the rail's content, but it is painted with the rail's
/// surface, so no unpainted strip (white in the app's canvas) shows above it.
void main() {
for (final brightness in Brightness.values) {
testWidgets('the rail top under a system inset is the rail surface '
'(${brightness.name})', (tester) async {
tester.view.physicalSize = const Size(1000, 800);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
final theme = ThemeData(
colorSchemeSeed: Colors.purple,
brightness: brightness,
);
await tester.pumpWidget(
MaterialApp(
theme: theme,
home: Scaffold(
body: Row(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
ShellNavigationRail(
selected: AppDestination.pipelines,
icon: (destination) =>
Icon(destinationDetails(destination).icon),
onSelected: (_) {},
padding: const EdgeInsets.only(top: 8),
),
],
),
),
),
);
await tester.pumpAndSettle();
final surface = theme.colorScheme.surface;
final cover = find.byKey(const ValueKey('shell.navigation-rail.surface'));
final rail = find.byKey(const ValueKey('shell.navigation-rail'));
// The cover and the rail's own background are the same surface colour.
expect(tester.widget<ColoredBox>(cover).color, surface);
expect(tester.widget<NavigationRail>(rail).backgroundColor, surface);
// The rail's content starts below the inset, and the cover starts at the
// window's top edge, so the inset strip is covered.
final coverRect = tester.getRect(cover);
final railRect = tester.getRect(rail);
expect(coverRect.top, 0);
expect(railRect.top, 8);
expect(
coverRect.contains(Offset(railRect.center.dx, 2)),
isTrue,
reason: 'the strip above the rail content is painted',
);
});
}
}
+6 -4
View File
@@ -90,8 +90,8 @@ void main() {
expect(find.text('runs body'), findsOneWidget);
});
testWidgets('Settings opens from the rail foot as a page and no tab is '
'selected meanwhile', (tester) async {
testWidgets('Settings opens from the rail foot as a destination with no '
'Back and no tab is selected meanwhile', (tester) async {
final semantics = tester.ensureSemantics();
await pumpShell(tester, width: 1000);
@@ -106,8 +106,10 @@ void main() {
.isSelected,
Tristate.isTrue,
);
// The page's own Back returns to Pipelines, the tab it belongs to.
await tester.tap(find.byKey(const ValueKey('shell.back')));
// Opened from its rail item, Settings is not a page: no Back.
expect(find.byKey(const ValueKey('shell.back')), findsNothing);
// The Pipelines item leaves it for the Pipelines tab.
await tester.tap(find.byKey(const ValueKey('shell.destination.pipelines')));
await tester.pumpAndSettle();
expect(tester.widget<NavigationRail>(rail()).selectedIndex, 0);
semantics.dispose();
+90
View File
@@ -0,0 +1,90 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/shell/adaptive_shell.dart';
import 'package:pipelines_app/shell/destination.dart';
/// Settings' Back: a destination reached from a shell control has none; a page
/// pushed by a route (a first load or a route change, such as a deep link or
/// the Pipelines gear) has one that returns to Pipelines.
void main() {
AdaptiveShell shellAt(AppDestination destination) => AdaptiveShell(
destination: destination,
destinationBodies: {
for (final value in AppDestination.values)
value: (_) => Text('${value.name} body'),
},
);
Future<void> pumpAt(
WidgetTester tester,
AppDestination destination, {
double width = 1000,
}) async {
tester.view.physicalSize = Size(width, 800);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
await tester.pumpWidget(MaterialApp(home: shellAt(destination)));
await tester.pumpAndSettle();
}
testWidgets('Settings selected from a rail item has no Back', (tester) async {
await pumpAt(tester, AppDestination.pipelines);
expect(find.byKey(const ValueKey('shell.back')), findsNothing);
await tester.tap(find.byKey(const ValueKey('shell.destination.settings')));
await tester.pumpAndSettle();
expect(find.text('settings body'), findsOneWidget);
expect(find.byKey(const ValueKey('shell.back')), findsNothing);
});
testWidgets('Settings selected from a phone bar item has no Back', (
tester,
) async {
await pumpAt(tester, AppDestination.pipelines, width: 390);
await tester.tap(find.byKey(const ValueKey('shell.destination.settings')));
await tester.pumpAndSettle();
expect(find.text('settings body'), findsOneWidget);
expect(find.byKey(const ValueKey('shell.back')), findsNothing);
});
testWidgets('Settings pushed by a route change has Back, which returns to '
'Pipelines', (tester) async {
await pumpAt(tester, AppDestination.pipelines);
// The route moves to Settings (as a gear or a deep link does).
await tester.pumpWidget(
MaterialApp(home: shellAt(AppDestination.settings)),
);
await tester.pumpAndSettle();
expect(find.text('settings body'), findsOneWidget);
expect(find.byKey(const ValueKey('shell.back')), findsOneWidget);
await tester.tap(find.byKey(const ValueKey('shell.back')));
await tester.pumpAndSettle();
expect(find.text('pipelines body'), findsOneWidget);
expect(find.byKey(const ValueKey('shell.back')), findsNothing);
});
testWidgets('a first load on Settings (a deep link) has Back', (
tester,
) async {
await pumpAt(tester, AppDestination.settings);
expect(find.text('settings body'), findsOneWidget);
expect(find.byKey(const ValueKey('shell.back')), findsOneWidget);
});
testWidgets('a nav selection after a pushed Settings clears its Back', (
tester,
) async {
await pumpAt(tester, AppDestination.settings);
expect(find.byKey(const ValueKey('shell.back')), findsOneWidget);
await tester.tap(find.byKey(const ValueKey('shell.destination.chat')));
await tester.pumpAndSettle();
expect(find.text('chat body'), findsOneWidget);
// Settings opened again from its rail item is a destination, not a page.
await tester.tap(find.byKey(const ValueKey('shell.destination.settings')));
await tester.pumpAndSettle();
expect(find.byKey(const ValueKey('shell.back')), findsNothing);
});
}
@@ -0,0 +1,98 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/shell/adaptive_shell.dart';
import 'package:pipelines_app/shell/destination.dart';
import 'package:pipelines_app/shell/windows/window_manager.dart';
import 'windows/window_test_harness.dart';
/// The shell bar's trailing action island is drawn only with actions. The
/// Windows button is one of them only while a floating window is open, so
/// Search and Settings (and every other route) show no empty pill at any size.
void main() {
Future<void> pumpShell(
WidgetTester tester, {
required AppDestination destination,
required double width,
WindowManager? windowManager,
}) async {
tester.view.physicalSize = Size(width, 800);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
await tester.pumpWidget(
MaterialApp(
home: AdaptiveShell(
destination: destination,
windowManager: windowManager,
destinationBodies: {
for (final value in AppDestination.values)
value: (_) => Text('${value.name} body'),
},
),
),
);
await tester.pumpAndSettle();
}
final actionIsland = find.byKey(const ValueKey('segmented.actions'));
for (final width in [1000.0, 430.0]) {
for (final destination in [
AppDestination.search,
AppDestination.settings,
AppDestination.pipelines,
]) {
testWidgets(
'${destination.name} at width ${width.toInt()} draws no empty action '
'island with no floating window',
(tester) async {
await pumpShell(
tester,
destination: destination,
width: width,
windowManager: probeManager(),
);
expect(actionIsland, findsNothing);
expect(find.byKey(const ValueKey('shell.windows')), findsNothing);
},
);
}
}
testWidgets('a shell without a window manager draws no action island', (
tester,
) async {
await pumpShell(tester, destination: AppDestination.settings, width: 1000);
expect(actionIsland, findsNothing);
});
testWidgets('the Windows button is the island only while a window is open', (
tester,
) async {
final manager = probeManager();
await pumpShell(
tester,
destination: AppDestination.search,
width: 1000,
windowManager: manager,
);
expect(actionIsland, findsNothing);
final entry = manager.open('probe', 'a');
await tester.pumpAndSettle();
expect(actionIsland, findsOneWidget);
expect(
find.descendant(
of: actionIsland,
matching: find.byKey(const ValueKey('shell.windows')),
),
findsOneWidget,
);
manager.close(entry.id);
await tester.pumpAndSettle();
expect(actionIsland, findsNothing);
expect(find.byKey(const ValueKey('shell.windows')), findsNothing);
});
}