From dcf63bba6f864a385844d9cefac76980068611b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Igor=20=C5=A0=C4=87eki=C4=87?= Date: Fri, 3 Jul 2026 14:03:15 +0200 Subject: [PATCH] fix(mobile): reset billing cache on kiloclaw destroy MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit After destroying an instance, the cached getBillingStatus response still reported the destroyed instance as existing. The onboarding modal auto-dismisses on 'has_access + instance exists', and it does so synchronously from the stale cache before the mount refetch can resolve (the instant unmount then aborts that refetch). Result: the 'Create your agent' button appeared dead until app relaunch. Reset the billing query on destroy so the next onboarding mount fetches fresh state instead of racing against stale cache. Plain invalidation is not enough — the stale data would still be delivered on mount and the modal would dismiss before the refetch lands. --- apps/mobile/src/lib/hooks/use-kiloclaw-mutations.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/apps/mobile/src/lib/hooks/use-kiloclaw-mutations.ts b/apps/mobile/src/lib/hooks/use-kiloclaw-mutations.ts index 25ff8c5c25..61f4226d91 100644 --- a/apps/mobile/src/lib/hooks/use-kiloclaw-mutations.ts +++ b/apps/mobile/src/lib/hooks/use-kiloclaw-mutations.ts @@ -390,6 +390,12 @@ export function useKiloClawMutations(organizationId?: string | null) { await Promise.all([ invalidateStatus(), queryClient.invalidateQueries({ queryKey: listAllInstancesKey }), + // Reset (not invalidate) billing: the onboarding modal dismisses + // itself synchronously on cached `has_access` + instanceId before a + // refetch can land, and the unmount aborts that refetch — so stale + // billing data would make "Create your agent" a no-op until app + // relaunch. Dropping the cache forces a fresh fetch on next mount. + queryClient.resetQueries({ queryKey: billingStatusKey }), ]); }, }),