fix(agent-hooks): harden Codex restart reconciliation

This commit is contained in:
Brennan Benson
2026-08-27 15:18:57 -07:00
parent f8ad411e2c
commit 4f3e1f43e7
12 changed files with 452 additions and 105 deletions
+6 -1
View File
@@ -35,6 +35,7 @@ export type CodexSubagentTranscriptState = {
parent: JsonlCursor
subagents: Map<string, TrackedTranscriptSubagent>
parentTerminalObserved?: boolean
parentReadable?: boolean
}
type JsonRecord = Record<string, unknown>
@@ -187,6 +188,7 @@ export function reconcileCodexSubagentTranscript(
): void {
const normalizedPath = transcriptPath?.trim()
if (!normalizedPath || !isAbsolute(normalizedPath) || extname(normalizedPath) !== '.jsonl') {
state.parentReadable = false
return
}
if (state.parent.filePath !== normalizedPath) {
@@ -196,8 +198,11 @@ export function reconcileCodexSubagentTranscript(
state.parent = { filePath: normalizedPath, offset: 0, carry: '' }
state.subagents.clear()
state.parentTerminalObserved = undefined
state.parentReadable = undefined
}
for (const recordValue of readJsonlCursor(state.parent) ?? []) {
const parentRecords = readJsonlCursor(state.parent)
state.parentReadable = parentRecords !== undefined
for (const recordValue of parentRecords ?? []) {
if (recordValue.type === 'event_msg') {
const eventType = record(recordValue.payload)?.type
if (eventType === 'task_started' || eventType === 'task_complete') {