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,110 @@
import 'package:flutter/material.dart';
import '../../../../ui/adaptive/platform.dart';
/// The width of the strip left of the reading column that an answer row
/// draws its Copy button in (`chatCopyGutter`); 0 when there is no room, and
/// Copy stays in the answer's footer.
class ChatCopyGutter extends InheritedWidget {
const ChatCopyGutter({super.key, required this.width, required super.child});
final double width;
static double of(BuildContext context) =>
context.dependOnInheritedWidgetOfExactType<ChatCopyGutter>()?.width ?? 0;
@override
bool updateShouldNotify(ChatCopyGutter oldWidget) => width != oldWidget.width;
}
/// The transcript's [children] when the list starts [gutter] left of the
/// reading column: every child except the transcript [rows] (which inset
/// themselves) is inset past the gutter, so it keeps to the column.
List<Widget> chatCopyGutterInset(
double gutter,
List<Widget> rows,
List<Widget> children,
) {
if (gutter <= 0) return children;
final own = Set<Widget>.identity()..addAll(rows);
return [
for (final child in children)
if (own.contains(child))
child
else
Padding(
key: child.key,
padding: EdgeInsets.only(left: gutter),
child: child,
),
];
}
/// An answer with its Copy button in the gutter to its left, bottom-aligned
/// with the answer's footer row. On a desktop the button shows while the
/// pointer is over the answer or the button has focus; it stays in the
/// focus order and the semantics tree when hidden. Touch platforms always
/// show it.
class ChatCopyGutterRow extends StatefulWidget {
const ChatCopyGutterRow({
super.key,
required this.width,
required this.copy,
required this.child,
});
final double width;
/// The Copy button, or null when the answer has nothing to copy yet.
final Widget? copy;
final Widget child;
@override
State<ChatCopyGutterRow> createState() => _ChatCopyGutterRowState();
}
class _ChatCopyGutterRowState extends State<ChatCopyGutterRow> {
bool _hovered = false;
bool _focused = false;
@override
Widget build(BuildContext context) {
final hover = prefersCompactHitTargets(context);
final copy = widget.copy;
final row = Row(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
SizedBox(
key: const Key('chat-copy-gutter'),
width: widget.width,
child: copy == null
? null
: Align(
alignment: Alignment.bottomRight,
child: Focus(
canRequestFocus: false,
skipTraversal: true,
onFocusChange: (focused) =>
setState(() => _focused = focused),
child: AnimatedOpacity(
key: const Key('chat-copy-gutter-visibility'),
opacity: !hover || _hovered || _focused ? 1 : 0,
duration: const Duration(milliseconds: 120),
alwaysIncludeSemantics: true,
child: copy,
),
),
),
),
Flexible(child: widget.child),
],
);
if (!hover || copy == null) return row;
return MouseRegion(
onEnter: (_) => setState(() => _hovered = true),
onExit: (_) => setState(() => _hovered = false),
child: row,
);
}
}
@@ -10,6 +10,7 @@ import 'chat_attachment_gallery.dart';
import '../../domain/chat_tool_calls.dart';
import '../../domain/chat_transcript.dart';
import 'chat_copy_button.dart';
import 'chat_copy_gutter.dart';
import 'chat_link_text.dart';
import 'chat_message_bubble.dart';
import 'chat_turn_activity_view.dart';
@@ -49,6 +50,9 @@ class ChatMessageView extends StatelessWidget {
final role = user ? 'User' : 'Assistant';
final cupertino = _isCupertino(context);
final content = user ? _userParts(context) : _agentParts(context);
// A wide window draws an answer's Copy in the gutter left of the reading
// column; without room it stays at the start of the answer's footer.
final gutter = user ? 0.0 : ChatCopyGutter.of(context);
// No visible role label: side and surface say who spoke and the row's
// semantics label names the role. The operator's turn is a neutral bubble
// that shrinks to its content; the agent's answer sits on the page with no
@@ -79,14 +83,15 @@ class ChatMessageView extends StatelessWidget {
constraints: BoxConstraints(
maxWidth: user
? (constraints.maxWidth * 0.85).clamp(0, 560).toDouble()
: 720,
: 720 + gutter,
),
child: user
? _userTurn(cupertino, content, body)
: _agentTurn(
: _agentRow(
context,
content,
ChatAgentSurface(cupertino: cupertino, child: body),
gutter,
),
),
),
@@ -174,9 +179,34 @@ class ChatMessageView extends StatelessWidget {
return widgets;
}
/// The answer, with its Copy button in the [gutter] to its left when there
/// is one, or else first in its footer.
Widget _agentRow(
BuildContext context,
List<Widget> content,
Widget answer,
double gutter,
) {
final copyText = row['streaming'] == true ? '' : _answerText(_partsOf(row));
final copy = copyText.isEmpty
? null
: ChatCopyButton(text: copyText, cupertino: _isCupertino(context));
if (gutter <= 0) return _agentTurn(context, content, answer, copy);
return ChatCopyGutterRow(
width: gutter,
copy: copy,
child: _agentTurn(context, content, answer, null),
);
}
/// Stable activity precedes the answer; permission summaries and recorded
/// model remain beneath it. Pending interaction cards are rendered separately.
Widget _agentTurn(BuildContext context, List<Widget> content, Widget answer) {
Widget _agentTurn(
BuildContext context,
List<Widget> content,
Widget answer,
Widget? copy,
) {
final parts = _partsOf(row);
final reasoning = [
for (final part in parts)
@@ -189,10 +219,8 @@ class ChatMessageView extends StatelessWidget {
if (isChatToolPart(part)) part,
];
final model = '${row['model'] ?? ''}'.trim();
final copyText = row['streaming'] == true ? '' : _answerText(parts);
final footer = <Widget>[
if (copyText.isNotEmpty)
ChatCopyButton(text: copyText, cupertino: _isCupertino(context)),
?copy,
...this.footer,
if (model.isNotEmpty)
Text(