chat: /clear round-trip is 3-5s since the #149 clear-hook — pull + double transcript parse block the forward #177
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Cloonar/coding-lab#177
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Symptom
Sending
/clear(or New conversation) used to feel sub-second; since the clear-hook shipped (issue #149, ~Jul 12) it takes 3-5 seconds before the chat visibly resets. Perceived as gradual degradation, but it is a discrete regression amplified by forge latency (issue #176).Mechanism (code-confirmed)
handleClearWithPull(internal/httpapi/chat.go) runs, serially, before the clear is forwarded:chat.Read— a full transcript parse (~20ms/MB measured with the real parser; 30-75ms at current sizes, grows within a conversation).PullBasewhen idle — git fetch against the forge + merge (~1-3s; forge RTT is 0.3-0.5s and rising with forge load).chat.Reply->dialogPending-> a second full transcript parse.Then the UI waits up to one tailer tick (1s poll) for the rotation to be noticed and the stream to reset. Total: ~3-5s of blocking work for what reads as an instant local action.
Fix direction
The clear is already sacrosanct ("always goes through"); make it fast too:
dialogPendingread the same state within milliseconds — a single read can serve both gates. (The tailer's last derived state is also available viachat.State(session)and may be fresh enough for the busy gate.)Constraints: keep the #149/#151 semantics — arg-bearing clears still pull, a failed pull is loud but never blocks the clear, a working agent skips the pull. The rotation-detection path (locateActive, issue #34) is fine and not part of this.
Verification
Reply-route histogram (
lab_http_request_duration_seconds{route="/api/v1/runs/{id}/reply"}): clear sends currently land in the 1-10s buckets; after the fix a clear POST should return in the same ~400ms band as an ordinary reply, and the chat should reset within ~1 tailer tick.