Skip to content

The agent that grows with you

fix(desktop): SESSIONS / BOTS tab labels follow the display language

teknium19a7d3937e41c
diff --git a/apps/desktop/src/app/contrib/controller.tsx b/apps/desktop/src/app/contrib/controller.tsx
index 343243564b7..a0e1a3948c5 100644
--- a/apps/desktop/src/app/contrib/controller.tsx
+++ b/apps/desktop/src/app/contrib/controller.tsx
@@ -42,7 +42,7 @@ import { discoverBundledPlugins } from '@/contrib/plugins'
import { Slot } from '@/contrib/react/slot'
import { registry } from '@/contrib/registry'
import { discoverRuntimePlugins } from '@/contrib/runtime-loader'
-import { translateNow } from '@/i18n'
+import { LocalizedTabTitle, translateNow } from '@/i18n'
import { NEW_SESSION_TITLE, sessionTitle as storedSessionTitle } from '@/lib/chat-runtime'
import { Download, FileText, LayoutDashboard, PanelBottom, PanelTop, Terminal, Upload, Users, Zap } from '@/lib/icons'
import { type KeybindContribution, KEYBINDS_AREA } from '@/lib/keybinds/actions'
@@ -162,7 +162,9 @@ registry.registerMany([
{
id: 'sessions',
area: 'panes',
- title: 'sessions',
+ // String fallback only (menus, drag ghosts); the tab itself renders
+ // `tabTitle` below so the strip follows `display.language` once it loads.
+ title: translateNow('sidebar.sessions'),
// Collapsible: leaves the grid on narrow viewports (edge overlay instead).
// dock: where a RE-ADOPTED pane lands (healed from a stale dismissal) —
// its default-ish spot beside main, not a random same-placement stack.
@@ -174,6 +176,7 @@ registry.registerMany([
// Standing chrome: no close gestures at all — the tab is shown/hidden
// (zone menu Show/Hide rows + the auto-registered ⌘K toggle below).
hideOnly: true,
+ tabTitle: () => <LocalizedTabTitle select={t => t.sidebar.sessions} />,
width: `${SIDEBAR_DEFAULT_WIDTH}px`,
minWidth: `${SIDEBAR_DEFAULT_WIDTH}px`,
maxWidth: `${SIDEBAR_MAX_WIDTH}px`
diff --git a/apps/desktop/src/app/contrib/sessions-pane-tab-title.test.tsx b/apps/desktop/src/app/contrib/sessions-pane-tab-title.test.tsx
new file mode 100644
index 00000000000..1bcdbc24a4e
--- /dev/null
+++ b/apps/desktop/src/app/contrib/sessions-pane-tab-title.test.tsx
@@ -0,0 +1,31 @@
+/**
+ * The Sessions sidebar pane registers at module import, before `I18nProvider`
+ * has fetched `display.language`, so its string `title` is whatever English
+ * `translateNow` sampled then. The strip label must come from `tabTitle`,
+ * which subscribes to the live locale.
+ */
+import type { ReactNode } from 'react'
+import { renderToStaticMarkup } from 'react-dom/server'
+import { describe, expect, it } from 'vitest'
+
+import { I18nProvider } from '@/i18n'
+
+const { registry } = await import('@/contrib/registry')
+
+await import('./controller')
+
+describe('the Sessions pane tab label', () => {
+ it('follows the live locale instead of the register-time title', () => {
+ const sessions = registry.getArea('panes').find(c => c.id === 'sessions')!
+ const tabTitle = (sessions.data as { tabTitle: () => ReactNode }).tabTitle
+ const inLocale = (locale: string) =>
+ renderToStaticMarkup(
+ <I18nProvider configClient={null} initialLocale={locale}>
+ {tabTitle()}
+ </I18nProvider>
+ )
+
+ expect(inLocale('ru')).toBe('Сеансы')
+ expect(inLocale('en')).toBe('Sessions')
+ })
+})
diff --git a/apps/desktop/src/i18n/index.ts b/apps/desktop/src/i18n/index.ts
index 6d85837889d..b13973f1c64 100644
--- a/apps/desktop/src/i18n/index.ts
+++ b/apps/desktop/src/i18n/index.ts
@@ -16,6 +16,7 @@ export {
localeConfigValue,
normalizeLocale
} from './languages'
+export { LocalizedTabTitle } from './localized-tab-title'
export {
createPluginI18n,
type PluginI18n,
diff --git a/apps/desktop/src/i18n/localized-tab-title.tsx b/apps/desktop/src/i18n/localized-tab-title.tsx
new file mode 100644
index 00000000000..a6d05a884bc
--- /dev/null
+++ b/apps/desktop/src/i18n/localized-tab-title.tsx
@@ -0,0 +1,20 @@
+import type { ReactNode } from 'react'
+
+import { useI18n } from './context'
+import type { Translations } from './types'
+
+/** Render-time pane TAB label for panes registered outside React.
+ *
+ * A contribution's `title` is a plain string sampled once, at `register`.
+ * Bundled panes (the Sessions sidebar, Bot Mode's roster) register during
+ * module import — BEFORE `I18nProvider` has fetched `display.language` from
+ * the backend — so a `translateNow(...)` there resolves English and the strip
+ * keeps reading SESSIONS / BOTS on a Russian install. Hand this to
+ * `data.tabTitle` instead: it subscribes to the live locale like any component
+ * and re-renders the tab when the language loads or the user switches it.
+ * `title` stays as the string fallback for the non-React readers. */
+export function LocalizedTabTitle({ select }: { select: (t: Translations) => ReactNode }) {
+ const { t } = useI18n()
+
+ return <>{select(t)}</>
+}
diff --git a/apps/desktop/src/plugins/hermes-bots/plugin-panes.test.tsx b/apps/desktop/src/plugins/hermes-bots/plugin-panes.test.tsx
index 6e93a8391be..4d4c216bf10 100644
--- a/apps/desktop/src/plugins/hermes-bots/plugin-panes.test.tsx
+++ b/apps/desktop/src/plugins/hermes-bots/plugin-panes.test.tsx
@@ -19,8 +19,14 @@
import type * as HermesSdk from '@hermes/plugin-sdk'
import type { PluginContext } from '@hermes/plugin-sdk'
import { atom } from 'nanostores'
+import type { ReactNode } from 'react'
+import { renderToStaticMarkup } from 'react-dom/server'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
+// The app provider the plugin's tab label renders under; a plugin test may reach it.
+// eslint-disable-next-line no-restricted-imports
+import { I18nProvider } from '@/i18n'
+
import type * as DataModule from './data'
import type * as RoutingModule from './routing'
@@ -180,6 +186,29 @@ describe('the Bots pane dock', () => {
harness.dispose()
})
+
+ it('renders its tab label from the live locale, not the register-time string', () => {
+ paneStores()
+
+ const harness = recordingContext()
+
+ // Registration runs at module import, before the app has loaded
+ // `display.language`: the string `title` is English here no matter what.
+ plugin.register(harness.ctx)
+
+ const tabTitle = harness.find('pane')!.data!.tabTitle as () => ReactNode
+ const inLocale = (locale: string) =>
+ renderToStaticMarkup(
+ <I18nProvider configClient={null} initialLocale={locale}>
+ {tabTitle()}
+ </I18nProvider>
+ )
+
+ expect(inLocale('ru')).toBe('Боты')
+ expect(inLocale('en')).toBe('Bots')
+
+ harness.dispose()
+ })
})
describe('the Scheduled jobs pane', () => {
diff --git a/apps/desktop/src/plugins/hermes-bots/plugin.tsx b/apps/desktop/src/plugins/hermes-bots/plugin.tsx
index e15c7d3b783..cc2b5fbeee0 100644
--- a/apps/desktop/src/plugins/hermes-bots/plugin.tsx
+++ b/apps/desktop/src/plugins/hermes-bots/plugin.tsx
@@ -15,7 +15,7 @@
* bot-initiated sends use `hermes -p <bot> chat --in ~ -c "Bot Chat"`.
*/
-import { CHAT_EMPTY_AREA, COMPOSER_AREAS, host, PALETTE_AREA, translateNow } from '@hermes/plugin-sdk'
+import { CHAT_EMPTY_AREA, COMPOSER_AREAS, host, LocalizedTabTitle, PALETTE_AREA, translateNow } from '@hermes/plugin-sdk'
import type { ChatEmptyProps, PluginContext } from '@hermes/plugin-sdk'
import { startFaceClock, stopFaceClock } from './avatar'
@@ -367,6 +367,8 @@ export default {
ctx.register({
id: 'pane',
area: 'panes',
+ // `title` is sampled at register (module import, before the locale has
+ // loaded) — the tab renders `tabTitle` below so BOTS follows the locale.
title: translateNow('common.bots'),
// dock: explicit adoption gesture — CENTER-STACK into the sessions zone
// so the sidebar grows a SESSIONS | BOTS tab strip instead of splitting
@@ -395,6 +397,7 @@ export default {
width: '260px',
collapsible: true,
hideOnly: true,
+ tabTitle: () => <LocalizedTabTitle select={t => t.common.bots} />,
dock: {
pane: 'sessions',
pos: 'center',
@@ -425,6 +428,7 @@ export default {
// a pane title is read at registration, outside React.
title: translateNow('cron.title'),
data: {
+ tabTitle: () => <LocalizedTabTitle select={t => t.cron.title} />,
placement: 'main',
// Repair persisted layouts that stranded Cronjobs in the Bots tab strip.
dock: {
diff --git a/apps/desktop/src/sdk/index.ts b/apps/desktop/src/sdk/index.ts
index 1d401ac276c..921c6cd526f 100644
--- a/apps/desktop/src/sdk/index.ts
+++ b/apps/desktop/src/sdk/index.ts
@@ -1759,9 +1759,12 @@ export { type GrabScroll, useGrabScroll } from '@/hooks/use-grab-scroll'
* `translateNow` is the one-shot form for the places a hook can't reach —
* notably a `ctx.register` pane `title`, which is read at registration time
* and is why plugin pane titles otherwise strand as hardcoded English. It
- * samples the locale at call time, so React should still use the hooks. */
+ * samples the locale at call time, so React should still use the hooks. A
+ * pane whose label must track the locale pairs that `title` with
+ * `data.tabTitle: () => <LocalizedTabTitle select={t => ...} />`. */
export {
type Locale,
+ LocalizedTabTitle,
type PluginI18n,
type PluginLocaleBundles,
type PluginMessages,