Show dismissed commands as an answer footer chip; move Copy to the left gutter

Dismissed shell runs leave the transcript and fold into a "N commands"
chip in the footer of the first answer at or after each run (the last
answer for newer runs, or a row of its own without any answer). The chip
opens the turn sheet (wide) or a full-screen page (narrow) listing the
commands; each opens its output read-only with Copy output, Send to agent
and Restore.

On a wide conversation the answer's Copy button moves out of the footer
into a 48 px gutter left of the reading column (chatCopyGutter), shown on
hover or focus on desktops and always on touch; narrow widths keep it in
the footer.
This commit is contained in:
2026-11-09 23:47:14 +00:00
parent f2520a09b8
commit cf9f71f27c
21 changed files with 1534 additions and 77 deletions
@@ -0,0 +1,150 @@
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/core/api_gateway.dart';
import 'package:pipelines_app/features/chat/conversation/chat_reading_width.dart';
import 'package:pipelines_app/features/chat/domain/chat_transcript.dart';
import 'package:pipelines_app/features/chat/ui/transcript/chat_copy_gutter.dart';
import 'package:pipelines_app/features/chat/ui/transcript/chat_message_view.dart';
import '../../shell/chat_shell_fixtures.dart';
JsonMap _answer() => transcriptRows([
{
'id': 'a1',
'role': 'assistant',
'model': 'gpt-test',
'created_at': 1000,
'parts': [
{'type': 'text', 'text': 'The answer text'},
],
},
]).single;
Widget _host(double gutter) => MaterialApp(
home: Scaffold(
body: ListView(
children: [
ChatCopyGutter(
width: gutter,
child: ChatMessageView(row: _answer()),
),
],
),
),
);
final _copy = find.byKey(const Key('chat-message-copy'));
final _footer = find.byKey(const Key('chat-message-footer'));
final _gutter = find.byKey(const Key('chat-copy-gutter'));
double _opacity(WidgetTester tester) => tester
.widget<AnimatedOpacity>(
find.byKey(const Key('chat-copy-gutter-visibility')),
)
.opacity;
void main() {
test('the gutter needs room left of the reading column', () {
expect(chatCopyGutter(kChatReadingWidth + 2 * kChatCopyGutterWidth), 48);
expect(chatCopyGutter(1400), kChatCopyGutterWidth);
expect(chatCopyGutter(kChatReadingWidth + 90), 0);
expect(chatCopyGutter(560), 0);
});
testWidgets('without a gutter Copy starts the footer', (tester) async {
await tester.pumpWidget(_host(0));
expect(find.descendant(of: _footer, matching: _copy), findsOneWidget);
expect(_gutter, findsNothing);
});
testWidgets('with a gutter Copy sits left of the answer, not in it', (
tester,
) async {
await tester.pumpWidget(_host(48));
expect(find.descendant(of: _footer, matching: _copy), findsNothing);
expect(find.descendant(of: _gutter, matching: _copy), findsOneWidget);
expect(find.byTooltip('Copy'), findsOneWidget);
final copy = tester.getRect(_copy);
final text = tester.getRect(find.text('The answer text'));
final footer = tester.getRect(_footer);
expect(copy.right, lessThanOrEqualTo(text.left));
// Bottom-aligned with the footer row (model and time).
expect((copy.bottom - footer.bottom).abs(), lessThan(1));
// Touch platforms always show it.
expect(_opacity(tester), 1);
});
testWidgets('desktop shows it on hover and focus, and keeps semantics', (
tester,
) async {
final semantics = tester.ensureSemantics();
await tester.pumpWidget(_host(48));
expect(_opacity(tester), 0);
// Hidden, it is still reachable by a screen reader.
expect(
tester.getSemantics(_copy),
isSemantics(tooltip: 'Copy', isButton: true, isFocusable: true),
);
final mouse = await tester.createGesture(kind: PointerDeviceKind.mouse);
addTearDown(mouse.removePointer);
await mouse.addPointer(location: Offset.zero);
await mouse.moveTo(tester.getCenter(find.text('The answer text')));
await tester.pumpAndSettle();
expect(_opacity(tester), 1);
await mouse.moveTo(const Offset(5, 590));
await tester.pumpAndSettle();
expect(_opacity(tester), 0);
// Keyboard focus reveals it too.
await tester.sendKeyEvent(LogicalKeyboardKey.tab);
await tester.pumpAndSettle();
expect(_opacity(tester), 1);
semantics.dispose();
}, variant: TargetPlatformVariant.only(TargetPlatform.macOS));
for (final (width, inGutter) in [(1400.0, true), (560.0, false)]) {
testWidgets('a ${width.toInt()} px conversation puts Copy '
'${inGutter ? 'in the gutter' : 'in the footer'}', (tester) async {
tester.view.physicalSize = Size(width, 900);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
final gateway = ShellGateway()
..messages = [
{
'id': 'a1',
'role': 'assistant',
'created_at': 1000,
'parts': [
{'type': 'text', 'text': 'The answer text'},
],
},
];
addTearDown(gateway.close);
await tester.pumpWidget(shellThread(gateway));
await tester.pump();
await tester.pump();
expect(_copy, findsOneWidget);
expect(
find.descendant(of: _footer, matching: _copy),
inGutter ? findsNothing : findsOneWidget,
);
final copy = tester.getRect(_copy);
final text = tester.getRect(find.text('The answer text'));
if (inGutter) {
expect(copy.right, lessThanOrEqualTo(text.left));
// The answer itself did not move: it starts where the column does.
final column = chatReadingInset(
tester.getSize(find.byType(Scaffold)).width,
);
expect(text.left, greaterThanOrEqualTo(column));
expect(copy.left, greaterThanOrEqualTo(column - kChatCopyGutterWidth));
} else {
expect(copy.top, greaterThanOrEqualTo(text.bottom));
}
});
}
}