The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 09:45 UTC
fix(pi): image reads show a preview in the work log (#37471)
Julius Marminge committed
Nov 15, 2026 at 19:56 UTC
e47a96e88d83f9682a7bbbe7df43b2c68b05c04d
2 files changed
+19
-1
packages/provider-pi/src/server/adapter.test.ts
+6
-1
@@ -3174,6 +3174,7 @@ describe("PiAdapterV2", () => {
3174
const cases = [
3175
{
3176
toolName: "read",
3177
+ args: { path: "/workspace/screens/shot.png" },
3178
result: { content, structuredContent: { ...image, note } },
3179
expected: { content },
3180
},
@@ -3230,6 +3231,7 @@ describe("PiAdapterV2", () => {
3231
type: `tool_execution_${phase}`,
3232
toolCallId: `image-${index}`,
3233
toolName: test.toolName,
3234
+ ...("args" in test ? { args: test.args } : {}),
3235
...(phase === "end" ? { result: test.result } : { partialResult: test.result }),
3236
isError: false,
3237
});
@@ -3247,7 +3249,10 @@ describe("PiAdapterV2", () => {
3249
? [{ mimeType: "image/png", data: image.data }]
3250
: [],
3251
);
3250
- if (index === 0) assert.equal(turnItemOutputText(event.turnItem), note);
3252
+ if (index === 0) {
3253
+ assert.equal(turnItemOutputText(event.turnItem), note);
3254
+ assert.equal(event.turnItem.viewedImagePath, "/workspace/screens/shot.png");
3255
+ }
3256
if (index === 5) assert.equal(turnItemOutputText(event.turnItem), "first\nsecond");
3257
if (index === 2) {
3258
assert.deepEqual(compactDynamicToolOutput(event.turnItem.output), {
packages/provider-pi/src/server/adapter.ts
+13
@@ -3,6 +3,7 @@ import * as NodeUtil from "node:util";
3
import { AgentScope } from "@t3tools/shared/AgentScope";
4
import { getModelSelectionStringOptionValue } from "@t3tools/shared/model";
5
import { readToolOutputImage } from "@t3tools/shared/toolOutput";
6
+import { isWorkspaceImagePreviewPath } from "@t3tools/shared/filePreview";
7
import * as Predicate from "effect/Predicate";
8
import {
9
ProviderDriverKind,
@@ -1409,6 +1410,17 @@ export const makePiAdapterV2 = Effect.fn("makePiAdapterV2")(function* (
1410
}
1411
}
1412
const output = piToolOutput(resultRecord, toolName);
1413
+ const readPath =
1414
+ toolName === "read"
1415
+ ? (recordString(args, "path") ?? recordString(args, "file_path"))?.trim()
1416
+ : undefined;
1417
+ const viewedImagePath =
1418
+ readPath &&
1419
+ readPath.length <= 4096 &&
1420
+ !/[\r\n]/.test(readPath) &&
1421
+ isWorkspaceImagePreviewPath(readPath)
1422
+ ? readPath
1423
+ : undefined;
1424
yield* emit({
1425
type: "turn_item.updated",
1426
driver: PI_PROVIDER,
@@ -1420,6 +1432,7 @@ export const makePiAdapterV2 = Effect.fn("makePiAdapterV2")(function* (
1432
toolName,
1433
input: args ?? {},
1434
...(output === undefined ? {} : { output }),
1435
+ ...(viewedImagePath === undefined ? {} : { viewedImagePath }),
1436
},
1437
});
1438
if (toolName === "subagent") {