Repository navigation
fix(transcript): exclude disclosure title toggle from reading hold - #1888
Merged
vastsa merged 2 commits intoOct 26, 2026
Merged
Conversation
When clicking a collapsed disclosure header (such as a command or thinking row), focus was placed on the title button. Because reading position protection checked both the title and body elements, focus on the title caused the disclosure to immediately claim a transient reading hold and preemptively expand before click completed. The subsequent click event then read the already-expanded state and toggled it closed, recording an explicit collapsed choice and causing a visible flash-collapse on first click. Exclude titleRef from the level's own reading hold checks so only keyboard focus or text selections inside the expanded body keep the disclosure open. Add a regression test to pin the reading hold scope.
Owner
|
Merged after verifying the root cause with the actual React hook in isolated Chromium: on old main, focusing the untouched collapsed header and then clicking leaves it collapsed ( |
This branch was previously deployed
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.
Problem
When clicking a collapsed transcript disclosure header (such as a shell command or thinking row) to view details, the row momentarily flashes open and immediately collapses back. Clicking it a second time successfully expands it without collapsing.
Cause
In commit 6e6f862 / PR #1808,
useAutomaticDisclosureintroduced transient reading protection viaownsReadingPosition(titleRef.current, bodyRef.current)and a global event hub listening tofocusinandpointerup.When a reader presses the pointer on a collapsed disclosure header
<button ref={titleRef}>:focusin), triggeringsyncReading().titleRef.currentwas passed intoownsReadingPosition,level.contains(document.activeElement)evaluated totrue, settingreading = true.choice === undefined),requestedOpenderived from(derivedOpen || reading)flipped totrue, causing the disclosure body to render and updatingcurrentOpen.current = true.clickevent firedtoggle(), which evaluatedsetManualOpen(!currentOpen.current)->setManualOpen(false). This collapsed the row back and explicitly recorded{ open: false }intochoices.On the second click,
choicewas already{ open: false }, which bypassed the(derivedOpen || reading)branch, allowing the toggle to work normally.Fix
useAutomaticDisclosure, restrictownsReadingandsyncReadingto inspectbodyRef.currentonly. The toggle button (titleRef) controls expansion and is not part of the active reading content. Keyboard focus or text selections inside an ancestor'sbodyRefalready protect the enclosing level.apps/desktop/test/transcript-disclosure-reading.test.mjsverifying reading protection inspectsbodyRef.currentand excludes the toggle title.Verification
node --test apps/desktop/test/transcript-disclosure-reading.test.mjs apps/desktop/test/activity-group-folding.test.mjs apps/desktop/test/thinking-ui.test.mjs apps/desktop/test/transcript-display-modes-ui.test.mjs— 36/36 passpnpm --filter @pi-desktop/desktop typecheck— 0 errorsnode scripts/check-pr-base-main.mjs— passed (HEAD is ahead of origin/main)node scripts/check-agent-policy-sync.mjs— passed