Skip to content

fix(site/src/pages/AgentsPage): skip chat list refetch on diff status events - #32080

Merged
mafredri merged 1 commit into
mainfrom
mafredri/agents-skip-list-refetch-on-diff-status
Nov 12, 2026
Merged

mafredri merged 1 commit into
mainfrom
mafredri/agents-skip-list-refetch-on-diff-status

Conversation

@mafredri

Copy link
Copy Markdown
Member

The chat watch handler refetched every chat list on each root diff_status_change event. On dogfood, one watch socket received 41 of these events in 30 seconds. Each event aborted the chat list requests in flight and started new ones, so most GET /api/v2/chats requests were cancelled before they completed.

The event carries the changed diff status and the handler merges it into the cached rows, so the rows stay current without a refetch. shouldInvalidateFilteredChatList now takes the sidebar filters and asks for a refetch on diff_status_change only under a PR status filter, the one sidebar filter whose membership depends on diff status. status_change and project_change still refetch.

Known limit: every watch event still cancels the list refetches in flight, to protect its cache write. Until now a root diff_status_change then restarted them. It no longer does, so a refetch that another trigger started can be dropped, and the list waits for the next trigger. Child chat and title events already behave this way.

Verified with: the new AgentsPageLayout diff status events tests, which fail when the change is reverted and when the filters are read at mount time, the shouldInvalidateFilteredChatList table, pnpm check and make pre-commit.

Part of CODAGT-1515. Related to CODAGT-1219.

Decision log
  • Client before server. Publishing diff_status_change only when the status changes (CODAGT-1219) would help every open tab at once, but why the events arrive is not established: one chat received 8 in 30 seconds, which a 120 second refresh interval does not explain, and the payloads were not compared. This change holds whatever sends the events.
  • The condition is in shouldInvalidateFilteredChatList, not at its call site, so the predicate and its tests state when a list refetches.
  • The handler reads the filters through useEffectEvent, like activeChatIdForWatch, so the socket effect keeps its dependencies and does not reconnect when filters change.
  • The sidebar filters decide for every list: the sidebar list and the project folder lists send them, and project page lists send no PR status filter. A cached list that is not mounted refetches when it mounts.
  • Not in this PR: skipping the cancel when an event changes no cached row, coalescing refetches from status_change, and the search invalidation, which still runs on each event while a search is open.

🤖 Created with the help of Coder Agents.

… events

The chat watch handler refetched every chat list on each root
diff_status_change event. On dogfood a watch socket received 41 such
events in 30 seconds, and each one aborted the list requests in flight
and started new ones, so most chat list requests never completed.

The event carries the changed diff status and the handler merges it
into the cached rows, so the refetch only matters for lists whose
membership depends on it. Refetch on diff_status_change only when the
sidebar has a PR status filter.

The event still cancels list refetches that are in flight. One started
by something else is no longer restarted by this event.
@linear-code

linear-code Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

CODAGT-1219

CODAGT-1515

@mafredri
mafredri temporarily deployed to main November 12, 2026 11:33 — with GitHub Actions Inactive
@mafredri
mafredri temporarily deployed to main November 12, 2026 11:33 — with GitHub Actions Inactive
@mafredri
mafredri marked this pull request as ready for review November 12, 2026 11:41
@mafredri
mafredri requested a review from a team as a code owner November 12, 2026 11:41
@mafredri
mafredri temporarily deployed to main November 12, 2026 11:41 — with GitHub Actions Inactive
@mafredri

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-12T11:44:35.450736Z f70428a Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@pr-queue-manager
pr-queue-manager Bot requested a review from jakehwll November 12, 2026 11:42
Comment on lines 245 to +246
const activeChatIdForWatch = useEffectEvent(() => agentId);
const sidebarFiltersForWatch = useEffectEvent(() => sidebarFilters);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lmao what the heck are we doing here 😂

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This probably needs a larger cleanup later 😆

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

Reviewed commit: f70428a161

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@mafredri
mafredri merged commit bd4f8c9 into main Nov 12, 2026
54 of 55 checks passed
@mafredri
mafredri deleted the mafredri/agents-skip-list-refetch-on-diff-status branch November 12, 2026 11:56
@mafredri
mafredri temporarily deployed to main November 12, 2026 11:56 — with GitHub Actions Inactive
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 12, 2026

This branch was previously deployed

1 inactive deployment
main — f70428a1 Deployed Nov 12, 2026 by mafredri via cla #254884
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants