Hold external chat admission until live turn recovery completes
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
"git.a-wan.net/alan/pipelines/internal/opencode"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync/atomic"
|
||||
|
||||
"git.a-wan.net/alan/pipelines/internal/pipeline"
|
||||
@@ -161,6 +162,16 @@ func chatClientToken() string {
|
||||
// connection-scoped write function so the read loop and the stream goroutine
|
||||
// never interleave partial websocket writes.
|
||||
func handleChat(ctx context.Context, request protocol.Message, broker chatBroker, hub *chatHub, registry operatorRegistry, clientID string, write func(protocol.Message) error) bool {
|
||||
// External chat admission and readback must follow durable turn/queue
|
||||
// restoration: even readback can reconcile hub state. Internal recovery
|
||||
// does not dispatch requests here. The cold registry scan runs afterward.
|
||||
if hub != nil && hub.recoveryReady != nil && strings.HasPrefix(string(request.Type), "chat_") {
|
||||
select {
|
||||
case <-hub.recoveryReady:
|
||||
case <-ctx.Done():
|
||||
return true
|
||||
}
|
||||
}
|
||||
switch request.Type {
|
||||
case protocol.ChatPrompt:
|
||||
handleChatPrompt(ctx, request, broker, hub, registry, clientID, write)
|
||||
|
||||
Reference in New Issue
Block a user