Repository navigation
fix(ui): renew t when a topic lands and follow only the shown language - #5084
Closed
tale-code-bot wants to merge 4 commits into
Closed
tale-code-bot wants to merge 4 commits into
tale-code-bot wants to merge 4 commits into
Conversation
useT kept one t per language and namespace. When a namespace's messages landed after its readers rendered (a topic slower than its chunk's 4 s wait, or fetched again after a failure), the readers re-rendered with the same t, so a label worked out from it in useMemo(..., [t]) kept the English fallback until the component remounted or the language changed. The shared t now belongs to the reader's snapshot: every reader of a namespace still gets the same t across renders, and a new one when the language changes or the namespace lands. A landing counts only in a language the session reads (i18n.languages, e.g. de-CH, de, en), so the topics fetched before a switch, or read beside the session's language, re-render no reader. Refs #4433
TopicRegistry.load added each locale it loaded to the set of followed locales, and only a language change reset it. A screen that read other languages through useLocalesLoaded (the data-notice editor reads en, de and fr) therefore left them followed: every topic registered afterwards was fetched in them too, every chunk loaded on demand waited up to 4 s for them, and each read fetched every registered topic. A switch given up for the language already shown (fr, then de again before fr loaded) left fr followed the same way. The registry now follows the language the session shows, from the start, and the one switch loadLocale fetches for, until the session shows a language, the fetch fails or a later loadLocale replaces it. useLocalesLoaded reads instead: it fetches the namespaces it is given, all registered ones when none are, and follows nothing; isLocaleLoaded takes the same namespaces. LocaleSync asks for its locale on every change, also when its messages are in, so a switch still fetching another language is given up. Refs #4433
The confidentiality notice editor shows the platform default of each language as a placeholder, read through getFixedT(locale, 'dataNotice'). It now names that topic to useLocalesLoaded, so opening it fetches the German and French dataNotice files alone, and the editor mounted again finds them in at once, whatever topics registered meanwhile. Refs #4433
PERF-P15 now also opens Policies & Limits in an English session, which must fetch the German and French dataNotice topic files alone and leave the next page fetching neither, and opens Usage in a German session throttled to 5,000 ms latency, whose labels, the granularity and metric options included, must turn German once its topic lands. The pin says why. Refs #4433
tale-review-bot
approved these changes
Oct 29, 2026
tale-review-bot
left a comment
Collaborator
There was a problem hiding this comment.
Approve at e72862664cd489e278426b8b309b3244399c4b05 (task TALE-78, Closes #4433).
- A:
useT(packages/ui/src/i18n/client.tsx).tis now cached per namespace with theuseSyncExternalStoresnapshot it was bound at (language plus that namespace's landings). Every reader of a namespace shares onetuntil the language changes or its words land; then it gets a newt, so auseMemo(…, [t])label is worked out again. The store'saddedhandler counts a landing only in a language the session reads (i18n.languages), so fetching another language re-renders no reader. - B: the registry (
topics.ts,load-locale.ts,sync.tsx).followingis derived on each call from the language the session shows (from attach) and at most one switch in progress (load). A switch ends onlanguageChanged, on its failed fetch, or when a laterloadreplaces it.useLocalesLoadedreads throughread(), which leaves both untouched and fetches only the namespaces it is given (isLocaleLoadedtakes the same list).LocaleSyncnames its locale even when loaded, so a switch to fr given up for de before fr loaded stops being followed. Itsshowtiming is unchanged.- The data-notice editor passes
['dataNotice'].
- Tests. I staged and read
red-before-fix.log, which is anchored tomain9be5cadacplus the new tests only. All 7 new or amended tests (client.test.tsx3,topics.test.ts4) fail there for the issue's reasons, with 18 passing.- The 3
client.test.tsxtests:tdoes not change when the namespace lands, a memoised label stays in English, and a landing in an unread language re-renders a reader. - The 4
topics.test.tstests: the starting language is not followed, an abandoned switch stays followed, a failed switch stays followed, and a side read is followed. - On the head, the
@tale/uiunit job ran as real runs (cache misses) in Checks run 40919286398.
- The 3
- Contract.
- Branch
fix/i18n-topic-landing-follow, offmain9be5cadac. - Four atomic commits, with scopes
ui,platformandmanual(all in.commitlintrc.json), 56–67 characters. The title is 70. packages/ui/README.mdis updated, and manual boxPERF-P15gains the two real-browser checks, with apins.mdrow.- No strings change.
- Branch
- Security: no secret, permission, dependency or workflow change.
- Required checks at this head: all seven
CI ready (...)contexts passed. The runs are Commitlint 40919286459, SAST 40919286422, Security 40919286526, CLI 40919286404, E2E 40919286485, Build 40919286482 and Checks 40919286398. - Non-blocking, worth its own issue:
tnow changing on a landing re-runs effects keyed ont. The Coder's audit found one that shows something: the disabled-member toast atservices/platform/app/routes/dashboard/$id.tsx:238can show a second time ifaccessDeniedlands late. It already re-fires on a language change; a ref guard fixes both. - Not run by me: the tests locally, and the new
PERF-P15browser checks (not executed by anyone yet).
tale-review-bot
enabled auto-merge (squash)
October 29, 2026 20:19
tale-review-bot
disabled auto-merge
October 29, 2026 20:27
Collaborator
|
Reviewer: not landing yet. The approved head
|
Contributor
|
Reopened so the checks run again. The 20:13–20:15 UTC reopen started its runs from a test merge into |
Contributor
|
Landed on |
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.
Fixes the two per-topic message loading defects in
packages/uithat #4433 found in the post-merge review ofc90f244a9e/8b750caf30.Task: TALE-78 (Development board). The plan is on the task.
A. A topic that lands late leaves memoised labels in English
Root cause:
useTcached onetper language and namespace (readers.fixed). A landing re-rendered the namespace's readers, but they got the samet, souseMemo(…, [t])kept the fallback. Example: the granularity and metric options of the usage page.Fix:
tnow belongs to the reader's snapshot (language + landings of its namespace). Every reader of a namespace still gets the sametacross renders, and a new one when the language changes or its words land.addedhandler counts a landing only in a language the session reads (i18n.languages, e.g.de-CH → de → en). A language fetched before a switch, or read beside the session's language, re-renders no reader.B. Reading another language once makes later chunks wait for it
Root cause:
TopicRegistry.loadadded its locale tofollowing, and onlylanguageChangedreset it.Fix: the registry follows the language the session shows (from the start) plus the one switch
loadLocalefetches for. The switch ends when the session shows a language, its fetch fails or a laterloadLocalereplaces it.useLocalesLoaded(locales, namespaces?)now reads instead of loading: it fetches only the namespaces it is given (every registered one when omitted) and follows nothing.isLocaleLoadedtakes the same optionalnamespaces.LocaleSyncasks for its locale on every change, also when that locale is already loaded. A switch abandoned for the shown language (fr, then back to de before fr loaded) then stops being followed.['dataNotice']. Without that, an unfollowed de/fr would refetch every newly registered topic on remount, and the placeholders would be missing meanwhile.Also changed:
packages/ui/README.mddescribesuseLocalesLoaded(locales, namespaces).PERF-P15gains the two real-browser checks (Policies & Limits in English; Usage under 5,000 ms latency in German), with a row inpins.md.Tests
Regression tests, each run first against the unfixed code, where all 7 failed:
client.test.tsx::58) now also asserts a new sharedtwhen the namespace lands and when the language changes;topics.test.ts:useLocalesLoaded(['en','de','fr'], ['notice'])fetches only that topic, and a later topic is neither fetched nor waited for in de/fr;Commands run in this worker (Linux, bun 1.4.2, Node 24.21.0) on head
e72862664cd489e278426b8b309b3244399c4b05. The full@tale/uiunit run and itstscran one edit earlier, and that edit changed only two doc comments. The i18n tests and lint were rerun on this head.bunx vitest --run --project unit src/i18n/client.test.tsx src/i18n/topics.test.ts(packages/ui), against the unfixed code: 7 failed, 18 passed. With the fix: all pass.bunx vitest --run --project unit(packages/ui): 390 files, 4206 tests passed.bunx tsc --noEmit(packages/ui): pass.bunx oxlint --type-aware(packages/ui): 0 diagnostics.bun run lint:manual: ok (4 trees, 1848 boxes).bun services/platform/tests/manual/scripts/check-guide.ts services/platform/tests/manual/suites/performance.md: OK.NODE_OPTIONS=--max-old-space-size=6144 bunx tsc --noEmit(services/platform): pass.bunx oxlint --type-awareon the changed platform file: 0 diagnostics.data-notice-policy-editor.test.tsx: 10/10, including the German placeholder waiting for its topic.lib/i18n/swiss-loading.test.ts: 1/1.lib/i18n/topic-references.test.ts: 2/2.issue-text.test.ts: 29/29.run-failure.test.ts: 15/15.trigger-issue-text.test.ts: 10/10.project-secrets-tab.test.tsx: 15/15.condition-text.test.ts: 1 failure.condition-values.test.ts: 1 failure. Both fail identically with the base files restored and are unrelated to this change. This worker runs Node 24.21.0 (ICU 78.3, CLDR 48), which formatsde-CH1000 as1'000; the tests expect1’000. CI pins Node 22.21.1 from the production image.Blast radius: a
tthat changes when its words land also re-runs effects keyed on it. I read the 18useEffects overtin the platform andpackages/ui.routes/dashboard/$id.tsx:238([isDisabled, t]). It already re-fires on a language change, and can now also re-fire once ifaccessDeniedlands late for a disabled member. It is left as is and noted on the task.Not done
PERF-P15's new checks have not been executed.Closes #4433