Skip to content

Cost UX round 2: live ticking, breakdown toggle fix, /cost page, clear confirm - #46

Merged
aakri0 merged 1 commit into
mainfrom
feat/cost-improvements-round-2
May 1, 2026
Merged

Cost UX round 2: live ticking, breakdown toggle fix, /cost page, clear confirm#46
aakri0 merged 1 commit into
mainfrom
feat/cost-improvements-round-2

Conversation

@aakri0

@aakri0 aakri0 commented May 1, 2026

Copy link
Copy Markdown
Owner

Five things you flagged, all fixed.

1. Live cost while running

actual_cost() now also handles status=running — it adds (now - started_at) onto the prior cumulative duration and tags the result live: true. The UI polls /jobs/{id} at 500ms while running, renders a pulsing LIVE pill next to the actual cost, and the number visibly ticks up in the strip.

Verified end-to-end: a 3s time.sleep(3) job ticks $0.0000139 → $0.0000271 → $0.0000403, then locks in at $0.0000404 (live=false) when it completes.

2. Breakdown toggle was broken

The CSS .cost-strip-detail { display: flex } overrode the UA stylesheet's [hidden] { display: none }, so the row was always visible regardless of the toggle. Added explicit [hidden] rule and the click-to-expand on the Actual cell now works.

3. "Estimated max" label clarified

The strip label now reads:

Estimated max (worst-case upper bound — assumes every retry hits its full timeout)

So the meaning is visible without hovering for a tooltip.

4. Clear-invocations confirmation modal

The old confirm() is replaced with a proper modal that previews:

  • About to delete: N completed (or whatever filter is active)
  • Cost recorded against these: total $ ...
  • explicit copy: "Your Last 30 days total and the Cost page breakdown will drop accordingly."

After the delete, both refreshUsageTotal() and refreshCostPage() fire so the cost panels update immediately.

5. New #cost page

A new sidebar tab. Two cards:

  • How it's calculated — the formula, the four rate knobs (with current values pulled from /usage/cost.pricing), the inputs the model uses (duration_seconds, vcpu_share, memory_mb, attempts, network_seconds), an explicit definition of Estimated max, and a note about what Clear does.
  • Your usage (last 30 days) — total + count headlines, plus a by-status breakdown table (completed, failed_permanently, canceled with their counts and summed cost).

Refreshes when the tab opens and after every Invoke / burst / clear.

Test plan

  • pytest -q — 174 passed (3 new pricing cases for live cost, mid-flight retry, missing started_at).
  • Live cost ticks visibly on a 3s job.
  • Click Actual — breakdown row expands; click again — it collapses.
  • Click Clear finished — modal opens with N + cost preview; cancel = no-op; confirm = jobs deleted, panels refresh.
  • Open #cost — page renders with current rates, formula, and 30-day breakdown.

Asset cache-busts: app.js?v=17, styles.css?v=14.

…r confirm

Five fixes/features in one PR — all touch how cost is presented.

(1) Live cost while running.
    actual_cost() now handles status=running by adding (now - started_at)
    to the prior cumulative duration. The result is tagged live=true so
    the UI can render a 'LIVE' pill and tick up in real time. pollResult
    drops to a 500ms cadence so the tick is visible.
    Verified: a 3s sleep job ticks 0.0000139 -> 0.0000271 -> 0.0000403
    -> final 0.0000404.

(2) Breakdown click-to-expand was broken. The .cost-strip-detail rule
    set display:flex, which beat the UA stylesheet's [hidden] rule, so
    the row was always visible. Added explicit [hidden] override.

(3) Estimated max label clarified — bracketed explanation inline.

(4) Clear-invocations confirmation modal. Replaces the bare confirm()
    with a modal that previews the count and cost about to be deleted,
    plus copy explaining the 'Last 30 days' panel will drop accordingly.
    Cost panels refresh after the delete.

(5) New /cost page (sidebar tab). Lays out the formula, the four rate
    knobs (with current values from /usage/cost.pricing), the inputs the
    model uses, an explicit definition of 'Estimated max', and a
    per-status breakdown of the user's last 30 days. Refreshed on tab
    open and after every Invoke / burst / clear.

Schema:
  - Cost dataclass gains a live: bool field, surfaced on /jobs responses
    for running jobs.
  - test_pricing.py: three new cases (live cost, retry-mid-flight,
    running-without-started-at).

Asset cache-busts: app.js?v=17, styles.css?v=14.
@aakri0
aakri0 merged commit f3a2add into main May 1, 2026
3 checks passed
@aakri0
aakri0 deleted the feat/cost-improvements-round-2 branch May 1, 2026 22:49
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