From a2856d774cbc22b329b3620368f14ecc204d9aae Mon Sep 17 00:00:00 2001 From: Mucheen <1528136628@qq.com> Date: Sun, 16 Aug 2026 00:02:18 +0800 Subject: [PATCH] fix(windows): hide project switcher for new-window mode --- .../layout/components/sidebar/main-sidebar.tsx | 7 ++++++- .../layout/utils/project-switcher.test.ts | 17 +++++++++++++++++ .../features/layout/utils/project-switcher.ts | 6 ++++++ 3 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 windows/tauri/src/features/layout/utils/project-switcher.test.ts create mode 100644 windows/tauri/src/features/layout/utils/project-switcher.ts diff --git a/windows/tauri/src/features/layout/components/sidebar/main-sidebar.tsx b/windows/tauri/src/features/layout/components/sidebar/main-sidebar.tsx index 7233c4303..33804df8b 100644 --- a/windows/tauri/src/features/layout/components/sidebar/main-sidebar.tsx +++ b/windows/tauri/src/features/layout/components/sidebar/main-sidebar.tsx @@ -40,6 +40,7 @@ import { getProjectSnapDuration, getProjectSwipeBounds, } from "@/features/layout/utils/project-carousel"; +import { shouldShowProjectSwitcher } from "@/features/layout/utils/project-switcher"; import { getSidebarPaneLevel, type SidebarView } from "@/features/layout/utils/sidebar-pane-utils"; import { OutlineSidebar } from "@/features/outline/components/outline-sidebar"; import { useSettingsStore } from "@/features/settings/stores/settings.store"; @@ -236,6 +237,10 @@ export const SidebarActivityRail = memo(({ expanded = false }: SidebarActivityRa projectCarouselDirection < 0 && carouselTargetProject ? carouselTargetProject : previousProject; const renderedNextProject = projectCarouselDirection > 0 && carouselTargetProject ? carouselTargetProject : nextProject; + const projectSwitcherVisible = shouldShowProjectSwitcher( + showActivityRailProjectSwitcher, + openFoldersInNewWindow, + ); const switchToProject = useFileSystemStore((state) => state.switchToProject); const isSwitchingProject = useFileSystemStore((state) => state.isSwitchingProject); const handleSidebarViewChange = (view: typeof activeSidebarView) => { @@ -719,7 +724,7 @@ export const SidebarActivityRail = memo(({ expanded = false }: SidebarActivityRa > {isBoundaryPanel ? null : ( <> - {showActivityRailProjectSwitcher ? ( + {projectSwitcherVisible ? ( { + test("hides the activity-bar switcher when projects open in new windows", () => { + expect(shouldShowProjectSwitcher(true, true)).toBe(false); + }); + + test("shows the activity-bar switcher when in-window switching is enabled", () => { + expect(shouldShowProjectSwitcher(true, false)).toBe(true); + }); + + test("respects the user's project switcher visibility setting", () => { + expect(shouldShowProjectSwitcher(false, false)).toBe(false); + expect(shouldShowProjectSwitcher(false, true)).toBe(false); + }); +}); diff --git a/windows/tauri/src/features/layout/utils/project-switcher.ts b/windows/tauri/src/features/layout/utils/project-switcher.ts new file mode 100644 index 000000000..71e948b2f --- /dev/null +++ b/windows/tauri/src/features/layout/utils/project-switcher.ts @@ -0,0 +1,6 @@ +export function shouldShowProjectSwitcher( + showProjectSwitcher: boolean, + openFoldersInNewWindow: boolean, +) { + return showProjectSwitcher && !openFoldersInNewWindow; +}