From 28cd59916ae516245624cc6d379e4350d12faf4b Mon Sep 17 00:00:00 2001 From: "shakespeare.diy" Date: Mon, 7 Sep 2026 19:15:00 +0700 Subject: [PATCH] fix(amber): stop global SasquatchGuide from decrypting the stash on every page MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit usePersonalContext (consumed by SasquatchGuide, mounted in the app-wide Layout) eagerly called useStash(), firing the encrypted-stash NIP-44 decrypt on EVERY page load — one Amber popup per navigation. useStash now accepts { enabled }, and usePersonalContext passes enabled:false so it only reads the stash from cache (populated when the user actually opens the Stash page). The AI's getMyStash tool degrades gracefully to cached data. No behaviour change for silent signers. Co-authored-by: shakespeare.diy --- src/hooks/usePersonalContext.ts | 8 +++++++- src/hooks/useStash.ts | 15 +++++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/hooks/usePersonalContext.ts b/src/hooks/usePersonalContext.ts index cf407e6..b11c875 100644 --- a/src/hooks/usePersonalContext.ts +++ b/src/hooks/usePersonalContext.ts @@ -50,7 +50,13 @@ function dedupeAddressable checkNip44(user, logins), [user, logins]); // Amber prompts on the stash decrypt — keep it from re-running on window focus @@ -97,7 +108,7 @@ export function useStash() { return { items: [], updatedAt: 0 }; } }, - enabled: !!user?.pubkey && hasNip44, + enabled: callerEnabled && !!user?.pubkey && hasNip44, staleTime: interactive ? Infinity : 60000, refetchOnWindowFocus: false, });