Repository navigation
Show why the Server menu lists no Connect servers - #2168
Merged
Merged
Conversation
When the desktop's Connect server sync had nothing to list (no local runtime and no cached credential, connect plugin disabled or unpaired, server or gate unreachable) it wrote one log line and told nobody. The Window > Server submenu then looked exactly like an account with no servers, and in the one flow where that menu is the recovery path (a saved custom target that stopped answering, #1494) the user had no hint that signing in to bb Connect would populate it. The sync now returns a typed outcome instead of null. The local RPC failure body is parsed instead of discarded (HTTP 503 is plugin-disabled, handler_error/not_paired is not-paired), the gate path distinguishes a refused credential from an outage, and a new onSkipped(reason) callback fires beside onServers. main.ts stores the reason, clears it on success, and rebuilds the application menu from onSkipped too, because Electron menus are immutable once built. menu.ts renders the reason as one disabled row under the server list, only when no Connect server is listed at all. Fixes #1753 Co-Authored-By: Claude <[email protected]>
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.
What was wrong
createConnectServerSync().runSync()inapps/desktop/src/connect-server-sync.tstreated every empty outcome offetchServers()asnull: no local runtime and no cached credential, connect plugin disabled (HTTP 503), connect plugin unpaired ({ code: "handler_error", message: "not_paired" }), server or gate unreachable, and a refused credential. It logged one line and returned, somain.tswas never told and never rebuilt the menu.buildMenuServerItems()mapped an emptyconnectAccountServersandcreateServerMenuItems()inmenu.tshas no empty-state row, so Window > Server looked exactly like an account with no servers.fetchConnectAccountServers()even parsedrpcFailureSchemaand discarded the result, although the server says which case it is on the wire.Issue: #1753. Report: https://get-bb.github.io/reports/issues/1753.html
What changed
apps/desktop/src/connect-server-sync.ts:fetchConnectAccountServers()returns{ ok: true, result } | { ok: false, reason }instead ofT | null. The reason is derived from the response: 503 isplugin-disabled,handler_error/not_pairedisnot-paired, anything else (fetch threw, non-JSON, unknown shape) isunavailable. The gate path returnsno-credentialwhen the app has none,unauthorizedwhen the gate refuses the credential (still callsonUnauthorized),unavailableotherwise. New required callbackonSkipped(reason)fires for every skipped sync next toonServers. The log line now names the reason and is written once per failure streak plus once when the reason changes.apps/desktop/src/main.ts: stores the reason inconnectServerSyncSkipReason, clears it inonServers, and callsrefreshApplicationMenu()fromonSkippedbecause Electron menus are immutable once built. The menu gets the reason only whenlistMenuConnectServers()is empty, so a persisted Connect selection that is still listed gets no note under it.apps/desktop/src/menu.ts:InstallApplicationMenuArgs.connectServersSkipReason: ConnectServerSyncSkipReason | null(required, not optional). A non-null reason renders one disabled row after the server radio items:No Connect servers — sign in to bb Connect/… Connect not paired on This Mac/… Connect plugin disabled/… sign in to bb Connect again/… could not reach bb Connect.No wire change between server and host daemon; the desktop to local-server RPC request is unchanged, only the parse of its failure body. No CLI or doc surfaces.
Deviation from the reporter's prototype (
Joesirven/bb@prototype/connect-server-list-skip-reason, no PR): the reason is pushed through a callback that rebuilds the menu, instead of agetSkipReason()polled at build time, so the row appears after the sync that produced it rather than after the next unrelated rebuild. Plugin-disabled and not-paired are told apart. The reason is set from the outcome, never before the fetch resolves. No clickable "Sign in to bb Connect…" item: that is a product decision and the issue asked for the disabled row as the minimum.Relation to #1494 / #2161: in the reporter's exact startup flow (saved custom target that no longer answers)
applyServerTarget()rejects onloadURLbefore the startupsyncNow()runs, so the first sync fires frommenu-will-showand the row shows from the second open of the menu. With #2161 the startup sync is reached and the row is there on the first open. This PR does not touch that flow.How you verified
Tests (
apps/desktop/test/connect-server-sync.test.ts,apps/desktop/test/menu.test.ts). Withgit checkout origin/main -- apps/desktop/src/connect-server-sync.ts apps/desktop/src/menu.ts apps/desktop/src/main.tsand the new tests:Tests 7 failed | 8 passed (15), includingOn this branch the same files pass (
Tests 15 passed (15)).pnpm exec turbo run typecheck test --filter=@bb/desktop --forceon the committed tree (git status --porcelainempty):Tasks: 5 successful, 5 total,Test Files 34 passed (34),Tests 224 passed (224).Manual: rendered the real
menu.tsinside Electron 41 under Xvfb with the report's harness, using theserversarraymain.tsproduces for the reporter's state (saved custom target, no local runtime, no credential). Before:This Mac | old-host.tailnet.ts.net:38886 | <separator> | Set Server URL…. After, withconnectServersSkipReason: "no-credential"asmain.tsnow passes it after the skipped sync:This Mac | old-host.tailnet.ts.net:38886 | No Connect servers — sign in to bb Connect | <separator> | Set Server URL…, the new row greyed out and not clickable.The server-side shapes the parser matches were checked against
apps/server/src/routes/plugins.ts(503 + stringerrorfor a plugin that is not running) andapps/server/src/services/plugins/plugin-service.ts+plugins/connect/src/rpc.ts({ code: "handler_error", message: error.message }where the handler rethrowsConnectListError.code), and match the report's live probe.Fixes #1753
Independent verification
Checked out
d4d3412ef(origin/mainis an ancestor;mergeable: MERGEABLE) in a fresh worktree, read the issue and the report first, and verified the wire shapes the new parser matches againstapps/server/src/routes/plugins.ts(503 + stringerrorfornot-running),plugin-service.ts({ code: "handler_error", message }with the raw thrown message) andplugins/connect/src/rpc.ts(throw new Error(error.code)forConnectListError).Fail-before / pass-after:
pnpm exec turbo run typecheck test --filter=@bb/desktop --forceon the clean committed tree:Tasks: 5 successful, 5 total,Test Files 34 passed (34),Tests 224 passed (224).Live wire check (own dev instance, not mocks): ran the branch's
fetchConnectAccountServers+createConnectServerSyncwithtsxagainst the real local server. Connect enabled but unpaired (HTTP 500{"code":"handler_error","message":"not_paired"}) ->onSkipped(["not-paired"]);bb plugin disable connect(HTTP 503) ->onSkipped(["plugin-disabled"]); closed port ->onSkipped(["unavailable"]). One log line each.Repro on the fixed branch: bundled the branch's real
connect-server-sync.ts+menu.tsinto Electron 41 under Xvfb, wiredonSkipped/onServersto rebuild the application menu the waymain.tsdoes, and firedonListRequested()(themenu-will-showtrigger, the only one reached in the reporter's flow). Before the sync:This Mac | old-host.tailnet.ts.net:38886 | <separator> | Set Server URL…. After:This Mac | old-host.tailnet.ts.net:38886 | No Connect servers — sign in to bb Connect | <separator> | Set Server URL…, the new row greyed (enabled: false), 2 menu builds. Same harness with the live dev server as the local runtime and the plugin disabled:This Mac | No Connect servers — Connect plugin disabled | <separator> | Set Server URL…. No longer reproduces.CI: all required checks pass (Checks, Tests x6, Package Smoke ubuntu + macos-15, version check); iOS/Node-compat smoke skipped by path filter.
Residual risks (none blocking): every desktop user whose bundled server is not paired to Connect now sees the greyed
Connect not paired on This Macrow in Window > Server, which is the behaviour the issue asks for but is visible beyond the reporter's case;onSkippedrebuilds the menu on every skipped sync (every 10 min and on throttled menu open), mirroring the existingonServerspath; after switching targets the previous reason can show for the sub-second window until the new sync completes;main.tswiring is verified by reading plus the harness above, not by a unit test. The startup sync is still not reached when the saved custom target is dead (#1494 / #2161), so in that exact flow the row appears from the second open of the menu.