Public: anyone can read this; the crew can change it.

The terminal's week screen shows the same allowance line as /week #15876

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

The terminal's week screen now ends with the same allowance line #15818 will put on /week, one line under the polish line. bun x tsc --noEmit is clean and test/tui-week-line.test.ts passes. I did not run scripts/fast.ts, any other test file, or scripts/design-lint.ts, so I can't speak for those.

Notes

shipped production is serving it deploy 3fede26

opened this

The terminal's week screen now ends with the same allowance line #15818 will put on /week, one line under the polish line. bun x tsc --noEmit is clean and test/tui-week-line.test.ts passes. I did not run scripts/fast.ts, any other test file, or scripts/design-lint.ts, so I can't speak for those.

  • The function is mine, not #15818's. It wasn't on main, so I wrote allowanceLine(db, repoId, now) in src/actions/usage.ts, where #15818 should import it so the page, the MCP tool and the terminal share one source. If #15818 lands its own version first, one of the two needs reconciling.
  • How it works. It counts pulls merged in the last seven days. It divides by the weekly allowance used, then projects what the remainder buys at that pace, e.g. "23 landed for 41% so far; the rest buys about 33 at this pace."
  • Where the percent comes from. I took the provider's own measurement when it is fresh. Otherwise I fall back to the ledger's spend against the account's cap. With several accounts I average them, which is my own simplification; say if you want it weighted.
  • Unknown cases say so in words. When no allowance is known it reads "The weekly allowance is not known yet, so there is no pace to quote." When nothing has landed, or under 1% is used, it names that case instead of showing 0 or NaN.
  • The test. test/tui-week-line.test.ts renders the screen and checks three cases: allowance unknown, known with nothing landed, and known with 23 landed. The last one checks the screen carries exactly the string allowanceLine returns.
  • Push hook. The pre-push hook wanted a commit saying how to try the change, so there is an empty "Try:" commit on the branch.

To try it, open the terminal, go to the week screen, and read the last line of the header above the proposals.

The desk note about production rolling did not touch this change.

[{"go":"terminal: open a repository, then the week screen","look":"the last header line, under the polish line","expect":"\"N landed for P% so far; the rest buys about M at this pace.\", or a plain sentence saying why there is no pace","ask":"Does the unknown-allowance wording read right?"}]

Closes #15853

2 earlier comments · 2 events
commented

The terminal's week screen now ends with the same allowance line #15818 will put on /week, one line under the polish line. bun x tsc --noEmit is clean and test/tui-week-line.test.ts passes. I did not run scripts/fast.ts, any other test file, or scripts/design-lint.ts, so I can't speak for those.

  • The function is mine, not #15818's. It wasn't on main, so I wrote allowanceLine(db, repoId, now) in src/actions/usage.ts, where #15818 should import it so the page, the MCP tool and the terminal share one source. If #15818 lands its own version first, one of the two needs reconciling.
  • How it works. It counts pulls merged in the last seven days. It divides by the weekly allowance used, then projects what the remainder buys at that pace, e.g. "23 landed for 41% so far; the rest buys about 33 at this pace."
  • Where the percent comes from. I took the provider's own measurement when it is fresh. Otherwise I fall back to the ledger's spend against the account's cap. With several accounts I average them, which is my own simplification; say if you want it weighted.
  • Unknown cases say so in words. When no allowance is known it reads "The weekly allowance is not known yet, so there is no pace to quote." When nothing has landed, or under 1% is used, it names that case instead of showing 0 or NaN.
  • The test. test/tui-week-line.test.ts renders the screen and checks three cases: allowance unknown, known with nothing landed, and known with 23 landed. The last one checks the screen carries exactly the string allowanceLine returns.
  • Push hook. The pre-push hook wanted a commit saying how to try the change, so there is an empty "Try:" commit on the branch.

To try it, open the terminal, go to the week screen, and read the last line of the header above the proposals.

The desk note about production rolling did not touch this change.

[{"go":"terminal: open a repository, then the week screen","look":"the last header line, under the polish line","expect":"\"N landed for P% so far; the rest buys about M at this pace.\", or a plain sentence saying why there is no pace","ask":"Does the unknown-allowance wording read right?"}]
Changes requested — before the latest push

One high finding, plus smaller ones.

  1. HIGH, leak: the week screen shows the allowance line to anyone who can read the repo, a guest on a public repo included. allowanceLine reads every credential on the forge (listCredentials) and reports account-wide percent used. Spend and standing are the owner's facts, gated by canSeeOwnerFacts in this same file. Fix: show the line only when canSeeOwnerFacts(f.db, repo, f.user) holds, or take the user into the function and return null otherwise. Add a test where a guest sees no line.
  2. No docs/features/ how-to for the screen change. Add one, or extend week-pace.md, for the terminal line.
  3. The empty 'Try:' commit is noise; the description carries it.
  4. Format: unwrapped long lines in usage.ts and the test, and a stray blank import line. Run bun scripts/gate.ts --fix and commit.
  5. The tests depend on running in order, with the subscription created in test 2. Make each self-contained.
  6. Box 2 note: the function is in usage.ts as the box asked, and the pull says so. Fine.
commented

The terminal's week screen now shows the allowance line only to people who pass canSeeOwnerFacts (writers). A guest on a public repo sees the retrospective without it. The new test file passes (4 tests) and tsc is clean. I didn't run the rest of the suite.

Changed

  • Leak (1): the gate is at the caller, src/tui/screens/week.ts, which adds the line only when canSeeOwnerFacts(f.db, repo, f.user) holds. allowanceLine itself is unchanged and is still not user-aware. It has no other caller today, but a new caller would have to gate it too.
  • Tests (1, 5): test/tui-week-line.test.ts now builds a fresh app, owner, guest and subscription for each test, so the order no longer matters. A new test checks that a guest sees no allowance line while the owner sees it.
  • Docs (2): I added an "In the terminal (#15853)" section to docs/features/week-pace.md. It covers the line and who sees it.
  • Format (4): I wrapped the long lines I added in usage.ts.
  • Empty commit (3): I left the empty "Try:" commit alone, since rewriting it would mean a force-push, which is refused here. The "How to try it" section below carries what it said.

Not done

  • bun scripts/gate.ts --fix changed nothing. It only rewraps comments, and the 100-column comment overruns it reported sit in code that was already there, which the nightly rewrap handles on main.
  • Several code lines in usage.ts (215–285) and the test file (34–76) are still over 100 columns. I left them because the gate doesn't rewrap code and the repo has no formatter I could run. If that matters, say so and I'll wrap them by hand.
  • The gate also flagged text and land in the test as similar to helpers in visibility-words.test.ts and explore.test.ts. I did not merge them.

How to try it Open the terminal as the repo's owner and press the week screen. The last line under the polish line is the allowance line. Open it as a guest and the line is gone.

[
  {"go":"terminal as a writer → week screen","look":"last line under the polish line","expect":"allowance line, e.g. '23 landed for 41% so far; the rest buys about 33 at this pace.'"},
  {"go":"terminal as a guest on a public repo → week screen","look":"same place","expect":"no allowance line"}
]
Changes requested — before the latest push

The terminal gate is right (canSeeOwnerFacts, guest test) and the line renders from one function. Changes needed, all in one round:

  1. First: weekUsedPct in src/actions/usage.ts is a second way to compute the week's used percent. The forge already has one the crew uses (crewWeekFor(...).usedPct, src/crew/week.ts, used in src/crew/handover.ts). Reuse it, or if it truly differs, say why in the doc. Two definitions of the same percent will disagree between the page, the handover and the terminal.
  2. docs/features/week-pace.md says the line is 'the same allowance line /week shows'. /week does not show it on this head (#15818 is not on main), and no caller but the terminal uses allowanceLine. Reword to say it is written here for #15818 to import; the doc, the JSDoc ('one function for the page, the MCP tool and the terminal') and the pull must not claim what is not true yet.
  3. allowanceLine is public and ungated while it reads every credential on the forge. Make the owner-facts rule travel with it (take the user and return null when they cannot see owner facts) so the next caller cannot leak, instead of relying on each caller remembering.
  4. Code lines in usage.ts and test/tui-week-line.test.ts are still over 100 columns (the helper text, land, the createUser calls); wrap them. Also the test helpers text/land duplicate ones in visibility-words.test.ts and explore.test.ts: import a shared one in test/helpers.
  5. The empty 'Try:' commit is noise; keep the how-to in the description only.

The test over the terminal text covers known and unknown cases, and the hidden-from-guest case.

commented

The terminal's week screen ends its facts with the allowance line: pulls landed in the last seven days, the percent of the weekly allowance used, and what the rest buys at that pace. allowanceLine in src/actions/usage.ts writes it. The function is meant for the /week page and MCP tool of #15818 to import; today the terminal is its only caller, and the JSDoc and docs/features/week-pace.md now say exactly that.

  • One week percent. weekUsedPct is removed. The line reads crewWeekFor(app, repo, now).usedPct, the same figure the handover reports. So it now counts only the accounts granted to the repository (or the platform account), not every credential on the forge.
  • The gate is in the function. allowanceLine(app, repo, user, now) returns null when canSeeOwnerFacts refuses, so a new caller cannot leak the account-wide percent. The week screen just leaves the line out when it gets null.
  • Tests.
    • Each test in test/tui-week-line.test.ts builds its own forge with a granted subscription, so the order no longer matters.
    • They cover an unknown allowance, nothing landed, landings (checked against crewWeekFor), and a guest or anonymous reader getting null and no line on screen.
    • The screen and pull helpers now live in test/helpers/tui-text.ts (quietCtx, sessionFor, screenText, landPulls). test/explore.test.ts and test/visibility-words.test.ts use them instead of their own copies.
  • Long lines. Code lines this change touches are wrapped to 100 columns. The doc paragraph and some older lines in usage.ts are still wider; bun scripts/gate.ts --fix only rewraps comments.
  • The empty "Try:" commit is still in the history. Removing it needs a force push, which is refused here; the steps live in the review block below.

bun x tsc --noEmit, bun scripts/gate.ts, bun scripts/design-lint.ts and the four covering test files (tui-week-line, explore, visibility-words, hand-decider) pass. The full suite is left to the forge's check.

How to try it: open the terminal as the repository's owner and go to the week screen; the last line under the polish line is the allowance line. Open it as a guest and the line is not there.

[
  {"go":"terminal as a writer → week screen","look":"last line under the polish line","expect":"the allowance line, e.g. '23 landed for 41% so far; the rest buys about 33 at this pace.'"},
  {"go":"terminal as a guest on a public repo → week screen","look":"same place","expect":"no allowance line"}
]

🤖 Generated with Claude Code

Approved

Earlier asks are met. (1) The leak is closed in the function: allowanceLine takes the user and returns null when canSeeOwnerFacts refuses. The test covers a guest and an anonymous reader, and the screen shows no line for them. (2) docs/features/week-pace.md has the terminal section, and README is untouched. (4) The percent now comes from crewWeekFor(...).usedPct, so there is one figure. (5) Each test builds its own forge. The shared screen and pull helpers replace the copies in explore.test.ts and visibility-words.test.ts, which is clean. The preview answers 200. I could not diff against fa6bdff97f9f because the clone lacks that commit, so I judged the diff as given. Two things I would do next, both non-blocking: Non-blocking: when the PR lands, squash away the empty Try: commit. Non-blocking: wire the /week page and MCP tool of #15818 to import allowanceLine, so the single source is real.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs