mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 04:44:21 +01:00
* refactor: add desktop sidebar navigation and consolidate header actions - Add DesktopSidebar component with collapsible navigation - Add useDesktop and useSidebarAction hooks for sidebar state management - Add useSidebarCollapsed hook with localStorage persistence and error handling - Integrate sidebar into App layout with tooltip support - Remove repoUrl and isRepoWorktree props from SourceControlPanel - BranchesTab now fetches repo data internally using getRepo query - Remove unused to prop from SidebarItem - Simplify RepoList conditional rendering - Add comprehensive test coverage for new components * refactor: remove LSP status button and memory plugin status hook - Delete LspStatusButton component and its test file - Remove unused useMemoryPluginStatus hook from RepoDetail - Clean up dead code as part of desktop header refactor
34 lines
824 B
TypeScript
34 lines
824 B
TypeScript
import { useState, useCallback } from 'react'
|
|
|
|
const STORAGE_KEY = 'oc:sidebar:collapsed'
|
|
|
|
export function useSidebarCollapsed(): [boolean, () => void] {
|
|
const [collapsed, setCollapsed] = useState(() => {
|
|
if (typeof window === 'undefined') {
|
|
return false
|
|
}
|
|
const stored = localStorage.getItem(STORAGE_KEY)
|
|
if (stored === null) {
|
|
return false
|
|
}
|
|
try {
|
|
const parsed = JSON.parse(stored)
|
|
return typeof parsed === 'boolean' ? parsed : false
|
|
} catch {
|
|
return false
|
|
}
|
|
})
|
|
|
|
const toggle = useCallback(() => {
|
|
setCollapsed((prev: boolean) => {
|
|
const newValue = !prev
|
|
if (typeof window !== 'undefined') {
|
|
localStorage.setItem(STORAGE_KEY, JSON.stringify(newValue))
|
|
}
|
|
return newValue
|
|
})
|
|
}, [])
|
|
|
|
return [collapsed, toggle]
|
|
}
|