Skip to content

fix(usage): keep billing when the path check refuses a sessions dir - #32972

Merged
bolichen97 merged 1 commit into
mainfrom
fix/usage-unc-sessions-dir
Nov 8, 2026
Merged

bolichen97 merged 1 commit into
mainfrom
fix/usage-unc-sessions-dir

Conversation

@bolichen97

@bolichen97 bolichen97 commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: On a Windows install whose kiro-cli home is on a network share, the Usage page shows plan, credits and spend again, with the warning that the session counts are incomplete.

Since #26951, the Usage tab on such a home shows only an untranslated error card ("cannot read sessions directory"), and the billing it showed before is gone. The path check's UNC gate trusts only the data home, the temp dir and the agents dir, so it refuses sessions/cli itself. _parse_sessions turned that refusal into error / code: sessions_dir_unreadable, api_kiro_usage copies error into the response, and website/src/providers/adapters/acp.ts throws on s.error before it reads billing. The same refusal on the KAS root dropped that store's sessions with no did-not-load count. Reported as a post-merge finding on #26951.

Why it matters

Operators whose Windows profile roams or whose kiro home is on \\host\share lose their whole Usage page, including billing, which does not depend on transcripts. The localized refused_transcripts_warning, written for exactly this case, no longer appears.

Not a goal

  • Admitting the session directories to the UNC gate, so the counts on such a home become correct rather than explained.
  • Changing how the frontend handles a real sessions_dir_unreadable error.
  • The optional notes on fix(usage): count KAS sessions on the Usage page #26951 (bulk validate_file_path cost, the half-pinned cache check, the POSIX PinnedDirectory.child hunk).

What changed (motivation → approach → change)

The billing loss comes from reporting a path-check refusal of a session directory as a read failure. A session directory that does not load is now reported on its own and adds no error, so the Usage tab shows billing with a warning.

What did not load Payload field What the Usage tab says
a session directory: refused, or a KAS root or record directory that cannot be listed unreadable_session_dirs "couldn't read your chat history" (no number)
a transcript file refused_transcripts "couldn't load N of your chats"

The directory warning names no number because the chats inside an unread directory were never counted. It wins when both fields are above 0. A real sessions/cli listing failure, such as a permission error, still reports sessions_dir_unreadable. The refusal itself is kept, so a link at sessions/cli or the KAS root that points to a UNC share is still never opened.

The new string unreadable_session_dirs_warning ships in every catalog under website/src/i18n/locales/, and the capture harness has an unc-home scene for it. The owning spec, docs/system-specs/modules/learn-cron-dashboard.md, says which field counts what.

Backwards compatibility

Compatible: the response only gains a key. A gateway without unreadable_session_dirs reads as 0 in the adapter, so an older backend keeps the count warning it showed before.

Reader: src/kiro_crew/dashboard/handlers/usage.py:api_kiro_usage -- crew page -- with no error in the sessions payload it returns billing and caches the response, the same branch an install with refused transcript files takes; test_a_home_on_an_untrusted_share_counts_as_not_loaded_without_an_error
Reader: website/src/providers/adapters/acp.ts:fetchUsage -- crew page -- no longer throws on s.error for this home, and maps unreadable_session_dirs (0 when absent); AcpAdapter.usageSessionsError.test.ts
Reader: website/src/pages/overview/UsageTab.tsx:UsageTab -- crew page -- shows the count-free directory warning, else the existing count warning; UsageTab.refusedTranscripts.test.tsx

Tests

  • test/test_usage_kas_sessions.py: a home whose two session directories are refused gets no error or code, keeps the statistics shape and counts 2 in unreadable_session_dirs and 0 in refused_transcripts. The refused cli link, refused KAS root, unreadable KAS root and unreadable record directory each count once there. An unlistable sessions/cli keeps its error. The cold-refresh placeholder has the same keys as a parse of an empty home.
  • test/test_usage.py: the empty-shape test carries the new key.
  • website/src/test/UsageTab.refusedTranscripts.test.tsx: the directory warning renders with no digit and without the count warning, and wins when both counts are above 0.
  • website/src/test/AcpAdapter.usageSessionsError.test.ts: the field is mapped, and reads 0 when absent.

Proof: PROVEN test/test_usage.py::TestParseSessions::test_empty_session_stats[False], test/test_usage.py::TestParseSessions::test_empty_session_stats[True], test/test_usage_kas_sessions.py::test_a_refused_cli_directory_link_is_not_listed, test/test_usage_kas_sessions.py::test_a_home_on_an_untrusted_share_counts_as_not_loaded_without_an_error (head 6cdbed6)

Determinism: the KAS test file passed 10 repeated runs at -n0 and 3 shuffled orders on Windows. The new tests use only tmp_path, a stubbed path check and fixed payloads, with no clock, port or sleep.

Manual verification

Rendered the real UsageTab through the real acp adapter in the usage-refused-transcripts capture harness, scene=unc-home (sessions payload with unreadable_session_dirs: 2 and billing), in Chromium on Windows. Billing shows, and the session card shows the count-free warning; the warning text holds no digit. Backend related tests (158) and the touched frontend and src/i18n tests passed, along with npm run i18n:check and tsc.

Screenshots / video

Billing, still shown on a UNC home (dark, light):

Billing card on a UNC home, dark
Billing card on a UNC home, light

Session card with the count-free warning (dark, light):

Session card with the unreadable-history warning, dark
Session card with the unreadable-history warning, light

Related Issues

Part of #26948

Sibling sweep

Swept: git grep -n "_pin_listing_dir|refused_transcripts +=" -- src/
Sibling: src/kiro_crew/dashboard/handlers/usage_sessions.py -- changed here

Pattern harvest

Not generalizable: the defect is one handler mapping a path-check refusal to a read error and folding directories into a per-file count; no other handler reports this payload.

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 8, 2026 06:28
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 8, 2026
@github-actions

github-actions Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ✅ PASS

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

UX-Verdict: PASS

Nothing blocks. Screenshots show the restored Billing card and the new warning, which the blind reader read correctly ("sure that it's a warning").

Notes

  • The blind reader asked "has my chat history been lost?" after reading unreadable_session_dirs_warning. "couldn't read your chat history" leaves loss open. Ending it with "Your chats are still saved; only this count is affected" would settle that.

[UX-REVIEWED] 723295d

Description read

[DESCRIPTION-READ] 3e5999c10ea672124556f577b8a3284439809636bebbae6135e1e760672f7a0c

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 8, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

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

Design-Verdict: PASS

Nothing blocks. The fix is aimed at the root cause: a refused directory is now counted, not reported as a read failure. The four screenshot downloads failed for a transport reason, so re-run the UX lane to confirm the evidence is there.

Notes

  • A KAS record directory that cannot be listed used to raise refused_transcripts and now raises unreadable_session_dirs. The page now shows the warning with no count in that case, even when the cli transcripts loaded fine. That is reversible, and the spec says so, but it is a change in wording on homes that are not on a share.

[DESIGN-REVIEWED] 723295d

Description read

[DESCRIPTION-READ] 80c99874b1448d31cb68f3bc211cdb6f359fd96b01e9642a5f8333b9422fbc43

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 8, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 723295d110d1b63b984d4bda29b84f4fcd489374 — 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 billing fix holds without the new field. The second warning goes beyond the Goal, but it fixes a real miscount, so it is a note, not a blocker.

Notes

  • Item 3 — oversized: the description's own "Why it matters" section says "The localized refused_transcripts_warning, written for exactly this case, no longer appears". The diff does not bring that warning back for this case. It sends the case to a new field and a new string in 15 catalogs. On the base commit, an unlistable KAS directory was already counted once in refused_transcripts. Subtraction: delete unreadable_session_dirs from the payload, from the NormalizedUsage type and from the UsageTab.tsx branch, delete unreadable_session_dirs_warning, and count a refused directory in refused_transcripts as the base commit already did. This lowers the concern rather than blocking, because then the warning shows "couldn't load 2 of your chats" for a number of chats nobody counted.

What this change ships

Inventory (6 items) — 4 justified

Intent: a Windows user whose kiro-cli home is on a network share sees plan, credits and spend on the Usage page again. FIX.

  1. Usage page on a network-share home shows billing again instead of an error card — justified
  2. A refused KAS root now counts as data that did not load instead of silently dropping its sessions — justified
  3. New unreadable_session_dirs payload field and its count-free "couldn't read your chat history" warning (1 consumer: UsageTab) — rides along, oversized
  4. An unlistable KAS directory moves from the counted warning to the count-free one — rides along
  5. Directory warning takes precedence when both counts are above 0 — justified
  6. Real sessions/cli listing failures still return sessions_dir_unreadable — justified

[FIRST-PRINCIPLES-REVIEWED] 723295d

Description read

[DESCRIPTION-READ] 9e2f726f210b015120854c8d38f1c4f6f2aa240e7027167fca2b8a8f58437dd2

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 8, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] 723295d

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

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

@github-actions

github-actions Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

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

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 723295d

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

@bolichen97
bolichen97 enabled auto-merge (squash) November 8, 2026 06:44
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running and removed readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention labels Nov 8, 2026
On a Windows home stored on a network share, the path check refuses
sessions/cli and the KAS root themselves. The sessions/cli refusal set
error/code on the session payload, so the Usage tab threw before it read
billing and showed only an error card. The KAS root refusal dropped its
sessions with no did-not-load count.

A session directory that does not load (refused, or a KAS root or record
directory that cannot be listed) now counts in a new
unreadable_session_dirs field and sets no error, and refused_transcripts
counts transcript files only. The Usage tab shows billing, and for an
unreadable directory a warning that names no count, since the number of
chats inside it is unknown. A real sessions/cli listing failure keeps
its error. The link refusal itself is unchanged.
@bolichen97
bolichen97 force-pushed the fix/usage-unc-sessions-dir branch from 7dd55de to 6cdbed6 Compare November 8, 2026 10:08
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Nov 8, 2026
@bolichen97
bolichen97 force-pushed the fix/usage-unc-sessions-dir branch from 6cdbed6 to 723295d Compare November 8, 2026 10:09
@bolichen97

Copy link
Copy Markdown
Contributor Author
  • A refused directory counted as one chat in refused_transcripts

fixed in 723295d: a session directory that does not load now counts in a new unreadable_session_dirs field, never in refused_transcripts.
The Usage tab shows a warning with no number for it, because the chats inside were never counted; the per-chat count warning shows only for transcript files.
The same class (a directory added to the per-chat count) is fixed at all four sites: the refused sessions/cli, the refused KAS root, the unlistable KAS root and the unlistable record directories.

Scope note: the ## Not a goal bullet "Changing the warning text, or making it count chats rather than directories" was removed because the PR owner asked to fix this finding in this PR with a separate warning.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running and removed readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention labels Nov 8, 2026
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention labels Nov 8, 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. On head 723295d the review read the full diff. A sessions directory that the path check refuses no longer returns error, so billing still reaches the Usage page. All four directory sites now count in unreadable_session_dirs, and the refused directory is still never opened or listed. The touched backend tests pass (121 at -n0). Five mutations of usage_sessions.py each made 2 to 4 named tests fail. The new key is in all 13 catalogs, and learn-cron-dashboard.md is updated in the same commit.
Done well: a directory that passes the path check but fails to list still reports sessions_dir_unreadable, and a test pins that boundary.
Optional: the Proof: line names head 6cdbed6, which is not this head. Re-running prove.py on 723295d and editing the body is enough, with no push.
Optional: the docstring at test/test_hooks_coverage.py:958 still says the usage page counts this refusal as refused_transcripts. It now counts in unreadable_session_dirs.
Optional: the directory warning in UsageTab.tsx:153 names Windows network drives and says chat history could not be read, even when only one record directory failed on a local home.

@bolichen97
bolichen97 merged commit ec255d3 into main Nov 8, 2026
393 of 423 checks passed
@bolichen97
bolichen97 deleted the fix/usage-unc-sessions-dir branch November 8, 2026 13:25
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Nov 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants