Skip to content

fix(layout): fix visual flicker in sidebar on collapse#2268

Merged
arnestrickmann merged 2 commits into
mainfrom
jan/eng-1448-visual-glitch-when-collapsing-the-sidebar
May 28, 2026
Merged

fix(layout): fix visual flicker in sidebar on collapse#2268
arnestrickmann merged 2 commits into
mainfrom
jan/eng-1448-visual-glitch-when-collapsing-the-sidebar

Conversation

@janburzinski
Copy link
Copy Markdown
Collaborator

@janburzinski janburzinski changed the title fix(layout): sync sidebar open state before collapse fix(layout): fix visual flicker in sidebar on collapse May 28, 2026
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 28, 2026

Greptile Summary

This PR eliminates the sidebar collapse flicker by eagerly updating isLeftOpen state before triggering programmatic collapse/expand, and blocking intermediate onResize events during the animation via the existing panelDragStore suppression window.

  • setCollapsed now calls setIsLeftOpen(!collapsed) eagerly before panel.collapse()/panel.expand(), so the React state reflects the intended outcome immediately rather than waiting for the panel library to emit its final resize event.
  • syncLeftOpenFromPanel replaces the former inline setIsLeftOpen callback on onResize, short-circuiting when getIsSuppressing() is true so the 140 ms burst of intermediate events cannot overwrite the eagerly-set state.
  • panelDragStore gains a getIsSuppressing() accessor to expose the suppression flag for synchronous reads outside of useSyncExternalStore.

Confidence Score: 5/5

Safe 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.

Important Files Changed

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"
Loading

Reviews (2): Last reviewed commit: "fix(layout): ignore suppressed sidebar r..." | Re-trigger Greptile

@janburzinski
Copy link
Copy Markdown
Collaborator Author

@greptileai

@arnestrickmann arnestrickmann merged commit 3da5766 into main May 28, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants