Repository navigation
feat(reader): cost panel with confidence chips (#1122) - #1171
Conversation
Add a per-conversation cost panel to the daemon web reader plus the
backing /api/conversations/{id}/cost endpoint. The panel surfaces the
typed cost-estimate substrate (basis split, per-model breakdown,
unavailable reasons) and renders one MK3 confidence chip per number
keyed on the cost-estimate status:
exact -> q-canonical
priced -> q-estimated
partial -> q-heuristic
unavailable -> q-unavailable
The reader does not import cost-rollup internals directly; the new
handler routes through ``Polylogue.list_session_cost_insights`` so the
panel consumes the same typed SessionCostInsight contract the CLI and
MCP outlook tools already use.
Unknown conversations return 404. A conversation that exists but has no
materialised session-cost insight returns a 200 with an explicit
"unavailable" shape so the panel is never blank.
Tests: unit contracts for the four chip mappings, the payload shape,
the empty/unavailable fallback, and the dispatch path (404/200). Visual
DOM smoke evidence (#865) pins the Cost inspector tab + chip vocabulary
in the shell HTML and exercises the live endpoint against the seeded
reader workspace.
Closes #1122
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (5)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 23c3c1bb24
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Historical Codex triage: evidence checked at 5ebcfe5. This records that source revision; it does not claim a fresh review of current master.
Only the rows listed above are dispositioned. Held findings remain open. |
|
Historical Codex triage: evidence checked at 5ebcfe5. This records that source revision; it does not claim a fresh review of current master.
Only the rows listed above are dispositioned. Held findings remain open. |
Summary
Adds the per-conversation cost panel to the daemon web reader plus the
backing
/api/conversations/{id}/costendpoint. The panel surfaces thetyped cost-estimate substrate (basis split, per-model breakdown,
unavailable reasons) and renders one MK3 confidence chip per number.
Problem
Issue #1122 specifies a reader cost panel with explicit confidence
chips so the operator can tell at a glance whether a cost is canonical
(provider-reported exact), estimated (catalog-priced), heuristic
(partial coverage), or unavailable. Until this PR the daemon's web
shell had no cost surface at all — selecting a conversation rendered
Info / Raw / Notes tabs only, with no view onto the typed
SessionCostInsightsubstrate landed under #1132 / #1136 / #1137.Solution
GET /api/conversations/{id}/costinpolylogue/daemon/http.py.Routes through
Polylogue.list_session_cost_insights(SessionCostInsightQuery(conversation_id=id))— the same public read adapter the CLI and MCP cost-outlook surfaces use, so
the reader does not import cost-rollup internals directly (AC#1122).
_confidence_tag,_cost_panel_payload, and_empty_cost_payloadproject the typed estimate into a stable JSONshape. The mapping
exact -> q-canonical / priced -> q-estimated / partial -> q-heuristic / unavailable -> q-unavailableis the singlesource of truth and is exercised by unit tests.
Costtab. The renderer lazy-loads theendpoint into
state.costPanels, shows the total + chip, thecycle-style basis split (provider_reported / api_equivalent /
subscription_equivalent / catalog_priced / tool_surcharge), the
per-model breakdown, token usage, and any
missing_reasons—explicit
unavailablestate for unconfigured / unpriced sessionsinstead of a blank panel (AC#1122).
not_found). Existingconversations without a materialised session-cost insight return 200
with
status: "unavailable",confidence_tag: "q-unavailable", anda zero-valued basis/usage so the panel is never blank.
polylogue/daemon/http.py1200 -> 1280,new entry for
polylogue/daemon/web_shell.pyat 1220, both with asplit candidatenote pointing at the future per-domain handler /per-tab decomposition.
Verification
Unit contracts pin the four confidence-tag mappings, the payload
shape, the empty/unavailable fallback, JSON round-trip safety, and
the dispatch path (404 for unknown, 200 + typed envelope for known).
Visual DOM smoke evidence (#865) pins the Cost inspector tab and the
chip vocabulary (
q-canonical/q-estimated/q-heuristic/q-unavailable, plusBasis splitandPer-modelsection labels)in the shell HTML, and exercises the live endpoint against the seeded
reader workspace.
Closes #1122