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:
@@ -17,7 +17,11 @@ import '../ui/sessions/session_actions.dart';
|
||||
import '../ui/transcript/chat_markdown_view.dart';
|
||||
import '../ui/transcript/chat_message_view.dart';
|
||||
import '../ui/transcript/chat_injected_rows.dart';
|
||||
import '../../artifacts/actions/artifact_file_bridge.dart';
|
||||
import '../domain/chat_session_handoff.dart';
|
||||
import 'chat_account_usage_section.dart';
|
||||
import 'chat_export_controller.dart';
|
||||
import 'chat_session_section.dart';
|
||||
import 'chat_background_tasks.dart';
|
||||
import 'chat_command_actions.dart';
|
||||
import 'chat_composer_bar.dart';
|
||||
@@ -75,6 +79,7 @@ class ChatThreadView extends StatefulWidget {
|
||||
this.onCreatedSession,
|
||||
this.onSessionRenamed,
|
||||
this.onSessionClosed,
|
||||
this.fileBridge = const ArtifactFileBridge(),
|
||||
});
|
||||
|
||||
final ApiGateway gateway;
|
||||
@@ -96,6 +101,9 @@ class ChatThreadView extends StatefulWidget {
|
||||
/// `/close` was accepted: the conversation is finished here as on the web.
|
||||
final VoidCallback? onSessionClosed;
|
||||
|
||||
/// The host file actions the info sheet's export uses; tests inject one.
|
||||
final ArtifactFileBridge fileBridge;
|
||||
|
||||
/// The list row's title when this visit knows it; a deep link may not.
|
||||
final String title;
|
||||
|
||||
@@ -332,16 +340,31 @@ class _ChatThreadViewState extends State<ChatThreadView> {
|
||||
Future<void> _openInfo() async {
|
||||
final cupertino =
|
||||
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
|
||||
final exporter = ChatExportController(
|
||||
repository: ChatRepository(widget.gateway),
|
||||
sessionId: widget.sessionId,
|
||||
bridge: widget.fileBridge,
|
||||
);
|
||||
try {
|
||||
await _showInfo(cupertino, exporter);
|
||||
} finally {
|
||||
exporter.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _showInfo(bool cupertino, ChatExportController exporter) async {
|
||||
final handoff = ChatSessionHandoff.from(widget.sessionId, widget.session);
|
||||
Widget sheet() => _ChatInfoSheet(
|
||||
controller: _controller,
|
||||
handoff: handoff,
|
||||
exporter: exporter,
|
||||
);
|
||||
if (cupertino) {
|
||||
await showCupertinoModalPopup<void>(
|
||||
context: context,
|
||||
builder: (sheetContext) => Align(
|
||||
alignment: Alignment.bottomCenter,
|
||||
child: SafeArea(
|
||||
child: CupertinoPopupSurface(
|
||||
child: _ChatInfoSheet(controller: _controller),
|
||||
),
|
||||
),
|
||||
child: SafeArea(child: CupertinoPopupSurface(child: sheet())),
|
||||
),
|
||||
);
|
||||
return;
|
||||
@@ -351,7 +374,7 @@ class _ChatThreadViewState extends State<ChatThreadView> {
|
||||
showDragHandle: true,
|
||||
isScrollControlled: true,
|
||||
useSafeArea: true,
|
||||
builder: (sheetContext) => _ChatInfoSheet(controller: _controller),
|
||||
builder: (sheetContext) => sheet(),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1541,9 +1564,15 @@ String _chatInfoDollars(num value) {
|
||||
/// The "Chat information" panel. It rebuilds from the controller, so metrics
|
||||
/// that arrive while it is open replace the displayed snapshot.
|
||||
class _ChatInfoSheet extends StatelessWidget {
|
||||
const _ChatInfoSheet({required this.controller});
|
||||
const _ChatInfoSheet({
|
||||
required this.controller,
|
||||
required this.handoff,
|
||||
required this.exporter,
|
||||
});
|
||||
|
||||
final ChatThreadController controller;
|
||||
final ChatSessionHandoff handoff;
|
||||
final ChatExportController exporter;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -1586,6 +1615,12 @@ class _ChatInfoSheet extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
),
|
||||
ChatSessionSection(
|
||||
handoff: handoff,
|
||||
exporter: exporter,
|
||||
cupertino: cupertino,
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
],
|
||||
);
|
||||
if (!cupertino) return SingleChildScrollView(child: content);
|
||||
|
||||
Reference in New Issue
Block a user