Chat queue: wake the runner when a scheduled head is unqueued; end a stale observed turn once the harness is idle
A prompt queued behind a scheduled prompt (the app's auto-continue at a usage limit's reset) stayed queued after that head was removed: unqueue never woke the runner, which slept until the removed prompt's send_at. unqueue now wakes it, and the runner re-checks a scheduled head at least every 30 s. Safety net: a due prompt held by a turn the room only observed (its end lost, or a reattach watcher that gave up) is delivered once the harness reports itself idle for a settle period and its probe confirms it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -247,6 +247,36 @@ func TestInterruptAfterRestart(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// A chat whose last turn before a restart was refused for a usage limit is
|
||||
// idle after the restart: the reattached host reports no turn running, so a
|
||||
// prompt queued for it is not held, and the next prompt runs on the same CLI.
|
||||
func TestRefusedLastTurnIsIdleAfterRestart(t *testing.T) {
|
||||
fixture := hostedSetup(t)
|
||||
first := hostedChat(t)
|
||||
session := newCreatedChat(t, first)
|
||||
frames := subscribe(t, first, session.ID)
|
||||
if err := first.Prompt(context.Background(), session.ID, "usage-limit"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
waitStepEnded(t, frames)
|
||||
second := restart(t, first)
|
||||
if running, err := second.ProbeTurn(context.Background(), session.ID); err != nil || running {
|
||||
t.Fatalf("the refused turn must not be running after the restart: running=%t err=%v", running, err)
|
||||
}
|
||||
if second.TurnRunning(session.ID) {
|
||||
t.Fatal("TurnRunning must report the refused chat idle after the restart")
|
||||
}
|
||||
frames = subscribe(t, second, session.ID)
|
||||
if err := second.Prompt(context.Background(), session.ID, "continue"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
waitFrame(t, frames, "the next turn's text", textFrame("Hello"))
|
||||
waitStepEnded(t, frames)
|
||||
if spawns := readArgs(t, fixture.logPath); len(spawns) != 1 {
|
||||
t.Fatalf("the CLI must not be restarted, spawns: %+v", spawns)
|
||||
}
|
||||
}
|
||||
|
||||
func TestModelAndBackgroundTaskSurviveRestart(t *testing.T) {
|
||||
fixture := hostedSetup(t)
|
||||
first := hostedChat(t)
|
||||
|
||||
Reference in New Issue
Block a user