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:
@@ -16,10 +16,15 @@ class ShellGateway implements ApiGateway {
|
||||
final calls = <({String type, JsonMap fields})>[];
|
||||
final _frames = StreamController<JsonMap>.broadcast();
|
||||
List<JsonMap> runs = const [];
|
||||
|
||||
/// The chat history `chat_messages` answers with.
|
||||
List<JsonMap> messages = const [];
|
||||
String? refusal;
|
||||
|
||||
/// Tombstone ids the `chat_shell_runs` readback reports.
|
||||
/// Dismissed ids the `chat_shell_runs` readback reports, and the dismissed
|
||||
/// runs it carries (a server that keeps them).
|
||||
List<String> dismissed = const [];
|
||||
List<JsonMap> dismissedRuns = const [];
|
||||
|
||||
/// The refusal of `chat_shell_dismiss` / `chat_shell_restore`, when set.
|
||||
String? dismissRefusal;
|
||||
@@ -47,9 +52,13 @@ class ShellGateway implements ApiGateway {
|
||||
final body = fields['chat_shell_run_request'] as JsonMap? ?? const {};
|
||||
switch (type) {
|
||||
case 'chat_messages':
|
||||
return chatPage(const []);
|
||||
return chatPage(messages);
|
||||
case 'chat_shell_runs':
|
||||
return {'chat_shell_runs': runs, 'chat_shell_dismissed': dismissed};
|
||||
return {
|
||||
'chat_shell_runs': runs,
|
||||
'chat_shell_dismissed': dismissed,
|
||||
'chat_shell_dismissed_runs': dismissedRuns,
|
||||
};
|
||||
case 'chat_shell_dismiss':
|
||||
if (dismissRefusal != null) throw StateError(dismissRefusal!);
|
||||
return {'chat_shell_dismissed': body['run_ids']};
|
||||
@@ -58,7 +67,7 @@ class ShellGateway implements ApiGateway {
|
||||
final ids = (body['run_ids'] as List).toSet();
|
||||
return {
|
||||
'chat_shell_runs': [
|
||||
for (final run in runs)
|
||||
for (final run in [...runs, ...dismissedRuns])
|
||||
if (ids.contains(run['id'])) run,
|
||||
],
|
||||
};
|
||||
@@ -75,7 +84,10 @@ class ShellGateway implements ApiGateway {
|
||||
return {'chat_shell_run': resumeReply};
|
||||
}
|
||||
return {
|
||||
'chat_shell_run': runs.firstWhere((r) => r['id'] == body['run_id']),
|
||||
'chat_shell_run': [
|
||||
...runs,
|
||||
...dismissedRuns,
|
||||
].firstWhere((r) => r['id'] == body['run_id']),
|
||||
};
|
||||
}
|
||||
return <String, dynamic>{};
|
||||
@@ -123,6 +135,7 @@ JsonMap shellRecord(
|
||||
bool terminal = false,
|
||||
String text = '',
|
||||
int outputStart = 0,
|
||||
int startedAt = 1000,
|
||||
}) => {
|
||||
'id': id,
|
||||
'session_id': 's',
|
||||
@@ -130,8 +143,8 @@ JsonMap shellRecord(
|
||||
'directory': '/home/op/project',
|
||||
'status': status,
|
||||
'exit_code': ?exitCode,
|
||||
'started_at': 1000,
|
||||
'ended_at': ?(status == 'running' ? null : 1000 + durationMs),
|
||||
'started_at': startedAt,
|
||||
'ended_at': ?(status == 'running' ? null : startedAt + durationMs),
|
||||
'duration_ms': durationMs,
|
||||
'output': output,
|
||||
'output_start': outputStart,
|
||||
|
||||
Reference in New Issue
Block a user