fix(layout): fix visual flicker in sidebar on collapse#2268
Conversation
Greptile SummaryThis PR eliminates the sidebar collapse flicker by eagerly updating
Confidence Score: 5/5Safe to merge — the changes are narrowly scoped to the sidebar collapse path and the logic correctly prevents state from being overwritten during animation. The eager setIsLeftOpen update combined with the suppression guard directly eliminates the flicker root cause. No new state paths are introduced that could regress other behaviour, and the panelDragStore addition is a read-only accessor with no side effects. No files require special attention.
|
| Filename | Overview |
|---|---|
| src/renderer/lib/layout/layout-provider.tsx | Core fix: eager setIsLeftOpen(!collapsed) before panel API call, plus syncLeftOpenFromPanel that guards against suppression window — logic is sound and context interface is correctly updated. |
| src/renderer/lib/layout/panel-drag-store.ts | Minimal, correct addition of getIsSuppressing() as a synchronous read accessor alongside the existing useSyncExternalStore-compatible API. |
| src/renderer/lib/layout/workspace-layout.tsx | One-line change swapping the inline onResize callback for syncLeftOpenFromPanel; no other logic touched. |
Sequence Diagram
sequenceDiagram
participant User
participant toggleLeft
participant setCollapsed
participant panelDragStore
participant ReactState
participant panel as react-resizable-panels
participant syncLeftOpenFromPanel
User->>toggleLeft: cmd+B / click
toggleLeft->>setCollapsed: setCollapsed('left', true)
setCollapsed->>panelDragStore: suppressFor(140ms)
setCollapsed->>ReactState: setIsLeftOpen(false) [eager]
setCollapsed->>panel: panel.collapse()
loop onResize burst (0-140ms)
panel-->>syncLeftOpenFromPanel: onResize fires
syncLeftOpenFromPanel->>panelDragStore: getIsSuppressing()
panelDragStore-->>syncLeftOpenFromPanel: true - early return
end
Note over panelDragStore: 140ms timer expires
panelDragStore->>panelDragStore: "isSuppressing = false"
panel-->>syncLeftOpenFromPanel: final onResize (if any)
syncLeftOpenFromPanel->>panelDragStore: getIsSuppressing()
panelDragStore-->>syncLeftOpenFromPanel: false
syncLeftOpenFromPanel->>ReactState: "setIsLeftOpen(!isCollapsed()) = false"
Reviews (2): Last reviewed commit: "fix(layout): ignore suppressed sidebar r..." | Re-trigger Greptile
before:
https://streamable.com/tqiq62
after:
https://streamable.com/af1tj5