Skip to content

fix(site/src/pages/AgentsPage/components/ChatConversation): move focus the turn's fold removes to its summary - #31138

Closed
ibetitsmike wants to merge 4 commits into
mike/working-block-collapse-finished-turnsfrom
mike/working-block-fold-focus
Closed

ibetitsmike wants to merge 4 commits into
mike/working-block-collapse-finished-turnsfrom
mike/working-block-fold-focus

Conversation

@ibetitsmike

@ibetitsmike ibetitsmike commented Oct 21, 2026 •

Copy link
Copy Markdown
Collaborator

Stacked on #31025, which folds each finished turn into one Working block that starts collapsed.

When a turn ends, its fold takes in the turn's earlier blocks and the text between its steps and collapses, so whatever the reader had focused there unmounts and focus falls to the page body. A keyboard or screen reader user loses their place. This happens when the reader had focused a control in an expanded earlier block, a link in text between steps, a control in the turn's last block, or the summary of a block that only the stream had when the turn ended.

Focus now moves to the summary of the fold that holds what the reader had focused. Focus that survives the fold, and focus lost while a turn runs, is left alone.

Review notes
  • FoldFocusRestorer is a class component because only getSnapshotBeforeUpdate sees the focused element before React commits the fold; a layout effect runs after the element is gone.
  • It finds the focused element's scroller item through data-message-id and focuses the first ended-turn block whose persisted message IDs include one of that item's. A block that only the stream had has no persisted rows; its content persists as messages newer than any rendered before, so it matches the fold that holds one of those.
  • This is the follow-up feat(site/src): fold each finished turn into one Working block #31025 defers, split in two to keep each PR under 500 changed lines: keeping an open lightbox through the fold follows in fix(site/src/pages/AgentsPage/components): keep an open lightbox through the turn's fold #31139.
  • On d323d2b9deb: frontend-deep-review passes all eight roles after three rounds, the test audit passes, and frontend-review FE1 to FE10 pass. The pre-commit hook, the unit tests in src/pages/AgentsPage, src/vendor, and src/testHelpers (the only failures are in ProjectChatsList.test.tsx, which fails the same way without this PR), and the ChatConversation story tests pass. Each case of the new test fails without the restorer, and the stream-only case also fails without the newer-rows match.

Xum opened this PR on behalf of @ibetitsmike.

…s the turn's fold removes to its summary

When a turn ends, its fold starts collapsed and takes in the turn's
earlier blocks and the text between them. A control focused there
unmounted, and focus fell to the page body.

FoldFocusRestorer now focuses the summary of the fold that holds the
focused item's rows. A block that only the stream had has no persisted
rows yet, so it matches the rows that the stream persisted as the turn
ended.
… newest row only once focus is lost

FoldFocusRestorer's snapshot runs on every timeline render while focus
sits in the timeline, including each streamed chunk, but it needs the
newest rendered row only when focus is lost from the live row. It now
reads that row from the previous props in componentDidUpdate.
@ibetitsmike
ibetitsmike added this pull request to stack #31026 October 21, 2026 19:00
@ibetitsmike ibetitsmike changed the title mike/working block fold focus fix(site/src/pages/AgentsPage/components/ChatConversation): move focus the turn's fold removes to its summary Oct 21, 2026
@linear-code

linear-code Bot commented Oct 26, 2026

Copy link
Copy Markdown

CODAGT-1114

@ibetitsmike
ibetitsmike removed this pull request from stack #31026 October 27, 2026 18:58
@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

Folded into #30656: its single commit, rebased onto main, now carries this change, so review continues there.

Xum closed this PR on behalf of @ibetitsmike.

@github-actions github-actions Bot locked and limited conversation to collaborators Oct 27, 2026
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.

1 participant