Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix e2e
  • Loading branch information
Brendonovich committed Jul 24, 2026
commit e6cab020f0e115efe13d188b1ceaf1e28133bab6
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ async function mockServers(page: Page, requests: string[]) {
const directory = url.searchParams.get("directory")
if (directory && directory !== current.directory) return json(route, { name: "InvalidDirectory" }, 500)
if (url.pathname === "/global/event" || url.pathname === "/event" || url.pathname === "/api/event") return sse(route)
if (url.pathname === "/global/health") return json(route, { healthy: true })
if (url.pathname === "/global/health") return json(route, {}, 404)
if (url.pathname === "/api/health") return json(route, { pid: 1 })
if (url.pathname === "/api/session") return json(route, { data: [currentSession(current)], cursor: {} })
if (url.pathname === "/api/session/active") return json(route, { data: {} })
if (url.pathname === `/api/session/${current.id}`) return json(route, { data: currentSession(current) })
Expand Down
3 changes: 2 additions & 1 deletion packages/app/e2e/regression/remote-tab-busy.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ async function mockServers(page: Page) {
if (directory && directory !== current.directory) return json(route, { name: "InvalidDirectory" }, 500)
if (url.pathname === "/global/event" || url.pathname === "/event" || url.pathname === "/api/event")
return sse(route, url.pathname === "/api/event")
if (url.pathname === "/global/health") return json(route, { healthy: true })
if (url.pathname === "/global/health") return json(route, {}, 404)
if (url.pathname === "/api/health") return json(route, { pid: 1 })
if (url.pathname === "/api/session/active")
return json(route, { data: url.origin === serverB ? { [sessionB.id]: { type: "running" } } : {} })
if (url.pathname === "/api/session") return json(route, { data: [currentSession(current)], cursor: {} })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ async function mockServer(
},
) {
await mockOpenCodeServer(page, {
protocol: "v2",
directory,
project: {
id: projectID,
Expand Down
7 changes: 6 additions & 1 deletion packages/app/src/context/permission.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,12 @@ function createServerPermissionState(input: { sdk: ServerSDK; sync: ServerSync }
const respond: PermissionRespondFn = (request) => {
if (meta.disposed) return
input.sdk.api.permission
.reply({ sessionID: request.sessionID, requestID: request.permissionID, reply: request.response })
.reply({
sessionID: request.sessionID,
requestID: request.permissionID,
reply: request.response,
location: request.directory ? { directory: request.directory } : undefined,
})
.catch(() => {
responded.delete(request.permissionID)
})
Expand Down
23 changes: 23 additions & 0 deletions packages/app/src/utils/server-compat.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,27 @@ describe("createCompatibleApi", () => {
data: { branch: "feature", defaultBranch: "dev" },
})
})

test("translates current file searches to the V1 dirs parameter", async () => {
const { api, requests } = setup("v1")
await api.file.find({ location: { directory: "/repo" }, query: "src", type: "file", limit: 20 })

const url = new URL(requests[0]!.url)
expect(url.pathname).toBe("/find/file")
expect(url.searchParams.get("dirs")).toBe("false")
expect(url.searchParams.get("limit")).toBe("20")
})

test("routes V1 permission replies through the requested directory", async () => {
const { api, requests } = setup("v1")
await api.permission.reply({
sessionID: "ses_1",
requestID: "permission_1",
reply: "once",
location: { directory: "/other" },
})

expect(new URL(requests[0]!.url).pathname).toBe("/session/ses_1/permissions/permission_1")
expect(new URL(requests[0]!.url).searchParams.get("directory")).toBe("/other")
})
})
19 changes: 15 additions & 4 deletions packages/app/src/utils/server-compat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,15 @@ type CompatibleSessionApi = Omit<
archive: (input: Parameters<SessionApi["archive"]>[0] & LegacyLocation) => ReturnType<SessionApi["archive"]>
remove: (input: Parameters<SessionApi["remove"]>[0] & LegacyLocation) => ReturnType<SessionApi["remove"]>
}
export type CompatibleApi = Omit<ServerApi, "session"> & { readonly session: CompatibleSessionApi }
type CompatiblePermissionApi = Omit<ServerApi["permission"], "reply"> & {
reply: (
input: Parameters<ServerApi["permission"]["reply"]>[0] & { location?: { directory?: string } },
) => ReturnType<ServerApi["permission"]["reply"]>
}
export type CompatibleApi = Omit<ServerApi, "session" | "permission"> & {
readonly session: CompatibleSessionApi
readonly permission: CompatiblePermissionApi
}
type LegacyPrompt = {
agent?: string
model?: { providerID: string; modelID: string }
Expand Down Expand Up @@ -350,7 +358,7 @@ function createV1Api(input: CompatibleInput): CompatibleApi {
async find(value: Parameters<ServerApi["file"]["find"]>[0]) {
const result = await legacy(value.location).find.files({
query: value.query,
type: value.type,
dirs: value.type === undefined ? undefined : value.type === "directory" ? "true" : "false",
limit: value.limit,
})
return located(
Expand Down Expand Up @@ -471,11 +479,14 @@ function createV1Api(input: CompatibleInput): CompatibleApi {
},
permission: {
...input.current.permission,
async reply(value: Parameters<ServerApi["permission"]["reply"]>[0]) {
await legacy().permission.respond({
async reply(
value: Parameters<ServerApi["permission"]["reply"]>[0] & { location?: { directory?: string } },
) {
await legacy(value.location).permission.respond({
sessionID: value.sessionID,
permissionID: value.requestID,
response: value.reply,
directory: directory(value.location),
})
},
},
Expand Down