From a07b42e49398eb73bcf6c3c14ace749d0f596cc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=B7=E7=94=B5=E8=8A=BD=E8=A1=A3?= Date: Thu, 16 Apr 2026 22:53:56 -0400 Subject: [PATCH] refactor(App): extract Shell wrapper for locale+titlebar chrome (P1-20) Collapse two near-identical LocaleContext/TranslationContext/TitleBar wrapper blocks into a single Shell component. --- src/renderer/App.tsx | 86 ++++++++++++++++++++++++++------------------ 1 file changed, 51 insertions(+), 35 deletions(-) diff --git a/src/renderer/App.tsx b/src/renderer/App.tsx index cae21567..8138d094 100644 --- a/src/renderer/App.tsx +++ b/src/renderer/App.tsx @@ -1,6 +1,7 @@ -import { useCallback, useMemo } from "react"; +import { useCallback, useMemo, type ReactNode } from "react"; import { CircleNotch, TerminalWindow } from "@phosphor-icons/react"; -import { LocaleContext, TranslationContext } from "./i18n"; +import { LocaleContext, TranslationContext, type TranslationFn } from "./i18n"; +import type { AppLocale } from "@shared/locale"; import { CompanyOnboarding } from "./components/CompanyOnboarding"; import TitleBar from "./components/TitleBar"; import ToastContainer from "./components/Toast"; @@ -15,6 +16,31 @@ import { useCommandPaletteHotkeys } from "./hooks/useCommandPaletteHotkeys"; import { AppActionsContext, type AppActions } from "./hooks/useAppActions"; import { unwrap } from "./lib/desktop"; +function Shell({ + locale, + t, + showCustomTitleBar, + className, + children, +}: { + locale: AppLocale; + t: TranslationFn; + showCustomTitleBar: boolean; + className?: string; + children: ReactNode; +}) { + return ( + + +
+ {showCustomTitleBar && } + {children} +
+
+
+ ); +} + export function App() { const ui = useUIController(); const company = useCompanyController(); @@ -99,44 +125,34 @@ export function App() { if (!company.snapshot) { return ( - - -
- {showCustomTitleBar && } -
- - {ui.t("app.loading")} -
-
-
-
+ +
+ + {ui.t("app.loading")} +
+
); } if (company.snapshot.companies.length === 0 || ui.showOnboarding || ui.initialOnboardingLocked) { return ( - - -
- {showCustomTitleBar && } -
- 0 && !ui.initialOnboardingLocked} - onCancel={() => { - ui.setShowOnboarding(false); - ui.setInitialOnboardingLocked(false); - setError(null); - }} - currentLocale={ui.locale} - onLocaleChange={ui.handleLocaleChange} - isFirstLaunch={company.snapshot.companies.length === 0} - /> -
-
-
-
+ +
+ 0 && !ui.initialOnboardingLocked} + onCancel={() => { + ui.setShowOnboarding(false); + ui.setInitialOnboardingLocked(false); + setError(null); + }} + currentLocale={ui.locale} + onLocaleChange={ui.handleLocaleChange} + isFirstLaunch={company.snapshot.companies.length === 0} + /> +
+
); }