|
| 1 | +# Mac-Style Project Tab Bar Implementation Plan |
| 2 | + |
| 3 | +> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:executing-plans to implement this plan task-by-task with verification checkpoints. |
| 4 | +
|
| 5 | +**Goal:** Add a horizontal project tab bar below the Windows title bar so every project open in the current window is visible and can be activated with one click. |
| 6 | + |
| 7 | +**Architecture:** Keep project persistence and switching in the existing Zustand/file-system stores. Add a small pure model helper to normalize the active tab for deterministic tests, a focused `ProjectTabBar` presentation component for rendering and activation, and mount it from `MainLayout` directly below `TitleBarWithSettings`. The existing title-bar project dropdown remains unchanged as the project-management menu. |
| 8 | + |
| 9 | +**Tech Stack:** React 19, TypeScript, Zustand selectors, Base UI-compatible buttons, Tailwind semantic tokens, Bun tests, Vite Plus. |
| 10 | + |
| 11 | +--- |
| 12 | + |
| 13 | +### Task 1: Normalize Project Tab Data |
| 14 | + |
| 15 | +**Files:** |
| 16 | +- Create: `windows/tauri/src/features/window/utils/project-tab-bar-model.ts` |
| 17 | +- Create: `windows/tauri/src/features/window/utils/project-tab-bar-model.test.ts` |
| 18 | + |
| 19 | +- [ ] **Step 1: Write the failing test** |
| 20 | + |
| 21 | +Add a fixture with two project tabs and assert that `getProjectTabBarItems` preserves order, marks only the first active project, and repairs an invalid multiple-active input by keeping the first active tab. |
| 22 | + |
| 23 | +```ts |
| 24 | +test("preserves project order and exposes one active tab", () => { |
| 25 | + const result = getProjectTabBarItems([ |
| 26 | + { id: "a", name: "Alpha", path: "D:/alpha", isActive: true, lastOpened: 1 }, |
| 27 | + { id: "b", name: "Beta", path: "D:/beta", isActive: true, lastOpened: 2 }, |
| 28 | + ]); |
| 29 | + |
| 30 | + expect(result.map((tab) => tab.name)).toEqual(["Alpha", "Beta"]); |
| 31 | + expect(result.map((tab) => tab.isActive)).toEqual([true, false]); |
| 32 | +}); |
| 33 | +``` |
| 34 | + |
| 35 | +- [ ] **Step 2: Run the focused test and confirm the expected failure** |
| 36 | + |
| 37 | +Run from `windows/tauri`: |
| 38 | + |
| 39 | +```powershell |
| 40 | +bun test src/features/window/utils/project-tab-bar-model.test.ts |
| 41 | +``` |
| 42 | + |
| 43 | +Expected: the test fails because `project-tab-bar-model.ts` does not exist yet. |
| 44 | + |
| 45 | +- [ ] **Step 3: Implement the minimal model helper** |
| 46 | + |
| 47 | +Implement `getProjectTabBarItems(projectTabs)` by finding the first `isActive` tab and mapping the input in its original order, setting `isActive` only for that ID while preserving the other display fields. |
| 48 | + |
| 49 | +- [ ] **Step 4: Run the focused test and confirm it passes** |
| 50 | + |
| 51 | +Run the same Bun test. Expected: 1 test passes, 0 failures. |
| 52 | + |
| 53 | +### Task 2: Build The Project Tab Bar |
| 54 | + |
| 55 | +**Files:** |
| 56 | +- Create: `windows/tauri/src/features/window/components/project-tab-bar.tsx` |
| 57 | +- Create: `windows/tauri/src/features/window/components/project-tab-bar.test.ts` |
| 58 | + |
| 59 | +- [ ] **Step 1: Write the failing component contract test** |
| 60 | + |
| 61 | +Add a source-level contract test that requires the component to expose `role="tablist"`, `role="tab"`, `aria-selected`, `isSwitchingProject`, and `switchToProject`. This protects the accessibility and switching contract without introducing a new renderer test dependency. |
| 62 | + |
| 63 | +- [ ] **Step 2: Run the focused test and confirm the expected failure** |
| 64 | + |
| 65 | +Run: |
| 66 | + |
| 67 | +```powershell |
| 68 | +bun test src/features/window/components/project-tab-bar.test.ts |
| 69 | +``` |
| 70 | + |
| 71 | +Expected: the test fails because the component file does not exist yet. |
| 72 | + |
| 73 | +- [ ] **Step 3: Implement the component** |
| 74 | + |
| 75 | +Implement the component with these exact behaviors: |
| 76 | + |
| 77 | +```tsx |
| 78 | +const projectTabs = useWorkspaceTabsStore.use.projectTabs(); |
| 79 | +const switchToProject = useFileSystemStore((state) => state.switchToProject); |
| 80 | +const isSwitchingProject = useFileSystemStore((state) => state.isSwitchingProject); |
| 81 | +const projects = getProjectTabBarItems(projectTabs); |
| 82 | + |
| 83 | +if (projects.length === 0) return null; |
| 84 | + |
| 85 | +return ( |
| 86 | + <div role="tablist" aria-label={t("titleProject.openProjects")}> |
| 87 | + {projects.map((project) => ( |
| 88 | + <button |
| 89 | + key={project.id} |
| 90 | + type="button" |
| 91 | + role="tab" |
| 92 | + aria-selected={project.isActive} |
| 93 | + disabled={isSwitchingProject || project.isActive} |
| 94 | + title={project.path} |
| 95 | + onClick={() => void switchToProject(project.id)} |
| 96 | + > |
| 97 | + {project.name} |
| 98 | + </button> |
| 99 | + ))} |
| 100 | + </div> |
| 101 | +); |
| 102 | +``` |
| 103 | + |
| 104 | +Use the existing `FolderOpenIcon`, semantic surface/border/selected tokens, fixed 30px tab height, horizontal overflow, visible focus styles, and truncated names. Do not add a native drag region or duplicate project-management actions. |
| 105 | + |
| 106 | +- [ ] **Step 4: Run the focused component contract test** |
| 107 | + |
| 108 | +Run the same Bun test. Expected: 1 test passes, 0 failures. |
| 109 | + |
| 110 | +### Task 3: Mount The Bar In The Workbench |
| 111 | + |
| 112 | +**Files:** |
| 113 | +- Modify: `windows/tauri/src/features/layout/components/main-layout.tsx` |
| 114 | + |
| 115 | +- [ ] **Step 1: Add the import and mount point** |
| 116 | + |
| 117 | +Import `ProjectTabBar` from the window feature and render `<ProjectTabBar />` immediately after `<TitleBarWithSettings />`, before the root-folder conditional. The component itself returns `null` when no project is open, preserving the welcome screen layout. |
| 118 | + |
| 119 | +- [ ] **Step 2: Run focused tests and typecheck** |
| 120 | + |
| 121 | +Run: |
| 122 | + |
| 123 | +```powershell |
| 124 | +bun test src/features/window/utils/project-tab-bar-model.test.ts src/features/window/components/project-tab-bar.test.ts |
| 125 | +bun run typecheck |
| 126 | +``` |
| 127 | + |
| 128 | +Expected: all focused tests pass and TypeScript exits with code 0. |
| 129 | + |
| 130 | +### Task 4: Verify The User Workflow |
| 131 | + |
| 132 | +**Files:** |
| 133 | +- No additional source files. |
| 134 | + |
| 135 | +- [ ] **Step 1: Run lint and frontend build** |
| 136 | + |
| 137 | +```powershell |
| 138 | +bunx vp lint src/features/layout/components/main-layout.tsx src/features/window/components/project-tab-bar.tsx src/features/window/components/project-tab-bar.test.ts src/features/window/utils/project-tab-bar-model.ts src/features/window/utils/project-tab-bar-model.test.ts |
| 139 | +bun run build |
| 140 | +git diff --check |
| 141 | +``` |
| 142 | + |
| 143 | +Expected: all commands exit 0. Existing dependency warnings are acceptable if they do not introduce errors. |
| 144 | + |
| 145 | +- [ ] **Step 2: Rebuild and launch Windows Release** |
| 146 | + |
| 147 | +Stop the current preview process, run `.\scripts\build-windows.ps1 -Configuration Release` from the repository root, and launch `windows/tauri/src-tauri/target/x86_64-pc-windows-msvc/release/lithe-windows.exe`. |
| 148 | + |
| 149 | +- [ ] **Step 3: Verify the live tab interaction through CDP** |
| 150 | + |
| 151 | +Open two projects in the current window, assert a visible `[role="tablist"]` contains both project names, click the inactive `[role="tab"]`, and assert its `aria-selected` becomes `true` while the previous tab becomes `false`. Confirm the title-bar project label changes to the newly active project. |
| 152 | + |
| 153 | +- [ ] **Step 4: Run the final focused checks** |
| 154 | + |
| 155 | +```powershell |
| 156 | +bun test src/features/window/utils/project-tab-bar-model.test.ts src/features/window/components/project-tab-bar.test.ts |
| 157 | +bun run typecheck |
| 158 | +git diff --check |
| 159 | +``` |
| 160 | + |
| 161 | +Expected: all tests pass, typecheck passes, and no whitespace errors are reported. |
| 162 | + |
| 163 | +### Task 5: Review And Commit |
| 164 | + |
| 165 | +**Files:** |
| 166 | +- Stage only the new project-tab-bar source/tests, `main-layout.tsx`, and the task plan/progress files. |
| 167 | + |
| 168 | +- [ ] **Step 1: Inspect the task diff and run an independent review** |
| 169 | + |
| 170 | +Check `git diff` and confirm unrelated pre-existing changes remain unstaged. Resolve any Critical or Important review findings before committing. |
| 171 | + |
| 172 | +- [ ] **Step 2: Create one focused implementation commit** |
| 173 | + |
| 174 | +```powershell |
| 175 | +git add -- windows/tauri/src/features/layout/components/main-layout.tsx windows/tauri/src/features/window/components/project-tab-bar.tsx windows/tauri/src/features/window/components/project-tab-bar.test.ts windows/tauri/src/features/window/utils/project-tab-bar-model.ts windows/tauri/src/features/window/utils/project-tab-bar-model.test.ts .planning/2026-08-17-project-tab-bar/task_plan.md .planning/2026-08-17-project-tab-bar/findings.md .planning/2026-08-17-project-tab-bar/progress.md docs/superpowers/plans/2026-08-17-project-tab-bar.md |
| 176 | +git commit -m "feat: add mac-style project tabs" |
| 177 | +``` |
0 commit comments