feat(core): allow external workspace creation (#26212)

This commit is contained in:
James Long
2026-05-08 11:09:12 -04:00
committed by GitHub
parent c36ab3f935
commit c818c9dcb6
21 changed files with 2039 additions and 145 deletions

View File

@@ -64,6 +64,36 @@ function localAdapter(directory: string): WorkspaceAdapter {
}
}
function listedAdapter(directory: string, type: string): WorkspaceAdapter {
return {
name: "Listed Test",
description: "List a local test workspace",
configure(info) {
return { ...info, name: "unused", directory }
},
async create() {},
async remove() {},
list() {
return [
{
type,
name: "listed-test",
branch: "listed/main",
directory,
extra: { listed: true },
projectID: Instance.project.id,
},
]
},
target() {
return {
type: "local" as const,
directory,
}
},
}
}
function remoteAdapter(directory: string, url: string, headers?: HeadersInit): WorkspaceAdapter {
return {
name: "Remote Test",
@@ -196,6 +226,30 @@ describe("workspace HttpApi", () => {
}),
)
it.live("serves list sync endpoint", () =>
Effect.gen(function* () {
Flag.OPENCODE_EXPERIMENTAL_WORKSPACES = true
const dir = yield* tmpdirScoped({ git: true })
const project = yield* Project.use.fromDirectory(dir)
const type = `listed-${Math.random().toString(36).slice(2)}`
registerAdapter(project.project.id, type, listedAdapter(path.join(dir, ".listed"), type))
const response = yield* request(WorkspacePaths.syncList, dir, { method: "POST" })
expect(response.status).toBe(204)
const listed = yield* request(WorkspacePaths.list, dir)
expect(yield* Effect.promise(() => listed.json())).toMatchObject([
{
type,
name: "listed-test",
branch: "listed/main",
directory: path.join(dir, ".listed"),
extra: { listed: true },
},
])
}),
)
it.live("creates workspace with the TUI payload shape", () =>
Effect.gen(function* () {
Flag.OPENCODE_EXPERIMENTAL_WORKSPACES = true