fix(mobile): reset billing cache on kiloclaw destroy#4382
Merged
Conversation
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.
Contributor
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Executive SummaryReviewed the single-file, 6-line addition that resets the Files Reviewed (1 files)
Reviewed by claude-sonnet-5-20260630 · Input: 16 · Output: 4.3K · Cached: 348.5K Review guidance: REVIEW.md from base branch |
jeanduplessis
approved these changes
Jul 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
After destroying a KiloClaw instance, tapping Create your agent on Home does nothing — the app has to be relaunched before onboarding works again.
Root cause
destroyinvalidatesgetStatusandlistAllInstancesbut never touchesgetBillingStatus, which is what the mobile onboarding facade is derived from (derive-mobile-onboarding-state.ts). The stale cache still reports the destroyed instance as existing, soOnboardingFlow's auto-dismiss effect (has_access+ instance exists →router.back()) closes the modal in the same frame it opens — the button looks dead.The cache never heals on its own: the mount-triggered refetch is aborted by the instant unmount (tRPC wires the abort signal), and nothing on Home subscribes to the billing query, so its
refetchIntervalnever runs.Fix
Reset (not invalidate) the billing query in
destroy'sonSettled. Plain invalidation isn't enough — the stale cached data would still be delivered synchronously on mount and the modal would dismiss before the refetch lands. Dropping the cache entry makes the next onboarding mount show the skeleton and fetch fresh state, which correctly lands on the identity step.Testing
pnpm format && pnpm typecheck && pnpm lint && pnpm check:unusedall pass inapps/mobile.