Skip to content

fix(desktop): remote server switching#17214

Open
OpeOginni wants to merge 8 commits intoanomalyco:devfrom
OpeOginni:fix/desktop-server-switch
Open

fix(desktop): remote server switching#17214
OpeOginni wants to merge 8 commits intoanomalyco:devfrom
OpeOginni:fix/desktop-server-switch

Conversation

@OpeOginni
Copy link
Contributor

@OpeOginni OpeOginni commented Mar 12, 2026

Issue for this PR

Closes #17211

Type of change

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

What does this PR do?

The issue
When switching servers, the provider tree is not properly rebuilt. GlobalSDKProvider and GlobalSyncProvider capture server.current at mount time and build SDK clients, SSE streams, event queues, and child stores around that snapshot. Without a remount boundary, switching servers left the entire subtree pointing at the old server — stale SDK clients, stale SSE connections, stale project data, and stale directory routes causing problems with displaying recent projects and properly spawning terminals.

Fix
This PR wraps the server-bound subtree in a Remount component keyed on server.key. This uses <For each={[key]}>. I tried making use of <Show when{server.key} keyed> (was also used previously before this commit b76ead3#diff-dc4486239f5091faca2b1d9b42efc48d0e5323b5388e53403f37f446a1d63fc8) but it still would not allow for proper remounting of the needed components, so I had situations like the sidebar still showing stale projects and it triggers TypeError: null is not an object (evaluating 'node.owned[i]') error.

This is a small fix I could get working, I believe the best solution for the future would be to make GlobalSDKProvider and GlobalSyncProvider internally reactive to server changes rather than relying on a full subtree remount. Since that will be a large rewrite I decided to make a simpler PR that works even if not as effective.

How did you verify your code works?

Tested on my local machine switching around 2 remote servers while having my terminal open with everything working as it should. Check video below.

Screenshots / recordings

Screen.Recording.2026-03-12.at.17.59.42.mov

Checklist

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

@github-actions
Copy link
Contributor

Hey! Your PR title Fix/desktop server switch doesn't follow conventional commit format.

Please update it to start with one of:

  • feat: or feat(scope): new feature
  • fix: or fix(scope): bug fix
  • docs: or docs(scope): documentation changes
  • chore: or chore(scope): maintenance tasks
  • refactor: or refactor(scope): code refactoring
  • test: or test(scope): adding or updating tests

Where scope is the package name (e.g., app, desktop, opencode).

See CONTRIBUTING.md for details.

@OpeOginni OpeOginni changed the title Fix/desktop server switch fix(desktop): remote server switching Mar 12, 2026
@Brendonovich Brendonovich enabled auto-merge (squash) March 13, 2026 01:00
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.

Switching to a remote server breaks desktop app, especially when the terminal is open

2 participants