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
@@ -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>[];