Merge main into unexpected failure notifications
This commit is contained in:
@@ -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';
|
||||||
|
}
|
||||||
@@ -41,7 +41,6 @@ import '../shell/windows/window_host.dart';
|
|||||||
import '../shell/windows/window_kind.dart';
|
import '../shell/windows/window_kind.dart';
|
||||||
import '../shell/windows/window_manager.dart';
|
import '../shell/windows/window_manager.dart';
|
||||||
import '../shell/windows/window_store.dart';
|
import '../shell/windows/window_store.dart';
|
||||||
import '../shell/windows/windows_menu_button.dart';
|
|
||||||
import 'app_terminals.dart';
|
import 'app_terminals.dart';
|
||||||
import '../features/chat/chat_runtime.dart';
|
import '../features/chat/chat_runtime.dart';
|
||||||
import '../features/chat/windows/chat_windows.dart';
|
import '../features/chat/windows/chat_windows.dart';
|
||||||
@@ -855,9 +854,10 @@ class _PipelinesAppState extends State<PipelinesApp>
|
|||||||
// The terminal button sits on the Chat tab's shell bar on wide layouts;
|
// 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
|
// a narrow layout has it in the chat's own bar instead. The keyboard
|
||||||
// shortcut still toggles the terminal everywhere.
|
// 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: [
|
barActions: [
|
||||||
// Shown on every tab while the app has floating windows.
|
|
||||||
WindowsMenuButton(manager: _windows),
|
|
||||||
if (_destinationOf(route.kind) == AppDestination.chat)
|
if (_destinationOf(route.kind) == AppDestination.chat)
|
||||||
?_terminals.barToggle(context),
|
?_terminals.barToggle(context),
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import '../core/servers/server_scope.dart';
|
|
||||||
|
|
||||||
import '../features/pipelines/screen.dart';
|
import '../features/pipelines/screen.dart';
|
||||||
import '../ui/adaptive/top_bar_notices.dart';
|
import '../ui/adaptive/top_bar_notices.dart';
|
||||||
import 'app_session.dart';
|
import 'app_session.dart';
|
||||||
import 'connection_status.dart';
|
import 'connection_status.dart';
|
||||||
|
import 'pending_run_scope.dart';
|
||||||
import 'server_endpoint.dart';
|
import 'server_endpoint.dart';
|
||||||
|
|
||||||
/// The Pipelines destination: the read-only browser plus honest status.
|
/// The Pipelines destination: the read-only browser plus honest status.
|
||||||
@@ -82,9 +82,7 @@ class PipelinesDestination extends StatelessWidget {
|
|||||||
|
|
||||||
Widget _pipelinesScreen() => PipelinesScreen(
|
Widget _pipelinesScreen() => PipelinesScreen(
|
||||||
gateway: session.gateway,
|
gateway: session.gateway,
|
||||||
endpoint: serverIdentity(session.gateway) == null
|
endpoint: pendingRunScope(session.gateway, server),
|
||||||
? server.uri?.toString() ?? ''
|
|
||||||
: 'profile:${serverIdentity(session.gateway)}',
|
|
||||||
legacyEndpoints: legacyPendingEndpoints,
|
legacyEndpoints: legacyPendingEndpoints,
|
||||||
embedded: true,
|
embedded: true,
|
||||||
active: active,
|
active: active,
|
||||||
|
|||||||
@@ -2,11 +2,13 @@ import 'package:flutter/material.dart';
|
|||||||
|
|
||||||
import '../features/attention/notify/notification_controller.dart';
|
import '../features/attention/notify/notification_controller.dart';
|
||||||
import '../features/attention/runtime/attention_controller.dart';
|
import '../features/attention/runtime/attention_controller.dart';
|
||||||
|
import '../features/pipelines/pending_run_store.dart';
|
||||||
import '../features/runs/screen.dart';
|
import '../features/runs/screen.dart';
|
||||||
import '../features/runs/ui/run_pipeline_link.dart';
|
import '../features/runs/ui/run_pipeline_link.dart';
|
||||||
import '../ui/adaptive/top_bar_notices.dart';
|
import '../ui/adaptive/top_bar_notices.dart';
|
||||||
import 'app_session.dart';
|
import 'app_session.dart';
|
||||||
import 'connection_status.dart';
|
import 'connection_status.dart';
|
||||||
|
import 'pending_run_scope.dart';
|
||||||
import 'server_endpoint.dart';
|
import 'server_endpoint.dart';
|
||||||
|
|
||||||
/// The Runs destination: the loaded screen plus an honest connection status.
|
/// The Runs destination: the loaded screen plus an honest connection status.
|
||||||
@@ -100,6 +102,9 @@ class RunsDestination extends StatelessWidget {
|
|||||||
listRefreshToken: listRefreshToken,
|
listRefreshToken: listRefreshToken,
|
||||||
notifications: notifications,
|
notifications: notifications,
|
||||||
attention: attention,
|
attention: attention,
|
||||||
|
pendingRunStore: SharedPreferencesPendingRunStore(
|
||||||
|
pendingRunScope(session.gateway, server),
|
||||||
|
),
|
||||||
onRunSelected: onRunSelected,
|
onRunSelected: onRunSelected,
|
||||||
onBack: onBack,
|
onBack: onBack,
|
||||||
onPipelineFilterChanged: onPipelineFilterChanged,
|
onPipelineFilterChanged: onPipelineFilterChanged,
|
||||||
|
|||||||
@@ -147,13 +147,11 @@ class _ChatBackgroundTasksState extends State<ChatBackgroundTasks> {
|
|||||||
visualDensity: VisualDensity.compact,
|
visualDensity: VisualDensity.compact,
|
||||||
),
|
),
|
||||||
onPressed: _open,
|
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
|
icon: automationOnly
|
||||||
? const Icon(Icons.schedule, size: 16)
|
? const Icon(Icons.schedule, size: 16)
|
||||||
: ChatTaskSpinner(
|
: ChatTaskSpinner(running: count),
|
||||||
spinning: count > 0,
|
|
||||||
child: const Icon(Icons.layers_outlined, size: 16),
|
|
||||||
),
|
|
||||||
label: caption(),
|
label: caption(),
|
||||||
);
|
);
|
||||||
return Padding(
|
return Padding(
|
||||||
@@ -170,7 +168,7 @@ class _ChatBackgroundTasksState extends State<ChatBackgroundTasks> {
|
|||||||
: 'Background work, $label; task list unavailable')
|
: 'Background work, $label; task list unavailable')
|
||||||
: 'Background work, $label',
|
: 'Background work, $label',
|
||||||
child: Tooltip(
|
child: Tooltip(
|
||||||
message: label,
|
message: count > 0 ? 'Background tasks ($count running)' : label,
|
||||||
excludeFromSemantics: true,
|
excludeFromSemantics: true,
|
||||||
child: button,
|
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
|
/// Background-task glyph for the composer. While [running] is above zero it
|
||||||
/// reduced motion it never turns. Hidden UI is silenced by TickerMode.
|
/// shows a thin Material progress ring around the count; with reduced motion
|
||||||
class ChatTaskSpinner extends StatefulWidget {
|
/// the ring holds one static quarter segment instead of spinning. With no
|
||||||
const ChatTaskSpinner({
|
/// running task it is the plain layers icon, with no ring. Always [size] square
|
||||||
super.key,
|
/// so the button keeps the same dimensions in every state.
|
||||||
required this.spinning,
|
class ChatTaskSpinner extends StatelessWidget {
|
||||||
required this.child,
|
const ChatTaskSpinner({super.key, required this.running, this.size = 16});
|
||||||
});
|
|
||||||
|
|
||||||
final bool spinning;
|
final int running;
|
||||||
final Widget child;
|
final double size;
|
||||||
|
|
||||||
/// One full turn while tasks run.
|
/// Fraction of the ring drawn while reduced motion holds it still.
|
||||||
static const Duration period = Duration(milliseconds: 2500);
|
static const double reducedSegment = 0.25;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<ChatTaskSpinner> createState() => _ChatTaskSpinnerState();
|
Widget build(BuildContext context) {
|
||||||
}
|
final theme = Theme.of(context);
|
||||||
|
final reduced = MediaQuery.maybeDisableAnimationsOf(context) ?? false;
|
||||||
class _ChatTaskSpinnerState extends State<ChatTaskSpinner>
|
final content = running > 0
|
||||||
with SingleTickerProviderStateMixin {
|
? Stack(
|
||||||
late final AnimationController _turns = AnimationController(
|
alignment: Alignment.center,
|
||||||
vsync: this,
|
children: [
|
||||||
duration: ChatTaskSpinner.period,
|
SizedBox.square(
|
||||||
);
|
dimension: size,
|
||||||
bool _reduced = false;
|
child: CircularProgressIndicator(
|
||||||
|
strokeWidth: 2,
|
||||||
@override
|
color: theme.colorScheme.primary,
|
||||||
void initState() {
|
value: reduced ? reducedSegment : null,
|
||||||
super.initState();
|
),
|
||||||
_sync();
|
),
|
||||||
}
|
FittedBox(
|
||||||
|
fit: BoxFit.scaleDown,
|
||||||
@override
|
child: Text(
|
||||||
void didChangeDependencies() {
|
'$running',
|
||||||
super.didChangeDependencies();
|
key: const Key('chat-background-tasks-count'),
|
||||||
_reduced = MediaQuery.maybeDisableAnimationsOf(context) ?? false;
|
style: theme.textTheme.labelSmall,
|
||||||
_sync();
|
),
|
||||||
}
|
),
|
||||||
|
],
|
||||||
@override
|
)
|
||||||
void didUpdateWidget(covariant ChatTaskSpinner oldWidget) {
|
: Icon(Icons.layers_outlined, size: size);
|
||||||
super.didUpdateWidget(oldWidget);
|
return SizedBox.square(
|
||||||
_sync();
|
key: const Key('chat-background-tasks-spinner'),
|
||||||
}
|
dimension: size,
|
||||||
|
child: content,
|
||||||
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,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,20 +1,36 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import '../../../core/servers/server_context.dart';
|
import '../../../core/servers/server_context.dart';
|
||||||
|
import '../../../ui/adaptive/app_popups.dart';
|
||||||
import '../../../ui/adaptive/segmented_bar.dart';
|
import '../../../ui/adaptive/segmented_bar.dart';
|
||||||
import '../../../ui/adaptive/segmented_bar_overflow.dart';
|
import '../../../ui/adaptive/segmented_bar_overflow.dart';
|
||||||
import 'chat_bar_tint.dart';
|
import 'chat_bar_tint.dart';
|
||||||
import '../workspace/chat_workspace_pane_scope.dart';
|
import '../workspace/chat_workspace_pane_scope.dart';
|
||||||
|
|
||||||
|
/// Below this width (in text-scaled logical pixels) the selectors leave the
|
||||||
|
/// bar for its More menu's settings entry, so the title keeps
|
||||||
|
/// [chatHeaderTitleShare].
|
||||||
|
const double chatHeaderNarrowWidth = 600;
|
||||||
|
|
||||||
|
/// The share of a narrow bar the conversation's title always keeps.
|
||||||
|
const double chatHeaderTitleShare = 0.6;
|
||||||
|
|
||||||
/// The open conversation's bar: the app's [SegmentedBar] above the
|
/// The open conversation's bar: the app's [SegmentedBar] above the
|
||||||
/// transcript.
|
/// transcript.
|
||||||
///
|
///
|
||||||
/// From the leading edge: a round Back (only where the page can go back), a
|
/// From the leading edge: a round Back (only where the page can go back), a
|
||||||
/// pill with the conversation's title and folder that opens the chat's
|
/// pill with the conversation's title and folder that opens the chat's
|
||||||
/// information, a selector island holding [controls] (model and mode),
|
/// information, a selector island holding [controls] (model, mode and
|
||||||
/// then the Files action and a native More menu in a separate island.
|
/// thinking), then the Files action and a native More menu in a separate
|
||||||
/// Narrow panes keep the model/mode selectors as compact icons in the same row;
|
/// island.
|
||||||
/// their semantic labels and native pickers continue to expose the values.
|
///
|
||||||
|
/// A narrow bar ([chatHeaderNarrowWidth]) keeps the title at
|
||||||
|
/// [chatHeaderTitleShare] of the bar: the [controls] join the More menu as one
|
||||||
|
/// "Chat settings" entry that opens them in a sheet, and the overflowable
|
||||||
|
/// actions join it too. A floating chat passes [showTitle] false, since its window bar names
|
||||||
|
/// the chat.
|
||||||
///
|
///
|
||||||
/// A chat with a [chatColor] carries it in the bar: each glass piece is
|
/// A chat with a [chatColor] carries it in the bar: each glass piece is
|
||||||
/// filled with its shade over the raised surface and its labels and icons
|
/// filled with its shade over the raised surface and its labels and icons
|
||||||
@@ -26,6 +42,7 @@ class ChatThreadHeader extends StatelessWidget {
|
|||||||
required this.title,
|
required this.title,
|
||||||
required this.folder,
|
required this.folder,
|
||||||
required this.onInfo,
|
required this.onInfo,
|
||||||
|
this.showTitle = true,
|
||||||
this.showBack = false,
|
this.showBack = false,
|
||||||
this.onBack,
|
this.onBack,
|
||||||
this.controls = const [],
|
this.controls = const [],
|
||||||
@@ -41,6 +58,10 @@ class ChatThreadHeader extends StatelessWidget {
|
|||||||
final String folder;
|
final String folder;
|
||||||
final VoidCallback onInfo;
|
final VoidCallback onInfo;
|
||||||
|
|
||||||
|
/// Whether the title pill (and its folder) shows; false in a floating
|
||||||
|
/// window, whose own bar names the chat.
|
||||||
|
final bool showTitle;
|
||||||
|
|
||||||
/// Whether the bar shows Back at all.
|
/// Whether the bar shows Back at all.
|
||||||
final bool showBack;
|
final bool showBack;
|
||||||
|
|
||||||
@@ -62,21 +83,36 @@ class ChatThreadHeader extends StatelessWidget {
|
|||||||
return LayoutBuilder(
|
return LayoutBuilder(
|
||||||
builder: (context, constraints) {
|
builder: (context, constraints) {
|
||||||
final textScale = MediaQuery.textScalerOf(context).scale(14) / 14;
|
final textScale = MediaQuery.textScalerOf(context).scale(14) / 14;
|
||||||
final compact = constraints.maxWidth / textScale < 800;
|
final scaledWidth = constraints.maxWidth / textScale;
|
||||||
|
final compact = scaledWidth < 800;
|
||||||
|
final narrow = scaledWidth < chatHeaderNarrowWidth;
|
||||||
|
// A narrow bar moves the selectors, and the overflowable actions, into
|
||||||
|
// its More menu; the others stay in the bar.
|
||||||
|
final menuActions = [
|
||||||
|
if (narrow) ...actions.whereType<SegmentedOverflowable>(),
|
||||||
|
...moreActions.whereType<SegmentedOverflowable>(),
|
||||||
|
];
|
||||||
|
final settingsEntry = narrow && controls.isNotEmpty
|
||||||
|
? SegmentedOverflowEntry(
|
||||||
|
label: 'Chat settings',
|
||||||
|
icon: Icons.tune,
|
||||||
|
onPressed: () => unawaited(_showSettings(context, controls)),
|
||||||
|
)
|
||||||
|
: null;
|
||||||
final actionChildren = [
|
final actionChildren = [
|
||||||
...actions,
|
for (final action in actions)
|
||||||
|
if (!narrow || action is! SegmentedOverflowable) action,
|
||||||
for (final action in moreActions)
|
for (final action in moreActions)
|
||||||
if (action is! SegmentedOverflowable) action,
|
if (action is! SegmentedOverflowable) action,
|
||||||
if (moreActions.whereType<SegmentedOverflowable>().isNotEmpty)
|
if (settingsEntry != null || menuActions.isNotEmpty)
|
||||||
SegmentedMoreButton(
|
SegmentedMoreButton(
|
||||||
entries: [
|
entries: [
|
||||||
for (final action
|
?settingsEntry,
|
||||||
in moreActions.whereType<SegmentedOverflowable>())
|
for (final action in menuActions) action.overflowEntry,
|
||||||
action.overflowEntry,
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
];
|
];
|
||||||
final Widget bar = SegmentedBar(
|
final bar = SegmentedBar(
|
||||||
pillColor: tint?.fill,
|
pillColor: tint?.fill,
|
||||||
foregroundColor: tint?.foreground,
|
foregroundColor: tint?.foreground,
|
||||||
automaticallyImplyLeading: false,
|
automaticallyImplyLeading: false,
|
||||||
@@ -88,16 +124,17 @@ class ChatThreadHeader extends StatelessWidget {
|
|||||||
onPressed: onBack,
|
onPressed: onBack,
|
||||||
)
|
)
|
||||||
: null,
|
: null,
|
||||||
title: title.isEmpty ? 'Chat' : title,
|
title: !showTitle ? '' : (title.isEmpty ? 'Chat' : title),
|
||||||
titleLeading: identity,
|
titleLeading: showTitle ? identity : null,
|
||||||
subtitle: ServerContext.metadata(context, folder),
|
subtitle: showTitle ? ServerContext.metadata(context, folder) : null,
|
||||||
subtitleIcon: Icons.folder_outlined,
|
subtitleIcon: Icons.folder_outlined,
|
||||||
onTitlePressed: onInfo,
|
onTitlePressed: showTitle ? onInfo : null,
|
||||||
titleSemanticLabel: 'Chat information',
|
titleSemanticLabel: 'Chat information',
|
||||||
titleKey: const Key('chat-info'),
|
titleKey: const Key('chat-info'),
|
||||||
separateActionIslands: true,
|
separateActionIslands: true,
|
||||||
|
titleShare: narrow && showTitle ? chatHeaderTitleShare : null,
|
||||||
actions: [
|
actions: [
|
||||||
if (controls.isNotEmpty)
|
if (controls.isNotEmpty && !narrow)
|
||||||
ChatWorkspacePaneActionBar(
|
ChatWorkspacePaneActionBar(
|
||||||
child: _ControlIsland(
|
child: _ControlIsland(
|
||||||
key: const Key('chat-model-permission-island'),
|
key: const Key('chat-model-permission-island'),
|
||||||
@@ -105,7 +142,7 @@ class ChatThreadHeader extends StatelessWidget {
|
|||||||
children: controls,
|
children: controls,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (actions.isNotEmpty || moreActions.isNotEmpty)
|
if (actionChildren.isNotEmpty)
|
||||||
ChatWorkspacePaneActionBar(
|
ChatWorkspacePaneActionBar(
|
||||||
child: Row(
|
child: Row(
|
||||||
key: const Key('chat-actions-island'),
|
key: const Key('chat-actions-island'),
|
||||||
@@ -136,6 +173,24 @@ class ChatThreadHeader extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// A narrow bar's selectors (model, mode and thinking), each with its label,
|
||||||
|
/// in a sheet opened from the More menu.
|
||||||
|
Future<void> _showSettings(BuildContext context, List<Widget> controls) =>
|
||||||
|
showAppChoiceMenu<void>(
|
||||||
|
context,
|
||||||
|
semanticLabel: 'Chat settings',
|
||||||
|
builder: (_) => SafeArea(
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.fromLTRB(16, 0, 16, 16),
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: controls,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
/// Related selectors share the available width. Each remains a real control;
|
/// Related selectors share the available width. Each remains a real control;
|
||||||
/// they never migrate into the unrelated actions menu.
|
/// they never migrate into the unrelated actions menu.
|
||||||
class _ControlIsland extends StatelessWidget {
|
class _ControlIsland extends StatelessWidget {
|
||||||
|
|||||||
@@ -1428,15 +1428,23 @@ class _ChatThreadViewState extends State<ChatThreadView> {
|
|||||||
? ModalRoute.of(context)?.impliesAppBarDismissal ?? false
|
? ModalRoute.of(context)?.impliesAppBarDismissal ?? false
|
||||||
: true);
|
: true);
|
||||||
final answeredBy = latestReplyModel(_controller.messages);
|
final answeredBy = latestReplyModel(_controller.messages);
|
||||||
return _chrome.widgetFor('header', answeredBy, [
|
// A floating window's own bar names the chat, so the header omits it.
|
||||||
widget,
|
final inWindow = WindowScope.maybeOf(context) != null;
|
||||||
inShellBar,
|
return _chrome.widgetFor(
|
||||||
canGoBack,
|
'header',
|
||||||
// The thinking control says when a turn is running.
|
answeredBy,
|
||||||
_controller.running,
|
[
|
||||||
// The More menu offers Dismiss all finished commands only with one.
|
widget,
|
||||||
_shellRuns.finishedIds.isNotEmpty,
|
inShellBar,
|
||||||
], () => _buildHeader(session, inShellBar, canGoBack, answeredBy));
|
canGoBack,
|
||||||
|
inWindow,
|
||||||
|
// The thinking control says when a turn is running.
|
||||||
|
_controller.running,
|
||||||
|
// The More menu offers Dismiss all finished commands only with one.
|
||||||
|
_shellRuns.finishedIds.isNotEmpty,
|
||||||
|
],
|
||||||
|
() => _buildHeader(session, inShellBar, canGoBack, answeredBy, inWindow),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildHeader(
|
Widget _buildHeader(
|
||||||
@@ -1444,6 +1452,7 @@ class _ChatThreadViewState extends State<ChatThreadView> {
|
|||||||
bool inShellBar,
|
bool inShellBar,
|
||||||
bool canGoBack,
|
bool canGoBack,
|
||||||
String answeredBy,
|
String answeredBy,
|
||||||
|
bool inWindow,
|
||||||
) {
|
) {
|
||||||
final hasModel =
|
final hasModel =
|
||||||
session != null && supportsChatModels('${session['backend'] ?? ''}');
|
session != null && supportsChatModels('${session['backend'] ?? ''}');
|
||||||
@@ -1466,6 +1475,7 @@ class _ChatThreadViewState extends State<ChatThreadView> {
|
|||||||
? null
|
? null
|
||||||
: ChatSessionAvatar(session: session, selected: true),
|
: ChatSessionAvatar(session: session, selected: true),
|
||||||
onInfo: _openInfo,
|
onInfo: _openInfo,
|
||||||
|
showTitle: !inWindow,
|
||||||
showBack: canGoBack,
|
showBack: canGoBack,
|
||||||
// A pushed page keeps the platform's stock Back (pop this route); a
|
// A pushed page keeps the platform's stock Back (pop this route); a
|
||||||
// standalone conversation calls its owner.
|
// standalone conversation calls its owner.
|
||||||
@@ -1518,6 +1528,7 @@ class _ChatThreadViewState extends State<ChatThreadView> {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
controls: [
|
controls: [
|
||||||
|
// Labelled, so a narrow bar's settings sheet shows their names.
|
||||||
if (hasModel)
|
if (hasModel)
|
||||||
ChatModelControl(
|
ChatModelControl(
|
||||||
key: ValueKey<String>('chat-model-${widget.sessionId}'),
|
key: ValueKey<String>('chat-model-${widget.sessionId}'),
|
||||||
@@ -1526,6 +1537,7 @@ class _ChatThreadViewState extends State<ChatThreadView> {
|
|||||||
session: session,
|
session: session,
|
||||||
onChanged: widget.onModelChanged,
|
onChanged: widget.onModelChanged,
|
||||||
answeredBy: answeredBy,
|
answeredBy: answeredBy,
|
||||||
|
showLabel: true,
|
||||||
),
|
),
|
||||||
if (hasMode) _modeControl(),
|
if (hasMode) _modeControl(),
|
||||||
// Only a model with levels gets the control (and its pill).
|
// Only a model with levels gets the control (and its pill).
|
||||||
@@ -1537,6 +1549,7 @@ class _ChatThreadViewState extends State<ChatThreadView> {
|
|||||||
session: session,
|
session: session,
|
||||||
running: _controller.running,
|
running: _controller.running,
|
||||||
onChanged: widget.onEffortChanged,
|
onChanged: widget.onEffortChanged,
|
||||||
|
showLabel: true,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
@@ -1551,6 +1564,7 @@ class _ChatThreadViewState extends State<ChatThreadView> {
|
|||||||
mode: '${widget.session?['mode'] ?? ''}'.trim(),
|
mode: '${widget.session?['mode'] ?? ''}'.trim(),
|
||||||
modeName: '${widget.session?['mode_name'] ?? ''}'.trim(),
|
modeName: '${widget.session?['mode_name'] ?? ''}'.trim(),
|
||||||
onChanged: widget.onModeChanged,
|
onChanged: widget.onModeChanged,
|
||||||
|
showLabel: true,
|
||||||
);
|
);
|
||||||
|
|
||||||
/// Stops the running turn, as the composer's `/stop` does.
|
/// Stops the running turn, as the composer's `/stop` does.
|
||||||
|
|||||||
@@ -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_move_shortcuts.dart';
|
||||||
import 'chat_pane_switch_motion.dart';
|
import 'chat_pane_switch_motion.dart';
|
||||||
import 'chat_pane_backdrop.dart';
|
import 'chat_pane_backdrop.dart';
|
||||||
|
import 'chat_pane_dim.dart';
|
||||||
import 'chat_workspace_pane_scope.dart';
|
import 'chat_workspace_pane_scope.dart';
|
||||||
import 'chat_workspace_surface.dart';
|
import 'chat_workspace_surface.dart';
|
||||||
import '../../../ui/input/keyboard_owner.dart';
|
import '../../../ui/input/keyboard_owner.dart';
|
||||||
@@ -509,8 +510,11 @@ class _ChatWorkspaceState extends State<ChatWorkspace>
|
|||||||
onPreferredWidthChanged: (width) =>
|
onPreferredWidthChanged: (width) =>
|
||||||
_reportPaneExtraWidth(pane.id, width),
|
_reportPaneExtraWidth(pane.id, width),
|
||||||
child: Builder(
|
child: Builder(
|
||||||
builder: (paneContext) =>
|
builder: (paneContext) => ChatPaneDim(
|
||||||
widget.paneBuilder(paneContext, pane, active),
|
// A single pane is always the active one, so it never dims.
|
||||||
|
dimmed: widget.controller.paneCount > 1 && !active,
|
||||||
|
child: widget.paneBuilder(paneContext, pane, active),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -1,21 +1,16 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import '../../../core/api_gateway.dart';
|
import '../../../core/api_gateway.dart';
|
||||||
import '../../../core/transport/connection_state.dart';
|
import '../../../ui/adaptive/segmented_bar_overflow.dart';
|
||||||
import '../../runs/data/runs_repository.dart';
|
|
||||||
import '../pipeline_models.dart';
|
import '../pipeline_models.dart';
|
||||||
import '../pipelines_controller.dart';
|
import '../pipelines_controller.dart';
|
||||||
import '../run_pipeline_intent.dart';
|
import 'run_pipeline_flow.dart';
|
||||||
import '../widgets/pipeline_bar_buttons.dart';
|
|
||||||
import 'run_pipeline_dialog.dart';
|
|
||||||
import 'run_pipeline_wording.dart';
|
import 'run_pipeline_wording.dart';
|
||||||
|
|
||||||
/// The pipeline detail's Run action.
|
const _runIcon = Icons.play_arrow_rounded;
|
||||||
///
|
|
||||||
/// Nothing is requested until the dialog's confirm. A confirmed attempt sends
|
/// The pipeline detail's Run action: a labelled button that opens the shared
|
||||||
/// the web's exact `run_pipeline` body against the pinned resolved version; a
|
/// start flow ([openRunPipelineFlow]).
|
||||||
/// 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.
|
|
||||||
class RunPipelineAction extends StatefulWidget {
|
class RunPipelineAction extends StatefulWidget {
|
||||||
const RunPipelineAction({
|
const RunPipelineAction({
|
||||||
super.key,
|
super.key,
|
||||||
@@ -26,8 +21,8 @@ class RunPipelineAction extends StatefulWidget {
|
|||||||
this.inBar = false,
|
this.inBar = false,
|
||||||
});
|
});
|
||||||
|
|
||||||
/// The compact icon-and-word button of a top bar's actions pill instead
|
/// The compact button of a top bar's actions pill instead of an inline
|
||||||
/// of an inline button.
|
/// button. A narrow bar moves it into its More menu, labelled.
|
||||||
final bool inBar;
|
final bool inBar;
|
||||||
|
|
||||||
final PipelinesController controller;
|
final PipelinesController controller;
|
||||||
@@ -45,143 +40,38 @@ class RunPipelineAction extends StatefulWidget {
|
|||||||
class _RunPipelineActionState extends State<RunPipelineAction> {
|
class _RunPipelineActionState extends State<RunPipelineAction> {
|
||||||
bool _dialogOpen = false;
|
bool _dialogOpen = false;
|
||||||
|
|
||||||
int get _pipelineId => widget.detail.id;
|
|
||||||
int get _version => widget.detail.resolvedVersion;
|
|
||||||
|
|
||||||
Future<void> _open() async {
|
Future<void> _open() async {
|
||||||
if (_dialogOpen) return;
|
if (_dialogOpen) return;
|
||||||
_dialogOpen = true;
|
_dialogOpen = true;
|
||||||
try {
|
try {
|
||||||
final pending = await widget.controller.loadPendingRun(
|
await openRunPipelineFlow(
|
||||||
_pipelineId,
|
|
||||||
_version,
|
|
||||||
);
|
|
||||||
if (!mounted) return;
|
|
||||||
await showRunPipelineDialog(
|
|
||||||
context: context,
|
context: context,
|
||||||
|
controller: widget.controller,
|
||||||
detail: widget.detail,
|
detail: widget.detail,
|
||||||
gateway: widget.gateway,
|
gateway: widget.gateway,
|
||||||
pending: pending,
|
onRunStarted: widget.onRunStarted,
|
||||||
onSubmit: _submit,
|
|
||||||
onPendingChanged: (intent) {
|
|
||||||
if (intent == null) {
|
|
||||||
widget.controller.clearPendingRun(_pipelineId, _version);
|
|
||||||
} else {
|
|
||||||
widget.controller.rememberPendingRun(intent);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onAccepted: _accepted,
|
|
||||||
);
|
);
|
||||||
} finally {
|
} finally {
|
||||||
_dialogOpen = false;
|
_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
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final label = const Text(runPipelineActionLabel);
|
final button = FilledButton.icon(
|
||||||
if (widget.inBar) {
|
|
||||||
return pipelineBarIconButton(
|
|
||||||
context,
|
|
||||||
key: runPipelineActionKey,
|
|
||||||
label: 'Run ${widget.detail.displayName}',
|
|
||||||
icon: Icons.play_arrow_rounded,
|
|
||||||
onPressed: _open,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return FilledButton(
|
|
||||||
key: runPipelineActionKey,
|
key: runPipelineActionKey,
|
||||||
onPressed: _open,
|
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,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,10 +11,15 @@ import '../attention/notify/notification_controller.dart';
|
|||||||
import '../../ui/layout/content_width.dart';
|
import '../../ui/layout/content_width.dart';
|
||||||
import '../attention/runtime/attention_controller.dart';
|
import '../attention/runtime/attention_controller.dart';
|
||||||
import '../attention/runtime/attention_store.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 'actions/decision_action.dart';
|
||||||
import 'data/runs_repository.dart';
|
import 'data/runs_repository.dart';
|
||||||
import 'data/runs_sort_store.dart';
|
import 'data/runs_sort_store.dart';
|
||||||
import 'domain/run_decisions.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_pipeline_link.dart';
|
||||||
import 'ui/run_detail_view.dart';
|
import 'ui/run_detail_view.dart';
|
||||||
import 'ui/run_search_selection.dart';
|
import 'ui/run_search_selection.dart';
|
||||||
@@ -47,6 +52,7 @@ class RunsScreen extends StatefulWidget {
|
|||||||
this.notifications,
|
this.notifications,
|
||||||
this.attention,
|
this.attention,
|
||||||
this.sortStore = const SharedPreferencesRunsSortStore(),
|
this.sortStore = const SharedPreferencesRunsSortStore(),
|
||||||
|
this.pendingRunStore = const SharedPreferencesPendingRunStore(''),
|
||||||
});
|
});
|
||||||
|
|
||||||
final ApiGateway gateway;
|
final ApiGateway gateway;
|
||||||
@@ -94,12 +100,24 @@ class RunsScreen extends StatefulWidget {
|
|||||||
/// Where the list's sort choice persists; tests inject a memory store.
|
/// Where the list's sort choice persists; tests inject a memory store.
|
||||||
final RunsSortStore sortStore;
|
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
|
@override
|
||||||
State<RunsScreen> createState() => _RunsScreenState();
|
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> {
|
class _RunsScreenState extends State<RunsScreen> {
|
||||||
late final RunsController controller;
|
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;
|
num? _shownRunId;
|
||||||
int? _reportedPipelineId;
|
int? _reportedPipelineId;
|
||||||
bool _applyingRoutePipeline = false;
|
bool _applyingRoutePipeline = false;
|
||||||
@@ -118,6 +136,10 @@ class _RunsScreenState extends State<RunsScreen> {
|
|||||||
RunsRepository(widget.gateway),
|
RunsRepository(widget.gateway),
|
||||||
sortStore: widget.sortStore,
|
sortStore: widget.sortStore,
|
||||||
);
|
);
|
||||||
|
_launches = PipelinesController(
|
||||||
|
PipelinesRepository(widget.gateway),
|
||||||
|
pendingRunStore: widget.pendingRunStore,
|
||||||
|
);
|
||||||
// A deleted open run closes its detail; the route returns to the list.
|
// A deleted open run closes its detail; the route returns to the list.
|
||||||
controller.onOpenRunRemoved = () =>
|
controller.onOpenRunRemoved = () =>
|
||||||
widget.onBack?.call(controller.pipelineId);
|
widget.onBack?.call(controller.pipelineId);
|
||||||
@@ -234,6 +256,23 @@ class _RunsScreenState extends State<RunsScreen> {
|
|||||||
widget.onBack?.call(controller.pipelineId);
|
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
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
controller.removeListener(_selectionChanged);
|
controller.removeListener(_selectionChanged);
|
||||||
@@ -241,6 +280,7 @@ class _RunsScreenState extends State<RunsScreen> {
|
|||||||
controller.removeListener(_detailChanged);
|
controller.removeListener(_detailChanged);
|
||||||
_page.dispose();
|
_page.dispose();
|
||||||
controller.dispose();
|
controller.dispose();
|
||||||
|
_launches.dispose();
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -285,20 +325,55 @@ class _RunsScreenState extends State<RunsScreen> {
|
|||||||
onClosed: _back,
|
onClosed: _back,
|
||||||
builder: (context) => _detail(() => Navigator.of(context).maybePop()),
|
builder: (context) => _detail(() => Navigator.of(context).maybePop()),
|
||||||
);
|
);
|
||||||
final list = AnimatedBuilder(
|
// The New run button floats over the list's bottom-right corner while the
|
||||||
animation: controller,
|
// list is the visible view. The list reserves the button's band in its
|
||||||
builder: (context, _) => ContentWidth(
|
// bottom padding, so its last row rests above the button, and the overlay
|
||||||
child: RunsList(
|
// lifts clear of the shell's bar like the list's own clearance does.
|
||||||
active: narrow ? !selected : true,
|
final list = Stack(
|
||||||
controller: controller,
|
fit: StackFit.expand,
|
||||||
onSelected: _select,
|
children: [
|
||||||
syncToken: widget.syncToken,
|
AnimatedBuilder(
|
||||||
attentionStore: widget.attentionStore,
|
animation: controller,
|
||||||
attentionNow: widget.attentionNow,
|
builder: (context, _) {
|
||||||
notifications: widget.notifications,
|
final showsButton = !(narrow && selected);
|
||||||
attention: widget.attention,
|
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;
|
if (narrow) return list;
|
||||||
return ListDetailPanes(
|
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>[
|
points: <String>[
|
||||||
'Pipelines tab: open a workflow and fill in its inputs.',
|
'Pipelines tab: open a workflow and fill in its inputs.',
|
||||||
'Runs tab: follow a run as it works, then read what it produced.',
|
'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(
|
WalkthroughStep(
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ import 'shell_list_shortcuts.dart';
|
|||||||
import 'shell_runs_pipelines_shortcut.dart';
|
import 'shell_runs_pipelines_shortcut.dart';
|
||||||
import 'shell_search_shortcut_labels.dart';
|
import 'shell_search_shortcut_labels.dart';
|
||||||
import 'tab_history.dart';
|
import 'tab_history.dart';
|
||||||
|
import 'windows/window_manager.dart';
|
||||||
|
import 'windows/windows_menu_button.dart';
|
||||||
import '../ui/input/keyboard_owner.dart';
|
import '../ui/input/keyboard_owner.dart';
|
||||||
|
|
||||||
class AdaptiveShell extends StatefulWidget {
|
class AdaptiveShell extends StatefulWidget {
|
||||||
@@ -33,12 +35,18 @@ class AdaptiveShell extends StatefulWidget {
|
|||||||
this.runningRunCount,
|
this.runningRunCount,
|
||||||
this.listPaneWidthStore = const SharedPreferencesListPaneWidthStore(),
|
this.listPaneWidthStore = const SharedPreferencesListPaneWidthStore(),
|
||||||
this.barActions = const [],
|
this.barActions = const [],
|
||||||
|
this.windowManager,
|
||||||
});
|
});
|
||||||
|
|
||||||
/// Actions every destination's bar ends with (the Terminal toggle), after
|
/// Actions every destination's bar ends with (the Terminal toggle), after
|
||||||
/// the screen's own or Search.
|
/// the screen's own or Search.
|
||||||
final List<Widget> barActions;
|
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.
|
/// Where each destination's dragged list-pane width is kept on this device.
|
||||||
final ListPaneWidthStore listPaneWidthStore;
|
final ListPaneWidthStore listPaneWidthStore;
|
||||||
|
|
||||||
@@ -268,7 +276,11 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
|
|||||||
SegmentedBar currentBar() =>
|
SegmentedBar currentBar() =>
|
||||||
_segmentedBar(_bar.specFor(_selected), details.label, page: page);
|
_segmentedBar(_bar.specFor(_selected), details.label, page: page);
|
||||||
final topBar = _ListPaneBar(
|
final topBar = _ListPaneBar(
|
||||||
listenable: Listenable.merge([_bar.bar, _paneWidths]),
|
listenable: Listenable.merge([
|
||||||
|
_bar.bar,
|
||||||
|
_paneWidths,
|
||||||
|
?widget.windowManager,
|
||||||
|
]),
|
||||||
initial: currentBar(),
|
initial: currentBar(),
|
||||||
split: () => _bar.split(_selected),
|
split: () => _bar.split(_selected),
|
||||||
preferredWidth: () => _paneWidths.widthFor(_selected.name),
|
preferredWidth: () => _paneWidths.widthFor(_selected.name),
|
||||||
@@ -472,6 +484,7 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
|
|||||||
spec?.onBack ?? (page && _settingsPushed ? _closePage : null);
|
spec?.onBack ?? (page && _settingsPushed ? _closePage : null);
|
||||||
final published = spec?.actions ?? const <Widget>[];
|
final published = spec?.actions ?? const <Widget>[];
|
||||||
final onSearch = widget.onSearch;
|
final onSearch = widget.onSearch;
|
||||||
|
final windows = widget.windowManager;
|
||||||
return SegmentedBar(
|
return SegmentedBar(
|
||||||
automaticallyImplyLeading: false,
|
automaticallyImplyLeading: false,
|
||||||
leading: onBack == null
|
leading: onBack == null
|
||||||
@@ -506,6 +519,10 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
|
|||||||
tooltip: 'Search (${shellSearchShortcutLabels().join(', ')})',
|
tooltip: 'Search (${shellSearchShortcutLabels().join(', ')})',
|
||||||
icon: const Icon(Icons.search),
|
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,
|
...widget.barActions,
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -56,35 +56,44 @@ class ShellNavigationRail extends StatelessWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final index = shellTabDestinations.indexOf(selected);
|
final index = shellTabDestinations.indexOf(selected);
|
||||||
return Padding(
|
final surface = Theme.of(context).colorScheme.surface;
|
||||||
padding: padding,
|
// The surface runs under the top inset too: the padding only moves the
|
||||||
child: SizedBox(
|
// rail's content below the system's top, so no unpainted strip shows above
|
||||||
width: kNavigationRailWidth,
|
// the rail's background.
|
||||||
child: NavigationRail(
|
return ColoredBox(
|
||||||
key: const ValueKey('shell.navigation-rail'),
|
key: const ValueKey('shell.navigation-rail.surface'),
|
||||||
minWidth: kNavigationRailWidth,
|
color: surface,
|
||||||
labelType: NavigationRailLabelType.all,
|
child: Padding(
|
||||||
selectedIndex: index < 0 ? null : index,
|
padding: padding,
|
||||||
onDestinationSelected: (value) =>
|
child: SizedBox(
|
||||||
onSelected(shellTabDestinations[value]),
|
width: kNavigationRailWidth,
|
||||||
destinations: [
|
child: NavigationRail(
|
||||||
for (final destination in shellTabDestinations)
|
key: const ValueKey('shell.navigation-rail'),
|
||||||
NavigationRailDestination(
|
backgroundColor: surface,
|
||||||
icon: KeyedSubtree(
|
minWidth: kNavigationRailWidth,
|
||||||
key: ValueKey('shell.destination.${destination.name}'),
|
labelType: NavigationRailLabelType.all,
|
||||||
// The bar it replaces named each tab in a tooltip too.
|
selectedIndex: index < 0 ? null : index,
|
||||||
child: Tooltip(
|
onDestinationSelected: (value) =>
|
||||||
message: destinationDetails(destination).label,
|
onSelected(shellTabDestinations[value]),
|
||||||
child: icon(destination),
|
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(
|
||||||
trailingAtBottom: true,
|
selected: selected == AppDestination.settings,
|
||||||
trailing: _SettingsRailItem(
|
onTap: () => onSelected(AppDestination.settings),
|
||||||
selected: selected == AppDestination.settings,
|
),
|
||||||
onTap: () => onSelected(AppDestination.settings),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -12,6 +12,11 @@ class WindowsMenuButton extends StatelessWidget {
|
|||||||
|
|
||||||
final WindowManager manager;
|
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
|
@override
|
||||||
Widget build(BuildContext context) => ListenableBuilder(
|
Widget build(BuildContext context) => ListenableBuilder(
|
||||||
listenable: Listenable.merge([
|
listenable: Listenable.merge([
|
||||||
|
|||||||
@@ -69,8 +69,14 @@ class SegmentedBar extends StatefulWidget implements PreferredSizeWidget {
|
|||||||
this.foregroundColor,
|
this.foregroundColor,
|
||||||
this.bottomPadding = 8,
|
this.bottomPadding = 8,
|
||||||
this.backdrop,
|
this.backdrop,
|
||||||
|
this.titleShare,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/// The share of the bar the title always keeps beside the actions, when it
|
||||||
|
/// must hold more than the default (a long conversation name in a narrow
|
||||||
|
/// bar). Null keeps the default shares.
|
||||||
|
final double? titleShare;
|
||||||
|
|
||||||
/// The title; empty shows no title pill unless there is a [subtitle].
|
/// The title; empty shows no title pill unless there is a [subtitle].
|
||||||
final String title;
|
final String title;
|
||||||
|
|
||||||
@@ -390,8 +396,11 @@ class _SegmentedBarState extends State<SegmentedBar> {
|
|||||||
// width (a destination's name) up to [SegmentedBar.maxTitleShare];
|
// width (a destination's name) up to [SegmentedBar.maxTitleShare];
|
||||||
// actions that do not fit beside it move into the More menu.
|
// actions that do not fit beside it move into the More menu.
|
||||||
final width = constraints.maxWidth;
|
final width = constraints.maxWidth;
|
||||||
|
final titleShare = widget.titleShare;
|
||||||
final titleMinimum = titleWidget != null || !showTitle
|
final titleMinimum = titleWidget != null || !showTitle
|
||||||
? width * SegmentedBar.minTitleShare
|
? width * SegmentedBar.minTitleShare
|
||||||
|
: titleShare != null
|
||||||
|
? width * titleShare
|
||||||
: math.max(
|
: math.max(
|
||||||
width * SegmentedBar.minTitleShare,
|
width * SegmentedBar.minTitleShare,
|
||||||
math.min(
|
math.min(
|
||||||
@@ -405,9 +414,9 @@ class _SegmentedBarState extends State<SegmentedBar> {
|
|||||||
width * SegmentedBar.maxTitleShare,
|
width * SegmentedBar.maxTitleShare,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
final minimumTitleShare = widget.separateActionIslands
|
final minimumTitleShare =
|
||||||
? .10
|
titleShare ??
|
||||||
: SegmentedBar.minTitleShare;
|
(widget.separateActionIslands ? .10 : SegmentedBar.minTitleShare);
|
||||||
final besideTitle =
|
final besideTitle =
|
||||||
width - (leading == null ? 0 : segmentedPieceHeight() + 8) - 8;
|
width - (leading == null ? 0 : segmentedPieceHeight() + 8) - 8;
|
||||||
// Actions that cannot move (a model picker) may take the room down
|
// Actions that cannot move (a model picker) may take the room down
|
||||||
|
|||||||
@@ -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.
|
||||||
@@ -0,0 +1,75 @@
|
|||||||
|
# Narrow chat header: title priority, settings in More, floating window
|
||||||
|
|
||||||
|
Run 415, stage 01-implement. Source only under `app/`. Not committed, not captured
|
||||||
|
(ui-review owns captures).
|
||||||
|
|
||||||
|
## Problem
|
||||||
|
|
||||||
|
- At 430px the chat title pill shrank to ~46x44 (a dot): `SegmentedBar` let the
|
||||||
|
non-overflowable selector island take up to 90% of the bar, leaving the title
|
||||||
|
its 10% floor.
|
||||||
|
- The harness mark was squeezed by the title pill's `FittedBox` leading.
|
||||||
|
- In a floating chat window the inner title repeated the window's own title.
|
||||||
|
|
||||||
|
## Changes
|
||||||
|
|
||||||
|
- `lib/ui/adaptive/segmented_bar.dart`: optional `titleShare`. When set, the title
|
||||||
|
keeps that share of the bar (its floor and the actions' ceiling). Default null
|
||||||
|
keeps the old shares for every other bar.
|
||||||
|
- `lib/features/chat/conversation/chat_thread_header.dart`:
|
||||||
|
- `showTitle` (default true). False omits the title pill and folder.
|
||||||
|
- Below 600 logical px (text-scaled, `chatHeaderNarrowWidth`): title keeps
|
||||||
|
`chatHeaderTitleShare` = 0.6 of the bar; the model/mode/thinking controls leave
|
||||||
|
the bar for one `Chat settings` entry in the More menu, which opens them in a
|
||||||
|
sheet with their labels; overflowable actions (Files, terminal, ...) join More.
|
||||||
|
- Wide (600+) layout unchanged.
|
||||||
|
- `lib/features/chat/conversation/chat_thread_view.dart`: `showTitle: !inWindow`
|
||||||
|
(floating window bar names the chat; More keeps `Chat details`); the three
|
||||||
|
controls pass `showLabel: true` (no effect at 600+, where they already show labels).
|
||||||
|
|
||||||
|
## Focused results (memwatch, from app/)
|
||||||
|
|
||||||
|
- Header, chat-bar and segmented-bar focused set (`chat_thread_header_test`,
|
||||||
|
`chat_effort_header_test`, `chat_mode_control_test`, `chat_model_picker_test`,
|
||||||
|
`chat_floating_chrome_test`, `chat_bar_tint_test`, `chat_pane_presentation_test`,
|
||||||
|
`segmented_bar_*`): 83/83 pass.
|
||||||
|
- Those plus the users of the changed header/keys (chat screen mode/model, floating
|
||||||
|
pane, list shortcuts, pane move, conversation and shell tests, terminal
|
||||||
|
bar-action tests, `chat_registration_test`), in one final run: 199 pass, 4 fail.
|
||||||
|
The 4 failures are `test/application/chat_registration_test.dart` (retap and
|
||||||
|
folded-workspace cases). The same 4 fail on untouched HEAD in a detached
|
||||||
|
worktree, so they are pre-existing and not caused by this change.
|
||||||
|
- `tool/analyze.sh`: clean.
|
||||||
|
|
||||||
|
New behavioural tests (`chat_thread_header_test.dart`, group "narrow title priority
|
||||||
|
at 430px"): short title whole (no truncation); long title ellipsized with the
|
||||||
|
title pill >= 60% of the bar; harness mark >= 20px beside the title; More opens
|
||||||
|
the controls in a sheet; Files moves into More; floating bar shows no title pill.
|
||||||
|
|
||||||
|
## Affected UI states (for ui-review to capture)
|
||||||
|
|
||||||
|
- 430px phone, chat bar: Back | title (>= 60% for long titles) | More.
|
||||||
|
Before: Back | ~46px title dot | model | mode | Files | More.
|
||||||
|
- 320px at 2x text: same shape (Back | title | More).
|
||||||
|
- More > Chat settings: sheet with model, mode and thinking controls, labelled.
|
||||||
|
- Floating chat window (any width): bar has no inner title; More has Chat details.
|
||||||
|
- 600px and wider: unchanged.
|
||||||
|
|
||||||
|
## Test expectation changes (narrow behaviour the task asked to change)
|
||||||
|
|
||||||
|
- `chat_thread_header_test.dart`: narrow bar expects the settings entry, not the
|
||||||
|
selector island/icons; wide branch keeps the old checks.
|
||||||
|
- `chat_floating_chrome_test.dart`: at 560px Files is in More (not in the bar).
|
||||||
|
- `chat_model_picker_test.dart`, `chat_screen_model_test.dart`,
|
||||||
|
`chat_screen_mode_test.dart`: phone tests open More > Chat settings to reach the
|
||||||
|
model/mode controls. Expected values are unchanged; `_shown` is now async.
|
||||||
|
|
||||||
|
## Limitations
|
||||||
|
|
||||||
|
- Phone users reach model/mode/thinking through More > Chat settings (two taps, was
|
||||||
|
one). Files is also in More on phones. The 60% title floor needs this at 430px
|
||||||
|
with 48px touch targets.
|
||||||
|
- The settings sheet holds the controls as built when opened. Server changes while
|
||||||
|
it is open show after reopening; each control's own accepted change updates at once.
|
||||||
|
- Harness mark size is asserted at >= 20px; no pre-change baseline was run for that test.
|
||||||
|
- Not verified on a device or in a browser; nothing captured here.
|
||||||
@@ -21,9 +21,9 @@
|
|||||||
- **More menu Stop.** `chat_thread_view.dart` adds a `Stop` item to the header's
|
- **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
|
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.
|
platform, so touch devices without a keyboard can stop.
|
||||||
- **Tasks spinner.** `chat_task_spinner.dart` turns the layers icon once per
|
- **Tasks spinner.** Superseded: `chat_task_spinner.dart` now draws a progress
|
||||||
2.5 s while at least one background task runs; static otherwise and under
|
ring with the running count instead of turning the layers icon. See
|
||||||
reduced motion. Automation-only state keeps its static schedule icon.
|
`notes/background-tasks-ring.md`.
|
||||||
|
|
||||||
## Focused tests (memwatch, from app/)
|
## Focused tests (memwatch, from app/)
|
||||||
|
|
||||||
|
|||||||
@@ -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,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.
|
||||||
@@ -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.
|
||||||
@@ -6,6 +6,8 @@ import 'package:flutter_test/flutter_test.dart';
|
|||||||
import 'package:pipelines_app/core/api_gateway.dart';
|
import 'package:pipelines_app/core/api_gateway.dart';
|
||||||
import 'package:pipelines_app/features/chat/conversation/chat_mode_control.dart';
|
import 'package:pipelines_app/features/chat/conversation/chat_mode_control.dart';
|
||||||
import 'package:pipelines_app/features/chat/screen.dart';
|
import 'package:pipelines_app/features/chat/screen.dart';
|
||||||
|
import 'package:pipelines_app/ui/adaptive/segmented_bar.dart'
|
||||||
|
show segmentedMoreKey;
|
||||||
|
|
||||||
/// A chat destination gateway whose listing can change between reads, as it
|
/// A chat destination gateway whose listing can change between reads, as it
|
||||||
/// does when the server learns a row's mode after the row was first opened.
|
/// does when the server learns a row's mode after the row was first opened.
|
||||||
@@ -101,13 +103,33 @@ Future<void> _pump(
|
|||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The mode the drawn control names, or null when the bar has none. A
|
/// The mode the drawn control names, or null when there is none. A phone bar
|
||||||
/// A narrow phone bar draws only the shield, so read the control itself.
|
/// keeps its selectors in the More menu's settings sheet, so the sheet is
|
||||||
String? _shown(WidgetTester tester) {
|
/// opened to read the control and then dismissed again.
|
||||||
if (_modeControl.evaluate().isEmpty) return null;
|
Future<String?> _shown(WidgetTester tester) async {
|
||||||
|
if (_modeControl.evaluate().isNotEmpty) {
|
||||||
|
final control = find.byType(ChatModeControl);
|
||||||
|
expect(control, findsOneWidget);
|
||||||
|
return tester.widget<ChatModeControl>(control).modeName;
|
||||||
|
}
|
||||||
|
await tester.tap(find.byKey(segmentedMoreKey).hitTestable());
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
if (find.text('Chat settings').evaluate().isEmpty) {
|
||||||
|
// No selectors for this chat: nothing to read; close the menu.
|
||||||
|
await tester.tapAt(const Offset(5, 5));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
await tester.tap(find.text('Chat settings'));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
final control = find.byType(ChatModeControl);
|
final control = find.byType(ChatModeControl);
|
||||||
expect(control, findsOneWidget);
|
final name = control.evaluate().isEmpty
|
||||||
return tester.widget<ChatModeControl>(control).modeName;
|
? null
|
||||||
|
: tester.widget<ChatModeControl>(control).modeName;
|
||||||
|
// Dismiss the sheet through its barrier, above the bar.
|
||||||
|
await tester.tapAt(const Offset(5, 5));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
@@ -123,7 +145,7 @@ void main() {
|
|||||||
await tester.tap(find.byKey(const Key('chat-row-s')));
|
await tester.tap(find.byKey(const Key('chat-row-s')));
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
expect(_shown(tester), 'Ask for permission');
|
expect(await _shown(tester), 'Ask for permission');
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -135,7 +157,7 @@ void main() {
|
|||||||
await _pump(tester, gateway, platform: platform);
|
await _pump(tester, gateway, platform: platform);
|
||||||
await tester.tap(find.byKey(const Key('chat-row-s')));
|
await tester.tap(find.byKey(const Key('chat-row-s')));
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
expect(_shown(tester), isNull);
|
expect(await _shown(tester), isNull);
|
||||||
|
|
||||||
// A reconnect re-reads the list; the open chat follows that row
|
// A reconnect re-reads the list; the open chat follows that row
|
||||||
// without being closed and opened again.
|
// without being closed and opened again.
|
||||||
@@ -151,7 +173,7 @@ void main() {
|
|||||||
_app(gateway, platform: platform, syncToken: 1),
|
_app(gateway, platform: platform, syncToken: 1),
|
||||||
);
|
);
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
expect(_shown(tester), 'Ask for permission');
|
expect(await _shown(tester), 'Ask for permission');
|
||||||
|
|
||||||
// Another device chose Auto; the next re-read keeps the bar in sync.
|
// Another device chose Auto; the next re-read keeps the bar in sync.
|
||||||
gateway.sessions = [
|
gateway.sessions = [
|
||||||
@@ -161,7 +183,7 @@ void main() {
|
|||||||
_app(gateway, platform: platform, syncToken: 2),
|
_app(gateway, platform: platform, syncToken: 2),
|
||||||
);
|
);
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
expect(_shown(tester), 'Auto');
|
expect(await _shown(tester), 'Auto');
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -171,7 +193,7 @@ void main() {
|
|||||||
final gateway = _ModeScreenGateway();
|
final gateway = _ModeScreenGateway();
|
||||||
await _pump(tester, gateway, platform: platform, initialSessionId: 's');
|
await _pump(tester, gateway, platform: platform, initialSessionId: 's');
|
||||||
|
|
||||||
expect(_shown(tester), 'Ask for permission');
|
expect(await _shown(tester), 'Ask for permission');
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('$style: switching chats shows each chat its own mode', (
|
testWidgets('$style: switching chats shows each chat its own mode', (
|
||||||
@@ -198,19 +220,19 @@ void main() {
|
|||||||
|
|
||||||
await tester.tap(find.byKey(const Key('chat-row-s')));
|
await tester.tap(find.byKey(const Key('chat-row-s')));
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
expect(_shown(tester), 'Ask for permission');
|
expect(await _shown(tester), 'Ask for permission');
|
||||||
|
|
||||||
await tester.tap(find.byKey(const Key('chat-row-t')));
|
await tester.tap(find.byKey(const Key('chat-row-t')));
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
expect(_shown(tester), 'Auto');
|
expect(await _shown(tester), 'Auto');
|
||||||
|
|
||||||
await tester.tap(find.byKey(const Key('chat-row-u')));
|
await tester.tap(find.byKey(const Key('chat-row-u')));
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
expect(_shown(tester), isNull);
|
expect(await _shown(tester), isNull);
|
||||||
|
|
||||||
await tester.tap(find.byKey(const Key('chat-row-s')));
|
await tester.tap(find.byKey(const Key('chat-row-s')));
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
expect(_shown(tester), 'Ask for permission');
|
expect(await _shown(tester), 'Ask for permission');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -252,7 +274,7 @@ void main() {
|
|||||||
await runNew(tester);
|
await runNew(tester);
|
||||||
|
|
||||||
expect(find.text('New chat'), findsWidgets);
|
expect(find.text('New chat'), findsWidgets);
|
||||||
expect(_shown(tester), 'Plan');
|
expect(await _shown(tester), 'Plan');
|
||||||
gateway.listGate!.complete();
|
gateway.listGate!.complete();
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
},
|
},
|
||||||
@@ -277,11 +299,11 @@ void main() {
|
|||||||
await runNew(tester);
|
await runNew(tester);
|
||||||
// The row is open on the /new reply, which names no mode.
|
// The row is open on the /new reply, which names no mode.
|
||||||
expect(find.text('New chat'), findsWidgets);
|
expect(find.text('New chat'), findsWidgets);
|
||||||
expect(_shown(tester), isNull);
|
expect(await _shown(tester), isNull);
|
||||||
|
|
||||||
gateway.listGate!.complete();
|
gateway.listGate!.complete();
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
expect(_shown(tester), 'Plan');
|
expect(await _shown(tester), 'Plan');
|
||||||
},
|
},
|
||||||
variant: _desktop,
|
variant: _desktop,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ import 'package:flutter_test/flutter_test.dart';
|
|||||||
import '../../native_back.dart';
|
import '../../native_back.dart';
|
||||||
import 'package:pipelines_app/core/api_gateway.dart';
|
import 'package:pipelines_app/core/api_gateway.dart';
|
||||||
import 'package:pipelines_app/features/chat/screen.dart';
|
import 'package:pipelines_app/features/chat/screen.dart';
|
||||||
|
import 'package:pipelines_app/ui/adaptive/segmented_bar.dart'
|
||||||
|
show segmentedMoreKey;
|
||||||
|
|
||||||
/// A chat destination gateway: one listed session whose harness offers models.
|
/// A chat destination gateway: one listed session whose harness offers models.
|
||||||
class _ScreenGateway implements ApiGateway {
|
class _ScreenGateway implements ApiGateway {
|
||||||
@@ -77,6 +79,22 @@ Future<void> _pumpScreen(
|
|||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// A phone bar keeps the model in the More menu's settings sheet: opens it
|
||||||
|
/// (a wide bar shows the control already).
|
||||||
|
Future<void> _openSettings(WidgetTester tester) async {
|
||||||
|
if (find.byKey(const Key('chat-model')).evaluate().isNotEmpty) return;
|
||||||
|
await tester.tap(find.byKey(segmentedMoreKey).hitTestable());
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
await tester.tap(find.text('Chat settings'));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Dismisses that sheet through its barrier, above the bar.
|
||||||
|
Future<void> _closeSettings(WidgetTester tester) async {
|
||||||
|
await tester.tapAt(const Offset(5, 5));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
}
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
testWidgets('an accepted switch survives leaving and reopening the chat', (
|
testWidgets('an accepted switch survives leaving and reopening the chat', (
|
||||||
tester,
|
tester,
|
||||||
@@ -86,6 +104,7 @@ void main() {
|
|||||||
|
|
||||||
await tester.tap(find.byKey(const Key('chat-row-s')));
|
await tester.tap(find.byKey(const Key('chat-row-s')));
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
|
await _openSettings(tester);
|
||||||
expect(find.byTooltip('Change model (currently model-a)'), findsOneWidget);
|
expect(find.byTooltip('Change model (currently model-a)'), findsOneWidget);
|
||||||
|
|
||||||
await tester.tap(find.byKey(const Key('chat-model')));
|
await tester.tap(find.byKey(const Key('chat-model')));
|
||||||
@@ -93,6 +112,7 @@ void main() {
|
|||||||
await tester.tap(find.text('Model Beta'));
|
await tester.tap(find.text('Model Beta'));
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
expect(find.byTooltip('Change model (currently model-b)'), findsOneWidget);
|
expect(find.byTooltip('Change model (currently model-b)'), findsOneWidget);
|
||||||
|
await _closeSettings(tester);
|
||||||
|
|
||||||
await tester.tap(findNativeBack());
|
await tester.tap(findNativeBack());
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
@@ -102,6 +122,7 @@ void main() {
|
|||||||
// still show the model the server accepted.
|
// still show the model the server accepted.
|
||||||
await tester.tap(find.byKey(const Key('chat-row-s')));
|
await tester.tap(find.byKey(const Key('chat-row-s')));
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
|
await _openSettings(tester);
|
||||||
|
|
||||||
expect(find.byTooltip('Change model (currently model-b)'), findsOneWidget);
|
expect(find.byTooltip('Change model (currently model-b)'), findsOneWidget);
|
||||||
expect(find.byTooltip('Change model (currently model-a)'), findsNothing);
|
expect(find.byTooltip('Change model (currently model-a)'), findsNothing);
|
||||||
@@ -133,6 +154,7 @@ void main() {
|
|||||||
// The deep link opened before any row was tapped: the list's own read
|
// The deep link opened before any row was tapped: the list's own read
|
||||||
// supplies the title and the recorded model, with no second list request.
|
// supplies the title and the recorded model, with no second list request.
|
||||||
expect(find.text('Wire chat'), findsOneWidget);
|
expect(find.text('Wire chat'), findsOneWidget);
|
||||||
|
await _openSettings(tester);
|
||||||
expect(find.byTooltip('Change model (currently model-a)'), findsOneWidget);
|
expect(find.byTooltip('Change model (currently model-a)'), findsOneWidget);
|
||||||
expect(find.byKey(const Key('chat-model')), findsOneWidget);
|
expect(find.byKey(const Key('chat-model')), findsOneWidget);
|
||||||
expect(gateway.count('chat_sessions'), 1);
|
expect(gateway.count('chat_sessions'), 1);
|
||||||
|
|||||||
@@ -673,11 +673,18 @@ void main() {
|
|||||||
});
|
});
|
||||||
await tester.pump();
|
await tester.pump();
|
||||||
await tester.pump(const Duration(milliseconds: 500));
|
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'));
|
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(
|
expect(
|
||||||
find.descendant(of: counter, matching: find.text('2')),
|
find.descendant(of: counter, matching: find.text('2')),
|
||||||
findsOneWidget,
|
findsNWidgets(2),
|
||||||
);
|
);
|
||||||
expect(
|
expect(
|
||||||
find.descendant(of: counter, matching: find.text('12')),
|
find.descendant(of: counter, matching: find.text('12')),
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ import 'package:flutter_test/flutter_test.dart';
|
|||||||
import 'package:pipelines_app/features/chat/conversation/chat_reading_width.dart';
|
import 'package:pipelines_app/features/chat/conversation/chat_reading_width.dart';
|
||||||
import 'package:pipelines_app/features/chat/conversation/chat_thread_view.dart';
|
import 'package:pipelines_app/features/chat/conversation/chat_thread_view.dart';
|
||||||
import 'package:pipelines_app/ui/adaptive/glass_pill.dart';
|
import 'package:pipelines_app/ui/adaptive/glass_pill.dart';
|
||||||
|
import 'package:pipelines_app/ui/adaptive/segmented_bar.dart'
|
||||||
|
show segmentedMoreKey;
|
||||||
import 'package:pipelines_app/ui/adaptive/segmented_bar_pieces.dart';
|
import 'package:pipelines_app/ui/adaptive/segmented_bar_pieces.dart';
|
||||||
|
|
||||||
import 'chat_thread_fixtures.dart';
|
import 'chat_thread_fixtures.dart';
|
||||||
@@ -149,7 +151,8 @@ void main() {
|
|||||||
final header = find.byKey(const Key('chat-thread-header'));
|
final header = find.byKey(const Key('chat-thread-header'));
|
||||||
expect(find.byKey(const Key('chat-mode')), findsNothing);
|
expect(find.byKey(const Key('chat-mode')), findsNothing);
|
||||||
// The round Back, the title pill and the actions pill, which always
|
// The round Back, the title pill and the actions pill, which always
|
||||||
// carries the Files toggle, so it is never drawn empty.
|
// carries the More menu, so it is never drawn empty. A narrow bar moves
|
||||||
|
// the Files toggle into that menu.
|
||||||
expect(
|
expect(
|
||||||
find.descendant(of: header, matching: find.byType(SegmentedPill)),
|
find.descendant(of: header, matching: find.byType(SegmentedPill)),
|
||||||
findsNWidgets(3),
|
findsNWidgets(3),
|
||||||
@@ -159,7 +162,12 @@ void main() {
|
|||||||
of: header,
|
of: header,
|
||||||
matching: find.bySemanticsIdentifier('chat-files-toggle'),
|
matching: find.bySemanticsIdentifier('chat-files-toggle'),
|
||||||
),
|
),
|
||||||
findsOneWidget,
|
findsNothing,
|
||||||
|
);
|
||||||
|
// The bar's own disabled More beside the actions' one.
|
||||||
|
expect(
|
||||||
|
find.descendant(of: header, matching: find.byKey(segmentedMoreKey)),
|
||||||
|
findsWidgets,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ import 'package:pipelines_app/core/api_gateway.dart';
|
|||||||
import 'package:pipelines_app/core/transport/connection_state.dart';
|
import 'package:pipelines_app/core/transport/connection_state.dart';
|
||||||
import 'package:pipelines_app/features/chat/conversation/chat_models.dart';
|
import 'package:pipelines_app/features/chat/conversation/chat_models.dart';
|
||||||
import 'package:pipelines_app/features/chat/conversation/chat_thread_view.dart';
|
import 'package:pipelines_app/features/chat/conversation/chat_thread_view.dart';
|
||||||
|
import 'package:pipelines_app/ui/adaptive/segmented_bar.dart'
|
||||||
|
show segmentedMoreKey;
|
||||||
|
|
||||||
/// A chat thread gateway with scripted model catalog and switch replies.
|
/// A chat thread gateway with scripted model catalog and switch replies.
|
||||||
class _ModelGateway implements ApiGateway {
|
class _ModelGateway implements ApiGateway {
|
||||||
@@ -91,6 +93,13 @@ Future<void> _openThread(
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _openChooser(WidgetTester tester) async {
|
Future<void> _openChooser(WidgetTester tester) async {
|
||||||
|
// A narrow bar keeps the model in the More menu's settings sheet.
|
||||||
|
if (find.byKey(const Key('chat-model')).evaluate().isEmpty) {
|
||||||
|
await tester.tap(find.byKey(segmentedMoreKey).hitTestable());
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
await tester.tap(find.text('Chat settings'));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
}
|
||||||
await tester.tap(find.byKey(const Key('chat-model')));
|
await tester.tap(find.byKey(const Key('chat-model')));
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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_background_tasks.dart';
|
||||||
import 'package:pipelines_app/features/chat/conversation/chat_task_spinner.dart';
|
import 'package:pipelines_app/features/chat/conversation/chat_task_spinner.dart';
|
||||||
|
|
||||||
RotationTransition _rotation(WidgetTester tester) =>
|
final _spinnerFinder = find.byKey(const Key('chat-background-tasks-spinner'));
|
||||||
tester.widget<RotationTransition>(
|
|
||||||
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(
|
Widget _spinner(int running, {Brightness brightness = Brightness.light}) =>
|
||||||
home: Scaffold(
|
MaterialApp(
|
||||||
body: ChatTaskSpinner(
|
theme: ThemeData(colorSchemeSeed: Colors.indigo, brightness: brightness),
|
||||||
spinning: spinning,
|
home: Scaffold(
|
||||||
child: const Icon(Icons.layers_outlined, size: 16),
|
body: Center(child: ChatTaskSpinner(running: running)),
|
||||||
),
|
),
|
||||||
),
|
);
|
||||||
);
|
|
||||||
|
|
||||||
void _reducedMotion(bool reduced) =>
|
void _reducedMotion(bool reduced) =>
|
||||||
TestWidgetsFlutterBinding.ensureInitialized()
|
TestWidgetsFlutterBinding.ensureInitialized()
|
||||||
@@ -51,58 +55,99 @@ class _TasksGateway implements ApiGateway {
|
|||||||
void main() {
|
void main() {
|
||||||
tearDown(() => _reducedMotion(false));
|
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);
|
_reducedMotion(false);
|
||||||
await tester.pumpWidget(_spinner(true));
|
await tester.pumpWidget(_spinner(1, brightness: Brightness.dark));
|
||||||
expect(_rotation(tester).turns.value, 0);
|
expect(
|
||||||
await tester.pump(ChatTaskSpinner.period ~/ 4);
|
_ring(tester).color,
|
||||||
expect(_rotation(tester).turns.value, closeTo(0.25, 0.01));
|
ThemeData(
|
||||||
// Past one full lap the turn starts again from the top.
|
colorSchemeSeed: Colors.indigo,
|
||||||
await tester.pump(
|
brightness: Brightness.dark,
|
||||||
ChatTaskSpinner.period ~/ 4 * 3 + const Duration(milliseconds: 100),
|
).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,
|
tester,
|
||||||
) async {
|
) async {
|
||||||
_reducedMotion(false);
|
_reducedMotion(false);
|
||||||
await tester.pumpWidget(_spinner(false));
|
await tester.pumpWidget(_spinner(0));
|
||||||
await tester.pump(const Duration(seconds: 2));
|
expect(
|
||||||
expect(_rotation(tester).turns.value, 0);
|
find.descendant(
|
||||||
expect(tester.binding.transientCallbackCount, 0);
|
of: _spinnerFinder,
|
||||||
|
matching: find.byType(CircularProgressIndicator),
|
||||||
await tester.pumpWidget(_spinner(true));
|
),
|
||||||
await tester.pump(const Duration(milliseconds: 625));
|
findsNothing,
|
||||||
expect(_rotation(tester).turns.value, greaterThan(0));
|
);
|
||||||
|
expect(
|
||||||
await tester.pumpWidget(_spinner(false));
|
find.descendant(
|
||||||
await tester.pump();
|
of: _spinnerFinder,
|
||||||
expect(_rotation(tester).turns.value, 0);
|
matching: find.byIcon(Icons.layers_outlined),
|
||||||
await tester.pump(const Duration(seconds: 2));
|
),
|
||||||
expect(_rotation(tester).turns.value, 0);
|
findsOneWidget,
|
||||||
|
);
|
||||||
expect(tester.binding.transientCallbackCount, 0);
|
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,
|
tester,
|
||||||
) async {
|
) async {
|
||||||
_reducedMotion(true);
|
_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));
|
await tester.pump(const Duration(seconds: 1));
|
||||||
expect(_rotation(tester).turns.value, 0);
|
expect(_ring(tester).value, ChatTaskSpinner.reducedSegment);
|
||||||
expect(tester.binding.transientCallbackCount, 0);
|
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);
|
_reducedMotion(false);
|
||||||
final gateway = _TasksGateway();
|
final gateway = _TasksGateway();
|
||||||
addTearDown(gateway.close);
|
addTearDown(gateway.close);
|
||||||
gateway.running = const [
|
gateway.running = const [
|
||||||
{'id': 'sh1', 'status': 'running', 'command': 'go test ./...'},
|
{'id': 'sh1', 'status': 'running', 'command': 'go test ./...'},
|
||||||
|
{'id': 'sh2', 'status': 'running', 'command': 'make'},
|
||||||
];
|
];
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
MaterialApp(
|
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();
|
||||||
await tester.pump();
|
await tester.pump();
|
||||||
expect(find.text('1 task'), findsOneWidget);
|
expect(find.text('2 tasks'), findsOneWidget);
|
||||||
final before = _rotation(tester).turns.value;
|
expect(find.byTooltip('Background tasks (2 running)'), findsOneWidget);
|
||||||
await tester.pump(const Duration(milliseconds: 300));
|
expect(_ring(tester).value, isNull);
|
||||||
expect(_rotation(tester).turns.value, greaterThan(before));
|
expect(
|
||||||
|
find.descendant(of: _spinnerFinder, matching: find.text('2')),
|
||||||
|
findsOneWidget,
|
||||||
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,14 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/rendering.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:pipelines_app/features/chat/conversation/chat_bar_control_style.dart';
|
import 'package:pipelines_app/features/chat/conversation/chat_bar_control_style.dart';
|
||||||
import 'package:pipelines_app/features/chat/conversation/chat_thread_view.dart';
|
import 'package:pipelines_app/features/chat/conversation/chat_thread_view.dart';
|
||||||
import 'package:pipelines_app/features/chat/conversation/chat_thread_header.dart';
|
import 'package:pipelines_app/features/chat/conversation/chat_thread_header.dart';
|
||||||
import 'package:pipelines_app/features/chat/conversation/chat_sidebar_controls.dart';
|
import 'package:pipelines_app/features/chat/conversation/chat_sidebar_controls.dart';
|
||||||
import 'package:pipelines_app/features/chat/ui/sessions/chat_adaptive.dart';
|
import 'package:pipelines_app/features/chat/ui/sessions/chat_adaptive.dart';
|
||||||
|
import 'package:pipelines_app/features/chat/ui/sessions/session_row_content.dart';
|
||||||
import 'package:pipelines_app/ui/adaptive/segmented_bar.dart';
|
import 'package:pipelines_app/ui/adaptive/segmented_bar.dart';
|
||||||
|
import 'package:pipelines_app/ui/adaptive/window_margins.dart';
|
||||||
|
|
||||||
import '../../../native_back.dart';
|
import '../../../native_back.dart';
|
||||||
import 'chat_thread_fixtures.dart';
|
import 'chat_thread_fixtures.dart';
|
||||||
@@ -104,10 +107,9 @@ void main() {
|
|||||||
);
|
);
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
expect(tester.takeException(), isNull);
|
expect(tester.takeException(), isNull);
|
||||||
expect(
|
// Narrow: the two selectors wait in the More menu's settings entry.
|
||||||
find.byKey(const Key('chat-model-permission-island')),
|
expect(find.byKey(const Key('chat-model')), findsNothing);
|
||||||
findsOneWidget,
|
expect(find.byKey(const Key('chat-model-permission-island')), findsNothing);
|
||||||
);
|
|
||||||
expect(tester.takeException(), isNull);
|
expect(tester.takeException(), isNull);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -136,11 +138,13 @@ void main() {
|
|||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
final title = find.text(_title);
|
final title = find.text(_title);
|
||||||
final model = find.byKey(const Key('chat-model'));
|
final more = find.byKey(segmentedMoreKey);
|
||||||
final info = find.byKey(const Key('chat-info'));
|
final info = find.byKey(const Key('chat-info'));
|
||||||
final back = find.byKey(const Key('chat-back'));
|
final back = find.byKey(const Key('chat-back'));
|
||||||
expect(title, findsOneWidget);
|
expect(title, findsOneWidget);
|
||||||
expect(model, findsOneWidget);
|
// A narrow bar keeps its selectors in the More menu's settings entry.
|
||||||
|
expect(more, findsWidgets);
|
||||||
|
expect(find.byKey(const Key('chat-model')), findsNothing);
|
||||||
expect(info, findsOneWidget);
|
expect(info, findsOneWidget);
|
||||||
expect(back, findsOneWidget);
|
expect(back, findsOneWidget);
|
||||||
expect(tester.takeException(), isNull);
|
expect(tester.takeException(), isNull);
|
||||||
@@ -155,14 +159,11 @@ void main() {
|
|||||||
// selector island in the trailing row.
|
// selector island in the trailing row.
|
||||||
double centerY(Finder finder) => tester.getCenter(finder).dy;
|
double centerY(Finder finder) => tester.getCenter(finder).dy;
|
||||||
expect((centerY(back) - centerY(info)).abs(), lessThan(16));
|
expect((centerY(back) - centerY(info)).abs(), lessThan(16));
|
||||||
expect((centerY(model) - centerY(info)).abs(), lessThan(16));
|
expect((centerY(more.first) - centerY(info)).abs(), lessThan(16));
|
||||||
expect(find.descendant(of: info, matching: title), findsOneWidget);
|
expect(find.descendant(of: info, matching: title), findsOneWidget);
|
||||||
double right(Finder finder) => tester.getTopRight(finder).dx;
|
double right(Finder finder) => tester.getTopRight(finder).dx;
|
||||||
expect(right(back), lessThanOrEqualTo(tester.getTopLeft(info).dx));
|
expect(right(back), lessThanOrEqualTo(tester.getTopLeft(info).dx));
|
||||||
expect(find.byIcon(Icons.memory_outlined), findsOneWidget);
|
expect(find.byIcon(Icons.tune), findsNothing);
|
||||||
final modelSemantics = tester.getSemantics(model);
|
|
||||||
expect(modelSemantics.label, contains('Change model'));
|
|
||||||
expect(modelSemantics.label, contains('currently'));
|
|
||||||
expect(
|
expect(
|
||||||
find.textContaining('an-extremely-long-recorded-model-id'),
|
find.textContaining('an-extremely-long-recorded-model-id'),
|
||||||
findsNothing,
|
findsNothing,
|
||||||
@@ -216,41 +217,31 @@ void main() {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
final selectors = find.byKey(const Key('chat-model-permission-island'));
|
|
||||||
final actions = find.byKey(const Key('chat-actions-island'));
|
final actions = find.byKey(const Key('chat-actions-island'));
|
||||||
expect(selectors, findsOneWidget);
|
|
||||||
expect(actions, findsOneWidget);
|
expect(actions, findsOneWidget);
|
||||||
expect(
|
|
||||||
(tester.getCenter(selectors).dy - tester.getCenter(actions).dy).abs(),
|
|
||||||
lessThan(16),
|
|
||||||
);
|
|
||||||
expect(find.byKey(const Key('chat-next')), findsNothing);
|
expect(find.byKey(const Key('chat-next')), findsNothing);
|
||||||
expect(find.text('Next chat'), findsNothing);
|
expect(find.text('Next chat'), findsNothing);
|
||||||
expect(find.byKey(const Key('chat-model')), findsOneWidget);
|
if (width < chatHeaderNarrowWidth) {
|
||||||
expect(find.byKey(const Key('chat-mode')), findsOneWidget);
|
// The selectors wait in the More menu's settings entry.
|
||||||
if (width < 600) {
|
expect(find.byKey(const Key('chat-model')), findsNothing);
|
||||||
|
expect(find.byKey(const Key('chat-mode')), findsNothing);
|
||||||
expect(find.text('model-a'), findsNothing);
|
expect(find.text('model-a'), findsNothing);
|
||||||
expect(find.text('Ask before making changes'), findsNothing);
|
expect(find.text('Ask before making changes'), findsNothing);
|
||||||
expect(find.byIcon(Icons.memory_outlined), findsOneWidget);
|
} else {
|
||||||
expect(find.byIcon(Icons.shield_outlined), findsOneWidget);
|
final selectors = find.byKey(const Key('chat-model-permission-island'));
|
||||||
expect(
|
expect(selectors, findsOneWidget);
|
||||||
tester.getSemantics(find.byKey(const Key('chat-model'))).label,
|
|
||||||
contains('Change model, currently'),
|
|
||||||
);
|
|
||||||
expect(
|
|
||||||
tester.getSemantics(find.byKey(const Key('chat-mode'))).label,
|
|
||||||
contains('Change mode, currently'),
|
|
||||||
);
|
|
||||||
expect(
|
expect(
|
||||||
(tester.getCenter(selectors).dy - tester.getCenter(actions).dy).abs(),
|
(tester.getCenter(selectors).dy - tester.getCenter(actions).dy).abs(),
|
||||||
lessThan(16),
|
lessThan(16),
|
||||||
);
|
);
|
||||||
}
|
expect(find.byKey(const Key('chat-model')), findsOneWidget);
|
||||||
for (final key in ['chat-model', 'chat-mode']) {
|
expect(find.byKey(const Key('chat-mode')), findsOneWidget);
|
||||||
expect(
|
for (final key in ['chat-model', 'chat-mode']) {
|
||||||
tester.getSize(find.byKey(Key(key))).width,
|
expect(
|
||||||
greaterThanOrEqualTo(48),
|
tester.getSize(find.byKey(Key(key))).width,
|
||||||
);
|
greaterThanOrEqualTo(48),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
expect(find.text('Sidebar action'), findsNothing);
|
expect(find.text('Sidebar action'), findsNothing);
|
||||||
expect(find.text('Pane action'), findsNothing);
|
expect(find.text('Pane action'), findsNothing);
|
||||||
@@ -354,4 +345,145 @@ void main() {
|
|||||||
expect(chatBarButtonPadding.left, 12);
|
expect(chatBarButtonPadding.left, 12);
|
||||||
expect(chatBarButtonPadding.right, 12);
|
expect(chatBarButtonPadding.right, 12);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
group('narrow title priority at 430px', () {
|
||||||
|
const width = 430.0;
|
||||||
|
const longTitle =
|
||||||
|
'A conversation title long enough to need an ellipsis at 430px';
|
||||||
|
|
||||||
|
void useWidth(WidgetTester tester) {
|
||||||
|
tester.view.physicalSize = const Size(width, 900);
|
||||||
|
tester.view.devicePixelRatio = 1;
|
||||||
|
addTearDown(tester.view.resetPhysicalSize);
|
||||||
|
addTearDown(tester.view.resetDevicePixelRatio);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget bar({
|
||||||
|
required String title,
|
||||||
|
bool showTitle = true,
|
||||||
|
Widget? identity,
|
||||||
|
}) => _host(
|
||||||
|
Align(
|
||||||
|
alignment: Alignment.topLeft,
|
||||||
|
child: SizedBox(
|
||||||
|
width: width,
|
||||||
|
child: ChatThreadHeader(
|
||||||
|
title: title,
|
||||||
|
folder: 'demo',
|
||||||
|
onInfo: () {},
|
||||||
|
showTitle: showTitle,
|
||||||
|
showBack: true,
|
||||||
|
onBack: () {},
|
||||||
|
identity: identity,
|
||||||
|
controls: const [
|
||||||
|
SizedBox(key: Key('header-control-1'), width: 48, height: 48),
|
||||||
|
SizedBox(key: Key('header-control-2'), width: 48, height: 48),
|
||||||
|
],
|
||||||
|
actions: [
|
||||||
|
ChatBarAction(
|
||||||
|
label: 'Files',
|
||||||
|
onPressed: () {},
|
||||||
|
materialIcon: Icons.folder_outlined,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
// The bar's own width: the window less its phone side margins.
|
||||||
|
double barWidth() => width - 2 * WindowMargins.narrowSide;
|
||||||
|
|
||||||
|
bool truncated(WidgetTester tester, String text) {
|
||||||
|
final render = tester.renderObject<RenderParagraph>(find.text(text));
|
||||||
|
final painter = TextPainter(
|
||||||
|
text: render.text,
|
||||||
|
textDirection: TextDirection.ltr,
|
||||||
|
textScaler: render.textScaler,
|
||||||
|
maxLines: 1,
|
||||||
|
)..layout();
|
||||||
|
final full = painter.width;
|
||||||
|
painter.dispose();
|
||||||
|
return full > render.size.width + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
testWidgets('a short title reads whole and the selectors collapse', (
|
||||||
|
tester,
|
||||||
|
) async {
|
||||||
|
useWidth(tester);
|
||||||
|
await tester.pumpWidget(bar(title: 'Fixture chat 1'));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
expect(tester.takeException(), isNull);
|
||||||
|
expect(truncated(tester, 'Fixture chat 1'), isFalse);
|
||||||
|
expect(find.byKey(const Key('header-control-1')), findsNothing);
|
||||||
|
});
|
||||||
|
|
||||||
|
testWidgets('a long title ellipsizes and keeps 60% of the bar', (
|
||||||
|
tester,
|
||||||
|
) async {
|
||||||
|
useWidth(tester);
|
||||||
|
await tester.pumpWidget(bar(title: longTitle));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
expect(tester.takeException(), isNull);
|
||||||
|
expect(truncated(tester, longTitle), isTrue);
|
||||||
|
final info = tester.getSize(find.byKey(const Key('chat-info')));
|
||||||
|
expect(info.width, greaterThanOrEqualTo(barWidth() * 0.6 - 1));
|
||||||
|
});
|
||||||
|
|
||||||
|
testWidgets('the harness mark keeps its size beside the title', (
|
||||||
|
tester,
|
||||||
|
) async {
|
||||||
|
useWidth(tester);
|
||||||
|
await tester.pumpWidget(
|
||||||
|
bar(
|
||||||
|
title: 'Fixture chat 1',
|
||||||
|
identity: ChatSessionAvatar(
|
||||||
|
session: <String, dynamic>{'id': 's', 'backend': 'opencode'},
|
||||||
|
selected: true,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
expect(tester.takeException(), isNull);
|
||||||
|
final mark = tester.getSize(find.byType(ImageIcon));
|
||||||
|
expect(mark.width, greaterThanOrEqualTo(20));
|
||||||
|
expect(mark.height, greaterThanOrEqualTo(20));
|
||||||
|
});
|
||||||
|
|
||||||
|
testWidgets('the More menu opens the controls in a sheet', (tester) async {
|
||||||
|
useWidth(tester);
|
||||||
|
await tester.pumpWidget(bar(title: 'Fixture chat 1'));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
expect(find.byKey(const Key('header-control-1')), findsNothing);
|
||||||
|
await tester.tap(find.byKey(segmentedMoreKey).hitTestable());
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
await tester.tap(find.text('Chat settings'));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
expect(find.byKey(const Key('header-control-1')), findsOneWidget);
|
||||||
|
expect(find.byKey(const Key('header-control-2')), findsOneWidget);
|
||||||
|
expect(tester.takeException(), isNull);
|
||||||
|
});
|
||||||
|
|
||||||
|
testWidgets('a narrow bar moves Files into its More menu', (tester) async {
|
||||||
|
useWidth(tester);
|
||||||
|
await tester.pumpWidget(bar(title: 'Fixture chat 1'));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
expect(find.byTooltip('Files'), findsNothing);
|
||||||
|
await tester.tap(find.byKey(segmentedMoreKey).hitTestable());
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
expect(find.text('Files'), findsOneWidget);
|
||||||
|
expect(tester.takeException(), isNull);
|
||||||
|
});
|
||||||
|
|
||||||
|
testWidgets('a floating window bar shows no title pill', (tester) async {
|
||||||
|
useWidth(tester);
|
||||||
|
await tester.pumpWidget(bar(title: 'Fixture chat 1', showTitle: false));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
expect(find.text('Fixture chat 1'), findsNothing);
|
||||||
|
expect(find.byKey(const Key('chat-info')), findsNothing);
|
||||||
|
expect(find.byKey(const Key('chat-back')), findsOneWidget);
|
||||||
|
expect(find.byKey(const Key('chat-actions-island')), findsOneWidget);
|
||||||
|
expect(tester.takeException(), isNull);
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -604,4 +604,28 @@ void main() {
|
|||||||
expect(find.text('Nightly review'), findsWidgets);
|
expect(find.text('Nightly review'), findsWidgets);
|
||||||
expect(launches, 0);
|
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]);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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:flutter_test/flutter_test.dart';
|
||||||
import 'package:pipelines_app/core/api_gateway.dart';
|
import 'package:pipelines_app/core/api_gateway.dart';
|
||||||
import 'package:pipelines_app/features/runs/screen.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 {
|
class _Gateway implements ApiGateway {
|
||||||
final listRequests = <Completer<JsonMap>>[];
|
final listRequests = <Completer<JsonMap>>[];
|
||||||
@@ -53,7 +58,7 @@ void main() {
|
|||||||
await tester.pump();
|
await tester.pump();
|
||||||
expect(gateway.listRequests, hasLength(2));
|
expect(gateway.listRequests, hasLength(2));
|
||||||
// No row is invented while the fresh read is outstanding.
|
// 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({
|
gateway.listRequests[1].complete({
|
||||||
'runs': [
|
'runs': [
|
||||||
{'id': 2, 'title': 'New run', 'status': 'running'},
|
{'id': 2, 'title': 'New run', 'status': 'running'},
|
||||||
@@ -63,7 +68,7 @@ void main() {
|
|||||||
await tester.pump();
|
await tester.pump();
|
||||||
await tester.pump();
|
await tester.pump();
|
||||||
|
|
||||||
expect(find.text('New run'), findsOneWidget);
|
expect(_rowTitled('New run'), findsOneWidget);
|
||||||
expect(gateway.listRequests, hasLength(2));
|
expect(gateway.listRequests, hasLength(2));
|
||||||
expect(gateway.detailRequests, isEmpty);
|
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',
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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);
|
||||||
|
});
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user