@@ -7,16 +7,17 @@ import { useMutation, useQueryClient } from "@tanstack/solid-query"
77import { showToast } from "@opencode-ai/ui/toast"
88import { useNavigate } from "@solidjs/router"
99import { type Accessor , createEffect , createMemo , For , type JSXElement , onCleanup , Show } from "solid-js"
10- import { createStore , reconcile } from "solid-js/store"
10+ import { createStore } from "solid-js/store"
1111import { ServerHealthIndicator , ServerRow } from "@/components/server/server-row"
1212import { useLanguage } from "@/context/language"
1313import { usePlatform } from "@/context/platform"
1414import { useSDK } from "@/context/sdk"
1515import { normalizeServerUrl , ServerConnection , useServer } from "@/context/server"
1616import { useSync } from "@/context/sync"
17- import { useCheckServerHealth , type ServerHealth } from "@/utils/server-health"
17+ import { type ServerHealth } from "@/utils/server-health"
1818import { useQueryOptions } from "@/context/server-sync"
1919import { pathKey } from "@/utils/path-key"
20+ import { useServers } from "@/context/servers"
2021
2122const pollMs = 10_000
2223
@@ -54,40 +55,6 @@ const listServersByHealth = (
5455 } )
5556}
5657
57- const useServerHealth = ( servers : Accessor < ServerConnection . Any [ ] > , enabled : Accessor < boolean > ) => {
58- const checkServerHealth = useCheckServerHealth ( )
59- const [ status , setStatus ] = createStore ( { } as Record < ServerConnection . Key , ServerHealth | undefined > )
60-
61- createEffect ( ( ) => {
62- if ( ! enabled ( ) ) {
63- setStatus ( reconcile ( { } ) )
64- return
65- }
66- const list = servers ( )
67- let dead = false
68-
69- const refresh = async ( ) => {
70- const results : Record < string , ServerHealth > = { }
71- await Promise . all (
72- list . map ( async ( conn ) => {
73- results [ ServerConnection . key ( conn ) ] = await checkServerHealth ( conn . http )
74- } ) ,
75- )
76- if ( dead ) return
77- setStatus ( reconcile ( results ) )
78- }
79-
80- void refresh ( )
81- const id = setInterval ( ( ) => void refresh ( ) , pollMs )
82- onCleanup ( ( ) => {
83- dead = true
84- clearInterval ( id )
85- } )
86- } )
87-
88- return status
89- }
90-
9158const useDefaultServerKey = (
9259 get : ( ( ) => string | Promise < string | null | undefined > | null | undefined ) | undefined ,
9360) => {
@@ -168,6 +135,7 @@ const useMcpToggleMutation = () => {
168135
169136export function StatusPopoverBody ( props : { shown : Accessor < boolean > } ) {
170137 const sync = useSync ( )
138+ const servers = useServers ( )
171139 const server = useServer ( )
172140 const platform = usePlatform ( )
173141 const dialog = useDialog ( )
@@ -192,15 +160,7 @@ export function StatusPopoverBody(props: { shown: Accessor<boolean> }) {
192160 dialogDead = true
193161 dialogRun += 1
194162 } )
195- const servers = createMemo ( ( ) => {
196- const current = server . current
197- const list = server . list
198- if ( ! current ) return list
199- if ( list . every ( ( item ) => ServerConnection . key ( item ) !== ServerConnection . key ( current ) ) ) return [ current , ...list ]
200- return [ current , ...list . filter ( ( item ) => ServerConnection . key ( item ) !== ServerConnection . key ( current ) ) ]
201- } )
202- const health = useServerHealth ( servers , props . shown )
203- const sortedServers = createMemo ( ( ) => listServersByHealth ( servers ( ) , server . key , health ) )
163+ const sortedServers = createMemo ( ( ) => listServersByHealth ( servers . list ( ) , server . key , servers . health ) )
204164 const toggleMcp = useMcpToggleMutation ( )
205165 const defaultServer = useDefaultServerKey ( platform . getDefaultServer )
206166 const mcpNames = createMemo ( ( ) => Object . keys ( sync . data . mcp ?? { } ) . sort ( ( a , b ) => a . localeCompare ( b ) ) )
@@ -226,7 +186,7 @@ export function StatusPopoverBody(props: { shown: Accessor<boolean> }) {
226186 >
227187 < Tabs . List data-slot = "tablist" class = "bg-transparent border-b-0 px-4 pt-2 pb-0 gap-4 h-10" >
228188 < Tabs . Trigger value = "servers" data-slot = "tab" class = "text-12-regular" >
229- { sortedServers ( ) . length > 0 ? `${ sortedServers ( ) . length } ` : "" }
189+ { servers . list ( ) . length > 0 ? `${ servers . list ( ) . length } ` : "" }
230190 { language . t ( "status.popover.tab.servers" ) }
231191 </ Tabs . Trigger >
232192 < Tabs . Trigger value = "mcp" data-slot = "tab" class = "text-12-regular" >
@@ -249,7 +209,7 @@ export function StatusPopoverBody(props: { shown: Accessor<boolean> }) {
249209 < For each = { sortedServers ( ) } >
250210 { ( s ) => {
251211 const key = ServerConnection . key ( s )
252- const blocked = ( ) => health [ key ] ?. healthy === false
212+ const blocked = ( ) => servers . health [ key ] ?. healthy === false
253213 return (
254214 < button
255215 type = "button"
@@ -265,11 +225,11 @@ export function StatusPopoverBody(props: { shown: Accessor<boolean> }) {
265225 queueMicrotask ( ( ) => server . setActive ( key ) )
266226 } }
267227 >
268- < ServerHealthIndicator health = { health [ key ] } />
228+ < ServerHealthIndicator health = { servers . health [ key ] } />
269229 < ServerRow
270230 conn = { s }
271231 dimmed = { blocked ( ) }
272- status = { health [ key ] }
232+ status = { servers . health [ key ] }
273233 class = "flex items-center gap-2 w-full min-w-0"
274234 nameClass = "text-14-regular text-text-base truncate"
275235 versionClass = "text-12-regular text-text-weak truncate"
0 commit comments