ReviewOS

also looking at this

stacks/uplink

fix(app): a settings.json this build cannot read no longer loops the app

#46
Merged glennmichael123 wants to merge fix/settings-fallbacks into main
4 files +130 -22
app/Uplink/desktop-agent.tsmodified+15-12
Changes to app/Uplink/desktop-agent.ts
@@ -8,12 +8,11 @@ import { homedir } from 'node:os'
88import { join } from 'node:path'
99import process from 'node:process'
1010import { loadConfig } from './config'
11import { isEngineId } from './engine'
1211import { allEngines, selectedEngine } from './engines'
1312import { formatDuration, truncate } from './format'
1413import { MessagesAccessError, MessagesDb } from './messages-db'
1514import { AppleScriptSender } from './sender'
16import { cleanToken, DATA_DIR, DATABASE_PATH, readSettings, readToken, settingsEnv, tokenLooksValid, writeSettings, writeToken } from './settings'
15import { cleanToken, coerceSettings, DATA_DIR, DATABASE_PATH, readSettings, readToken, settingsEnv, tokenLooksValid, writeSettings, writeToken } from './settings'
1716import { checkLicenseKey, describeLicense, isLicensed, normalizeKey, portalUrl, PRICING_URL, readLicenseKey, readLicenseState, RECHECK_MS, writeLicenseKey, writeLicenseState } from './license'
1817import { SignIn } from './sign-in'
1918import { SqliteStore } from './sqlite-store'
@@ -614,16 +613,20 @@ export async function startDesktopAgent(options: { version: string }): Promise<D
614613 return json(engineResult())
615614
616615 case '/api/settings': {
617 if (Array.isArray(body.allowed))
618 settings.allowed = body.allowed.map(String).map((s: string) => s.trim()).filter(Boolean)
619 if (typeof body.engine === 'string' && isEngineId(body.engine))
620 settings.engine = body.engine
621 if (typeof body.paused === 'boolean')
622 settings.paused = body.paused
623 if (typeof body.openAtLogin === 'boolean') {
624 settings.openAtLogin = body.openAtLogin
625 setOpenAtLogin(body.openAtLogin)
626 }
616 // The four fields the popover can send, checked by the same tests the
617 // read path uses. Anything absent or unusable keeps what is set now,
618 // so this stays a partial update.
619 settings = coerceSettings({
620 allowed: body.allowed,
621 engine: body.engine,
622 paused: body.paused,
623 openAtLogin: body.openAtLogin,
624 }, settings)
625 // Rewritten whenever the popover sent the field, not only when the
626 // value changed: someone toggling it back and forth is how a login
627 // item left pointing at an old install gets repaired.
628 if (typeof body.openAtLogin === 'boolean')
629 setOpenAtLogin(settings.openAtLogin)
627630 writeSettings(settings)
628631 settings = readSettings()
629632 config = loadConfig(settingsEnv(settings))