Skip to content

[Bug]: Claude Code session import skips sessions whose first message is a large image (over 1 MiB) #41436

Closed

Description

@killlilwinters

Before submitting

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

Related but different issues (different causes): #31677, #29153, #27163 and #27581.

Area

apps/server

Steps to reproduce

  1. Create a Claude Code transcript at <claude-home>/projects/<slug>/fake-session-0001.jsonl:
    • Lines 1 and 2 are queue-operation records with no cwd field.
    • Line 3 is a user record with a top-level cwd pointing to an existing <project-folder>. Its message content is an array with a text block and an image block whose base64 data is about 1.1 MiB (fake bytes are fine).
    • Line 4 is an assistant text reply.
  2. Set the file mtime to within the last 30 days.
  3. Run T3 Code's import scan for that project (the "import recent threads" path, which calls AgentSessionScanner.recentThreads).
  4. Observe that the session is not listed.
  5. Control: the same file with the image at about 900 KiB is listed.

Fake-data generator (fake strings only):

import json, base64, os, time
def make(path, cwd, image_bytes):
    os.makedirs(os.path.dirname(path), exist_ok=True)
    fake_image = base64.b64encode(b"\0" * image_bytes).decode()
    lines = [
        {"type": "queue-operation", "operation": "enqueue", "sessionId": "fake-session-0001"},
        {"type": "queue-operation", "operation": "dequeue", "sessionId": "fake-session-0001"},
        {"type": "user", "cwd": cwd, "sessionId": "fake-session-0001",
         "message": {"role": "user", "content": [
             {"type": "text", "text": "fake prompt"},
             {"type": "image", "source": {"type": "base64", "media_type": "image/png", "data": fake_image}}]}},
        {"type": "assistant", "sessionId": "fake-session-0001",
         "message": {"role": "assistant", "content": [{"type": "text", "text": "fake reply"}]}},
    ]
    with open(path, "w") as f:
        f.write("\n".join(json.dumps(l) for l in lines) + "\n")
    os.utime(path, (time.time(), time.time()))
# make("<claude-home>/projects/<slug>/fake-session-0001.jsonl", "<project-folder>", 825 * 1024)  # ~1.1 MiB base64

Expected behavior

The session appears in the import list. A large first message should not hide the project folder.

Actual behavior

The session is dropped silently, with no warning. readCwd in apps/server/src/project/AgentSessionScanner.ts reads at most MAX_TRANSCRIPT_SCAN_BYTES = 1024 * 1024 (line 74 on origin/main commit c768764). When the line holding cwd is bigger than that, the transcript returns null and is skipped.

Evidence: a 7-case reproducer run on origin/main c768764 gives 5 passes and 2 failures. Raising MAX_TRANSCRIPT_SCAN_BYTES to 8 MiB makes all 7 pass (checked on commit 59651c1).

Case Session listed on origin/main c768764 Session listed with 8 MiB scan limit
Short text prompt pass pass
2 MiB record after the cwd line pass pass
Image at about 256 KiB pass pass
Image at about 512 KiB pass pass
Image at about 900 KiB pass pass
Image at about 1.1 MiB fail pass
Image at about 2 MiB fail pass

Impact

Minor bug or occasional failure

A session that never appears is a clear case, but the number of affected sessions is unknown.

Version or commit

T3 Code desktop 0.1.11 (build commit 59651c1). Also reproduced on origin/main c768764.

Environment

macOS (Darwin 27.2.0), T3 Code desktop beta 0.1.11, Claude Code CLI version unknown.

Logs or stack traces

None needed.

Workaround

Run claude --resume <session-id> from the project folder in a terminal, or start a new T3 thread and paste a summary.

Activity

  1. added
    bug
    needs-triage
    on Nov 23, 2026
  2. killlilwinters commented on Nov 25, 2026

    @killlilwinters
    Author

    This isn't fully fixed. The repro above put cwd before message in the first user record, but real Claude Code (2.1.317) writes message first. With a large pasted image, cwd still lands past the 1 MiB scan window, so the session is still dropped on v0.1.12, which includes #41446.

    Open PR #42640 handles that order: a 2 MiB message-before-cwd test fails on v0.1.12 and passes on its head.

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

    bugneeds-triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions