Skip to content

fix(prompts): shallow-update tab/sort URL params instead of router.replace - #474

Merged
gkhngyk merged 1 commit into
mainfrom
fix/prompts-tab-sync-shallow
Jul 18, 2026
Merged

gkhngyk merged 1 commit into
mainfrom
fix/prompts-tab-sync-shallow

Conversation

@gkhngyk

@gkhngyk gkhngyk commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Summary

The All Prompts table spun forever on cold loads — in dev and in production. Root cause chain, verified live against production:

  1. On mount, the tab-sync effect called router.replace('?tab=all'), firing an RSC round trip.
  2. That request intermittently dies server-side with Error: The router state header was sent but could not be parsed (captured in Vercel function logs) — a known Next.js framework issue for apps with a broad proxy/middleware matcher on Vercel (App Router _rsc navigations intermittently fail with "The router state header was sent but could not be parsed" when Proxy matcher is broad on Vercel vercel/next.js#91723, related: 92907/92961). Our proxy matcher is necessarily broad (auth gate).
  3. The failed navigation never completes, and Next holds every queued server action behind the pending transition — so getPromptsPageData never even dispatched. The suggestions card's call slipped through ahead of the replace; the table's never did.

Fix: the tab and sort keys are pure client state — the URL is only updated so deep links and reloads restore the view. window.history.replaceState does exactly that with no server request (Next's app router syncs with the History API), so the crashing RSC round trip is gone and the action queue can never be blocked by it again. Both call sites converted (tab sync + column sort); useRouter dropped from the page.

Verified in the browser: after the change the page load issues no ?tab=all&_rsc request at all, and the URL still updates to ?tab=all.

Related issue

Direct fix for the urgent "prompts page never loads" report; the upstream framework issue remains open — if sporadic RSC navigation failures ever show up elsewhere, narrowing what the proxy does for RSC requests is the next lever.

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. Cold-open /dashboard/prompts in a fresh tab: the table loads; the Network tab shows no ?tab=all&_rsc request and no 503s; the URL bar still gains ?tab=all.
  2. Switch tabs (All / Query Fan-out / Insights): URL follows, back/forward and reload land on the right tab.
  3. Sort columns on All Prompts: ?sort=…&dir=… appears in the URL without any server request; reload preserves the sort.

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

…r.replace

The tab-sync effect called router.replace('?tab=all') on mount. That
fires an RSC round-trip whose prefetch render 500s server-side, the
navigation never completes, and Next then holds every queued server
action behind the pending transition — so the page's data fetch never
even dispatched. Symptom: the All Prompts table spun forever on cold
loads, in dev and in production alike (verified live: the router's
?tab=all request returns 503/500 while a plain RSC GET of the same URL
returns 200).

The tab and sort keys are pure client state; the URL is only updated so
deep links and reloads land on the same view. window.history.replaceState
does exactly that with no server request — Next's app router syncs with
the History API — so the action queue can never be blocked by it again.
Both call sites (tab sync + column sort) converted; useRouter is no
longer needed on this page.
@gkhngyk
gkhngyk merged commit a733a3f into main Jul 18, 2026
5 checks passed
@gkhngyk
gkhngyk deleted the fix/prompts-tab-sync-shallow branch July 18, 2026 14:08
gkhngyk added a commit that referenced this pull request Jul 18, 2026
Soft navigations to /dashboard/prompts (e.g. sidebar Visibility ->
Prompts) still froze after #474: the navigation's RSC request carries
the router state tree through the intl middleware and intermittently
dies server-side with 'The router state header was sent but could not
be parsed' (captured in Vercel function logs; known framework issue for
broad proxy matchers on Vercel, vercel/next.js#91723). The failed
transition then blocks the client's queued server actions, so the
page's data fetch never dispatches.

With a single 'en' locale the only thing next-intl's middleware does
for these requests is the /en rewrite — do that manually for any
request carrying an RSC or Next-Action header and skip the intl
machinery entirely. Auth checks still run first; supabase session
cookies are still forwarded.

Document requests (no RSC header) keep going through next-intl
unchanged.
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