Skip to content

fix(share): The language of the shared page will cause the language of the original website to change. - #18043

Merged
wangq8 merged 1 commit into
infiniflow:mainfrom
dcc123456:fix/share-page-i18n
Aug 10, 2026
Merged

wangq8 merged 1 commit into
infiniflow:mainfrom
dcc123456:fix/share-page-i18n

Conversation

@dcc123456

Copy link
Copy Markdown
Collaborator

Summary

fix(share): The language of the shared page will cause the language of the original website to change.

  • Add persist option to changeLanguageAsync to skip writing language to localStorage
  • Pass persist: false on share pages (chat/agent/search) and floating widget so the visitor's main site language setting isn't overwritten
  • Fix SelectWithSearch using non-reactive t from i18next — switch to useTranslation() so dropdown placeholders and empty state update on language change
  • Remove unnecessary useMemo wrapping on thinkingOptions in NextMessageInput — t ref is stable so memoization prevented label updates after changeLanguage
  • Remove duplicate language init effect from RootProvider (already handled in main.tsx via initLanguage)

…rage

- Add `persist` option to `changeLanguageAsync` to skip writing language
  to localStorage
- Pass `persist: false` on share pages (chat/agent/search) and floating
  widget so the visitor's main site language setting isn't overwritten
- Fix `SelectWithSearch` using non-reactive `t` from `i18next` — switch
  to `useTranslation()` so dropdown placeholders and empty state update
  on language change
- Remove unnecessary `useMemo` wrapping on `thinkingOptions` in
  `NextMessageInput` — `t` ref is stable so memoization prevented label
  updates after `changeLanguage`
- Remove duplicate language init effect from `RootProvider` (already
  handled in `main.tsx` via `initLanguage`)

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. 🐞 bug Something isn't working, pull request that fix bug. 🧰 typescript Pull requests that update Typescript code labels Aug 10, 2026
@dcc123456
dcc123456 requested review from cike8899 and wangq8 August 10, 2026 08:09
@dcc123456 dcc123456 added the ci Continue Integration label Aug 10, 2026
@coderabbitai

coderabbitai Bot commented Aug 10, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The update makes language persistence optional, disables persistence for temporary locale changes, removes startup language restoration, and resolves select translations during rendering. It also removes memoization from the thinking options list.

Changes

Locale persistence and initialization

Layer / File(s) Summary
Language persistence contract and callers
web/src/locales/config.ts, web/src/pages/*/share/index.tsx, web/src/components/floating-chat-widget.tsx
changeLanguageAsync now accepts persist, which defaults to true. Shared pages and the floating chat widget pass persist: false.
Startup locale initialization
web/src/app.tsx
RootProvider no longer reads stored language data or changes the locale during mount.

Render-time translation updates

Layer / File(s) Summary
Render-time translation values
web/src/components/originui/select-with-search.tsx, web/src/components/message-input/next.tsx
SelectWithSearch uses useTranslation for fallback values. thinkingOptions is created directly during render instead of through useMemo.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: cike8899

Poem

A rabbit hops through locale light,
No stored tongue is changed tonight.
Selects translate when they appear,
Thinking choices stay bright and clear.
“Persist when asked,” the rabbit cheers.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly identifies the main fix: shared-page language changes must not alter the original website language.
Description check ✅ Passed The description includes the required Summary section and clearly explains the problem, implementation, and affected pages.

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.

@dcc123456
dcc123456 marked this pull request as draft August 10, 2026 08:09
@dcc123456
dcc123456 marked this pull request as ready for review August 10, 2026 08:09

@wangq8 wangq8 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this fix! The root cause analysis is solid — shared pages overwriting the main site language preference is a real UX issue, and your persist option approach is clean and backward-compatible.

What looks good:

  • changeLanguageAsync with persist option (default true) is a minimal, non-breaking API change. All callers that don't pass persist keep existing behavior.
  • The persist: false additions on share pages (agent/share, chats/share, search/share, floating widget) correctly scope the fix to the affected surfaces.
  • Removing the duplicate language init from RootProvider is correct — initLanguage in main.tsx already handles this, and having both creates a race.
  • The SelectWithSearch fix switching from import { t } from i18next (module-level, non-reactive) to useTranslation() (hook, reactive) is exactly right. Without it, default placeholders and empty states would be stuck in the initial language.

One note on NextMessageInput:

  • Removing useMemo from thinkingOptions is the right call since t from useTranslation() is reference-stable, so the memo was equivalent to useMemo(() => [...], []) — it would never update on language change.
  • Now thinkingOptions is recreated on every render. The translated strings are the same-by-value but different-by-reference each time. If the selector component does reference-equality checks on the options array, it could trigger extra re-renders. In practice, this is a minor concern for a thinking-level dropdown — not a perf hotspot. Just something to be aware of.

Overall LGTM. Nice work!

@wangq8
wangq8 merged commit 5a2cd36 into infiniflow:main Aug 10, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐞 bug Something isn't working, pull request that fix bug. ci Continue Integration size:M This PR changes 30-99 lines, ignoring generated files. 🧰 typescript Pull requests that update Typescript code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants