Burst populates the strip + hydrate Estimated/Actual after a hard refresh - #48
Merged
Conversation
…resh Two related cost-strip gaps from #47: 1. Invoke ×50 (load test) updated 'Last 30 days' (because refreshAll ticks /usage/cost) but Estimated max and Actual stayed at —. onBurst skipped renderEstimate and pollResult — the strip's first two cells were single-submit-only. 2. After a hard refresh the JS state was empty, so all cells started at '—'. The Last 30 days panel filled in within 2s, but Estimated and Actual had no source until the user submitted again. Fixes: onBurst now: - calls fetchEstimate(body) -> renderEstimate so Estimated max populates immediately with the per-job number (the aggregate lives in Last 30 days where it belongs); - clears the actual cell, then awaits all 50 submits, picks the first job_id and pollResult()s it so Actual ticks live for one representative — same UX as a single submit. New hydrateCostStripFromJobs() + computeEstimateLocal(): - On every refreshAll tick, if the strip is empty AND the user hasn't just submitted (lastInvokeAt < 30s), pick the most recent terminal job from /jobs and: * render its cost as Actual, * reconstruct its worst-case estimate locally using the rates we cache from /usage/cost.pricing. - Active flows take priority via state.lastInvokeAt set in onSubmit and onBurst, so an in-flight pollResult never gets clobbered. The estimate reconstruction matches api/pricing.estimate_max_cost exactly (same formula, same per-attempt accounting, same network treatment) and uses the rate card already on /usage/cost so a single source of truth stays. Bumped app.js?v=19.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Two cost-strip gaps left by #47:
Last 30 daysticked becauserefreshAllalready tracks/usage/cost, butonBurstskipped bothrenderEstimateandpollResult. The first two cells of the strip were single-submit-only.onSubmit/onBurst. A page reload nuked that, leaving—until the user submitted again.Fixes
onBurst()fetchEstimate(body)→renderEstimate. Estimated max populates immediately with the per-job number (the aggregate lives in Last 30 days where it belongs).job_idand callspollResult()on it so Actual ticks live for one representative — same UX as a single submit.hydrateCostStripFromJobs()+computeEstimateLocal()refreshAlltick, if the strip is empty AND the user hasn't just submitted (lastInvokeAt < 30s), pick the most recent terminal job from/jobsand:costas Actual,/usage/cost.pricing.state.lastInvokeAt, set inonSubmitandonBurst, so an in-flightpollResultnever gets clobbered by hydration.The local estimate reconstruction mirrors
api/pricing.estimate_max_costexactly (same formula, same per-attempt fee accounting, same network treatment) and reuses the rate card already on/usage/cost.pricing, so the API stays the single source of truth.Verified
/jobs?limit=1returns every spec field hydration needs (memory_mb,timeout_seconds,max_retries,cpu_nanos,auto_install) plus the structuredcostobject on terminal rows.hydrateCostStripFromJobs/computeEstimateLocal/lastInvokeAt/results[0]in the servedapp.js?v=19.app.js?v=19.