Skip to content

fix: keep the kiro credit pill on the default harness when a read fails - #31459

Merged
KiroCrewCaptain merged 1 commit into
mainfrom
fix/29795-kas-credit-pill
Nov 7, 2026
Merged

KiroCrewCaptain merged 1 commit into
mainfrom
fix/29795-kas-credit-pill

Conversation

@bolichen97

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: On the default KAS harness, a failed credit read keeps the top-bar credit pill as an "unavailable" dash that opens the Kiro Account modal, as it already does on kiro-cli.

On a default install (KAS harness), when GET /api/sessions/usage fails (a 503), the top bar shows no credit pill at all: no error state and no way into the account modal. The same failure on the kiro-cli harness shows the "—" dash labelled "Kiro account & credits — unavailable", and the modal behind it.

Why it matters

KAS is the harness every install runs when it holds no choice, and it bills the same Kiro account as kiro-cli. Every such user whose usage read fails loses the only surface that reports the failure and the desktop's only door to the account modal (Refresh, switch account, manage subscription). The phone drawers' Kiro Account entry follows the same rule, so phone users lose it too.

Not a goal

  • Naming the sign-in remedy ("sign in again") when the read is refused with kiro_prerequisite_required, the second report on the issue. That 503 is also what the gateway answers while it boots, so relabelling it needs its own decision; this PR makes the pill and its modal reachable there.
  • Any change for harnesses that do not run on the Kiro account (Claude Code, Codex and the rest): a failed read still hides the segment there.
  • The backend usage read or its readiness gate.

What changed (motivation → approach → change)

Symptom: on KAS a failed usage read hid the credit segment. Cause: shell/topbar/kiroUsageReadout.tsx decided whether the Kiro credit surface exists with isKiroBackend, which is true for kiro-cli only, so KAS was treated like a harness with no Kiro balance and its failed state was hidden.

Change: the surface is decided by isKiroHarness instead, the existing positive check for the Kiro harness set (kiro-cli and KAS, KIRO_HARNESS_BACKENDS in api/acpBackend.ts). On KAS a failed read now keeps the "unavailable" dash and its modal, an empty reading keeps the "no reading" dash with Refresh, and the phone drawers keep the Kiro Account entry, exactly as on kiro-cli. Every other harness hides the segment as before, and an unloaded config still renders no dash.

The comments that described the old rule (kiroUsageReadout.tsx, api/kiroUsage.ts, api/acpBackend.ts, components/KiroAccountModal.tsx, the api/acpBackend.test.ts header), the phone-drawer paragraph in website/docs/narrow-viewport.md, and the account-modal sentence in docs/system-specs/modules/learn-cron-dashboard.md say "a Kiro harness" (isKiroHarness) where they said kiro-cli (isKiroBackend).

Backwards compatibility

Compatible: the credit segment now appears on KAS where it was hidden; nothing that renders today stops rendering.
Removes nothing: the only behaviour change adds a surface on KAS; the hide rule for non-Kiro harnesses is unchanged.

Tests

website/src/test/App.creditPillError.test.tsx:

  • The failed-dash case runs on kiro and kas (it.each): a 503 usage read renders the dash labelled "unavailable", and clicking it opens the account modal in its unavailable state.
  • The no-reading dash case runs on kiro and kas the same way.
  • The two "non-Kiro harness hides the segment" cases use claude instead of kas, since KAS is a Kiro harness; their assertions are unchanged.

Both kas cases are red with kiroUsageReadout.tsx reverted to origin/main and green with the fix; the kiro cases are green on both. The file passed 20 runs, each in a shuffled order (--sequence.shuffle, seeds 1037 to 1740 in steps of 37).

Related frontend specs (App.mobileSingleTopbar, App.topbarAndShortcuts, App.topbarCapsule, kiroUsageReadout.fastPoll, KiroAccountModal*, stubDashboardApiConfigFixture, shell-notifications.locations) pass; tsc -p tsconfig.app.json and eslint pass.

Proof: not provable -- frontend test (prove.py runs Python only)

Manual verification

Built the SPA from origin/main and from this branch and drove both with Playwright behind the gateway-free loopback server and API stub (scripts/lib/serve-dist.mjs, scripts/lib/stub-dashboard-api.mjs), with /api/sessions/usage answering 503 kiro_prerequisite_required:

build acp_backend capsule buttons
main kas connection, metrics (no credit pill)
this branch kas connection, metrics, "Kiro account & credits — unavailable" (opens the modal)
this branch claude connection, metrics (unchanged)

Screenshots / video

Before, KAS, usage read failing: no credit pill in the capsule.

before: KAS header

After, KAS, same failure: the "—" dash sits in the capsule.

after: KAS header

After, the dash opens the account modal in its unavailable state, with Refresh.

after: KAS modal

After, Claude Code harness, same failure: still no credit pill.

after: Claude Code header

Related Issues

Closes #29795

Sibling sweep

Swept: git grep -n "isKiroBackend" -- website/src
Sibling: website/src/api/kiroUsage.ts:114 -- changed here
Sibling: website/src/components/KiroPrerequisiteGate.tsx:849 -- not affected -- a comment naming where the definition lives, no surface decision
Sibling: website/src/pages/settings/KiroHarnessFallbackNote.tsx:14 -- not affected -- already reads isKiroHarness, so KAS is covered

Pattern harvest

Not generalizable: isKiroBackend is the right check for kiro-cli-only behaviour, and whether a surface belongs to kiro-cli or to the Kiro account is a per-surface judgement no rule can make.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

@bolichen97
bolichen97 requested review from a team and KiroCrewCaptain as code owners November 6, 2026 14:27
@bolichen97
bolichen97 requested a review from Zedmor November 6, 2026 14:27
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 6, 2026
@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of e6725f6f1bc5c3b0d170f19722165bfd9e8a21a0 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Nothing blocks: swapping isKiroBackend for the existing positive isKiroHarness check puts the decision on the right axis (does the harness run on the Kiro account). Non-Kiro harnesses keep their hide rule.

Notes

  • On KAS, if the usage-read readiness latch stays unverified for long stretches, the pill will sit on "unavailable" for that whole time and not just on a rare failure. The kiro_prerequisite_required relabel deferred under "Not a goal" becomes the follow-up that matters here.

[DESIGN-REVIEWED] e6725f6

Description read

[DESCRIPTION-READ] ce7317f7e626b566386f65904ab795fcfdc48442693b97647f36b02c34914e07

That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of e6725f6f1bc5c3b0d170f19722165bfd9e8a21a0 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

First-Principles-Verdict: PASS

The fix swaps in the existing isKiroHarness check for the one that excluded KAS, which is the cause of #29795. One function is left with no production caller.

Notes

  • Item 6 — undeclared: after this change, a search for isKiroBackend\b in non-test code under website/src finds 0 production callers. It appears only at its definition (api/acpBackend.ts:50), in two comments (acpBackend.ts:73, KiroPrerequisiteGate.tsx:849) and in two test files. The change even trims its doc comment down to "nothing Kiro-only should render on a guess", a rule nothing enforces any more. Subtraction: delete isKiroBackend, its test block in acpBackend.test.ts, and the assertion at stubDashboardApiConfigFixture.test.tsx:126, and point the two comments at isKiroHarness.

What this change ships

Inventory (6 items) — 5 justified

Intent: let a default-install (KAS) user whose credit read fails still see the failure and open the Kiro Account modal. FIX.

  1. On KAS, a failed usage read shows the "unavailable" dash, and clicking it opens the account modal — justified
  2. On KAS, an empty reading shows the "no reading" dash with Refresh — justified
  3. Phone drawers keep the Kiro Account entry on KAS — justified
  4. The tests' "non-Kiro harness hides the segment" cases now use claude instead of kas — justified
  5. Comments and specs say "a Kiro harness (kiro-cli or KAS)" where they said kiro-cli — justified
  6. isKiroBackend is left with no production caller — undeclared: an orphaned exported function

[FIRST-PRINCIPLES-REVIEWED] e6725f6

Description read

[DESCRIPTION-READ] 70dcc44854f583f8894ac47fc60272b1d31bd7c5c59682867867fb59af5ac6b1

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ✅ PASS

UX-level review of e6725f6f1bc5c3b0d170f19722165bfd9e8a21a0 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

UX-Verdict: PASS

Nothing blocks. The PR only widens where an existing pill and modal appear. Screenshots shot-02 and shot-03 show both on KAS, and the blind reader linked the pill to the "Kiro Account" modal by its shared icon.

Notes

  • The "—" pill shows only an icon and a dash, so it gives no hint that something failed. The blind reader said "a plain dash doesn't say 'error' the way the pop-up does", and "nothing says" the pill opens the pop-up. The PR makes this existing pill more common, so a visible label (for example "Credits unavailable") would help. That would be a follow-up, outside this PR's goal.
  • In the modal, "Account details unavailable" and "Could not read your balance." read to the reader like two separate errors. Merging them into one message (for example "Couldn't load your Kiro credits") would remove that confusion.

[UX-REVIEWED] e6725f6

Description read

[DESCRIPTION-READ] 59ce0179fea9419c80325a1f49894ad418b536a9de8d06b9df5da852d20eac9f

That sha256 names everything this verdict read: the PR description, plus the 7 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed e6725f6f1bc5c3b0d170f19722165bfd9e8a21a0 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] e6725f6

Verdict parsed from the review's SHA-scoped output markers for commit e6725f6f1bc5c3b0d170f19722165bfd9e8a21a0.

False positive or not applicable? A repository writer can comment:
/ai-review override fable e6725f6f1bc5c3b0d170f19722165bfd9e8a21a0 false-positive: <reason, 20 to 500 characters>

@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of e6725f6f1bc5c3b0d170f19722165bfd9e8a21a0 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] e6725f6

False positive or not applicable? A repository writer can comment:
/ai-review override gpt e6725f6f1bc5c3b0d170f19722165bfd9e8a21a0 false-positive: <reason, 20 to 500 characters>

@bolichen97
bolichen97 enabled auto-merge (squash) November 6, 2026 14:43
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Nov 6, 2026
@bolichen97
bolichen97 force-pushed the fix/29795-kas-credit-pill branch from 0e6494b to 3c0454b Compare November 6, 2026 16:56
@bolichen97

Copy link
Copy Markdown
Contributor Author

Rebased: main moved in docs/system-specs/modules/ (acp-client.md, cli.md, security.md and 78 more same-dir files) since this head went green (b764e20 -> aca93ab); CI re-running. The base now carries #31469, which clears the security package line-budget red both backend shard 2 jobs hit on the previous head.

[operator: bolichen97]

@bolichen97
bolichen97 force-pushed the fix/29795-kas-credit-pill branch from 3c0454b to d70e9be Compare November 6, 2026 19:01
@bolichen97

Copy link
Copy Markdown
Contributor Author

Rebased: main moved in docs/system-specs/modules/learn-cron-dashboard.md (and 48 more same-dir files under docs/system-specs/modules/) since this head went green (aca93ab -> f9e8bdf); CI re-running. The changed lines are byte-identical to the previous head; the previous head's AI review, policy and readiness lanes stopped on an exhausted CI API rate limit, so they had no verdict to keep.

[operator: bolichen97]

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Nov 6, 2026
The top-bar credit surface was keyed on the kiro-cli backend alone, so
on KAS, the default harness and one that draws on the same Kiro
account, a failed usage read hid the segment and left no way into the
account modal. Decide the surface by the Kiro harness set (kiro-cli
and KAS) instead, so the failed read keeps its "unavailable" dash and
modal there, while other harnesses still hide it.

Closes #29795
@bolichen97
bolichen97 force-pushed the fix/29795-kas-credit-pill branch from d70e9be to e6725f6 Compare November 7, 2026 01:51
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Nov 7, 2026

@KiroCrewCaptain KiroCrewCaptain left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved for the on-call. Review lanes pass on e6725f6, no conflict, no open change request.

@KiroCrewCaptain
KiroCrewCaptain merged commit 963d468 into main Nov 7, 2026
97 of 102 checks passed
@KiroCrewCaptain
KiroCrewCaptain deleted the fix/29795-kas-credit-pill branch November 7, 2026 02:59
buluoray added a commit that referenced this pull request Nov 8, 2026
…ls (#31459)

The top-bar credit surface was keyed on the kiro-cli backend alone, so
on KAS, the default harness and one that draws on the same Kiro
account, a failed usage read hid the segment and left no way into the
account modal. Decide the surface by the Kiro harness set (kiro-cli
and KAS) instead, so the failed read keeps its "unavailable" dash and
modal there, while other harnesses still hide it.

Closes #29795

(cherry picked from commit 963d468)

Co-author on main: Bolin Chen
buluoray added a commit that referenced this pull request Nov 8, 2026
…ls (#31459)

The top-bar credit surface was keyed on the kiro-cli backend alone, so
on KAS, the default harness and one that draws on the same Kiro
account, a failed usage read hid the segment and left no way into the
account modal. Decide the surface by the Kiro harness set (kiro-cli
and KAS) instead, so the failed read keeps its "unavailable" dash and
modal there, while other harnesses still hide it.

Closes #29795

(cherry picked from commit 963d468)

Co-author on main: Bolin Chen
buluoray added a commit that referenced this pull request Nov 8, 2026
…ls (#31459)

The top-bar credit surface was keyed on the kiro-cli backend alone, so
on KAS, the default harness and one that draws on the same Kiro
account, a failed usage read hid the segment and left no way into the
account modal. Decide the surface by the Kiro harness set (kiro-cli
and KAS) instead, so the failed read keeps its "unavailable" dash and
modal there, while other harnesses still hide it.

Closes #29795

(cherry picked from commit 963d468)

Co-author on main: Bolin Chen
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

readiness: passed Eligible automated validation passed for the current revision

Projects

None yet

Development

Successfully merging this pull request may close these issues.

On the default harness a failed credit read hides the credit pill

2 participants