feat(frontend): consolidate session picker navigation and remote project loading

This commit is contained in:
Chris Scott committed 2026-10-23 22:35:10 -04:00
1 parent 81fb2d4033
commit 52aeb7780f
42 files changed
+1486 -769

No files matched your search

@@ -1,24 +1,26 @@
import { useLocation } from 'react-router-dom'
import { LOCAL_OPENCODE_SERVER_ID } from '@opencode-manager/shared/schemas'
import type { Repo } from '@/api/types'
import { parseRepoRoute, parseServerProjectRoute, parseServerSessionRoute } from '@/lib/navigation'
import type { RemotePickerScope } from '@/components/session/SessionPickerDialog'
import { parseRepoRoute, parseServerSessionRoute } from '@/lib/navigation'
import { useNavigableRepos } from '@/hooks/useSidebarRepoGroups'
import { useOpenCodeServers } from '@/hooks/useOpenCodeServers'
import { useSidebarServerSelection } from '@/hooks/useSidebarServerSelection'
import { useActiveRemoteDirectory } from '@/hooks/useActiveRemoteDirectory'
export interface SessionPickerRouteScope {
currentRepo: Repo | undefined
activeSessionID: string | undefined
activeServerId: string | undefined
isRemote: boolean
remote: { serverId: string; serverName?: string; projectDirectory?: string } | undefined
remote: RemotePickerScope | undefined
}
export function useSessionPickerRouteScope(enabled: boolean): SessionPickerRouteScope {
const { pathname, search } = useLocation()
const { pathname } = useLocation()
const [selectedServerId] = useSidebarServerSelection()
const { repos } = useNavigableRepos(enabled)
const { servers } = useOpenCodeServers({ enabled })
const activeRemoteDirectory = useActiveRemoteDirectory(selectedServerId, { enabled })
const isRemote = selectedServerId !== LOCAL_OPENCODE_SERVER_ID
const repoRoute = parseRepoRoute(pathname)
@@ -28,23 +30,19 @@ export function useSessionPickerRouteScope(enabled: boolean): SessionPickerRoute
: repos.find((candidate) => candidate.id === repoRoute.repoId)
const activeSessionID = repoRoute.sessionId ?? serverSessionRoute?.sessionId ?? undefined
const activeServerId = repoRoute.sessionId ? LOCAL_OPENCODE_SERVER_ID : serverSessionRoute?.serverId
const remoteProjectDirectory = isRemote
? parseServerProjectRoute(pathname, search)?.directory
: undefined
if (!isRemote) {
return { currentRepo, activeSessionID, activeServerId, isRemote, remote: undefined }
return { currentRepo, activeSessionID, activeServerId, remote: undefined }
}
return {
currentRepo,
activeSessionID,
activeServerId,
isRemote,
remote: {
serverId: selectedServerId,
serverName: servers.find((server) => server.id === selectedServerId)?.name,
projectDirectory: remoteProjectDirectory,
projectDirectory: activeRemoteDirectory ?? undefined,
},
}
}