fix(windows): paste copied image files
Summary
- preserve existing bitmap clipboard paste behavior and add a Windows-only fallback for image files copied in Explorer
- decode one properly terminated FileNameW path, reject malformed or unsafe paths, and bound source bytes, dimensions, native decoding, and PNG output
- reuse the existing target-aware attachment ownership path for local, SSH, and paired-runtime terminal and native-chat paste
Reproduction
The regression test models the real Electron/Windows boundary: readImage returns empty while FileNameW contains a UTF-16LE, NUL-terminated absolute image path. Against the merge base, the IPC flow returned null instead of the expected target-owned attachment path. The same test passes with this change and remains deterministic without requiring Windows.
Design notes
The high-level fallback proposed in #9583 is correct. This implementation additionally requires valid termination and a fully qualified non-device path, limits support to Electron-compatible PNG/JPEG sources, reads and validates through one bounded file handle, and checks encoded dimensions before native decoding. Malformed, multiple, unsupported, missing, changing, oversized, or undecodable inputs fail closed.
A real Windows Explorer smoke test is still required to validate the OS/Electron integration itself.
Validation
- focused clipboard parser, IPC routing, terminal paste, and native-chat paste: 73 passed
- pnpm typecheck
- touched-file oxlint and oxfmt check
- pnpm run check:max-lines-ratchet
- pnpm run check:reliability-gates
- pnpm build
- pnpm run build:electron-vite
- git diff --check
Full pnpm test initialized native modules and passed 32,915 tests. Two unrelated relay fixture assertions failed because inherited GIT_CONFIG variables changed the fixture count; that suite passed 10/10 with those inherited variables unset. Repository-wide pnpm lint remains blocked by pre-existing switch-exhaustiveness errors in untouched files.
No actionable comments were generated in the recent review. đ
âšī¸ Recent review info
âī¸ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 6b271f10-4ca5-468c-8cc1-b128d2887f5a
đĨ Commits
Reviewing files that changed from the base of the PR and between a924daa5dd9bb832acf38f24f988cbba80e5cd1b and f5c2dd0cbbe92a15ff4b763a9ca53bef762eb73f.
đ Files selected for processing (4)
src/main/window/clipboard-ipc-handlers.test.tssrc/main/window/clipboard-ipc-handlers.tssrc/main/window/clipboard-windows-image-file.test.tssrc/main/window/clipboard-windows-image-file.ts
đ§ Files skipped from review as they are similar to previous changes (4)
- src/main/window/clipboard-ipc-handlers.ts
- src/main/window/clipboard-windows-image-file.ts
- src/main/window/clipboard-ipc-handlers.test.ts
- src/main/window/clipboard-windows-image-file.test.ts
đ Walkthrough
Walkthrough
Adds a Windows clipboard image file reader that validates FileNameW paths, bounds file reads and image dimensions, decodes supported PNG/JPEG sources, and converts them to PNG. Updates the clipboard IPC handler to use this reader on Windows and save the result locally or through SSH. Extends tests for malformed paths, file failures, size limits, decoding behavior, cleanup, and IPC mock wiring.
đĨ Pre-merge checks | â 4 | â 1
â Failed checks (1 warning)
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Description check | â ī¸ Warning | The description omits required Screenshots, AI Review Report, Security Audit, and Notes sections from the template. | Add the missing sections and include the requested cross-platform AI review, security audit, screenshots or 'No visual change', and platform-specific notes. |
â Passed checks (4 passed)
| Check name | Status | Explanation |
|---|---|---|
| Title check | â Passed | The title is concise and accurately summarizes the Windows clipboard image paste fix. |
| Docstring Coverage | â Passed | No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. |
| 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. |
⨠Finishing Touches
đ Generate docstrings
- [ ] Create stacked PR
- [ ] Commit on current branch
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.
Comment @coderabbitai help to get the list of available commands.