Chat info: Session section with native id, resume command and export

The chat information sheet gains a Session section: the harness's native
session id (copy), harness, directory, a verified resume command (copy)
and Export conversation (Markdown), Export JSON and, for Claude Code,
Export native session (the JSONL transcript).

Server: chat_sessions rows carry resume_command and native_export; new
chat_export command builds Markdown/JSON from the same paged history
chat_messages serves (bounded at 8 MiB), refuses non-operator sessions.
App: exports go through the artifact file bridge (web download, share
sheet on phones).
This commit is contained in:
2026-11-03 10:59:41 +00:00
parent 6413fc5a90
commit 1de74f76bb
19 changed files with 1552 additions and 10 deletions
+29
View File
@@ -26,6 +26,16 @@ int get _hits => int.tryParse(_params['hits'] ?? '') ?? 0;
int get _chats => int.tryParse(_params['chats'] ?? '') ?? 0;
bool get perfRunGraph => _params['graph'] == '1';
/// `?harness=claude|codex` makes the chats that harness's (default OpenCode),
/// with the resume command the server would send for it.
String get _harness => _params['harness'] ?? 'opencode';
String _resumeCommand(String id) => switch (_harness) {
'claude' => 'cd /workspace/demo && claude --resume $id',
'codex' => 'cd /workspace/demo && codex resume $id',
_ => 'cd /workspace/demo && opencode --session $id',
};
/// Whether a chat scroll option (tool/perf/chat_scroll_fixture.dart) shapes
/// the transcripts instead of the bench's short markdown history.
bool get _scrollVariety => ['msgs', 'rich', 'older'].any(_params.containsKey);
@@ -142,9 +152,28 @@ JsonMap? perfChatReply(JsonMap request) {
'id': 'perf-chat-$i',
'title': 'Fixture chat ${i + 1}',
'directory': '/workspace/demo',
// Server-shaped handoff facts (chat_sessions rows carry them).
if (_harness != 'opencode') 'backend': _harness,
'resume_command': _resumeCommand('perf-chat-$i'),
'native_export': _harness == 'claude',
},
],
};
case 'chat_export':
final body = request['chat_export'];
final format = body is Map ? '${body['format'] ?? ''}' : '';
final json = format == 'json';
return {
'id': id,
'type': 'chat_export',
'chat_export_file': {
'session_id': body is Map ? body['session_id'] : '',
'format': format,
'name': json ? 'Fixture-chat.json' : 'Fixture-chat.md',
'mime': json ? 'application/json' : 'text/markdown',
'content': json ? '{"messages":[]}\n' : '# Fixture chat\n',
},
};
case 'chat_subscribe':
return {'id': id, 'type': 'chat_subscribed'};
case 'chat_shells':