fix(codex): reconcile cold connections without resuming queued goals
This commit is contained in:
+6
-1
@@ -1208,6 +1208,7 @@ export const EVENT_USAGE = "usage";
|
||||
export const EVENT_USER = "user";
|
||||
export const EVENT_SHELL = "shell";
|
||||
export const EVENT_FORM = "form";
|
||||
export const EVENT_RESYNC = "resync";
|
||||
|
||||
/** ChatStep.Status values. `ended` is the one status that settles a turn. */
|
||||
export const STEP_ENDED = "ended";
|
||||
@@ -1603,6 +1604,8 @@ export function applyChatForm(thread, form) {
|
||||
* targets is created on first sight, so a live turn never gains a second bubble.
|
||||
*/
|
||||
export function applyChatEvent(thread, frame, now = Date.now()) {
|
||||
if (frame?.kind === EVENT_RESYNC) return thread ?? newChatThread(str(frame?.session_id));
|
||||
if (frame?.kind === EVENT_STEP && frame.step?.status === STEP_ENDED && frame.step?.turn_id && frame.step.turn_id !== thread?.nativeTurnId) return thread ?? newChatThread(str(frame?.session_id));
|
||||
const current = thread?.queued
|
||||
? { ...thread, queued: false }
|
||||
: (thread ?? newChatThread(str(frame?.session_id)));
|
||||
@@ -1616,7 +1619,9 @@ export function applyChatEvent(thread, frame, now = Date.now()) {
|
||||
return applyTool(current, frame, now);
|
||||
case EVENT_STEP:
|
||||
if (frame?.step?.intermediate) return current;
|
||||
return setThreadRunning(current, str(frame?.step?.status) !== STEP_ENDED, now);
|
||||
if (frame?.step?.turn_id && frame.step.status === STEP_ENDED && frame.step.turn_id !== current.nativeTurnId) return current;
|
||||
return { ...setThreadRunning(current, str(frame?.step?.status) !== STEP_ENDED, now),
|
||||
nativeTurnId: frame.step?.status === STEP_ENDED ? "" : frame.step?.turn_id || current.nativeTurnId || "" };
|
||||
// A shell frame only folds its shell into the retained set: it NEVER marks
|
||||
// the thread running, because a background process is not the turn — a shell
|
||||
// that outlives the turn keeps showing after the turn's own indicator is gone.
|
||||
|
||||
Reference in New Issue
Block a user