|
| 1 | +# Sidebar Toggle Placement Implementation Plan |
| 2 | + |
| 3 | +> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:executing-plans |
| 4 | +> to implement this plan directly in the current agent, task-by-task. Never use |
| 5 | +> subagent-driven development. Steps use checkbox (`- [ ]`) syntax for tracking. |
| 6 | +
|
| 7 | +**Goal:** Move the desktop sidebar toggle next to the session filter while |
| 8 | +preserving the existing mobile hamburger behavior. |
| 9 | + |
| 10 | +**Approved spec/design:** This plan is based directly on the user's approved |
| 11 | +requirements: with the desktop sidebar open, render the collapse control to the |
| 12 | +right of the filter; with it closed, render the expand control to the left of |
| 13 | +the relocated filter; keep the current mobile hamburger and drawer behavior. |
| 14 | + |
| 15 | +**Architecture:** Add one shared state-aware sidebar toggle built from kit-ui's |
| 16 | +`IconButton`, then render it at the two session-list boundaries that own the |
| 17 | +filter. The global header keeps the hamburger only on mobile. Session detail |
| 18 | +receives the same closed-state toggle/filter pair in its breadcrumb. Focus moves |
| 19 | +to the newly visible counterpart after a keyboard-initiated toggle, and each |
| 20 | +control exposes the sidebar relationship through `aria-expanded` and |
| 21 | +`aria-controls`, so closing the sidebar never strands the user. |
| 22 | + |
| 23 | +**Tech Stack:** Svelte 5, TypeScript, kit-ui, Lucide icons, Paraglide JS, Vitest |
| 24 | +through Vite+ |
| 25 | + |
| 26 | +## Global Constraints |
| 27 | + |
| 28 | +- Do not change the existing mobile hamburger route and drawer behavior, and do |
| 29 | + not render the relocated controls on mobile. |
| 30 | +- Use shared controls rather than adding one-off button chrome. |
| 31 | +- Keep every locale catalog's message keys identical. |
| 32 | +- Tests must assert rendered order and click behavior, not source text. |
| 33 | + |
| 34 | +______________________________________________________________________ |
| 35 | + |
| 36 | +### Task 1: Protect the responsive placement contract |
| 37 | + |
| 38 | +**Files:** |
| 39 | + |
| 40 | +- Modify: `frontend/src/lib/components/layout/AppHeader.test.ts` |
| 41 | +- Modify: `frontend/src/lib/components/sidebar/SessionList.test.ts` |
| 42 | +- Modify: `frontend/src/lib/components/analytics/AnalyticsPage.test.ts` |
| 43 | +- Modify: `frontend/src/lib/components/layout/SessionBreadcrumb.test.ts` |
| 44 | +- Create: `frontend/src/lib/components/layout/SidebarToggleButton.test.ts` |
| 45 | + |
| 46 | +**Interfaces:** |
| 47 | + |
| 48 | +- Consumes: current `ui.sidebarOpen`, `ui.isMobileViewport`, and rendered filter |
| 49 | + controls. |
| 50 | + |
| 51 | +- Produces: regression coverage for desktop header removal, both mobile |
| 52 | + hamburger branches, open-state filter/collapse order, closed-state |
| 53 | + expand/filter order, and keyboard focus handoff in both directions. |
| 54 | + |
| 55 | +- [ ] **Step 1: Install the pinned frontend dependencies** |
| 56 | + |
| 57 | +Run: |
| 58 | + |
| 59 | +```bash |
| 60 | +cd frontend && vp install -- --allow-git=root |
| 61 | +``` |
| 62 | + |
| 63 | +Expected: dependencies install successfully without changing the pinned |
| 64 | +dependency set. |
| 65 | + |
| 66 | +- [ ] **Step 2: Write failing rendered-behavior tests** |
| 67 | + |
| 68 | +Add tests that query the localized `aria-label` values, compare sibling order |
| 69 | +around `.filter-btn`, click the toggle, and assert the observable |
| 70 | +`ui.sidebarOpen` state change. Focused-button tests must assert that focus moves |
| 71 | +to the newly visible counterpart after both collapse and reopen. Mobile |
| 72 | +AppHeader tests must cover closing the drawer on the sessions route and |
| 73 | +navigating from another route to open it. Mobile SessionList, Analytics, and |
| 74 | +Breadcrumb tests must prove the relocated controls are absent. Each desktop |
| 75 | +relocated control must retain the existing localized `Toggle sidebar (b)` title |
| 76 | +so the keyboard shortcut remains discoverable. |
| 77 | + |
| 78 | +- [ ] **Step 3: Run the focused tests and verify RED** |
| 79 | + |
| 80 | +Run: |
| 81 | + |
| 82 | +```bash |
| 83 | +cd frontend && PATH="$(pwd)/node_modules/.bin:$PATH" vp test src/lib/components/layout/AppHeader.test.ts src/lib/components/layout/SidebarToggleButton.test.ts src/lib/components/sidebar/SessionList.test.ts src/lib/components/analytics/AnalyticsPage.test.ts src/lib/components/layout/SessionBreadcrumb.test.ts |
| 84 | +``` |
| 85 | + |
| 86 | +Expected: assertion failures because the desktop hamburger is still global and |
| 87 | +the filter-adjacent controls do not exist. |
| 88 | + |
| 89 | +### Task 2: Add the shared sidebar toggle and place it around the filter |
| 90 | + |
| 91 | +**Files:** |
| 92 | + |
| 93 | +- Create: `frontend/src/lib/components/layout/SidebarToggleButton.svelte` |
| 94 | +- Modify: `frontend/src/lib/icons.ts` |
| 95 | +- Modify: `frontend/src/lib/icons.test.ts` |
| 96 | +- Modify: `frontend/src/lib/components/layout/AppHeader.svelte` |
| 97 | +- Modify: `frontend/src/lib/components/layout/ThreeColumnLayout.svelte` |
| 98 | +- Modify: `frontend/src/lib/components/sidebar/SessionList.svelte` |
| 99 | +- Modify: `frontend/src/lib/components/analytics/AnalyticsPage.svelte` |
| 100 | +- Modify: `frontend/src/lib/components/layout/SessionBreadcrumb.svelte` |
| 101 | +- Modify: `frontend/messages/en.json` |
| 102 | +- Modify: `frontend/messages/zh-CN.json` |
| 103 | +- Modify: `frontend/messages/zh-TW.json` |
| 104 | +- Modify: `frontend/messages/ko.json` |
| 105 | +- Modify: `frontend/messages/fr.json` |
| 106 | + |
| 107 | +**Interfaces:** |
| 108 | + |
| 109 | +- Consumes: `ui.sidebarOpen`, `ui.toggleSidebar()`, `m.nav_open_sidebar()`, and |
| 110 | + `m.nav_close_sidebar()`. |
| 111 | + |
| 112 | +- Produces: `SidebarToggleButton`, a shared icon-only button that renders the |
| 113 | + correct panel-open/panel-close icon and accessible state-specific label. |
| 114 | + |
| 115 | +- [ ] **Step 1: Add localized open-sidebar copy** |
| 116 | + |
| 117 | +Add `nav_open_sidebar` to every locale next to `nav_close_sidebar`, with an |
| 118 | +accurate translation in each catalog. |
| 119 | + |
| 120 | +- [ ] **Step 2: Implement the shared control** |
| 121 | + |
| 122 | +Create `SidebarToggleButton.svelte` with kit-ui `IconButton`. It calls |
| 123 | +`ui.toggleSidebar()`, labels itself from the current state, retains |
| 124 | +`m.nav_toggle_sidebar_shortcut()` as its title, and uses `PanelLeftCloseIcon` |
| 125 | +while open and `PanelLeftOpenIcon` while closed. Export both icons through the |
| 126 | +app icon facade and add them to its allowlist. Identify whether each toggle is |
| 127 | +in the sidebar or content region, expose `aria-expanded` and `aria-controls`, |
| 128 | +and move keyboard focus to the opposite region's toggle after the state change. |
| 129 | +Give the layout sidebar the stable ID referenced by the controls. |
| 130 | + |
| 131 | +- [ ] **Step 3: Relocate the desktop control** |
| 132 | + |
| 133 | +Render the AppHeader hamburger only when `ui.isMobileViewport`. On desktop only, |
| 134 | +place `SidebarToggleButton` immediately after `SessionFilterControl` in |
| 135 | +`SessionList`. On desktop with the sidebar collapsed, place |
| 136 | +`SidebarToggleButton` immediately before `SessionFilterControl` in the Analytics |
| 137 | +toolbar and SessionBreadcrumb. Give the breadcrumb pair a positioned flex |
| 138 | +wrapper, and configure its filter with `showDisplay={false}`, |
| 139 | +`showStarred={false}`, and `align="left"` so its dropdown has a valid anchor and |
| 140 | +exposes only working filters. |
| 141 | + |
| 142 | +- [ ] **Step 4: Run the focused tests and verify GREEN** |
| 143 | + |
| 144 | +Run the same focused test command from Task 1. Expected: all selected tests |
| 145 | +pass. |
| 146 | + |
| 147 | +### Task 3: Verify the frontend, commit, push, and open the pull request |
| 148 | + |
| 149 | +**Files:** |
| 150 | + |
| 151 | +- Verify all files listed above. |
| 152 | + |
| 153 | +**Interfaces:** |
| 154 | + |
| 155 | +- Consumes: the completed responsive placement implementation. |
| 156 | + |
| 157 | +- Produces: compiled locale output, repository-required frontend validation, one |
| 158 | + focused commit, a pushed feature branch, and an open pull request. |
| 159 | + |
| 160 | +- [ ] **Step 1: Compile localization and run frontend checks** |
| 161 | + |
| 162 | +```bash |
| 163 | +cd frontend && npm run i18n:compile && PATH="$(pwd)/node_modules/.bin:$PATH" vp check && PATH="$(pwd)/node_modules/.bin:$PATH" vp test && PATH="$(pwd)/node_modules/.bin:$PATH" vp run check:kit-ui |
| 164 | +``` |
| 165 | + |
| 166 | +Expected: locale compilation, formatting, linting, type checking, the full |
| 167 | +frontend suite (including locale key parity), and the kit-ui contract check all |
| 168 | +exit successfully. |
| 169 | + |
| 170 | +- [ ] **Step 2: Re-run the focused regression tests** |
| 171 | + |
| 172 | +```bash |
| 173 | +cd frontend && PATH="$(pwd)/node_modules/.bin:$PATH" vp test src/lib/components/layout/AppHeader.test.ts src/lib/components/sidebar/SessionList.test.ts src/lib/components/analytics/AnalyticsPage.test.ts src/lib/components/layout/SessionBreadcrumb.test.ts |
| 174 | +``` |
| 175 | + |
| 176 | +Expected: all selected tests pass with no failures. |
| 177 | + |
| 178 | +- [ ] **Step 3: Check the responsive layout visually** |
| 179 | + |
| 180 | +At the minimum desktop width, verify the open and collapsed control groups in |
| 181 | +English and a locale with longer labels. Confirm that the sidebar header and |
| 182 | +analytics toolbar do not overlap, clip, or wrap unexpectedly. |
| 183 | + |
| 184 | +- [ ] **Step 4: Review the diff and commit** |
| 185 | + |
| 186 | +Stage only the plan, component, catalog, and test changes, then create a focused |
| 187 | +conventional commit explaining why the toggle belongs with the panel controls |
| 188 | +and why mobile remains unchanged. |
| 189 | + |
| 190 | +- [ ] **Step 5: Push and open the pull request** |
| 191 | + |
| 192 | +The user already authorized the commit-push-PR workflow. Push the current |
| 193 | +feature branch to `origin`, run the private-data scrub on the proposed |
| 194 | +title/body, then create a pull request whose description summarizes the behavior |
| 195 | +and rationale without a test-plan section or checklist. |
0 commit comments