实现 Codex 风格上下文压缩时间线交互

This commit is contained in:
2026-08-15 08:43:33 +08:00
parent 953b0f491e
commit fd9b5b46a9
13 changed files with 2044 additions and 73 deletions

View File

@@ -293,6 +293,30 @@ export interface OpencodeNormalizedSessionMessage {
partIDs: string[];
}
export type OpencodeCompactionSource = 'manual' | 'automatic';
export type OpencodeCompactionStatus = 'running' | 'completed';
/**
* A renderer-owned compaction timeline item. `id` is the immutable UI
* identity; native Part/event ids are correlation keys and may arrive later.
*/
export interface OpencodeCompactionTimelineEvent {
id: string;
sessionID: string;
source: OpencodeCompactionSource;
status: OpencodeCompactionStatus;
order: number;
anchorMessageID?: string;
anchorPartID?: string;
nativePartID?: string;
nativeEventID?: string;
runID?: string;
generation?: number;
startedAt?: number;
completedAt?: number;
}
export interface OpencodeSessionTranscriptState {
sessionID: string;
status: OpencodeSessionExecutionState;
@@ -300,6 +324,8 @@ export interface OpencodeSessionTranscriptState {
messageOrder: string[];
partsById: Record<string, OpencodeNormalizedSessionPart>;
partOrderByMessageId: Record<string, string[]>;
compactionsById: Record<string, OpencodeCompactionTimelineEvent>;
compactionOrder: string[];
lastError?: string;
lastEventKey?: string;
lastDeltaSignature?: string;