The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): localize sidebar filters without changing selections
brooklyn!1766f65df813
diff --git a/apps/desktop/src/app/chat/sidebar/filter-menu.test.tsx b/apps/desktop/src/app/chat/sidebar/filter-menu.test.tsxnew file mode 100644index 00000000000..7a47e9b835d--- /dev/null+++ b/apps/desktop/src/app/chat/sidebar/filter-menu.test.tsx@@ -0,0 +1,61 @@+import { act, cleanup, fireEvent, render, screen } from '@testing-library/react'+import { afterEach, expect, it } from 'vitest'++import { I18nProvider, TRANSLATIONS, useI18n } from '@/i18n'+import type { I18nContextValue } from '@/i18n'+import { $interfaceMode } from '@/store/interface-mode'+import {+ $sidebarListGroupIds,+ $sidebarOrdering,+ $sidebarStatusFilter,+ resetSidebarView,+ setSidebarGrouping,+ setSidebarOrdering+} from '@/store/layout'++import { SidebarFilterMenu } from './filter-menu'++let i18n: I18nContextValue++function Menu() {+ i18n = useI18n()++ return <SidebarFilterMenu />+}++afterEach(() => {+ cleanup()+ resetSidebarView()+})++it('translates the live filter menu while preserving selected values and the current grouping order', async () => {+ $interfaceMode.set('advanced')+ setSidebarGrouping('date')+ setSidebarOrdering('manual')+ $sidebarListGroupIds.set(['today'])+ render(+ <I18nProvider configClient={null} initialLocale="zh">+ <Menu />+ </I18nProvider>+ )+ const zh = TRANSLATIONS.zh.sidebar.filter+ fireEvent.keyDown(screen.getByRole('button', { name: zh.filters }), { key: 'Enter' })+ const group = screen.getByRole('menuitem', { name: new RegExp(zh.grouping) })+ fireEvent.keyDown(group, { key: 'ArrowRight' })+ expect(screen.getByRole('menuitemradio', { name: zh.updated }).getAttribute('aria-checked')).toBe('true')+ fireEvent.keyDown(screen.getByRole('menuitemradio', { name: zh.updated }), { key: 'Escape' })+ fireEvent.keyDown(screen.getByRole('button', { name: zh.filters }), { key: 'Enter' })+ fireEvent.keyDown(screen.getByRole('menuitem', { name: zh.status }), { key: 'ArrowRight' })+ fireEvent.click(screen.getByRole('menuitemcheckbox', { name: zh.needsInput }))+ expect($sidebarStatusFilter.get()).toContain('needs-input')+ await act(() => i18n.setLocale('ja'))+ const ja = TRANSLATIONS.ja.sidebar.filter+ expect(screen.getByText(TRANSLATIONS.ja.sidebar.profileRail)).toBeTruthy()+ expect(screen.getByText(TRANSLATIONS.ja.sidebar.markAllRead)).toBeTruthy()+ expect(screen.queryByText(TRANSLATIONS.en.sidebar.profileRail)).toBeNull()+ expect(screen.queryByText(TRANSLATIONS.en.sidebar.markAllRead)).toBeNull()+ fireEvent.keyDown(screen.getByRole('menuitem', { name: ja.status }), { key: 'ArrowRight' })+ expect(screen.getByRole('menuitemcheckbox', { name: ja.needsInput }).getAttribute('aria-checked')).toBe('true')+ expect(screen.queryByRole('menuitemcheckbox', { name: zh.needsInput })).toBeNull()+ expect($sidebarOrdering.get()).toBe('manual')+})diff --git a/apps/desktop/src/app/chat/sidebar/filter-menu.tsx b/apps/desktop/src/app/chat/sidebar/filter-menu.tsxindex a3e52f35493..6eca7b41199 100644--- a/apps/desktop/src/app/chat/sidebar/filter-menu.tsx+++ b/apps/desktop/src/app/chat/sidebar/filter-menu.tsx@@ -77,49 +77,6 @@ interface Option<T extends string = string> {label: string}-const GROUPING_OPTIONS: Record<SidebarGrouping, Omit<Option<SidebarGrouping>, 'id'>> = {- date: { icon: 'clock', label: 'Updated' },- profile: { icon: 'account', label: 'Profile' },- project: { icon: 'root-folder', label: 'Project' },- status: { icon: 'pulse', label: 'Status' }-}--const GROUPINGS: Option<SidebarGrouping>[] = SIDEBAR_GROUPING_ORDER.map(id => ({ id, ...GROUPING_OPTIONS[id] }))--const ORDERINGS: Option<SidebarOrdering>[] = [- { icon: 'clock', id: 'updated', label: 'Updated' },- { icon: 'add', id: 'created', label: 'Created' },- { icon: 'pulse', id: 'status', label: 'Status' },- { icon: 'symbol-numeric', id: 'tokens', label: 'Tokens' },- { icon: 'credit-card', id: 'cost', label: 'Cost' },- { icon: 'list-ordered', id: 'manual', label: 'Manual' }-]--const ROW_META: Option<SidebarRowMeta>[] = [- { icon: 'clock', id: 'updated', label: 'Updated' },- { icon: 'comment', id: 'preview', label: 'Preview' },- { icon: 'symbol-numeric', id: 'tokens', label: 'Tokens' },- { icon: 'credit-card', id: 'cost', label: 'Cost' },- { icon: 'git-pull-request', id: 'pr', label: 'PR' },- { icon: 'account', id: 'profile', label: 'Profile' }-]--const PR_FILTERS: Option<PullRequestBucket>[] = [- { icon: 'git-pull-request', id: 'open', label: 'Open' },- { icon: 'git-pull-request-draft', id: 'draft', label: 'Draft' },- { icon: 'git-merge', id: 'merged', label: 'Merged' },- { icon: 'git-pull-request-closed', id: 'closed', label: 'Closed' },- { icon: 'circle-slash', id: 'none', label: 'No PR' }-]--const STATUS_FILTERS: Option<SessionStatusBucket>[] = [- { dot: sessionDotClassName('needs-input'), id: 'needs-input', label: 'Needs input' },- { dot: sessionDotClassName('working'), id: 'working', label: 'Working' },- { dot: sessionDotClassName('unread'), id: 'unread', label: 'Unread' },- { dot: sessionDotClassName('draft'), id: 'draft', label: 'Draft' },- { dot: cn(sessionDotClassName('idle'), 'bg-(--ui-text-quaternary)'), id: 'idle', label: 'Idle' }-]-function OptionGlyph({ option }: { option: Option }) {if (option.dot) {return <span aria-hidden="true" className={cn('shrink-0', option.dot)} />@@ -158,6 +115,51 @@ function OptionRadio({ option }: { option: Option }) {export function SidebarFilterMenu({ className }: { className?: string }) {const { t } = useI18n()+ const f = t.sidebar.filter++ const GROUPING_OPTIONS: Record<SidebarGrouping, Omit<Option<SidebarGrouping>, 'id'>> = {+ date: { icon: 'clock', label: f.updated },+ profile: { icon: 'account', label: f.profile },+ project: { icon: 'root-folder', label: f.project },+ status: { icon: 'pulse', label: f.status }+ }++ const GROUPINGS: Option<SidebarGrouping>[] = SIDEBAR_GROUPING_ORDER.map(id => ({ id, ...GROUPING_OPTIONS[id] }))++ const ORDERINGS: Option<SidebarOrdering>[] = [+ { icon: 'clock', id: 'updated', label: f.updated },+ { icon: 'add', id: 'created', label: f.created },+ { icon: 'pulse', id: 'status', label: f.status },+ { icon: 'symbol-numeric', id: 'tokens', label: f.tokens },+ { icon: 'credit-card', id: 'cost', label: f.cost },+ { icon: 'list-ordered', id: 'manual', label: f.manual }+ ]++ const ROW_META: Option<SidebarRowMeta>[] = [+ { icon: 'clock', id: 'updated', label: f.updated },+ { icon: 'comment', id: 'preview', label: f.preview },+ { icon: 'symbol-numeric', id: 'tokens', label: f.tokens },+ { icon: 'credit-card', id: 'cost', label: f.cost },+ { icon: 'git-pull-request', id: 'pr', label: f.pr },+ { icon: 'account', id: 'profile', label: f.profile }+ ]++ const PR_FILTERS: Option<PullRequestBucket>[] = [+ { icon: 'git-pull-request', id: 'open', label: f.open },+ { icon: 'git-pull-request-draft', id: 'draft', label: f.draft },+ { icon: 'git-merge', id: 'merged', label: f.merged },+ { icon: 'git-pull-request-closed', id: 'closed', label: f.closed },+ { icon: 'circle-slash', id: 'none', label: f.noPR }+ ]++ const STATUS_FILTERS: Option<SessionStatusBucket>[] = [+ { dot: sessionDotClassName('needs-input'), id: 'needs-input', label: f.needsInput },+ { dot: sessionDotClassName('working'), id: 'working', label: f.working },+ { dot: sessionDotClassName('unread'), id: 'unread', label: f.unread },+ { dot: sessionDotClassName('draft'), id: 'draft', label: f.draft },+ { dot: cn(sessionDotClassName('idle'), 'bg-(--ui-text-quaternary)'), id: 'idle', label: f.idle }+ ]+const grouping = useStore($sidebarGrouping)const ordering = useStore($sidebarOrdering)const rowMeta = useStore($sidebarRowMeta)@@ -233,7 +235,7 @@ export function SidebarFilterMenu({ className }: { className?: string }) {<DropdownMenu><DropdownMenuTrigger asChild><Button- aria-label="Filters"+ aria-label={f.filters}className={cn(className,'data-[state=open]:bg-(--ui-control-active-background) data-[state=open]:text-foreground data-[state=open]:opacity-100',@@ -254,7 +256,7 @@ export function SidebarFilterMenu({ className }: { className?: string }) {<DropdownMenuGroup><DropdownMenuSub><DropdownMenuSubTrigger hideChevron>- Grouping+ {f.grouping}<span className="ml-auto flex items-center gap-1 pl-4 text-(--ui-text-tertiary)">{groupingLabel}<Codicon name="chevron-right" size="1rem" />@@ -273,7 +275,7 @@ export function SidebarFilterMenu({ className }: { className?: string }) {</DropdownMenuSub><DropdownMenuSub>- <DropdownMenuSubTrigger>Ordering</DropdownMenuSubTrigger>+ <DropdownMenuSubTrigger>{f.ordering}</DropdownMenuSubTrigger><DropdownMenuSubContent><DropdownMenuRadioGrouponValueChange={value => setSidebarOrdering(value as SidebarOrdering)}@@ -288,7 +290,7 @@ export function SidebarFilterMenu({ className }: { className?: string }) {{showsAdvancedChrome && (<DropdownMenuSub>- <DropdownMenuSubTrigger>Show</DropdownMenuSubTrigger>+ <DropdownMenuSubTrigger>{f.show}</DropdownMenuSubTrigger><DropdownMenuSubContent>{rowMetaOptions.map(option => (<OptionCheckbox@@ -315,7 +317,7 @@ export function SidebarFilterMenu({ className }: { className?: string }) {<OptionCheckboxchecked={cardRows}onCheck={() => setSidebarCardRows(!cardRows)}- option={{ icon: 'inbox', id: 'card-rows', label: 'Inbox style' }}+ option={{ icon: 'inbox', id: 'card-rows', label: f.inboxStyle }}/>{/* The colored strip at the sidebar foot. Off, the statusbar grows a@@ -333,10 +335,10 @@ export function SidebarFilterMenu({ className }: { className?: string }) {<DropdownMenuSeparator /><DropdownMenuGroup>- <DropdownMenuLabel>Filters</DropdownMenuLabel>+ <DropdownMenuLabel>{f.filters}</DropdownMenuLabel><DropdownMenuSub>- <DropdownMenuSubTrigger>Status</DropdownMenuSubTrigger>+ <DropdownMenuSubTrigger>{f.status}</DropdownMenuSubTrigger><DropdownMenuSubContent>{STATUS_FILTERS.map(option => (<OptionCheckbox@@ -353,7 +355,7 @@ export function SidebarFilterMenu({ className }: { className?: string }) {this submenu never appears rather than filtering everything out. */}{prAvailable && showsAdvancedChrome && (<DropdownMenuSub>- <DropdownMenuSubTrigger>Pull request</DropdownMenuSubTrigger>+ <DropdownMenuSubTrigger>{f.pullRequest}</DropdownMenuSubTrigger><DropdownMenuSubContent>{PR_FILTERS.map(option => (<OptionCheckbox@@ -368,7 +370,7 @@ export function SidebarFilterMenu({ className }: { className?: string }) {)}<DropdownMenuSub>- <DropdownMenuSubTrigger>Profile</DropdownMenuSubTrigger>+ <DropdownMenuSubTrigger>{f.profile}</DropdownMenuSubTrigger><DropdownMenuSubContent className="max-h-80 overflow-y-auto">{/* Scoped to one profile the rail is already the filter, so theper-profile boxes only appear where they can narrow something.@@ -395,7 +397,7 @@ export function SidebarFilterMenu({ className }: { className?: string }) {{projects.length > 1 && (<DropdownMenuSub>- <DropdownMenuSubTrigger>Project</DropdownMenuSubTrigger>+ <DropdownMenuSubTrigger>{f.project}</DropdownMenuSubTrigger><DropdownMenuSubContent className="max-h-80 overflow-y-auto">{projects.map(project => (<OptionCheckbox@@ -430,23 +432,23 @@ export function SidebarFilterMenu({ className }: { className?: string }) {<OptionCheckboxchecked={showArchived}onCheck={() => setSidebarShowArchived(!showArchived)}- option={{ id: 'archived', label: 'Archived' }}+ option={{ id: 'archived', label: f.archived }}/>{/* One way back rather than two near-identical ones: this drops thegrouping and sort too, which "clear filters" left behind. */}- {viewCustomized && <DropdownMenuItem onSelect={resetSidebarView}>Reset to defaults</DropdownMenuItem>}+ {viewCustomized && <DropdownMenuItem onSelect={resetSidebarView}>{f.resetToDefaults}</DropdownMenuItem>}</DropdownMenuGroup><DropdownMenuSeparator />{foldIds.length > 0 && (<DropdownMenuItem onSelect={() => setWorkspaceNodesOpen(foldIds, foldCollapsed)}>- {foldCollapsed ? 'Expand all' : 'Collapse all'}+ {foldCollapsed ? f.expandAll : f.collapseAll}</DropdownMenuItem>)}<DropdownMenuItem disabled={unreadIds.length === 0} onSelect={markAllSessionsRead}>- Mark all as read+ {t.sidebar.markAllRead}</DropdownMenuItem></DropdownMenuContent></DropdownMenu>diff --git a/apps/desktop/src/i18n/ar.ts b/apps/desktop/src/i18n/ar.tsindex b8f4af80216..63502cbdc91 100644--- a/apps/desktop/src/i18n/ar.ts+++ b/apps/desktop/src/i18n/ar.ts@@ -1986,6 +1986,39 @@ export const ar = defineLocale({missingBody: 'لم يعد هذا الناتج موجودًا في السجل المحلي.'},sidebar: {+ profileRail: 'شريط الملفات الشخصية',+ markAllRead: 'وضع علامة مقروء على الكل',+ filter: {+ grouping: 'تجميع',+ ordering: 'ترتيب',+ show: 'إظهار',+ filters: 'تصفية',+ status: 'الحالة',+ pullRequest: 'طلب سحب',+ profile: 'الملف الشخصي',+ project: 'المشروع',+ archived: 'مؤرشف',+ resetToDefaults: 'إعادة تعيين إلى الافتراضي',+ expandAll: 'توسيع الكل',+ collapseAll: 'طي الكل',+ inboxStyle: 'نمط البريد الوارد',+ updated: 'محدّث',+ created: 'أُنشئ',+ tokens: 'الرموز',+ cost: 'التكلفة',+ manual: 'يدوي',+ preview: 'معاينة',+ pr: 'PR',+ needsInput: 'يحتاج إدخالاً',+ working: 'يعمل',+ unread: 'غير مقروء',+ draft: 'مسودة',+ idle: 'خامل',+ open: 'مفتوح',+ merged: 'مدمج',+ closed: 'مغلق',+ noPR: 'لا يوجد PR'+ },gatewayGroups: {grouping: 'البوابة والملف الشخصي',rename: 'إعادة تسمية المجموعة',diff --git a/apps/desktop/src/i18n/en.ts b/apps/desktop/src/i18n/en.tsindex 802518b48ba..9d8f1a125d3 100644--- a/apps/desktop/src/i18n/en.ts+++ b/apps/desktop/src/i18n/en.ts@@ -3393,6 +3393,37 @@ export const en: Translations = {},sidebar: {+ filter: {+ grouping: 'Grouping',+ ordering: 'Ordering',+ show: 'Show',+ filters: 'Filters',+ status: 'Status',+ pullRequest: 'Pull request',+ profile: 'Profile',+ project: 'Project',+ archived: 'Archived',+ resetToDefaults: 'Reset to defaults',+ expandAll: 'Expand all',+ collapseAll: 'Collapse all',+ inboxStyle: 'Inbox style',+ updated: 'Updated',+ created: 'Created',+ tokens: 'Tokens',+ cost: 'Cost',+ manual: 'Manual',+ preview: 'Preview',+ pr: 'PR',+ needsInput: 'Needs input',+ working: 'Working',+ unread: 'Unread',+ draft: 'Draft',+ idle: 'Idle',+ open: 'Open',+ merged: 'Merged',+ closed: 'Closed',+ noPR: 'No PR'+ },gatewayGroups: {grouping: 'Gateway & profile',rename: 'Rename group',diff --git a/apps/desktop/src/i18n/ja.ts b/apps/desktop/src/i18n/ja.tsindex fcb75e52f85..66abefee350 100644--- a/apps/desktop/src/i18n/ja.ts+++ b/apps/desktop/src/i18n/ja.ts@@ -2355,6 +2355,39 @@ export const ja = defineLocale({},sidebar: {+ profileRail: 'プロファイルバー',+ markAllRead: 'すべて既読にする',+ filter: {+ grouping: 'グループ化',+ ordering: '並び替え',+ show: '表示',+ filters: 'フィルター',+ status: 'ステータス',+ pullRequest: 'プルリクエスト',+ profile: 'プロファイル',+ project: 'プロジェクト',+ archived: 'アーカイブ',+ resetToDefaults: 'デフォルトに戻す',+ expandAll: 'すべて展開',+ collapseAll: 'すべて折りたたむ',+ inboxStyle: '受信トレイスタイル',+ updated: '更新',+ created: '作成',+ tokens: 'トークン',+ cost: 'コスト',+ manual: '手動',+ preview: 'プレビュー',+ pr: 'PR',+ needsInput: '入力待ち',+ working: '実行中',+ unread: '未読',+ draft: '下書き',+ idle: 'アイドル',+ open: 'オープン',+ merged: 'マージ済み',+ closed: 'クローズ済み',+ noPR: 'PRなし'+ },gatewayGroups: {grouping: 'ゲートウェイとプロファイル',rename: 'グループ名を変更',diff --git a/apps/desktop/src/i18n/ru.ts b/apps/desktop/src/i18n/ru.tsindex d1f2fab88fc..b4d82f174bf 100644--- a/apps/desktop/src/i18n/ru.ts+++ b/apps/desktop/src/i18n/ru.ts@@ -2554,6 +2554,38 @@ export const ru = defineLocale({missingBody: 'Этот артефакт больше нет в локальном реестре.'},sidebar: {+ profileRail: 'Панель профилей',+ filter: {+ grouping: 'Группировка',+ ordering: 'Сортировка',+ show: 'Показывать',+ inboxStyle: 'Стиль «Входящие»',+ status: 'Статус',+ pullRequest: 'Запрос на слияние',+ profile: 'Профиль',+ project: 'Проект',+ archived: 'Архивные',+ expandAll: 'Развернуть все',+ collapseAll: 'Свернуть все',+ updated: 'Обновление',+ created: 'Создано',+ tokens: 'Токены',+ cost: 'Стоимость',+ manual: 'Вручную',+ preview: 'Превью',+ pr: 'PR',+ open: 'Открыт',+ draft: 'Черновик',+ merged: 'Слит',+ closed: 'Закрыт',+ needsInput: 'Нужен ввод',+ working: 'В работе',+ unread: 'Непрочитанные',+ idle: 'Бездействие',+ filters: 'Фильтры',+ resetToDefaults: 'Сбросить настройки',+ noPR: 'Без PR'+ },gatewayGroups: {grouping: 'Шлюз и профиль',rename: 'Переименовать группу',diff --git a/apps/desktop/src/i18n/types.ts b/apps/desktop/src/i18n/types.tsindex f728ad22743..27b42dcf76d 100644--- a/apps/desktop/src/i18n/types.ts+++ b/apps/desktop/src/i18n/types.ts@@ -2845,6 +2845,37 @@ export interface Translations {}sidebar: {+ filter: {+ grouping: string+ ordering: string+ show: string+ filters: string+ status: string+ pullRequest: string+ profile: string+ project: string+ archived: string+ resetToDefaults: string+ expandAll: string+ collapseAll: string+ inboxStyle: string+ updated: string+ created: string+ tokens: string+ cost: string+ manual: string+ preview: string+ pr: string+ needsInput: string+ working: string+ unread: string+ draft: string+ idle: string+ open: string+ merged: string+ closed: string+ noPR: string+ }gatewayGroups: {grouping: stringrename: stringdiff --git a/apps/desktop/src/i18n/zh-hant.ts b/apps/desktop/src/i18n/zh-hant.tsindex d28bbc56ecc..5563a7597b0 100644--- a/apps/desktop/src/i18n/zh-hant.ts+++ b/apps/desktop/src/i18n/zh-hant.ts@@ -2578,6 +2578,39 @@ export const zhHant = defineLocale({},sidebar: {+ profileRail: '設定檔列',+ markAllRead: '全部標示為已讀',+ filter: {+ grouping: '分組',+ ordering: '排序',+ show: '顯示',+ filters: '篩選',+ status: '狀態',+ pullRequest: '提取請求',+ profile: '設定檔',+ project: '專案',+ archived: '已封存',+ resetToDefaults: '重設為預設值',+ expandAll: '全部展開',+ collapseAll: '全部收合',+ inboxStyle: '收件匣樣式',+ updated: '已更新',+ created: '已建立',+ tokens: '詞元數',+ cost: '費用',+ manual: '手動',+ preview: '預覽',+ pr: 'PR',+ needsInput: '需要輸入',+ working: '運作中',+ unread: '未讀',+ draft: '草稿',+ idle: '閒置',+ open: '開啟',+ merged: '已合併',+ closed: '已關閉',+ noPR: '無 PR'+ },gatewayGroups: {grouping: '閘道與設定檔',rename: '重新命名群組',diff --git a/apps/desktop/src/i18n/zh.ts b/apps/desktop/src/i18n/zh.tsindex fbe8dc6a88f..2746fd3037a 100644--- a/apps/desktop/src/i18n/zh.ts+++ b/apps/desktop/src/i18n/zh.ts@@ -3211,6 +3211,37 @@ export const zh = defineLocale({},sidebar: {+ filter: {+ grouping: '分组',+ ordering: '排序',+ show: '显示',+ filters: '筛选',+ status: '状态',+ pullRequest: '拉取请求',+ profile: '配置档案',+ project: '项目',+ archived: '已归档',+ resetToDefaults: '重置为默认',+ expandAll: '全部展开',+ collapseAll: '全部折叠',+ inboxStyle: '收件箱样式',+ updated: '更新时间',+ created: '创建时间',+ tokens: '词元数',+ cost: '费用',+ manual: '手动',+ preview: '预览',+ pr: 'PR',+ needsInput: '需要输入',+ working: '运行中',+ unread: '未读',+ draft: '草稿',+ idle: '空闲',+ open: '打开',+ merged: '已合并',+ closed: '已关闭',+ noPR: '无PR'+ },profileRail: '配置档案栏',gatewayGroups: {grouping: '网关与配置',