Fix missing root-level fallback for turns in parseThreadSnapshot
When the API returns a flat response (threadId at root level instead of nested under thread), parseThreadSnapshot correctly fell back to reading threadId from the root but silently defaulted turns to []. This caused checkpoint listings to return no checkpoints and revert operations to use a messageCount of zero, leading to data loss. Add a fallback to read turns from the root-level response, matching the existing fallback pattern used for threadId.
This commit is contained in:
1 parent
e448221739
commit
645e6dbe3c
1 file changed
+1
-1
@@ -795,7 +795,7 @@ export class CodexAppServerManager extends EventEmitter<CodexAppServerManagerEve
|
||||
throw new Error(`${method} response did not include a thread id.`);
|
||||
}
|
||||
|
||||
const turnsRaw = this.readArray(thread, "turns") ?? [];
|
||||
const turnsRaw = this.readArray(thread, "turns") ?? this.readArray(responseRecord, "turns") ?? [];
|
||||
const turns = turnsRaw.map((turnValue, index) => {
|
||||
const turn = this.readObject(turnValue);
|
||||
const turnId = this.readString(turn, "id") ?? `${threadId}:turn:${index + 1}`;
|
||||
|
||||
Reference in new issue
Block a user