Skip to content

[Bug]: Upgraded v0.1.12 installs keep pre-existing deleted thread content in statev2.sqlite for up to 6 hours (plus delete dialog scope gaps) #42796

Done

Description

@realshawnwong

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

apps/server

Steps to reproduce

  1. On a version prior to v0.1.12, create and run several threads, then delete them via the UI (which displays "This permanently clears conversation history for this thread.").
  2. Let background compaction run on the older version so ~/.t3/userdata/compacted-at is updated recently.
  3. Upgrade and restart into v0.1.12 (verified on macOS T3 Code (Beta) 0.1.12, also still present on main @ dca3ab20).
  4. Inspect ~/.t3/userdata/statev2.sqlite read-only after startup.

Expected behavior

  1. Upgrading to v0.1.12 should immediately detect and purge previously deleted threads on startup (or via an explicit one-time migration / startup sweep), rather than leaving deleted conversation content and FTS5 index entries intact for up to 6 hours waiting for COMPACTION_INTERVAL.
  2. When the UI states "This permanently clears conversation history for this thread", either all user-identifying history for that thread should be cleared promptly, or the UI should accurately disclose what remains (e.g., thread tombstone metadata, kept run.updated (status = 'running') events, and external provider transcripts stored by underlying CLIs such as ~/.claude/projects or CODEX_HOME/sessions).

Actual behavior

  1. Up to 6-hour retroactive purge delay after upgrading to v0.1.12:
    • In apps/server/src/persistence/DatabaseStorage.ts, firstCompactionDelay is computed from the existing compacted-at timestamp plus COMPACTION_INTERVAL (hours(6)).
    • Because pre-v0.1.12 deletions never enqueued thread-content.purge, and the previous version already updated compacted-at, upgrading to v0.1.12 leaves all previously deleted threads completely unpurged in statev2.sqlite until the next 6-hour compaction window arrives.
    • Observed on a live v0.1.12 install upgraded shortly after an earlier compaction: 7 previously deleted threads still had their original titles intact along with 40 rows in orchestration_v2_projection_messages, 24 rows in orchestration_v2_message_search (FTS5), 165 rows in orchestration_v2_projection_turn_items, 26 rows in orchestration_v2_projection_runs, and 131 rows in orchestration_v2_projection_nodes. Running the purgeableThreads SQL from apps/server/src/orchestration-v2/ProjectionMaintenance.ts matched all 7/7 threads, confirming they are simply waiting on the 6-hour compacted-at timer.
  2. Residual data & UI expectation mismatch even after purge:
    • ProjectionMaintenance.ts intentionally retains orchestration_events rows where event_type = 'run.updated' AND json_extract(payload_json, '$.status') = 'running' (for Codex usage history) and keeps thread tombstones in orchestration_v2_projection_threads.
    • External provider transcripts on disk (~/.claude/projects, CODEX_HOME/sessions, etc.) are not cleared or mentioned in the delete confirmation dialog, even though the dialog says "This permanently clears conversation history for this thread."

Note — not a duplicate of #17845 or #32378: #17845 was closed as completed and v0.1.12 ships purgeDeletedThread for newly deleted threads, but this specifically reports the post-upgrade retroactive purge delay (compacted-at + 6h) and the residual-data / external-CLI disclosure gap still reproducible in v0.1.12 (main @ dca3ab20).

Impact

Major degradation or frequent failure

Version or commit

v0.1.12 (also verified in main @ dca3ab2)

Environment

macOS (arm64), T3 Code (Beta) Desktop v0.1.12, Orchestrator V2 (statev2.sqlite)

Logs or stack traces

# Read-only inspection of ~/.t3/userdata/statev2.sqlite after upgrading to v0.1.12:
orchestration_v2_projection_threads (deleted_at IS NOT NULL): 7
  orchestration_v2_projection_messages (for deleted threads): 40
  orchestration_v2_message_search FTS5 (for deleted threads): 24
  orchestration_v2_projection_turn_items (for deleted threads): 165
  orchestration_v2_projection_runs (for deleted threads): 26
  orchestration_v2_projection_nodes (for deleted threads): 131
# Running purgeableThreads query matched 7 / 7, blocked only by compacted-at + COMPACTION_INTERVAL (6h).

Workaround

Wait up to 6 hours for the next scheduled pruneEventStore run after compacted-at expires, or manually clear external provider session directories if full local erasure is required.

Suggested fix & priority context

  • Priority context: Data retention after clicking "Delete" is currently a high-visibility privacy/trust concern in public audits of T3 Code. Users who upgrade specifically to get the [Bug]: Deleting a thread says it permanently clears its history, but V2 keeps every event and projection row #17845 fix and immediately inspect statev2.sqlite still see all of their previously deleted conversations and titles intact for hours, making the fix appear broken.
  • Concrete low-risk fix:
    1. In DatabaseStorage.ts (or a lightweight startup sweep / one-time schema version marker), run purgeThreads(undefined) promptly after startup when unpurged deleted threads exist, without waiting for compacted-at + COMPACTION_INTERVAL.
    2. Add a short note in the delete confirmation dialog (or docs) clarifying that underlying CLI providers may retain their own local session logs outside T3 Code's database, and consider offering an explicit "Compact & purge deleted history now" action in Settings > Maintenance.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions