The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): a local rename moves the saved startup profile
alt-glitch6909c329713d
diff --git a/apps/desktop/electron/desktop-profile.test.ts b/apps/desktop/electron/desktop-profile.test.tsindex 6930a7d0c39..d3884ae023f 100644--- a/apps/desktop/electron/desktop-profile.test.ts+++ b/apps/desktop/electron/desktop-profile.test.ts@@ -238,3 +238,29 @@ test('a stored profile whose home is gone boots default instead of a missing --pfs.rmSync(root, { recursive: true, force: true })}})++test('a local rename moves the saved startup profile after its old home is gone', () => {+ const root = fs.mkdtempSync(path.join(os.tmpdir(), 'desktop-profile-rename-'))+ const target = path.join(root, 'active-profile.json')+ const profilesRoot = path.join(root, 'profiles')+ fs.mkdirSync(path.join(profilesRoot, 'work'), { recursive: true })+ const profileExists = (name: string) => fs.existsSync(path.join(profilesRoot, name))++ try {+ const preferences = createDesktopProfilePreferences(target, { profileExists })+ preferences.remember('work')+ // The backend has already renamed the home when the response comes back.+ fs.renameSync(path.join(profilesRoot, 'work'), path.join(profilesRoot, 'job'))++ preferences.afterProfileRequest(+ null,+ { method: 'PATCH', path: '/api/profiles/work', body: { new_name: 'job' } },+ { ok: true },+ 'local'+ )++ assert.equal(createDesktopProfilePreferences(target, { profileExists }).readActive(), 'job')+ } finally {+ fs.rmSync(root, { recursive: true, force: true })+ }+})diff --git a/apps/desktop/electron/desktop-profile.ts b/apps/desktop/electron/desktop-profile.tsindex 58141fe97f0..ed06697c525 100644--- a/apps/desktop/electron/desktop-profile.ts+++ b/apps/desktop/electron/desktop-profile.ts@@ -122,16 +122,18 @@ export function createDesktopProfilePreferences(}}- function readActive(): null | string {+ function readStored(): null | string {const value = read().profileconst profile = typeof value === 'string' ? value.trim() : ''- if (!DESKTOP_PROFILE_NAME_RE.test(profile)) {- return null- }+ return DESKTOP_PROFILE_NAME_RE.test(profile) ? profile : null+ }++ function readActive(): null | string {+ const profile = readStored()// A stored profile whose home is gone boots default: `--profile <missing>` would fail the backend.- return profile === 'default' || options.profileExists?.(profile) !== false ? profile : null+ return profile === 'default' || (profile && options.profileExists?.(profile) !== false) ? profile : null}function remember(name: unknown): null | string {@@ -161,7 +163,8 @@ export function createDesktopProfilePreferences(}function profileChanged(connectionId: null | string, oldName: string, newName: null | string, backendMode: string) {- if (backendMode === 'local' && readActive() === oldName) {+ // A finished rename or delete has already removed oldName's home, so match the saved name, not readActive.+ if (backendMode === 'local' && readStored() === oldName) {remember(newName || 'default')}