mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 04:44:21 +01:00
feat(servers): show linked server projects on the home page and remove the server page
The home page follows the sidebar server selection and lists a linked server's projects with the same cards, search and row actions as local repositories. /servers/:id now selects that server and redirects home. Back from a remote session goes to its project page and back from a project goes home, and the selection follows the route app-wide so mobile keeps the linked server.
This commit is contained in:
1 parent
c1e09f34a5
commit
c18c3584ef
32 files changed
+1576
-789
No files matched your search
@@ -10,11 +10,12 @@ function isLocalRoute(pathname: string): boolean {
|
||||
}
|
||||
|
||||
/**
|
||||
* The linked server selected in the sidebar, defaulting to the local server. The route selects a
|
||||
* server when the location changes, selecting a row never navigates, and a selected server that is
|
||||
* missing or disabled in a successfully loaded list falls back to local.
|
||||
* Keeps the sidebar server selection in step with the location and the linked server list: a linked
|
||||
* server route selects that server, a local repo or assistant route selects local, and a selected
|
||||
* server that is missing or disabled in a successfully loaded list falls back to local. Mounted once
|
||||
* by the app shell so the selection follows the route even when no sidebar consumer is rendered.
|
||||
*/
|
||||
export function useSidebarServerSelection(): [string, (serverId: string) => void] {
|
||||
export function useSidebarServerRouteSync(): void {
|
||||
const { pathname } = useLocation()
|
||||
const routeServerId = useMatch('/servers/:serverId/*')?.params.serverId
|
||||
const { servers, isSuccess } = useOpenCodeServers()
|
||||
@@ -39,6 +40,15 @@ export function useSidebarServerSelection(): [string, (serverId: string) => void
|
||||
selectServer(LOCAL_OPENCODE_SERVER_ID)
|
||||
}
|
||||
}, [isSuccess, servers, serverId, selectServer])
|
||||
}
|
||||
|
||||
/**
|
||||
* The linked server selected in the sidebar, defaulting to the local server. Selecting a server
|
||||
* never navigates; `useSidebarServerRouteSync` keeps the selection aligned with the route.
|
||||
*/
|
||||
export function useSidebarServerSelection(): [string, (serverId: string) => void] {
|
||||
const serverId = useSidebarServerStore((state) => state.serverId)
|
||||
const selectServer = useSidebarServerStore((state) => state.selectServer)
|
||||
|
||||
return [serverId, selectServer]
|
||||
}
|
||||
Reference in new issue
Block a user