Repository navigation
fix(prompts): consolidate the page's first load into one server action - #473
Merged
Merged
Conversation
The Prompts page's cold load was slow because Next.js queues client-fired server actions sequentially — each is its own POST — and the page fired three (volumes + prompt sets + visibility summaries) with the suggestions card's fourth queued behind them: total wait was the SUM of all of them (the #313 lesson from Insights, never applied here). - New getPromptsPageData action runs the three reads in a real server-side Promise.all — one round trip. A volumes failure/timeout degrades to an empty list with a warning toast instead of blanking the prompt table: the page's core content is never hostage to the volumes upstream. - Visibility summaries move to a prompt_visibility_summaries RPC (migration 00025, SECURITY INVOKER): one GROUP BY per brand instead of pulling the raw 30-day result window into JS — which was also silently capped at 1000 rows by PostgREST, so busy brands showed wrong health columns (the #430/#464 defect family). Verified on production data: 104 prompt rows, max 210 runs per prompt — depth the 1000-row sample could never see. - The aeo-server fetches for volumes and the suggestions-card read get AbortSignal.timeout(15s) (#427 lesson) so a hung upstream can't pin the queue. Fixes the reported slow/never-ending first load of /dashboard/prompts.
gkhngyk
force-pushed
the
fix/prompts-page-first-load
branch
from
July 18, 2026 13:30
0da5536 to
d1e8d33
Compare
7 of 12 tasks
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
The Prompts page's cold load was slow (reported as a minutes-long spinner). Next.js queues client-fired server actions sequentially — each is its own POST — and the page fired three on mount (volumes + prompt sets + visibility summaries) with the suggestions card's fourth queued behind them: the total wait was the SUM of all of them. This is the #313 lesson from Insights, never applied here.
getPromptsPageDataaction runs the three reads in a real server-sidePromise.all— one round trip. Verified live in the browser: resolves in ~1s on a brand with a 13k-row result window.prompt_visibility_summariesRPC (migration00025, SECURITY INVOKER, already applied to the hosted project): one GROUP BY per brand instead of pulling the raw 30-day window into JS — which was also silently capped at 1000 rows by PostgREST, so busy brands showed wrong health columns (the fix(citations): page past the silent 1000-row cap in overview and gaps scans #430/Topics: leaderboard numbers disagree with Insights — unpaginated scan, no shopping exclusion, fixed window #464 defect family). Verified on production data: 104 prompt rows, max 210 runs per prompt — depth the 1000-row sample could never see.AbortSignal.timeout(15s)(Query fan-out: long hang then production-masked server error surfaced raw in the UI #427 lesson).Note: during debugging we also found the local dev slowness had a second, environment-side component (a corrupted
.nextincremental cache after heavy branch switching — fixed byrm -rf web/.next). The changes here address the real product-side costs and are what production users feel.Related issue
No open issue — urgent fix requested directly; supersedes the client-side symptoms investigated on the Prompts page.
Type of change
feat— New featurefix— Bug fixchore— Maintenance / dependenciesdocs— Documentation onlyrefactor— Code change that neither fixes a bug nor adds a featuretest— Adding or updating testsHow to test
/dashboard/promptsin a fresh tab: the table loads in a single round trip (one action POST in the Network tab instead of three serialized ones).Checklist
feature/,fix/,chore/,docs/) — see CONTRIBUTING.mdyarn lintpasses (run fromweb/)yarn typecheckpasses (run fromweb/)yarn format:checkpasses (run fromweb/)