hermes-agent/apps/desktop/electron
Ben Barclay 49423f8084 fix(desktop-auth): make RFC 8252 native login work end-to-end at runtime
The native-app (RFC 8252) login passed its unit tests but failed in real
Electron runtime — the tests mocked the exact seams that were broken. Four
runtime defects, each proven against a live gated gateway:

1. Lockfile drift: apps/desktop declared @assistant-ui/react +
   @assistant-ui/react-streamdown but package-lock.json didn't place them, so
   `npm ci` (CI + every fresh checkout) failed to install them → Vite
   "Failed to resolve @assistant-ui/react". Reconcile the lockfile.

2. Double JSON encoding: postJsonNoAuth pre-JSON.stringify'd the body before
   fetchJson (which stringifies again), so /auth/native/token received a JSON
   string, not an object → gateway 422 "Input should be a valid dictionary" →
   native login silently fell back to the embedded webview.

3. Cookie-only liveness gate: buildRemoteConnection (and the Settings
   connected indicator) treated "signed in" as "has OAuth cookie". The native
   flow stores a bearer and sets no cookie, so a completed native login looped
   the UI into needsOauthLogin. Accept native token OR cookie.

4. Cookie-only REST path: the hermes:api handler routed oauth-mode REST through
   the cookie partition only. A cookieless native session → 401 no_cookie on
   every API call. Prefer the native bearer (with transparent refresh), else
   cookie — mirroring mintGatewayWsTicket, which was already bearer-aware.

The three decision points (2–4) are extracted into a pure
native-auth-decisions.ts with regression tests, since the mocked flow tests
could not catch them. Verified live: system-browser login → cookieless bearer
→ connected chat, no embedded webview.
2026-07-22 06:50:50 -07:00
..
backend-child.ts
…
backend-command.test.ts
…
backend-command.ts
…
backend-connection-state.test.ts
…
backend-connection-state.ts
…
backend-env.test.ts
…
backend-env.ts
…
backend-probes.test.ts
…
backend-probes.ts
…
backend-ready.test.ts
…
backend-ready.ts
…
backend-start-failure.test.ts
…
backend-start-failure.ts
…
bootstrap-platform.test.ts
…
bootstrap-platform.ts
…
bootstrap-runner.test.ts
…
bootstrap-runner.ts
…
connection-apply.test.ts
…
connection-apply.ts
…
connection-config.test.ts
…
connection-config.ts
…
dashboard-token.test.ts
…
dashboard-token.ts
…
desktop-electron-pin.test.ts
…
desktop-installation.test.ts
…
desktop-installation.ts
…
desktop-uninstall.test.ts
…
desktop-uninstall.ts
…
embed-referer.ts
…
entitlements.mac.inherit.plist
…
entitlements.mac.plist
…
event-dedupe.test.ts
…
event-dedupe.ts
…
fs-read-dir.test.ts
…
fs-read-dir.ts
…
gateway-ws-probe.test.ts
…
gateway-ws-probe.ts
…
git-repo-scan.test.ts
…
git-repo-scan.ts
…
git-review-ops.test.ts
…
git-review-ops.ts
…
git-root.test.ts
…
git-root.ts
…
git-worktree-ops.test.ts
…
git-worktree-ops.ts
…
hardening.test.ts
…
hardening.ts
…
link-title-window.test.ts
…
link-title-window.ts
…
main-window-lifecycle.test.ts
…
main-window-lifecycle.ts
…
main.ts
…
native-auth-decisions.test.ts
…
native-auth-decisions.ts
…
native-oauth-login.test.ts
…
native-oauth-login.ts
…
native-oauth.test.ts
…
native-oauth.ts
…
oauth-net-request.test.ts
…
oauth-net-request.ts
…
power-save.test.ts
…
power-save.ts
…
preload.ts
…
profile-delete-routing.test.ts
…
profile-delete-routing.ts
…
remote-lifecycle.test.ts
…
remote-lifecycle.ts
…
remote-liveness.test.ts
…
remote-liveness.ts
…
session-windows.test.ts
…
session-windows.ts
…
spawn-helper-perms.test.ts
…
spawn-helper-perms.ts
…
ssh-bootstrap-coordinator.test.ts
…
ssh-bootstrap-coordinator.ts
…
ssh-config.test.ts
…
ssh-config.ts
…
ssh-connection.test.ts
…
ssh-connection.ts
…
titlebar-overlay-width.test.ts
…
titlebar-overlay-width.ts
…
update-count.test.ts
…
update-count.ts
…
update-marker.test.ts
…
update-marker.ts
…
update-rebuild.test.ts
…
update-rebuild.ts
…
update-relaunch.test.ts
…
update-relaunch.ts
…
update-remote.test.ts
…
update-remote.ts
…
updater-process.test.ts
…
updater-process.ts
…
vscode-marketplace.test.ts
…
vscode-marketplace.ts
…
window-state.test.ts
…
window-state.ts
…
windows-child-options.test.ts
…
windows-child-options.ts
…
windows-hermes-path.test.ts
…
windows-hermes-path.ts
…
windows-remote-lifecycle.test.ts
…
windows-remote-lifecycle.ts
…
windows-remote-live.test.ts
…
windows-sandbox-fallback.test.ts
…
windows-sandbox-fallback.ts
…
windows-system-ca.test.ts
…
windows-system-ca.ts
…
windows-user-env.test.ts
…
windows-user-env.ts
…
workspace-cwd.test.ts
…
workspace-cwd.ts
…
wsl-clipboard-image.test.ts
…
wsl-clipboard-image.ts
…
wsl-path-bridge.test.ts
…
wsl-path-bridge.ts
…
zoom.test.ts
…
zoom.ts
…