Commit Graph

5 Commits

Author SHA1 Message Date
hermes-seaeye[bot] 3ca096de5f fmt(js): npm run fix on merge (#100685)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2026-09-01 20:48:06 +00:00
Sergey Tiraspolsky f6c9cb7b90 fix(desktop): re-score heuristic active-profile.json pins
_migrated:true files were skipped on later boots, so #100576 installs
stayed stuck on the named profile. Re-evaluate those files only; leave
user-selected pins (no _migrated) alone. If default now wins, write
{profile:null} instead of pinning default.
2026-09-01 15:24:33 -04:00
Sergey Tiraspolsky c90f8e8cf6 fix(desktop): score default ~/.hermes/state.db in first-boot profile migration
First-boot migrateActiveProfileIfMissing only listed ~/.hermes/profiles/*
and scored profiles/<name>/state.db. Default's real DB is ~/.hermes/state.db,
so a tiny named profile could be pinned after an update.

Always candidate default, score/pid-check it at HERMES_HOME, and do not
write active-profile.json when the winner is default.

Fixes #100576
2026-09-01 15:24:33 -04:00
David Metcalfe 75f8ab2f87 style(desktop): satisfy eslint and prettier in profile migration
- curly: brace all single-line if statements in profile-migration.ts and
  profile-migration.test.ts (17 errors in CI check:lint)
- perfectionist/sort-imports: node:fs builtin import before vitest external
- padding-line-between-statements: blank lines after block statements
- prettier: normalize formatting (fmt script style) in the three touched files

All 967 electron project tests still pass.
2026-09-01 09:54:22 -07:00
David Metcalfe a0511fd884 refactor(desktop): extract pure active-profile migration helpers
Addresses teknium1's review (#64195) — the migration decision logic should
be unit-testable without Electron. Pull the ladder (legacy sticky file,
running-gateway scan, state.db heuristic) into pure helpers in a new
`profile-migration.ts` module, following the dep-injection pattern
already established by `profile-delete-routing.ts`.

The helpers take an injected `MigrationDeps` bag so tests can exercise
precedence, stale-PID rejection, fallback behavior, and the single-profile
case without touching `/proc`, `ps`, or the host filesystem. The default
profile is explicitly rejected from the legacy rung because the regex
matches `default` and accepting it would suppress the heuristic that is
the whole point of the migration.

The wrapper in main.ts is unchanged in behavior — the same `MigrationDeps`
fields get filled in from `fs`/`path` and `isHermesProcess`. The atomic
write + parent-dir-create that the wrapper performs matches
`writeActiveDesktopProfile`'s semantics so the migration produces a file
indistinguishable from a user-driven profile switch.

No production behavior change; pure code organization.

Tests added in a separate commit.
2026-09-01 09:54:22 -07:00