open-swe/ui/src/features/agents/lib/gitPanelPreferences.ts
Adam Moussa e542f0d7a6
fix: collapse git panel by default (#1744)
Co-authored-by: Ramon Nogueira <270434257+ramon-langchain@users.noreply.github.com>
Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com>
(cherry picked from commit 3e8089c36995cccaeee3694599cf58857b06e557)

Co-authored-by: Ramon Nogueira <ramon.nogueira@langchain.dev>
2026-07-17 16:22:38 -04:00

20 lines
788 B
TypeScript

const PANEL_STORAGE_COLLAPSED = "open-swe.gitpanel.collapsed"
const COLLAPSED_STATE_TRUE = "1"
const COLLAPSED_STATE_FALSE = "0"
const PANEL_DEFAULT_EXPANDED_MEDIA_QUERY = "(min-width: 1536px)"
export function readStoredPanelCollapsed(): boolean {
if (typeof window === "undefined") return true
const stored = window.localStorage.getItem(PANEL_STORAGE_COLLAPSED)
if (stored === COLLAPSED_STATE_TRUE) return true
if (stored === COLLAPSED_STATE_FALSE) return false
return !window.matchMedia(PANEL_DEFAULT_EXPANDED_MEDIA_QUERY).matches
}
export function writeStoredPanelCollapsed(collapsed: boolean): void {
if (typeof window === "undefined") return
window.localStorage.setItem(
PANEL_STORAGE_COLLAPSED,
collapsed ? COLLAPSED_STATE_TRUE : COLLAPSED_STATE_FALSE
)
}