Skip to content

Conversation

@aspiers
Copy link
Contributor

@aspiers aspiers commented Jan 5, 2026

Without this patch, the desktop application requires a strict port configuration (port 1420) and hardcodes the devUrl in tauri.conf.json. This causes issues when the port is already in use during development.

This is a problem because developers cannot easily run multiple instances or work around port conflicts without manual configuration changes.

This patch solves the problem by removing the hardcoded devUrl from tauri.conf.json, setting strictPort to false in vite.config.ts to allow Vite to find an available port, and updating the Rust code to read the dev URL from the Tauri config or fall back to the default localhost:1420.

Closes #6943.

@aspiers aspiers requested a review from adamdotdevin as a code owner January 5, 2026 13:40
@github-actions
Copy link
Contributor

github-actions bot commented Jan 5, 2026

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

Results

No duplicate PRs found (beyond the PR itself at #6947).

The searches across multiple relevant keyword combinations returned only the PR itself. This suggests that:

  1. No other open PRs are currently addressing the same dev server port configuration issue
  2. The specific problem (port 1420 conflicts in the Tauri desktop app) hasn't been tackled by another PR
  3. The fixes (removing hardcoded devUrl, setting strictPort to false) are unique to this PR

This is a good sign — you can proceed with this PR without worrying about duplicate efforts.

@adamdotdevin
Copy link
Contributor

cc @Brendonovich can you take a look? i like the idea of this, i've had this bite me running multiple

@aspiers
Copy link
Contributor Author

aspiers commented Jan 5, 2026

Rebasing to fix conflicts now...

Without this patch, the desktop application requires a strict port
configuration (port 1420) and hardcodes the devUrl in tauri.conf.json.
This causes issues when the port is already in use during development.

This is a problem because developers cannot easily run multiple
instances or work around port conflicts without manual configuration
changes.

This patch solves the problem by removing the hardcoded devUrl from
tauri.conf.json, setting strictPort to false in vite.config.ts to
allow Vite to find an available port, and updating the Rust code to
read the dev URL from the Tauri config or fall back to the default
localhost:1420.
@aspiers aspiers force-pushed the desktop-strictPort-false branch from 89d025a to dc238fe Compare January 5, 2026 19:32
@Brendonovich
Copy link
Collaborator

If Vite decides to use a port other than 1420, how does Tauri become aware of that? I don't think this change implements that.
Might be easier to just hardcode a different port number.

@aspiers
Copy link
Contributor Author

aspiers commented Jan 6, 2026

@Brendonovich wrote:

If Vite decides to use a port other than 1420, how does Tauri become aware of that? I don't think this change implements that.

It does! I tested it and it works.

Might be easier to just hardcode a different port number.

Easier but substantially less useful; then you still can't run multiple instances and might get other conflicts on that same port.

@Brendonovich
Copy link
Collaborator

Brendonovich commented Jan 6, 2026

@aspiers Can you detail how you've tested this? I ran bun tauri dev in two terminals and both windows loaded localhost:1430 - Tauri's default. Vite was running on 1420 and 1421 but not being used by either instance.

@aspiers
Copy link
Contributor Author

aspiers commented Jan 6, 2026

@Brendonovich I've tested it in three ways:

1. Test it works as normal with no other Tauri app running

Self-explanatory

2. Test conflict with other Tauri app already running

  1. Run Whispering, confirm it takes port 1420
  2. Run OpenCode Desktop, confirm it takes port 1421 and that the UI launches correctly
image image

3. Test multiple OpenCode Desktop instances running at the same time

Following on from test 2 above:

  1. Run OpenCode Desktop again, confirm it takes port 1422 and that another UI launches correctly
image image

@aspiers
Copy link
Contributor Author

aspiers commented Jan 6, 2026

@Brendonovich If it's not working for you on this PR branch, then I would make a wildly uninformed guess as a Tauri / OpenCode newb that maybe you're missing a build step? E.g. see #6780 (comment).

@Brendonovich
Copy link
Collaborator

Ah I think I know why it's working for you: Tauri's behaviour when devUrl isn't provided is to serve assets from frontendDist on its own dev server at localhost:1430. It's likely that you've built the app before and Tauri is serving those assets, rather than connecting to the Vite servers.
The thing to check is location.href in the inspector's console - the OC server URL is injected into the webview differently such that it will work in either case.

@aspiers
Copy link
Contributor Author

aspiers commented Jan 7, 2026

Not sure I follow but if I spin up two instances then location.href in the console of the first shows port 1430, and the second shows 1431:

image image

@Brendonovich
Copy link
Collaborator

Ok yeah that's what I expected - the webviews aren't connecting to the vite instances, theyre connecting to Tauri's internal dev server that's serving files from desktop/dist. If you delete that folder then it'll stop working.
Tauri doesn't have a way to know about the random port that Vite selects

@aspiers
Copy link
Contributor Author

aspiers commented Jan 8, 2026

Ah, I see, thanks. Couldn't we make it dynamically set TAURI_CLI_PORT to the port selected by vite?

@Brendonovich
Copy link
Collaborator

Afaik no since 1) TAURI_CLI_PORT sets the port that Tauri's devserver would be started on which would conflict with Vite's and 2) the Tauri CLI is responsible for invoking Vite, without a way for pulling the port number back out.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

desktop clashes with other Tauri apps

3 participants