Skip to content

[Bug]: A deleted imported Claude Code thread can't be re-imported into the same project #45055

Done

Description

@v-k-data

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. Open a project whose folder has a local Claude Code session and import that session (agent session import). T3 creates the thread import:claudeAgent:<session-id>.
  2. Send a message or two in that thread in T3 Code, or continue the session in the Claude Code CLI or Claude desktop app, so the transcript changes.
  3. Delete the thread in T3 Code.
  4. Import sessions for the same project again.

Expected behavior

The session is imported again with its current transcript and the thread shows up in the project, the same way #44863 now handles ACP sessions after a thread is deleted.

Actual behavior

The thread does not come back, and there is no way in the UI to get the session into T3 again.

Deleting the thread is a soft delete, and the importer doesn't account for that:

  • The thread id is deterministic (import:${providerInstanceId}:${providerSessionId}), so re-import looks up the same id and orchestrator.getThreadRecords returns the soft-deleted thread (deletedAt set, same projectId, historyOrigin: "v1_import", its messages already released).
  • The provider_session_runtime row for the thread is kept, with runtimePayload.importedTranscripts still listing the transcript.
  • Unchanged transcript → the scanner yields AlreadyImported, which is counted as imported but creates nothing.
  • Changed transcript → Importable. The existing-thread branch then compares stored messages (now 0) with the transcript. The thread has runs, so the result is false and nothing is imported. On main @ 270fb87, a thread without runs would get its messages rewritten, but deletedAt stays set, so the thread is still hidden.

How this relates to existing issues:

A possible fix is to treat a soft-deleted v1_import thread as absent regardless of project: import into a fresh thread as #44863 does, or extend #34064's restore path to same-project deletions. Clearing importedTranscripts from provider_session_runtime when an imported thread is deleted would also stop the AlreadyImported dead end.

Impact

Major degradation or frequent failure

Version or commit

Desktop 0.1.13 (stable); the importer logic is unchanged on main @ 270fb87

Environment

macOS 14.6 (Apple Silicon), T3 Code desktop 0.1.13, Claude Code provider (claudeAgent), Claude Opus 5.5

Logs or stack traces

# statev2.sqlite after deleting the thread and re-importing (ids redacted)

orchestration_v2_projection_threads
  thread_id      = import:claudeAgent:<session-id>
  title          = Deleted thread
  historyOrigin  = v1_import
  deleted_at     = 2026-11-28T16:49:44.187Z
  messages       = 0

provider_session_runtime
  thread_id      = import:claudeAgent:<session-id>
  status         = stopped
  runtime_payload_json = {"cwd":"~/t3","importedTranscripts":[{"provider":"claudeAgent",
    "providerSessionId":"<session-id>","filePath":"~/.claude/projects/-…-t3/<session-id>.jsonl",
    "size":571892, ...}]}

# Rows for the deleted thread still present in:
# provider_session_runtime, orchestration_v2_projection_threads, _run_attempts,
# _provider_sessions, _provider_threads, _provider_turns, _checkpoint_scopes,
# _checkpoints, orchestration_v2_effect_outbox, orchestration_events,
# orchestration_command_receipts

# server.trace.ndjson: both re-import attempts end with
#   ws.rpc.agentSessions.import  exit=Success
# so no error is logged for the skipped session.

Screenshots, recordings, or supporting files

No response

Workaround

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugneeds-triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions