From 963e200ef8700cea0bf2434ada24d878f68227e1 Mon Sep 17 00:00:00 2001 From: MoerAI Date: Fri, 14 Aug 2026 14:30:53 +0900 Subject: [PATCH 1/2] test(opencode): cover snapshot exclude write failure --- .../opencode/test/snapshot/snapshot.test.ts | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/packages/opencode/test/snapshot/snapshot.test.ts b/packages/opencode/test/snapshot/snapshot.test.ts index a39624087c63..f1cc4714b756 100644 --- a/packages/opencode/test/snapshot/snapshot.test.ts +++ b/packages/opencode/test/snapshot/snapshot.test.ts @@ -3,6 +3,8 @@ import { $ } from "bun" import { CrossSpawnSpawner } from "@opencode-ai/core/cross-spawn-spawner" import { LayerNode } from "@opencode-ai/core/effect/layer-node" import { FSUtil } from "@opencode-ai/core/fs-util" +import { Global } from "@opencode-ai/core/global" +import { Hash } from "@opencode-ai/core/util/hash" import fs from "fs/promises" import path from "path" import { Effect, Fiber, Layer } from "effect" @@ -10,6 +12,7 @@ import { Snapshot } from "../../src/snapshot" import { disposeAllInstances, provideInstance, + requireInstance, testInstanceStoreLayer, TestInstance, tmpdirScoped, @@ -647,6 +650,26 @@ it.instance( { git: true }, ) +it.instance( + "git info exclude write failure keeps tracking alive", + Effect.gen(function* () { + const tmp = yield* bootstrap() + const snapshot = yield* Snapshot.Service + const before = yield* snapshot.track() + expect(before).toBeTruthy() + // Make the snapshot exclude write fail: a directory can never be overwritten by a file. + const ctx = yield* requireInstance + const gitdir = path.join(Global.Path.data, "snapshot", ctx.project.id, Hash.fast(ctx.worktree)) + yield* rm(path.join(gitdir, "info", "exclude")) + yield* mkdirp(path.join(gitdir, "info", "exclude")) + yield* write(`${tmp.path}/after.txt`, "after content") + const after = yield* snapshot.track() + expect(after).toBeTruthy() + }), + { git: true }, + { timeout: 60000 }, +) + it.instance( "concurrent file operations during patch", withTrackedSnapshot(({ tmp, snapshot, before }) => From aca6d95d4e1b8de32870c9e8479c9ba0d90fc4d9 Mon Sep 17 00:00:00 2001 From: MoerAI Date: Fri, 14 Aug 2026 14:30:55 +0900 Subject: [PATCH 2/2] fix(opencode): handle snapshot exclude write failure gracefully --- packages/opencode/src/snapshot/index.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/opencode/src/snapshot/index.ts b/packages/opencode/src/snapshot/index.ts index 4da9bc3ca864..60d399ba41ff 100644 --- a/packages/opencode/src/snapshot/index.ts +++ b/packages/opencode/src/snapshot/index.ts @@ -188,8 +188,11 @@ const layer: Layer.Layer Effect.logWarning("failed to write snapshot exclude", { target, error }))) }) // Reuse the hashes for the git storage between the original repo and snapshot