Files
magpie/docs
yetone a80a920f56 gateway: a turn on a Codex WebSocket says where its time went
buhaodeshiyehao on X (Codex through Lody's ACP): the Routing page's
"Where the time went" showed only the request's masking. Codex's turns
to the ChatGPT backend, and to a Responses provider with Socket, go over
a WebSocket (codexSocket), and every turn of a conversation after its
first goes on the kept socket. No HTTP request went out that the try's
client trace saw, so TryNet was nil and the page had nothing but the
masking to show. A new socket's turn had TryNet from its handshake only:
the 101's wait read as the vendor's, and the backend's real wait went
into "First token".

codexSocket.turn now tells the request's client trace of the turn as
Go's client tells it of an HTTP request (socketTrace): on a kept socket
GetConn and GotConn (reused), on a new one GotConn once the handshake is
answered (its DNS, connect and TLS stand; its round trip is the wait for
the connection), WroteRequest once the message is written and
GotFirstResponseByte at the first frame. Both callers' traces get it
(gateway.go's routed tries and codex_backend.go's own sign-in), and so
does the usage record's sent/own split, which kept-socket turns lacked.

Test: TestSocketTurnTellsWhereItsTimeWent, Codex's own sign-in and a
Responses provider with Socket, a new socket then the kept one, a 200ms
hold before the first frame. Red on the old code (new socket: Wait 0.4ms
for the 200ms hold; kept socket: no timing), green with it (Wait ~201ms
on all four turns).

Run on mote at this tree (base 9bcdcfb7d; rebased onto 2a8e1b444, whose three commits touch LESSONS.md, internal/plugin and internal/provider only): gofmt -l; go vet
./internal/gateway on darwin, GOOS=linux and GOOS=windows; go test
-count=1 -timeout 45m ./internal/gateway: ok (984s).
No GUI change: the page already draws every part once TryNet is there.
Not tried: a real Codex turn through Lody against chatgpt.com.
2026-11-15 22:43:30 +08:00
..