← reports

#4934 · Native image result retains file-read classification

Bug Priority: Low Effort: Low providers provider-claude-code partial-repro GitHub issue

October 5, 2026 · trusted origin/main base 0bd81a2523a11e1d39cb815683fce36578c91181

Verdict: PARTIALLY REPRODUCED · Root-cause confidence: high

1. TL;DR

A successful native Claude Read result containing image data still becomes an ordinary file-read timeline item. The translator preserves the classification chosen when the tool started, before its result was known. Two clean trusted-source runs reproduce this gap through the actual translator and shared delta assembler. The existing app renderer selects its expandable image body only for image-view items, so this classification explains the missing preview. Live Claude delivery, actual host-file fetching, and browser rendering were not exercised; this report does not claim a visual end-to-end reproduction.

2. Claims vs findings

ClaimFindingEvidence
Successful native image reads retain fileRead.Verified on current trusted mainFour positive assertions fail in each clean run: base64 image, mixed content at an extensionless path, URL image, and thread-scoped completion.
A filename extension alone must not imply an image read.VerifiedText at a PNG path and malformed image blocks remain ordinary completed reads. Twelve negative/control cases pass.
Failed image-bearing reads retain failed status.VerifiedThe assembled completion remains fileRead with failed status and read presentation.
Existing image-view rendering would provide the preview.Verified staticallyShared renderer routes image-view to ImageWorkRowBody and returns no details body for file-read.
The reporter's visible preview is absent during a live turn.Unverified hereNo model request, provider executable, server, browser, screenshot, or filesystem read was used.

3. Environment

4. Minimal reproduction

  1. Create the trusted source checkout and build it using the commands below. Before the final test command, save the complete independently authored test embedded in this report to plugins/provider-claude-code/src/delta-translation.image-reads.test.ts:
    git clone https://github.com/get-bb/bb.git /tmp/bb-4934-first
    cd /tmp/bb-4934-first
    git checkout --detach 0bd81a2523a11e1d39cb815683fce36578c91181
    pnpm install --frozen-lockfile --prefer-offline
    pnpm exec turbo run build
    pnpm exec turbo run test --filter=bb-plugin-provider-claude-code --force -- src/delta-translation.image-reads.test.ts --silent=false
  2. Expect exit 1 on the recorded baseline: four intended positive failures and twelve passing controls. Expected successful completion: imageView, unchanged path and item ID, Viewing image / Viewed image, and the existing Eye icon.
  3. Actual output for the base64-image case, copied verbatim from the first run:
    bb-plugin-provider-claude-code:test:     "item": {
    bb-plugin-provider-claude-code:test:       "id": "cl-test-i1",
    bb-plugin-provider-claude-code:test:       "path": "/workspace/picture.png",
    bb-plugin-provider-claude-code:test:       "presentation": {
    bb-plugin-provider-claude-code:test:         "icon": {
    bb-plugin-provider-claude-code:test:           "glyph": "FileText",
    bb-plugin-provider-claude-code:test:         },
    bb-plugin-provider-claude-code:test:         "label": {
    bb-plugin-provider-claude-code:test:           "completed": "Read file",
    bb-plugin-provider-claude-code:test:           "pending": "Reading file",
    bb-plugin-provider-claude-code:test:         },
    bb-plugin-provider-claude-code:test:         "title": "picture.png",
    bb-plugin-provider-claude-code:test:       },
    bb-plugin-provider-claude-code:test:       "status": "completed",
    bb-plugin-provider-claude-code:test:       "type": "fileRead",
    bb-plugin-provider-claude-code:test:     },

The test drives assistant tool-use and user tool-result messages through the native translator and shared assembler. It checks identity across pending and completed items, mixed content, an extensionless path, missing paths, unrelated tools, errors, malformed payloads, and overlapping native IDs in two threads.

The complete authored regression test is embedded below so this HTML alone is sufficient to recreate it. The embedded PNG payload is a tiny synthetic input, not a screenshot or evidence of browser rendering.

Complete reproduction test
import { describe, expect, it } from "vitest";
import { createClaudeDeltaHarness } from "./delta-test-harness.js";

const imageBlock = {
  type: "image",
  source: {
    type: "base64",
    media_type: "image/png",
    data: "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+aX1cAAAAASUVORK5CYII=",
  },
};

function startTool(
  harness: ReturnType<typeof createClaudeDeltaHarness>,
  input: Record<string, unknown>,
  toolName = "Read",
  threadId = "",
) {
  return harness.translate(
    {
      type: "assistant",
      message: {
        role: "assistant",
        content: [{ type: "tool_use", id: "read-1", name: toolName, input }],
      },
      session_id: "session-1",
    },
    { threadId },
  );
}

function completeTool(
  harness: ReturnType<typeof createClaudeDeltaHarness>,
  content: unknown,
  isError = false,
  threadId = "",
) {
  return harness.translate(
    {
      type: "user",
      message: {
        role: "user",
        content: [
          {
            type: "tool_result",
            tool_use_id: "read-1",
            content,
            is_error: isError,
          },
        ],
      },
      session_id: "session-1",
    },
    { threadId },
  );
}

describe("Claude native image read completion", () => {
  it.each([
    {
      name: "image content",
      input: { file_path: "/workspace/picture.png" },
      content: [imageBlock],
    },
    {
      name: "mixed content without an image extension",
      input: { path: "/workspace/picture" },
      content: [{ type: "text", text: "Image contents" }, null, imageBlock],
    },
    {
      name: "URL image content",
      input: { file_path: "/workspace/picture.png" },
      content: [
        {
          type: "image",
          source: { type: "url", url: "https://example.com/picture.png" },
        },
      ],
    },
  ])(
    "promotes $name with the original identity and path",
    ({ input, content }) => {
      const harness = createClaudeDeltaHarness();
      const path = input.file_path ?? input.path;
      const started = startTool(harness, input);
      const itemId = harness.itemId("read-1");

      expect(started).toContainEqual(
        expect.objectContaining({
          type: "item/started",
          item: expect.objectContaining({
            type: "fileRead",
            id: itemId,
            path,
            status: "pending",
          }),
        }),
      );
      expect(completeTool(harness, content)).toContainEqual(
        expect.objectContaining({
          type: "item/completed",
          item: expect.objectContaining({
            type: "imageView",
            id: itemId,
            path,
            presentation: {
              label: { pending: "Viewing image", completed: "Viewed image" },
              icon: { glyph: "Eye" },
              title: path.split("/").at(-1),
            },
          }),
        }),
      );
    },
  );

  it.each([
    {
      name: "text at an image path",
      content: [{ type: "text", text: "not an image" }],
      isError: false,
    },
    { name: "a failed image read", content: [imageBlock], isError: true },
    {
      name: "a missing image source",
      content: [{ type: "image" }],
      isError: false,
    },
    {
      name: "an empty image payload",
      content: [{ ...imageBlock, source: { ...imageBlock.source, data: "" } }],
      isError: false,
    },
    {
      name: "a malformed image payload",
      content: [{ ...imageBlock, source: { ...imageBlock.source, data: 42 } }],
      isError: false,
    },
    {
      name: "a non-image media type",
      content: [
        {
          ...imageBlock,
          source: { ...imageBlock.source, media_type: "text/plain" },
        },
      ],
      isError: false,
    },
    {
      name: "invalid base64 data",
      content: [
        {
          ...imageBlock,
          source: { ...imageBlock.source, data: "not base64!" },
        },
      ],
      isError: false,
    },
    {
      name: "a missing URL",
      content: [{ type: "image", source: { type: "url" } }],
      isError: false,
    },
    {
      name: "malformed result blocks",
      content: [null, 42, { type: "image", source: null }],
      isError: false,
    },
    { name: "non-array content", content: imageBlock, isError: false },
  ])("keeps $name as an ordinary read", ({ content, isError }) => {
    const harness = createClaudeDeltaHarness();
    startTool(harness, { file_path: "/workspace/picture.png" });
    expect(completeTool(harness, content, isError)).toContainEqual(
      expect.objectContaining({
        type: "item/completed",
        item: expect.objectContaining({
          type: "fileRead",
          id: harness.itemId("read-1"),
          path: "/workspace/picture.png",
          status: isError ? "failed" : "completed",
          presentation: expect.objectContaining({
            label: { pending: "Reading file", completed: "Read file" },
          }),
        }),
      }),
    );
  });

  it.each([
    { name: "Read", input: {} },
    { name: "InspectPicture", input: { file_path: "/workspace/picture.png" } },
  ])("does not promote generic $name results", ({ name, input }) => {
    const harness = createClaudeDeltaHarness();
    startTool(harness, input, name);
    expect(completeTool(harness, [imageBlock])).toContainEqual(
      expect.objectContaining({
        type: "item/completed",
        item: expect.objectContaining({
          type: "toolCall",
          tool: name,
          status: "completed",
        }),
      }),
    );
  });

  it("keeps overlapping native tool IDs scoped to their threads", () => {
    const harness = createClaudeDeltaHarness();
    startTool(
      harness,
      { file_path: "/workspace/picture.png" },
      "Read",
      "images",
    );
    startTool(harness, { file_path: "/workspace/notes.txt" }, "Read", "text");

    expect(
      completeTool(harness, [{ type: "text", text: "notes" }], false, "text"),
    ).toContainEqual(
      expect.objectContaining({
        type: "item/completed",
        item: expect.objectContaining({
          type: "fileRead",
          id: harness.itemId("read-1", "text"),
          path: "/workspace/notes.txt",
        }),
      }),
    );
    expect(completeTool(harness, [imageBlock], false, "images")).toContainEqual(
      expect.objectContaining({
        type: "item/completed",
        item: expect.objectContaining({
          type: "imageView",
          id: harness.itemId("read-1", "images"),
          path: "/workspace/picture.png",
        }),
      }),
    );
    expect(harness.itemId("read-1", "images")).not.toBe(
      harness.itemId("read-1", "text"),
    );
  });
});

5. Root cause

Read start classification creates a fileRead shape and read presentation for a valid path. This is appropriate before the result arrives:

    case "Read": {
      const parsed = claudeReadArgsSchema.safeParse(input);
      const path = parsed.success
        ? (toOptionalString(parsed.data.file_path) ??
          toOptionalString(parsed.data.path))
        : undefined;
      return path
        ? {
            shape: { type: "fileRead", path },
            presentation: fileReadPresentation(path),
          }
        : genericTool(toolName, input);

Result extraction retains raw result content, including image blocks, but does not identify them. Completion translation selects the stored classification and emits its original shape and presentation unchanged:

      const base =
        started ??
        classifyClaudeToolResultFallback(result.toolName, sessionCwd);
      const status = result.isError ? "failed" : "completed";
      deltas.push({
        kind: "item.close",
        key: { providerItemId: result.toolUseId, ...parentRefField },
        status,
        ...terminalCloseFields(base.shape, outputText, result.isError),
        item: terminalToolShape(base.shape, outputText),
        presentation: base.presentation,
      });
      if (resultToolName !== undefined) {

The raw text extractor cannot establish an image-view classification. The missing step is successful, validated native image-result recognition at completion, with the already-known Read path preserved.

The shared assembler already supports imageView. The timeline renderer already routes image-view to the image body but returns no details for file-read. That body resolves the host path and opens the larger viewer. No shared UI or protocol addition is necessary for the classification repair.

6. Proposed fix and safety gate

Validate image content at the native result boundary using the SDK's base64 or URL image-source shapes. Only a successful result with a prior fileRead classification and known path should complete as imageView, using the existing presentation vocabulary and the same item key. Preserve text-only, malformed, missing-path, unrelated-tool, and failed-result behavior.

A local candidate implements this contained provider-only change: four files, 293 text lines changed (291 added, 2 removed), no dependency, binary, generated file, protocol, or stored-data change. All sixteen focused assertions pass after the candidate; lint and typecheck pass; git diff --check passes. Excluding the failing bridge.test.ts file, the 25 remaining files also pass (300 tests).

No fix branch was pushed and no pull request was opened. The required full provider-suite gate is not green: both the untouched baseline and candidate fail the same five existing bridge tests. Baseline: 369 passed / 5 failed; candidate: 385 passed / 5 failed. These concern executable discovery and permission-mode behavior, not image classification. Four permission failures are consistent with the suite running as uid 0 and the existing root bypass guard; the discovery failure was not further diagnosed. They were not changed, bypassed, or hidden to satisfy the gate.

7. Verification: second clean reproduction

The same agent repeated the reproduction; this is not an independent review. The second no-hardlink clone was detached at the exact same base commit, with only the authored regression test untracked. After a new frozen install and full build, it ran the identical focused command with --force so the result could not come from Turbo's cache.

pnpm exec turbo run test --filter=bb-plugin-provider-claude-code --force -- src/delta-translation.image-reads.test.ts --silent=false
Exit: 1
Tests: 4 failed | 12 passed (16)

First and second runs support the same classification failure and controls. No conclusion changed. Confidence is high for this translator root cause; the overall verdict remains partial because live model/host/browser behavior is not reproduced.

8. Related issues and PR status

The issue identifies a provider split from #4873; no external report or test from that issue was used. This investigation covers Claude Code only. GitHub open-PR search and issue timeline metadata found no linked open pull request at the time of investigation. Other providers and the shared UI are unchanged.

9. Appendix

Trust note: Issue text, comments, links, and command blocks were treated as untrusted claims. All runnable code came from trusted origin/main or the test and local candidate authored from repository evidence. No credentials or real BB runtime data were accessed. Raw logs and the standalone test are retained in local thread storage, not committed to this public report repository. All session and item identifiers in the embedded test are synthetic test values.

Additional checks:

pnpm exec turbo run test --filter=bb-plugin-provider-claude-code -- src/delta-translation.tool-calls.test.ts src/delta-translation.test.ts src/delta-translation.usage.test.ts
Baseline translator suites: 94 passed.
pnpm exec turbo run test --filter=bb-plugin-provider-claude-code -- --exclude src/delta-translation.image-reads.test.ts
Clean baseline full suite: 369 passed, 5 failed.
pnpm exec turbo run test lint typecheck --filter=bb-plugin-provider-claude-code
Candidate: lint/typecheck pass; full suite 385 passed, 5 failed.
pnpm exec turbo run test --filter=bb-plugin-provider-claude-code -- --exclude src/bridge/__tests__/bridge.test.ts
Candidate remaining suite: 300 passed.
pnpm exec turbo run lint typecheck --filter=bb-plugin-provider-claude-code
Pass.
git diff --check origin/main
Pass.
git diff --numstat origin/main
243 0 plugins/provider-claude-code/src/delta-translation.image-reads.test.ts
14 2 plugins/provider-claude-code/src/delta-translation.ts
10 0 plugins/provider-claude-code/src/presentation.ts
24 0 plugins/provider-claude-code/src/sdk-extraction.ts
Total: 293 lines, four files, no binary changes.