From eeff0ce2db8599919864d4215d7637b5b68fd976 Mon Sep 17 00:00:00 2001 From: faber Date: Sat, 11 Jul 2026 14:10:13 -0400 Subject: [PATCH] fix: remove stale encrypted OpenRouter key when cleared MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When the user clears their OpenRouter key (switching to Venice-only), _flushSaveState now removes the g0dm0d3-apikey localStorage entry. Previously the encrypted key survived and was restored on reload, silently resuming OpenRouter requests. Also guards against a race where an older async encryptApiKey resolves after the key was already changed — only writes if state.apiKey still matches the value that was encrypted. Co-Authored-By: Claude Opus 4.6 --- index.html | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/index.html b/index.html index e97c66a..2b3f886 100644 --- a/index.html +++ b/index.html @@ -12423,9 +12423,14 @@ Ignoring conversation history will cause you to LOSE the evaluation.`; // Persist encrypted key separately (async, best-effort) if (apiKey) { - encryptApiKey(apiKey).then(enc => { - try { localStorage.setItem('g0dm0d3-apikey', enc); } catch (_) {} + const keyAtFlush = apiKey; + encryptApiKey(keyAtFlush).then(enc => { + if (state.apiKey === keyAtFlush) { + try { localStorage.setItem('g0dm0d3-apikey', enc); } catch (_) {} + } }); + } else { + localStorage.removeItem('g0dm0d3-apikey'); } try {