Repository navigation
fix(usage): keep billing when the path check refuses a sessions dir - #32972
Conversation
UX Review (Opus 5.5) — ✅ PASSUX-level review of 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
[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 |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of 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
[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 |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of 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
What this change shipsInventory (6 items) — 4 justifiedIntent: a Windows user whose kiro-cli home is on a network share sees plan, credits and spend on the Usage page again. FIX.
[FIRST-PRINCIPLES-REVIEWED] 723295d Description read[DESCRIPTION-READ] 9e2f726f210b015120854c8d38f1c4f6f2aa240e7027167fca2b8a8f58437dd2 That sha256 names the PR description this verdict read. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
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.
7dd55de to
6cdbed6
Compare
6cdbed6 to
723295d
Compare
Scope note: the |
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
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.
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/cliitself._parse_sessionsturned that refusal intoerror/code: sessions_dir_unreadable,api_kiro_usagecopieserrorinto the response, andwebsite/src/providers/adapters/acp.tsthrows ons.errorbefore 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\sharelose their whole Usage page, including billing, which does not depend on transcripts. The localizedrefused_transcripts_warning, written for exactly this case, no longer appears.Not a goal
sessions_dir_unreadableerror.validate_file_pathcost, the half-pinned cache check, the POSIXPinnedDirectory.childhunk).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.unreadable_session_dirsrefused_transcriptsThe 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/clilisting failure, such as a permission error, still reportssessions_dir_unreadable. The refusal itself is kept, so a link atsessions/clior the KAS root that points to a UNC share is still never opened.The new string
unreadable_session_dirs_warningships in every catalog underwebsite/src/i18n/locales/, and the capture harness has anunc-homescene 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_dirsreads 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
errorin 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_errorReader: website/src/providers/adapters/acp.ts:fetchUsage -- crew page -- no longer throws on
s.errorfor this home, and mapsunreadable_session_dirs(0 when absent); AcpAdapter.usageSessionsError.test.tsReader: 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 noerrororcode, keeps the statistics shape and counts 2 inunreadable_session_dirsand 0 inrefused_transcripts. The refused cli link, refused KAS root, unreadable KAS root and unreadable record directory each count once there. An unlistablesessions/clikeeps itserror. 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
-n0and 3 shuffled orders on Windows. The new tests use onlytmp_path, a stubbed path check and fixed payloads, with no clock, port or sleep.Manual verification
Rendered the real
UsageTabthrough the real acp adapter in theusage-refused-transcriptscapture harness,scene=unc-home(sessions payload withunreadable_session_dirs: 2and 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 andsrc/i18ntests passed, along withnpm run i18n:checkandtsc.Screenshots / video
Billing, still shown on a UNC home (dark, light):
Session card with the count-free warning (dark, 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
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)