fix(codex): reconcile cold connections without resuming queued goals

This commit is contained in:
2026-10-20 18:33:20 +01:00
parent b3bcfa3826
commit d564765ca5
14 changed files with 355 additions and 34 deletions
+12
View File
@@ -147,6 +147,7 @@ type chatRoom struct {
pollerStarted bool
wake chan struct{}
turnDone chan struct{}
nativeTurnID string
}
func newChatRoom(base context.Context, sessionID string) *chatRoom {
@@ -373,6 +374,15 @@ func (h *chatHub) emitRoom(source *chatRoom, frame protocol.ChatEventFrame) {
h.mu.Unlock()
return
}
if room != nil && frame.Kind == protocol.ChatEventStep && frame.Step != nil && frame.Step.TurnID != "" && !frame.Step.Intermediate {
if frame.Step.Status == protocol.ChatStepStarted {
room.nativeTurnID = frame.Step.TurnID
}
if frame.Step.Status == protocol.ChatStepEnded && room.nativeTurnID != frame.Step.TurnID {
h.mu.Unlock()
return
}
}
h.applyLocked(frame)
buffered := false
var targets []*chatSub
@@ -475,6 +485,7 @@ func (h *chatHub) replaceShellsLocked(sessionID string, shells []protocol.ChatSh
// wait. Callers must hold h.mu.
func (h *chatHub) finishTurnLocked(room *chatRoom) {
room.running = false
room.nativeTurnID = ""
if room.turnDone != nil {
close(room.turnDone)
room.turnDone = nil
@@ -660,6 +671,7 @@ func (h *chatHub) nextPrompt(room *chatRoom) (*chatQueuedPrompt, chan struct{},
p := room.queue[0]
room.queue = room.queue[1:]
room.running = true
room.nativeTurnID = ""
room.turnDone = make(chan struct{})
done := room.turnDone
h.mu.Unlock()