Repository navigation
fix(threads): read an already-open thread when Activity opens it #1524
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
jrobotham-square
merged 8 commits into
block:main
from
joelrobotham:fix/activity-thread-focus
Oct 25, 2026
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
4757cc7
fix(threads): read an already-open thread when Activity opens it
joelrobotham 1a338ce
fix(threads): leave focus alone when it is on a tab
joelrobotham 0ae40bb
fix(threads): leave a thread's first opening to its tab
joelrobotham 1bec785
test(threads): make the already-open Activity test say why it failed
joelrobotham 5809530
fix(threads): keep focus in a thread opened from Activity
joelrobotham 89bf94c
test(threads): keep focus moved during an Activity reopening
joelrobotham d458d7d
test(github): let each PR video finish instead of racing its Pause
joelrobotham 329a260
Merge remote-tracking branch 'origin/main' into fix/activity-thread-f…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤖 [P2] Preserve newer focus intent while the retained thread retargets
Reopening an already-open thread from Activity waits for RetainedThreadPanel's async view.retarget() before this effect receives the new navigation. If the user clicks into the channel composer and starts typing while the root/overlay reads are pending, this guard accepts that newer focus and moves it into the thread scroller when the reads finish, interrupting typing. I reproduced this with an explicitly gated root read in both Chromium and WebKit; the same scenario passes with only this new effect removed. Capture the opening focus intent before awaiting retarget and expire the handoff on subsequent pointer/keyboard input, following the existing usePendingRequest policy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, reproduced and fixed in 5809530, with a regression test in 89bf94c.
Test (
thread-unread.spec.mjs, "an Activity reopening leaves focus the person moved meanwhile"): it holds relay reads, opens the already-open thread from Activity, and types in the channel composer while the reads are held. After the reads are released and navigation reportsopened, it checks that the composer still has focus and still contains the text.Fix: the handoff now moves focus into the thread only when nothing holds focus (
activeElementisbody). That is the state an Activity row leaves behind when the popover unmounts it. Focus the person placed anywhere else is no longer taken, whether during a pending retarget like here or just after a first opening whose routed request arrives late. The late-request case was also breakingnavigation-thread-history:20in WebKit under load.Same commit: the Activity popover no longer returns focus to its sidebar trigger after a thread row opens a thread. That uses the
finalFocus={() => !handoff.current}pattern fromProfileButton. Base UI's return-focus microtask could run after the thread took focus and steal it, which caused the intermittent CI failure of the Activity test.Not done: expiring the handoff on pointer/keyboard input the way
usePendingRequestdoes. With thebody-only rule, that would add just one case: a click on a non-focusable area during the reads. That leaves nothing focused, so the thread that was asked for takes focus. Covering it properly means starting the listener beforeretargetand passing the result down. Happy to add it if you think that case matters.