package server import ( "context" "encoding/json" "github.com/coder/websocket" "github.com/coder/websocket/wsjson" "git.a-wan.net/alan/pipelines/internal/protocol" ) // readTestFrame reads the next websocket frame into v like wsjson.Read, but // skips chat_activity pushes. Those reach every connection whenever any // chat's turn or background-task count changes, so tests that read one // connection's replies in order would otherwise see them interleaved. Tests of // chat_activity itself read the raw stream. func readTestFrame(ctx context.Context, conn *websocket.Conn, v any) error { for { var raw json.RawMessage if err := wsjson.Read(ctx, conn, &raw); err != nil { return err } var head struct { Type string `json:"type"` } if json.Unmarshal(raw, &head) == nil && head.Type == protocol.ChatActivityChanged { continue } return json.Unmarshal(raw, v) } }