fix(site/AgentsPage): suppress unread dot while a chat is streaming#25373
Open
blinkagent[bot] wants to merge 1 commit into
Open
fix(site/AgentsPage): suppress unread dot while a chat is streaming#25373blinkagent[bot] wants to merge 1 commit into
blinkagent[bot] wants to merge 1 commit into
Conversation
The sidebar was painting a per-chat unread indicator at the same time the row spinner was running. That combination implies the agent is waiting on user action, but during running/pending the chat is mid-turn and the user has nothing to act on. The dot also flickered (appear, then vanish) as intermediate status_change events raced the authoritative server value from the next list refetch. Two coordinated fixes: - mergeWatchedChatSummary: do not flip has_unread to true on a status_change event when the new status is running or pending. Existing has_unread is still preserved (so a chat that was already unread before the new turn started keeps its dot until the user opens it). Terminal-ish transitions (waiting / completed / requires_action / error) still mark inactive chats unread. - AgentsSidebar row: gate the visible unread indicator and sr-only unread label on !isStreaming, so any cached has_unread=true is hidden while the row is mid-turn. Defends against the case where the cache carried has_unread=true from before the current turn. Tests cover the four new branches in mergeWatchedChatSummary.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The per-chat unread indicator in the agents sidebar was being painted at the same time the row spinner was running. Two related problems with that:
status_changeevents raced the authoritativehas_unreadvalue computed by the server on the next list refetch.Root cause
Two independent paths converged on this:
mergeWatchedChatSummaryinsite/src/api/queries/chats.tsflippedhas_unread = trueon anystatus_changeevent for a non-active chat, including intermediatepending→runningtransitions during a turn.chat.has_unread && !isActiveChat, regardless of streaming state, so any cachedhas_unread = truewould paint even whilechat.statuswasrunning/pending.The server-side
has_unread(coderd/database/queries/chats.sql) is based on thelast_read_message_idcursor, which is only advanced bymarkChatAsReadincoderd/exp_chats.goon stream connect/disconnect. That part is correct and unchanged.Fix
Two coordinated changes on the client:
mergeWatchedChatSummary: only fliphas_unreadtotrueon astatus_changewhen the new status is notrunning/pending. Existinghas_unreadis preserved (a chat that was already unread before the new turn started keeps its dot until the user opens it). Terminal-ish transitions (waiting,completed,requires_action,error) still mark inactive chats unread.AgentsSidebarrow: gate both the visible unread dot and thesr-only"(unread)" label on!isStreaming. This defends against the case where the cache carriedhas_unread = truefrom before the current turn began.Tests
Four new cases in
chats.test.tsundermergeWatchedChatSummary:runningpendinghas_unread = truewhen transitioning to a streaming statuswaitingExisting test "marks other chats unread on fresh status updates" continues to pass (it transitions to
completed, which is terminal).Requested on behalf of @tracyjohnsonux.