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:
@@ -8,3 +8,14 @@ const double kChatReadingWidth = 760;
|
||||
/// The space on each side of the centred reading column in [width].
|
||||
double chatReadingInset(double width) =>
|
||||
math.max(0, (width - kChatReadingWidth) / 2);
|
||||
|
||||
/// The strip left of the reading column that holds an answer's Copy button,
|
||||
/// outside the answer itself.
|
||||
const double kChatCopyGutterWidth = 48;
|
||||
|
||||
/// The copy gutter a transcript [width] wide gives each answer:
|
||||
/// [kChatCopyGutterWidth] when the margin left of the centred reading column
|
||||
/// fits it, else 0, and Copy stays in the answer's footer (phones, narrow
|
||||
/// panes).
|
||||
double chatCopyGutter(double width) =>
|
||||
chatReadingInset(width) >= kChatCopyGutterWidth ? kChatCopyGutterWidth : 0;
|
||||
|
||||
@@ -59,6 +59,7 @@ import '../../../ui/adaptive/segmented_bar_overlay.dart';
|
||||
import '../../../ui/layout/app_sheet_header.dart';
|
||||
import '../../../ui/layout/wheel_scroll_forwarding.dart';
|
||||
import 'chat_reading_width.dart';
|
||||
import '../ui/transcript/chat_copy_gutter.dart';
|
||||
import 'chat_pane_presentation.dart';
|
||||
import 'chat_thread_header.dart';
|
||||
import 'chat_transcript_anchor.dart';
|
||||
@@ -67,6 +68,8 @@ import '../files/files_controller.dart';
|
||||
import '../files/files_panel.dart';
|
||||
import '../files/files_preferences.dart';
|
||||
import '../shell/chat_shell_command.dart';
|
||||
import '../shell/chat_shell_history.dart';
|
||||
import '../shell/chat_shell_history_chip.dart';
|
||||
import '../shell/chat_shell_dismiss.dart';
|
||||
import '../shell/chat_shell_run.dart';
|
||||
import '../shell/chat_shell_run_card.dart';
|
||||
@@ -1053,11 +1056,15 @@ class _ChatThreadViewState extends State<ChatThreadView> {
|
||||
);
|
||||
final notices = _dismissals.visible(allNotices);
|
||||
final compactionNotice = _noticeOf(notices, ChatNoticeKind.compaction);
|
||||
// The operator's own shell commands sit among the turns by start time.
|
||||
final rows = withChatShellRunRows([
|
||||
for (final row in allRows)
|
||||
if (!_hiddenRunningCompaction(row)) row,
|
||||
], _shellRuns.runs);
|
||||
// The operator's own shell commands sit among the turns by start time;
|
||||
// dismissed ones fold into a chip under the answer that followed them.
|
||||
final rows = attachChatShellHistory(
|
||||
withChatShellRunRows([
|
||||
for (final row in allRows)
|
||||
if (!_hiddenRunningCompaction(row)) row,
|
||||
], _shellRuns.runs),
|
||||
_shellRuns.dismissedRuns,
|
||||
);
|
||||
// Older pages prepend messages and a live frame can append one, so a
|
||||
// folded assistant turn's first message id is not a stable identity.
|
||||
// ChatRowKeys carries a turn's key forward while it still holds any of
|
||||
@@ -1129,29 +1136,42 @@ class _ChatThreadViewState extends State<ChatThreadView> {
|
||||
// Rows keep to the centred reading column on a wide
|
||||
// window; the margins beside it still scroll the list.
|
||||
final side = chatReadingInset(constraints.maxWidth);
|
||||
// Answers draw Copy in a strip left of the column; every
|
||||
// other row keeps to the column by insetting past it.
|
||||
final gutter = chatCopyGutter(constraints.maxWidth);
|
||||
final media = MediaQuery.paddingOf(context);
|
||||
final transcript = [
|
||||
for (var index = 0; index < rows.length; index++)
|
||||
Padding(
|
||||
key: ValueKey<String>(keys[index]),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
padding: EdgeInsets.only(
|
||||
left:
|
||||
16 +
|
||||
(rows[index]['kind'] == 'assistant' ? 0 : gutter),
|
||||
right: 16,
|
||||
),
|
||||
// Slivers mount only visible rows. Defer constructing
|
||||
// their chips and checking cached widgets until then,
|
||||
// rather than visiting the entire history per delta.
|
||||
child: Builder(
|
||||
builder: (_) => _entering(
|
||||
rows[index],
|
||||
_transcriptRow(
|
||||
child: ChatCopyGutter(
|
||||
width: rows[index]['kind'] == 'assistant'
|
||||
? gutter
|
||||
: 0,
|
||||
child: Builder(
|
||||
builder: (_) => _entering(
|
||||
rows[index],
|
||||
keys[index],
|
||||
onDismissCompaction:
|
||||
compactionNotice != null &&
|
||||
chatNoticeActivityCondition(
|
||||
rows[index],
|
||||
) ==
|
||||
compactionNotice.condition
|
||||
? () => _dismiss(compactionNotice)
|
||||
: null,
|
||||
_transcriptRow(
|
||||
rows[index],
|
||||
keys[index],
|
||||
onDismissCompaction:
|
||||
compactionNotice != null &&
|
||||
chatNoticeActivityCondition(
|
||||
rows[index],
|
||||
) ==
|
||||
compactionNotice.condition
|
||||
? () => _dismiss(compactionNotice)
|
||||
: null,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -1177,12 +1197,12 @@ class _ChatThreadViewState extends State<ChatThreadView> {
|
||||
? null
|
||||
: ValueKey<String>(keys[split]),
|
||||
padding: EdgeInsets.fromLTRB(
|
||||
side,
|
||||
side - gutter,
|
||||
media.top + 8,
|
||||
side,
|
||||
8,
|
||||
),
|
||||
children: [
|
||||
children: chatCopyGutterInset(gutter, transcript, [
|
||||
if (initialLoad)
|
||||
Padding(
|
||||
key: const Key('chat-thread-loading'),
|
||||
@@ -1278,7 +1298,7 @@ class _ChatThreadViewState extends State<ChatThreadView> {
|
||||
notice: notice,
|
||||
onDismiss: _dismiss,
|
||||
),
|
||||
],
|
||||
]),
|
||||
),
|
||||
),
|
||||
if (showJump)
|
||||
@@ -1538,6 +1558,16 @@ class _ChatThreadViewState extends State<ChatThreadView> {
|
||||
runId: '${row['run_id']}',
|
||||
);
|
||||
}
|
||||
if (kind == chatShellHistoryRowKind) {
|
||||
// A chat with no answer yet keeps its dismissed commands on their own.
|
||||
return Align(
|
||||
alignment: AlignmentDirectional.centerStart,
|
||||
child: ChatShellHistoryChip(
|
||||
controller: _shellRuns,
|
||||
runIds: chatShellHistoryIds(row),
|
||||
),
|
||||
);
|
||||
}
|
||||
if (kind == chatShownRowKind) {
|
||||
return ChatShownCard(
|
||||
row: row,
|
||||
@@ -1563,6 +1593,8 @@ class _ChatThreadViewState extends State<ChatThreadView> {
|
||||
summary: Map<String, dynamic>.from(diff),
|
||||
load: () => _controller.turnDiff('${diff['turn_id']}'),
|
||||
),
|
||||
if (chatShellHistoryIds(row) case final ids when ids.isNotEmpty)
|
||||
ChatShellHistoryChip(controller: _shellRuns, runIds: ids),
|
||||
];
|
||||
if (kind == 'permissions') {
|
||||
return Align(
|
||||
@@ -1587,7 +1619,15 @@ class _ChatThreadViewState extends State<ChatThreadView> {
|
||||
return _rowWidgets.widgetFor(
|
||||
key,
|
||||
row,
|
||||
[delivery, cupertino, onRemove != null, _images, _controller, _composer],
|
||||
[
|
||||
delivery,
|
||||
cupertino,
|
||||
onRemove != null,
|
||||
_images,
|
||||
_controller,
|
||||
_composer,
|
||||
_shellRuns,
|
||||
],
|
||||
() => ChatMessageView(
|
||||
row: row,
|
||||
textBuilder: chatMarkdownText,
|
||||
|
||||
Reference in New Issue
Block a user