Skip to content

fix(desktop): omit undefined IPC payload fields - #50333

Closed
andogensi wants to merge 2 commits into
anomalyco:devfrom
andogensi:desktop-ipc-options
Closed

andogensi wants to merge 2 commits into
anomalyco:devfrom
andogensi:desktop-ipc-options

Conversation

@andogensi

@andogensi andogensi commented Sep 21, 2026 •

Copy link
Copy Markdown

Issue for this PR

Closes #50153

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Opening “Images and files” sends title: undefined over the desktop MessagePort. The server's JSON codec rejects it before the picker handler runs, producing Desktop IPC handler failed.

Omit undefined fields from plain objects at the renderer's request boundary, including nested options. Preserve non-plain objects, including attachment byte arrays, rather than converting them to plain objects. Add regression coverage through the real RPC transport for the picker, directory/save dialogs, opening paths and binary uploads.

This addresses request decoding; #50207 separately improves error reporting.

How did you verify your code works?

Against v2.0.11, the original payload reproduced Expected string | null at ["options"]["title"]. On the updated v2 base:

  • From packages/desktop: bun test src/main/ipc-transport.test.ts src/renderer/ipc-payload.test.ts src/renderer/platform/files.test.ts src/main/files — 35 passed.
  • From packages/desktop: bun typecheck — passed.
  • Oxlint on the four original changed files and again on the two files in the follow-up — no warnings or errors.
  • Regression tests preserve Date, Map, Set, ArrayBuffer, DataView, Blob and File references at the root and inside objects/arrays, while still omitting undefined fields from null-prototype objects.

Manually verified on Windows using the native Electron development app at commit fb189dc599:

  • Clicking + -> Images and Files opened the native file picker.
  • Selecting a PNG and then a TXT file displayed both attachments in the composer.
  • Cancelling a subsequent picker preserved the attachments without an IPC error.

No prompt was submitted. The desktop main/preload/renderer were built from this PR, with the installed 2.0.11 CLI used as the local backend.

The repository-wide bun run check could not run because the filtered workspace install lacks the root oxlint command; the scoped lint above used Oxlint 1.60.0 separately. No packaged build has been verified.

I am using a tool to translate Japanese into English, so I apologize if the meaning is incorrect.

Screenshots / recordings

image

Windows development app after attaching the test PNG (white thumbnail) and TXT file:

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

@andogensi
andogensi marked this pull request as ready for review September 21, 2026 11:49
@andogensi

Copy link
Copy Markdown
Author

I've verified the fix in the Windows desktop development app and added a screenshot and test results to the PR description.

Could a maintainer approve the pending CI workflows and manually link #50153? The description includes Closes #50153, but this PR targets v2, while the default branch is dev.

Thank you!

@Vibe-coding-nvm-delete-repo

Copy link
Copy Markdown

Independent verification on the packaged Windows build (Desktop 2.0.12, Windows 11 10.0.26200), for the "no packaged build has been verified" note above.

Method: instrumented the shipped renderer's IPC port (MessagePort) and replayed requests through the real RPC transport.

  1. The pre-fix payload reproduces the reported defect exactly:
Request: { tag: "FilesOpenFilePicker", payload: { options: { multiple: true, title: undefined, extensions: undefined } } }
Exit:    { _tag: "Failure", cause: [ { _tag: "Die", defect: "Expected string | null\n  at [\"options\"][\"title\"]" } ] }
  1. With undefined omitted at the renderer's request boundary (the approach in this PR), the same UI action emits:
{ options: { multiple: true, defaultPath: "C:\\dev" } }

and the decode failure no longer occurs (no Die cause, no generic toast).

Scope note for reviewers: in the shipped bundle the request boundary (Ut in /out/renderer/assets/main-C16eq30x.js) is shared by every Files*, Menu* and Window* request, so the same undefined-field rejection also covers FilesOpenPath (application), the save dialog and the directory picker - consistent with the regression cases listed in this PR.

Caveat: this is packaged-binary verification (normalized the request boundary in the installed renderer), not a build of this branch, and the native dialog itself was not visually confirmed in my remote session.

@ilajosmanov

Copy link
Copy Markdown

Confirmed the same failure in OpenCode Desktop 2.0.12, Linux x64 AppImage on Omarchy/Hyprland, with Nautilus 50.3.1.

Clicking Open in File Manager consistently shows “Desktop IPC handler failed,” including after restarting the desktop.

Captured the underlying RPC failure through the renderer debugger:

Expected string | null
  at ["application"]

The renderer sends FilesOpenPath with application: undefined. Nautilus launches normally when invoked directly. This matches the FilesOpenPath regression case in this PR.

No configured plugins. The installed AppImage was tested; this PR’s build has not been tested locally.

@andogensi

Copy link
Copy Markdown
Author

Thanks @ilajosmanov and @Vibe-coding-nvm-delete-repo for the independent confirmations on Linux and the packaged Windows build.

These findings match the regression cases already covered by this PR, including FilesOpenPath with application: undefined, and further confirm that the issue is at the shared renderer IPC request boundary rather than being specific to the Windows file picker.

@andogensi

Copy link
Copy Markdown
Author

Confirmed this still reproduces on OpenCode Desktop 2.0.13 on Windows.

@thdxr
thdxr changed the base branch from v2 to dev October 10, 2026 19:12
@github-actions

Copy link
Copy Markdown
Contributor

Automated PR Cleanup

Thank you for contributing to opencode.

Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions.

This PR was closed because it matched the following cleanup criteria:

  • The PR was created more than 1 month ago
  • The PR had fewer than 2 positive reactions
  • Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR

PRs created within the last month are not affected by this cleanup.

If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate.

Thanks again for taking the time to contribute.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

desktop: "Images and files" picker never opens on Windows (Desktop IPC handler failed)

3 participants