Skip to content

Commit 2b2b69d

Browse files
authored
fix(app): refresh V1 MCP state (anomalyco#38816)
1 parent 9e8b217 commit 2b2b69d

2 files changed

Lines changed: 22 additions & 5 deletions

File tree

packages/app/src/context/global-sync/bootstrap.test.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,14 @@ function directoryState() {
7373
}
7474

7575
describe("bootstrapDirectory", () => {
76-
test("marks a loading directory partial during bootstrap and complete after success", async () => {
76+
test("uses legacy MCP endpoints while refreshing a v1 directory", async () => {
7777
const mcpReads: string[] = []
7878
const [store, setStore] = directoryState()
7979

8080
await bootstrapDirectory({
8181
directory: "/project",
8282
scope: ServerScope.local,
83-
mcp: false,
83+
mcp: true,
8484
global: {
8585
config: {} satisfies Config,
8686
path: { state: "", config: "", worktree: "/project", directory: "/project", home: "/home" },
@@ -90,6 +90,7 @@ describe("bootstrapDirectory", () => {
9090
sdk: {
9191
app: { agents: async () => ({ data: [{ name: "build", mode: "primary" }] }) },
9292
config: { get: async () => ({ data: {} }) },
93+
session: { status: async () => ({ data: {} }) },
9394
vcs: { get: async () => ({ data: undefined }) },
9495
command: {
9596
list: async () => {
@@ -106,6 +107,14 @@ describe("bootstrapDirectory", () => {
106107
return { data: {} }
107108
},
108109
},
110+
experimental: {
111+
resource: {
112+
list: async () => {
113+
mcpReads.push("resource")
114+
return { data: {} }
115+
},
116+
},
117+
},
109118
provider: { list: async () => ({ data: { all: [], connected: [], default: {} } }) },
110119
} as unknown as OpencodeClient,
111120
api,
@@ -115,14 +124,15 @@ describe("bootstrapDirectory", () => {
115124
loadSessions() {},
116125
translate: (key) => key,
117126
queryClient: new QueryClient(),
127+
protocol: Promise.resolve("v1"),
118128
})
119129

120130
expect(store.status).toBe("partial")
121131

122132
await new Promise((resolve) => setTimeout(resolve, 80))
123133

124134
expect(store.status).toBe("complete")
125-
expect(mcpReads).toEqual([])
135+
expect(mcpReads.sort()).toEqual(["command", "resource", "status"])
126136
})
127137
})
128138

packages/app/src/context/global-sync/bootstrap.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -503,9 +503,16 @@ export async function bootstrapDirectory(input: {
503503
}),
504504
),
505505
() => Promise.resolve(input.loadSessions(input.directory)),
506-
input.mcp && (() => input.queryClient.fetchQuery(loadMcpQuery(input.scope, input.directory, input.api.mcp))),
507506
input.mcp &&
508-
(() => input.queryClient.fetchQuery(loadMcpResourcesQuery(input.scope, input.directory, input.api.mcp))),
507+
(() =>
508+
input.queryClient.fetchQuery(
509+
loadMcpQuery(input.scope, input.directory, input.api.mcp, input.sdk, input.protocol),
510+
)),
511+
input.mcp &&
512+
(() =>
513+
input.queryClient.fetchQuery(
514+
loadMcpResourcesQuery(input.scope, input.directory, input.api.mcp, input.sdk, input.protocol),
515+
)),
509516
() =>
510517
input.queryClient
511518
.fetchQuery(loadProvidersQuery(input.scope, input.directory, input.api, input.sdk, input.protocol))

0 commit comments

Comments
 (0)