Skip to content

fix(i18n): localize the status bar resource and host labels - #12439

Closed
smwbev wants to merge 2 commits into
stablyai:mainfrom
smwbev:fix/localize-status-bar-resource-labels
Closed

smwbev wants to merge 2 commits into
stablyai:mainfrom
smwbev:fix/localize-status-bar-resource-labels

Conversation

@smwbev

@smwbev smwbev commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Summary

The status bar renders the Resource Manager tooltip and the remote-host count from bare literals inside helper functions, so both stay English while everything around them is translated.

resource-manager-terminal-copy.ts builds the whole tooltip without touching the catalog:

export function formatTerminalSessionCount(count: number): string {
  return `${count} terminal session${count === 1 ? '' : 's'}`
}
// …
lines.push('Terminal sessions are grouped by workspace.')

SshStatusSegment.tsx does the same for the collapsed segment:

function connectedHostCountLabel(count: number): string {
  return `${count} ${count === 1 ? 'host' : 'hosts'}`
}

Why the coverage gate does not catch it. audit-localization-coverage.mjs inspects JSX attributes and object properties, not values returned by helper functions, so pnpm verify:localization-coverage passes while the strings ship untranslated. This is the same class of defect as #11826; that sweep counted 57 such helpers across the renderer, and this PR takes the status bar ones.

What changed

Area Strings
Resource Manager tooltip headline, memory-unavailable fallback, space-scan row, grouped/empty session rows
Resource Manager screen-reader label segment name + session count
Remote hosts segment host count (singular/plural) + Connecting…

sync:localization-catalog added 11 keys; nothing was removed or reworded (11948 → 11959, 0 deletions, 0 value changes). English wording is byte-identical.

A latent bug this surfaces

The segment tinted one tooltip row by comparing it against the English text:

className={line === 'Space scan ready' ? 'text-primary' : ''}

That comparison stops matching the moment the copy comes from the catalog, so simply routing the string through translate() would have dropped the tint in every non-English build. getResourceManagerTooltipLines now returns { text, emphasized } and the segment reads the flag. A test pins it so the text-matching pattern cannot come back.

Notes on the approach:

  • Keys are stable and semantic (sessionsGroupedByWorkspace, hostCountOther) rather than content hashes, matching config/i18n-translation-source.md: "a feature developer adds a stable message ID and current English copy once".
  • Plural forms use two explicit keys selected by a ternary, matching how the rest of the codebase selects plurals rather than introducing count.
  • Host helpers moved to ssh-status-copy.ts so SshStatusSegment.tsx keeps its headroom under the 400-line gate — the same split accepted in fix(i18n): localize status labels in settings and stats #11826.

Screenshots

No visual change in English — every string keeps its exact English wording, so an English build renders identically.

The defect is only visible in a localized build. From a Russian language pack on current main, before this PR — the tooltip and 0 hosts sit in English next to a fully translated status bar:

Status bar

Testing

  • pnpm lint
  • pnpm typecheck
  • pnpm test
  • pnpm build
  • Added or updated high-quality tests that would catch regressions

src/renderer/src/i18n/status-bar-copy-localization.test.ts pins all 11 keys to their English text, so a helper that reverts to a bare literal fails the suite. resource-manager-terminal-copy.test.ts gains a case asserting that the space-scan row is flagged rather than recognized by its wording.

The full suite reports 44520 passed with 20 pre-existing failures across 8 files — omp-shell-wrapper.node-pty, ssh-posix-command-wrapper, updater, terminal-ime-hangul-syllable-flush, terminal-ime-xterm-composition-cancel, automation-schedules, external-automation-jobs-file, and macos-computer-helper-owner-loss-processes. All of them reproduce on a clean upstream/main checkout on this machine (macOS, Node 26), and none touch the status bar or i18n. The status-bar suite specifically is green: 38 files, 268 tests.

AI Review Report

Reviewed the diff for correctness, localization behavior, and cross-platform impact on macOS, Linux, and Windows.

  • Flagged and fixed: the line === 'Space scan ready' comparison described above. Routing the copy through the catalog without this change would have been a silent visual regression in every translated build — caught before pushing, and now covered by a test.
  • Cross-platform: the change touches UI copy and its lookup path only. No paths, shell invocations, keyboard shortcuts, path separators, or Electron platform APIs are involved. Connecting… uses U+2026, already present in this file. The memory label (3.69 GB · Σ RSS) is produced upstream by memoryMetricCopy and is passed through unchanged as an interpolation value on all platforms.
  • Verified: English output is unchanged, confirmed by the pre-existing assertions in resource-manager-terminal-copy.test.ts; the full status-bar suite (38 files, 268 tests) passes.

Security Audit

  • Input handling: memoryLabel originates from the daemon resource snapshot over IPC. It previously reached the DOM via template concatenation and now reaches it as an i18next interpolation value — the same data on the same path, no new source of untrusted input.
  • Escaping: the renderer sets interpolation.escapeValue: false, but these strings render as React text nodes ({line.text}), so React escapes them. No dangerouslySetInnerHTML, no HTML assembly.
  • Command execution / paths / auth / secrets / dependencies: untouched. No new IPC channels, no new dependencies, no filesystem or process access.

Notes

Plural forms are selected with a ternary because that is the existing convention. This keeps two-form languages working and leaves languages with more plural categories approximated, which is the subject of #12106 — no change to that is proposed here.

smwbev added 2 commits August 4, 2026 13:00
The Resource Manager tooltip and the remote-host count were built from bare
literals inside helper functions, so they stayed English with a language pack
active. Route them through translate() with stable keys.

Host helpers move to ssh-status-copy.ts so SshStatusSegment.tsx keeps its
headroom under the 400-line gate.
…its text

The segment tinted that row by comparing the line against the English string,
which stops matching the moment the copy comes from the catalog. Return the
flag with the line so the tint survives translation.
@smwbev
smwbev requested a review from brennanb2025 as a code owner August 4, 2026 06:15
@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: f4805318-9c74-4eed-93bf-884fa9ca23e7

📥 Commits

Reviewing files that changed from the base of the PR and between ed4d697 and 226a41e.

📒 Files selected for processing (7)
  • src/renderer/src/components/status-bar/ResourceUsageStatusSegment.tsx
  • src/renderer/src/components/status-bar/SshStatusSegment.tsx
  • src/renderer/src/components/status-bar/resource-manager-terminal-copy.test.ts
  • src/renderer/src/components/status-bar/resource-manager-terminal-copy.ts
  • src/renderer/src/components/status-bar/ssh-status-copy.ts
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/status-bar-copy-localization.test.ts

📝 Walkthrough

Walkthrough

Status-bar copy now uses localized catalog entries for Resource Manager, terminal sessions, workspace states, reconnect attempts, and SSH host counts. Resource Manager tooltip lines carry text and emphasis metadata, and the renderer uses that metadata for styling. SSH status rendering uses shared helpers for connected-host counts and connecting-state text. Tests verify tooltip structures, emphasis behavior, and required English localization values.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 30.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
Title check ✅ Passed The title clearly identifies the main change: localizing Resource Manager and host labels in the status bar.
Description check ✅ Passed The description covers the summary, screenshots, testing, AI review, security audit, and platform-specific notes with sufficient detail.
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.

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.

@nwparker

nwparker commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Thanks @smwbev — I reproduced this independently and your diagnosis is right, including the point that audit-localization-coverage.mjs cannot see values returned from helper functions.

I've opened #12478 with a fix that builds on yours. Credit where it's due: your { text, emphasized } change caught a real bug in my version. I had localized 'Space scan ready' but left ResourceUsageStatusSegment.tsx:1193 tinting the row via line === 'Space scan ready', so the highlight silently vanished in every translated build. I've adopted your structural fix and your unit test for the flag, and commit 6d1fdbc is co-authored to you.

Visual proof of exactly that, three states from one harness under a Japanese UI (before / localize-only / after) is in #12478.

What #12478 adds on top:

  • es/ja/ko/zh translations. This PR adds keys to en.json only, so at runtime nothing changes — translate() already falls back to the same inline English default. Recent i18n fixes here (0d38053945, 8fc892dd02) ship the target catalogs in the same PR.
  • The 'Workspace conflict' / 'Workspace sync error' ternary two lines from the Connecting… you fixed.
  • A narrowing of classifyStringNode so ?? / || / && ancestors keep walking, which surfaced 4 more genuine unlocalized strings. (I left the helper-return half open — I measured 1056 candidates, too big for a bug fix.)
  • Whole-line keys for the tooltip summary and aria label instead of parts.join(', '), since ja/zh repunctuate to 、.

Happy to close mine in favour of yours if you'd rather land the target catalogs and the sibling strings here instead.

@smwbev

smwbev commented Aug 4, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @nwparker — closing this in favour of #12478, and I appreciate you tracing the tint bug back rather than just landing your own version.

Your PR is the better one to ship, for two reasons that are not close calls:

  • It ships the target catalogs. This PR only adds keys to en.json, so es/ja/ko/zh would have stayed English until a follow-up. I am not in a position to write those four translations to a standard worth shipping, so landing mine first would have meant landing the smaller half.
  • ariaLabel / ariaLabelWithSpaceScan is a real fix to my version. I built the screen-reader label with parts.join(', '), which bakes a comma into every locale. Whole-line keys are correct and I had missed it.

Two things that may save you a round trip.

The plural mechanism may draw a review comment

You use {{count}} with _one/_other. That is what I originally proposed in #11826, and @AmethystLiang rewrote it to a === 1 ? … : … ternary before merging — the codebase has since read as if the ternary were the house style. Worth knowing before review, since the two of you have now landed on different answers for the same question.

Separately, and unrelated to which mechanism you pick: neither one produces CLDR plural categories for plugin language packs. Those register under a synthetic plugin<hex> resource language, which i18next does not map to a locale, so a Russian pack falls back to English plural rules — two forms where Russian needs three. That is what #12106 is about, and your PR is a good concrete example if you want to weigh in there. It does not affect the built-in catalogs in your diff.

The helper-return sweep you set aside

You mentioned measuring 1056 candidates and leaving that half open — that number is dominated by noise, and a narrower cut is tractable. Scanning src/renderer/src on 13f033f09 for functions that return a bare UI-shaped string literal (excluding anything already inside translate(), plus Tailwind class lists), then keeping only those whose result reaches JSX:

87 functions, 214 literals. Heaviest files:

Literals File
10 components/automations/AutomationsPage.tsx
10 components/automations/automation-page-parts.tsx
10 components/crash-report/CrashReportDialogSurface.tsx
10 components/github/pr-check-presentation.ts
10 components/right-sidebar/checks-panel-content.tsx
9 components/task-page-github-work-item-status.ts
8 components/AgentStateDot.tsx
8 components/settings/repository-source-control-ai-labels.ts
8 components/status-bar/usage-error-copy.ts
7 components/settings/McpConfigFileRow.tsx

Spot-checking the top of that list: getCheckStatusLabel() returns Successful / Failed / Cancelled / Timed out / …, and agentStateLabel() returns Working / Blocked / Waiting for input / … — all user-visible, none reachable by the coverage audit today.

Treat 214 as an upper bound rather than a worklist: a tail of it is proper nouns that should stay English (getProviderDisplayName() returns Claude, Codex, Grok). Happy to share the scan script if it is useful, or to take a slice of that list as a separate PR once #12478 lands — your call, and no need to route it through me if you would rather keep it in one pair of hands.

@smwbev

smwbev commented Aug 4, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by #12478, which carries this fix plus the es/ja/ko/zh catalogs.

@smwbev smwbev closed this Aug 4, 2026
nwparker added a commit that referenced this pull request Aug 7, 2026
…its English text

The tooltip tinted a row with `line === 'Space scan ready'`, so routing that
copy through the catalog silently dropped the tint in every translated build.
Return `{ text, emphasized }` and let the segment read the flag.

Adopted from #12439 by @smwbev.

Co-authored-by: Evgenii <[email protected]>

Co-authored-by: Orca <[email protected]>
nwparker added a commit that referenced this pull request Aug 7, 2026
…e-host count (#12478)

* fix(i18n): localize the status bar Resource Manager tooltip and remote-host count

The Resource Manager tooltip/aria label and the SSH segment's host count were
assembled from bare English literals inside helper functions, so they stayed
English under every non-English UI language while the labels around them
translated. Route them through the catalog with _one/_other plural keys and
whole-line messages (locales reorder and repunctuate the summary), and add
en/es/ja/ko/zh entries.

Root cause of the miss: audit-localization-coverage bailed on any ancestor
binary expression whose operator was not `+`, which hid every string under a
`cond && <JSX/>` guard or a `?? 'fallback'` — including this segment's
'Connecting…'. Only comparison operands are code, so keep `??`, `||` and
`&&` walking, and localize the four real strings that surfaced.

Co-authored-by: Orca <[email protected]>

* fix(status-bar): flag the space-scan tooltip row instead of matching its English text

The tooltip tinted a row with `line === 'Space scan ready'`, so routing that
copy through the catalog silently dropped the tint in every translated build.
Return `{ text, emphasized }` and let the segment read the flag.

Adopted from #12439 by @smwbev.

Co-authored-by: Evgenii <[email protected]>

Co-authored-by: Orca <[email protected]>

* fix(status-bar): key Resource Manager tooltip rows by role instead of array index

Co-authored-by: Orca <[email protected]>

---------

Co-authored-by: Orca <[email protected]>
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…e-host count (stablyai#12478)

* fix(i18n): localize the status bar Resource Manager tooltip and remote-host count

The Resource Manager tooltip/aria label and the SSH segment's host count were
assembled from bare English literals inside helper functions, so they stayed
English under every non-English UI language while the labels around them
translated. Route them through the catalog with _one/_other plural keys and
whole-line messages (locales reorder and repunctuate the summary), and add
en/es/ja/ko/zh entries.

Root cause of the miss: audit-localization-coverage bailed on any ancestor
binary expression whose operator was not `+`, which hid every string under a
`cond && <JSX/>` guard or a `?? 'fallback'` — including this segment's
'Connecting…'. Only comparison operands are code, so keep `??`, `||` and
`&&` walking, and localize the four real strings that surfaced.

Co-authored-by: Orca <[email protected]>

* fix(status-bar): flag the space-scan tooltip row instead of matching its English text

The tooltip tinted a row with `line === 'Space scan ready'`, so routing that
copy through the catalog silently dropped the tint in every translated build.
Return `{ text, emphasized }` and let the segment read the flag.

Adopted from stablyai#12439 by @smwbev.

Co-authored-by: Evgenii <[email protected]>

Co-authored-by: Orca <[email protected]>

* fix(status-bar): key Resource Manager tooltip rows by role instead of array index

Co-authored-by: Orca <[email protected]>

---------

Co-authored-by: Orca <[email protected]>
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.

2 participants