Skip to content

Commit 84c96c5

Browse files
MarkShawn2020claude
andcommitted
feat(workspace): Dashboard 侧边栏支持 hide/show 切换
- 新增 dashboardSessionsVisibleAtom 控制侧边栏可见性 - VerticalFeatureTabs 仅在 Dashboard 页面显示 - 侧边栏底部添加 Hide 按钮 - 隐藏时左侧显示展开按钮 - 状态持久化到 localStorage Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent d2ebb0b commit 84c96c5

4 files changed

Lines changed: 36 additions & 4 deletions

File tree

src/components/GlobalHeader/VerticalFeatureTabs.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@ import { useAtom } from "jotai";
33
import {
44
ChevronDownIcon,
55
ChevronRightIcon,
6+
ChevronLeftIcon,
67
ChatBubbleIcon,
78
DotsVerticalIcon,
89
} from "@radix-ui/react-icons";
910
import {
1011
workspaceDataAtom,
1112
collapsedProjectGroupsAtom,
1213
verticalTabsSidebarWidthAtom,
14+
dashboardSessionsVisibleAtom,
1315
} from "@/store";
1416
import { useNavigate, useInvokeQuery } from "@/hooks";
1517
import { invoke } from "@tauri-apps/api/core";
@@ -31,6 +33,7 @@ export function VerticalFeatureTabs() {
3133
const [workspace] = useAtom(workspaceDataAtom);
3234
const [collapsedGroups, setCollapsedGroups] = useAtom(collapsedProjectGroupsAtom);
3335
const [sidebarWidth, setSidebarWidth] = useAtom(verticalTabsSidebarWidthAtom);
36+
const [, setSidebarVisible] = useAtom(dashboardSessionsVisibleAtom);
3437
const [isResizing, setIsResizing] = useState(false);
3538
const resizeRef = useRef<HTMLDivElement>(null);
3639

@@ -87,6 +90,18 @@ export function VerticalFeatureTabs() {
8790
</div>
8891
</div>
8992

93+
{/* Hide Sidebar Button */}
94+
<div className="shrink-0 border-t border-border p-2">
95+
<button
96+
onClick={() => setSidebarVisible(false)}
97+
className="w-full flex items-center justify-center gap-1.5 px-2 py-1.5 text-xs text-muted-foreground hover:text-ink hover:bg-muted rounded-lg transition-colors"
98+
title="Hide sidebar"
99+
>
100+
<ChevronLeftIcon className="w-3.5 h-3.5" />
101+
<span>Hide</span>
102+
</button>
103+
</div>
104+
90105
{/* Resize Handle */}
91106
<div
92107
ref={resizeRef}

src/pages/_layout.tsx

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77
import { useState, useEffect, useCallback } from "react";
88
import { Outlet, useLocation, useNavigate } from "react-router-dom";
9-
import { PersonIcon } from "@radix-ui/react-icons";
9+
import { PersonIcon, ChevronRightIcon } from "@radix-ui/react-icons";
1010
import { GlobalHeader, VerticalFeatureTabs } from "../components/GlobalHeader";
1111
import { StatusBar } from "../components/StatusBar";
1212
import { setAutoCopyOnSelect, getAutoCopyOnSelect } from "../components/Terminal";
@@ -19,7 +19,7 @@ import { Button } from "../components/ui/button";
1919
import { invoke } from "@tauri-apps/api/core";
2020
import { listen } from "@tauri-apps/api/event";
2121
import { useAtom } from "jotai";
22-
import { shortenPathsAtom, profileAtom, featureTabsLayoutAtom, workspaceDataAtom } from "../store";
22+
import { shortenPathsAtom, profileAtom, featureTabsLayoutAtom, workspaceDataAtom, dashboardSessionsVisibleAtom } from "../store";
2323
import { AppConfigContext, useAppConfig, type AppConfig } from "../context";
2424
import type { FeatureType, UserProfile } from "../types";
2525

@@ -82,12 +82,16 @@ export default function RootLayout() {
8282
// App state (non-routing)
8383
const [featureTabsLayout] = useAtom(featureTabsLayoutAtom);
8484
const [workspace] = useAtom(workspaceDataAtom);
85+
const [dashboardSidebarVisible, setDashboardSidebarVisible] = useAtom(dashboardSessionsVisibleAtom);
8586
const [homeDir, setHomeDir] = useState("");
8687
const [shortenPaths, setShortenPaths] = useAtom(shortenPathsAtom);
8788
const [showSettings, setShowSettings] = useState(false);
8889
const [profile, setProfile] = useAtom(profileAtom);
8990
const [showProfileDialog, setShowProfileDialog] = useState(false);
9091

92+
// Check if currently in workspace (Dashboard) view
93+
const isInWorkspace = location.pathname === "/workspace";
94+
9195
useEffect(() => {
9296
invoke<string>("get_home_dir").then(setHomeDir).catch(() => {});
9397
}, []);
@@ -164,7 +168,17 @@ export default function RootLayout() {
164168
onShowSettings={() => setShowSettings(true)}
165169
/>
166170
<div className="flex-1 flex overflow-hidden">
167-
{featureTabsLayout === "vertical" && workspace && <VerticalFeatureTabs />}
171+
{featureTabsLayout === "vertical" && workspace && isInWorkspace && dashboardSidebarVisible && <VerticalFeatureTabs />}
172+
{/* Show expand button when sidebar is hidden in workspace */}
173+
{featureTabsLayout === "vertical" && isInWorkspace && !dashboardSidebarVisible && (
174+
<button
175+
onClick={() => setDashboardSidebarVisible(true)}
176+
className="shrink-0 w-6 flex items-center justify-center border-r border-border bg-card hover:bg-muted transition-colors"
177+
title="Show sidebar"
178+
>
179+
<ChevronRightIcon className="w-4 h-4 text-muted-foreground" />
180+
</button>
181+
)}
168182
<main className="flex-1 overflow-auto">
169183
<Outlet />
170184
</main>

src/store/atoms/workspace.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,6 @@ export const featureSidebarFilesExpandedAtom = atomWithStorage("feature-sidebar-
1818
// VerticalFeatureTabs sidebar mode
1919
export type SidebarMode = "feats" | "sessions";
2020
export const sidebarModeAtom = atomWithStorage<SidebarMode>("sidebar-mode", "feats");
21+
22+
// Dashboard sessions panel visibility
23+
export const dashboardSessionsVisibleAtom = atomWithStorage("dashboard-sessions-visible", true);

src/store/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export {
3333
primaryFeatureAtom,
3434
workspaceDataAtom, workspaceLoadingAtom, collapsedProjectGroupsAtom,
3535
featureSidebarExpandedPanelsAtom, featureSidebarPinnedExpandedAtom, featureSidebarFilesExpandedAtom,
36-
sidebarModeAtom,
36+
sidebarModeAtom, dashboardSessionsVisibleAtom,
3737
type SidebarMode,
3838
} from "./atoms/workspace";
3939

0 commit comments

Comments
 (0)