Skip to content

[Bug]: Re-importing a deleted project imports zero sessions (stale import records and soft-deleted threads block import) #34043

Open

Description

@juanpahv

Summary

After deleting a project and adding/importing the same folder again, session import creates zero threads. Every previously imported Claude session for that workspace stays invisible, even though the transcripts are intact on disk.

Related: #31628 (re-import does not refresh history). Deleting and re-importing the project is the natural workaround for #31628, and it currently makes things worse.

Environment

  • T3 Code macOS desktop 0.1.8 (Beta)
  • Claude Code CLI transcripts in the standard Claude projects directory
  • ~39 transcripts for the workspace, 31 of them previously imported

Observed behavior

  1. The deleted project and its import:claudeAgent:<sessionId> threads remain in the state DB as soft-deleted rows (deleted_at set) under the old project id.
  2. The provider_session_runtime rows for those threads are not removed; their runtimePayload.importedTranscripts still lists each transcript identity, keyed by cwd.
  3. On re-import into the new project id, each candidate transcript hits one of two dead ends:
    • Unchanged transcript: completedSources (built from provider_session_runtime by cwd) matches it, so the scanner yields AlreadyImported. The importer counts it as imported but creates no thread, because the only thread is the soft-deleted one.
    • Changed transcript: it yields Importable, but orchestrator.getThreadRecords(threadId) still returns the soft-deleted thread (the canonical projection read does not filter deleted_at). Its projectId differs, so it fails with AgentSessionThreadProjectConflictError.

Result: the new project shows no sessions at all.

Reproduction

  1. Add a project folder that has local Claude Code sessions and import them.
  2. Continue at least one of those sessions outside T3 (for example in a terminal).
  3. Delete the project in T3.
  4. Add the same folder again and run session import.
  5. No threads appear.

Expected behavior

Deleting a project should either purge its imported threads and their provider_session_runtime import records, or have import ignore soft-deleted threads and transcript records that belong to deleted projects, so that importing the folder again recreates the sessions with their current history.

Workaround

With T3 closed and the DB backed up, deleting every row for those import:* thread ids works. The rows are in provider_session_runtime, the orchestration_v2_* tables keyed by thread_id, orchestration_events.stream_id and orchestration_command_receipts.aggregate_id. A fresh import then recreates the threads. This should not be needed.

Activity

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