Merge commit 'a2e6f8557ee46a545a9b4b2e7c5440b947b7c4df' into pipelines/run-20261111-0420-cupertino-out-artifacts-9258

This commit is contained in:
2026-11-11 04:50:39 +00:00
17 changed files with 172 additions and 460 deletions
@@ -1,6 +1,5 @@
import 'dart:async'; import 'dart:async';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
@@ -76,7 +75,6 @@ class _ChatShellCardActionsState extends State<ChatShellCardActions> {
key: const Key('chat-shell-run-stop'), key: const Key('chat-shell-run-stop'),
label: stopping ? chatShellStoppingLabel : chatShellStopLabel, label: stopping ? chatShellStoppingLabel : chatShellStopLabel,
material: Icons.stop, material: Icons.stop,
cupertino: CupertinoIcons.stop_fill,
destructive: true, destructive: true,
onPressed: stopping onPressed: stopping
? null ? null
@@ -87,9 +85,6 @@ class _ChatShellCardActionsState extends State<ChatShellCardActions> {
key: const Key('chat-shell-run-copy'), key: const Key('chat-shell-run-copy'),
label: _copied ? chatShellCopiedLabel : chatShellCopyLabel, label: _copied ? chatShellCopiedLabel : chatShellCopyLabel,
material: _copied ? Icons.check : Icons.copy_outlined, material: _copied ? Icons.check : Icons.copy_outlined,
cupertino: _copied
? CupertinoIcons.checkmark
: CupertinoIcons.doc_on_doc,
onPressed: () => unawaited(_copy()), onPressed: () => unawaited(_copy()),
), ),
if (!run.running) if (!run.running)
@@ -103,9 +98,6 @@ class _ChatShellCardActionsState extends State<ChatShellCardActions> {
material: share == ChatShellShareState.sent material: share == ChatShellShareState.sent
? Icons.check ? Icons.check
: Icons.send_outlined, : Icons.send_outlined,
cupertino: share == ChatShellShareState.sent
? CupertinoIcons.checkmark
: CupertinoIcons.paperplane,
onPressed: share == ChatShellShareState.idle onPressed: share == ChatShellShareState.idle
? () => unawaited(controller.share(run.id)) ? () => unawaited(controller.share(run.id))
: null, : null,
@@ -115,7 +107,6 @@ class _ChatShellCardActionsState extends State<ChatShellCardActions> {
key: const Key('chat-shell-run-expand'), key: const Key('chat-shell-run-expand'),
label: chatShellFullScreenLabel, label: chatShellFullScreenLabel,
material: Icons.fullscreen, material: Icons.fullscreen,
cupertino: CupertinoIcons.fullscreen,
onPressed: widget.onFullScreen, onPressed: widget.onFullScreen,
), ),
], ],
@@ -126,33 +117,9 @@ class _ChatShellCardActionsState extends State<ChatShellCardActions> {
required Key key, required Key key,
required String label, required String label,
required IconData material, required IconData material,
required IconData cupertino,
required VoidCallback? onPressed, required VoidCallback? onPressed,
bool destructive = false, bool destructive = false,
}) { }) {
if (widget.cupertino) {
final color = destructive
? CupertinoColors.systemRed.resolveFrom(context)
: null;
return CupertinoButton(
key: key,
padding: const EdgeInsets.symmetric(horizontal: 8),
onPressed: onPressed,
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(cupertino, color: onPressed == null ? null : color),
const SizedBox(width: 6),
Text(
label,
style: onPressed == null || color == null
? null
: TextStyle(color: color),
),
],
),
);
}
final style = destructive final style = destructive
? TextButton.styleFrom( ? TextButton.styleFrom(
foregroundColor: Theme.of(context).colorScheme.error, foregroundColor: Theme.of(context).colorScheme.error,
@@ -1,6 +1,5 @@
import 'dart:async'; import 'dart:async';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import '../../../ui/adaptive/segmented_bar_overflow.dart'; import '../../../ui/adaptive/segmented_bar_overflow.dart';
@@ -22,24 +21,11 @@ class ChatShellDismissButton extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
if (!cupertino) { return IconButton(
return IconButton( key: const Key('chat-shell-run-dismiss'),
key: const Key('chat-shell-run-dismiss'), tooltip: chatShellDismissLabel,
tooltip: chatShellDismissLabel, icon: const Icon(Icons.close),
icon: const Icon(Icons.close), onPressed: onPressed,
onPressed: onPressed,
);
}
return Semantics(
label: chatShellDismissLabel,
button: true,
excludeSemantics: true,
child: CupertinoButton(
key: const Key('chat-shell-run-dismiss'),
padding: const EdgeInsets.symmetric(horizontal: 8),
onPressed: onPressed,
child: const Icon(CupertinoIcons.xmark),
),
); );
} }
} }
@@ -1,9 +1,7 @@
import '../../../shell/windows/window_scope.dart'; import '../../../shell/windows/window_scope.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import '../../../ui/adaptive/app_popups.dart'; import '../../../ui/adaptive/app_popups.dart';
import '../ui/sessions/chat_adaptive.dart';
import '../ui/transcript/chat_turn_chip.dart'; import '../ui/transcript/chat_turn_chip.dart';
import 'chat_shell_history.dart'; import 'chat_shell_history.dart';
import 'chat_shell_history_view.dart'; import 'chat_shell_history_view.dart';
@@ -26,20 +24,10 @@ class ChatShellHistoryChip extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final cupertino = final color = Theme.of(context).colorScheme.onSurfaceVariant;
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
final color = cupertino
? CupertinoColors.secondaryLabel.resolveFrom(context)
: Theme.of(context).colorScheme.onSurfaceVariant;
return ChatTurnChip( return ChatTurnChip(
chipKey: const Key('chat-shell-history-chip'), chipKey: const Key('chat-shell-history-chip'),
leading: Icon( leading: Icon(Icons.terminal, size: 14, color: color),
cupertino
? CupertinoIcons.chevron_left_slash_chevron_right
: Icons.terminal,
size: 14,
color: color,
),
label: chatShellHistoryLabel(runIds.length), label: chatShellHistoryLabel(runIds.length),
color: color, color: color,
semanticsLabel: chatShellHistorySemantics(runIds.length), semanticsLabel: chatShellHistorySemantics(runIds.length),
@@ -1,6 +1,5 @@
import 'dart:async'; import 'dart:async';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
@@ -25,11 +24,7 @@ Future<void> openChatShellHistoryOutput(
runId: runId, runId: runId,
cupertino: cupertino, cupertino: cupertino,
); );
return Navigator.of(context).push<void>( return Navigator.push<void>(context, MaterialPageRoute<void>(builder: page));
cupertino
? CupertinoPageRoute<void>(builder: page)
: MaterialPageRoute<void>(builder: page),
);
} }
/// One dismissed command: everything the server kept of its output in the /// One dismissed command: everything the server kept of its output in the
@@ -93,7 +88,6 @@ class _ChatShellHistoryOutputPageState
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final cupertino = widget.cupertino;
final held = widget.controller.dismissedRun(widget.runId); final held = widget.controller.dismissedRun(widget.runId);
final title = Text( final title = Text(
held == null ? 'Command' : '\$ ${held.command}', held == null ? 'Command' : '\$ ${held.command}',
@@ -110,28 +104,18 @@ class _ChatShellHistoryOutputPageState
if (snapshot.hasError) { if (snapshot.hasError) {
return Text( return Text(
"Couldn't read the output: ${snapshot.error}", "Couldn't read the output: ${snapshot.error}",
style: chatCardSecondaryStyle(context, cupertino), style: chatCardSecondaryStyle(context, false),
); );
} }
final full = snapshot.data; final full = snapshot.data;
if (full == null) { if (full == null) {
return Center( return const Center(child: CircularProgressIndicator());
child: cupertino
? const CupertinoActivityIndicator()
: const CircularProgressIndicator(),
);
} }
return _content(context, full); return _content(context, full);
}, },
), ),
), ),
); );
if (cupertino) {
return CupertinoPageScaffold(
navigationBar: CupertinoNavigationBar(middle: title),
child: body,
);
}
return Scaffold( return Scaffold(
appBar: AppBar(title: title), appBar: AppBar(title: title),
body: body, body: body,
@@ -139,7 +123,6 @@ class _ChatShellHistoryOutputPageState
} }
Widget _content(BuildContext context, ChatShellRun full) { Widget _content(BuildContext context, ChatShellRun full) {
final cupertino = widget.cupertino;
final session = _session ??= ChatShellTerminalSession( final session = _session ??= ChatShellTerminalSession(
full, full,
onInput: (_) {}, onInput: (_) {},
@@ -155,11 +138,11 @@ class _ChatShellHistoryOutputPageState
runSpacing: 4, runSpacing: 4,
crossAxisAlignment: WrapCrossAlignment.center, crossAxisAlignment: WrapCrossAlignment.center,
children: [ children: [
ChatShellStatus(run: full, cupertino: cupertino), ChatShellStatus(run: full, cupertino: false),
if (full.directory.isNotEmpty) if (full.directory.isNotEmpty)
Text( Text(
full.directory, full.directory,
style: chatCardSecondaryStyle(context, cupertino), style: chatCardSecondaryStyle(context, false),
), ),
], ],
), ),
@@ -169,11 +152,11 @@ class _ChatShellHistoryOutputPageState
? Text( ? Text(
'No output.', 'No output.',
key: const Key('chat-shell-output-empty'), key: const Key('chat-shell-output-empty'),
style: chatCardSecondaryStyle(context, cupertino), style: chatCardSecondaryStyle(context, false),
) )
: ChatShellTerminalView( : ChatShellTerminalView(
session: session, session: session,
cupertino: cupertino, cupertino: false,
fill: true, fill: true,
), ),
), ),
@@ -203,9 +186,6 @@ class _ChatShellHistoryOutputPageState
key: const Key('chat-shell-history-copy'), key: const Key('chat-shell-history-copy'),
label: _copied ? chatShellCopiedLabel : chatShellCopyLabel, label: _copied ? chatShellCopiedLabel : chatShellCopyLabel,
material: _copied ? Icons.check : Icons.copy_outlined, material: _copied ? Icons.check : Icons.copy_outlined,
cupertino: _copied
? CupertinoIcons.checkmark
: CupertinoIcons.doc_on_doc,
onPressed: () => unawaited(_copy(full)), onPressed: () => unawaited(_copy(full)),
), ),
_button( _button(
@@ -218,9 +198,6 @@ class _ChatShellHistoryOutputPageState
material: share == ChatShellShareState.sent material: share == ChatShellShareState.sent
? Icons.check ? Icons.check
: Icons.send_outlined, : Icons.send_outlined,
cupertino: share == ChatShellShareState.sent
? CupertinoIcons.checkmark
: CupertinoIcons.paperplane,
onPressed: share == ChatShellShareState.idle onPressed: share == ChatShellShareState.idle
? () => unawaited(controller.share(widget.runId)) ? () => unawaited(controller.share(widget.runId))
: null, : null,
@@ -229,7 +206,6 @@ class _ChatShellHistoryOutputPageState
key: const Key('chat-shell-history-page-restore'), key: const Key('chat-shell-history-page-restore'),
label: 'Restore', label: 'Restore',
material: Icons.restore, material: Icons.restore,
cupertino: CupertinoIcons.arrow_counterclockwise,
onPressed: () => unawaited(_restore()), onPressed: () => unawaited(_restore()),
), ),
], ],
@@ -241,8 +217,8 @@ class _ChatShellHistoryOutputPageState
error, error,
style: chatCardSecondaryStyle( style: chatCardSecondaryStyle(
context, context,
widget.cupertino, false,
)?.copyWith(color: chatCardErrorColor(context, widget.cupertino)), )?.copyWith(color: chatCardErrorColor(context, false)),
), ),
), ),
], ],
@@ -253,20 +229,8 @@ class _ChatShellHistoryOutputPageState
required Key key, required Key key,
required String label, required String label,
required IconData material, required IconData material,
required IconData cupertino,
required VoidCallback? onPressed, required VoidCallback? onPressed,
}) { }) {
if (widget.cupertino) {
return CupertinoButton(
key: key,
padding: const EdgeInsets.symmetric(horizontal: 8),
onPressed: onPressed,
child: Row(
mainAxisSize: MainAxisSize.min,
children: [Icon(cupertino), const SizedBox(width: 6), Text(label)],
),
);
}
return TextButton.icon( return TextButton.icon(
key: key, key: key,
onPressed: onPressed, onPressed: onPressed,
@@ -1,11 +1,9 @@
import 'dart:async'; import 'dart:async';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import '../../../ui/text/monospace.dart'; import '../../../ui/text/monospace.dart';
import '../conversation/chat_card_styles.dart'; import '../conversation/chat_card_styles.dart';
import '../ui/sessions/chat_adaptive.dart';
import 'chat_shell_history_output_page.dart'; import 'chat_shell_history_output_page.dart';
import 'chat_shell_run.dart'; import 'chat_shell_run.dart';
import 'chat_shell_runs_controller.dart'; import 'chat_shell_runs_controller.dart';
@@ -54,8 +52,6 @@ class _ChatShellHistoryViewState extends State<ChatShellHistoryView> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final cupertino =
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
final list = ListenableBuilder( final list = ListenableBuilder(
listenable: widget.controller.membership, listenable: widget.controller.membership,
builder: (context, _) { builder: (context, _) {
@@ -80,18 +76,16 @@ class _ChatShellHistoryViewState extends State<ChatShellHistoryView> {
padding: const EdgeInsets.all(16), padding: const EdgeInsets.all(16),
child: Text( child: Text(
'Every command here was restored to the transcript.', 'Every command here was restored to the transcript.',
style: chatCardSecondaryStyle(context, cupertino), style: chatCardSecondaryStyle(context, false),
), ),
), ),
for (final run in runs) _entry(context, run, cupertino), for (final run in runs) _entry(context, run),
], ],
); );
}, },
); );
final style = cupertino final style = Theme.of(context).textTheme.bodyMedium;
? CupertinoTheme.of(context).textTheme.textStyle // Entries are Material list tiles inside the surface.
: Theme.of(context).textTheme.bodyMedium;
// Entries are Material list tiles inside a Cupertino surface too.
final content = Material( final content = Material(
type: MaterialType.transparency, type: MaterialType.transparency,
child: DefaultTextStyle.merge(style: style, child: list), child: DefaultTextStyle.merge(style: style, child: list),
@@ -105,8 +99,8 @@ class _ChatShellHistoryViewState extends State<ChatShellHistoryView> {
); );
} }
Widget _entry(BuildContext context, ChatShellRun run, bool cupertino) { Widget _entry(BuildContext context, ChatShellRun run) {
final secondary = chatCardSecondaryStyle(context, cupertino); final secondary = chatCardSecondaryStyle(context, false);
final refusal = _refusals[run.id]; final refusal = _refusals[run.id];
final command = run.purged || run.command.isEmpty final command = run.purged || run.command.isEmpty
? Text(chatShellCommandNotKept, style: secondary) ? Text(chatShellCommandNotKept, style: secondary)
@@ -124,7 +118,7 @@ class _ChatShellHistoryViewState extends State<ChatShellHistoryView> {
runSpacing: 4, runSpacing: 4,
crossAxisAlignment: WrapCrossAlignment.center, crossAxisAlignment: WrapCrossAlignment.center,
children: [ children: [
ChatShellStatus(run: run, cupertino: cupertino), ChatShellStatus(run: run, cupertino: false),
Text(chatShellRunTime(context, run.startedAt), style: secondary), Text(chatShellRunTime(context, run.startedAt), style: secondary),
if (run.purged) Text(chatShellOutputNotKept, style: secondary), if (run.purged) Text(chatShellOutputNotKept, style: secondary),
if (refusal != null) if (refusal != null)
@@ -132,20 +126,13 @@ class _ChatShellHistoryViewState extends State<ChatShellHistoryView> {
refusal, refusal,
key: const Key('chat-shell-history-refusal'), key: const Key('chat-shell-history-refusal'),
style: secondary?.copyWith( style: secondary?.copyWith(
color: chatCardErrorColor(context, cupertino), color: chatCardErrorColor(context, false),
), ),
), ),
], ],
); );
final restore = run.purged final restore = run.purged
? null ? null
: cupertino
? CupertinoButton(
key: ValueKey<String>('chat-shell-history-restore-${run.id}'),
padding: const EdgeInsets.symmetric(horizontal: 8),
onPressed: () => unawaited(_restore(run.id)),
child: const Text(chatShellRestoreLabel),
)
: TextButton( : TextButton(
key: ValueKey<String>('chat-shell-history-restore-${run.id}'), key: ValueKey<String>('chat-shell-history-restore-${run.id}'),
onPressed: () => unawaited(_restore(run.id)), onPressed: () => unawaited(_restore(run.id)),
@@ -164,7 +151,7 @@ class _ChatShellHistoryViewState extends State<ChatShellHistoryView> {
context, context,
controller: widget.controller, controller: widget.controller,
runId: run.id, runId: run.id,
cupertino: cupertino, cupertino: false,
), ),
), ),
); );
@@ -1,4 +1,3 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import '../conversation/chat_card_styles.dart'; import '../conversation/chat_card_styles.dart';
@@ -13,10 +12,8 @@ class ChatShellModeIndicator extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final accent = cupertino final accent = Theme.of(context).colorScheme.primary;
? CupertinoTheme.of(context).primaryColor final label = (chatCardBodyStyle(context, false) ?? const TextStyle())
: Theme.of(context).colorScheme.primary;
final label = (chatCardBodyStyle(context, cupertino) ?? const TextStyle())
.copyWith(color: accent, fontWeight: FontWeight.w600); .copyWith(color: accent, fontWeight: FontWeight.w600);
return Semantics( return Semantics(
key: const Key('chat-composer-shell-mode'), key: const Key('chat-composer-shell-mode'),
@@ -35,9 +32,7 @@ class ChatShellModeIndicator extends StatelessWidget {
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
Icon( Icon(
cupertino Icons.terminal,
? CupertinoIcons.chevron_left_slash_chevron_right
: Icons.terminal,
color: accent, color: accent,
size: MediaQuery.textScalerOf( size: MediaQuery.textScalerOf(
context, context,
@@ -49,7 +44,7 @@ class ChatShellModeIndicator extends StatelessWidget {
), ),
Text( Text(
chatShellModeHint, chatShellModeHint,
style: chatCardSecondaryStyle(context, cupertino), style: chatCardSecondaryStyle(context, false),
), ),
], ],
), ),
@@ -36,7 +36,7 @@ class ChatShellOutputView extends StatelessWidget {
return Text( return Text(
'No output.', 'No output.',
key: const Key('chat-shell-output-empty'), key: const Key('chat-shell-output-empty'),
style: chatCardSecondaryStyle(context, cupertino), style: chatCardSecondaryStyle(context, false),
); );
} }
final session = controller.terminals.session(run); final session = controller.terminals.session(run);
@@ -47,7 +47,7 @@ class ChatShellOutputView extends StatelessWidget {
ChatShellTerminalView( ChatShellTerminalView(
key: viewKey, key: viewKey,
session: session, session: session,
cupertino: cupertino, cupertino: false,
autoResize: !fullScreen, autoResize: !fullScreen,
), ),
if (session.live && !fullScreen) if (session.live && !fullScreen)
@@ -55,7 +55,7 @@ class ChatShellOutputView extends StatelessWidget {
padding: const EdgeInsets.only(top: 8), padding: const EdgeInsets.only(top: 8),
child: ChatShellTerminalKeys( child: ChatShellTerminalKeys(
session: session, session: session,
cupertino: cupertino, cupertino: false,
field: chatShellTouchFirst(), field: chatShellTouchFirst(),
), ),
), ),
@@ -1,12 +1,9 @@
import 'dart:async'; import 'dart:async';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import '../../../ui/text/monospace.dart'; import '../../../ui/text/monospace.dart';
import '../../../ui/theme/app_theme.dart';
import '../conversation/chat_card_styles.dart'; import '../conversation/chat_card_styles.dart';
import '../ui/sessions/chat_adaptive.dart';
import 'chat_shell_card_actions.dart'; import 'chat_shell_card_actions.dart';
import 'chat_shell_dismiss.dart'; import 'chat_shell_dismiss.dart';
import 'chat_shell_output_view.dart'; import 'chat_shell_output_view.dart';
@@ -43,13 +40,13 @@ class _ChatShellRunCardState extends State<ChatShellRunCard> {
bool _fullScreen = false; bool _fullScreen = false;
int _viewGeneration = 0; int _viewGeneration = 0;
Future<void> _openFullScreen(bool cupertino) async { Future<void> _openFullScreen() async {
setState(() => _fullScreen = true); setState(() => _fullScreen = true);
await openChatShellTerminalPage( await openChatShellTerminalPage(
context, context,
controller: widget.controller, controller: widget.controller,
runId: widget.runId, runId: widget.runId,
cupertino: cupertino, cupertino: false,
); );
if (!mounted) return; if (!mounted) return;
setState(() { setState(() {
@@ -60,41 +57,28 @@ class _ChatShellRunCardState extends State<ChatShellRunCard> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final cupertino =
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
return ListenableBuilder( return ListenableBuilder(
listenable: widget.controller, listenable: widget.controller,
builder: (context, _) { builder: (context, _) {
final run = widget.controller.run(widget.runId); final run = widget.controller.run(widget.runId);
if (run == null) return const SizedBox.shrink(); if (run == null) return const SizedBox.shrink();
final body = _body(context, run, cupertino); final body = _body(context, run);
return Semantics( return Semantics(
identifier: 'chat-shell-run-card', identifier: 'chat-shell-run-card',
container: true, container: true,
child: cupertino child: Card(
? CupertinoListSection.insetGrouped( margin: const EdgeInsets.only(bottom: 12),
backgroundColor: AppColors.groupedBackground, child: Padding(padding: const EdgeInsets.all(16), child: body),
margin: const EdgeInsets.only(bottom: 12), ),
children: [
Padding(padding: const EdgeInsets.all(16), child: body),
],
)
: Card(
margin: const EdgeInsets.only(bottom: 12),
child: Padding(
padding: const EdgeInsets.all(16),
child: body,
),
),
); );
}, },
); );
} }
Widget _body(BuildContext context, ChatShellRun run, bool cupertino) { Widget _body(BuildContext context, ChatShellRun run) {
final controller = widget.controller; final controller = widget.controller;
final error = controller.errorFor(run.id); final error = controller.errorFor(run.id);
final command = (chatCardBodyStyle(context, cupertino) ?? const TextStyle()) final command = (chatCardBodyStyle(context, false) ?? const TextStyle())
.copyWith(fontFamily: appMonospaceFamily, fontWeight: FontWeight.w600); .copyWith(fontFamily: appMonospaceFamily, fontWeight: FontWeight.w600);
return Column( return Column(
key: ValueKey<String>('chat-shell-run-${run.id}'), key: ValueKey<String>('chat-shell-run-${run.id}'),
@@ -107,10 +91,8 @@ class _ChatShellRunCardState extends State<ChatShellRunCard> {
Padding( Padding(
padding: const EdgeInsetsDirectional.only(end: 12), padding: const EdgeInsetsDirectional.only(end: 12),
child: Icon( child: Icon(
cupertino Icons.terminal,
? CupertinoIcons.chevron_left_slash_chevron_right color: chatCardSecondaryColor(context, false),
: Icons.terminal,
color: chatCardSecondaryColor(context, cupertino),
), ),
), ),
Expanded( Expanded(
@@ -125,21 +107,21 @@ class _ChatShellRunCardState extends State<ChatShellRunCard> {
if (run.directory.isNotEmpty) if (run.directory.isNotEmpty)
Text( Text(
run.directory, run.directory,
style: chatCardSecondaryStyle(context, cupertino), style: chatCardSecondaryStyle(context, false),
), ),
], ],
), ),
), ),
const SizedBox(width: 8), const SizedBox(width: 8),
ChatShellStatus(run: run, cupertino: cupertino), ChatShellStatus(run: run, cupertino: false),
if (!run.running) if (!run.running)
ChatShellDismissButton( ChatShellDismissButton(
cupertino: cupertino, cupertino: false,
onPressed: () => unawaited( onPressed: () => unawaited(
// A refusal brings the card back with the server's reason. // A refusal brings the card back with the server's reason.
dismissChatShellRuns(context, controller, [ dismissChatShellRuns(context, controller, [
run.id, run.id,
], cupertino: cupertino), ], cupertino: false),
), ),
), ),
], ],
@@ -148,7 +130,7 @@ class _ChatShellRunCardState extends State<ChatShellRunCard> {
ChatShellOutputView( ChatShellOutputView(
run: run, run: run,
controller: controller, controller: controller,
cupertino: cupertino, cupertino: false,
viewKey: ValueKey<int>(_viewGeneration), viewKey: ValueKey<int>(_viewGeneration),
fullScreen: _fullScreen, fullScreen: _fullScreen,
), ),
@@ -157,15 +139,15 @@ class _ChatShellRunCardState extends State<ChatShellRunCard> {
padding: const EdgeInsets.only(top: 8), padding: const EdgeInsets.only(top: 8),
child: Text( child: Text(
run.error, run.error,
style: chatCardSecondaryStyle(context, cupertino), style: chatCardSecondaryStyle(context, false),
), ),
), ),
const SizedBox(height: 4), const SizedBox(height: 4),
ChatShellCardActions( ChatShellCardActions(
run: run, run: run,
controller: controller, controller: controller,
cupertino: cupertino, cupertino: false,
onFullScreen: () => _openFullScreen(cupertino), onFullScreen: () => _openFullScreen(),
), ),
if (error != null) if (error != null)
Semantics( Semantics(
@@ -173,9 +155,8 @@ class _ChatShellRunCardState extends State<ChatShellRunCard> {
child: Text( child: Text(
error, error,
key: const Key('chat-shell-run-error'), key: const Key('chat-shell-run-error'),
style: style: (chatCardBodyStyle(context, false) ?? const TextStyle())
(chatCardBodyStyle(context, cupertino) ?? const TextStyle()) .copyWith(color: chatCardErrorColor(context, false)),
.copyWith(color: chatCardErrorColor(context, cupertino)),
), ),
), ),
], ],
@@ -1,4 +1,3 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import '../../../ui/text/monospace.dart'; import '../../../ui/text/monospace.dart';
@@ -9,16 +8,10 @@ import 'chat_shell_command.dart';
Future<String?> showChatShellRunDialog( Future<String?> showChatShellRunDialog(
BuildContext context, { BuildContext context, {
required bool cupertino, required bool cupertino,
}) => cupertino }) => showDialog<String>(
? showCupertinoDialog<String>( context: context,
context: context, builder: (_) => const ChatShellRunDialog(cupertino: false),
barrierDismissible: true, );
builder: (_) => const ChatShellRunDialog(cupertino: true),
)
: showDialog<String>(
context: context,
builder: (_) => const ChatShellRunDialog(cupertino: false),
);
class ChatShellRunDialog extends StatefulWidget { class ChatShellRunDialog extends StatefulWidget {
const ChatShellRunDialog({super.key, required this.cupertino}); const ChatShellRunDialog({super.key, required this.cupertino});
@@ -48,37 +41,6 @@ class _ChatShellRunDialogState extends State<ChatShellRunDialog> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
const mono = TextStyle(fontFamily: appMonospaceFamily); const mono = TextStyle(fontFamily: appMonospaceFamily);
if (widget.cupertino) {
return CupertinoAlertDialog(
title: const Text(chatShellRunDialogTitle),
content: Column(
children: [
const Text(chatShellModeHint),
const SizedBox(height: 12),
CupertinoTextField(
key: const Key('chat-shell-run-field'),
controller: _text,
autofocus: true,
placeholder: 'Command',
style: mono,
onSubmitted: (_) => _submit(),
),
],
),
actions: [
CupertinoDialogAction(
onPressed: _cancel,
child: const Text('Cancel'),
),
CupertinoDialogAction(
key: const Key('chat-shell-run-confirm'),
isDefaultAction: true,
onPressed: _submit,
child: const Text(chatShellRunDialogConfirm),
),
],
);
}
return AlertDialog( return AlertDialog(
title: const Text(chatShellRunDialogTitle), title: const Text(chatShellRunDialogTitle),
content: Column( content: Column(
@@ -1,4 +1,3 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import '../conversation/chat_card_styles.dart'; import '../conversation/chat_card_styles.dart';
@@ -24,46 +23,26 @@ class ChatShellStatus extends StatelessWidget {
return Semantics( return Semantics(
key: const Key('chat-shell-run-running'), key: const Key('chat-shell-run-running'),
label: chatShellStatusLabel(run), label: chatShellStatusLabel(run),
child: cupertino // As tall as the line of text beside it, at any text scale.
? const CupertinoActivityIndicator() child: SizedBox.square(
// As tall as the line of text beside it, at any text scale. dimension: MediaQuery.textScalerOf(context).scale(20),
: SizedBox.square( child: const CircularProgressIndicator(strokeWidth: 2),
dimension: MediaQuery.textScalerOf(context).scale(20), ),
child: const CircularProgressIndicator(strokeWidth: 2),
),
); );
} }
final label = run.durationMs > 0 final label = run.durationMs > 0
? '${chatShellStatusLabel(run)} · ${chatShellDuration(run.durationMs)}' ? '${chatShellStatusLabel(run)} · ${chatShellDuration(run.durationMs)}'
: chatShellStatusLabel(run); : chatShellStatusLabel(run);
final color = switch (run.state) { final color = switch (run.state) {
ChatShellRunState.succeeded => ChatShellRunState.succeeded => Theme.of(context).colorScheme.primary,
cupertino ChatShellRunState.failed => chatCardErrorColor(context, false),
? CupertinoColors.systemGreen.resolveFrom(context) _ => chatCardSecondaryColor(context, false),
: Theme.of(context).colorScheme.primary,
ChatShellRunState.failed => chatCardErrorColor(context, cupertino),
_ => chatCardSecondaryColor(context, cupertino),
}; };
final icon = switch (run.state) { final icon = switch (run.state) {
ChatShellRunState.succeeded => ChatShellRunState.succeeded => Icons.check_circle_outline,
cupertino ChatShellRunState.failed => Icons.error_outline,
? CupertinoIcons.checkmark_circle _ => Icons.stop_circle_outlined,
: Icons.check_circle_outline,
ChatShellRunState.failed =>
cupertino ? CupertinoIcons.xmark_circle : Icons.error_outline,
_ => cupertino ? CupertinoIcons.stop_circle : Icons.stop_circle_outlined,
}; };
if (cupertino) {
return Row(
key: const Key('chat-shell-run-status'),
mainAxisSize: MainAxisSize.min,
children: [
Icon(icon, color: color, size: 18),
const SizedBox(width: 4),
Text(label, style: chatCardSecondaryStyle(context, true)),
],
);
}
return Chip( return Chip(
key: const Key('chat-shell-run-status'), key: const Key('chat-shell-run-status'),
avatar: Icon(icon, color: color), avatar: Icon(icon, color: color),
@@ -1,16 +1,14 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:xterm/core.dart'; import 'package:xterm/core.dart';
import 'chat_shell_terminal_session.dart'; import 'chat_shell_terminal_session.dart';
/// One key of the terminal toolbar: its label, icons and what it sends. /// One key of the terminal toolbar: its label, icon and what it sends.
typedef _Key = ({ typedef _Key = ({
String id, String id,
String label, String label,
IconData? material, IconData? material,
IconData? cupertino,
void Function(Terminal terminal) send, void Function(Terminal terminal) send,
}); });
@@ -19,56 +17,48 @@ final List<_Key> _keys = [
id: 'enter', id: 'enter',
label: 'Enter', label: 'Enter',
material: Icons.keyboard_return, material: Icons.keyboard_return,
cupertino: CupertinoIcons.return_icon,
send: (t) => t.keyInput(TerminalKey.enter), send: (t) => t.keyInput(TerminalKey.enter),
), ),
( (
id: 'ctrl-c', id: 'ctrl-c',
label: 'Ctrl-C', label: 'Ctrl-C',
material: null, material: null,
cupertino: null,
send: (t) => t.textInput('\x03'), send: (t) => t.textInput('\x03'),
), ),
( (
id: 'tab', id: 'tab',
label: 'Tab', label: 'Tab',
material: Icons.keyboard_tab, material: Icons.keyboard_tab,
cupertino: CupertinoIcons.arrow_right_to_line,
send: (t) => t.keyInput(TerminalKey.tab), send: (t) => t.keyInput(TerminalKey.tab),
), ),
( (
id: 'esc', id: 'esc',
label: 'Esc', label: 'Esc',
material: null, material: null,
cupertino: null,
send: (t) => t.keyInput(TerminalKey.escape), send: (t) => t.keyInput(TerminalKey.escape),
), ),
( (
id: 'left', id: 'left',
label: 'Left', label: 'Left',
material: Icons.keyboard_arrow_left, material: Icons.keyboard_arrow_left,
cupertino: CupertinoIcons.arrow_left,
send: (t) => t.keyInput(TerminalKey.arrowLeft), send: (t) => t.keyInput(TerminalKey.arrowLeft),
), ),
( (
id: 'up', id: 'up',
label: 'Up', label: 'Up',
material: Icons.keyboard_arrow_up, material: Icons.keyboard_arrow_up,
cupertino: CupertinoIcons.arrow_up,
send: (t) => t.keyInput(TerminalKey.arrowUp), send: (t) => t.keyInput(TerminalKey.arrowUp),
), ),
( (
id: 'down', id: 'down',
label: 'Down', label: 'Down',
material: Icons.keyboard_arrow_down, material: Icons.keyboard_arrow_down,
cupertino: CupertinoIcons.arrow_down,
send: (t) => t.keyInput(TerminalKey.arrowDown), send: (t) => t.keyInput(TerminalKey.arrowDown),
), ),
( (
id: 'right', id: 'right',
label: 'Right', label: 'Right',
material: Icons.keyboard_arrow_right, material: Icons.keyboard_arrow_right,
cupertino: CupertinoIcons.arrow_right,
send: (t) => t.keyInput(TerminalKey.arrowRight), send: (t) => t.keyInput(TerminalKey.arrowRight),
), ),
]; ];
@@ -127,21 +117,9 @@ class _ChatShellTerminalKeysState extends State<ChatShellTerminalKeys> {
spacing: 4, spacing: 4,
runSpacing: 4, runSpacing: 4,
children: [ children: [
_button( _button('paste', 'Paste', Icons.content_paste, _paste),
'paste',
'Paste',
Icons.content_paste,
CupertinoIcons.doc_on_clipboard,
_paste,
),
for (final key in _keys) for (final key in _keys)
_button( _button(key.id, key.label, key.material, () => key.send(_terminal)),
key.id,
key.label,
key.material,
key.cupertino,
() => key.send(_terminal),
),
], ],
); );
if (!widget.field) return keys; if (!widget.field) return keys;
@@ -157,27 +135,6 @@ class _ChatShellTerminalKeysState extends State<ChatShellTerminalKeys> {
Widget _field() { Widget _field() {
final toggle = _hidden ? 'Show typing' : 'Hide typing'; final toggle = _hidden ? 'Show typing' : 'Hide typing';
if (widget.cupertino) {
return CupertinoTextField(
key: const Key('chat-shell-terminal-field'),
controller: _text,
placeholder: 'Type input, then Enter',
obscureText: _hidden,
autocorrect: false,
enableSuggestions: false,
textInputAction: TextInputAction.send,
onSubmitted: (_) => _submit(),
suffix: CupertinoButton(
key: const Key('chat-shell-terminal-hide'),
padding: const EdgeInsets.symmetric(horizontal: 8),
onPressed: () => setState(() => _hidden = !_hidden),
child: Icon(
_hidden ? CupertinoIcons.eye : CupertinoIcons.eye_slash,
semanticLabel: toggle,
),
),
);
}
return TextField( return TextField(
key: const Key('chat-shell-terminal-field'), key: const Key('chat-shell-terminal-field'),
controller: _text, controller: _text,
@@ -202,20 +159,9 @@ class _ChatShellTerminalKeysState extends State<ChatShellTerminalKeys> {
String id, String id,
String label, String label,
IconData? material, IconData? material,
IconData? cupertino,
VoidCallback onPressed, VoidCallback onPressed,
) { ) {
final key = Key('chat-shell-key-$id'); final key = Key('chat-shell-key-$id');
if (widget.cupertino) {
return CupertinoButton(
key: key,
padding: const EdgeInsets.symmetric(horizontal: 8),
onPressed: onPressed,
child: cupertino == null
? Text(label)
: Icon(cupertino, semanticLabel: label),
);
}
if (material == null) { if (material == null) {
return OutlinedButton( return OutlinedButton(
key: key, key: key,
@@ -1,4 +1,3 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import '../../../ui/text/monospace.dart'; import '../../../ui/text/monospace.dart';
@@ -20,11 +19,7 @@ Future<void> openChatShellTerminalPage(
runId: runId, runId: runId,
cupertino: cupertino, cupertino: cupertino,
); );
return Navigator.of(context).push<void>( return Navigator.push<void>(context, MaterialPageRoute<void>(builder: page));
cupertino
? CupertinoPageRoute<void>(builder: page)
: MaterialPageRoute<void>(builder: page),
);
} }
class ChatShellTerminalPage extends StatelessWidget { class ChatShellTerminalPage extends StatelessWidget {
@@ -63,7 +58,7 @@ class ChatShellTerminalPage extends StatelessWidget {
Expanded( Expanded(
child: ChatShellTerminalView( child: ChatShellTerminalView(
session: session, session: session,
cupertino: cupertino, cupertino: false,
fill: true, fill: true,
autofocus: true, autofocus: true,
), ),
@@ -73,7 +68,7 @@ class ChatShellTerminalPage extends StatelessWidget {
padding: const EdgeInsets.only(top: 8), padding: const EdgeInsets.only(top: 8),
child: ChatShellTerminalKeys( child: ChatShellTerminalKeys(
session: session, session: session,
cupertino: cupertino, cupertino: false,
field: chatShellTouchFirst(), field: chatShellTouchFirst(),
), ),
), ),
@@ -82,12 +77,6 @@ class ChatShellTerminalPage extends StatelessWidget {
), ),
); );
} }
if (cupertino) {
return CupertinoPageScaffold(
navigationBar: CupertinoNavigationBar(middle: title),
child: body,
);
}
return Scaffold( return Scaffold(
appBar: AppBar(title: title), appBar: AppBar(title: title),
body: body, body: body,
@@ -1,6 +1,5 @@
import 'dart:ui' as ui; import 'dart:ui' as ui;
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:xterm/xterm.dart'; import 'package:xterm/xterm.dart';
@@ -12,17 +11,10 @@ import '../conversation/chat_card_styles.dart';
/// selection. The sixteen ANSI colours are the emulator's standard palette, /// selection. The sixteen ANSI colours are the emulator's standard palette,
/// darkened on a light surface so coloured output stays readable. /// darkened on a light surface so coloured output stays readable.
TerminalTheme chatShellTerminalTheme(BuildContext context, bool cupertino) { TerminalTheme chatShellTerminalTheme(BuildContext context, bool cupertino) {
final brightness = cupertino final dark = Theme.of(context).brightness == Brightness.dark;
? CupertinoTheme.brightnessOf(context) final background = chatCardFillColor(context, false);
: Theme.of(context).brightness; final foreground = Theme.of(context).colorScheme.onSurface;
final dark = brightness == Brightness.dark; final accent = Theme.of(context).colorScheme.primary;
final background = chatCardFillColor(context, cupertino);
final foreground = cupertino
? CupertinoColors.label.resolveFrom(context)
: Theme.of(context).colorScheme.onSurface;
final accent = cupertino
? CupertinoTheme.of(context).primaryColor
: Theme.of(context).colorScheme.primary;
final base = TerminalThemes.defaultTheme; final base = TerminalThemes.defaultTheme;
Color ansi(Color color) { Color ansi(Color color) {
if (dark) return color; if (dark) return color;
@@ -37,9 +29,7 @@ TerminalTheme chatShellTerminalTheme(BuildContext context, bool cupertino) {
// Opaque: the emulator paints cells over its own background. // Opaque: the emulator paints cells over its own background.
background: Color.alphaBlend( background: Color.alphaBlend(
background, background,
cupertino Theme.of(context).colorScheme.surface,
? CupertinoColors.systemBackground.resolveFrom(context)
: Theme.of(context).colorScheme.surface,
), ),
black: dark ? base.black : foreground, black: dark ? base.black : foreground,
red: ansi(base.red), red: ansi(base.red),
@@ -65,7 +55,7 @@ TerminalTheme chatShellTerminalTheme(BuildContext context, bool cupertino) {
/// The terminal's text: the host's monospace family at the card body size. /// The terminal's text: the host's monospace family at the card body size.
TerminalStyle chatShellTerminalStyle(BuildContext context, bool cupertino) { TerminalStyle chatShellTerminalStyle(BuildContext context, bool cupertino) {
final body = chatCardBodyStyle(context, cupertino) ?? const TextStyle(); final body = chatCardBodyStyle(context, false) ?? const TextStyle();
return TerminalStyle( return TerminalStyle(
fontFamily: appMonospaceFamily, fontFamily: appMonospaceFamily,
fontSize: (body.fontSize ?? 14) * 0.95, fontSize: (body.fontSize ?? 14) * 0.95,
@@ -155,7 +155,7 @@ class _ChatShellTerminalViewState extends State<ChatShellTerminalView> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
final session = widget.session; final session = widget.session;
final live = session.live; final live = session.live;
final style = chatShellTerminalStyle(context, widget.cupertino); final style = chatShellTerminalStyle(context, false);
const padding = EdgeInsets.all(8); const padding = EdgeInsets.all(8);
Widget view = Semantics( Widget view = Semantics(
identifier: 'chat-shell-terminal', identifier: 'chat-shell-terminal',
@@ -168,7 +168,7 @@ class _ChatShellTerminalViewState extends State<ChatShellTerminalView> {
focusNode: _focus, focusNode: _focus,
autofocus: widget.autofocus && live, autofocus: widget.autofocus && live,
autoResize: widget.autoResize, autoResize: widget.autoResize,
theme: chatShellTerminalTheme(context, widget.cupertino), theme: chatShellTerminalTheme(context, false),
textStyle: style, textStyle: style,
padding: padding, padding: padding,
readOnly: !live, readOnly: !live,
@@ -25,39 +25,30 @@ void main() {
durationMs: 50, durationMs: 50,
); );
for (final cupertino in [false, true]) { testWidgets('Dismiss removes a finished card without a notice', (
final host = cupertino ? 'Cupertino' : 'Material'; tester,
) async {
gateway.runs = [finished('run_done'), shellRecord('run_live')];
await tester.pumpWidget(shellThread(gateway));
await tester.pump();
testWidgets('$host: Dismiss removes a finished card without a notice', ( expect(card(), findsNWidgets(2));
tester, // Only the finished card offers Dismiss; a running one must stop first.
) async { expect(dismiss, findsOneWidget);
gateway.runs = [finished('run_done'), shellRecord('run_live')]; expect(find.byTooltip('Dismiss'), findsOneWidget);
await tester.pumpWidget(shellThread(gateway, cupertino: cupertino));
await tester.pump();
expect(card(), findsNWidgets(2)); await tester.tap(dismiss);
// Only the finished card offers Dismiss; a running one must stop first. await tester.pump();
expect(dismiss, findsOneWidget); await tester.pump(const Duration(milliseconds: 300));
expect( expect(gateway.bodies('chat_shell_dismiss').single['run_ids'], [
cupertino 'run_done',
? find.bySemanticsLabel('Dismiss') ]);
: find.byTooltip('Dismiss'), expect(card(), findsOneWidget);
findsOneWidget, expect(find.text('\$ true'), findsNothing);
); expect(notice, findsNothing);
expect(find.text('Command dismissed'), findsNothing);
await tester.tap(dismiss); expect(find.text('Undo'), findsNothing);
await tester.pump(); });
await tester.pump(const Duration(milliseconds: 300));
expect(gateway.bodies('chat_shell_dismiss').single['run_ids'], [
'run_done',
]);
expect(card(), findsOneWidget);
expect(find.text('\$ true'), findsNothing);
expect(notice, findsNothing);
expect(find.text('Command dismissed'), findsNothing);
expect(find.text('Undo'), findsNothing);
});
}
testWidgets('a refused dismissal brings the card back with the reason', ( testWidgets('a refused dismissal brings the card back with the reason', (
tester, tester,
@@ -1,6 +1,5 @@
import 'dart:async'; import 'dart:async';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; 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';
@@ -168,7 +167,7 @@ String terminalText(WidgetTester tester, {int index = 0}) {
return lines.join('\n'); return lines.join('\n');
} }
Widget shellThread(ShellGateway gateway, {bool cupertino = false}) { Widget shellThread(ShellGateway gateway) {
final thread = ChatThreadView( final thread = ChatThreadView(
gateway: gateway, gateway: gateway,
sessionId: 's', sessionId: 's',
@@ -176,7 +175,5 @@ Widget shellThread(ShellGateway gateway, {bool cupertino = false}) {
onBack: () {}, onBack: () {},
drafts: MemoryChatDraftStore(), drafts: MemoryChatDraftStore(),
); );
return cupertino return MaterialApp(home: Scaffold(body: thread));
? CupertinoApp(home: CupertinoPageScaffold(child: thread))
: MaterialApp(home: Scaffold(body: thread));
} }
@@ -14,89 +14,79 @@ void main() {
Finder card() => find.bySemanticsIdentifier('chat-shell-run-card'); Finder card() => find.bySemanticsIdentifier('chat-shell-run-card');
for (final cupertino in [false, true]) { testWidgets('a running command streams output and stops', (tester) async {
final host = cupertino ? 'Cupertino' : 'Material'; gateway.runs = [shellRecord('run_a', output: 'line 1\n')];
await tester.pumpWidget(shellThread(gateway));
await tester.pump();
testWidgets('$host: a running command streams output and stops', ( expect(card(), findsOneWidget);
tester, expect(find.text('\$ make test'), findsOneWidget);
) async { expect(find.byKey(const Key('chat-shell-run-running')), findsOneWidget);
gateway.runs = [shellRecord('run_a', output: 'line 1\n')]; gateway.emitOutput('run_a', 'line 2\n', 7);
await tester.pumpWidget(shellThread(gateway, cupertino: cupertino)); await tester.pump();
await tester.pump(); expect(terminalText(tester), 'line 1\nline 2');
expect(find.byKey(const Key('chat-shell-run-share')), findsNothing);
expect(card(), findsOneWidget); await tester.tap(find.byKey(const Key('chat-shell-run-stop')));
expect(find.text('\$ make test'), findsOneWidget); await tester.pump();
expect(find.byKey(const Key('chat-shell-run-running')), findsOneWidget); expect(gateway.bodies('chat_shell_stop').single['run_id'], 'run_a');
gateway.emitOutput('run_a', 'line 2\n', 7); expect(find.text('Stopping…'), findsOneWidget);
await tester.pump();
expect(terminalText(tester), 'line 1\nline 2');
expect(find.byKey(const Key('chat-shell-run-share')), findsNothing);
await tester.tap(find.byKey(const Key('chat-shell-run-stop'))); gateway.emitRun(shellRecord('run_a', status: 'stopped', durationMs: 2400));
await tester.pump(); await tester.pump();
expect(gateway.bodies('chat_shell_stop').single['run_id'], 'run_a'); expect(find.byKey(const Key('chat-shell-run-running')), findsNothing);
expect(find.text('Stopping…'), findsOneWidget); expect(find.text('Stopped · 2.4 s'), findsOneWidget);
expect(find.byKey(const Key('chat-shell-run-stop')), findsNothing);
// The streamed output stays after the lifecycle frame.
expect(terminalText(tester), 'line 1\nline 2');
});
gateway.emitRun( testWidgets('finished commands show their exit status', (tester) async {
shellRecord('run_a', status: 'stopped', durationMs: 2400), gateway.runs = [
); shellRecord(
await tester.pump(); 'run_ok',
expect(find.byKey(const Key('chat-shell-run-running')), findsNothing); command: 'true',
expect(find.text('Stopped · 2.4 s'), findsOneWidget); status: 'exited',
expect(find.byKey(const Key('chat-shell-run-stop')), findsNothing); exitCode: 0,
// The streamed output stays after the lifecycle frame. output: 'fine\n',
expect(terminalText(tester), 'line 1\nline 2'); durationMs: 120,
}); ),
shellRecord(
'run_bad',
command: 'false',
status: 'exited',
exitCode: 1,
output: 'broken\n',
durationMs: 3000,
),
];
await tester.pumpWidget(shellThread(gateway));
await tester.pump();
// Finished terminals shrink to their output after their first frame.
await tester.pumpAndSettle();
testWidgets('$host: finished commands show their exit status', ( expect(card(), findsNWidgets(2));
tester, expect(find.text('Exit 0 · 120 ms'), findsOneWidget);
) async { expect(find.text('Exit 1 · 3.0 s'), findsOneWidget);
gateway.runs = [ expect(find.byKey(const Key('chat-shell-run-copy')), findsNWidgets(2));
shellRecord( });
'run_ok',
command: 'true',
status: 'exited',
exitCode: 0,
output: 'fine\n',
durationMs: 120,
),
shellRecord(
'run_bad',
command: 'false',
status: 'exited',
exitCode: 1,
output: 'broken\n',
durationMs: 3000,
),
];
await tester.pumpWidget(shellThread(gateway, cupertino: cupertino));
await tester.pump();
// Finished terminals shrink to their output after their first frame.
await tester.pumpAndSettle();
expect(card(), findsNWidgets(2)); testWidgets('Send to agent shares the run once', (tester) async {
expect(find.text('Exit 0 · 120 ms'), findsOneWidget); gateway.runs = [
expect(find.text('Exit 1 · 3.0 s'), findsOneWidget); shellRecord('run_a', status: 'exited', exitCode: 0, output: 'ok\n'),
expect(find.byKey(const Key('chat-shell-run-copy')), findsNWidgets(2)); ];
}); await tester.pumpWidget(shellThread(gateway));
await tester.pump();
testWidgets('$host: Send to agent shares the run once', (tester) async { expect(gateway.calls.where((c) => c.type == 'chat_prompt'), isEmpty);
gateway.runs = [ await tester.tap(find.byKey(const Key('chat-shell-run-share')));
shellRecord('run_a', status: 'exited', exitCode: 0, output: 'ok\n'), await tester.pump();
]; expect(gateway.bodies('chat_shell_share').single['run_id'], 'run_a');
await tester.pumpWidget(shellThread(gateway, cupertino: cupertino)); expect(find.text('Sent to agent'), findsOneWidget);
await tester.pump(); await tester.tap(find.byKey(const Key('chat-shell-run-share')));
await tester.pump();
expect(gateway.calls.where((c) => c.type == 'chat_prompt'), isEmpty); expect(gateway.bodies('chat_shell_share'), hasLength(1));
await tester.tap(find.byKey(const Key('chat-shell-run-share'))); });
await tester.pump();
expect(gateway.bodies('chat_shell_share').single['run_id'], 'run_a');
expect(find.text('Sent to agent'), findsOneWidget);
await tester.tap(find.byKey(const Key('chat-shell-run-share')));
await tester.pump();
expect(gateway.bodies('chat_shell_share'), hasLength(1));
});
}
testWidgets('Copy output copies the plain-text rendering', (tester) async { testWidgets('Copy output copies the plain-text rendering', (tester) async {
final copied = <String>[]; final copied = <String>[];