diff --git a/src/agents/workspace-sqlite-safety.test.ts b/src/agents/workspace-sqlite-safety.test.ts index b3fda90b7b36..6536d1a1ab67 100644 --- a/src/agents/workspace-sqlite-safety.test.ts +++ b/src/agents/workspace-sqlite-safety.test.ts @@ -21,6 +21,7 @@ import { import { DEFAULT_AGENTS_FILENAME, DEFAULT_BOOTSTRAP_FILENAME, + DEFAULT_IDENTITY_FILENAME, ensureAgentWorkspace, WORKSPACE_VANISHED_ERROR_CODE, } from "./workspace.js"; @@ -114,6 +115,20 @@ describe("workspace setup-only SQLite safety", () => { }); }); + it("accepts a customized profile with migrated setup-only state", async () => { + const tempDir = await makeTempWorkspace("openclaw-workspace-"); + const identityPath = path.join(tempDir, DEFAULT_IDENTITY_FILENAME); + await fs.writeFile(identityPath, "# Existing identity\n"); + mergeWorkspaceSetupState(tempDir, { + setupCompletedAt: "2026-07-15T10:01:00.000Z", + }); + + await expect( + ensureAgentWorkspace({ dir: tempDir, ensureBootstrapFiles: true }), + ).resolves.toMatchObject({ dir: tempDir }); + await expect(fs.readFile(identityPath, "utf8")).resolves.toBe("# Existing identity\n"); + }); + it("does not mistake an old generated template for setup-only customization", async () => { const tempDir = await makeTempWorkspace("openclaw-workspace-"); await fs.writeFile(path.join(tempDir, DEFAULT_AGENTS_FILENAME), "old generated agents\n"); diff --git a/src/agents/workspace.ts b/src/agents/workspace.ts index 35565d35c185..62a14264bdfd 100644 --- a/src/agents/workspace.ts +++ b/src/agents/workspace.ts @@ -655,7 +655,7 @@ async function workspaceSetupStateHasSurvivalEvidence(params: { if (await pathExists(params.bootstrapPath)) { return true; } - if (await hasWorkspaceUserContentEvidence(params.dir)) { + if (await workspaceProfileLooksConfigured({ dir: params.dir })) { return true; } const currentState = readCanonicalWorkspaceStateSnapshot(params.dir);