fix(extension): route clipboard image reading through extension host - #559
Merged
Conversation
The outer webview's navigator.clipboard.read() requires user activation (a keystroke on THAT document), but the user types inside the sandboxed iframe — so the async Clipboard API throws silently in newer Chromium/ Electron, causing image paste to do nothing. Fix: forward clipboard-image-request to the extension host, which reads the clipboard image using platform-native tools: - macOS: osascript + NSPasteboard (PNG/TIFF), with file-URL priority so Finder-copied images paste the actual file, not the Finder icon - Linux: xclip with text/uri-list priority for file manager copies, then raw image/png data - Windows: PowerShell with GetFileDropList priority for Explorer copies, then GetImage for screenshots Changes: - chat_bridge.ts: add clipboard-image-read handler with native readers - chat_panel.ts: replace client-side navigator.clipboard.read() with forwarding to extension host (both splash and non-splash variants) - deck/shell.ts: same forwarding for the deck shell webview - Tests: bridge test, panel relay test
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (5)
📝 WalkthroughWalkthroughThe extension adds a visibility-gated ChangesClipboard image flow
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant ChatWebview
participant ExtensionHost
participant NativeClipboard
ChatWebview->>ExtensionHost: Send clipboard-image-read
ExtensionHost->>NativeClipboard: Read image with platform tools
NativeClipboard-->>ExtensionHost: Return image data or null
ExtensionHost-->>ChatWebview: Send clipboard-image metadata
Suggested reviewers: ✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The outer webview's
navigator.clipboard.read()requires user activation (a keystroke on THAT document), but the user types inside the sandboxed iframe — so the async Clipboard API throws silently in newer Chromium/Electron, causing image paste to do nothing.Fix
Forward
clipboard-image-requestto the extension host, which reads the clipboard image using platform-native tools:public.file-url→ resolve path → read filetext/uri-listvia xclip → read fileimage/pngGetFileDropList→ read fileGetImage→ PNGChanges
chat_bridge.ts: newclipboard-image-readhandler with native readerschat_panel.ts: forward to extension host (both webview variants)deck/shell.ts: same forwarding for deck shellCompanion: harmoniqs/opencode#254
Summary by CodeRabbit
New Features
Bug Fixes