openclaw - ✅(Solved) Fix doctor --fix silently archives orphan transcripts, causing session history loss after upgrade [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#73106Fetched 2026-04-28 06:27:29
View on GitHub
Comments
0
Participants
1
Timeline
1
Reactions
0
Author
Participants
Timeline (top)
cross-referenced ×1

Running openclaw doctor --fix after an upgrade can silently archive (rename to .deleted.*) transcript files that appear as orphans due to sessions.json being regenerated during the upgrade. This causes users to lose recent session history across all channels without any warning or confirmation.

Root Cause

In src/commands/doctor-prompter.ts, the confirmRuntimeRepair handler calls shouldAutoApproveDoctorFix(repairMode, { blockDuringUpdate: true }) and returns true if the --fix flag is active. However, the orphan transcript archival prompt in doctor-state-integrity.ts is called with initialValue: false:

const archiveOrphans = await prompter.confirmRuntimeRepair({
  message: `Archive ${orphanCount} in ${displaySessionsDir}? ...`,
  initialValue: false,  // <-- signals: potentially destructive, do not auto-approve
});

initialValue: false is meant to mark the action as potentially destructive and should suppress auto-approval. But confirmRuntimeRepair ignores this field when --fix is active, causing it to silently return true and archive all orphans.

Fix Action

Fix

Check p.initialValue !== false before auto-approving in confirmRuntimeRepair. Only actions with initialValue: true or undefined (safe/reversible) should be auto-approved by --fix.

PR: https://github.com/openclaw/openclaw/pull/73107

PR fix notes

PR #73107: fix(doctor): do not auto-archive orphan transcripts when --fix is passed

Description (problem / solution / changelog)

Problem

openclaw doctor --fix silently archives orphan transcript files without user confirmation. This causes session history loss after upgrades that regenerate sessions.json, because previously-active transcripts appear as "orphans" that don't match any index entry.

Fixes #73106

Root Cause

In confirmRuntimeRepair, shouldAutoApproveDoctorFix returns true for all --fix runs regardless of initialValue. The orphan transcript archival prompt uses initialValue: false to signal it is potentially destructive and should not be auto-approved — but this was being ignored.

// doctor-state-integrity.ts
const archiveOrphans = await prompter.confirmRuntimeRepair({
  message: `Archive ${orphanCount}...`,
  initialValue: false,  // <-- should suppress --fix auto-approval
});

Fix

Skip auto-approval in confirmRuntimeRepair when p.initialValue === false. Only prompts with initialValue: true or undefined (safe/reversible actions) are auto-approved by --fix.

// doctor-prompter.ts
confirmRuntimeRepair: async (p) => {
  // Only auto-approve when initialValue is not explicitly false.
  // initialValue: false signals a potentially destructive action (e.g. archiving
  // orphan transcripts) that must not be silently applied by --fix.
  if (shouldAutoApproveDoctorFix(repairMode, { blockDuringUpdate: true }) && p.initialValue !== false) {
    return true;
  }
  ...
}

Test

Added a test to doctor-state-integrity.test.ts that verifies orphan transcripts are NOT archived when a --fix-style prompter (which returns false for initialValue: false prompts) is used.

Checklist

  • Fix in src/commands/doctor-prompter.ts
  • Test in src/commands/doctor-state-integrity.test.ts
  • No behavior change for existing auto-approved fixes (those use initialValue: true or omit it)

Changed files

  • src/commands/doctor-prompter.ts (modified, +4/-1)
  • src/commands/doctor-state-integrity.test.ts (modified, +21/-0)

Code Example

const archiveOrphans = await prompter.confirmRuntimeRepair({
  message: `Archive ${orphanCount} in ${displaySessionsDir}? ...`,
  initialValue: false,  // <-- signals: potentially destructive, do not auto-approve
});
RAW_BUFFERClick to expand / collapse

Summary

Running openclaw doctor --fix after an upgrade can silently archive (rename to .deleted.*) transcript files that appear as orphans due to sessions.json being regenerated during the upgrade. This causes users to lose recent session history across all channels without any warning or confirmation.

Steps to Reproduce

  1. Upgrade OpenClaw (e.g. to 2026.4.25)
  2. Run openclaw doctor --fix
  3. Doctor detects orphan transcript files (transcripts on disk that aren't in the regenerated sessions.json)
  4. Without any user interaction, doctor archives all orphan transcripts to .deleted.<timestamp> files
  5. Sessions that were previously active now appear reset — conversation context is lost

Root Cause

In src/commands/doctor-prompter.ts, the confirmRuntimeRepair handler calls shouldAutoApproveDoctorFix(repairMode, { blockDuringUpdate: true }) and returns true if the --fix flag is active. However, the orphan transcript archival prompt in doctor-state-integrity.ts is called with initialValue: false:

const archiveOrphans = await prompter.confirmRuntimeRepair({
  message: `Archive ${orphanCount} in ${displaySessionsDir}? ...`,
  initialValue: false,  // <-- signals: potentially destructive, do not auto-approve
});

initialValue: false is meant to mark the action as potentially destructive and should suppress auto-approval. But confirmRuntimeRepair ignores this field when --fix is active, causing it to silently return true and archive all orphans.

Impact

  • Users lose active session history after running openclaw doctor --fix post-upgrade
  • No prompt, no warning, no dry-run indication
  • Particularly dangerous when sessions.json is regenerated during upgrade and previously-valid transcripts appear as orphans

Fix

Check p.initialValue !== false before auto-approving in confirmRuntimeRepair. Only actions with initialValue: true or undefined (safe/reversible) should be auto-approved by --fix.

PR: https://github.com/openclaw/openclaw/pull/73107

Environment

  • OpenClaw version: 2026.4.25
  • Platform: Linux

extent analysis

TL;DR

To prevent silent archival of orphan transcript files, modify the confirmRuntimeRepair function to check the initialValue property before auto-approving repairs when the --fix flag is active.

Guidance

  • Review the confirmRuntimeRepair function in src/commands/doctor-prompter.ts to ensure it respects the initialValue property when --fix is active.
  • Verify that the initialValue property is set to false for potentially destructive actions, such as archiving orphan transcripts, to prevent auto-approval.
  • Test the modified confirmRuntimeRepair function with the --fix flag to ensure it prompts the user for confirmation before archiving orphan transcripts.
  • Consider adding a dry-run option to openclaw doctor --fix to allow users to preview changes before applying them.

Example

const shouldAutoApprove = (p.initialValue !== false) && repairMode === 'fix';

Notes

This fix assumes that the initialValue property is correctly set in the doctor-state-integrity.ts file. If this property is not set or is set incorrectly, the fix may not work as intended.

Recommendation

Apply the workaround by modifying the confirmRuntimeRepair function to respect the initialValue property, as this will prevent silent archival of orphan transcript files and ensure that users are prompted for confirmation before applying potentially destructive changes.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - ✅(Solved) Fix doctor --fix silently archives orphan transcripts, causing session history loss after upgrade [1 pull requests, 1 participants]