Skip to content

Name saved desktop servers, hide This Mac, and switch servers from the palette - #4296

Open
idrevnii wants to merge 1 commit into
get-bb:mainfrom
idrevnii:bb/desktop-server-manager
Open

idrevnii wants to merge 1 commit into
get-bb:mainfrom
idrevnii:bb/desktop-server-manager

Conversation

@idrevnii

@idrevnii idrevnii commented Sep 24, 2026 •

Copy link
Copy Markdown

Human comments

What was wrong

The desktop server chooser appears in three places: bb → Desktop Settings → Server (#4274), its Window → Server alias, and the Choose server… popup on startup error pages (#4295). All three name saved servers only by host (10.0.0.3:38886) and always list the built-in server. The rendered app cannot reach that list at all: BbDesktopApi exposes no server targets (#3133). That works for one extra server. It does not work for people who deliberately run several independent bb instances, each with its own users, projects, and plugins, and switch between them in one desktop app; for example a personal server, one shared with a friend, and a homelab "ops" server. Those instances are separate on purpose, so moving them onto machines of a single server (the reason #628 gave for removing the earlier multi-server UI from #605) is not a substitute.

Separately, server-target.json is parsed with a strict schema. A file that contains any field the running build does not know loads as "no saved servers", and the next save (for example Add Server…) overwrites it. Moving between desktop builds, in either direction, can therefore silently erase the saved list. I reproduced this against main's server-target.ts with a real file: two saved servers plus one unknown field loaded as [] / builtin, and after Add Server… the file held only the new server.

What changed

Server targeting stays in the native menus, following #628, #3919, #4274, and #4295. There is no renderer management UI.

Desktop shell (apps/desktop):

  • Names in the existing dialogs (server-url-dialog*.ts). Add Server… and Set Server URL… get an optional Name field, with the same markup and CSS as the URL field. buildServerMenuArgs() feeds the names to all three chooser surfaces, including the error-page popup.
    • Adding an already-saved URL with a name renames it; with no name, the saved name is kept.
    • In Set Server URL…, changing only the name renames the server without selecting it or reloading windows. Changing the URL behaves as before: it selects the edited server.
  • Edits keep their place (server-target.ts). URL edits keep the server's position and name instead of moving it to the end. Pointing an edit at another saved server's URL merges into that server and keeps its name.
  • Show This Mac (menu.ts, server-list.ts, server-target.ts). A checkbox in bb → Desktop Settings, next to Server (Show This Computer on Linux, using the platform labels from Improve desktop startup recovery and moved-server navigation #4295). It sits outside the chooser, so Window → Server and the error-page popup offer only server choices.
    • The built-in server stays listed while it is the current server or when no other server is saved, so hiding it never leaves the chooser empty.
    • While it is hidden, clearing the current server's URL falls back to the next saved server instead of the built-in one.
    • Selecting it still goes through selectBuiltinServer(), so the moved-server view from Improve desktop startup recovery and moved-server navigation #4295 is unchanged.
  • Storage compatible across builds (server-target.ts).
    • Names (keyed by URL) and the built-in choice live in a new server-menu.json next to server-target.json. server-target.json keeps exactly the format released builds write, so older and newer builds keep each other's saved servers.
    • Unknown fields are ignored instead of invalidating the file. A malformed name drops only that entry, and a missing or corrupt server-menu.json only resets names and the built-in choice.
    • Saves are serialized, so overlapping writes (for example a Connect refresh during a menu toggle) cannot leave an older state on disk.
  • Bridge (preload.ts, main.ts, packages/desktop-contract/src/servers.ts). Optional getServerTargets, onServerTargetsChange, and selectServerTarget members on BbDesktopApi, as Expose the Desktop server selector in the sidebar header #3133 proposes.
    • They carry the menu's display names and opaque ids (a hash of the URL), not URLs.
    • Selection is accepted only from application-window main frames, must match a listed id, and runs through the same setActiveServerTarget path as the menus.

App (apps/app):

  • The quick palette offers Switch to server: <name> for every other listed server (palette-server-actions.ts, useDesktopServerTargets.ts).

Other surfaces:

  • Docs: apps/desktop/README.md (Saved servers) and the verify-bb desktop recipe.
  • Wire and APIs: no server/daemon wire change, so no HOST_DAEMON_PROTOCOL_VERSION bump. No plugin API change.
  • CLI: no CLI command. The saved-server list and menus are local to the desktop shell (as with dataDirectory.open in Add a quick palette command to open the data directory #4256), and the CLI already targets any server through BB_SERVER_URL.

Trade-off to review: the loaded server's page can read the other servers' display names, which fall back to host:port for unnamed entries. It can also ask the desktop to switch to one of them. The palette needs both, and #3133 proposes the same bridge. A page could already navigate its own window anywhere without the bridge.

Deviation from #3133: it asks for a sidebar selector. This PR adds the bridge it describes but switches from the quick palette only, leaving app chrome unchanged; a sidebar control could build on the same members. Related: #1451 (multiple desktop servers). The Show This Mac checkbox covers the "hide This Mac from the Server menu" part of #3168, but not its request to stop starting the bundled runtime.

Palette entries need both a desktop build and a served app that include this change; older desktops simply omit the optional bridge members.

How you verified

  • pnpm exec turbo run typecheck lint --filter=@bb/app --filter=@bb/desktop --filter=@bb/desktop-contract
  • pnpm exec turbo run test --filter=@bb/desktop --filter=@bb/desktop-contract: 462 + 22 passed, 1 skipped (existing).
  • pnpm exec turbo run test --filter=@bb/app: 5109 passed, 5 skipped.
  • New and updated tests:
    • server-target.test.ts:
      • naming, renaming without selecting, in-place URL edits, and clearing a name;
      • merging into another saved server keeps its name;
      • an over-long name is rejected without writing either file;
      • falling back to the next server while the built-in one is hidden;
      • reload persistence;
      • the written server-target.json passes a copy of the released strict schema;
      • files with unknown fields keep all saved servers and the target;
      • a malformed or corrupt server-menu.json keeps the server list and the valid names;
      • overlapping saves end with the latest state. This one fails with the latest state lost when saves are not serialized.
    • server-list.test.ts: names and hosts, built-in visibility rules, opaque ids. Labels come from BUILTIN_SERVER_NAME, so the test passes on macOS and Linux.
    • menu.test.ts: the checkbox sits in Desktop Settings next to Server and in neither chooser copy.
    • palette-server-actions.test.ts and CommandPalette.test.tsx: switching from the palette.
  • Manual check on Linux: source-built Electron with an isolated profile against pnpm start:worktree, with saved servers pointing at it through 127.0.0.1 and localhost plus an unreachable one, driven through CDP and the main-process inspector.
    • Unreachable saved server: the error page offered Choose server…. Its popup listed the servers by name (ops, broken checked), with no hidden built-in entry and no settings toggle.
    • Desktop Settings showed Server ▸ and Show This Computer. Checking it added This Computer back to every chooser.
    • Set Server URL opens with the URL and name filled in.
    • Renaming the current server kept the page loaded (a marker set in the page survived) and updated the menus.
    • Add Server with an existing URL and a name renamed that server and switched to it.
    • With the built-in server hidden, clearing the current server's URL switched to the other saved server and updated the menu immediately.
    • The palette listed the other server, and selecting it loaded that server.
  • Not verified: physical macOS. Menus use the same Electron menu code on both platforms.

Refs #3133, #1451, #3168

🤖 Generated with Claude Code

AGENT GENERATED

…e palette

Saved servers take an optional name in the existing Add Server and Set
Server URL dialogs, shown in the Server menu instead of the host. Changing
only the name renames without switching. A Show This Mac checkbox hides
the built-in entry while another server is selected. The quick palette
lists the other servers through optional BbDesktopApi members that expose
names and opaque ids, not URLs.

Names and the This Mac choice live in server-menu.json, so
server-target.json keeps the format released builds read and write.
Unknown fields no longer discard the saved servers, and saves are
serialized.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@idrevnii
idrevnii force-pushed the bb/desktop-server-manager branch from 67952f4 to 59db264 Compare September 25, 2026 10:44

This branch has not been deployed

No deployments
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.

1 participant