fix(agent-hooks): reconcile authoritative remote Codex state

This commit is contained in:
Brennan Benson
2026-08-27 16:01:30 -07:00
parent 4f3e1f43e7
commit dd750dc6b3
14 changed files with 360 additions and 16 deletions
@@ -9,7 +9,8 @@ export function seedCodexSubagentTranscriptFromSnapshot(
state: CodexSubagentTranscriptState,
snapshots: readonly (Pick<AgentSubagentSnapshot, 'id' | 'description' | 'startedAt' | 'model'> &
Partial<Pick<AgentSubagentSnapshot, 'state'>>)[],
transcriptPath?: string
transcriptPath?: string,
options: { authoritative?: boolean } = {}
): void {
const normalizedPath = transcriptPath?.trim()
if (
@@ -18,11 +19,14 @@ export function seedCodexSubagentTranscriptFromSnapshot(
extname(normalizedPath) === '.jsonl' &&
state.parent.filePath !== normalizedPath
) {
state.parent = { filePath: normalizedPath, offset: 0, carry: '' }
state.parent = { filePath: normalizedPath, offset: 0, carry: '', coverageAuthoritative: false }
state.subagents.clear()
state.parentTerminalObserved = undefined
state.parentReadable = undefined
}
if (options.authoritative) {
state.parent.coverageAuthoritative = true
}
for (const snapshot of snapshots) {
if (!SAFE_THREAD_ID.test(snapshot.id) || state.subagents.has(snapshot.id)) {
continue
@@ -30,6 +34,7 @@ export function seedCodexSubagentTranscriptFromSnapshot(
state.subagents.set(snapshot.id, {
offset: 0,
carry: '',
coverageAuthoritative: false,
description: snapshot.description,
model: snapshot.model,
restoredState: