Repository navigation
Closed
Labels
Description
Problem
On the prompts page's Query Fan-out tab, the table renders quickly but the Intent column fills in much later — on a cold cache, minutes later, and since #428's 20s fetch abort, possibly not until a later visit.
Why (verified in code)
POST /api/prompts/fanout-intents(https://github.com/ansvisor/ansvisor/blob/main/server/src/routes/prompts.js) classifies every cache-miss with the LLM before responding — concurrency 6, up to 200 queries per request. 120 cold queries ≈ 20 waves of LLM latency ≈ 40s+ for a single response.- The client (
web/src/app/[locale]/(dashboard)/dashboard/prompts/_fanout-tab.tsx) requests intents for all observed sub-queries in one call, not the 10 rows actually visible (PAGE_SIZE = 10) — the user waits on classifications for rows they may never scroll to. - The initial paint deliberately stops waiting after 1.5s and lets the badges fill when the batch resolves — correct instinct, but the batch itself is the bottleneck.
- Since fix(fanout): complete aggregation, bounded fetches, real error messages #428, the action's 20s
AbortSignal.timeoutcuts the request off; the server keeps classifying and persists tofanout_query_intents, so intents appear only on a later visit. Better than a pinned function, but it turns "late" into "never (this session)".
Proposal
- Client: chunked, page-first requests. Ask for the visible page's queries first (fast — mostly cache hits or ≤10 LLM calls), then classify the remainder in background chunks of ~20, merging each chunk into state as it resolves. Badges appear progressively instead of all-or-nothing. No server change strictly required.
- Server (optional hardening): accept the smaller batches as-is; consider returning cached hits +
pending: [...]for misses instead of blocking, so no request ever waits on LLM waves.
Acceptance criteria
- Visible rows show intent badges within a few seconds on a warm cache, and within one LLM round-trip on a cold cache.
- Remaining rows fill progressively; no single request blocks on classifying the entire observed set.
- Works within the existing 20s fetch timeout (no request needs anywhere near it).
Activity