Compare commits

...
Author SHA1 Message Date
Hona b338d7a750 refactor(app): simplify settings migration 2026-08-25 03:45:40 +00:00
Hona 3680483b69 feat(app): queue follow-ups for new users 2026-08-25 03:43:44 +00:00
2 changed files with 33 additions and 2 deletions
+15
View File
@@ -0,0 +1,15 @@
import { describe, expect, test } from "bun:test"
import { migrateSettings } from "./model"
describe("settings migration", () => {
test("keeps steer for existing users without a follow-up preference", () => {
expect(migrateSettings({ general: { autoSave: true } })).toEqual({
general: { autoSave: true, followUpBehavior: "steer" },
})
})
test("preserves an explicit follow-up preference", () => {
const settings = { general: { followUpBehavior: "queue" } }
expect(migrateSettings(settings)).toBe(settings)
})
})
+18 -2
View File
@@ -128,7 +128,7 @@ const defaultSettings: Settings = {
showCustomAgents: false,
mobileTitlebarPosition: "top",
terminalPlacement: "side",
followUpBehavior: "steer",
followUpBehavior: "queue",
},
appearance: {
fontSize: 14,
@@ -167,7 +167,10 @@ export const { use: useSettings, provider: SettingsProvider } = createSimpleCont
name: "Settings",
gate: false,
init: () => {
const [store, setStore, , ready] = persisted("settings.v3", createStore<Settings>(defaultSettings))
const [store, setStore, , ready] = persisted(
{ key: "settings.v3", migrate: migrateSettings },
createStore<Settings>(defaultSettings),
)
const showFileTree = withFallback(() => store.general?.showFileTree, defaultSettings.general.showFileTree)
const showSearch = withFallback(() => store.general?.showSearch, defaultSettings.general.showSearch)
const showStatus = withFallback(() => store.general?.showStatus, defaultSettings.general.showStatus)
@@ -380,3 +383,16 @@ export const { use: useSettings, provider: SettingsProvider } = createSimpleCont
}
},
})
export function migrateSettings(value: unknown) {
if (!value || typeof value !== "object" || Array.isArray(value)) return value
const settings = value as Partial<Settings>
if (settings.general?.followUpBehavior) return value
return {
...settings,
general: {
...settings.general,
followUpBehavior: "steer",
},
}
}