Skip to content

feat(bin): add a lightweight read-only web page showing every Claude seat's quota - #12

Merged
max-metaplanet merged 4 commits into
mainfrom
fm/seat-board
Sep 24, 2026
Merged

max-metaplanet merged 4 commits into
mainfrom
fm/seat-board

Conversation

@max-metaplanet

@max-metaplanet max-metaplanet commented Sep 24, 2026 •

Copy link
Copy Markdown
Owner

Intent

can you make a very lightweight web ui that essentially just displays the result of the quota-axi for all seats? pass to a fast worker to just do it in a easy simple way

Context: Claude seats are managed by bin/fm-seat.sh and bin/fm-seat-lib.sh (docs/claude-seats.md); quota-axi reads each seat's Claude quota. The page is for glancing at every seat's remaining quota in one place.

What Changed

  • Adds bin/fm-seat-board.sh, which serves a read-only local page on 127.0.0.1 (default port 4405, set with --port) through python3 -m http.server. The page shows the quota-axi report for the default login and every named seat: account email, percent left and reset time for each window, extra-usage spend against its cap, any attention line, and which seat is active for new workers. A render subcommand prints one page to stdout without starting a server.
  • Every quota read goes through fm-seat-lib.sh's fm_seat_quota_json, which doesn't refresh credentials or trigger keychain prompts. Each seat's report is cached for FM_SEAT_BOARD_CACHE_SECONDS (default 60s), so reloading the page doesn't hit the quota endpoint again. Output is HTML-escaped.
  • Adds tests/fm-seat-board.test.sh, which checks rendering, escaping, port parsing and cache behavior, and adds a "Glancing at every seat at once" section to docs/claude-seats.md.

🤖 Generated with Claude Code

Risk Assessment

✅ Low: The change adds a small, self-contained script that only reads data and serves on 127.0.0.1. It calls the existing fm_seat_quota_json path, which passes --no-credential-refresh. The fix round correctly resolved all five chosen findings: the leading --port dispatch, port validation, behavior tests replacing the grep tests, the cache keyed on the config dir, and reuse of fm_seat_quota_json. It introduced no new defects.

Testing

I ran the seat board for real in isolated lab homes: served it on 127.0.0.1, opened it in Playwright and took a screenshot, drove argument edge cases and a real Ctrl-C through a pty, checked caching and that nothing was modified, and did one render with the real quota-axi against the default login. The page lists every seat (default plus named seats) with email, percent left per window, reset times, extra-usage spend against its cap, attention lines, and which seat is active. Markup in quota-axi text shows as literal text, which fixes round 1's bash 5.2+ escaping failure. Page reloads do not call quota-axi again. Bad or missing --port values exit 2 without hanging. Ctrl-C stops the server cleanly. All scenarios passed. One test note: an early Ctrl-C attempt looked like a failure only because processes started with & in this harness ignore SIGINT; the real pty test is the valid one.

  • Live validation: ✅ go - 10 of 10 scenarios driven live against the product
Scenario Result Live Evidence
Operator runs the board and sees every seat's quota at a glance: default plus named seats, with email, percent left and reset time per window, extra-usage spend against its cap, and which seat is acti… ✅ pass live seat-board.png, served-page.html
Seats in trouble show quota-axi's attention line as-is (rate limited), and a seat with no usable report shows 'no quota data' instead of breaking the page ✅ pass live seat-board.png (spare and burner sections)
Adversarial: markup in quota-axi's email or error text (<b>, <script>, &, ") shows as literal text, not live HTML, on bash 5.3 ✅ pass live seat-board.png; served-page.html contains &lt;script&gt; and &lt;b&gt;x&lt;/b&gt; &amp; &quot;q&quot;; Playwright DOM check found 0 injected <b> or <script> elements
Server is reachable only from this machine (127.0.0.1, not the LAN) ✅ pass live lsof shows 127.0.0.1:4491 LISTEN; curl to the en0 IP was refused
Every quota read uses --no-credential-refresh and never --allow-keychain-prompt ✅ pass live The fake quota-axi's argument log showed every call as --provider claude --no-credential-refresh --full --json
Reloading the page does not query quota-axi again within the cache minute ✅ pass live cli-transcript.txt: 5 reloads added 0 calls; the one extra call came from a later render re-reading the seat whose report did not parse, which is never cached
Board is read-only: seat selection and the seats root are untouched ✅ pass live cli-transcript.txt: config/claude-seat is still 'work' and the seat directories are unchanged
--port &lt;n&gt; works with or without serve; missing or non-numeric --port and unknown arguments print usage and exit 2 without hanging ✅ pass live cli-args-and-shutdown.txt (all exit=2, none hung past the 5s guard); --port 4491 and serve --port 4492 both served the page
Ctrl-C in a terminal stops the server, frees the port, leaves no processes, and removes the scratch dir ✅ pass live ctrl-c-shutdown.txt (real pty, \x03 sent)
With the real quota-axi and the operator's default login, the page shows real quota data and no token or credential ✅ pass live real-quota-axi-render.html (session 87%, week 55%, Fable week 100%, extra usage $0 of $10000); the cached report has no token or credential fields

Rendered seat board screenshot (4 seats: healthy, missing data, rate-limited with a <script> error, active seat with markup in the email and extra usage)

Evidence: Raw HTTP response served on 127.0.0.1:4491

Source: Raw HTTP response served on 127.0.0.1:4491

HTTP/1.0 200 OK
Server: SimpleHTTP/0.6 Python/3.14.3
Date: Thu, 24 Sep 2026 18:26:14 GMT
Content-type: text/html
Content-Length: 1970
Last-Modified: Thu, 24 Sep 2026 18:26:11 GMT

<!DOCTYPE html>
<html><head><meta charset="utf-8">
<title>Claude seats</title>
<meta http-equiv="refresh" content="60">
<style>body { font-family: -apple-system, system-ui, sans-serif; margin: 2rem; color: #1a1a1a; }
h1 { font-size: 1.4rem; }
.generated { color: #666; font-size: 0.85rem; }
section.seat { border: 1px solid #ccc; border-radius: 6px; padding: 0.75rem 1rem; margin-bottom: 1rem; }
section.seat h2 { font-size: 1.05rem; margin: 0 0 0.35rem; }
.active { color: #0a7a2f; font-weight: bold; font-size: 0.8rem; }
.account { color: #444; margin: 0.1rem 0; }
.attention { color: #b30000; font-weight: bold; }
table.windows { border-collapse: collapse; margin-top: 0.4rem; }
table.windows th, table.windows td { text-align: left; padding: 0.15rem 0.6rem 0.15rem 0; }
.extra { color: #444; }</style>
</head><body>
<h1>Claude seats</h1>
<p class="generated">generated 2026-09-24T18:26:11Z</p>
<section class="seat">
<h2>default</h2>
<p class="account">[email protected]</p>
<table class="windows">
<tr><th>window</th><th>left</th><th>resets</th></tr>
<tr><td>session</td><td>62%</td><td>2026-09-24T15:00:00Z</td></tr>
<tr><td>week</td><td>41%</td><td>2026-09-28T00:00:00Z</td></tr>
</table>
</section>
<section class="seat">
<h2>burner</h2>
<p class="attention">no quota data (quota-axi unavailable or the read timed out)</p>
</section>
<section class="seat">
<h2>spare</h2>
<p class="attention">Claude quota endpoint rate limited &lt;script&gt;alert(1)&lt;/script&gt;</p>
<table class="windows">
<tr><th>window</th><th>left</th><th>resets</th></tr>
</table>
</section>
<section class="seat">
<h2>work <span class="active">active for new workers</span></h2>
<p class="account">[email protected] &lt;b&gt;x&lt;/b&gt; &amp; &quot;q&quot;</p>
<table class="windows">
<tr><th>window</th><th>left</th><th>resets</th></tr>
<tr><td>session</td><td>12%</td><td>2026-09-24T14:00:00Z</td></tr>
</table>
<p class="extra">extra usage: $17.5 of $50</p>
</section>
</body></html>
Evidence: Page rendered with the real quota-axi against the default login (email redacted)

Source: Page rendered with the real quota-axi against the default login (email redacted)

</head><body>
<h1>Claude seats</h1>
<p class="generated">generated 2026-09-24T18:28:11Z</p>
<section class="seat">
<h2>default <span class="active">active for new workers</span></h2>
<p class="account"><redacted-email></p>
<table class="windows">
<tr><th>window</th><th>left</th><th>resets</th></tr>
<tr><td>session</td><td>87%</td><td>2026-09-24T19:59:59.880488+00:00</td></tr>
<tr><td>week</td><td>55%</td><td>2026-09-25T10:59:59.880515+00:00</td></tr>
<tr><td>Fable week</td><td>100%</td><td>2026-09-25T11:00:00+00:00</td></tr>
</table>
<p class="extra">extra usage: $0 of $10000</p>
</section>
</body></html>
Evidence: Ctrl-C through a real pty

Source: Ctrl-C through a real pty

terminal output: Seat board: http://127.0.0.1:4493/
Ctrl-C to stop.
Serving HTTP on 127.0.0.1 port 4493 (http://127.0.0.1:4493/) ...
before Ctrl-C: HTTP 200 | scratch docroot created: True
board process exited: False
after Ctrl-C: HTTP refused (URLError)
leftover processes: none
scratch docroot removed: True
Evidence: Bad-argument exit codes

Source: Bad-argument exit codes

## serve --port (no value)
exit=2
## --port (no value, no serve)
exit=2
## serve --port abc
exit=2
## bogus
exit=2
Evidence: Cache and read-only transcript

Source: Cache and read-only transcript

## cache: 5 reloads + 1 render within 60s
quota-axi calls before=       4 after=       5
## read-only: seat config unchanged
claude-seat
claude-seats-root
work
burner
spare
work
- Outcome: 🔧 2 issues found → auto-fixed ✅ across 2 runs (7m37s)

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

🔧 **Review** - 6 issues found → auto-fixed ✅
  • ⚠️ bin/fm-seat-board.sh:237 - The header documents fm-seat-board.sh [serve] [--port &lt;n&gt;], so serve should be optional. But the top-level dispatch case &#34;${1:-serve}&#34; only matches serve, render and -h. So fm-seat-board.sh --port 4500 hits *) usage and exits 2 without starting a server. Fix: treat a leading --port (or any leading flag) as serve and pass all the arguments through, e.g. add a --port) cmd_serve &#34;$@&#34; ;; arm.
  • ⚠️ bin/fm-seat-board.sh:207 - fm-seat-board.sh serve --port with no value gets stuck in an endless loop. When only one argument is left, shift 2 fails and shifts nothing, so the while [ $# -gt 0 ] loop sees --port again forever. The port value is also never checked. Fix: check that $2 exists and is numeric (e.g. [ $# -ge 2 ] || usage) before shifting.
  • ⚠️ tests/fm-seat-board.test.sh:184 - Two new tests only grep the script's own source, which the test-quality rule forbids. test_serve_prints_127_0_0_1_only_and_never_0_0_0_0 greps for '127.0.0.1' and '0.0.0.0'. test_serve_never_invokes_allow_keychain_prompt greps for '--allow-keychain-prompt' and 'fm_seat_quota_read'. Neither checks behavior: a comment containing the string would satisfy them. Replace them with behavior checks, for example have the fake quota-axi record its argv during render and assert that --no-credential-refresh is present and --allow-keychain-prompt is absent. Otherwise, remove them.
  • ℹ️ bin/fm-seat-board.sh:96 - The cache file is named only after the seat, under a global ~/.cache/fm-seat-board. It does not depend on FM_HOME, the seats root, or CLAUDE_CONFIG_DIR. Two homes with different seat roots, or a different CLAUDE_CONFIG_DIR for default, share one cache file. So rendering the board in a second home within 60s can show the first home's email and quota under the same seat name. Fix: build the cache key from the resolved config dir ($dir) instead of the name, or put the cache under FM_HOME.
  • ℹ️ bin/fm-seat-board.sh:104 - seat_quota_cached repeats the read-and-check that fm_seat_quota_json in bin/fm-seat-lib.sh already does (read, reject empty, jq -e .). Call out=$(fm_seat_quota_json &#34;$dir&#34;) || out= instead, so there is one place that decides what counts as a usable report.
  • ℹ️ bin/fm-seat-board.sh:112 - When a fresh read fails, the last cached report is shown with no sign that it is stale. For example, after quota-axi times out on a seat for an hour, the page still shows hour-old percentages as if they were current, next to a fresh 'generated' timestamp. Consider showing the cache file's age when falling back to it.

🔧 Fix applied.
✅ Re-checked - no issues remain.

🔧 **Test** - 2 issues found → auto-fixed ✅
  • 🚨 bin/fm-seat-board.sh:66 - html_escape does not escape anything on bash 5.2 and later. With bash's patsub_replacement option (on by default), an unquoted &amp; in the replacement of ${s//&lt;/&amp;lt;} stands for the matched text. So &lt; becomes &lt;lt;, &gt; becomes &gt;gt; and &#34; becomes &#34;quot;. Live proof: a seat whose email is [email protected] &lt;b&gt;x&lt;/b&gt; was served as [email protected] &lt;lt;b&gt;gt;x&lt;lt;/b&gt;gt;, and the screenshot shows the &lt;b&gt; rendered as real bold markup. Any markup in quota-axi's email or state.error text is injected into the page unescaped. Fix: quote the replacements, e.g. s=${s//&amp;/&#39;&amp;amp;&#39;}, s=${s//&lt;/&#39;&amp;lt;&#39;}, s=${s//&gt;/&#39;&amp;gt;&#39;}, s=${s//\&#34;/&#39;&amp;quot;&#39;}. This form works on both bash 3.2 and 5.3. Add a render test with a fake quota-axi email or error containing &lt;b&gt;&amp;&#34; and assert the output contains &amp;lt;b&amp;gt;&amp;amp;&amp;quot;. The existing tests pass only because no fixture contains a special character.
  • 🚨 live validation verdict: no-go (8 of 9 scenarios were driven live against the product); failed: Untrusted text from quota-axi (email/error containing < > & ") is shown as literal text on the page
  • Live validation: ❌ no-go - 8 of 9 scenarios driven live against the product
Scenario Result Live Evidence
Open the board and see every seat (default + named) with email, percent left per window, reset time, extra-usage spend, and the active-seat marker ✅ pass live seat-board.png, seat-board.html: default, personal, spare and work are listed. work is marked 'active for new workers' and shows 42%/71% left with resets and 'extra usage: $12.5 of $100'
A rate-limited seat and a not-logged-in seat show their attention line as-is ✅ pass live seat-board.png: personal shows 'Claude quota endpoint rate limited' and spare shows 'not logged in'
Untrusted text from quota-axi (email/error containing < > & ") is shown as literal text on the page ❌ fail live seat-board.html: &lt;b&gt;x&lt;/b&gt; was served as &lt;lt;b&gt;gt;x&lt;lt;/b&gt;gt; and rendered bold in seat-board.png. Cause: bash 5.2+ patsub_replacement in html_escape
Server listens only on 127.0.0.1 and prints its URL/port on start (default 4405) ✅ pass live lsof showed only 127.0.0.1:4591 LISTEN; serve-ctrl-c-transcript.txt shows 'Seat board: http://127.0.0.1:4405/&#39; for a bare invocation
Reloading the page does not re-query quota-axi; reads are rate-bounded by the cache interval ✅ pass live The fake quota-axi call log did not grow from 5 back-to-back reloads; it grew only once per background regeneration interval
Read-only: quota reads use --no-credential-refresh, never --allow-keychain-prompt, and no seat setting is changed ✅ pass live Every logged argv was --provider claude --no-credential-refresh --full --json, with 0 keychain-prompt occurrences; lab config/claude-seat still 'work' and no new config files
Ctrl-C stops the server and cleans up its scratch directory and background loop ✅ pass live serve-ctrl-c-transcript.txt: curl 200 before Ctrl-C and 000 after; scratch docroot removed; no fm-seat-board processes of mine left
Invalid or missing --port values (with or without 'serve') exit with usage instead of hanging or serving ✅ pass live port-flag-transcript.txt: all five cases exit=2 within the 5s alarm
Board shows real quota for the operator's actual Claude seats ⏸️ untested no Not run on purpose. It would read production Claude credentials, and the operator's account emails would be published in the evidence branch, which the runbook and the no-credential rule discourage. T…
  • bash tests/fm-seat-board.test.sh (all 8 behavior tests pass)
  • Live bin/fm-seat-board.sh --port 4591 against an isolated lab: throwaway FM_HOME, seats root with work/personal/spare seats, active seat work, a fake quota-axi on PATH that logs its argv, and cache dir under /tmp. Fetched the page with curl and a Playwright full-page screenshot
  • lsof -iTCP:4591 -sTCP:LISTEN to confirm the server binds only to 127.0.0.1
  • 5 page reloads plus 12s wait while counting the fake quota-axi's call log, and checking the argv of every call for --no-credential-refresh and the absence of --allow-keychain-prompt
  • Checked lab config/claude-seat and the config dir after serving to confirm nothing was changed
  • Ran bare bin/fm-seat-board.sh (no args) in a pty: default port 4405, curl 200, sent Ctrl-C (\x03), then confirmed the port was closed, the scratch docroot removed and no processes left
  • Stopped the --port 4591 server's python child to confirm the EXIT trap kills the regen loop and removes the docroot
  • fm-seat-board.sh serve --port, --port, serve --port abc, --port 45x, bogus under a 5s perl alarm: all exit 2 with usage and none hang
  • bash -c comparison of unquoted vs quoted ${s//&lt;/&amp;lt;} on bash 5.3.9 and /bin/bash 3.2 to confirm the escaping root cause and a portable fix

🔧 Fix applied.
✅ Re-checked - no issues remain.

  • Live validation: ✅ go - 10 of 10 scenarios driven live against the product
Scenario Result Live Evidence
Operator runs the board and sees every seat's quota at a glance: default plus named seats, with email, percent left and reset time per window, extra-usage spend against its cap, and which seat is acti… ✅ pass live seat-board.png, served-page.html
Seats in trouble show quota-axi's attention line as-is (rate limited), and a seat with no usable report shows 'no quota data' instead of breaking the page ✅ pass live seat-board.png (spare and burner sections)
Adversarial: markup in quota-axi's email or error text (<b>, <script>, &, ") shows as literal text, not live HTML, on bash 5.3 ✅ pass live seat-board.png; served-page.html contains &lt;script&gt; and &lt;b&gt;x&lt;/b&gt; &amp; &quot;q&quot;; Playwright DOM check found 0 injected <b> or <script> elements
Server is reachable only from this machine (127.0.0.1, not the LAN) ✅ pass live lsof shows 127.0.0.1:4491 LISTEN; curl to the en0 IP was refused
Every quota read uses --no-credential-refresh and never --allow-keychain-prompt ✅ pass live The fake quota-axi's argument log showed every call as --provider claude --no-credential-refresh --full --json
Reloading the page does not query quota-axi again within the cache minute ✅ pass live cli-transcript.txt: 5 reloads added 0 calls; the one extra call came from a later render re-reading the seat whose report did not parse, which is never cached
Board is read-only: seat selection and the seats root are untouched ✅ pass live cli-transcript.txt: config/claude-seat is still 'work' and the seat directories are unchanged
--port &lt;n&gt; works with or without serve; missing or non-numeric --port and unknown arguments print usage and exit 2 without hanging ✅ pass live cli-args-and-shutdown.txt (all exit=2, none hung past the 5s guard); --port 4491 and serve --port 4492 both served the page
Ctrl-C in a terminal stops the server, frees the port, leaves no processes, and removes the scratch dir ✅ pass live ctrl-c-shutdown.txt (real pty, \x03 sent)
With the real quota-axi and the operator's default login, the page shows real quota data and no token or credential ✅ pass live real-quota-axi-render.html (session 87%, week 55%, Fable week 100%, extra usage $0 of $10000); the cached report has no token or credential fields
  • FM_HOME=/tmp/fmsb-lab/home bin/fm-seat-board.sh --port 4491: server started with no serve word, lab home had 4 seats and a fake quota-axi on PATH that records its arguments; fetched with curl http://127.0.0.1:4491/
  • Playwright: opened http://127.0.0.1:4491/, took a full-page screenshot, and ran DOM checks (0 injected <b> elements, 0 injected <script> elements, email shown as literal text)
  • lsof -iTCP:4491 -sTCP:LISTEN plus curl to the LAN IP: the server listens on 127.0.0.1 only
  • Recorded quota-axi arguments: every call was --provider claude --no-credential-refresh --full --json, never --allow-keychain-prompt
  • Cache check: 5 page reloads plus 1 render within 60s; quota-axi call count before and after
  • Read-only check: the lab home's config/claude-seat and seats root were unchanged after serving and rendering
  • bin/fm-seat-board.sh serve --port, --port, serve --port abc, bogus under a 5s kill guard: all exit 2, none hang
  • bin/fm-seat-board.sh serve --port 4492: explicit serve with a custom port serves all 4 seats
  • Python pty driver sending \x03 (a real Ctrl-C) to bin/fm-seat-board.sh --port 4493: port freed, no processes left, scratch dir removed
  • FM_HOME=/tmp/fmsb-real/home bin/fm-seat-board.sh render with the real quota-axi against the ambient default login (empty seats root, throwaway cache); email redacted in the evidence; checked the cached report for credential fields
✅ **Document** - passed

✅ No issues found.

🔧 **Lint** - 1 issue found → auto-fixed ✅
  • ⚠️ linter found issues (exit code 1)

🔧 Fix applied.
✅ Re-checked - no issues remain.

✅ **Push** - passed

✅ No issues found.

…'s quota

fm-seat-board.sh renders each seat's quota-axi report (account, window
percent-left/reset, extra-usage spend, attention lines) as one local page on
127.0.0.1, caching reads to stay under quota-axi's rate limit.
@max-metaplanet max-metaplanet changed the title feat(bin): lightweight read-only Claude seat quota board feat(bin): add a lightweight read-only web page showing every Claude seat's quota Sep 24, 2026
@max-metaplanet
max-metaplanet merged commit 8c1679a into main Sep 24, 2026
35 of 38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant