Skip to content

Add local web UI for ocw serve - #8

Merged
anilmurty merged 1 commit into
mainfrom
web-ui
Apr 7, 2026
Merged

anilmurty merged 1 commit into
mainfrom
web-ui

Conversation

@anilmurty

Copy link
Copy Markdown
Contributor

Summary

Single-file Preact SPA served by ocw serve at http://127.0.0.1:7391/. Dark theme, dense data display, no build step.

5 views:

  • Status — agent cards with cost/tokens/alerts, auto-refresh every 5s
  • Traces — filterable list + span waterfall with click-to-inspect detail panel
  • Cost — breakdown by day/agent/model/tool with summary totals
  • Alerts — severity-filtered table with expandable JSON detail
  • Drift — baseline vs latest session Z-scores with pass/fail indicators

Backend changes:

  • New GET /api/v1/status endpoint
  • Drift endpoint now lists all agents when agent_id omitted
  • CORS regex for localhost port matching
  • API key injected via <meta> tag (no prompt needed)

Test plan

  • All 232 tests pass
  • ruff check ocw/ clean
  • Open http://127.0.0.1:7391/ after ocw serve — UI loads
  • All 5 views render with data from example agents
  • Span waterfall renders correctly for multi-span traces
  • /docs Swagger still works
  • /api/v1/* endpoints still work

🤖 Generated with Claude Code

- Single-file Preact SPA at ocw/ui/index.html (no build step, CDN imports)
- Served at / and /ui/* by FastAPI, API key injected via meta tag
- Status view: agent cards with cost, tokens, alerts (auto-refresh 5s)
- Traces view: list with filters + span waterfall with click-to-inspect
- Cost view: breakdown by day/agent/model/tool with summary totals
- Alerts view: filterable table with expandable detail
- Drift view: baseline vs latest session with Z-score pass/fail
- New GET /api/v1/status endpoint (extracts cmd_status logic)
- Drift endpoint now supports optional agent_id (lists all baselines)
- CORS updated to regex for localhost port matching

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@anilmurty
anilmurty merged commit 9a47c66 into main Apr 7, 2026
4 checks passed
@anilmurty
anilmurty deleted the web-ui branch April 7, 2026 22:30
anilmurty added a commit that referenced this pull request Jun 19, 2026
…#10,#13)

Smoke-test playbook (tests/manual-new-release-tests.md):

- #3 (and #8/#9/#11/#12/#14/#16 — same root cause): code blocks are now
  command-only; the inline "# comments" and "# [ ]" checklists that the markdown
  copy button was pulling into copied commands moved to prose / "- [ ]" lists
  around each block. Added a note explaining the convention.
- #10: corrected the Section 4 trim expectation — with [capture] prompts=false
  (default), trim checks the capture prereq first and prints the capture hint,
  NOT the tokenjam[bloat] install hint (only reachable once capture is on).
- #13: export file is "claude-code-<date>.jsonc", not ".json".

Doc-only; no code changes.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
anilmurty pushed a commit that referenced this pull request Jul 2, 2026
Real Claude Code backfills carry the current Anthropic model ids, but
`claude-fable-5` and `claude-sonnet-4-5` had no entry in the packaged
pricing table. `get_rates` returned None for them, so `calculate_cost`
fell back to the $0.50/$2.00-per-MTok default and logged a "No pricing
data" warning — silently mis-pricing the secondary API-plan "implied
value / calibration" dollar line in `tj context`, `tj quota-audit`, and
`tj tokenmaxx`. Surfaced while building #6.

Add both entries with the published per-MTok rates
(https://platform.claude.com/docs/en/pricing):
  - claude-fable-5: input 10.00 / output 50.00 / cache-read 1.00 /
    cache-write(5m) 12.50
  - claude-sonnet-4-5: input 3.00 / output 15.00 / cache-read 0.30 /
    cache-write(5m) 3.75 (same published tier as Sonnet 4.6)

The other current ids the backfill warns about — claude-opus-4-8,
claude-sonnet-4-6, claude-haiku-4-5 — were already present.

Extend tests/unit/test_pricing_override.py to assert each current
Anthropic model resolves to its packaged rate, that none falls through
to the default fallback, and that the dated YYYYMMDD variant resolves
via the existing suffix-strip path.

Co-Authored-By: Claude <[email protected]>
(cherry picked from commit 0d16227)
anilmurty pushed a commit that referenced this pull request Jul 2, 2026
The claude-haiku-4-5 entry in pricing/models.toml carried the retired
Haiku 3.5 rates (input 0.80 / output 4.00 / cache_read 0.08 /
cache_write 1.00 per MTok) — identical to the claude-haiku-3-5 row. The
entry existed, so it did not trip the #8 "No pricing data" warning, but it
silently understated the Haiku-4.5 API-plan dollar calibration line.

Update to the current published Haiku 4.5 rates (input 1.00 / output 5.00 /
cache_read 0.10 / cache_write 1.25 per MTok, 5-minute cache-write column),
verified against platform.claude.com/docs/en/about-claude/pricing. Haiku
3.5 keeps its own old rates for the Bedrock/Vertex date-suffix fallback.

Tests: add claude-haiku-4-5 to the #8 current-Anthropic coverage dict and a
dedicated regression asserting it no longer carries the retired 3.5 figures
(and that 3.5 still does). Update the dollar/rate assertions across
test_cost.py, test_cost_tracking.py, test_provider_attribution_194.py, and
test_cost_charts.py that were pinned to the old Haiku rate.

Co-Authored-By: Claude <[email protected]>
(cherry picked from commit 3dbc25e)
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