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

Quota and usage admin sentences live in one module, read by the web pages and the terminal #5641

Merged opened this

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

Merged

The two admin sentences about quotas and usage are now written once, in a new module `src/actions/admin_limits_words.ts`. No existing module owned both of them: `actions/quotas.ts` and `actions/usage.ts` each cover only one. The module exports: - `QUOTA_INVALID`: "A quota is a positive whole number, or empty for no limit." - `USAGE_ADMIN_ONLY`: "Usage is read by a forge admin."

shipped production is serving it deploy 7cfd21c

opened this

The two admin sentences about quotas and usage are now written once, in a new module src/actions/admin_limits_words.ts. No existing module owned both of them: actions/quotas.ts and actions/usage.ts each cover only one. The module exports:

  • QUOTA_INVALID: "A quota is a positive whole number, or empty for no limit."
  • USAGE_ADMIN_ONLY: "Usage is read by a forge admin."

Four files import them instead of typing the sentence out. In each one, only the line with the sentence and one import line changed:

  • src/web/pages/admin-limits.ts: the message shown when saving quotas fails.
  • src/tui/screens/quotas.ts: the invalid_quota answer.
  • src/web/pages/usage.ts: the note on the 403 "Admins only" empty state.
  • src/tui/screens/usage.ts: the header line shown to someone who is not an admin.

The wording is unchanged. grep -rn for either sentence under src/ now finds only the new module.

The new test/admin-limits-words.test.ts reads each of the four files as text. It fails if one contains the sentence again or stops importing its constant. It also pins each constant to its exact wording.

Checks run before pushing, all passing:

  • the new test, plus the existing quota, limits, usage and terminal tests, and the timing tests for the two admin pages (40 tests, unchanged);
  • bun x tsc --noEmit, with no errors;
  • bun scripts/design-lint.ts, which is clean.

The check on the earlier pull (#5636) failed on one test: test/settings-timing.test.ts > "GET /settings/tokens names its phases and answers within its budget". This change does not touch the /settings/tokens page or anything it renders. That test passes 5 of 5 runs here, but I don't have the check log, so I can't say which of its assertions failed. Besides the load-relative budget, it has two fixed millisecond limits on how the timing phases add up, which a busy check machine can break. I filed #5642 to make it pass reliably on a loaded check machine, as #5197 did for /signin. This pull leaves that test alone and adds an empty commit to run the check again.

I did not move the other sentences in these files, such as "Quotas saved." and "You cannot change quotas.", because the issue names only these two.

To try it: on /admin/limits as an admin, submit a quota of abc, then open the usage page as someone who is not an admin. Both show the same text as before.

🤖 Generated with Claude Code

Closes #5621

commented

The two admin sentences about quotas and usage are now written once, in a new module src/actions/admin_limits_words.ts. No existing module owned both of them: actions/quotas.ts and actions/usage.ts each cover only one. The module exports:

  • QUOTA_INVALID: "A quota is a positive whole number, or empty for no limit."
  • USAGE_ADMIN_ONLY: "Usage is read by a forge admin."

Four files import them instead of typing the sentence out. In each one, only the line with the sentence and one import line changed:

  • src/web/pages/admin-limits.ts: the message shown when saving quotas fails.
  • src/tui/screens/quotas.ts: the invalid_quota answer.
  • src/web/pages/usage.ts: the note on the 403 "Admins only" empty state.
  • src/tui/screens/usage.ts: the header line shown to someone who is not an admin.

The wording is unchanged. grep -rn for either sentence under src/ now finds only the new module.

The new test/admin-limits-words.test.ts reads each of the four files as text. It fails if one contains the sentence again or stops importing its constant. It also pins each constant to its exact wording.

Checks run before pushing, all passing:

  • the new test, plus the existing quota, limits, usage and terminal tests, and the timing tests for the two admin pages (40 tests, unchanged);
  • bun x tsc --noEmit, with no errors;
  • bun scripts/design-lint.ts, which is clean.

The check on the earlier pull (#5636) failed on one test: test/settings-timing.test.ts > "GET /settings/tokens names its phases and answers within its budget". This change does not touch the /settings/tokens page or anything it renders. That test passes 5 of 5 runs here, but I don't have the check log, so I can't say which of its assertions failed. Besides the load-relative budget, it has two fixed millisecond limits on how the timing phases add up, which a busy check machine can break. I filed #5642 to make it pass reliably on a loaded check machine, as #5197 did for /signin. This pull leaves that test alone and adds an empty commit to run the check again.

I did not move the other sentences in these files, such as "Quotas saved." and "You cannot change quotas.", because the issue names only these two.

To try it: on /admin/limits as an admin, submit a quota of abc, then open the usage page as someone who is not an admin. Both show the same text as before.

🤖 Generated with Claude Code

Approved

Pure wording move: two sentences now live in src/actions/admin_limits_words.ts and the four readers (web and tty) import them. Wording is unchanged, no markup or tokens touched, so the design system is unaffected, and the web and terminal doors stay identical. The new test fails if a file types its own copy or stops importing it. The preview boots and /settings/usage answers a guest with the sign-in redirect as before; I could not exercise the admin-only 403 state without an admin session. Two things I would do next: (1) move the neighbouring sentences ("Quotas saved.", "You cannot change quotas.") so the module is complete; (2) the source-text test is brittle against refactors, so a behavioural test of the tty invalid_quota path would be sturdier. This is small housekeeping behind the arm-stability work, which should go first.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs