fix(desktop): the setup profile is never the profile Desktop launches into

The startup-profile heuristic picks the profile whose state.db is the most
recent and largest, and re-scores on every boot while active-profile.json is
heuristic-owned. Right after the first-run setup chat, the setup profile's
state.db is the freshest, so quitting during setup made every later launch
boot into the setup profile, where chats have only the setup toolsets. Skip
setup then "returned" to it, because the kickoff records the booted profile
as the one to go back to.

The setup profile (the one carrying .setup-profile.json) is no longer a
startup candidate. A heuristic-owned file that already names it is re-scored
on the next boot and repaired.
This commit is contained in:
alt-glitch
2026-10-07 08:33:02 +05:30
parent a175ddfeb4
commit 70f1ba1637

View File

@@ -209,10 +209,14 @@ export function decideMigration(
return { profile: best, _migrated: true }
}
// hermes_cli/profiles.py::SETUP_PROFILE_MARKER: the backend-made first-run setup profile. Its state.db is the
// freshest on the machine right after setup, so the recency heuristic would boot every later launch into it.
const SETUP_PROFILE_MARKER = '.setup-profile.json'
/**
* List named profile directory names under `profilesRoot`. A directory named
* `default` is accepted if present (unusual) but production default is not a
* child of this folder — see `withDefaultCandidate`.
* List named profile directory names under `profilesRoot`, minus the setup profile, which is never a startup
* profile. A directory named `default` is accepted if present (unusual) but production default is not a child
* of this folder — see `withDefaultCandidate`.
*/
export function listProfileDirs(deps: MigrationDeps): string[] {
let entries: Dirent[]
@@ -225,6 +229,7 @@ export function listProfileDirs(deps: MigrationDeps): string[] {
return entries
.filter(e => e.isDirectory() && (e.name === 'default' || deps.isValidProfileName(e.name)))
.filter(e => !deps.existsSync(`${deps.profilesRoot}/${e.name}/${SETUP_PROFILE_MARKER}`))
.map(e => e.name)
}