GeezerVison is showing github.com — fix e2e · anomalyco/opencode@7e52ae7
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: packages/app/e2e/regression/cross-server-tab-close.spec.ts +2-1Lines changed: 2 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -86,7 +86,8 @@ async function mockServers(page: Page, requests: string[]) { | 86 | 86 | const directory = url.searchParams.get("directory") | 87 | 87 | if (directory && directory !== current.directory) return json(route, { name: "InvalidDirectory" }, 500) | 88 | 88 | if (url.pathname === "/global/event" || url.pathname === "/event" || url.pathname === "/api/event") return sse(route) | 89 | | - if (url.pathname === "/global/health") return json(route, { healthy: true }) | | 89 | + if (url.pathname === "/global/health") return json(route, {}, 404) | | 90 | + if (url.pathname === "/api/health") return json(route, { pid: 1 }) | 90 | 91 | if (url.pathname === "/api/session") return json(route, { data: [currentSession(current)], cursor: {} }) | 91 | 92 | if (url.pathname === "/api/session/active") return json(route, { data: {} }) | 92 | 93 | if (url.pathname === `/api/session/${current.id}`) return json(route, { data: currentSession(current) }) | |
Collapse file Copy file name to clipboardExpand all lines: packages/app/e2e/regression/remote-tab-busy.spec.ts +2-1Lines changed: 2 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -60,7 +60,8 @@ async function mockServers(page: Page) { | 60 | 60 | if (directory && directory !== current.directory) return json(route, { name: "InvalidDirectory" }, 500) | 61 | 61 | if (url.pathname === "/global/event" || url.pathname === "/event" || url.pathname === "/api/event") | 62 | 62 | return sse(route, url.pathname === "/api/event") | 63 | | - if (url.pathname === "/global/health") return json(route, { healthy: true }) | | 63 | + if (url.pathname === "/global/health") return json(route, {}, 404) | | 64 | + if (url.pathname === "/api/health") return json(route, { pid: 1 }) | 64 | 65 | if (url.pathname === "/api/session/active") | 65 | 66 | return json(route, { data: url.origin === serverB ? { [sessionB.id]: { type: "running" } } : {} }) | 66 | 67 | if (url.pathname === "/api/session") return json(route, { data: [currentSession(current)], cursor: {} }) | |
Collapse file Copy file name to clipboardExpand all lines: packages/app/e2e/regression/session-request-docks.spec.ts +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -173,6 +173,7 @@ async function mockServer( | 173 | 173 | }, | 174 | 174 | ) { | 175 | 175 | await mockOpenCodeServer(page, { | | 176 | + protocol: "v2", | 176 | 177 | directory, | 177 | 178 | project: { | 178 | 179 | id: projectID, | |
Collapse file Copy file name to clipboardExpand all lines: packages/app/src/context/permission.tsx +6-1Lines changed: 6 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -245,7 +245,12 @@ function createServerPermissionState(input: { sdk: ServerSDK; sync: ServerSync } | 245 | 245 | const respond: PermissionRespondFn = (request) => { | 246 | 246 | if (meta.disposed) return | 247 | 247 | input.sdk.api.permission | 248 | | - .reply({ sessionID: request.sessionID, requestID: request.permissionID, reply: request.response }) | | 248 | + .reply({ | | 249 | + sessionID: request.sessionID, | | 250 | + requestID: request.permissionID, | | 251 | + reply: request.response, | | 252 | + location: request.directory ? { directory: request.directory } : undefined, | | 253 | + }) | 249 | 254 | .catch(() => { | 250 | 255 | responded.delete(request.permissionID) | 251 | 256 | }) | |
Collapse file Copy file name to clipboardExpand all lines: packages/app/src/utils/server-compat.test.ts +23Lines changed: 23 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -123,4 +123,27 @@ describe("createCompatibleApi", () => { | 123 | 123 | data: { branch: "feature", defaultBranch: "dev" }, | 124 | 124 | }) | 125 | 125 | }) | | 126 | + | | 127 | + test("translates current file searches to the V1 dirs parameter", async () => { | | 128 | + const { api, requests } = setup("v1") | | 129 | + await api.file.find({ location: { directory: "/repo" }, query: "src", type: "file", limit: 20 }) | | 130 | + | | 131 | + const url = new URL(requests[0]!.url) | | 132 | + expect(url.pathname).toBe("/find/file") | | 133 | + expect(url.searchParams.get("dirs")).toBe("false") | | 134 | + expect(url.searchParams.get("limit")).toBe("20") | | 135 | + }) | | 136 | + | | 137 | + test("routes V1 permission replies through the requested directory", async () => { | | 138 | + const { api, requests } = setup("v1") | | 139 | + await api.permission.reply({ | | 140 | + sessionID: "ses_1", | | 141 | + requestID: "permission_1", | | 142 | + reply: "once", | | 143 | + location: { directory: "/other" }, | | 144 | + }) | | 145 | + | | 146 | + expect(new URL(requests[0]!.url).pathname).toBe("/session/ses_1/permissions/permission_1") | | 147 | + expect(new URL(requests[0]!.url).searchParams.get("directory")).toBe("/other") | | 148 | + }) | 126 | 149 | }) |
Collapse file Copy file name to clipboardExpand all lines: packages/app/src/utils/server-compat.ts +15-4Lines changed: 15 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -30,7 +30,15 @@ type CompatibleSessionApi = Omit< | 30 | 30 | archive: (input: Parameters<SessionApi["archive"]>[0] & LegacyLocation) => ReturnType<SessionApi["archive"]> | 31 | 31 | remove: (input: Parameters<SessionApi["remove"]>[0] & LegacyLocation) => ReturnType<SessionApi["remove"]> | 32 | 32 | } | 33 | | -export type CompatibleApi = Omit<ServerApi, "session"> & { readonly session: CompatibleSessionApi } | | 33 | +type CompatiblePermissionApi = Omit<ServerApi["permission"], "reply"> & { | | 34 | + reply: ( | | 35 | + input: Parameters<ServerApi["permission"]["reply"]>[0] & { location?: { directory?: string } }, | | 36 | + ) => ReturnType<ServerApi["permission"]["reply"]> | | 37 | +} | | 38 | +export type CompatibleApi = Omit<ServerApi, "session" | "permission"> & { | | 39 | + readonly session: CompatibleSessionApi | | 40 | + readonly permission: CompatiblePermissionApi | | 41 | +} | 34 | 42 | type LegacyPrompt = { | 35 | 43 | agent?: string | 36 | 44 | model?: { providerID: string; modelID: string } | @@ -350,7 +358,7 @@ function createV1Api(input: CompatibleInput): CompatibleApi { | 350 | 358 | async find(value: Parameters<ServerApi["file"]["find"]>[0]) { | 351 | 359 | const result = await legacy(value.location).find.files({ | 352 | 360 | query: value.query, | 353 | | - type: value.type, | | 361 | + dirs: value.type === undefined ? undefined : value.type === "directory" ? "true" : "false", | 354 | 362 | limit: value.limit, | 355 | 363 | }) | 356 | 364 | return located( | @@ -471,11 +479,14 @@ function createV1Api(input: CompatibleInput): CompatibleApi { | 471 | 479 | }, | 472 | 480 | permission: { | 473 | 481 | ...input.current.permission, | 474 | | - async reply(value: Parameters<ServerApi["permission"]["reply"]>[0]) { | 475 | | - await legacy().permission.respond({ | | 482 | + async reply( | | 483 | + value: Parameters<ServerApi["permission"]["reply"]>[0] & { location?: { directory?: string } }, | | 484 | + ) { | | 485 | + await legacy(value.location).permission.respond({ | 476 | 486 | sessionID: value.sessionID, | 477 | 487 | permissionID: value.requestID, | 478 | 488 | response: value.reply, | | 489 | + directory: directory(value.location), | 479 | 490 | }) | 480 | 491 | }, | 481 | 492 | }, | |
|