feat(operations): show real claude.ai subscription usage % on /operations #244

Merged
chaim merged 1 commits from worktree-operations-usage-ui into main 2026-06-13 10:35:19 +00:00
Owner

מציג את אחוז-השימוש האמיתי (5-שעות / שבועי / שבועי-Opus) שה-Claude Code status bar מציג, בראש דף /operations. עוצב ואושר דרך שער Claude Design (כרטיס 02c-operations-usage.html).

שלוש שכבות

  1. host-bridge (court_fetch_service): endpoint חדש GET /usage שקורא את ה-OAuth token מ-~/.claude/.credentials.json ו-proxy ל-/api/oauth/usage עם UA claude-code/* (חובה). read-only, ללא auth (כמו /pm2). host-only — הטוקן לא נכנס לקונטיינר.
  2. web/app.py: _ops_subscription_usage() proxy ל-bridge; snapshot של /api/operations מקבל שדה subscription_usage (null כשה-endpoint לא זמין).
  3. web-ui: SubscriptionUsagePanel — שלושה מדים (תווית · % · פס · איפוס) בראש /operations; הפס ענבר >75% / אדום >90%; מוסתר כש-usage null. טיפוסים ב-operations.ts.

בנוסף: תיקון שגיאת-lint קיימת (react/no-unescaped-entities) ב-learning-panel.tsx — escape ל-" בטקסט עברי (", נראה זהה).

אימות

  • tsc --noEmit עובר; lint error-count = 0.
  • ה-next build המלא נחסם רק ע"י סימלינק-ה-node_modules של worktree-ידני — ה-Docker build עם node_modules אמיתי לא מושפע.

פריסה

  • קונטיינר (web/, web-ui/) → Coolify deploy.
  • host (court_fetch_service) → סנכרון לעץ-host + pm2 restart legal-court-fetch-service.

Invariants

  • G2 — דרך ה-bridge הקיים + snapshot של /api/operations, בלי מסלול מקביל.

🤖 Generated with Claude Code

מציג את אחוז-השימוש האמיתי (5-שעות / שבועי / שבועי-Opus) שה-Claude Code status bar מציג, בראש דף `/operations`. **עוצב ואושר דרך שער Claude Design** (כרטיס `02c-operations-usage.html`). ## שלוש שכבות 1. **host-bridge** (`court_fetch_service`): endpoint חדש `GET /usage` שקורא את ה-OAuth token מ-`~/.claude/.credentials.json` ו-proxy ל-`/api/oauth/usage` עם UA `claude-code/*` (חובה). read-only, ללא auth (כמו `/pm2`). **host-only** — הטוקן לא נכנס לקונטיינר. 2. **`web/app.py`**: `_ops_subscription_usage()` proxy ל-bridge; snapshot של `/api/operations` מקבל שדה `subscription_usage` (null כשה-endpoint לא זמין). 3. **web-ui**: `SubscriptionUsagePanel` — שלושה מדים (תווית · % · פס · איפוס) בראש `/operations`; הפס ענבר >75% / אדום >90%; מוסתר כש-usage null. טיפוסים ב-`operations.ts`. בנוסף: תיקון שגיאת-lint קיימת (`react/no-unescaped-entities`) ב-`learning-panel.tsx` — escape ל-`"` בטקסט עברי (`"`, נראה זהה). ## אימות - `tsc --noEmit` עובר; lint error-count = 0. - ה-`next build` המלא נחסם רק ע"י סימלינק-ה-node_modules של worktree-ידני — ה-Docker build עם node_modules אמיתי לא מושפע. ## פריסה - **קונטיינר** (`web/`, `web-ui/`) → Coolify deploy. - **host** (`court_fetch_service`) → סנכרון לעץ-host + `pm2 restart legal-court-fetch-service`. ## Invariants - **G2** — דרך ה-bridge הקיים + snapshot של `/api/operations`, בלי מסלול מקביל. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
chaim added 1 commit 2026-06-13 10:35:13 +00:00
feat(operations): show real claude.ai subscription usage % on /operations
All checks were successful
G12 Leak-Guard / leak-guard (pull_request) Successful in 5s
6f3c3963a4
Surfaces the 5-hour / weekly / weekly-Opus utilization the Claude Code status
bar shows — the authoritative number, not a token estimate. Design approved via
the Claude Design gate (card 02c-operations-usage.html).

Three layers:
- court-fetch-service (host bridge): new GET /usage reads the OAuth token from
  ~/.claude/.credentials.json and proxies /api/oauth/usage with the required
  claude-code User-Agent. Read-only, no auth (like /pm2). Host-only — the token
  never enters the container.
- web/app.py: _ops_subscription_usage() proxies the bridge /usage; the
  /api/operations snapshot gains a `subscription_usage` field (null when the
  undocumented endpoint is unreachable).
- web-ui: SubscriptionUsagePanel renders three meters (label · % · bar · reset)
  at the top of /operations; bar turns amber >75% / red >90%; hidden when usage
  is null. Types added to operations.ts (hand-maintained snapshot type).

Also fixes a pre-existing react/no-unescaped-entities lint error in
learning-panel.tsx (escaped a `"` in Hebrew text — renders identically).

tsc --noEmit passes; lint error count 0. (Full next build is blocked only by the
manual-worktree node_modules symlink — the Docker build has real node_modules.)

Invariants: G2 (usage surfaced through the existing host bridge + /api/operations
snapshot — no parallel control path).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
chaim merged commit 17460044ac into main 2026-06-13 10:35:19 +00:00
chaim deleted branch worktree-operations-usage-ui 2026-06-13 10:35:19 +00:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: ezer-mishpati/legal-ai#244