Skip to content

fix(shell): poll for the reboot result after reusing a gh account#109

Merged
stuffbucket merged 1 commit into
mainfrom
fix/gh-reuse-poll-after-reboot
Jun 11, 2026
Merged

fix(shell): poll for the reboot result after reusing a gh account#109
stuffbucket merged 1 commit into
mainfrom
fix/gh-reuse-poll-after-reboot

Conversation

@stuffbucket

Copy link
Copy Markdown
Owner

Fixes the stuck-UI you hit signing in as bstucker_microsoft via "Reuse a GitHub CLI account".

Root cause (two things)

  1. The UI never recovered (this fix). useGhAccount fired restart_sidecar then did nothing. Nothing re-drives auth status after a reboot (the unauthenticated state doesn't poll), so the row stayed on "Signing in…" forever — even if the reboot had worked.
  2. The reboot didn't fire in your running app:dev: the shell process was stale relative to the rebuilt binary, so the restart_sidecar IPC silently failed (safeInvoke swallows it). The sidecar stayed on its pre-import boot; the freshly-written token sat unused. (A fresh app:dev gets a clean shell with the command.)

The fix

After the reboot, poll auth-status until the sidecar reports its new state, then resolve the UI:

  • authenticated → render it (done);
  • error / back-up-but-unauthenticated → recover the row + explain (account may lack Copilot on this host);
  • restart never fired → after ~20s, recover the row + "the proxy may not have restarted."

A failed poll mid-reboot is expected and signals the restart did happen — used to distinguish "rebooted but not signed in" from "never rebooted." The UI can no longer stay stuck.

Verified

  • The token/boot path is sound: I booted an isolated proxy from a copy of the imported token → authenticated (login + models fetched). So once a reboot fires, sign-in completes.
  • Shell tsc clean.

Note (separate, pre-existing)

Both this and #106's sign-out lean on restart_sidecar; it's only ever been validated via the proxy-side --replace mechanism, not a live Tauri kill+respawn (macOS WKWebView has no WebDriver to drive it). Worth a manual app:dev confirm that restart_sidecar actually bounces the sidecar — the stale-shell incident suggests we should also verify the real kill+respawn path.

The gh-reuse success path fired restart_sidecar then did nothing — nothing
re-drives auth status after the reboot (the unauthenticated state doesn't
poll), so the row stayed stuck on 'Signing in…' forever. Now it polls
auth-status until the rebooted sidecar reports its state:
- authenticated → render it (success);
- error, or back-up-but-unauthenticated → recover the row + explain (the
  account may lack Copilot on this host);
- restart never fired (e.g. invoke swallowed by safeInvoke / a stale dev
  shell) → after ~20s, recover the row + 'the proxy may not have restarted'.

A failed poll mid-reboot is expected and signals the restart actually
happened (distinguishes 'rebooted but not signed in' from 'never rebooted').
Recovery avoids a full re-render so the message isn't cleared by loadGhAccounts.

Verified separately: booting into an imported gho_ token authenticates
(login + models), so the token/boot path is sound — this closes the UI gap.
@stuffbucket stuffbucket merged commit f96c852 into main Jun 11, 2026
4 checks passed
@stuffbucket stuffbucket deleted the fix/gh-reuse-poll-after-reboot branch June 11, 2026 02:19
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