hermes-agent/apps/desktop/electron
张豪杰 1535c114c9 test(desktop): cover connection.json owner-only mode end to end
The helpers were tested; nothing proved main.ts called them. Reverting both
call sites and both imports in readDesktopConnectionConfig /
writeDesktopConnectionConfig left the whole suite green (947 passed / 2
skipped, tsc 0, eslint clean, e2e 1 passed 1 skipped) while connection.json
went back to 0644 — the user-visible fix this PR promises was untested.

The e2e spec could not catch it by construction: it asserts the ENCRYPTION
contract with a raw-bytes scan, and safeStorage keeps the token opaque
regardless of the file's mode, so a 0644 file passes that scan every time.
There was no mode assertion anywhere in e2e/.

Adds the missing third contract — unreadable by other local accounts — on all
three paths that can produce the file:

- write: assert the mode of the artifact test 1 already proves the app wrote.
- read, valid file: seed the app's own encrypted connection.json back to 0644
  and assert launch tightens it. Scoped to the MODE only, so it is independent
  of the still-deferred plaintext migration — the fixture's token is already
  ciphertext, so nothing re-encrypts, no #62319 opt-in marker is involved, and
  no rotation guidance is owed.
- read, corrupt file: a truncated file still holds the token bytes and throws
  into the swallowing catch, so it would be the one file never tightened. This
  is the only test that distinguishes the chmod's placement relative to the
  parse.

Also moves the tighten above JSON.parse for exactly that reason, and pins the
cache invariant the placement depends on: the tighten must be a chmod, not a
rewrite, because it sits inside the function whose cache keys on mtimeMs.

Asserted as `mode & 0o077 === 0` rather than `=== 0o600` to avoid a
change-detector, and skipped on win32, where chmod maps to the read-only bit
and the fix deliberately no-ops (ACLs are PR #77527).

Every assertion was mutation-tested: reverting the full wiring fails all three;
reverting only the write path fails only the write test; deleting only the
tighten-on-read fails only the two read tests; moving the tighten below the
parse fails only the corrupt test; making the tighten a rewrite instead of a
chmod fails the mtime assertions. Bundle greps confirmed each mutation reached
dist/electron-main.mjs before the run.

(cherry picked from commit 99cfc16e7c)
2026-08-12 22:38:17 -07:00
..
active-runtime-state.test.ts fix(desktop): launch a usable active runtime without a bootstrap marker 2026-07-26 16:12:14 -05:00
active-runtime-state.ts fix(desktop): launch a usable active runtime without a bootstrap marker 2026-07-26 16:12:14 -05:00
backend-child.ts fix(desktop): reap orphaned serve backends via parent-death watchdog + group-kill 2026-08-10 17:02:56 -07:00
backend-command.test.ts test(desktop): move node tests to vitest as well 2026-07-13 17:22:17 -04:00
backend-command.ts cleanup(desktop): remove 'use strict' in ts & mjs 2026-07-13 17:22:17 -04:00
backend-connection-state.test.ts test(desktop): port backend-connection-state test to vitest 2026-07-16 14:55:58 -04:00
backend-connection-state.ts fix(desktop): ignore stale backend exits 2026-07-16 14:53:11 -04:00
backend-env.test.ts fmt(js): `npm run fix` on merge (#76547) 2026-08-02 03:33:09 +00:00
backend-env.ts fix(desktop,install): keep bundled Node ahead of system Node on Windows 2026-08-01 20:09:35 -04:00
backend-health.test.ts fmt(js): `npm run fix` on merge (#71740) 2026-07-26 04:11:26 +00:00
backend-health.ts fix(desktop): read a readiness-probe 401 by whether it was credentialed 2026-07-25 21:52:26 -05:00
backend-probes.test.ts fix(desktop): raise backend probe timeout and retry on timeout 2026-07-29 13:59:11 +05:30
backend-probes.ts fix(desktop): widen probe-budget fix to sibling boot-path probes 2026-07-29 16:52:53 +05:30
backend-ready.test.ts test(desktop): move node tests to vitest as well 2026-07-13 17:22:17 -04:00
backend-ready.ts cleanup(desktop): lint&fmt all 2026-07-13 17:22:17 -04:00
backend-start-failure.test.ts fix(desktop): latch a confirmed remote reauth failure so the overlay stays clickable 2026-07-25 21:52:45 -05:00
backend-start-failure.ts fix(desktop): latch a confirmed remote reauth failure so the overlay stays clickable 2026-07-25 21:52:45 -05:00
bootstrap-platform.test.ts fmt(js): `npm run fix` on merge (#85010) 2026-08-13 03:33:45 +00:00
bootstrap-platform.ts feat(desktop): auto-detect Linux keychain backend for secure token storage 2026-07-14 10:24:15 -04:00
bootstrap-repair-guard.test.ts fix(desktop): break renderer-led reinstall loop on transient backend stalls 2026-07-31 22:33:53 -07:00
bootstrap-repair-guard.ts fmt(js): `npm run fix` on merge (#76404) 2026-08-01 20:45:40 +00:00
bootstrap-runner.test.ts fmt(js): `npm run fix` on merge (#67749) 2026-07-19 23:42:14 +00:00
bootstrap-runner.ts fmt(js): `npm run fix` on merge (#67749) 2026-07-19 23:42:14 +00:00
connection-apply.test.ts style(desktop): satisfy merged eslint/prettier config 2026-07-20 23:01:49 +02:00
connection-apply.ts feat(desktop): add "Connect to existing Hermes" option to first-run onboarding 2026-07-24 12:55:06 -05:00
connection-config.test.ts fix(desktop): reject reserved remote profile names 2026-08-01 14:30:16 -07:00
connection-config.ts fix(desktop): reject reserved remote profile names 2026-08-01 14:30:16 -07:00
crash-forensics.test.ts fix(desktop): record main-process faults in desktop.log 2026-07-27 13:41:59 -05:00
crash-forensics.ts fix(desktop): record main-process faults in desktop.log 2026-07-27 13:41:59 -05:00
dashboard-token.test.ts test(desktop): move node tests to vitest as well 2026-07-13 17:22:17 -04:00
dashboard-token.ts cleanup(desktop): `npm run fix` for fmtting 2026-07-08 16:24:16 -07:00
desktop-electron-pin.test.ts fmt(js): `npm run fix` on merge (#65912) 2026-07-16 19:57:39 +00:00
desktop-installation.test.ts style(desktop): satisfy merged eslint/prettier config 2026-07-20 23:01:49 +02:00
desktop-installation.ts style(desktop): satisfy merged eslint/prettier config 2026-07-20 23:01:49 +02:00
desktop-uninstall.test.ts test(desktop): move node tests to vitest as well 2026-07-13 17:22:17 -04:00
desktop-uninstall.ts cleanup(desktop): lint&fmt all 2026-07-13 17:22:17 -04:00
dev-cdp.test.ts feat(desktop): on by default for dev-server runs 2026-07-27 23:52:33 -05:00
dev-cdp.ts feat(desktop): on by default for dev-server runs 2026-07-27 23:52:33 -05:00
embed-referer.ts feat(desktop): ts-ify everything 2026-07-08 16:24:16 -07:00
entitlements.mac.inherit.plist build(desktop): declare camera usage for signed macOS builds 2026-07-28 13:40:44 -05:00
entitlements.mac.plist build(desktop): declare camera usage for signed macOS builds 2026-07-28 13:40:44 -05:00
event-dedupe.test.ts fix(desktop): de-dupe cross-window cues so peers don't spam 2026-07-20 18:33:14 -05:00
event-dedupe.ts refactor(desktop): tidy the cross-window deduper 2026-07-20 18:36:05 -05:00
find-git-bash.test.ts style(desktop): apply eslint/prettier conventions to find-git-bash module 2026-07-23 17:59:58 -07:00
find-git-bash.ts style(desktop): apply eslint/prettier conventions to find-git-bash module 2026-07-23 17:59:58 -07:00
find-in-page.test.ts fmt(js): `npm run fix` on merge (#72411) 2026-07-27 02:52:53 +00:00
find-in-page.ts fmt(js): `npm run fix` on merge (#72411) 2026-07-27 02:52:53 +00:00
first-run-setup-gate.test.ts feat(desktop): add "Connect to existing Hermes" option to first-run onboarding 2026-07-24 12:55:06 -05:00
first-run-setup-gate.ts feat(desktop): add "Connect to existing Hermes" option to first-run onboarding 2026-07-24 12:55:06 -05:00
first-run-setup-main-process.test.ts feat(desktop): add "Connect to existing Hermes" option to first-run onboarding 2026-07-24 12:55:06 -05:00
fs-read-dir.test.ts test(desktop): move node tests to vitest as well 2026-07-13 17:22:17 -04:00
fs-read-dir.ts feat(desktop): bridge WSL paths for a Windows host + WSL backend 2026-07-12 05:32:54 -04:00
gateway-ws-probe.test.ts test(desktop): move node tests to vitest as well 2026-07-13 17:22:17 -04:00
gateway-ws-probe.ts cleanup(desktop): lint&fmt all 2026-07-13 17:22:17 -04:00
git-repo-scan.test.ts fmt(js): `npm run fix` on merge (#68681) 2026-07-21 14:28:28 +00:00
git-repo-scan.ts fmt(js): `npm run fix` on merge (#68681) 2026-07-21 14:28:28 +00:00
git-review-ops.test.ts fix(desktop): bound review workspace scans 2026-08-03 00:08:30 +05:30
git-review-ops.ts feat(desktop): paste a PR review comment as structured composer context 2026-08-12 22:48:00 -05:00
git-root.test.ts test(desktop): move node tests to vitest as well 2026-07-13 17:22:17 -04:00
git-root.ts cleanup(desktop): `npm run fix` for fmtting 2026-07-08 16:24:16 -07:00
git-worktree-ops.test.ts fmt(js): `npm run fix` on merge (#79505) 2026-08-05 16:32:54 +00:00
git-worktree-ops.ts feat(desktop): let convert-a-branch reach remote branches too 2026-08-05 11:43:09 -04:00
handoff-result.test.ts fmt(js): `npm run fix` on merge (#84193) 2026-08-12 01:41:34 +00:00
handoff-result.ts fix(update): exempt manual results from the hand-off freshness window 2026-08-11 17:03:00 -05:00
hardening.test.ts fix(desktop): create connection.json owner-only 2026-08-12 22:38:17 -07:00
hardening.ts fix(desktop): create connection.json owner-only 2026-08-12 22:38:17 -07:00
hud-cursor.test.ts fix(desktop): keep the HUD clickable on Linux 2026-08-08 22:15:24 -05:00
hud-cursor.ts fix(desktop): keep the HUD clickable on Linux 2026-08-08 22:15:24 -05:00
hud-snap-shortcut.test.ts feat(desktop): snap HUD to cursor with global ⌘⇧G 2026-08-10 05:21:05 -05:00
hud-snap-shortcut.ts fmt(js): `npm run fix` on merge (#83132) 2026-08-10 10:44:00 +00:00
hud-snap.test.ts feat(desktop): snap HUD to cursor with global ⌘⇧G 2026-08-10 05:21:05 -05:00
hud-snap.ts fmt(js): `npm run fix` on merge (#83132) 2026-08-10 10:44:00 +00:00
hud-url.test.ts fix(desktop): open HUD mode on the focused conversation's profile (#82325) 2026-08-09 09:10:59 +00:00
hud-url.ts fix(desktop): open HUD mode on the focused conversation's profile (#82325) 2026-08-09 09:10:59 +00:00
hyprland.test.ts fmt(js): `npm run fix` on merge (#82417) 2026-08-09 09:51:41 +00:00
hyprland.ts feat(desktop): read the window below through Hyprland's IPC (#82226) 2026-08-09 04:43:10 -05:00
link-title-window.test.ts test(desktop): move node tests to vitest as well 2026-07-13 17:22:17 -04:00
link-title-window.ts perf(desktop): let the hidden link-title window throttle 2026-07-31 00:38:11 -05:00
main-window-lifecycle.test.ts fmt(js): `npm run fix` on merge (#65912) 2026-07-16 19:57:39 +00:00
main-window-lifecycle.ts fix(desktop): restore closed main window on second launch (#64800) 2026-07-16 15:33:38 -04:00
main.ts test(desktop): cover connection.json owner-only mode end to end 2026-08-12 22:38:17 -07:00
native-auth-decisions.test.ts fix(desktop): name the readiness-probe auth and password-gateway guard decisions 2026-07-25 21:52:40 -05:00
native-auth-decisions.ts fix(desktop): name the readiness-probe auth and password-gateway guard decisions 2026-07-25 21:52:40 -05:00
native-oauth-login.test.ts fmt(js): `npm run fix` on merge (#69503) 2026-07-22 16:30:14 +00:00
native-oauth-login.ts fmt(js): `npm run fix` on merge (#69503) 2026-07-22 16:30:14 +00:00
native-oauth.test.ts fmt(js): `npm run fix` on merge (#75517) 2026-07-31 16:22:58 +00:00
native-oauth.ts fix(desktop): restore native OAuth tokens after restart 2026-07-31 10:16:21 -04:00
native-token-store.test.ts fix(desktop): redact gateway credentials from token logs 2026-07-31 10:16:21 -04:00
native-token-store.ts fix(desktop): redact gateway credentials from token logs 2026-07-31 10:16:21 -04:00
oauth-net-request.test.ts test(desktop): move node tests to vitest as well 2026-07-13 17:22:17 -04:00
oauth-net-request.ts cleanup(desktop): `npm run fix` for fmtting 2026-07-08 16:24:16 -07:00
power-save.test.ts feat(desktop): keep-computer-awake toggle + System settings section 2026-07-20 11:50:22 -05:00
power-save.ts feat(desktop): keep-computer-awake toggle + System settings section 2026-07-20 11:50:22 -05:00
preload.ts feat(desktop): paste a PR review comment as structured composer context 2026-08-12 22:48:00 -05:00
primary-backend-startup.test.ts feat(desktop): add "Connect to existing Hermes" option to first-run onboarding 2026-07-24 12:55:06 -05:00
primary-backend-startup.ts fmt(js): `npm run fix` on merge (#75582) 2026-07-31 18:54:27 +00:00
primary-connection-rehome.ts feat(desktop): add "Connect to existing Hermes" option to first-run onboarding 2026-07-24 12:55:06 -05:00
profile-delete-routing.test.ts test(desktop): move node tests to vitest as well 2026-07-13 17:22:17 -04:00
profile-delete-routing.ts cleanup(desktop): remove 'use strict' in ts & mjs 2026-07-13 17:22:17 -04:00
profile-session-routing.test.ts fix(desktop): preserve OAuth sessions in sidebar 2026-07-27 13:41:56 -05:00
profile-session-routing.ts fix(desktop): preserve OAuth sessions in sidebar 2026-07-27 13:41:56 -05:00
quick-entry.test.ts feat(desktop): quick-entry window — global hotkey capture to any session 2026-07-26 17:48:19 -07:00
quick-entry.ts fmt(js): `npm run fix` on merge (#75582) 2026-07-31 18:54:27 +00:00
quit-guard.test.ts feat(desktop): confirm before quitting with a turn in flight 2026-07-27 15:47:57 -05:00
quit-guard.ts feat(desktop): confirm before quitting with a turn in flight 2026-07-27 15:47:57 -05:00
remote-lifecycle.test.ts fix(desktop-ssh): raise remote backend file limit 2026-08-10 18:04:59 -07:00
remote-lifecycle.ts fix(desktop-ssh): raise remote backend file limit 2026-08-10 18:04:59 -07:00
remote-liveness.test.ts fix(desktop): record main-process faults in desktop.log 2026-07-27 13:41:59 -05:00
remote-liveness.ts fix(desktop): retire pooled remote backends whose host went away 2026-07-27 13:41:59 -05:00
renderer-log.test.ts fmt(js): `npm run fix` on merge (#83539) 2026-08-11 00:20:02 +00:00
renderer-log.ts fmt(js): `npm run fix` on merge (#83539) 2026-08-11 00:20:02 +00:00
session-windows.test.ts perf(desktop): scope background-throttling opt-out to live streaming 2026-07-31 00:38:11 -05:00
session-windows.ts perf(desktop): scope background-throttling opt-out to live streaming 2026-07-31 00:38:11 -05:00
spawn-helper-perms.test.ts fix(desktop): resolve unpacked spawn-helper before chmod (#71171) 2026-07-25 15:19:29 -04:00
spawn-helper-perms.ts fix(desktop): resolve unpacked spawn-helper before chmod (#71171) 2026-07-25 15:19:29 -04:00
ssh-bootstrap-coordinator.test.ts fix(desktop): map SSH profiles to remote profiles 2026-08-01 14:30:16 -07:00
ssh-bootstrap-coordinator.ts fix(desktop): map SSH profiles to remote profiles 2026-08-01 14:30:16 -07:00
ssh-config.test.ts style(desktop): satisfy merged eslint/prettier config 2026-07-20 23:01:49 +02:00
ssh-config.ts style(desktop): satisfy merged eslint/prettier config 2026-07-20 23:01:49 +02:00
ssh-connection.test.ts style(desktop): satisfy merged eslint/prettier config 2026-07-20 23:01:49 +02:00
ssh-connection.ts style(desktop): satisfy merged eslint/prettier config 2026-07-20 23:01:49 +02:00
stream-throttle.test.ts perf(desktop): scope background-throttling opt-out to live streaming 2026-07-31 00:38:11 -05:00
stream-throttle.ts perf(desktop): scope background-throttling opt-out to live streaming 2026-07-31 00:38:11 -05:00
titlebar-overlay-width.test.ts test(desktop): move node tests to vitest as well 2026-07-13 17:22:17 -04:00
titlebar-overlay-width.ts cleanup(desktop): `npm run fix` for fmtting 2026-07-08 16:24:16 -07:00
update-count.test.ts test(desktop): move node tests to vitest as well 2026-07-13 17:22:17 -04:00
update-count.ts cleanup(desktop): `npm run fix` for fmtting 2026-07-08 16:24:16 -07:00
update-gate.test.ts fix(desktop): gate backend respawns on updateInFlight, not just the update marker (#73822) 2026-07-28 23:53:25 -07:00
update-gate.ts fix(desktop): gate backend respawns on updateInFlight, not just the update marker (#73822) 2026-07-28 23:53:25 -07:00
update-marker.test.ts fix(desktop): refuse a second update hand-off while one is already live 2026-08-01 10:47:45 -07:00
update-marker.ts fix(desktop): refuse a second update hand-off while one is already live 2026-08-01 10:47:45 -07:00
update-remote.test.ts test(desktop): move node tests to vitest as well 2026-07-13 17:22:17 -04:00
update-remote.ts cleanup(desktop): lint&fmt all 2026-07-13 17:22:17 -04:00
updater-process.test.ts fix(update): posix hand-off truth ordering, relaunch-gate port, JSON escaping 2026-08-11 11:07:17 -05:00
updater-process.ts fix(update): posix hand-off truth ordering, relaunch-gate port, JSON escaping 2026-08-11 11:07:17 -05:00
venv-blocker-scan.test.ts fmt(js): `npm run fix` on merge (#73666) 2026-07-28 21:55:38 +00:00
venv-blocker-scan.ts fmt(js): `npm run fix` on merge (#73666) 2026-07-28 21:55:38 +00:00
vscode-marketplace.test.ts test(desktop): move node tests to vitest as well 2026-07-13 17:22:17 -04:00
vscode-marketplace.ts cleanup(desktop): `npm run fix` for fmtting 2026-07-08 16:24:16 -07:00
wake-indicator-window.ts fix(desktop): single-owner console capture + HUD lifecycle coverage 2026-08-10 19:00:19 -07:00
wake-indicator.test.ts fix(desktop): attach renderer-lifecycle diagnostics to all BrowserWindow instances (#81290) 2026-08-10 19:00:19 -07:00
wake-indicator.ts feat(desktop): add notch wake indicator 2026-08-01 14:30:11 -07:00
window-below.test.ts feat(desktop): read the window below through Hyprland's IPC (#82226) 2026-08-09 04:43:10 -05:00
window-below.ts feat(desktop): read the window below through Hyprland's IPC (#82226) 2026-08-09 04:43:10 -05:00
window-renderer-lifecycle.test.ts fmt(js): `npm run fix` on merge (#83609) 2026-08-11 02:09:04 +00:00
window-renderer-lifecycle.ts fmt(js): `npm run fix` on merge (#83609) 2026-08-11 02:09:04 +00:00
window-reveal.test.ts fix(desktop): reveal every window after a missed ready event, not just the main one 2026-08-08 16:51:44 -05:00
window-reveal.ts fix(desktop): reveal every window after a missed ready event, not just the main one 2026-08-08 16:51:44 -05:00
window-state.test.ts fix(desktop): persist window geometry on Linux 2026-08-08 22:13:08 -05:00
window-state.ts fix(desktop): say why read_window_below cannot see the windows 2026-08-08 22:17:38 -05:00
windows-child-options.test.ts fix(desktop): reap orphaned serve backends via parent-death watchdog + group-kill 2026-08-10 17:02:56 -07:00
windows-child-options.ts test(desktop): extract hiddenWindowsChildOptions + stopBackendChild for real unit tests 2026-07-13 17:22:17 -04:00
windows-hermes-path.test.ts fmt(js): `npm run fix` on merge (#65229) 2026-07-15 21:40:56 +00:00
windows-hermes-path.ts fmt(js): `npm run fix` on merge (#65229) 2026-07-15 21:40:56 +00:00
windows-remote-lifecycle.test.ts fix(desktop): map SSH profiles to remote profiles 2026-08-01 14:30:16 -07:00
windows-remote-lifecycle.ts fix(desktop): map SSH profiles to remote profiles 2026-08-01 14:30:16 -07:00
windows-remote-live.test.ts style(desktop): satisfy merged eslint/prettier config 2026-07-20 23:01:49 +02:00
windows-sandbox-fallback.test.ts fix(desktop): harden Windows sandbox fallback against false-positive sandbox loss 2026-07-18 02:26:19 -07:00
windows-sandbox-fallback.ts fix(desktop): harden Windows sandbox fallback against false-positive sandbox loss 2026-07-18 02:26:19 -07:00
windows-system-ca.test.ts fix(desktop): trust Windows system CAs for remote gateways (#66304) 2026-07-17 18:55:34 -04:00
windows-system-ca.ts fmt(js): `npm run fix` on merge (#66731) 2026-07-18 04:56:56 +00:00
windows-user-env.test.ts test(desktop): move node tests to vitest as well 2026-07-13 17:22:17 -04:00
windows-user-env.ts cleanup(desktop): lint&fmt all 2026-07-13 17:22:17 -04:00
workspace-cwd.test.ts test(desktop): move node tests to vitest as well 2026-07-13 17:22:17 -04:00
workspace-cwd.ts cleanup(desktop): `npm run fix` for fmtting 2026-07-08 16:24:16 -07:00
wsl-clipboard-image.test.ts test(desktop): move node tests to vitest as well 2026-07-13 17:22:17 -04:00
wsl-clipboard-image.ts cleanup(desktop): `npm run fix` for fmtting 2026-07-08 16:24:16 -07:00
wsl-path-bridge.test.ts fmt(js): `npm run fix` on merge (#65229) 2026-07-15 21:40:56 +00:00
wsl-path-bridge.ts fmt(js): `npm run fix` on merge (#65229) 2026-07-15 21:40:56 +00:00
zoom.test.ts feat(desktop): add notch wake indicator 2026-08-01 14:30:11 -07:00
zoom.ts feat(desktop): HUD mode window and its session handoff 2026-08-08 01:38:57 -05:00