feat: built-in /compact and compaction rows in the transcript

- /compact is not one of the directory's commands: OpenChamber's own
  client supplies it and runs POST /api/session/:id/compact. The palette now
  starts with that local command (压缩), so picking it compacts without the
  model seeing anything.
- A compaction message (status running/completed/failed, reason, summary,
  tokens) is part of the timeline. It now shows as the official client's
  row: a scissors glyph and "正在压缩对话" / "对话已压缩", a 显示摘要 toggle,
  and the summary as Markdown (revealed with the same height animation as
  the other folds). Failed compactions keep the error block.
- Live compaction events are subscribed: started adds the running record
  (or refreshes the tail when it names no id), delta appends the streaming
  summary, ended/failed fetch the server's settled record.
- Version 0.3.8 (code 308).
This commit is contained in:
blumia committed 2026-11-20 12:26:15 +08:00
1 parent fbadf6f858
commit b9433c30cb
7 files changed
+214 -14

No files matched your search

+6 -2
View File
@@ -196,10 +196,12 @@ class Message {
final TokenUsage? tokens;
/// Set when the step (or compaction) failed.
final MessageError? error;
/// Compaction messages: 'failed' etc.
/// Compaction messages: 'running' | 'completed' | 'failed'.
final String status;
/// Compaction messages: why it ran ('manual').
/// Compaction messages: why it ran ('manual' | 'auto').
final String reason;
/// Compaction messages: the summary the model wrote for the new history.
final String summary;
Message({
required this.id,
required this.type,
@@ -216,6 +218,7 @@ class Message {
this.error,
this.status = '',
this.reason = '',
this.summary = '',
});
factory Message.fromJson(Map<String, dynamic> j) {
final t = j['time'] as Map<String, dynamic>? ?? {};
@@ -243,6 +246,7 @@ class Message {
: MessageError.fromJson(j['error'] as Map<String, dynamic>),
status: j['status'] as String? ?? '',
reason: j['reason'] as String? ?? '',
summary: j['summary'] as String? ?? '',
);
}
String get partText {