From d3ef7bbe666fbbfb92ca7c8f04ed91893a477fd2 Mon Sep 17 00:00:00 2001 From: LukeParkerDev <10430890+Hona@users.noreply.github.com> Date: Thu, 2 Jul 2026 15:03:40 +1000 Subject: [PATCH] test(opencode): cover Windows session list directory spellings --- .../test/server/httpapi-session.test.ts | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/packages/opencode/test/server/httpapi-session.test.ts b/packages/opencode/test/server/httpapi-session.test.ts index 37f6af62086c..9d7643cb3309 100644 --- a/packages/opencode/test/server/httpapi-session.test.ts +++ b/packages/opencode/test/server/httpapi-session.test.ts @@ -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(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(`${SessionPaths.list}?${query}`, { headers }) + expect({ spelling, ids: listed.map((item) => item.id) }).toEqual({ spelling, ids: [created.id] }) + } + }), + { 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(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(`${SessionPaths.list}?${query}`, { headers }) + expect(listed.map((item) => item.id)).toContain(driveRootSession.id) + }), + { git: true, config: { formatter: false, lsp: false, share: "disabled" } }, + { timeout: 15000 }, + ) + it.instance( "serves paginated message link headers", () =>