Skip to content

Commit 58ce61e

Browse files
saravmajesticclaude
andcommitted
fix(workspace): a purged snapshot is not "recently synced"
`deactivate` removed the tree but left the stamps that say this project synced a moment ago. Where the purge is followed by a successful sync that is harmless — the stamps are rewritten. Where it is not, which is exactly the account switch this change introduces, the next run skipped for a whole poll interval with nothing on disk. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
1 parent 1a1ffb0 commit 58ce61e

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

‎packages/opencode/src/altimate/workspace/skill-sync.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -863,6 +863,13 @@ async function deactivate(directory: string, why: string): Promise<boolean> {
863863
if (!(await ownsManagedDir(directory))) return false
864864
await removeManaged(directory)
865865
await sweepStaging(directory)
866+
// The tree is gone, so the stamps that say "recently synced" no longer
867+
// describe anything. Left behind, a purge that is not followed by a
868+
// successful sync — an account switch to a project this user has not bound —
869+
// made the next run skip for a whole poll interval with nothing on disk.
870+
const canon = path.resolve(directory)
871+
lastSyncedAt.delete(canon)
872+
syncedFor.delete(canon)
866873
log.info("removed the workspace skill snapshot", { why, path: root })
867874
return true
868875
}

‎packages/opencode/test/altimate/workspace/skill-sync.test.ts‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1872,6 +1872,19 @@ describe("workspace skill sync", () => {
18721872
expect(existsSync(skillFile("pub-1", "SKILL.md"))).toBe(true)
18731873
})
18741874

1875+
test("a purge re-syncs immediately instead of waiting out the poll interval", async () => {
1876+
// Raised in review. `deactivate` removed the tree but left the "recently
1877+
// synced" stamps, so a purge that is not followed by a successful sync made
1878+
// the next run skip with nothing on disk until the interval expired.
1879+
serve({ "pub-1": { "SKILL.md": "one" } })
1880+
await syncSkills(project)
1881+
expect(await recentlySynced(project)).toBe(true)
1882+
1883+
await purgeManagedSnapshot(project, "the test switched accounts")
1884+
1885+
expect(await recentlySynced(project)).toBe(false)
1886+
})
1887+
18751888
test("a directory holding a manifest we cannot read is not ours", async () => {
18761889
// Ownership was decided on the FILENAME `.manifest.json`. A directory with
18771890
// an unrelated or corrupt file of that name is someone else's, and was

0 commit comments

Comments
 (0)