Repository navigation
fix(ui): keep chat commands visible and preserve reader scroll control - #138140
Conversation
Unify pending scroll cancellation across render completion and animation frames. Give local, steer, redirect, and detached approval submissions the same explicit jump as ordinary sends, while delayed replies preserve later reader takeover. Share native-key ownership between transcript restoration and older-history loading. Replace scheduler field assertions with behavior regressions and remove redundant scroll state and test scaffolding. Verified with failing/passing regressions, focused/browser tests, and an isolated real Gateway before/after flow with synthetic conversation data.
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
@clawsweeper review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Codex review: blocked before merge. Reviewed September 4, 2026, 6:55 AM ET / 10:55 UTC. ClawSweeper reviewWhat this changesThe PR centralizes Control UI chat-scroll scheduling, scrolls to command output on admission, and prevents native controls and nested scrollports from taking transcript scroll ownership. Regression provenancePossible regression — probable (reproduction; reviewed change). No predecessor PR is attributed. Merge readiness⛔ Blocked before merge - 1 item remains No blocking findings. This PR remains necessary because current main still lacks manual scroll admission for several command paths and treats native control keys as transcript input; the final head addresses both at their shared owners with sufficient real-browser evidence. Priority: P2 Review scores
Verification
How this fits togetherControl UI Chat renders Gateway-backed conversation history and sends commands through the chat submission path. Its transcript virtualizer controls latest-message following while preserving a reader’s intentional scroll position. flowchart LR
Input[Reader or command input] --> Submit[Chat submission]
Submit --> Scheduler[Scroll scheduler]
Controls[Native controls and nested scrollports] --> KeyCheck[Key ownership check]
KeyCheck --> Transcript[Transcript virtualizer]
Scheduler --> Transcript
Transcript --> Viewport[Visible latest output]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +85, Tests +302, Docs 0. Total +387 across 19 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Technical reviewBest possible solution: Keep one cancellable scheduler for scroll lifecycle and one control-ownership classifier shared by transcript restoration and history loading. Do we have a high-confidence way to reproduce the issue? Yes—current main visibly omits the relevant command scroll admissions and uses blanket key handling; the supplied real-Gateway baseline also reports the command-output failure before the fix. Is this the best way to solve the issue? Yes—the shared scheduler and shared key classifier repair the ownership boundaries directly, avoiding command-specific delayed-scroll workarounds or separate consumer filters. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against e0c97ac015d9. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (2 earlier review cycles) |
Keep caret and selection keys with their native controls. Preserve native paging and hand it to the transcript only after nested scrollports reach their directional edge. Share the platform and geometry regressions across restoration and history loading.
|
Merged via squash.
|
openclaw#138140) * fix(ui): keep chat commands visible and preserve reader scroll control Unify pending scroll cancellation across render completion and animation frames. Give local, steer, redirect, and detached approval submissions the same explicit jump as ordinary sends, while delayed replies preserve later reader takeover. Share native-key ownership between transcript restoration and older-history loading. Replace scheduler field assertions with behavior regressions and remove redundant scroll state and test scaffolding. Verified with failing/passing regressions, focused/browser tests, and an isolated real Gateway before/after flow with synthetic conversation data. * fix(ui): respect native editing and nested scroll ownership Keep caret and selection keys with their native controls. Preserve native paging and hand it to the transcript only after nested scrollports reach their directional edge. Share the platform and geometry regressions across restoration and history loading. * fix(ui): preserve native media keyboard ownership
Related: #138008 (sending could leave the newest message partly hidden), #138004.
Additional instructions
Changes are on the repository-owned
codex/refactor-chat-scroll-lifecyclebranch.What Problem This Solves
Fixes cases where submitting a slash command while reading older chat messages left its output offscreen. Locally executed commands, direct
/steerand/redirect, and/approveduring an active run bypassed the normal send scroll request. Keys consumed by transcript controls could also cancel saved-position restoration or trigger an unwanted older-history request.The broader review of the original send fix found that cancelling a render could leave manual-scroll priority stuck, or leave its already-queued animation frame alive.
Why This Change Was Made
A single cancellable scroll request now owns render completion, frame scheduling, and manual priority. It replaces the page's separate frame ID, generation counter, commit cleanup, and manual-request set. Explicit transcript submissions request their jump when admitted; delayed replies continue to respect subsequent reader input.
The transcript virtualizer and history loader share one native-key ownership check. It distinguishes native editing and selection from transcript navigation, including shadow-root controls. Native paging stays inside a nested editor until its directional edge, then yields to the transcript. macOS and non-macOS Home/End bindings retain their different behavior, and plain PageUp/PageDown from single-line inputs still scrolls the transcript. Native video/audio controls retain playback, volume, and seeking keys even when the browser leaves
defaultPreventedfalse; PageUp/PageDown still yields to the transcript. The virtualizer retains ownership of geometry, restoration, and smooth-scroll cancellation. Approval authority and command transport are unchanged.User Impact
Sending ordinary messages or transcript commands returns to the latest output even after scrolling into history. Scrolling away afterward remains effective when a reply arrives. Using a text field, range control, select, or media control no longer masquerades as a transcript scroll for the covered keys.
Evidence
Exact-head CI run33864859170 is green for
916c387ec5dcdb79c9983b8bb78041948fb10b3c(attempt2). Every code/UI/browser lane passed on attempt1; only the production dependency audit exhausted four npm advisory-request timeouts. Rerunning failed jobs completed the audit and aggregate gate successfully, with the patch unchanged.Before-fix regressions reproduced two render-cancellation failures, four missing command-admission jumps, nine control-key restoration failures, and three unintended history requests. Positive ordinary-send, real-keyboard-navigation, and restoration cases remained covered. A separate real-Gateway baseline using the old submission owner reproduced
/helpstaying at scrollTop 0, 4,087 pixels above the output; the fixed source reached distance 0. The attached before/after captures contain only synthetic profile and conversation data.test-helperskept synthetic strings out of the production translation scan.check:changedrun and targeted completion: core/UI types, policy/dependency checks, all dead-export scans, formatting, changed-file lint, and style checks. Initial lint caught a three-line file-limit overage; inlining the one-use wrapper resolved it, and final format/UI types plus every remaining lint/style batch passed./helpmoved from 3,967 pixels above the end to 0;/statusmoved from 6,175 to 3 while the composer shrank from 156 to 36 pixels and the progress card expanded. After reader takeover, a later injected reply preserved scrollTop exactly at 5,636; Latest returned to 0 pixels from the end. The browser sent exactly one realchat.send(/status); local/helpsent none.Review follow-through
Addressed the platform/selection review and the latest native-media finding and Rank-up moves at the shared keyboard owner. On the earlier PR head, 32 restoration cases and 16 older-history cases failed for platform/modifier editing or paging within an editor. The expanded shared table now passes 124 restoration/history/focus tests, including single-line input paging and both nested-scroll edges. Four additional single-line paging cases and four collapsed-select Ctrl+Home/End cases failed during repair before their native forwarding was restored.
A live macOS Chromium 151 probe uses actual focused controls and Playwright keyboard input, checking editing/selection ownership and outer scrolling. Caret-reveal scrolling remains editor-owned. All 56 final-source cases pass, covering input, textarea, contenteditable, collapsed select, selection modifiers, and nested-editor edge chaining. Browser binding interpretation was checked against Chromium editing commands and page movement implementation, rather than assuming every Home/End event scrolls.
The final Linux native-browser comparison used Blacksmith Testbox
tbx_01m1nygym6m973r8rn14php0qf, managed Chromium 151, and the exact final classifier source. The earlier PR helper failed 44 of 56 cases; the final source passed all 56. The wrapper reported exit 0 and the retained lease was stopped after verification. An initial worker lacked Chromium; the repository's standard browser installer resolved that setup failure. Native Windows browser execution was not run.The native-media follow-up reproduced the reported
<video controls>defect with playable synthetic media and actual Chromium keyboard input. Video and audio hosts consume Space, ArrowUp/Down, Home/End, and Ctrl/Shift+Home/End while leavingdefaultPrevented=false; PageUp/Down genuinely scrolls the transcript. The shared owner now distinguishes those actions. Its new cases failed before the change: 18 restoration failures and eight unwanted-history failures. The final focused run passes 180 tests: 106 restoration cases, 50 history/focus cases, and 24 existing audio/video component cases.A 104-case native-media probe covered both host focus and tab-focused browser play/seek/volume controls; the 78 native-subcontrol cases keep their events inside the browser shadow tree. Another 26 cases confirmed host behavior without an explicit tabindex, matching the production video markup. The final-source 26-case rerun preserves playback, seeking, and volume while correctly classifying every event: owned keys keep outer scrollTop 800; PageUp/PageDown moves it to 340/1,260. This contract also matches Chromium's native media event handler. Media proof ran on macOS Chromium; the preceding Linux proof covers the unchanged non-media paths. No player transport or controls were replaced.
The final-head review accepts the real-browser evidence and reports no actionable findings. Its remaining data-model compatibility flag is not applicable:
ui/src/pages/chat/test-helpers/chat-scroll-input.ts:48usesJSON.stringify(fixture)only to create a Vitest case name. The module is imported solely bychat-pane-keyboard-focus.test.tsandchat-transcript-scroll-ownership.test.ts. It does not read or write stored state. This PR changes no SQLite schema, serialized representation, persistence API, or migration; the removed page fields and replacement WeakMap are ephemeral UI scheduling state. No upgrade migration is needed.Live before/after screenshots (synthetic data)
Before: the old submission owner accepted
/helpbut left the transcript 4,087 pixels above its output.After: the fixed source reaches the true end while retaining space for the progress card and composer.
A real
/statusreply also remains visible after simultaneous composer shrink and progress expansion.Focused validation commands
node scripts/run-vitest.mjs ui/src/pages/chat/scroll.test.ts ui/src/pages/chat/chat-send.test.ts ui/src/pages/chat/chat-send-submit.test.ts ui/src/pages/chat/chat-state.test.ts ui/src/pages/chat/chat-pane-lifecycle.test.ts ui/src/pages/chat/chat-pane-keyboard-focus.test.ts ui/src/pages/chat/components/chat-transcript-controller.test.ts ui/src/pages/chat/components/chat-transcript-scroll-ownership.test.ts ui/src/pages/chat/components/chat-transcript-recovery.test.ts node scripts/run-vitest.mjs ui/src/pages/chat/chat-pane-keyboard-focus.test.ts node scripts/run-vitest.mjs run --config test/vitest/vitest.ui.config.ts --configLoader runner ui/src/pages/chat/components/chat-transcript-scroll-ownership.test.ts ui/src/pages/chat/components/chat-video-player.test.ts ui/src/pages/chat/components/chat-audio-player.test.ts node scripts/run-vitest.mjs ui/src/pages/chat/chat-send.test.ts -t 'preserves reader ownership across pending delivery' node scripts/run-vitest.mjs run --config test/vitest/vitest.ui-e2e.config.ts --configLoader runner ui/src/e2e/chat-scroll.e2e.test.ts ui/src/e2e/chat-flow.streaming.e2e.test.ts --maxWorkers 1Production LOC: +199/-114 (net +85); tests/support: +470/-168 (net +302); docs: +1/-1. The scheduler refactor is net-neutral including removed page fields. Growth supplies the shared native-key ownership contract, directional nested-scroll ownership, and missing command-admission calls. Keeping the old blanket key filter or excluding every native control would violate the reproduced browser behavior; geometry remains with the virtualizer. The transcript tests reuse their moved mount fixture; obsolete scheduler-field assertions, unused test scaffolding, and a one-use escaping wrapper were removed.
Provenance: the manual-priority cancellation gap follows #138008's verified parent-relative patch. Missing command jumps and indiscriminate keyboard cancellation are also present in stable
v2026.8.2; their original introducing commits were not established. Keyboard ownership was further repaired during review after focused tests and native browser probes exposed modifier, platform, and nested-scroll distinctions.Named follow-up — injected-reply identity: the live fixture made one later
chat.injectcall, but its final bubble displayed×2. The trace contains both the expected session-message and chat-final events; raw envelopes and database row counts were not retained, so this is a duplicate-display observation, not a claim of duplicated storage. Investigate joining the injected final with its durable transcript identity separately. Scroll-position assertions passed independently of that count.