80022ea41a
Chat attention notifications (questions, approvals, finished replies) come from a session's event stream, which the hub only read while a room existed; detach destroyed the room when the last client left, so a turn that finished or asked with the app closed notified nobody. A room whose last client leaves now stays observing, unattended, while its turn is in flight or it holds an unanswered question/approval, and is torn down when the turn ends (or after 6h for a stuck turn); at most 16 such rooms. At server start, recently used open sessions whose harness reports a running turn (OpenCode /api/session/active, Codex thread/turns/list) are observed again so their reply still notifies. Settings, dedupe and app_notifications recording are unchanged.
31 lines
901 B
Go
31 lines
901 B
Go
package codex
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"sync/atomic"
|
|
"testing"
|
|
)
|
|
|
|
// ProbeTurn reports the latest turn's in-progress state from the App Server.
|
|
func TestProbeTurnReadsLatestTurn(t *testing.T) {
|
|
var completed atomic.Bool
|
|
c := modelTestChat(t, func(method string, _ json.RawMessage) any {
|
|
if method != "thread/turns/list" {
|
|
t.Errorf("unexpected method: %s", method)
|
|
}
|
|
status := "inProgress"
|
|
if completed.Load() {
|
|
status = "completed"
|
|
}
|
|
return json.RawMessage(`{"data":[{"id":"turn","status":"` + status + `","items":[]}],"nextCursor":null}`)
|
|
})
|
|
if running, err := c.ProbeTurn(context.Background(), fixtureThread); err != nil || !running {
|
|
t.Fatalf("in-progress turn: %v %v", running, err)
|
|
}
|
|
completed.Store(true)
|
|
if running, err := c.ProbeTurn(context.Background(), fixtureThread); err != nil || running {
|
|
t.Fatalf("completed turn: %v %v", running, err)
|
|
}
|
|
}
|