Skip to content

fix(workspace): detect user content to prevent re-bootstrapping after config loss#27492

Closed
widingmarcus-cyber wants to merge 1 commit intoopenclaw:mainfrom
widingmarcus-cyber:fix/configure-preserve-workspace
Closed

fix(workspace): detect user content to prevent re-bootstrapping after config loss#27492
widingmarcus-cyber wants to merge 1 commit intoopenclaw:mainfrom
widingmarcus-cyber:fix/configure-preserve-workspace

Conversation

@widingmarcus-cyber
Copy link
Contributor

@widingmarcus-cyber widingmarcus-cyber commented Feb 26, 2026

Summary

Fixes #27314openclaw configure could silently re-bootstrap an existing workspace after config corruption, leading to data loss.

Root Cause

When config is lost/corrupted (e.g., during restart cycles), running openclaw configure creates a fresh config. The workspace seeder's isBrandNewWorkspace check only looked at template files (SOUL.md, IDENTITY.md, etc.). If those were somehow missing, the workspace was treated as brand new, triggering BOOTSTRAP.md seeding even when user data (memory/, MEMORY.md) existed.

Changes

src/agents/workspace.ts

  • isBrandNewWorkspace: Now also checks for memory/ dir and MEMORY.md as user-content indicators. A workspace with user content is never treated as brand new.
  • Legacy migration path: Also checks for user-content indicators when deciding if onboarding was already completed. Prevents BOOTSTRAP.md seeding when template files match defaults but real user data exists.

src/commands/configure.wizard.ts

  • Shows an "Existing workspace" note when user content is detected but config doesn't exist, reassuring users their files will be preserved.

src/agents/workspace.test.ts

  • New test: workspace with memory/ dir and MEMORY.md but no template files is treated as existing, not brand new.

Test Results

All 14 workspace tests pass including the new regression test.

@greptile-apps please review

@openclaw-barnacle openclaw-barnacle bot added commands Command implementations agents Agent runtime and tooling size: M trusted-contributor labels Feb 26, 2026
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 26, 2026

Greptile Summary

Prevents openclaw configure from re-seeding existing workspaces by checking if bootstrap files are already present before running the workspace initialization. The fix introduces a new isWorkspaceBootstrapped() function that checks both workspace-state.json timestamps and physical file existence as fallback for legacy workspaces. The configure wizard now conditionally skips bootstrap when appropriate.

  • Added isWorkspaceBootstrapped() with dual-path detection (state file + file existence fallback)
  • Configure wizard checks bootstrap status before calling ensureWorkspaceAndSessions()
  • isBrandNewWorkspace check now includes workspace-state.json to prevent treating partially-corrupted workspaces as new
  • 7 new tests cover all scenarios: empty dirs, state-based detection, file-based detection, customized file preservation, and wizard integration
  • All existing workspace (43) and configure wizard (4) tests pass

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The implementation correctly addresses the root cause with defensive fallback logic, comprehensive test coverage (7 new tests plus all existing tests passing), clear documentation, and no breaking changes to existing functionality
  • No files require special attention

Last reviewed commit: f9096a0

… config loss (openclaw#27314)

When config is lost/corrupted and 'openclaw configure' re-runs, the workspace
seeder could treat an existing workspace as brand new if template files were
missing, triggering BOOTSTRAP.md creation and potentially confusing the user.

Changes:
- ensureAgentWorkspace: isBrandNewWorkspace now checks for memory/ dir and
  MEMORY.md in addition to template files. A workspace with user content is
  never treated as brand new.
- Legacy migration path: also checks for memory/ and MEMORY.md as indicators
  of completed onboarding, preventing BOOTSTRAP seeding when template files
  match defaults but user data exists.
- Configure wizard: shows 'Existing workspace' note when user content is
  detected but no config exists, reassuring users their files are preserved.
- New test: workspace with memory/ but no template files is treated as
  existing, not brand new.

Closes openclaw#27314
@widingmarcus-cyber widingmarcus-cyber force-pushed the fix/configure-preserve-workspace branch from f9096a0 to 1d1cc23 Compare February 26, 2026 12:02
@widingmarcus-cyber widingmarcus-cyber changed the title fix: prevent configure wizard from re-seeding existing workspace fix(workspace): detect user content to prevent re-bootstrapping after config loss Feb 26, 2026
@widingmarcus-cyber
Copy link
Contributor Author

Closing — upstream has diverged significantly in the affected files (workspace.ts, configure.wizard.ts). Will re-evaluate if the issue resurfaces.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling commands Command implementations size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: openclaw configure to add Telegram channel destroys workspace, sessions, memory, etc.

1 participant