Repository navigation
fix(prompts): report volume progress from the run, and pick it up again on reload - #751
Merged
Merged
Conversation
…in on reload Two things were wrong with the progress readout, both plain on a 100-prompt brand: it sat at "Analyzing 0/100" for the whole run, and a page refresh put the Analyze button back as though nothing were happening. The stall is a consequence of batching the DataForSEO lookup. Every row now lands in one go at the end of the run, so a figure taken from prompt_volumes reads zero for the ten minutes the keyword phase takes and then jumps straight to the total. It was measuring the wrong thing. The run now reports its own count as it goes — one step per prompt, which is where the minutes are — and the status endpoint serves that while a run is in flight, falling back to rows on disk once there is none. A prompt whose keyword extraction failed still counts as done, or the figure would stall short of the total. The button came back because the page never asked whether a run was going; the state lived in the tab. It asks on arrival now — a reload, a reopened tab, a return to the brand — and adopts a run already in flight, spinner and all. The server has known this all along; nothing new is stored. The progress listener cannot fail the run. By the time it is called there may be a quarter of an hour of work behind it, and a UI callback is not worth losing that to.
7 tasks done
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.
Summary
Two problems reported from testing a 100-prompt brand after #749 shipped:
Analyzing 0/100for the whole run — no movement until it was over.Why the counter stalled
This one is a consequence of #749. Batching the DataForSEO lookup moved every write to the end of the run: keywords are worked out for all 100 prompts first (~10 minutes, the LLM call per prompt), then one lookup, then all 100 rows in a few seconds.
The status endpoint counted rows in
prompt_volumes. So it read0for ten minutes and then jumped to100. It was measuring the wrong thing — the finish, not the work.The run now reports its own progress, one step per prompt through the keyword phase, which is where the minutes actually go.
GET /status/:brandIdserves that live count asdonewhile a run is in flight and falls back to rows on disk once there is none, so a page arriving after the run still sees the truth.A prompt whose keyword extraction failed counts as done — otherwise the figure stalls short of the total and never arrives.
Why the button came back
The page never asked whether a run was going;
analyzingwas React state, and a reload cleared it. The server has known all along —/statusreports it — the page just wasn't looking.It now asks on arrival (reload, reopened tab, or switching back to the brand) and adopts a run already in flight, disabled button and spinner and all. Nothing new is stored to make this work.
No double-spend was possible in the meantime: the server's claim already refused a second run for a brand, so clicking the re-enabled button returned "already running". The UI was wrong, not the billing.
Related issue
None — reported directly from testing.
Type of change
fix— Bug fixHow to test
Needs a brand with enough unanalyzed prompts for the run to take a while.
Analyzing 1/100,7/100, … — instead of sitting at0/100.Analyze 100 promptsbutton.Volume analysis finished, table populated, button returns to normal.Verification already done
0 → 40 → 90to pin that it moves, rather than only checking a single reading.yarn typecheck,yarn format:check,yarn lint(0 errors) andyarn buildpass fromweb/;yarn lint,yarn format:check,yarn testpass fromserver/.Not covered by tests: the page's own adopt-on-load behaviour — this repo has no component tests, so steps 2 and 3 above are the check.
Note
runningis tracked per process, so a server restart mid-run reports "not running" while rows are still being written. The page then shows what has landed rather than a spinner. That is the honest reading, and unchanged from #747.Checklist
feature/,fix/,chore/,docs/)yarn lintpasses (run fromweb/)yarn typecheckpasses (run fromweb/)yarn format:checkpasses (run fromweb/)