Files
opencode-manager/frontend/src/hooks/useDialogParam.ts
T
Chris Scott 015a44a5f3 feat(sidebar): add repo-grouped session navigation with live status (#361)
* feat(sidebar): add repo-grouped session navigation with live status

- Add a searchable, collapsible session tree to the desktop sidebar, grouped by repository with pinned and time-bucketed ordering.
- Track per-session busy, retry, and compact status in a shared store fed by the SSE event stream and scoped by directory.
- Extract shared navigation components reused by the desktop tree and the mobile repo quick-switch sheet.
- Show a Git tab and hide Schedules inside a repo on the mobile tab bar; add Repos and Assistant entries to the session More drawer.
- Replace the CommitsTab local relative-time formatter with a shared formatShortRelativeTime util.

* refactor(sidebar): unify session status tracking and navigation helpers

* feat(sidebar): add collapsible sessions and menu sections

* fix(sessions): keep specific live status over snapshot busy
2026-09-26 21:50:23 -04:00

36 lines
828 B
TypeScript

import { useCallback } from 'react'
import { useUrlParams } from './useUrlParams'
export function openDialogParam(
updateParams: ReturnType<typeof useUrlParams>['updateParams'],
name: string,
): void {
updateParams((p) => {
p.set('dialog', name)
p.delete('mobileTab')
}, 'push')
}
export function useDialogParam(name: string): [boolean, (open: boolean) => void] {
const { searchParams, updateParams } = useUrlParams()
const isOpen = searchParams.get('dialog') === name
const setOpen = useCallback(
(open: boolean) => {
if (open) {
openDialogParam(updateParams, name)
return
}
updateParams((p) => {
if (p.get('dialog') === name) {
p.delete('dialog')
}
}, 'replace')
},
[updateParams, name],
)
return [isOpen, setOpen]
}