From 2b2b69d668ed05836ea6d3fa7f42d416bdb61806 Mon Sep 17 00:00:00 2001 From: Brendan Allan <14191578+Brendonovich@users.noreply.github.com> Date: Sat, 25 Jul 2026 15:01:18 +0800 Subject: [PATCH] fix(app): refresh V1 MCP state (#38816) --- .../src/context/global-sync/bootstrap.test.ts | 16 +++++++++++++--- .../app/src/context/global-sync/bootstrap.ts | 11 +++++++++-- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/packages/app/src/context/global-sync/bootstrap.test.ts b/packages/app/src/context/global-sync/bootstrap.test.ts index de2baa704c0..58cc65a2e0b 100644 --- a/packages/app/src/context/global-sync/bootstrap.test.ts +++ b/packages/app/src/context/global-sync/bootstrap.test.ts @@ -73,14 +73,14 @@ function directoryState() { } describe("bootstrapDirectory", () => { - test("marks a loading directory partial during bootstrap and complete after success", async () => { + test("uses legacy MCP endpoints while refreshing a v1 directory", async () => { const mcpReads: string[] = [] const [store, setStore] = directoryState() await bootstrapDirectory({ directory: "/project", scope: ServerScope.local, - mcp: false, + mcp: true, global: { config: {} satisfies Config, path: { state: "", config: "", worktree: "/project", directory: "/project", home: "/home" }, @@ -90,6 +90,7 @@ describe("bootstrapDirectory", () => { sdk: { app: { agents: async () => ({ data: [{ name: "build", mode: "primary" }] }) }, config: { get: async () => ({ data: {} }) }, + session: { status: async () => ({ data: {} }) }, vcs: { get: async () => ({ data: undefined }) }, command: { list: async () => { @@ -106,6 +107,14 @@ describe("bootstrapDirectory", () => { return { data: {} } }, }, + experimental: { + resource: { + list: async () => { + mcpReads.push("resource") + return { data: {} } + }, + }, + }, provider: { list: async () => ({ data: { all: [], connected: [], default: {} } }) }, } as unknown as OpencodeClient, api, @@ -115,6 +124,7 @@ describe("bootstrapDirectory", () => { loadSessions() {}, translate: (key) => key, queryClient: new QueryClient(), + protocol: Promise.resolve("v1"), }) expect(store.status).toBe("partial") @@ -122,7 +132,7 @@ describe("bootstrapDirectory", () => { await new Promise((resolve) => setTimeout(resolve, 80)) expect(store.status).toBe("complete") - expect(mcpReads).toEqual([]) + expect(mcpReads.sort()).toEqual(["command", "resource", "status"]) }) }) diff --git a/packages/app/src/context/global-sync/bootstrap.ts b/packages/app/src/context/global-sync/bootstrap.ts index 4f7b949e61a..cf030c8af09 100644 --- a/packages/app/src/context/global-sync/bootstrap.ts +++ b/packages/app/src/context/global-sync/bootstrap.ts @@ -503,9 +503,16 @@ export async function bootstrapDirectory(input: { }), ), () => Promise.resolve(input.loadSessions(input.directory)), - input.mcp && (() => input.queryClient.fetchQuery(loadMcpQuery(input.scope, input.directory, input.api.mcp))), input.mcp && - (() => input.queryClient.fetchQuery(loadMcpResourcesQuery(input.scope, input.directory, input.api.mcp))), + (() => + input.queryClient.fetchQuery( + loadMcpQuery(input.scope, input.directory, input.api.mcp, input.sdk, input.protocol), + )), + input.mcp && + (() => + input.queryClient.fetchQuery( + loadMcpResourcesQuery(input.scope, input.directory, input.api.mcp, input.sdk, input.protocol), + )), () => input.queryClient .fetchQuery(loadProvidersQuery(input.scope, input.directory, input.api, input.sdk, input.protocol))