feat(desktop): add --port and --hostname CLI arguments for sidecar configuration#22004
Open
hokonoko wants to merge 1 commit intoanomalyco:devfrom
Open
feat(desktop): add --port and --hostname CLI arguments for sidecar configuration#22004hokonoko wants to merge 1 commit intoanomalyco:devfrom
hokonoko wants to merge 1 commit intoanomalyco:devfrom
Conversation
Contributor
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
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.
Issue for this PR
Relates to #7629, #18906, #20271
Type of change
What does this PR do?
The OpenCode desktop app always spawns its sidecar server on a random OS-assigned port with
127.0.0.1as hostname. The only way to override the port was theOPENCODE_PORTenvironment variable (compile-time or runtime). There was no way to change the hostname at all.This PR adds
--portand--hostnameCLI arguments to the desktop app binary, so users can control the sidecar's listen address at launch time. This unblocks use cases like:--hostname 0.0.0.0)--port 4096)How it works:
main.rsparses CLI args viaparse_cli_args_from()into aCliOptionsstruct (port,hostname,warnings). The struct is passed throughrun_with_options()→initialize(). Port/hostname overrides are applied when spawning the sidecar; invalid values produce atracing::warn!log and fall back to defaults so the app never fails to start.The existing
run()entry point is preserved (no arguments) for#[cfg_attr(mobile, tauri::mobile_entry_point)]compatibility.When a secondary instance is launched with
--port/--hostnamewhile a primary instance is already running, the single-instance handler logs an info message noting that these overrides are ignored.Priority order:
--port/--hostname(highest)OPENCODE_PORTenv var (port only, existing behavior)127.0.0.1(default)How did you verify your code works?
cargo check --libpasses with no new warningscargo test --bin opencode-desktop— 15/15 unit tests pass covering:--port N,--port=N,--hostname ADDR,--hostname=ADDR, invalid/missing values, boundary values (0, 1, 65535), combined flags, unknown flags ignoredinitialize()Screenshots / recordings
N/A — this is a CLI argument change with no UI impact.
Checklist