From ebe3aac000140646dd9f9d5bb1c511777dfd65bb Mon Sep 17 00:00:00 2001 From: OrcaWin Date: Sat, 7 Nov 2026 20:34:28 -0800 Subject: [PATCH] refactor(i18n): finish EditorFileTab and the checks tab actions on useTranslate (#39726) ChecksTabActions is called as a plain function, so it now takes the checks tab's `t` instead of reading translate(). EditorFileTab would go over budget once converted, so its mode icon choice moves to its own module first. Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com> --- config/render-path-translate-baseline.txt | 2 -- .../checks-tab-header.tsx | 24 +++++++------ .../inspect-pull-request/checks-tab.tsx | 3 +- .../src/components/tab-bar/EditorFileTab.tsx | 35 ++++--------------- .../tab-bar/editor-file-tab-mode-icon.ts | 29 +++++++++++++++ 5 files changed, 51 insertions(+), 42 deletions(-) create mode 100644 src/renderer/src/components/tab-bar/editor-file-tab-mode-icon.ts diff --git a/config/render-path-translate-baseline.txt b/config/render-path-translate-baseline.txt index 5d03a60d142..8fabb878a11 100644 --- a/config/render-path-translate-baseline.txt +++ b/config/render-path-translate-baseline.txt @@ -161,7 +161,6 @@ 8 src/renderer/src/components/floating-terminal/FloatingTerminalOrchestrationDialog.tsx 4 src/renderer/src/components/floating-terminal/FloatingTerminalToggleButton.tsx 8 src/renderer/src/components/floating-terminal/FloatingTerminalWindowControls.tsx -8 src/renderer/src/components/github-item-dialog/inspect-pull-request/checks-tab-header.tsx 13 src/renderer/src/components/github/CommentCodeContext.tsx 3 src/renderer/src/components/github/CommentReactions.tsx 1 src/renderer/src/components/github/GitHubMarkdownComposer.tsx @@ -361,7 +360,6 @@ 20 src/renderer/src/components/stats/UsageOverviewPane.tsx 3 src/renderer/src/components/stats/share-card-utils.tsx 23 src/renderer/src/components/stats/usage-overview-sections.tsx -2 src/renderer/src/components/tab-bar/EditorFileTab.tsx 1 src/renderer/src/components/tab-group/TabGroupDropOverlay.tsx 3 src/renderer/src/components/tab-group/TabGroupPaneActionsMenu.tsx 1 src/renderer/src/components/tab-group/TabGroupPanel.tsx diff --git a/src/renderer/src/components/github-item-dialog/inspect-pull-request/checks-tab-header.tsx b/src/renderer/src/components/github-item-dialog/inspect-pull-request/checks-tab-header.tsx index 0842e62dcac..2211b0a9b3c 100644 --- a/src/renderer/src/components/github-item-dialog/inspect-pull-request/checks-tab-header.tsx +++ b/src/renderer/src/components/github-item-dialog/inspect-pull-request/checks-tab-header.tsx @@ -9,8 +9,7 @@ import { DropdownMenuTrigger } from '@/components/ui/dropdown-menu' import { cn } from '@/lib/utils' -import { translate } from '@/i18n/i18n' -import { useTranslate } from '@/i18n/use-translate' +import { useTranslate, type Translate } from '@/i18n/use-translate' export function ChecksTabActions({ variant, @@ -23,7 +22,8 @@ export function ChecksTabActions({ listLength, onRefresh, onRerun, - onFix + onFix, + t }: { variant: 'compact' | 'page' canUseChecksRepoContext: boolean @@ -36,6 +36,8 @@ export function ChecksTabActions({ onRefresh: () => void onRerun: (failedOnly: boolean) => void onFix: () => void + /** The caller's render translator; this runs as a plain function, not a component. */ + t: Translate }): { refreshAction: React.JSX.Element fixBrokenChecksAction: React.JSX.Element | null @@ -53,13 +55,13 @@ export function ChecksTabActions({ className="size-7 shrink-0" disabled={!canUseChecksRepoContext || refreshing} onClick={() => void onRefresh()} - aria-label={translate('auto.components.GitHubItemDialog.9a1004fc76', 'Refresh checks')} + aria-label={t('auto.components.GitHubItemDialog.9a1004fc76', 'Refresh checks')} > - {translate('auto.components.GitHubItemDialog.9a1004fc76', 'Refresh checks')} + {t('auto.components.GitHubItemDialog.9a1004fc76', 'Refresh checks')} ) @@ -81,12 +83,12 @@ export function ChecksTabActions({ )} {variant === 'compact' - ? translate('auto.components.GitHubItemDialog.9157d48ddb', 'Fix checks') - : translate('auto.components.GitHubItemDialog.2511f44bb7', 'Fix broken checks')} + ? t('auto.components.GitHubItemDialog.9157d48ddb', 'Fix checks') + : t('auto.components.GitHubItemDialog.2511f44bb7', 'Fix broken checks')} - {translate( + {t( 'auto.components.GitHubItemDialog.f4b1292569', 'Start the default AI agent on these checks' )} @@ -109,7 +111,7 @@ export function ChecksTabActions({ ) : ( )} - {translate('auto.components.GitHubItemDialog.1b56e28faa', 'Rerun')} + {t('auto.components.GitHubItemDialog.1b56e28faa', 'Rerun')} @@ -119,11 +121,11 @@ export function ChecksTabActions({ onSelect={() => void onRerun(true)} > - {translate('checks.rerunUnsuccessful', 'Rerun unsuccessful')} + {t('checks.rerunUnsuccessful', 'Rerun unsuccessful')} void onRerun(false)}> - {translate('auto.components.GitHubItemDialog.71c11aff84', 'Rerun all checks')} + {t('auto.components.GitHubItemDialog.71c11aff84', 'Rerun all checks')} diff --git a/src/renderer/src/components/github-item-dialog/inspect-pull-request/checks-tab.tsx b/src/renderer/src/components/github-item-dialog/inspect-pull-request/checks-tab.tsx index 761f3f173aa..5bfa5efb78d 100644 --- a/src/renderer/src/components/github-item-dialog/inspect-pull-request/checks-tab.tsx +++ b/src/renderer/src/components/github-item-dialog/inspect-pull-request/checks-tab.tsx @@ -298,7 +298,8 @@ export function ChecksTab({ }, onFix: () => { void handleFixBrokenChecks() - } + }, + t }) const compactHeader = ( file.tabId ? editorTabWorkspace(state.unifiedTabsByWorktree, file.tabId) !== file.worktreeId @@ -86,26 +80,11 @@ export default function EditorFileTab({ data: dragData }) - const isDiff = file.mode === 'diff' const isConflictReview = file.mode === 'conflict-review' - const isCheckDetails = file.mode === 'check-details' const isMarkdownPreviewTab = file.mode === 'markdown-preview' const customEditor = useTabCustomEditor(file) // Why: simulator tabs reuse this chrome with a synthetic path an icon theme would map to its file icon. - const ModeIcon = - file.mode === 'git-graph' - ? GitGraph - : isConflictReview - ? ShieldAlert - : isCheckDetails - ? ListChecks - : isDiff - ? GitCompareArrows - : isMarkdownPreviewTab - ? Eye - : file.language === 'simulator' - ? Smartphone - : null + const ModeIcon = getEditorFileTabModeIcon(file) const tabIcon = (className: string): React.ReactNode => ( diff --git a/src/renderer/src/components/tab-bar/editor-file-tab-mode-icon.ts b/src/renderer/src/components/tab-bar/editor-file-tab-mode-icon.ts new file mode 100644 index 00000000000..2ef04cc1e69 --- /dev/null +++ b/src/renderer/src/components/tab-bar/editor-file-tab-mode-icon.ts @@ -0,0 +1,29 @@ +import { + Eye, + GitCompareArrows, + GitGraph, + ListChecks, + ShieldAlert, + Smartphone, + type LucideIcon +} from 'lucide-react' +import type { EditorFileTabProps } from './editor-file-tab-props' + +// Why: simulator tabs reuse this chrome with a synthetic path an icon theme would map to its file icon. +export function getEditorFileTabModeIcon( + file: Pick +): LucideIcon | null { + return file.mode === 'git-graph' + ? GitGraph + : file.mode === 'conflict-review' + ? ShieldAlert + : file.mode === 'check-details' + ? ListChecks + : file.mode === 'diff' + ? GitCompareArrows + : file.mode === 'markdown-preview' + ? Eye + : file.language === 'simulator' + ? Smartphone + : null +}