Skip to content

fix(fanout): classify intents progressively — visible page first, background chunks - #448

Merged
gkhngyk merged 1 commit into
mainfrom
fix/fanout-intent-chunking
Jul 17, 2026
Merged

gkhngyk merged 1 commit into
mainfrom
fix/fanout-intent-chunking

Conversation

@gkhngyk

@gkhngyk gkhngyk commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Summary

The Query Fan-out tab requested intent classification for every observed sub-query in a single call. On a cold cache that one request serialized dozens of LLM waves (120 queries ≈ 40s+), blew past the server action's 20s fetch timeout (#428), and the badges never arrived that session — the server kept classifying and persisting, so they only showed up on a later visit.

This PR classifies progressively, client-side only:

  • The table renders immediately and never waits on classification (the old 1.5s first-paint race is gone).
  • The visible page's 10 queries go first — one request, at most ~2 LLM waves on a fully cold cache, so badges appear within seconds.
  • The remainder is classified in background chunks of 20 (≈4 LLM waves each, comfortably inside the 20s timeout), each merged into state as it resolves — badges fill progressively down the list.
  • A failed/timed-out chunk only leaves its own rows unbadged; the chain continues.
  • A run counter cancels the stale chain on reload/brand switch/unmount, and already-classified queries are skipped on the silent reload after tracking a query.

No server changes — /api/prompts/fanout-intents already accepts arbitrary batch sizes and caches per query.

Related issue

Closes #431

Type of change

  • feat — New feature
  • fix — Bug fix
  • chore — Maintenance / dependencies
  • docs — Documentation only
  • refactor — Code change that neither fixes a bug nor adds a feature
  • test — Adding or updating tests

How to test

  1. Clear (or partially delete from) fanout_query_intents to simulate a cold cache.
  2. Open Prompts → Query Fan-out on a brand with many observed sub-queries.
  3. The table paints instantly; the first page's Intent badges appear within a few seconds; later rows fill in waves of ~20.
  4. Switch brands or reload mid-fill — no stale badges bleed across; classification restarts for the new data only.
  5. Track a sub-query (+) — the silent refresh does not re-request already-classified intents.

Checklist

  • Branch follows the naming convention (feature/, fix/, chore/, docs/) — see CONTRIBUTING.md
  • 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

…kground chunks

The Query Fan-out tab requested intent classification for every observed
sub-query in a single call. On a cold cache that one request serialized
dozens of LLM waves (120 queries ~= 40s+), blew past the server action's
20s fetch timeout (#428), and the badges never arrived that session.

Classify progressively instead: the visible page's 10 queries go first
(one request, at most ~2 LLM waves), then the remainder in background
chunks of 20, each merged into state as it resolves. The table never
waits on classification, a failed chunk only leaves its own rows
unbadged, and a reload/brand switch cancels the stale chain via a run
counter. Already-classified queries are skipped on silent reloads.

Closes #431
@gkhngyk
gkhngyk merged commit 49d2989 into main Jul 17, 2026
5 checks passed
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.

Query fan-out: intent badges arrive minutes late (or never) on cold cache

1 participant