summaryrefslogtreecommitdiffhomepage
path: root/packages/app/src/context/global-sync/utils.test.ts
diff options
context:
space:
mode:
authorLuke Parker <[email protected]>2026-04-30 08:39:19 +1000
committerGitHub <[email protected]>2026-04-29 22:39:19 +0000
commitd7b7be1909d614a4022b345bdbeef0c1ec32e159 (patch)
treeb25640c571a0333b62cf7f06a0ee7ea24b8d3c68 /packages/app/src/context/global-sync/utils.test.ts
parenta740d2c66782ef3371146cd55d70920ae9b94daf (diff)
downloadopencode-d7b7be1909d614a4022b345bdbeef0c1ec32e159.tar.gz
opencode-d7b7be1909d614a4022b345bdbeef0c1ec32e159.zip
fix(desktop): Path mismatches cause sessions missing + strong ID + existing data fix (#25013)
Diffstat (limited to 'packages/app/src/context/global-sync/utils.test.ts')
-rw-r--r--packages/app/src/context/global-sync/utils.test.ts19
1 files changed, 18 insertions, 1 deletions
diff --git a/packages/app/src/context/global-sync/utils.test.ts b/packages/app/src/context/global-sync/utils.test.ts
index 6d44ac9a8..406c0f124 100644
--- a/packages/app/src/context/global-sync/utils.test.ts
+++ b/packages/app/src/context/global-sync/utils.test.ts
@@ -1,6 +1,6 @@
import { describe, expect, test } from "bun:test"
import type { Agent } from "@opencode-ai/sdk/v2/client"
-import { normalizeAgentList } from "./utils"
+import { directoryKey, normalizeAgentList } from "./utils"
const agent = (name = "build") =>
({
@@ -33,3 +33,20 @@ describe("normalizeAgentList", () => {
expect(normalizeAgentList([{ name: "build" }, agent("docs")])).toEqual([agent("docs")])
})
})
+
+describe("directoryKey", () => {
+ test("normalizes slashes", () => {
+ expect(String(directoryKey("C:\\Repos\\sst\\opencode"))).toBe("C:/Repos/sst/opencode")
+ expect(String(directoryKey("C:/Repos/sst/opencode"))).toBe("C:/Repos/sst/opencode")
+ })
+
+ test("preserves backslashes in posix paths", () => {
+ expect(String(directoryKey("/tmp/foo\\bar"))).toBe("/tmp/foo\\bar")
+ })
+
+ test("trims trailing slashes without breaking roots", () => {
+ expect(String(directoryKey("C:/Repos/sst/opencode/"))).toBe("C:/Repos/sst/opencode")
+ expect(String(directoryKey("C:/"))).toBe("C:/")
+ expect(String(directoryKey("/"))).toBe("/")
+ })
+})