Skip to content

fix(mobile): stop showing low-balance alert as off and fix usage stats skeleton - #6762

Merged
iscekic merged 2 commits into
mainfrom
kwf/janitor-mobile-organization-1c509708e6
Sep 28, 2026
Merged

iscekic merged 2 commits into
mainfrom
kwf/janitor-mobile-organization-1c509708e6

Conversation

@iscekic

@iscekic iscekic commented Sep 26, 2026 •

Copy link
Copy Markdown
Collaborator

Fix proof

The hub's 'Low balance alert' row subtitle falls back to 'Off' whenever the withMembers query has no data, so while that query is paused offline or has errored (it is not in the persisted read cache)

Asserted value: apps/mobile/src/components/organization/hub-screen.tsx. Sense check (jev): probability 0.95

The scripts were proven on an earlier base, so only the head ran.

Head 0df6da628267

Head log: backend-assert f4f2ff320335 exited 0
$ git diff --unified=0 332f0c033e0781f85b7782c75ee4f2f595a7e2a8 0df6da6282678aca11ece1cc56866e270123ce73 -- apps/mobile/src/components/organization/hub-screen.tsx
diff --git a/apps/mobile/src/components/organization/hub-screen.tsx b/apps/mobile/src/components/organization/hub-screen.tsx
--- a/apps/mobile/src/components/organization/hub-screen.tsx
+++ b/apps/mobile/src/components/organization/hub-screen.tsx
+    lowBalanceSubtitle = t('organization.hub.lowBalanceBelow', {
+      amount: formatMoney(minimumBalance, i18n.language),
+    });
+  } else if (orgWithMembers.data != null) {
+    lowBalanceSubtitle = t('common.off');
+  } else if (orgWithMembers.isError) {
+    lowBalanceSubtitle = t('common.unknown');
+  }

On the organization hub the 2x2 usage-stat tiles disappear and only the 'Last 30 days' eyebrow renders when the usage query is paused (offline), because OrgUsageStats keys its skeleton off React Query

Asserted value: apps/mobile/src/components/organization/org-usage-stats.tsx. Sense check (model): The changed line const { data, isPending, isError } = useOrgUsageStats(organizationId) in org-usage-stats.tsx swaps isLoading for isPending, the exact fix the claim names for the paused-query state.

The scripts were proven on an earlier base, so only the head ran.

Head 0df6da628267

Head log: backend-assert b556fae42f7a exited 0
$ git diff --unified=0 332f0c033e0781f85b7782c75ee4f2f595a7e2a8 0df6da6282678aca11ece1cc56866e270123ce73 -- apps/mobile/src/components/organization/org-usage-stats.tsx
diff --git a/apps/mobile/src/components/organization/org-usage-stats.tsx b/apps/mobile/src/components/organization/org-usage-stats.tsx
--- a/apps/mobile/src/components/organization/org-usage-stats.tsx
+++ b/apps/mobile/src/components/organization/org-usage-stats.tsx
+        />
+        <StatTile
+          label={t('organization.usageStats.outputTokens')}
+          value={formatNumber(data.totalOutputTokens, i18n.language)}
+        />
+      </View>
+    </Animated.View>
+  );

Changelog for users

  • The organization hub's Low balance alert row now shows loading until settings arrive and unknown on error, instead of reading Off.
  • The hub's 2x2 usage stat tiles keep their skeleton while the usage query is pending, including offline, instead of disappearing.

Changelog for maintainers

  • Low balance subtitle now branches four ways: amount when set, Off only with a loaded payload, unknown on error, loading otherwise.
  • Usage stats now key the skeleton off isPending, so a paused query shows placeholder tiles rather than an empty grid.
  • The change references common.unknown and common.loading; confirm both translation keys exist before merge.
  • Review the subtitle branch order first: a loaded payload with no stored threshold still reads Off as intended.
  • No query, API, or data contract changed; only render branches and one status flag moved.

E2E proof

The hub's 'Low balance alert' row subtitle falls back to 'Off' whenever the withMembers query has no data, so while that query is paused offline or has errored (it is not in the persisted read cache) an org with the alert enabled reads as disabled; the subtitle must not treat missing settings as off.

Code trace: apps/mobile/src/components/organization/hub-screen.tsx:93 changed in 6e24929a7d044ac77b9e8d97fdd7da4502eeb420. Sense check (jev): probability 0.96

Changed lines
+  // A missing `withMembers` payload is not "off": the query can be paused
+  // offline or have errored with no persisted copy, so an org with the alert
+  // enabled must never read as disabled. Only a loaded payload with no stored
+  // threshold is genuinely off.
-  const lowBalanceSubtitle =
-    minimumBalance != null
-      ? t('organization.hub.lowBalanceBelow', {
-          amount: formatMoney(minimumBalance, i18n.language),
-        })
-      : t('common.off');
+  let lowBalanceSubtitle: string;
+  if (minimumBalance != null) {
+    lowBalanceSubtitle = t('organization.hub.lowBalanceBelow', {
+      amount: formatMoney(minimumBalance, i18n.language),
+    });
+  } else if (orgWithMembers.data != null) {
+    lowBalanceSubtitle = t('common.off');
+  } else if (orgWithMembers.isError) {
+    lowBalanceSubtitle = t('common.unknown');
+  } else {
+    lowBalanceSubtitle = t('common.loading');
+  }

On the organization hub the 2x2 usage-stat tiles disappear and only the 'Last 30 days' eyebrow renders when the usage query is paused (offline), because OrgUsageStats keys its skeleton off React Query isLoading (isPending && isFetching), which is false for a paused query; it must use isPending, as the sibling low-balance sheet already documents for this exact state.

Code trace: apps/mobile/src/components/organization/org-usage-stats.tsx:38 changed in 6e24929a7d044ac77b9e8d97fdd7da4502eeb420. Sense check (jev): probability 0.91

Changed lines
-  const { data, isLoading, isError } = useOrgUsageStats(organizationId);
+  const { data, isPending, isError } = useOrgUsageStats(organizationId);
-  if (isLoading) {
+  if (isPending) {
Owner request

Fix 2 janitor findings in mobile/organization. Fix every one; the proof covers each.

  1. The hub's 'Low balance alert' row subtitle falls back to 'Off' whenever the withMembers query has no data, so while that query is paused offline or has errored (it is not in the persisted read cache) an org with the alert enabled reads as disabled; the subtitle must not treat missing settings as off.
    Trace: apps/mobile/src/components/organization/hub-screen.tsx:93: The hub's 'Low balance alert' row subtitle falls back to 'Off' whenever the withMembers query has no data, so while that query is paused offline or has errored (it is not in the persisted read cache) an org with the alert enabled reads as disabled; the subtitle must not treat missing settings as off. (janitor area features-workflows).
    Files: apps/mobile/src/components/organization/hub-screen.tsx.
  2. On the organization hub the 2x2 usage-stat tiles disappear and only the 'Last 30 days' eyebrow renders when the usage query is paused (offline), because OrgUsageStats keys its skeleton off React Query isLoading (isPending && isFetching), which is false for a paused query; it must use isPending, as the sibling low-balance sheet already documents for this exact state.
    Trace: apps/mobile/src/components/organization/org-usage-stats.tsx:48: On the organization hub the 2x2 usage-stat tiles disappear and only the 'Last 30 days' eyebrow renders when the usage query is paused (offline), because OrgUsageStats keys its skeleton off React Query isLoading (isPending && isFetching), which is false for a paused query; it must use isPending, as the sibling low-balance sheet already documents for this exact state. (janitor area features-workflows).
    Files: apps/mobile/src/components/organization/org-usage-stats.tsx.

@iscekic iscekic added the kwf-janitor Admitted to the workflow from a janitor finding label Sep 26, 2026
@kilo-code-bot

kilo-code-bot Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Executive Summary

The incremental commit 0df6da628267 is a lint-driven refactor: the low-balance subtitle is initialized to common.loading with identical branch semantics, and the usage-stats if/else is collapsed into a ternary that keeps the skeleton for pending queries; mobile typecheck and lint both pass on the head commit.

Files Reviewed (2 files)
  • apps/mobile/src/components/organization/hub-screen.tsx
  • apps/mobile/src/components/organization/org-usage-stats.tsx
Previous Review Summary (commit 6bccfb0)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit 6bccfb0)

Status: No Issues Found | Recommendation: Merge

Executive Summary

Both render-branch fixes are correct: common.unknown/common.loading exist in en.json, the low-balance subtitle branch order matches the stated contract, and isPending is the right React Query v5 flag for a paused offline query.

Files Reviewed (2 files)
  • apps/mobile/src/components/organization/hub-screen.tsx
  • apps/mobile/src/components/organization/org-usage-stats.tsx

Reviewed by deepseek-v4.1-flash · Input: 0 · Output: 0 · Cached: 0

Review guidance: REVIEW.md from base branch main

@iscekic iscekic self-assigned this Sep 26, 2026
Initialize lowBalanceSubtitle at its declaration to satisfy
init-declarations, and collapse the usage stats if/else into a ternary so
no-unnecessary-condition and prefer-ternary pass.
@iscekic

iscekic commented Sep 26, 2026

Copy link
Copy Markdown
Collaborator Author

bot: Fixed failing checks in 0df6da6.

@iscekic iscekic added the human-ready The PR is ready for human review. label Sep 26, 2026
@iscekic iscekic added merge-by-human the merge bot routed this PR to a human merge-by-bot and removed human-ready The PR is ready for human review. merge-by-human the merge bot routed this PR to a human labels Sep 26, 2026
@iscekic
iscekic marked this pull request as draft September 28, 2026 08:41
@iscekic
iscekic marked this pull request as ready for review September 28, 2026 08:45
@iscekic
iscekic marked this pull request as draft September 28, 2026 08:53
@iscekic
iscekic marked this pull request as ready for review September 28, 2026 09:02
@iscekic
iscekic marked this pull request as draft September 28, 2026 09:05
@iscekic
iscekic marked this pull request as ready for review September 28, 2026 09:11
@iscekic
iscekic marked this pull request as draft September 28, 2026 09:18
@iscekic
iscekic marked this pull request as ready for review September 28, 2026 09:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kwf-janitor Admitted to the workflow from a janitor finding merge-by-bot

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants