fix(web): let paste expand a resting composer#9498

merged1
main
fix/composer-paste-expands
openedSep 3, 2026byJJulius Marminge
View on GitHubTwo-way sync enabledPR last imported 5d ago

What Changed

Why

UI Changes

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes
  • I included a video for animation/interaction changes

Note

Low Risk Localized chat input UX using the existing type-to-focus pattern and composer API; no auth, data, or backend changes.

Overview Fixes paste being dropped when the composer is in its resting (blurred) state after clicking the timeline—behavior that type-to-focus already handled for single keys.

Shared redirect rules: shouldRedirectInputToComposer centralizes the checks (editable/interactive targets, floating layers, defaultPrevented) so keyboard type-to-focus and the new paste path stay aligned. shouldTypeToFocusComposer now delegates to that helper after its key-specific guards.

Paste-to-focus: A capture-phase window paste listener runs when a thread is active and the same exclusions apply (command palette, terminal focus, open model picker). pasteTextToFocusComposer only handles plain text (skips file pastes for the composer’s own handler); on success it calls insertTextAtEnd, preventDefault, and stopPropagation so the composer focuses/expands like typing would.

Reviewed by Cursor Bugbot for commit 08346fbf4ff44eedabc513af9df049a3bbefa9d8. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Let paste events expand and focus a resting composer in ChatView

  • Adds a shared shouldRedirectInputToComposer predicate that rejects default-prevented events, editable/interactive surfaces, and active floating layers; both type-to-focus and paste-to-focus use it
  • Adds pasteTextToFocusComposer to accept plain-text clipboard events with no files, and a capture-phase window paste listener in ChatViewContent that inserts eligible text at the end of the composer and cancels default propagation on success
  • The paste listener skips inactive-thread, command-palette, terminal-owned, and model-picker states
  • Risk: paste events outside editable surfaces are now intercepted and cancelled when the composer accepts them; pasting into other custom listeners that rely on propagation may be affected

Macroscope summarized 08346fb.

Added 1 commit

  • fix(web): let paste expand a resting composer08346fb
Synced from GitHub

Thread transfer impact

✅ Thread transfer remains within every enforced ceiling.

ProviderMetricMain baselineThis PRImpactPR ceiling
CodexTotal thread wire13.7 KiB13.5 KiB−228 B (−1.6%)15.1 KiB✅
CodexThread snapshot wire7.0 KiB7.0 KiB+2 B (+0.0%)7.3 KiB✅
CodexLive turn WebSocket wire6.7 KiB6.5 KiB−230 B (−3.3%)7.8 KiB✅
CodexLive turn WebSocket decoded58.5 KiB57.0 KiB−1.5 KiB (−2.6%)66.4 KiB✅
CodexLive turn messages108−2 (−20.0%)21✅
ClaudeTotal thread wire13.8 KiB13.6 KiB−182 B (−1.3%)15.1 KiB✅
ClaudeThread snapshot wire7.0 KiB7.0 KiB−4 B (−0.1%)7.3 KiB✅
ClaudeLive turn WebSocket wire6.7 KiB6.6 KiB−178 B (−2.6%)7.8 KiB✅
ClaudeLive turn WebSocket decoded59.3 KiB57.9 KiB−1.4 KiB (−2.4%)66.4 KiB✅
ClaudeLive turn messages10100 (0.0%)21✅

Baseline: 80b5373 · PR result: 08346fb · Source CI: success

Scenario and decoded snapshot size

10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

  • Codex decoded thread snapshot: 113.8 KiB
  • Claude decoded thread snapshot: 114.5 KiB

Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

Synced from GitHub

Approvability

Verdict: Approved at 08346fb

Macroscope's review found this PR approvable — This focused web fix restores plain-text paste handling when the composer is blurred, while preserving paste behavior for editors, controls, dialogs, terminals, and file attachments. Its one-file scope and narrow reuse of existing composer insertion and focus logic keep the runtime impact low.

You can add or adjust custom eligibility rules. Learn more.