Skip to content

Render cost + estimate in the web UI - #42

Merged
aakri0 merged 1 commit into
mainfrom
feat/cost-ui
May 1, 2026
Merged

Render cost + estimate in the web UI#42
aakri0 merged 1 commit into
mainfrom
feat/cost-ui

Conversation

@aakri0

@aakri0 aakri0 commented May 1, 2026

Copy link
Copy Markdown
Owner

Why

The cost endpoints landed in v1.3 but the UI never read them, so users couldn't actually see the numbers. The bug report ('I cannot see the cost estimation on the UI') was correct — the data was sitting in /submit and /jobs/{id} responses unused.

What changed

Three places now show cost. No new API calls beyond responses we already fetch, plus one /usage/cost call on account-modal open.

Latest result card (Invoke tab)

  • Estimated max cost — from the /submit response. Shown immediately on submit. Tooltip explains it's a worst-case bound (every attempt to its full timeout).
  • Actual cost — appears when the polled GET /jobs/{id} returns a terminal status. Tooltip carries duration / vCPU / memory / attempts.

Job drawer (Invocations tab)

  • Cost row plus a small grey detail line: 0.18s · 0.5 vCPU · 256 MB · 1 attempt, plus Ns net if any auto-install rounds ran.

Account modal

  • Cost (last 30d) line. Opens fire /usage/cost?window_days=30 and renders $X.XX · N jobs.

Verified locally

  • POST /submit → response carries estimated_cost.max_cost_display = "$0.000507".
  • GET /jobs/{id} after the run → cost.cost_display = "$0.000002685", metrics.duration_seconds = 0.181.
  • web/ is bind-mounted, so a hard refresh picks up app.js?v=13 + styles.css?v=11 with no rebuild.

Test plan

  • Hard-refresh the Invoke tab, submit a job, see the estimate appear immediately and the actual cost replace (waiting...) once it finishes.
  • Open a finished job in the Invocations drawer — Cost row populates with the breakdown chip + detail line.
  • Open the Account modal — Cost (last 30d) shows total + count.

The cost endpoints landed in v1.3 but the UI never displayed them. Wire
the existing /submit + /jobs/{id} responses into:

- Latest result card (Invoke tab): 'Estimated max cost' from the submit
  response, then 'Actual cost' once the job reaches a terminal status.
  Tooltip on the estimate shows the worst-case caveat.

- Job drawer (Invocations tab): 'Cost' chip + a small detail line
  showing duration / vCPU / memory / attempts, optionally seconds of
  network if auto-install ran.

- Account modal: 'Cost (last 30d)' line that calls /usage/cost?window_days=30
  on open and shows total + jobs counted.

Bumped styles.css?v=11 and app.js?v=13 so browsers pick up the new HTML
hooks and JS without a hard refresh dance.
@aakri0
aakri0 merged commit 3a65193 into main May 1, 2026
3 checks passed
@aakri0
aakri0 deleted the feat/cost-ui branch May 1, 2026 09:01
aakri0 added a commit that referenced this pull request May 1, 2026
…ges (#43)

The cost-rendering code from #42 only fires when /submit returns an
estimated_cost field. If an operator pulls the new web/ but their API
container is still the pre-#40 image (e.g. `docker compose up -d`
without `--build` after a pull), the field is missing, the row stays
hidden, and the UI looks broken with no on-screen explanation.

Two changes so this can't bite silently:

- onSubmit() now calls /jobs/estimate as a fallback when estimated_cost
  is missing from the /submit response. The estimate row populates either
  way, so the user sees the number even on a half-deployed stack (as long
  as the API has *any* cost endpoint at all).

- A console.warn fires when the fallback runs, naming the likely cause
  ('your API container predates the cost feature: run docker compose up
  --build -d api'). Operators can paste this into a bug report.

Bumped app.js?v=14 so browsers pick up the new code without a hard
refresh.
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