From cbdd252d7a60cdcfb7c75290ba8e9055940367f5 Mon Sep 17 00:00:00 2001 From: Chris Scott <99081550+chriswritescode-dev@users.noreply.github.com> Date: Wed, 21 Oct 2026 23:14:12 -0400 Subject: [PATCH] feat(frontend): switch servers from the home page header Replace the read-only connection status with the server switcher, so the header names the selected linked server and can change servers in place. --- .../navigation/LinkedServersNav.tsx | 8 ++-- .../components/servers/ConnectionStatus.tsx | 43 ----------------- frontend/src/pages/Repos.tsx | 26 ++-------- frontend/src/pages/__tests__/Repos.test.tsx | 48 +++++++++---------- 4 files changed, 32 insertions(+), 93 deletions(-) delete mode 100644 frontend/src/components/servers/ConnectionStatus.tsx diff --git a/frontend/src/components/navigation/LinkedServersNav.tsx b/frontend/src/components/navigation/LinkedServersNav.tsx index e0db4a05..6ff7ba7e 100644 --- a/frontend/src/components/navigation/LinkedServersNav.tsx +++ b/frontend/src/components/navigation/LinkedServersNav.tsx @@ -20,10 +20,10 @@ import { cn } from '@/lib/utils' const LOCAL_SERVER_LABEL = 'OC Manager' -export type LinkedServersVariant = 'sidebar' | 'rail' | 'sheet' +export type LinkedServersVariant = 'sidebar' | 'rail' | 'sheet' | 'header' interface LinkedServersNavProps { - /** `sidebar` renders the full-width trigger row, `rail` the collapsed icon button, `sheet` the mobile sheet row. */ + /** `sidebar` renders the full-width trigger row, `rail` the collapsed icon button, `sheet` the mobile sheet row, `header` a compact page-header trigger. */ variant?: LinkedServersVariant } @@ -218,7 +218,9 @@ export function LinkedServersNav({ variant = 'sidebar' }: LinkedServersNavProps) 'flex items-center rounded-md text-sm text-foreground transition-colors duration-150', 'hover:bg-accent/50', 'focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background', - isRail ? 'mx-auto h-9 w-9 justify-center' : 'h-9 w-full gap-2 px-2', + isRail && 'mx-auto h-9 w-9 justify-center', + variant === 'header' && 'h-8 min-w-0 max-w-[45vw] gap-2 px-2 sm:max-w-xs', + (variant === 'sidebar' || variant === 'sheet') && 'h-9 w-full gap-2 px-2', )} > diff --git a/frontend/src/components/servers/ConnectionStatus.tsx b/frontend/src/components/servers/ConnectionStatus.tsx deleted file mode 100644 index 80c86762..00000000 --- a/frontend/src/components/servers/ConnectionStatus.tsx +++ /dev/null @@ -1,43 +0,0 @@ -import type { OpenCodeServerStatus } from '@opencode-manager/shared/schemas' - -interface ConnectionStatusProps { - status?: OpenCodeServerStatus - isLoading: boolean -} - -/** - * Connection indicator for a linked server: checking, unknown, unreachable with its error, or - * connected with the server version. - */ -export function ConnectionStatus({ status, isLoading }: ConnectionStatusProps) { - if (isLoading) { - return Checking connection... - } - - if (!status) { - return ( - - - Unknown - - ) - } - - if (!status.connected) { - return ( - - - Unreachable - {status.error ? · {status.error} : null} - - ) - } - - return ( - - - Connected - {status.version ? · v{status.version} : null} - - ) -} diff --git a/frontend/src/pages/Repos.tsx b/frontend/src/pages/Repos.tsx index 222c317e..7650e0f1 100644 --- a/frontend/src/pages/Repos.tsx +++ b/frontend/src/pages/Repos.tsx @@ -1,41 +1,21 @@ import { useState } from "react"; import { useNavigate } from "react-router-dom"; -import { Plus, FolderOpen, CalendarClock, Settings } from "lucide-react"; +import { Plus, FolderOpen, CalendarClock } from "lucide-react"; import { LOCAL_OPENCODE_SERVER_ID } from "@opencode-manager/shared/schemas"; import { RepoList } from "@/components/repo/RepoList"; import { AddRepoDialog } from "@/components/repo/AddRepoDialog"; import { FileBrowserSheet } from "@/components/file-browser/FileBrowserSheet"; import { RemoteProjectList } from "@/components/servers/RemoteProjectList"; -import { ConnectionStatus } from "@/components/servers/ConnectionStatus"; import { Header } from "@/components/ui/header"; import { Button } from "@/components/ui/button"; import { PendingActionsGroup } from "@/components/notifications/PendingActionsGroup"; +import { LinkedServersNav } from "@/components/navigation/LinkedServersNav"; import { ToolSidePanel } from "@/components/navigation/ToolSidePanel"; import { useDialogParam } from "@/hooks/useDialogParam"; import { useMobile } from "@/hooks/useMobile"; -import { useOpenCodeServerStatuses } from "@/hooks/useOpenCodeServers"; -import { useSettingsDialog } from "@/hooks/useSettingsDialog"; import { useSidebarServerSelection } from "@/hooks/useSidebarServerSelection"; import { useToolPanel } from "@/hooks/useToolPanel"; -function LinkedServerHeaderActions({ serverId }: { serverId: string }) { - const { statusById, isLoading } = useOpenCodeServerStatuses(); - const { openTab } = useSettingsDialog(); - const status = statusById[serverId]; - - return ( - <> - - - - - - ); -} - export function Repos() { const navigate = useNavigate(); const [addRepoOpen, setAddRepoOpen] = useState(false); @@ -71,7 +51,7 @@ export function Repos() { ) : ( - + )}