Files
pipelines/app/lib/features/chat/domain/chat_session_handoff.dart
T
alan 1de74f76bb 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).
2026-11-03 10:59:41 +00:00

52 lines
1.6 KiB
Dart

import '../../../core/api_gateway.dart';
/// The facts the info sheet's "Session" section shows, read from the chat's
/// `chat_sessions` row.
///
/// The chat id is the harness's native session id (Claude Code session UUID,
/// Codex thread id, OpenCode `ses_` id). The resume command and native export
/// flag come from the server, which checked each form against the harness
/// CLI; an older server sends neither, and nothing is invented here.
class ChatSessionHandoff {
const ChatSessionHandoff({
required this.id,
required this.backend,
required this.directory,
required this.resumeCommand,
required this.nativeExport,
});
/// [row] may be null when the conversation was opened by id alone.
factory ChatSessionHandoff.from(String sessionId, JsonMap? row) {
String text(String key) => '${row?[key] ?? ''}'.trim();
final id = text('id');
return ChatSessionHandoff(
id: id.isEmpty ? sessionId.trim() : id,
backend: row == null
? ''
: (text('backend').isEmpty ? 'opencode' : text('backend')),
directory: text('directory'),
resumeCommand: text('resume_command'),
nativeExport: row?['native_export'] == true,
);
}
final String id;
/// Empty when the row is unknown; a row without a backend is OpenCode.
final String backend;
final String directory;
final String resumeCommand;
final bool nativeExport;
}
/// The formats `chat_export` accepts.
enum ChatExportFormat {
markdown('markdown'),
json('json'),
native('native');
const ChatExportFormat(this.wire);
final String wire;
}