Skip to content

fix(web): preserve locale preference during prefetch - #13255

Merged
teamleaderleo merged 3 commits into
mainfrom
fix/locale-prefetch-preference
Sep 20, 2026
Merged

teamleaderleo merged 3 commits into
mainfrom
fix/locale-prefetch-preference

Conversation

@teamleaderleo

@teamleaderleo teamleaderleo commented Sep 20, 2026 •

Copy link
Copy Markdown
Collaborator

A Korean-route prefetch can complete after the language picker has selected English and overwrite NEXT_LOCALE=en with ko. The page remains English, but reloads use the stale preference. A browser trace reproduced this ordering: the prefetch requested /ko/blog/cmux-vault with the new English cookie, then returned Set-Cookie: NEXT_LOCALE=ko.

Suppress next-intl's cookie publication for all router-prefetch variants (including static 1, runtime 2, and shell 3) and purpose: prefetch, preserving its locale routing and request headers. Rebuild the response without the cookie headers so later cookie writes cannot resurrect the preference from an internal cookie map. Ordinary document and RSC navigation still persist the destination locale. The language picker and existing browser assertions are unchanged.

Validation: the static/purpose regressions fail before the initial fix, and the runtime/shell regressions fail before the review fix. All 10 focused middleware/link tests, typecheck, and the complexity check pass on the current head. The initial fix also passed all four existing production-browser locale cases (Korean/Japanese/Arabic roundtrips and nested-route reload), 20 further nested-route repetitions, and the complexity gate across all tracked web sources. Fresh hosted browser/CI results are required for the review follow-up. The original browser failure was preserved (1 failure in 10 baseline nested-route repetitions), rather than waived as unrelated CI noise.

Fixes #13246.

@coderabbitai

coderabbitai Bot commented Sep 20, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 2 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Repository: manaflow-ai/cmux/.coderabbit.yaml

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 5a76b684-0799-4a19-9d49-56a52c40e5ac

📥 Commits

Reviewing files that changed from the base of the PR and between 692f2c0 and 65b4b0b.

📒 Files selected for processing (2)
  • web/proxy.ts
  • web/tests/locale-prefetch-cookie.test.ts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@greptile-apps

greptile-apps Bot commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

The PR appears safe to merge; the previously missed runtime-prefetch variant is handled and no new actionable failure remains.

Summary

The PR prevents delayed locale-route prefetch responses from overwriting a newer explicit locale preference.

  • Detects all next-router-prefetch variants as well as purpose: prefetch.
  • Rebuilds prefetch responses without locale cookie-publication headers while preserving locale routing metadata.
  • Adds deterministic coverage for prefetch header values 1, 2, and 3, plus a real-navigation control.
  • The previous finding is fully addressed: runtime prefetch value 2 is now recognized and tested.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Localized request] --> B[next-intl middleware]
    B --> C{Prefetch header present?}
    C -- Yes --> D[Remove cookie publication headers]
    D --> E[Return routing response without changing preference]
    C -- No --> F[Return normal response]
    F --> G[Persist destination locale]
Loading

Reviews (2) · Last reviewed commit: "fix: cover runtime and shell locale pref..."

Comment thread web/proxy.ts Outdated
@teamleaderleo
teamleaderleo merged commit 9e7d3be into main Sep 20, 2026
39 of 40 checks passed
rustybret pushed a commit to rustybret/bmux that referenced this pull request Sep 20, 2026
e77a6b1 feat: add current-work reads and Find Work (manaflow-ai#13269)
6386ba5 Cache Ghostty CLI helper builds across local invocations (manaflow-ai#13206)
8f6c0ea ci: measure compiled test artifact transfer cost (manaflow-ai#13172)
55092b9 docs: add a concise guide for public CMUX writing (manaflow-ai#13257)
9e7d3be fix(web): preserve locale preference during prefetch (manaflow-ai#13255)
b093335 build: skip unchanged diff sidecar builds (manaflow-ai#13212)
b79d77d perf: skip unchanged bundled resource builds (manaflow-ai#13209)
4c19fcb feat: expose stable surface and workspace IDs in catalog reads (manaflow-ai#13247)
95fdfd7 ci: add safe stale run janitor (manaflow-ai#13143)
0bcf003 docs: make the contributor verification ladder explicit (manaflow-ai#13242)
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.

web: locale navigation retains Korean cookie after switching to English

1 participant