Skip to content

fix(desktop): let every CEF first responder own the paste hotkey - #110

Draft
banozz0 wants to merge 1 commit into
mainfrom
fix/cef-first-responder-paste-passthrough
Draft

fix(desktop): let every CEF first responder own the paste hotkey#110
banozz0 wants to merge 1 commit into
mainfrom
fix/cef-first-responder-paste-passthrough

Conversation

@banozz0

@banozz0 banozz0 commented Aug 27, 2026

Copy link
Copy Markdown
Collaborator

Complements the renderer-edit CEF passthrough (7a70ed4) by widening it from Source/Manage/SessionChat to every CEF first responder.

Why

shell_focus keeps naming a terminal pane while an app modal, the sidebar, a Kanban/Automate page, a titlebar popup, a browser tab, or the editor companion holds AppKit's first responder — so the app-wide Cmd+V binding still resolves a hidden terminal and pastes the same clipboard into its composer alongside the CEF view's own paste. The next chat send's draft-preservation step then sweeps that phantom composer draft into Saved Prompts as a prompt the user never saved.

We hit this in the wild today: image pastes into session chat were written to disk twice ~45ms apart (native terminal path first, chat composer second) and the terminal copy surfaced as an untagged Saved Prompt after the send. 7a70ed4 fixes the chat/Docs/Source cases; this covers the remaining Chromium surfaces, which shadow-paste through exactly the same mechanism. A Chromium first responder always owns its own paste, so the enumeration doesn't need to grow case by case.

cargo check clean (no new warnings in focus.rs).

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Fixed macOS paste handling across embedded browser surfaces.
    • Prevented clipboard content from being unintentionally pasted into hidden terminal input when dialogs, sidebars, popups, or browser tabs are active.

The renderer-edit passthrough introduced with the chat/Docs/Source guard
stops the Cmd+V terminal binding from shadow-pasting into the shell-focus
terminal while a Chromium surface is AppKit's first responder. The same
double-fire exists for every other CEF surface — app modals, the sidebar,
Kanban/Automate pages, titlebar popups, browser tabs, the editor
companion — because shell_focus keeps naming a terminal pane while those
views hold native focus. The phantom terminal draft it leaves behind is
what a later chat send's draft-preservation step sweeps into Saved
Prompts as a prompt the user never saved. Widen the guard to any CEF
first responder: a Chromium view always owns its own paste.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Aug 27, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 6636828f-636a-4ca0-b91f-642a2d17bce2

📥 Commits

Reviewing files that changed from the base of the PR and between 8818ac5 and 2cae150.

📒 Files selected for processing (1)
  • apps/desktop/src/app/focus.rs

Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review.


📝 Walkthrough

Walkthrough

The macOS renderer edit hotkey passthrough now treats every CefSurface as owning native focus. The existing non-macOS fallback and propagation behavior remain unchanged.

Changes

CEF Paste Focus Handling

Layer / File(s) Summary
Broaden the CEF focus gate
apps/desktop/src/app/focus.rs
The macOS match now accepts any CefSurface. The comment documents modal, sidebar, Kanban, titlebar popup, and browser-tab cases. Non-macOS behavior is unchanged.

Estimated code review effort: 2 (Simple) | ~5 minutes

Merge Risk: ⚪ Minimal · up to 2cae1

This change routes Cmd+V to the visible CEF view instead of a hidden terminal composer, preventing duplicate pastes and unintended saved drafts. No actionable merge-blocking risk remains beyond normal checks and review.

Suggested reviewers: maddada

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: allowing every CEF first responder to own the paste hotkey.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/cef-first-responder-paste-passthrough

Warning

Some tools did not complete. Review the errors below.

🔧 Clippy (1.97.1)

Clippy execution failed


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@maddada
maddada marked this pull request as draft August 27, 2026 16:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant