Skip to content

Commit 3a9640c

Browse files
only21milclaudemaria-rcks
authored
fix(claude): name the notebook a NotebookEdit changed (pingdotgg#22130)
Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: maria-rcks <[email protected]>
1 parent 1b78b65 commit 3a9640c

2 files changed

Lines changed: 85 additions & 1 deletion

File tree

‎apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts‎

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6865,6 +6865,90 @@ describe("ClaudeAdapterV2 background wake turns", () => {
68656865
),
68666866
);
68676867

6868+
it.effect("names the notebook a Claude NotebookEdit changed", () =>
6869+
Effect.gen(function* () {
6870+
const harness = yield* makeWakeHarness;
6871+
yield* harness.runtime.startTurn(
6872+
makeClaudeTestTurnInput({
6873+
threadId: harness.threadId,
6874+
providerThread: harness.providerThread,
6875+
now: yield* DateTime.now,
6876+
attemptId: RunAttemptId.make("attempt-notebook-edit"),
6877+
text: "Fix the notebook",
6878+
attachments: [],
6879+
}),
6880+
);
6881+
yield* Queue.offer(
6882+
harness.sdkMessages,
6883+
claudeSdkFrame({
6884+
type: "assistant",
6885+
uuid: "00000000-0000-4000-8000-000000000604",
6886+
session_id: WAKE_NATIVE_SESSION,
6887+
parent_tool_use_id: null,
6888+
message: {
6889+
id: "msg_notebook_edit",
6890+
model: "claude-sonnet-4-6",
6891+
type: "message",
6892+
role: "assistant",
6893+
content: [
6894+
{
6895+
type: "tool_use",
6896+
id: "notebook",
6897+
name: "NotebookEdit",
6898+
input: {
6899+
notebook_path: "/workspace/analysis.ipynb",
6900+
cell_id: "c1",
6901+
new_source: "print(1)",
6902+
},
6903+
},
6904+
],
6905+
stop_reason: "tool_use",
6906+
stop_sequence: null,
6907+
usage: {
6908+
input_tokens: 1,
6909+
output_tokens: 1,
6910+
cache_creation_input_tokens: 0,
6911+
cache_read_input_tokens: 0,
6912+
},
6913+
},
6914+
}),
6915+
);
6916+
yield* Queue.offer(
6917+
harness.sdkMessages,
6918+
claudeSdkFrame({
6919+
type: "user",
6920+
uuid: "00000000-0000-4000-8000-000000000605",
6921+
session_id: WAKE_NATIVE_SESSION,
6922+
parent_tool_use_id: null,
6923+
message: {
6924+
role: "user",
6925+
content: [{ type: "tool_result", tool_use_id: "notebook", content: "Updated cell c1" }],
6926+
},
6927+
}),
6928+
);
6929+
yield* Queue.offer(
6930+
harness.sdkMessages,
6931+
makeResultFrame({ uuid: "00000000-0000-4000-8000-000000000606", result: "Done" }),
6932+
);
6933+
yield* Queue.take(harness.terminalReceipts);
6934+
const item = harness.events
6935+
.flatMap((event) =>
6936+
event.type === "turn_item.updated" &&
6937+
event.turnItem.nativeItemRef?.nativeId === "notebook"
6938+
? [event.turnItem]
6939+
: [],
6940+
)
6941+
.at(-1);
6942+
assert.equal(item?.type, "file_change");
6943+
if (item?.type === "file_change") assert.equal(item.fileName, "/workspace/analysis.ipynb");
6944+
}).pipe(
6945+
Effect.scoped,
6946+
Effect.provide(
6947+
Layer.mergeAll(NodeServices.layer, IdAllocator.layer, McpProviderSessions.layer),
6948+
),
6949+
),
6950+
);
6951+
68686952
it.effect.each(["claude-haiku-4-5-20251001", "claude-sonnet-4-6"])(
68696953
"renegotiates auto only when switching API models after fallback to default: %s",
68706954
(nextModel) =>

‎apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2923,7 +2923,7 @@ function parseClaudeBackgroundTaskEntry(
29232923

29242924
function fileNameFromClaudeTool(toolName: string, input: ClaudeNativeToolInput): string {
29252925
return (
2926-
firstStringInputField(input, ["file_path", "path", "filename", "fileName"]) ??
2926+
firstStringInputField(input, ["file_path", "notebook_path", "path", "filename", "fileName"]) ??
29272927
`${toolName} result`
29282928
);
29292929
}

0 commit comments

Comments
 (0)