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