feat(desktop): Support Portable Mode - #37325
Conversation
Updated comment to English and clarified IPC handling.
|
The following comment was made by an LLM, it may be inaccurate: Found one potentially related PR: PR #8963: This PR is related because it also addresses portable mode functionality and environment variable handling for portable/profile isolation. You may want to review it to ensure there's no overlapping work or to understand any previous design decisions around portable mode. |
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
|
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:
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. |
Issue for this PR
Closes #
Type of change
What does this PR do?
This PR introduces a "Portable Mode", allowing users to run the app directly from a USB drive or custom directory without leaving data in the system's default
AppDatafolder.To achieve this, I made the following changes:
packages/desktop/src/main/index.ts. If it detects the portable directory, it redirectsapp.setPath("userData", ...)and overrides environment variables (likeXDG_DATA_HOME) to a localopencode-datafolder next to the executable.packages/desktop/src/main/ipc.ts), triggering a native confirmation dialog that safely restarts the application to apply the new paths. If the user cancels the dialog, the promise correctly rejects so the frontend UI switch reverts its state.i18nlocalization keys for all supported languages.This approach works because redirecting the
userDatapath before the app emits thereadyevent ensures all subsequent Chromium processes, local DBs, and the sidecar node server read/write strictly from the isolated directory.How did you verify your code works?
bunx electron-builder --dir).opencode-datafolder (with the.portablemarker) is successfully created next to the.exe.opencode-datarather than%APPDATA%..portablemarker, restarts, and gracefully falls back to the system default directory.Screenshots / recordings
Checklist