From 87a6f219d1c8e221c8465cb49942ca8b7f8c7696 Mon Sep 17 00:00:00 2001 From: ai-bot Date: Sat, 26 Sep 2026 14:22:53 +0000 Subject: [PATCH] Only write the API key when it actually changed --- startos/actions/configureApiKey.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/startos/actions/configureApiKey.ts b/startos/actions/configureApiKey.ts index d39bd41..1b5bbd3 100644 --- a/startos/actions/configureApiKey.ts +++ b/startos/actions/configureApiKey.ts @@ -56,14 +56,19 @@ export const configureApiKey = sdk.Action.withInput( async ({ effects, input }) => { // Write each setting only when it actually changed. main.ts re-runs — and - // the daemon restarts — on every file change, so writing both files - // unconditionally would restart the service twice in a single action. + // the daemon restarts — on every file change, so writing values + // unconditionally would restart the service (possibly twice) for nothing. const currentDebug = (await storeJson.read((s) => s.debug).once()) ?? false if (input.debug !== currentDebug) { await storeJson.merge(effects, { debug: input.debug }) } const apiKey = (input.apiKey ?? '').trim() - if (apiKey) await configJson.merge(effects, { apiKey }) + if (apiKey) { + const currentKey = (await configJson.read((c) => c.apiKey).once()) ?? '' + if (apiKey !== currentKey) { + await configJson.merge(effects, { apiKey }) + } + } }, ) \ No newline at end of file