Skip to content
Merged
Changes from all commits
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
48 changes: 48 additions & 0 deletions packages/opencode/test/server/httpapi-session.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -904,6 +904,54 @@ describe("session HttpApi", () => {
{ git: true, config: { formatter: false, lsp: false, share: "disabled" } },
)

it.instance(
"lists Windows sessions for equivalent directory spellings",
() =>
Effect.gen(function* () {
if (process.platform !== "win32") return
const test = yield* TestInstance
const headers = { "x-opencode-directory": test.directory, "content-type": "application/json" }
const created = yield* requestJson<Session.Info>(SessionPaths.create, {
method: "POST",
headers,
body: JSON.stringify({ title: "windows spelling" }),
})

const forwardSlashes = test.directory.replaceAll("\\", "/")
const lowercaseDrive = test.directory.replace(/^[A-Z]:/, (drive) => drive.toLowerCase())
const trailingSeparator = `${test.directory}\\`
for (const spelling of [forwardSlashes, lowercaseDrive, trailingSeparator]) {
const query = new URLSearchParams({ directory: spelling, roots: "true" })
const listed = yield* requestJson<Session.Info[]>(`${SessionPaths.list}?${query}`, { headers })
expect({ spelling, ids: listed.map((item) => item.id) }).toEqual({ spelling, ids: [created.id] })
}
Comment on lines +923 to +927
}),
{ git: true, config: { formatter: false, lsp: false, share: "disabled" } },
{ timeout: 15000 },
)

it.instance(
"lists Windows sessions created through the global worktree sentinel",
() =>
Effect.gen(function* () {
if (process.platform !== "win32") return
const globalWorktreeSentinel = "/"
const headers = { "x-opencode-directory": globalWorktreeSentinel, "content-type": "application/json" }
const driveRootSession = yield* requestJson<Session.Info>(SessionPaths.create, {
method: "POST",
headers,
body: JSON.stringify({ title: "created at drive root" }),
})
expect(driveRootSession.directory).toMatch(/^[A-Za-z]:\\$/)

const query = new URLSearchParams({ directory: globalWorktreeSentinel, roots: "true" })
const listed = yield* requestJson<Session.Info[]>(`${SessionPaths.list}?${query}`, { headers })
expect(listed.map((item) => item.id)).toContain(driveRootSession.id)
Comment on lines +947 to +949
}),
{ git: true, config: { formatter: false, lsp: false, share: "disabled" } },
{ timeout: 15000 },
)

it.instance(
"serves paginated message link headers",
() =>
Expand Down
Loading