Skip to content

fix: update Linked resource badge on runtime language change - #716

Open
nabalone wants to merge 4 commits into
developfrom
fix-linked-badge-language-switch
Open

nabalone wants to merge 4 commits into
developfrom
fix-linked-badge-language-switch

Conversation

@nabalone

Copy link
Copy Markdown
Collaborator

Summary

The mobile Internalization resource list drew its Linked badge from row.artifactType — a localized string snapshotted when the row was built. After a runtime language change the rows are not rebuilt, so the badge kept showing the old language's wording.

The component now reads the artifactType strings itself via useSelector(artifactTypeSelector, shallowEqual) and uses at.linked. This follows the TT-6225 rule in docs/ai/localization.md: read strings at the point of use, never from a snapshot.

row.isGeneralResource and row.artifactTypeSlug carry no language, so they are still read from the row.

Changes

  • PassageDetailsArtifactsMobile.tsx — add artifactTypeSelector / IArtifactTypeStrings, use at.linked in typeBadge.

Test plan

  • Open a passage's Internalization tab in mobile view as an admin with a linked (shared) resource attached.
  • Switch the UI language in the profile dialog without refreshing.
  • The Linked badge should immediately show the new language's wording (previously it stayed in the old language).

🤖 Generated with Claude Code

The mobile Internalization badge read row.artifactType, a localized
string snapshotted when rows are built, so it kept the old wording after
a runtime language change. Read artifactType strings at the point of use.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@nabalone
nabalone force-pushed the fix-linked-badge-language-switch branch from 3a54290 to 9308911 Compare November 13, 2026 16:08
@nabalone
nabalone requested a balanced review from Copilot November 13, 2026 16:09

Copilot AI left a comment

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.

Note

Copilot was unable to complete this review at the selected tier due to model policy or plan restrictions.

🟢 Approval recommended

The change is narrowly scoped to sourcing the Linked badge label from selector-derived localization at render time, addressing the runtime language-switch bug with no review evidence of remaining issues.

No open issues 🎉

What changed in this PR

Fixes a mobile Internalization localization bug where the Linked resource badge stayed in the old language after a runtime language change because it was sourced from a snapshotted, already-localized row field.

Changes:

  • Read artifact-type localization strings at render time via useSelector(artifactTypeSelector, shallowEqual).
  • Render the Linked badge using at.linked instead of row.artifactType so it updates immediately on language switch.
File Description
web/​src/​components/​PassageDetail/​Internalization/​PassageDetailsArtifactsMobile.tsx Updates the Linked badge label to use selector-derived artifact-type strings at render time so it reflects runtime language changes instead of a localized row snapshot.

Review effort: Balanced

@nabalone
nabalone marked this pull request as ready for review November 13, 2026 16:31
? t.general
: row.artifactTypeSlug === ArtifactTypeSlug.SharedResource
? row.artifactType
? at.linked

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.

what is at.linked? That name means nothing to me - certainly doesn't sound like a localized version of the artifact.

? t.general
: row.artifactTypeSlug === ArtifactTypeSlug.SharedResource
? row.artifactType
? at.linked

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.

Can we get rid of row.artifactType entirely? This is the localized string? Do we also store the id?

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.

Oh...I see we store the artifactTypeSlug above. Duh. So we should get rid of row.artifactType.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done, with some related refactoring

Copilot AI left a comment

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.

Note

Copilot was unable to complete this review at the selected tier due to model policy or plan restrictions.

🟡 Changes recommended

Outstanding review findings include unsafe type escapes (as any) and a potentially unsafe localization lookup cast/fallback that could yield non-string values or mishandle empty translations, so these issues should be addressed before approval.

2 open issues

Review effort: Balanced

Comment on lines +8 to +12
export const useLocalizedArtifactType = () => {
const t: IArtifactTypeStrings = useSelector(stringSelector, shallowEqual);
return (val: string): string =>
(t as unknown as Record<string, string | undefined>)[val] || val;
};
onDelete={onDelete}
/>
),
} as any
Use the shared artifactTypeSelector in useLocalizedArtifactType and guard
the lookup so only non-empty strings are returned. Drop the unneeded
slug cast in PassageDetailItem and the leftover `as any` in SortableItem.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@nabalone

Copy link
Copy Markdown
Collaborator Author

Also noting I just made a behavior change in this: “General Resource” → “General” in the Type column because this simplifies things since we will soon move to the new design which does not use the string “General Resource”. If it is really a problem to say “General” in the type column, let me know and we can hold off on merging this PR and I will do the switch to the new design first

image image

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.

3 participants