Skip to content

feat(settings): add toggle to protect conversation history from auto-deletion#1624

Open
daymade wants to merge 2 commits intofarion1231:mainfrom
daymade:feat/transcript-cleanup-protection
Open

feat(settings): add toggle to protect conversation history from auto-deletion#1624
daymade wants to merge 2 commits intofarion1231:mainfrom
daymade:feat/transcript-cleanup-protection

Conversation

@daymade
Copy link
Copy Markdown

@daymade daymade commented Mar 22, 2026

Summary

  • Add a "Keep conversation history" toggle in Settings → General, below "Skip Claude Code first-run confirmation"
  • When enabled, sets cleanupPeriodDays: 99999 in ~/.claude/settings.json to prevent auto-deletion
  • Toggle syncs from Claude's actual settings.json on load, reflecting manual edits

Root Cause

Claude Code silently deletes conversation transcripts after 30 days by default. Users are unaware until they lose data. Multiple upstream issues:

Changes

Rust backend (3 files):

  • claude_mcp.rs: set_cleanup_period_days() / clear_cleanup_period_days() / get_cleanup_period_days() — reads/writes ~/.claude/settings.json
  • commands/plugin.rs: 3 Tauri commands
  • lib.rs: Command registration

Frontend (9 files):

  • WindowSettings.tsx: ToggleRow with History icon (amber-500)
  • useSettings.ts: Auto-save logic following skipClaudeOnboarding pattern
  • useSettingsForm.ts: Field init + on-load sync from actual Claude settings
  • settings.ts / schemas/settings.ts / types.ts: Type definitions
  • en.json / zh.json / ja.json: i18n (3 locales)

Why This Is Safe

  • Follows the exact same pattern as skipClaudeOnboarding (proven, shipped)
  • Target file (~/.claude/settings.json) is the official Claude Code settings file
  • Incremental JSON merge — preserves all existing fields
  • Setting cleanupPeriodDays: 99999 is the documented workaround
  • Toggle OFF removes the field entirely, reverting to Claude's default behavior

Testing

  • cargo check passes cleanly
  • 13 files changed, 186 insertions, 1 deletion

Closes #1623

🤖 Generated with Claude Code

…deletion

Claude Code silently deletes conversation transcripts after 30 days by
default (cleanupPeriodDays: 30). Most users are unaware of this until
they lose data (anthropics/claude-code#4172, #22547, #23710).

Add a "Keep conversation history" toggle in Settings → General, below
the existing "Skip Claude Code first-run confirmation" toggle. When
enabled, sets cleanupPeriodDays: 99999 in ~/.claude/settings.json.

The toggle syncs from Claude's actual settings.json on load, so it
reflects reality even if the user edited the file manually.

Closes farion1231#1623

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@farion1231
Copy link
Copy Markdown
Owner

@codex

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3174941fdd

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

- Auto-save handler: remove stale `data?.` comparison for
  skipClaudeOnboarding and keepConversationHistory — the
  `updates !== undefined` guard is sufficient and avoids
  skipping API calls when data hasn't refetched after rapid toggles
- Explicit save handler: keep `data?.` comparison with clarifying
  comments — prevents premature clearTranscriptProtection() when
  async init hasn't completed yet
- Add userTouchedTranscriptRef to prevent async getTranscriptProtection()
  from overwriting user's manual toggle choice

Addresses review feedback from farion1231#1624.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@daymade
Copy link
Copy Markdown
Author

daymade commented Mar 26, 2026

Hi @farion1231, I've pushed a fix commit (7101e187) addressing the two Codex review comments plus one additional race condition found during cross-model review (Claude + Codex adversarial challenge).

Changes in the new commit

useSettings.ts — auto-save handler:

  • Removed stale data?. comparison for both skipClaudeOnboarding and keepConversationHistory. The updates !== undefined guard is sufficient, and the old comparison could skip API calls when data hadn't refetched after rapid toggles.

useSettings.ts — explicit save handler:

  • Kept data?. comparison (added clarifying comments). This prevents a premature clearTranscriptProtection() call when the async init hasn't completed yet — the form default is false, so saving before init would silently wipe an existing protection setting.

useSettingsForm.ts:

  • Added userTouchedTranscriptRef — once the user manually toggles keepConversationHistory, the async getTranscriptProtection() read no longer overwrites the form state. This prevents confusing UI flips from late-resolving promises.

All changes pass pnpm typecheck. Ready for re-review.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: add toggle to protect Claude Code conversation history from auto-deletion

2 participants