Skip to content

fix(mobile): reset billing cache on kiloclaw destroy#4382

Merged
iscekic merged 1 commit into
mainfrom
fix/mobile-destroy-stale-billing-cache
Jul 3, 2026
Merged

fix(mobile): reset billing cache on kiloclaw destroy#4382
iscekic merged 1 commit into
mainfrom
fix/mobile-destroy-stale-billing-cache

Conversation

@iscekic

@iscekic iscekic commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

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

destroy invalidates getStatus and listAllInstances but never touches getBillingStatus, 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, so OnboardingFlow'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 refetchInterval never runs.

Fix

Reset (not invalidate) the billing query in destroy's onSettled. 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:unused all pass in apps/mobile.

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.
@iscekic iscekic self-assigned this Jul 3, 2026
@kilo-code-bot

kilo-code-bot Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Executive Summary

Reviewed the single-file, 6-line addition that resets the getBillingStatus query cache in destroy's onSettled; found no correctness, security, or performance issues in the changed lines.

Files Reviewed (1 files)
  • apps/mobile/src/lib/hooks/use-kiloclaw-mutations.ts

Reviewed by claude-sonnet-5-20260630 · Input: 16 · Output: 4.3K · Cached: 348.5K

Review guidance: REVIEW.md from base branch main

@iscekic iscekic requested a review from jeanduplessis July 3, 2026 12:09
@iscekic iscekic enabled auto-merge (squash) July 3, 2026 12:10
@iscekic iscekic merged commit a44dbd3 into main Jul 3, 2026
19 checks passed
@iscekic iscekic deleted the fix/mobile-destroy-stale-billing-cache branch July 3, 2026 12:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants