From 7a54eda8db6bca8df341e579778f4a33226ef63f Mon Sep 17 00:00:00 2001 From: "opencode-assistant[bot]" Date: Thu, 12 Mar 2026 00:35:21 +0800 Subject: [PATCH 1/2] fix: normalize directory paths for session list queries on Windows --- packages/opencode/src/session/index.ts | 27 +++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/packages/opencode/src/session/index.ts b/packages/opencode/src/session/index.ts index 5cc4d7da8d3..d088cb25aca 100644 --- a/packages/opencode/src/session/index.ts +++ b/packages/opencode/src/session/index.ts @@ -36,6 +36,21 @@ export namespace Session { const parentTitlePrefix = "New session - " const childTitlePrefix = "Child session - " + /** + * Normalize directory path for consistent comparison across platforms. + * On Windows, paths can have different representations (e.g., B: vs b:, / vs \). + * This function ensures consistent path comparison for session listing. + */ + function normalizeDirectory(dir: string): string { + // Normalize backslashes to forward slashes + let normalized = dir.replaceAll("\\", "/") + // Normalize drive letter to uppercase for case-insensitive comparison on Windows + if (process.platform === "win32") { + normalized = normalized.replace(/^([a-z]):/, (_, drive) => drive.toUpperCase() + ":") + } + return normalized + } + function createDefaultTitle(isChild = false) { return (isChild ? childTitlePrefix : parentTitlePrefix) + new Date().toISOString() } @@ -89,7 +104,7 @@ export namespace Session { workspace_id: info.workspaceID, parent_id: info.parentID, slug: info.slug, - directory: info.directory, + directory: normalizeDirectory(info.directory), title: info.title, version: info.version, share_url: info.share?.url, @@ -549,7 +564,10 @@ export namespace Session { conditions.push(eq(SessionTable.workspace_id, WorkspaceContext.workspaceID)) } if (input?.directory) { - conditions.push(eq(SessionTable.directory, input.directory)) + // Normalize the directory path to handle Windows path variations + // (e.g., B: vs b:, / vs \) + const normalizedDir = normalizeDirectory(input.directory) + conditions.push(eq(SessionTable.directory, normalizedDir)) } if (input?.roots) { conditions.push(isNull(SessionTable.parent_id)) @@ -589,7 +607,10 @@ export namespace Session { const conditions: SQL[] = [] if (input?.directory) { - conditions.push(eq(SessionTable.directory, input.directory)) + // Normalize the directory path to handle Windows path variations + // (e.g., B: vs b:, / vs \) + const normalizedDir = normalizeDirectory(input.directory) + conditions.push(eq(SessionTable.directory, normalizedDir)) } if (input?.roots) { conditions.push(isNull(SessionTable.parent_id)) From 51c98b30e94e14d9f1c52b53fcf405501695204a Mon Sep 17 00:00:00 2001 From: "opencode-assistant[bot]" Date: Fri, 13 Mar 2026 23:53:17 +0800 Subject: [PATCH 2/2] test: normalize directory path in workspace session test --- packages/app/e2e/projects/workspace-new-session.spec.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/app/e2e/projects/workspace-new-session.spec.ts b/packages/app/e2e/projects/workspace-new-session.spec.ts index 18fa46d3299..643aa1212d7 100644 --- a/packages/app/e2e/projects/workspace-new-session.spec.ts +++ b/packages/app/e2e/projects/workspace-new-session.spec.ts @@ -70,7 +70,11 @@ async function createSessionFromWorkspace(page: Page, slug: string, text: string } async function sessionDirectory(directory: string, sessionID: string) { - const info = await createSdk(directory) + // Normalize directory path for consistent comparison on Windows + // (convert backslashes to forward slashes and uppercase drive letter) + const normalizedDir = directory.replace(/\\/g, "/").replace(/^([a-z]):/, (_, drive) => drive.toUpperCase() + ":") + + const info = await createSdk(normalizedDir) .session.get({ sessionID }) .then((x) => x.data) .catch(() => undefined)