Skip to content

fix(site): own manual chat read mutations per row - #30301

Open
jakehwll wants to merge 2 commits into
jakehwll/agents-per-surface-pinfrom
jakehwll/agents-per-surface-read-state
Open

jakehwll wants to merge 2 commits into
jakehwll/agents-per-surface-pinfrom
jakehwll/agents-per-surface-read-state

Conversation

@jakehwll

@jakehwll jakehwll commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

🤖 This PR was written by Coder Agents on behalf of Jake Howell.

Depends on #30300. Part 3 of 3 in the per-surface chat mutation stack: #30276 → #30299 → #30300 → this PR.

Move manual mark-as-read/unread mutations into sidebar rows and remove their layout-owned callbacks. Keep automatic active-chat read synchronization in the layout. Pending state follows each chat across row remounts, disables only that chat’s read toggle, and leaves other chats actionable.

Read-filter projection now retains cached roots for optimistic rollback. A failed mutation restores only the target’s read flag on still-existing cache entries, preserving other pending chats and newer responses; list refetch waits for the last pending read mutation.

Reviewer context

Coverage exercises read-filter unmount/remount, same-chat blocking, concurrent different-chat mutations, rollback without resurrecting removed rows, and hiding the active chat’s manual toggle. The pending-state Storybook story was visually checked. The combined stack passed the full pre-push Go and frontend suites and production site build; affected validation also passed 308 unit tests and 91 Storybook tests.

@jakehwll
jakehwll added this pull request to stack #30302 October 2, 2026 21:54
@jakehwll
jakehwll marked this pull request as ready for review October 2, 2026 22:15
@jakehwll
jakehwll requested a review from a team as a code owner October 2, 2026 22:15
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-02T22:19:40.972438Z ec3b249 Draft marked ready
ℹ️ 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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ec3b24945b

ℹ️ 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".

Comment on lines +1838 to +1840
queryClient.isMutating({ mutationKey: chatReadStateMutationKey }) <= 1
) {
await invalidateChatListQueries(queryClient);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Invalidate after concurrently settling read mutations

When two read-state requests finish concurrently, both onSettled callbacks can observe an active count of 2 and skip invalidation, so no callback performs the promised final refetch. TanStack Query keeps each mutation pending until its onSettled promise returns, dispatching success only afterward (v5.82.0 source), which makes this race possible. In a paginated read/unread filter, the retained optimistic rows then leave server offsets shifted and later fetchNextPage calls can permanently skip chats until another external refetch occurs.

Useful? React with 👍 / 👎.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant