Repository navigation
π fix: dashboard chat stops showing replies when a poll request stalls - #15195
Conversation
Bound each /api/chat/messages poll with a 10 s abort and queue one follow-up poll for callers that land while a poll is in flight, so a stalled request can no longer swallow the post-command poll and leave no timer armed. Fixes #15137 Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> Co-authored-by: kanrenibm <91967876+kanrenibm@users.noreply.github.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
hive/awaiting-ci: CI pending β sweep will merge when green. π Hive Agent: β hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88 |
Open PR overlap checkBase branch: Conflicts are checked with every PR merged onto the current tip of
|
There was a problem hiding this comment.
Read the poll slice at the PR head (src/pkg/dashboard/static/index.html:58538-58573) and its callers; this looks correct to me.
GET /api/chat/messagesreturns immediately (src/pkg/dashboard/api_chat.go:228-253βDashboardChatPoll(since)thenjsonResponse, no long-poll), so a 10 sAbortControllerdeadline cannot cut off a legitimate response.- The
chatPollQueuedflag is reset at the top of the next run (:58546) and only consulted afteragain(:58569-58570), so the epoch-reset retry subsumes the queued follow-up instead of issuing a third request, and overlapping callers still never fetch in parallel. An abort lands in the existingcatchβchatNotePollFailureβ backoff path. - The caller at
:58212(await chatPollMessages()after an accepted/api/chat) already tolerated an early return, so the queued path does not change its contract. TestHiveChatPollRecoversFromStalledRequestexercises the real slice via the node harness; the finalscheduled[...] === CHAT_POLL_OPEN_MSassertion holds because the queued poll's success resetschatPollFailuresafter the abort increments it.
Dashboard test shards are green on this head.
β hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88
There was a problem hiding this comment.
Read the poll slice at base (src/pkg/dashboard/static/index.html:58534-58571) and the node harness that extracts it. The change looks correct to me.
What I verified:
- The abort path lands in the existing
catchβchatNotePollFailure()βfinally, so an abandoned request takes the same backoff as a non-2xx, andclearTimeout(abortTimer)runs on every exit (index.html:58567). The follow-up poll then resetschatPollFailures = 0on success, which is why the test's last scheduled delay isCHAT_POLL_OPEN_MS. chatPollQueuedis declared inside the slice the harness lifts (chat_outbox_cursor_test.go:16, betweenchatRenderOutboundand the Device Flow comment), andCHAT_POLL_TIMEOUT_MSis supplied by the harness prelude β so the test runs the real production function, not a copy.- When
againandchatPollQueuedare both set, theretriedcall resetschatPollQueued = falseon entry and its fetch uses the updatedsince, so the queued caller's request is still covered by a later fetch. No parallel requests are introduced; the #9135 single-flight invariant holds. chatAskBackendalready uses the sameAbortControllerpattern (index.html:58197), as the body says.
Minor, not a blocker: the queued follow-up runs even if document.hidden flipped true mid-flight (chatSchedulePoll is the only hidden-tab guard). That is at most one extra GET per hide, so I would not change it.
β hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88
|
Thank you for your contribution! Your PR has been merged. We'd love to hear how your experience was: share feedback |
Closes #15137
Why
The bot replies (seq 118/120) were already on the server. The browser just stopped asking for them for 99 s.
chatPollMessageslets only one request run at a time. It clears the next-poll timer when a request starts and only re-arms it when that request settles. Two gaps combined:chatPollInFlightstays true with no timer armed. The channel goes silent until the browser or proxy gives up on the request.POST /api/chatis accepted,chatAskBackendrunsawait chatPollMessages()to fetch the reply. With a request in flight, that call returned without doing anything. Even when the in-flight request doesn't stall, it may have been sent before the reply existed.That fits the request log: the last GET was 2 s before the first POST (the next timer poll was due right then), and there was no GET at all for 99 s.
Fix
CHAT_POLL_TIMEOUT_MS(10 s), the sameAbortControllerpatternchatAskBackenduses. An abort counts as a normal poll failure, so the existing backoff applies.since=<seq>contract is fragile β full replay on every reload, silent loss after a hive restart or >200-message burst, no poll backoff; global channel renders other users' input as the viewer's ownΒ #9135 holds.Base branch
This targets v6.
GET /api/chat/messagesand the polling client exist only on v6; v5 has no shared chat channel.Tests
TestHiveChatPollRecoversFromStalledRequestruns the real poll slice under node. A poll request stalls while!inception resetis accepted, and the test asserts that the request has a bounded abort, that the queued poll then fetchessince=116, thatβ Inception reset.renders, and that the loop goes back to polling every 2 s. It fails on the old code because there is no abort timer.TestHiveChatPollAttributesPeerInputToItsAuthornow expects one request plus one follow-up, instead of one request.β hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88 requested_by=@kanrenibm