Chat queue: handle usage refusals only after start-up recovery; fix shell share test ordering
TestAutoSwitchReplacesTheAutoContinue flaked because a usage refusal (delivered on its own goroutine) was acted on while start-up recovery was still running. resumeQueued read the durable auto-continue row, the server's account switch then removed it, and resumeQueued put it back into the room; as the queue head scheduled an hour out it held the switch's continue prompt behind it. The refusal handler (and the schedule_followup tool) now wait for the same recovery gate chat_* requests already wait for, and the refusal watcher is registered only once the hub is fully wired. TestChatShellShareQueuesAnOrdinaryPrompt flaked because the turn runner writes the sender's reply straight to its connection while the echoed user turn goes through the subscription writer, so the reply can arrive first and the test discarded it while reading for the echo. The test now accepts either order. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -175,8 +175,17 @@ func TestChatShellShareQueuesAnOrdinaryPrompt(t *testing.T) {
|
||||
finishedShell(t, ctx, conns[0], run.ID)
|
||||
writeChat(t, ctx, conns[0], shellRequest(protocol.ChatShellShare, "share", run.ID, ""))
|
||||
// The composed prompt is echoed to the sender too: it has no local copy.
|
||||
for _, conn := range conns {
|
||||
// The turn runner writes the sender's reply straight to its connection
|
||||
// while the echo goes through the sender's subscription writer, so the two
|
||||
// arrive in either order; neither may be skipped while reading for the
|
||||
// other.
|
||||
var reply *protocol.Message
|
||||
for i, conn := range conns {
|
||||
user := readShellFrame(t, ctx, conn, func(m protocol.Message) bool {
|
||||
if i == 0 && m.ID == "share" {
|
||||
reply = &m
|
||||
return false
|
||||
}
|
||||
return m.Type == protocol.ChatEvent && m.ChatEvent != nil && m.ChatEvent.Kind == protocol.ChatEventUser
|
||||
}).ChatEvent
|
||||
text := user.Part.Text
|
||||
@@ -184,7 +193,11 @@ func TestChatShellShareQueuesAnOrdinaryPrompt(t *testing.T) {
|
||||
t.Fatalf("shared prompt = %q", text)
|
||||
}
|
||||
}
|
||||
if reply := readShellFrame(t, ctx, conns[0], func(m protocol.Message) bool { return m.ID == "share" }); reply.Type != protocol.ChatPrompt {
|
||||
if reply == nil {
|
||||
got := readShellFrame(t, ctx, conns[0], func(m protocol.Message) bool { return m.ID == "share" })
|
||||
reply = &got
|
||||
}
|
||||
if reply.Type != protocol.ChatPrompt {
|
||||
t.Fatalf("share reply = %+v", reply)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user