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; }