fix(codex): preserve transcript sync across mode switches

This commit is contained in:
weishu
2026-07-28 12:20:54 +08:00
parent f0c7d0b7e7
commit 92958890de
6 changed files with 118 additions and 9 deletions
+10 -2
View File
@@ -17,11 +17,11 @@ export class CodexSession extends AgentSessionBase<EnhancedMode> {
readonly codexCliOverrides?: CodexCliOverrides;
readonly startedBy: 'runner' | 'terminal';
readonly startingMode: 'local' | 'remote';
readonly replayTranscriptHistoryOnStart: boolean;
readonly sourceSessionId?: string;
localLaunchFailure: LocalLaunchFailure | null = null;
private transcriptPathCallbacks: Array<(path: string) => void> = [];
private transcriptHistoryReplayPending: boolean;
constructor(opts: {
api: ApiClient;
@@ -68,7 +68,7 @@ export class CodexSession extends AgentSessionBase<EnhancedMode> {
this.codexCliOverrides = opts.codexCliOverrides;
this.startedBy = opts.startedBy;
this.startingMode = opts.startingMode;
this.replayTranscriptHistoryOnStart = opts.replayTranscriptHistoryOnStart ?? false;
this.transcriptHistoryReplayPending = opts.replayTranscriptHistoryOnStart ?? false;
this.sourceSessionId = opts.sourceSessionId;
this.permissionMode = opts.permissionMode;
this.model = opts.model;
@@ -76,6 +76,14 @@ export class CodexSession extends AgentSessionBase<EnhancedMode> {
this.collaborationMode = opts.collaborationMode;
}
shouldReplayTranscriptHistory(): boolean {
return this.transcriptHistoryReplayPending;
}
markTranscriptHistoryReplayConsumed(): void {
this.transcriptHistoryReplayPending = false;
}
onTranscriptPathFound(path: string): void {
if (this.transcriptPath === path) {
return;