Skip to content

fix(core): settings i18n refresh#14760

Open
darkskygit wants to merge 1 commit intocanaryfrom
fix/settings-i18n-wrapper-refresh
Open

fix(core): settings i18n refresh#14760
darkskygit wants to merge 1 commit intocanaryfrom
fix/settings-i18n-wrapper-refresh

Conversation

@darkskygit
Copy link
Copy Markdown
Member

@darkskygit darkskygit commented Apr 1, 2026

replace #14758

PR Dependency Tree

This tree was auto-generated by Charcoal

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced language switching to ensure the settings dialog properly reflects language changes when users update their language preference.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 1, 2026

📝 Walkthrough

Walkthrough

These changes expose useTranslation from the i18n module and implement language-aware remounting of the settings dialog by dynamically keying the FrameworkScope component based on the current active i18n language, ensuring the settings scope reinitializes when the language changes.

Changes

Cohort / File(s) Summary
I18n Module Export
packages/frontend/i18n/src/react.ts
Added useTranslation to the re-exports from react-i18next alongside existing I18nextProvider and Trans exports.
Settings Dialog Language Integration
packages/frontend/core/src/desktop/dialogs/setting/index.tsx
Integrated useTranslation hook to read the current i18n language and dynamically key the FrameworkScope component with settings-language-${currentLanguageKey}, triggering remount behavior when language changes.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 A tongue-twist and a flutter of keys,
The settings scope dances with language degrees,
i18n whispers which tongue we should speak,
And remounts the realm each time that we seek!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix(core): settings i18n refresh' clearly describes the main change: fixing i18n (internationalization) refresh behavior in the settings component by adding dynamic key-based remounting when language changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/settings-i18n-wrapper-refresh

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 and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/frontend/core/src/desktop/dialogs/setting/index.tsx`:
- Around line 198-201: Remove the language-based key on FrameworkScope to avoid
remounting the entire settings subtree: in the JSX where FrameworkScope is
rendered (currently keyed with `settings-language-${currentLanguageKey}` and
using `scope={currentServer.scope}`), delete the
`key={...currentLanguageKey...}` prop so the component is keyed only by its
stable identity (`currentServer.scope`), and if you need language-driven
updates, implement them inside a narrower child component instead of on
`FrameworkScope`.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 3c57b97b-9b1b-4e95-bb5f-42473591abef

📥 Commits

Reviewing files that changed from the base of the PR and between 91ad783 and 7cc591b.

📒 Files selected for processing (2)
  • packages/frontend/core/src/desktop/dialogs/setting/index.tsx
  • packages/frontend/i18n/src/react.ts

Comment on lines +198 to +201
<FrameworkScope
key={`settings-language-${currentLanguageKey}`}
scope={currentServer.scope}
>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

cd packages/frontend/core/src/desktop/dialogs/setting && wc -l index.tsx

Repository: toeverything/AFFiNE

Length of output: 76


🏁 Script executed:

head -220 packages/frontend/core/src/desktop/dialogs/setting/index.tsx | tail -50

Repository: toeverything/AFFiNE

Length of output: 1650


🏁 Script executed:

sed -n '190,210p' packages/frontend/core/src/desktop/dialogs/setting/index.tsx

Repository: toeverything/AFFiNE

Length of output: 654


🏁 Script executed:

rg -i "frameworkscope" packages/frontend --type typescript --type typescriptreact -B 2 -A 5

Repository: toeverything/AFFiNE

Length of output: 97


🏁 Script executed:

rg "currentLanguageKey" packages/frontend/core/src/desktop/dialogs/setting/index.tsx -B 3 -A 3

Repository: toeverything/AFFiNE

Length of output: 539


🏁 Script executed:

sed -n '1,230p' packages/frontend/core/src/desktop/dialogs/setting/index.tsx

Repository: toeverything/AFFiNE

Length of output: 7658


🏁 Script executed:

find packages -name "*.ts" -o -name "*.tsx" | xargs grep -l "export.*FrameworkScope" | head -5

Repository: toeverything/AFFiNE

Length of output: 214


🏁 Script executed:

rg "FrameworkScope" packages/frontend -A 3 -B 1 | head -80

Repository: toeverything/AFFiNE

Length of output: 6772


🏁 Script executed:

rg "currentLanguageKey" packages/frontend/core/src/desktop/dialogs/setting/ -r '$0'

Repository: toeverything/AFFiNE

Length of output: 307


🏁 Script executed:

sed -n '240,307p' packages/frontend/core/src/desktop/dialogs/setting/index.tsx

Repository: toeverything/AFFiNE

Length of output: 1856


🏁 Script executed:

find packages/frontend/core/src/desktop/dialogs/setting -name "workspace*" -type f

Repository: toeverything/AFFiNE

Length of output: 159


🏁 Script executed:

head -50 packages/frontend/core/src/desktop/dialogs/setting/workspace-setting.tsx

Repository: toeverything/AFFiNE

Length of output: 194


🏁 Script executed:

find packages/frontend/core/src/desktop/dialogs/setting/workspace-setting -name "*.tsx" | head -3

Repository: toeverything/AFFiNE

Length of output: 347


🏁 Script executed:

ls -la packages/frontend/core/src/desktop/dialogs/setting/

Repository: toeverything/AFFiNE

Length of output: 1017


🏁 Script executed:

cat packages/frontend/core/src/desktop/dialogs/setting/workspace-setting/index.tsx | head -80

Repository: toeverything/AFFiNE

Length of output: 2852


🏁 Script executed:

cat packages/common/infra/src/framework/react/index.tsx | head -100

Repository: toeverything/AFFiNE

Length of output: 2383


🏁 Script executed:

rg "language.*scope|scope.*language" packages/frontend/core/src/desktop/dialogs/setting/ -i

Repository: toeverything/AFFiNE

Length of output: 45


🏁 Script executed:

rg "remount|re-mount" packages -i | head -20

Repository: toeverything/AFFiNE

Length of output: 1653


🏁 Script executed:

head -100 packages/frontend/core/src/desktop/dialogs/setting/workspace-setting/preference/index.tsx

Repository: toeverything/AFFiNE

Length of output: 2916


Remove language-based key from FrameworkScope to prevent settings subtree remounting on locale change.

Keying FrameworkScope by currentLanguageKey forces the entire settings tree to remount when the language changes, destroying component state and in-progress interactions in nested settings flows (such as workspace properties and other workspace settings accessed via SubPageContext). Since currentServer.scope is independent of language, the key serves no functional purpose. Remove the key or move language-specific refresh logic to a narrower UI boundary within the tree.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/frontend/core/src/desktop/dialogs/setting/index.tsx` around lines
198 - 201, Remove the language-based key on FrameworkScope to avoid remounting
the entire settings subtree: in the JSX where FrameworkScope is rendered
(currently keyed with `settings-language-${currentLanguageKey}` and using
`scope={currentServer.scope}`), delete the `key={...currentLanguageKey...}` prop
so the component is keyed only by its stable identity (`currentServer.scope`),
and if you need language-driven updates, implement them inside a narrower child
component instead of on `FrameworkScope`.

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 1, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 57.29%. Comparing base (91ad783) to head (7cc591b).

Additional details and impacted files
@@            Coverage Diff             @@
##           canary   #14760      +/-   ##
==========================================
- Coverage   57.82%   57.29%   -0.54%     
==========================================
  Files        2960     2960              
  Lines      165735   165735              
  Branches    24428    24287     -141     
==========================================
- Hits        95841    94953     -888     
- Misses      66848    67658     +810     
- Partials     3046     3124      +78     
Flag Coverage Δ
server-test 76.13% <ø> (-1.00%) ⬇️
unittest 34.62% <ø> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app:core mod:i18n Related to i18n

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

1 participant