MCPcopy
hub / github.com/anomalyco/opencode / nextServerAfterRemoval

Function nextServerAfterRemoval

packages/app/src/context/server.tsx:211–219  ·  view source on GitHub ↗
(
  servers: ServerConnection.Any[],
  removed: ServerConnection.Key,
  fallback: ServerConnection.Key,
)

Source from the content-addressed store, hash-verified

209}
210
211export function nextServerAfterRemoval(
212 servers: ServerConnection.Any[],
213 removed: ServerConnection.Key,
214 fallback: ServerConnection.Key,
215) {
216 const remaining = servers.filter((server) => ServerConnection.key(server) !== removed)
217 const next = remaining.find((server) => ServerConnection.key(server) === fallback) ?? remaining[0]
218 return next ? ServerConnection.key(next) : fallback
219}
220
221export const { use: useServer, provider: ServerProvider } = createSimpleContext({
222 name: "Server",

Callers 2

server.test.tsFile · 0.90
removeFunction · 0.85

Calls 2

findMethod · 0.65
keyMethod · 0.45

Tested by

no test coverage detected