Skip to content

fix(composer): reserve the scrollbar gutter under the paste chip mirror - #15511

Merged
iamwhatever merged 1 commit into
kirodotdev:mainfrom
Pearcekieser:fix/paste-chip-scroll-desync
Oct 9, 2026
Merged

iamwhatever merged 1 commit into
kirodotdev:mainfrom
Pearcekieser:fix/paste-chip-scroll-desync

Conversation

@Pearcekieser

@Pearcekieser Pearcekieser commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: Keep the collapsed paste chip's highlight on its token when the composer draft is long enough to show a scrollbar.

Once a draft overflows, the chip background is painted one line away from the [ Paste #N · … ] token: it covers the line above, and the token's own line shows no highlight.

Why it matters

Anyone who pastes into a long draft on a platform with classic scrollbars (Chromium on Linux or Windows) sees a floating highlight detached from the text it belongs to. The composer looks broken, and it is unclear which text is the collapsed paste.

Not a goal

What changed (motivation → approach → change)

The chip is painted by a mirror <div> behind the <textarea>, and the two must wrap text at the same width. When the draft overflows, the textarea draws the 6px scrollbar from index.css; the mirror is overflow: hidden and never does. The textarea's text box is then 6px narrower, so a line ending near the right edge wraps there and not in the mirror, and every later chip is painted a line off.

website/src/components/ChatInput.tsx and website/src/components/PasteHighlightLayer.tsx both set [scrollbar-gutter:stable]. Each box reserves the same gutter whether or not a scrollbar is drawn, so both wrap at the same width. The textarea's comment in ChatInput.tsx says why the gutter is load-bearing and names the spec that pins it.

The composer sizes itself by measuring an off-screen twin textarea (website/src/components/chat-input/sizing.ts). The twin copies the textarea's border-box width, which does not show a reserved gutter, so scrollbarGutter joins the copied properties. Without it the twin would wrap 6px wider and could measure a draft one line short, leaving the textarea scrolling below its height cap.

Backwards compatibility

Compatible: a CSS class on two elements. No prop, API or stored data changes.

Tests

website/playwright/composer-paste-highlight-scrollbar.spec.ts launches Chromium with classic scrollbars and holds two cases:

  • The textarea and the chip mirror have equal clientWidth once the textarea scrolls. On main they differ by 6px.
  • The autosize twin and the textarea have equal clientWidth for a short draft. Without the sizing.ts change they differ by 6px (738 vs 744).

test/test_playwright_e2e.py: MIN_EXECUTED_SPECS raised from 239 to 241 for the two new tests; the floor counts executed tests.

Manual verification

Ran both paste-highlight spec files (6 tests) against an isolated gateway serving this branch's built dist: all pass. The before/after captures below come from the same rig.

Screenshots / video

Before: the chip background sits on the wrapped line and hides the token.

Before: chip highlight drawn one line above its token

After: the chip background covers [ Paste #1 · 8 lines ].

After: chip highlight on its token

Related Issues

Related: #8309

Fixes #15510

Pattern harvest

Not generalizable: the textarea-plus-mirror pair is the only overlay in the app that has to match another box's text wrapping, and #8309 plans to remove it.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

@Pearcekieser
Pearcekieser requested a review from a team September 30, 2026 17:51
@Pearcekieser
Pearcekieser requested a review from a team as a code owner September 30, 2026 17:51
@Pearcekieser

Copy link
Copy Markdown
Contributor Author

Intent: Keep the collapsed paste chip highlight on its token when the composer textarea shows a scrollbar, by making the textarea and its mirror wrap at the same width.
Not a goal: Replacing the textarea-plus-mirror design with inline editor nodes (#8309), or changing how the chip looks.

@github-actions github-actions Bot added fork Pull request from a fork (external contributor) readiness: checking Automated validation is still running labels Sep 30, 2026
@github-actions

github-actions Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5, fork) — ✅ PASS

Premise-level review of 9fc409b4452ce912c3578361e5108b9f81854922 via the fork AI-review pipeline — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

First-Principles-Verdict: PASS

The composer's text box is now 6px narrower for every draft, short ones included, on classic-scrollbar platforms. A human should confirm that permanent narrowing is acceptable.

What this change ships

Inventory (5 items) — 5 justified

Intent: keep a long draft's collapsed-paste highlight on its own token line when the composer shows a scrollbar. This is a FIX (#15510, and a Playwright case that fails on base).

  1. The paste chip highlight now stays on its [ Paste #N · … ] line once the draft scrolls — justified
  2. The composer textarea now always keeps a scrollbar-width gutter, so text wraps 6px earlier even on short drafts (Chromium classic scrollbars) — justified
  3. Auto-grow measures the same narrower width, so a draft no longer comes up one line short and scrolls below the height cap — justified
  4. Two new browser tests run with real scrollbars, and the executed-spec floor goes from 239 to 241 — justified
  5. Before/after screenshots committed under temp-screenshots/ (the convention .gitignore:116 documents) — justified

[FIRST-PRINCIPLES-REVIEWED] 9fc409b

Description read

[DESCRIPTION-READ] 7d81c43072d1342a327174b352fd8f6e01a5ae728c61157e3b030535f5f2c301

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5, fork) — 🟡 CONCERNS

UX-level review of 9fc409b4452ce912c3578361e5108b9f81854922 via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

UX-Verdict: CONCERNS

No first-time reader has looked at the repaired paste chip. The before/after captures show it, and the fix itself looks right.

Watch

  • The highlight is faint in the after capture. In after.png (attachment-01) the chip background behind [ Paste #1 · 8 lines ] is a pale wash. In before.png (attachment-02) the misplaced block is clearly purple. The text drawn over it probably accounts for the difference, but someone should check the chip still reads as one highlighted unit in the light theme. If it doesn't, people still won't be able to tell which text is the collapsed paste, which is the problem this PR exists to fix. Severity: low. It shows on every paste into a long draft, but it doesn't stop the task; it only makes the paste harder to spot.
  • Only the scrolling state is shown. [scrollbar-gutter:stable] now leaves a 6px strip empty on the right of the composer even for a short draft with no scrollbar. Nothing shows that case. Severity: low. It's 6px on a wide box and costs nothing in function, but one short-draft capture would rule out a visible empty strip next to the send button.

[UX-REVIEWED] 9fc409b

Description read

[DESCRIPTION-READ] 824da8397bf612ad4bc8ad15789b24e2f1878780725cf6d60eee5e06df7b6fde

That sha256 names everything this verdict read: the PR description, plus the 5 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review (fork) — ✅ no blocking findings

Reviewed 9fc409b4452ce912c3578361e5108b9f81854922 via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 9fc409b

@github-actions

github-actions Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5, fork) — ✅ PASS

Design-level review of 9fc409b4452ce912c3578361e5108b9f81854922 via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: PASS

The textarea now always keeps a 6px scrollbar gutter, even for a short draft. Check that the narrower text area still looks right next to the composer's controls.

[DESIGN-REVIEWED] 9fc409b

Description read

[DESCRIPTION-READ] 914e6c5417b01366c35cc21fd6da4523ab8388c3f596bc3503393859b2293051

That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review (fork) — ✅ no blocking findings

Reviewed 9fc409b4452ce912c3578361e5108b9f81854922 via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 9fc409b

@Pearcekieser
Pearcekieser force-pushed the fix/paste-chip-scroll-desync branch from 4fca8d8 to c8c3a46 Compare September 30, 2026 20:22
@Pearcekieser

Copy link
Copy Markdown
Contributor Author
  • rebutted: committed before/after PNGs ride along

The PNGs under temp-screenshots/paste-chip-scrollbar/ are the PR's screenshot evidence, not part of the fix. This is a fork PR: gh pr edit --attach returns 404 without write access, and the template and .gitignore name committing under temp-screenshots/ as the fork-contributor path.
The maintainer can drop them from the tip after merge, as the template describes.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

self-added: yes
mechanism: autosize twin copies scrollbarGutter from the live textarea

  • fixed: autosize twin wraps 6px wider than the gutter-reserving textarea

Fixed in c8c3a46: website/src/components/chat-input/sizing.ts adds scrollbarGutter to the properties the measuring twin copies, so it reserves the same gutter as the live textarea.
A second case in composer-paste-highlight-scrollbar.spec.ts asserts the twin and the textarea have equal clientWidth; without the change it reads 738 vs 744.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author
  • rebutted: committed before/after PNGs ride along

The PNGs under temp-screenshots/paste-chip-scrollbar/ are the PR's screenshot evidence, not part of the fix. This is a fork PR: gh pr edit --attach returns 404 without write access, and the template and .gitignore name committing under temp-screenshots/ as the fork-contributor path.
The maintainer can drop them from the tip after merge, as the template describes.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

The one red on c8c3a46 is Backend Tests (3.12, 4): test/test_design_tweak_relay_paths.py::TestRelayWsPump::test_pump_forwards_and_exits_on_close timed out, with 18,493 passing on the same shard. This PR does not touch the design-tweak relay; its only backend edit is the MIN_EXECUTED_SPECS constant. The test passes locally on this head in 1.1s, so it looks like a runner-timing flake.

As a fork contributor I cannot re-run jobs. Could a maintainer re-run the failed job in run 36772166017? Every other check and every review lane on this head is green.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Sep 30, 2026
@Pearcekieser
Pearcekieser force-pushed the fix/paste-chip-scroll-desync branch from c8c3a46 to 2541672 Compare September 30, 2026 23:34
@Pearcekieser

Copy link
Copy Markdown
Contributor Author

Rebased: main moved 14 commits since c8c3a46 went through CI (3ecea02 -> 2a51d42). Clean rebase, no code change; CI re-running on 2541672, which also re-runs the backend shard that hit the relay-test timeout.

@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Sep 30, 2026
@Pearcekieser
Pearcekieser force-pushed the fix/paste-chip-scroll-desync branch from 2541672 to 9b740e7 Compare October 1, 2026 00:45
@Pearcekieser

Copy link
Copy Markdown
Contributor Author

Rebased: main moved in website/src/components/ChatInput.tsx (and nearby chat-input files) since 2541672 went through CI (2a51d42 -> 1e3885a). Clean rebase, no code change; CI re-running on 9b740e7. Every review lane on 2541672 was clean; its one red was an unrelated Windows flake in test/test_subprocess_pool.py.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Oct 1, 2026
@Pearcekieser
Pearcekieser force-pushed the fix/paste-chip-scroll-desync branch from 9b740e7 to 26b40ab Compare October 1, 2026 14:00
@Pearcekieser

Copy link
Copy Markdown
Contributor Author

Rebased onto current main with no code change; git range-diff shows the commit is identical. This push also reruns CI. On the previous head, the only test failure was in Backend Tests (Windows) shard 2: two alias lock-file sweep tests in test/test_native_skill_projection.py. This PR doesn't touch that file, and #15651 tracks those tests as red on main. Rerun locally on the rebased head: type check, 143 composer/paste unit tests, test/test_playwright_e2e.py, and the 6 paste-highlight browser tests against a rebuilt dashboard. All pass.

@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Oct 1, 2026
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Oct 8, 2026
@Pearcekieser

Copy link
Copy Markdown
Contributor Author

note (non-blocking): Frontend Tests shard 4 on 715af87cdd failed one test, ChatInput.lexicalKeys.test.tsx > Ctrl+Shift+Enter optimizes the prompt instead of sending it (expected +0 to be 1). The other 11,247 tests in that shard passed. This looks like a flake rather than a finding. The test drives the Lexical composer, and this PR's only ChatInput.tsx change adds [scrollbar-gutter:stable] to the plain textarea's class list, which jsdom does not apply. The same commit passed this shard on 4ee1e81813, and the test passes locally on 715af87cdd. I'll retrigger with an identical tree once this round settles.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Oct 8, 2026
@Pearcekieser
Pearcekieser force-pushed the fix/paste-chip-scroll-desync branch from 715af87 to c8af92a Compare October 8, 2026 15:21
@Pearcekieser

Copy link
Copy Markdown
Contributor Author

note (non-blocking): identical-tree retrigger at c8af92ad1a, no code change (git diff 715af87cdd c8af92ad1a is empty). The round on 715af87cdd had one real red, the ChatInput.lexicalKeys.test.tsx > Ctrl+Shift+Enter optimizes the prompt instead of sending it flake in Frontend Tests shard 4 (see the earlier note). Frontend Coverage Merge, Coverage Gate and PR Readiness failed closed on that one recorded failure, not on a coverage drop. The other 96 checks passed.

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Oct 8, 2026
@Pearcekieser

Copy link
Copy Markdown
Contributor Author

note (non-blocking): Integration (in-process gateway) on c8af92ad1a failed the same test as on 7a7c3068d4: test_owner_only_boot.py::test_a_fresh_boot_leaves_nothing_readable_by_others found a 0o644 autonomy/.../inbound-spool file after a fresh boot. That is #17964, still open, and it is intermittent on main rather than fixed (main's 08:08Z run passed it, this run did not). This PR does not touch the autonomy spool or boot path. Opus 5.5 and UX both passed on this head. I'll let the round settle before deciding on a retrigger.

@Pearcekieser
Pearcekieser force-pushed the fix/paste-chip-scroll-desync branch from c8af92a to 5251e7f Compare October 9, 2026 00:16
@Pearcekieser

Copy link
Copy Markdown
Contributor Author

note (non-blocking): identical-tree retrigger at 5251e7f637, no code change (git diff c8af92ad1a 5251e7f637 is empty). On c8af92ad1a, 94 checks passed. The only reds were Integration (in-process gateway), which failed the owner-only-boot test tracked in #17964 and intermittent on main, and PR Readiness failing on it. Opus 5.5 and UX both passed on that head.

@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Oct 9, 2026
@Pearcekieser

Copy link
Copy Markdown
Contributor Author

note (non-blocking): Integration (in-process gateway) on 5251e7f637 failed the same test again, test_owner_only_boot.py::test_a_fresh_boot_leaves_nothing_readable_by_others (0o644 autonomy/inbound-spool). That is #17964, open on main, with its fix in #18224. This PR does not touch the autonomy store. GPT 6.1, Opus 5.5 and First Principles passed on this head. Once the round settles I'll rebase if #18224 has merged, otherwise retrigger with an identical tree.

The collapsed-paste chip is painted by a mirror div behind the composer
textarea. The mirror never shows a scrollbar, but the textarea draws the
6px classic scrollbar from index.css once the draft overflows. Its text
box is then 6px narrower than the mirror's, so a line that ends near the
right edge wraps in the textarea and not in the mirror, and every chip
after that line is painted one line off its token.

Both boxes now set scrollbar-gutter: stable, so they reserve the same
gutter and wrap at the same width. A Playwright case launched with
visible scrollbars asserts the two boxes have equal client widths while
the textarea scrolls (6px apart before this change).

The composer's autosize twin in chat-input/sizing.ts copies the textarea's
border-box width, which does not show the reserved gutter, so the twin now
copies scrollbar-gutter too. Without it the twin wraps 6px wider and can
measure a draft one line short, leaving the textarea scrolling below its cap.
A second Playwright case asserts the twin and the textarea have equal client
widths.
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Oct 9, 2026
@Pearcekieser
Pearcekieser force-pushed the fix/paste-chip-scroll-desync branch from 5251e7f to 9fc409b Compare October 9, 2026 03:44
@Pearcekieser

Copy link
Copy Markdown
Contributor Author

note (non-blocking): identical-tree retrigger at 9fc409b445, no code change (git diff 5251e7f637 9fc409b445 is empty). On 5251e7f637, 93 checks passed. The only red was Integration (in-process gateway), which failed the owner-only-boot test tracked in #17964, plus PR Readiness failing on it. The fix for #17964 is #18224, which is still open. GPT 6.1, Opus 5.5 and First Principles all passed on that head.

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Oct 9, 2026

@iamwhatever iamwhatever left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fixes the paste chip highlight being painted one line off its token once a long draft shows a classic scrollbar. The root cause is addressed: the textarea's 6px scrollbar narrowed its text box relative to the overflow:hidden mirror, so the two wrapped differently. Both boxes now set [scrollbar-gutter:stable] (ChatInput.tsx, PasteHighlightLayer.tsx), and the autosize twin copies scrollbarGutter in chat-input/sizing.ts, so its height measurement wraps at the same width. The new Playwright spec turns off --hide-scrollbars and guards its preconditions (the scrollbar actually takes width, the draft actually overflows) before asserting zero width gap for the mirror and the twin, so it would fail on main. It also raises MIN_EXECUTED_SPECS by 2. The committed PNGs under temp-screenshots/ come from a fork, which is the allowed path for evidence. The side effect is a permanent 6px empty gutter on classic-scrollbar platforms even for short drafts. The UX lane raises this as a low Watch item on the current head 9fc409b, and it has no current-head disposition yet; the author should answer it, but it is advisory. GPT and Opus are clean, Design and First Principles PASS, and checks are green. — crew-pr-reviewer

@Pearcekieser

Copy link
Copy Markdown
Contributor Author
  • rebutted: 6px gutter stays reserved on short drafts

The reserved strip is the fix itself. [scrollbar-gutter:stable] keeps the textarea and the overflow:hidden mirror at the same text width whether or not the draft scrolls, so they wrap identically. Reserving it only once a scrollbar appears would narrow the textarea by the scrollbar width at that moment, which is the desync this PR fixes.
The cost is 6px of empty space on classic-scrollbar platforms only; overlay-scrollbar platforms such as default macOS reserve nothing.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author
  • rebutted: highlight looks fainter in the after capture

This PR does not change the chip highlight colour or opacity; PasteHighlightLayer.tsx only gains the gutter class. In before.png the misplaced highlight sits on a line with no glyphs over it, so the full fill shows. In after.png it sits under its own [ Paste #1 · 8 lines ] token, and the text drawn on top covers part of the fill.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fork Pull request from a fork (external contributor)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Paste chip highlight drifts a line when the composer shows a scrollbar

2 participants