summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorDax Raad <[email protected]>2025-12-09 15:36:57 -0500
committerDax Raad <[email protected]>2025-12-09 15:41:38 -0500
commitc5e5627cbd22f8b46d6422f3caeb0cbf143e076e (patch)
tree9f8d9d7949eac34a0668b03f7b6c4bfafb87cf4d
parent93378526b9b533ba883b000955243c7eab1f7d89 (diff)
downloadopencode-c5e5627cbd22f8b46d6422f3caeb0cbf143e076e.tar.gz
opencode-c5e5627cbd22f8b46d6422f3caeb0cbf143e076e.zip
test fixes
-rw-r--r--packages/opencode/src/project/project.ts12
-rw-r--r--packages/opencode/test/project/project.test.ts12
-rw-r--r--packages/opencode/test/snapshot/snapshot.test.ts2
3 files changed, 17 insertions, 9 deletions
diff --git a/packages/opencode/src/project/project.ts b/packages/opencode/src/project/project.ts
index 70e8e542b..4e71032aa 100644
--- a/packages/opencode/src/project/project.ts
+++ b/packages/opencode/src/project/project.ts
@@ -70,6 +70,12 @@ export namespace Project {
id = roots[0]
if (id) Bun.file(path.join(git, "opencode")).write(id)
}
+ if (!id)
+ return {
+ id: "global",
+ worktree,
+ vcs: "git",
+ }
worktree = await $`git rev-parse --show-toplevel`
.quiet()
.nothrow()
@@ -101,7 +107,7 @@ export namespace Project {
await migrateFromGlobal(id, worktree)
}
}
- if (!existing.icon) discover(existing)
+ discover(existing)
await Storage.write<Info>(["project", id], {
...existing,
worktree,
@@ -120,7 +126,9 @@ export namespace Project {
return existing
}
- export async function discover(input: Pick<Info, "id" | "worktree">) {
+ export async function discover(input: Info) {
+ if (input.vcs !== "git") return
+ if (input.icon) return
const glob = new Bun.Glob("**/{favicon,icon,logo}.{ico,png,svg,jpg,jpeg,webp}")
for await (const match of glob.scan({
cwd: input.worktree,
diff --git a/packages/opencode/test/project/project.test.ts b/packages/opencode/test/project/project.test.ts
index c3474ca57..33296981d 100644
--- a/packages/opencode/test/project/project.test.ts
+++ b/packages/opencode/test/project/project.test.ts
@@ -49,13 +49,13 @@ describe("Project.discover", () => {
const pngData = Buffer.from([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a])
await Bun.write(path.join(tmp.path, "favicon.png"), pngData)
- await Project.discover({ id: project.id, worktree: tmp.path })
+ await Project.discover(project)
const updated = await Storage.read<Project.Info>(["project", project.id])
expect(updated.icon).toBeDefined()
expect(updated.icon?.url).toStartWith("data:")
expect(updated.icon?.url).toContain("base64")
- expect(updated.icon?.color).toBe("#000000")
+ expect(updated.icon?.color).toBeUndefined()
})
test("should discover icon.svg in subdirectory", async () => {
@@ -65,7 +65,7 @@ describe("Project.discover", () => {
await $`mkdir -p ${path.join(tmp.path, "public")}`.quiet()
await Bun.write(path.join(tmp.path, "public", "icon.svg"), "<svg></svg>")
- await Project.discover({ id: project.id, worktree: tmp.path })
+ await Project.discover(project)
const updated = await Storage.read<Project.Info>(["project", project.id])
expect(updated.icon).toBeDefined()
@@ -80,7 +80,7 @@ describe("Project.discover", () => {
const icoData = Buffer.from([0x00, 0x00, 0x01, 0x00])
await Bun.write(path.join(tmp.path, "logo.ico"), icoData)
- await Project.discover({ id: project.id, worktree: tmp.path })
+ await Project.discover(project)
const updated = await Storage.read<Project.Info>(["project", project.id])
expect(updated.icon).toBeDefined()
@@ -93,7 +93,7 @@ describe("Project.discover", () => {
await Bun.write(path.join(tmp.path, "favicon.txt"), "not an image")
- await Project.discover({ id: project.id, worktree: tmp.path })
+ await Project.discover(project)
const updated = await Storage.read<Project.Info>(["project", project.id])
expect(updated.icon).toBeUndefined()
@@ -110,7 +110,7 @@ describe("Project.discover", () => {
const pngData = Buffer.from([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a])
await Bun.write(path.join(tmp.path, "favicon.png"), pngData)
- await Project.discover({ id: project.id, worktree: tmp.path })
+ await Project.discover(project)
const updated = await Storage.read<Project.Info>(["project", project.id])
expect(updated.icon?.color).toBe("#ff0000")
diff --git a/packages/opencode/test/snapshot/snapshot.test.ts b/packages/opencode/test/snapshot/snapshot.test.ts
index cf933f812..11eeaab72 100644
--- a/packages/opencode/test/snapshot/snapshot.test.ts
+++ b/packages/opencode/test/snapshot/snapshot.test.ts
@@ -469,7 +469,7 @@ test("snapshot state isolation between projects", async () => {
})
})
-test("patch detects changes in secondary worktree", async () => {
+test.only("patch detects changes in secondary worktree", async () => {
await using tmp = await bootstrap()
const worktreePath = `${tmp.path}-worktree`
await $`git worktree add ${worktreePath} HEAD`.cwd(tmp.path).quiet()