Complete the Codex host initialization handshake once
This commit is contained in:
@@ -39,6 +39,7 @@ func TestHostedDetachRetainsAnswerableInteractions(t *testing.T) {
|
||||
var mu sync.Mutex
|
||||
var upstream *websocket.Conn
|
||||
var initialized atomic.Int32
|
||||
var handshakeCompleted atomic.Int32
|
||||
responses := make(chan rpcMessage, 8)
|
||||
readyUpstream := make(chan struct{})
|
||||
server := &http.Server{Handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
@@ -63,6 +64,10 @@ func TestHostedDetachRetainsAnswerableInteractions(t *testing.T) {
|
||||
if msg.Method == "initialize" {
|
||||
initialized.Add(1)
|
||||
}
|
||||
if msg.Method == "initialized" {
|
||||
handshakeCompleted.Add(1)
|
||||
continue
|
||||
}
|
||||
mu.Lock()
|
||||
err = wsjson.Write(ctx, conn, map[string]any{"id": msg.ID, "result": map[string]any{}})
|
||||
mu.Unlock()
|
||||
@@ -161,8 +166,8 @@ func TestHostedDetachRetainsAnswerableInteractions(t *testing.T) {
|
||||
if !seen["7"] || !seen["8"] {
|
||||
t.Fatalf("callback identities changed: %+v", seen)
|
||||
}
|
||||
if initialized.Load() != 1 {
|
||||
t.Fatalf("upstream initialized %d times", initialized.Load())
|
||||
if initialized.Load() != 1 || handshakeCompleted.Load() != 1 {
|
||||
t.Fatalf("upstream handshake counts: initialize=%d initialized=%d", initialized.Load(), handshakeCompleted.Load())
|
||||
}
|
||||
if err := after.Answer(ctx, protocol.ChatAnswerRequest{SessionID: "thread-a", FormID: "question", Answers: map[string]any{"q": "no"}}); err == nil {
|
||||
t.Fatal("question was answered twice")
|
||||
|
||||
Reference in New Issue
Block a user