Skip to content

fix(prompts): report volume progress from the run, and pick it up again on reload - #751

Merged
gkhngyk merged 1 commit into
mainfrom
feature/volume-analysis-live-progress
Aug 20, 2026
Merged

gkhngyk merged 1 commit into
mainfrom
feature/volume-analysis-live-progress

Conversation

@gkhngyk

@gkhngyk gkhngyk commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Summary

Two problems reported from testing a 100-prompt brand after #749 shipped:

  1. The button read Analyzing 0/100 for the whole run — no movement until it was over.
  2. Refreshing the page brought the Analyze button back, as though nothing were running.

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 read 0 for ten minutes and then jumped to 100. 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/:brandId serves that live count as done while 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; analyzing was React state, and a reload cleared it. The server has known all along — /status reports 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 fix

How to test

Needs a brand with enough unanalyzed prompts for the run to take a while.

  1. Start volume analysis. Expected: the count climbs steadily — Analyzing 1/100, 7/100, … — instead of sitting at 0/100.
  2. Refresh the page mid-run. Expected: the button comes back disabled with the spinner and the current count, and keeps climbing. Previously it came back as a live Analyze 100 prompts button.
  3. Switch to another brand and back mid-run. Expected: same — the run is picked up again.
  4. Let it finish. Expected: Volume analysis finished, table populated, button returns to normal.
  5. Open the page when no run is going. Expected: no spinner, button available, no extra polling.

Verification already done

  • 355 server tests pass (was 348). 7 new: 5 on the progress reporting, 2 on the status endpoint serving the live count.
  • Mutation-checked: removing the per-prompt progress report fails exactly the two tests written for it.
  • One test drives the status endpoint through 0 → 40 → 90 to pin that it moves, rather than only checking a single reading.
  • yarn typecheck, yarn format:check, yarn lint (0 errors) and yarn build pass from web/; yarn lint, yarn format:check, yarn test pass from server/.

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

running is 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

  • Branch follows the naming convention (feature/, fix/, chore/, docs/)
  • Commits follow Conventional Commits
  • yarn lint passes (run from web/)
  • yarn typecheck passes (run from web/)
  • yarn format:check passes (run from web/)
  • Changes are focused — one concern per PR

…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.
@gkhngyk
gkhngyk merged commit 0be228f into main Aug 20, 2026
6 checks passed
@gkhngyk
gkhngyk deleted the feature/volume-analysis-live-progress branch August 20, 2026 14:48
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