Skip to content

fix(ui): keep chat commands visible and preserve reader scroll control - #138140

Merged
steipete merged 3 commits into
mainfrom
codex/refactor-chat-scroll-lifecycle
Sep 4, 2026
Merged

steipete merged 3 commits into
mainfrom
codex/refactor-chat-scroll-lifecycle

Conversation

@steipete

@steipete steipete commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

Related: #138008 (sending could leave the newest message partly hidden), #138004.

Additional instructions

Changes are on the repository-owned codex/refactor-chat-scroll-lifecycle branch.

What Problem This Solves

Fixes cases where submitting a slash command while reading older chat messages left its output offscreen. Locally executed commands, direct /steer and /redirect, and /approve during 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 defaultPrevented false; 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 /help staying 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.

  • 12 reply and submission/takeover cases passed after inlining a one-use Markdown-escaping helper to meet the existing file-size limit. The exact regex/replacement and all scroll logic are unchanged from the successful live proof.
  • 673 focused tests passed across scroll policy, send admission, state, pane lifecycle, transcript ownership, and recovery. After the final detached-approval addition, all six submission/takeover scenarios passed again.
  • All 12 browser scenarios passed again after the keyboard repair, including delayed send acknowledgement, composer/progress resizing, scrolling away during streaming, and latest-button geometry.
  • All selected gates also passed for the keyboard follow-up, with UI types rechecked after the final select fix. Moving the shared fixture into test-helpers kept synthetic strings out of the production translation scan.
  • All selected repository gates passed across the initial check:changed run 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.
  • Fresh independent Codex review of the complete final diff found no actionable P0–P2 issues. Earlier index-only findings were already fixed in the working tree; staging the complete candidate resolved that review mismatch.
  • Live Chromium against an isolated real Gateway and the changed source UI: /help moved from 3,967 pixels above the end to 0; /status moved 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 real chat.send (/status); local /help sent none.
  • This live fixture used a synthetic profile, history, and workspace with provider/channel execution disabled. It verifies command transport, rendering, and scroll behavior; it does not claim model-provider or external-channel proof. Source-mode plugin-catalog loader warnings were present and did not block these flows. The first attempt stopped on an ambiguous test locator; an exact observed heading fixed the harness, and the rerun passed.

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 leaving defaultPrevented=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:48 uses JSON.stringify(fixture) only to create a Vitest case name. The module is imported solely by chat-pane-keyboard-focus.test.ts and chat-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 /help but left the transcript 4,087 pixels above its output.

Before: help accepted but output remains below the viewport

After: the fixed source reaches the true end while retaining space for the progress card and composer.

After: help output reaches the true transcript end

A real /status reply also remains visible after simultaneous composer shrink and progress expansion.

Real status reply remains visible after layout changes

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 1

Production 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.inject call, 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.

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.
@steipete steipete self-assigned this Sep 4, 2026
@clawsweeper

clawsweeper Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@steipete
steipete marked this pull request as ready for review September 4, 2026 09:33
@steipete

steipete commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper review

@clawsweeper

clawsweeper Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 4, 2026
@clawsweeper

clawsweeper Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 4, 2026, 6:55 AM ET / 10:55 UTC.

ClawSweeper review

What this changes

The 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 provenance

Possible 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
Reviewed head: 916c387ec5dcdb79c9983b8bb78041948fb10b3c

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) Strong final-head browser evidence and focused owner-boundary coverage support a clean, necessary repair.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The changed production owners are the submission path, shared scroll scheduler, and transcript virtualizer; supplied final-head isolated-Gateway Chromium evidence exercises command admission, reader takeover, layout changes, and native media keyboard controls with observed after-fix behavior.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The changed production owners are the submission path, shared scroll scheduler, and transcript virtualizer; supplied final-head isolated-Gateway Chromium evidence exercises command admission, reader takeover, layout changes, and native media keyboard controls with observed after-fix behavior.
Evidence reviewed 7 items Shared scroll owner: The new scheduler owns both post-commit cleanup and queued animation-frame cancellation, while retaining manual requests across incidental automatic requests.
Command admission coverage: Detached approval, queued local commands, and direct steer/redirect commands now request the same manual scroll behavior before their asynchronous delivery or dispatch work.
Shared native-key boundary: Both virtualizer interruption and older-history loading use one classifier, so a native control cannot cancel restoration while still triggering history loading.
Findings None None.
Security None None.

How this fits together

Control 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]
Loading

Before merge

  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.
Agent review details

Security

None.

PR surface

Source +85, Tests +302, Docs 0. Total +387 across 19 files.

View PR surface stats
Area Files Added Removed Net
Source 7 199 114 +85
Tests 11 470 168 +302
Docs 1 1 1 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 19 670 283 +387

Review metrics

Metric Value Why it matters
Production versus test delta production +199/-114 (net +85); tests/support +470/-168 (net +302); docs +1/-1 The production growth replaces separate lifecycle fields with the shared cancellation and native-key ownership boundaries; the remainder is behavior coverage and moved test support.

Stored data model

Persistent data-model change detected: serialized state: ui/src/pages/chat/test-helpers/chat-scroll-input.ts, unknown-data-model-change: ui/src/pages/chat/test-helpers/chat-scroll-input.ts. Confirm migration or upgrade compatibility proof before merge.

Technical review

Best 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.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The changed production owners are the submission path, shared scroll scheduler, and transcript virtualizer; supplied final-head isolated-Gateway Chromium evidence exercises command admission, reader takeover, layout changes, and native media keyboard controls with observed after-fix behavior.
  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The changed production owners are the submission path, shared scroll scheduler, and transcript virtualizer; supplied final-head isolated-Gateway Chromium evidence exercises command admission, reader takeover, layout changes, and native media keyboard controls with observed after-fix behavior.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: The PR fixes a bounded but user-visible Control UI transcript navigation and command-output usability defect.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The changed production owners are the submission path, shared scroll scheduler, and transcript virtualizer; supplied final-head isolated-Gateway Chromium evidence exercises command admission, reader takeover, layout changes, and native media keyboard controls with observed after-fix behavior.
  • proof: sufficient: Contributor real behavior proof is sufficient. The changed production owners are the submission path, shared scroll scheduler, and transcript virtualizer; supplied final-head isolated-Gateway Chromium evidence exercises command admission, reader takeover, layout changes, and native media keyboard controls with observed after-fix behavior.

Evidence

What I checked:

  • Shared scroll owner: The new scheduler owns both post-commit cleanup and queued animation-frame cancellation, while retaining manual requests across incidental automatic requests. (ui/src/pages/chat/scroll.ts:181, 916c387ec5dc)
  • Command admission coverage: Detached approval, queued local commands, and direct steer/redirect commands now request the same manual scroll behavior before their asynchronous delivery or dispatch work. (ui/src/pages/chat/chat-send-submit.ts:331, 916c387ec5dc)
  • Shared native-key boundary: Both virtualizer interruption and older-history loading use one classifier, so a native control cannot cancel restoration while still triggering history loading. (ui/src/pages/chat/chat-scroll-input.ts:5, 916c387ec5dc)
  • Current-main necessity: Current main still sends detached approval and queued local commands without a manual scroll request, and its virtualizer treats every listed navigation key as reader takeover. (ui/src/pages/chat/chat-send-submit.ts:330, e0c97ac015d9)
  • Behavior regressions: Focused tests cover cancellation before and after commit plus all six pending-delivery command cases, including reader takeover after admission. (ui/src/pages/chat/chat-send.test.ts:3021, 916c387ec5dc)
  • Final-head real behavior proof: The supplied PR evidence reports isolated real-Gateway Chromium runs on the final source: command output reaches the transcript end, later reader takeover remains preserved, and real native audio/video controls retain their keyboard ownership. (916c387ec5dc)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (2 earlier review cycles)
  • reviewed 2026-09-04T09:44:00.847Z sha b276532 :: blocked before merge. :: [P1] Exclude native caret keys from transcript scroll ownership
  • reviewed 2026-09-04T10:31:36.339Z sha 8d32928 :: needs real behavior proof before merge. :: [P2] Exclude native media controls from transcript 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.
@clawsweeper clawsweeper Bot added status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 4, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 4, 2026
@steipete
steipete merged commit c9dc71e into main Sep 4, 2026
235 of 239 checks passed
@steipete
steipete deleted the codex/refactor-chat-scroll-lifecycle branch September 4, 2026 11:17
@steipete

steipete commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 5, 2026
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant