fix(ui): align sidebar menu state with visibility#236
fix(ui): align sidebar menu state with visibility#236benvinegar merged 1 commit intomodem-dev:mainfrom
Conversation
Greptile SummaryThis PR fixes a UI bug where the View menu's Sidebar checkbox reflected
Confidence Score: 3/5The menu-checkmark fix is correct, but initialising The half of the change that passes src/ui/App.tsx lines 112–113 — the Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[terminal.width] --> B[resolveResponsiveLayout\nlayoutMode, width]
B --> C{responsiveLayout\n.showSidebar}
D[sidebarVisible state] --> E
C --> E
F[forceSidebarOpen state] --> E
G[canForceShowSidebar] --> E
E{renderSidebar =\nsidebarVisible &&\nshowSidebar OR forceSidebar} --> H[Sidebar rendered]
E --> I[View menu checkbox\nchecked: renderSidebar]
J["toggleSidebar()"] --> D
J --> F
Prompt To Fix All With AIFix the following 1 code review issue. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 1
src/ui/App.tsx:112-113
Initializing `sidebarVisible` from the responsive layout at mount time breaks the existing auto-show behavior. With the old `useState(true)`, a user who opens the app on a narrow/medium terminal and later resizes to a full-width terminal (≥ 220 cols) would automatically see the sidebar appear — because `sidebarVisible` stayed `true` and `responsiveLayout.showSidebar` would flip to `true`, making `renderSidebar` true. With this change, `sidebarVisible` is set to `false` on narrow/medium viewports and is never reset on resize, so the sidebar never auto-shows even after widening the terminal.
The reported menu bug is fully fixed just by passing `renderSidebar` to `buildAppMenus` (the other half of this PR). The `sidebarVisible` initial value can stay `true` — the computed `renderSidebar` already accounts for the viewport width.
```suggestion
const [sidebarVisible, setSidebarVisible] = useState(true);
```
Reviews (1): Last reviewed commit: "fix(ui): align sidebar menu state with v..." | Re-trigger Greptile |
| const initialResponsiveLayout = resolveResponsiveLayout(bootstrap.initialMode, terminal.width); | ||
| const [sidebarVisible, setSidebarVisible] = useState(initialResponsiveLayout.showSidebar); |
There was a problem hiding this comment.
Initializing
sidebarVisible from the responsive layout at mount time breaks the existing auto-show behavior. With the old useState(true), a user who opens the app on a narrow/medium terminal and later resizes to a full-width terminal (≥ 220 cols) would automatically see the sidebar appear — because sidebarVisible stayed true and responsiveLayout.showSidebar would flip to true, making renderSidebar true. With this change, sidebarVisible is set to false on narrow/medium viewports and is never reset on resize, so the sidebar never auto-shows even after widening the terminal.
The reported menu bug is fully fixed just by passing renderSidebar to buildAppMenus (the other half of this PR). The sidebarVisible initial value can stay true — the computed renderSidebar already accounts for the viewport width.
| const initialResponsiveLayout = resolveResponsiveLayout(bootstrap.initialMode, terminal.width); | |
| const [sidebarVisible, setSidebarVisible] = useState(initialResponsiveLayout.showSidebar); | |
| const [sidebarVisible, setSidebarVisible] = useState(true); |
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/ui/App.tsx
Line: 112-113
Comment:
Initializing `sidebarVisible` from the responsive layout at mount time breaks the existing auto-show behavior. With the old `useState(true)`, a user who opens the app on a narrow/medium terminal and later resizes to a full-width terminal (≥ 220 cols) would automatically see the sidebar appear — because `sidebarVisible` stayed `true` and `responsiveLayout.showSidebar` would flip to `true`, making `renderSidebar` true. With this change, `sidebarVisible` is set to `false` on narrow/medium viewports and is never reset on resize, so the sidebar never auto-shows even after widening the terminal.
The reported menu bug is fully fixed just by passing `renderSidebar` to `buildAppMenus` (the other half of this PR). The `sidebarVisible` initial value can stay `true` — the computed `renderSidebar` already accounts for the viewport width.
```suggestion
const [sidebarVisible, setSidebarVisible] = useState(true);
```
How can I resolve this? If you propose a fix, please make it concise.5793e48 to
150a24c
Compare
|
Thanks @aliou! |
Hello!
Noticed this UI bug while interacting with Hunk from a smaller terminal window:
This PR makes the checkbox reflect whether the sidebar is actually rendered.
Research + code review session (gpt-5.5): https://pi.dev/session/#bcf0b5045252c82447828797ca8e013c
Implementation session (kimi k2.6): https://pi.dev/session/#758e5740c6f72a5289d28f0643937396
-> Some manual code tweaks were done outside of those two sessions (especially around tests)
Let me know if you need/want more changes!
Summary by GPT-5.5:
Summary
src/ui/App.tsxinstead of always defaulting to visible.renderSidebarstate intobuildAppMenusso the View menu checkmark reflects the sidebar currently rendered on screen.src/ui/lib/appMenus.tsandsrc/ui/lib/ui-lib.test.tsto userenderSidebaras the menu state input.src/ui/AppHost.responsive.test.tsxfor medium-width terminals where the sidebar is hidden by layout but can still be forced open.Behavior
On medium-width terminals, the View menu now shows Sidebar unchecked when the sidebar is not visible. Pressing
sstill opens the hidden sidebar when there is enough room to force it open.Validation
bun test src/ui/AppHost.responsive.test.tsxbun test src/ui/lib/ui-lib.test.tsbun run typecheck