diff --git a/packages/app/src/session/timeline/controller.tsx b/packages/app/src/session/timeline/controller.tsx index 708e7116204..44bb5933a26 100644 --- a/packages/app/src/session/timeline/controller.tsx +++ b/packages/app/src/session/timeline/controller.tsx @@ -75,6 +75,8 @@ export function createTimelineController(input: { active: Accessor /** Whether this timeline is the New timeline experiment. */ next: boolean + /** The server's `full_codemode` flag: without it, a script's changes neither show nor count. */ + scriptDiffs: Accessor }) { const navigate = useNavigate() const sdk = useWorkspaceLocation() @@ -213,6 +215,7 @@ export function createTimelineController(input: { pendingInputIDs, queuedCompactionIDs, turnDiffs: settings.general.showTurnDiffs, + scriptDiffs: input.scriptDiffs, } const projection = input.next diff --git a/packages/app/src/session/timeline/message-timeline.tsx b/packages/app/src/session/timeline/message-timeline.tsx index 96f462fd262..4d10c9b62a7 100644 --- a/packages/app/src/session/timeline/message-timeline.tsx +++ b/packages/app/src/session/timeline/message-timeline.tsx @@ -4,6 +4,7 @@ import { abort } from "@opencode/util/abort" import { createAnimatedPresence } from "@/runtime/animated-presence" import type { SessionMessageUser } from "@opencode/client/promise" import type { SessionUserActions } from "@opencode/session-ui/actions" +import { useData } from "@opencode/session-ui/context" import { Button } from "@opencode/ui/button" import { Icon } from "@opencode/ui/icon" import { IconButton } from "@opencode/ui/icon-button" @@ -116,10 +117,13 @@ export function MessageTimeline(props: MessageTimelineProps) { } function MountedTimeline(props: MessageTimelineProps & { next: boolean }) { + const data = useData() + const controller = createTimelineController({ session: props.session, active: () => props.active !== false, next: props.next, + scriptDiffs: () => data.flag("full_codemode"), }) const tail = props.follow.following() ? controller.data.projection.rows().at(-1) : undefined diff --git a/packages/session-ui/component-tests/session-timeline.spec.ts b/packages/session-ui/component-tests/session-timeline.spec.ts index 116766b0de4..dcae5d66e53 100644 --- a/packages/session-ui/component-tests/session-timeline.spec.ts +++ b/packages/session-ui/component-tests/session-timeline.spec.ts @@ -8,8 +8,11 @@ story("spaces an error between a shell result and expanded updates", async ({ mo const shellBox = (await shell.boundingBox())! const errorBox = (await error.boundingBox())! const updatesBox = (await updates.boundingBox())! + // The row's line of text: its 28px click area reaches 6px above and below it. + const updatesLine = (await updates.locator('[data-component="tool-trigger"]').first().boundingBox())! expect(errorBox.y - (shellBox.y + shellBox.height)).toBe(24) - expect(updatesBox.y - (errorBox.y + errorBox.height)).toBe(8) + // Blocks stand 16px apart, measured from one block's text to the next; a script's own changes keep 8px under it. + expect(updatesLine.y - (errorBox.y + errorBox.height)).toBe(16) expect(updatesBox.x).toBe(errorBox.x) await updates.click() const notice = timeline.locator('[data-slot="session-timeline-notice"]') @@ -17,7 +20,8 @@ story("spaces an error between a shell result and expanded updates", async ({ mo const expandedBox = (await updates.boundingBox())! expect((await notice.boundingBox())!.y - (expandedBox.y + expandedBox.height)).toBe(0) expect((await notice.boundingBox())!.x - expandedBox.x).toBe(24) - expect(expandedBox.height).toBe(28) + // The open header's click area: 6px above its line, the line, then the 16px gap to its first item. + expect(expandedBox.height).toBe(38) }) for (const streaming of [false, true]) { diff --git a/packages/session-ui/src/components/message-part.css b/packages/session-ui/src/components/message-part.css index 2151a873016..079604a4366 100644 --- a/packages/session-ui/src/components/message-part.css +++ b/packages/session-ui/src/components/message-part.css @@ -1065,6 +1065,11 @@ margin-top: 12px; } +/* A script's Output row, after its last change when its changes are drawn right after it, keeps the block's tight gap. */ +[data-script-changes] > [data-script-output] { + margin-top: 8px; +} + [data-component="execute-tool-calls"] { display: flex; flex-direction: column; @@ -1205,6 +1210,32 @@ } } +/* The flat layout (`full_codemode`): steps line up with the title, with no markers before them, and read as steps in + the face of the timeline's titles while what they ran on stays code. Output is muted, as the title is. */ +[data-component="execute-tool-calls"][data-execute-layout="flat"] { + [data-slot="execute-tool-call-name"] { + font-family: var(--v2-font-family-sans); + font-weight: 440; + letter-spacing: -0.04px; + } + + [data-slot="execute-tool-call"][data-kind="output"] [data-slot="execute-tool-call-name"] { + color: var(--v2-text-text-muted); + } + + [data-slot="execute-tool-call-more"], + [data-slot="execute-tool-output"], + [data-slot="execute-tool-error"] { + margin-inline-start: 0; + padding-inline-start: 0; + } +} + +/* A script's title labels the steps under it, so it is muted as the timeline's other labels are. */ +[data-component="collapsible"] [data-slot="basic-tool-tool-title"][data-execute-title] { + color: var(--v2-text-text-muted); +} + [data-slot="execute-tool-call-marker"] [data-slot="icon-svg"] { color: inherit; } @@ -1455,6 +1486,11 @@ flex-direction: column; gap: 8px; + /* An opened group spaces its items as the timeline spaces blocks; a script's changes stay by the script. */ + > [data-slot="context-tool-group-item"] + [data-slot="context-tool-group-item"]:not([data-script-change]) { + margin-top: 8px; + } + [data-slot="context-tool-group-item"] { min-width: 0; min-height: 28px; @@ -2169,3 +2205,59 @@ border-color: var(--v2-border-border-base); color: var(--v2-text-text-faint); } + +/* In the current timeline, as in the New timeline, a block is as tall as its text, so the gaps between blocks are the + gaps that show and every pair of blocks stands the same 16px apart. A row's 28px click area stays: 6px of padding + above and below, taken back by margins of the same size. An open row keeps its header's room above its content. */ +[data-timeline-row="AssistantPart"]:not([data-timeline="next"]) { + [data-component="collapsible"] > [data-slot="collapsible-trigger"] { + box-sizing: border-box; + height: calc(var(--line-height-compact) + 12px); + padding-block: 6px; + margin-block: -6px; + } + + [data-component="collapsible"] > [data-slot="collapsible-trigger"]:is([aria-expanded="true"], [data-locked]) { + margin-bottom: 0; + } + + /* An open group's header stands as far above its first item as blocks stand apart. */ + [data-component="collapsed-tool-group"] + > [data-component="collapsible"] + > [data-slot="collapsible-trigger"][aria-expanded="true"] { + height: calc(var(--line-height-compact) + 22px); + padding-bottom: 16px; + } + + [data-component="context-tool-group-list"] [data-slot="context-tool-group-item"] { + min-height: var(--line-height-compact); + } + + /* A row's action stays centred on its click area, which reaches 6px above the row, without making the row taller. */ + [data-component="collapsible"] > [data-slot="basic-tool-action"] { + margin-top: -4px; + } + + /* The flat layout (`full_codemode`): a script's title's text sits above its first call's text as far as one call's + text sits above the next, as in the New timeline. */ + [data-component="collapsible"].tool-collapsible:has( + > [data-slot="collapsible-content"] > [data-component="execute-tool-calls"][data-execute-layout="flat"] + ) { + row-gap: 0; + + > [data-slot="collapsible-trigger"][data-locked] { + --execute-title-gap: calc(6px + (var(--line-height-base) - var(--line-height-compact)) / 2); + padding-bottom: var(--execute-title-gap); + height: calc(var(--line-height-compact) + 6px + var(--execute-title-gap)); + + [data-slot="basic-tool-tool-info"] { + line-height: var(--line-height-compact); + } + } + + /* The title's row holds the gap below its text, so the View code button sits at its top, centred on the text. */ + > [data-slot="basic-tool-action"] { + align-self: flex-start; + } + } +} diff --git a/packages/session-ui/src/storybook/codemode-snapshots/appends.json b/packages/session-ui/src/storybook/codemode-snapshots/appends.json new file mode 100644 index 00000000000..9d70d085415 --- /dev/null +++ b/packages/session-ui/src/storybook/codemode-snapshots/appends.json @@ -0,0 +1 @@ +{"session":{"id":"ses_decc9e6a8ffe3CN0kwa8l8ay2a","title":"appends","directory":"/repo","time":{"created":1795618642265,"updated":1795618642265}},"messages":{"data":[{"id":"msg_2133619b90013n4jxonwVlPk6R","time":{"created":1795618642361},"type":"idle","outcome":"succeeded"},{"id":"msg_2133619a5001cAiPt07xZvJ7y2","time":{"created":1795618642344,"firstToken":1795618642350,"streamed":1795618642356,"completed":1795618642357},"type":"assistant","agent":"build","model":{"id":"claude-opus-5-5","providerID":"simulation","variant":"default"},"content":[{"type":"text","text":"Done appends (1)."}],"finish":"stop","rawFinish":"stop","cost":0,"tokens":{"input":0,"output":0,"reasoning":0,"cache":{"read":0,"write":0}}},{"id":"msg_21336196e001Q9ldBk3Nl3Y0E3","time":{"created":1795618642289,"firstToken":1795618642298,"streamed":1795618642312,"completed":1795618642332},"type":"assistant","agent":"build","model":{"id":"claude-opus-5-5","providerID":"simulation","variant":"default"},"content":[{"type":"text","text":"Running appends."},{"type":"tool","id":"call_appends","name":"execute","executed":false,"state":{"status":"completed","input":{"code":"const w = Bun.file(\"/repo/files/log.txt\").writer()\nw.write('first\\n'); await w.flush()\nw.write('second\\nthird\\n'); await w.flush(); await w.end()\nawait Bun.write(\"/repo/files/logo.png\", new Uint8Array([137,80,78,71,13,10,26,10,0,0,0,13,255,0,1]))\nawait Bun.write(\"/repo/files/src/copy-dest.ts\", Bun.file(\"/repo/files/src/copy-src.ts\"))\nreturn 'ok'"},"content":[{"type":"text","text":"ok"}],"metadata":{"toolCalls":[{"tool":"Bun","status":"completed","input":{"method":"file","path":"/repo/files/log.txt"}},{"tool":"Bun","status":"completed","input":{"method":"write","path":"/repo/files/logo.png"}},{"tool":"Bun","status":"completed","input":{"method":"file","path":"/repo/files/src/copy-src.ts"}},{"tool":"Bun","status":"completed","input":{"method":"write","path":"/repo/files/src/copy-dest.ts","from":"/repo/files/src/copy-src.ts"}}],"files":[{"file":"files/log.txt","status":"added","additions":1,"deletions":0,"patch":"Index: files/log.txt\n===================================================================\n--- files/log.txt\n+++ files/log.txt\n@@ -0,0 +1,1 @@\n+first\n"},{"file":"files/log.txt","status":"modified","additions":2,"deletions":0},{"file":"files/logo.png","status":"modified"},{"file":"files/src/copy-dest.ts","status":"added"}],"truncated":false}},"time":{"created":1795618642303,"ran":1795618642309,"completed":1795618642330}}],"finish":"tool-calls","rawFinish":"tool_calls","cost":0,"tokens":{"input":0,"output":0,"reasoning":0,"cache":{"read":0,"write":0}}},{"id":"msg_21336195d001cbbVEfFObhyCBi","time":{"created":1795618642279},"text":"SCN:appends please","type":"user"}],"cursor":{"previous":"eyJpZCI6Im1zZ18yMTMzNjE5YjkwMDEzbjRqeG9ud1ZsUGs2UiIsIm9yZGVyIjoiZGVzYyIsImRpcmVjdGlvbiI6InByZXZpb3VzIn0","next":"eyJpZCI6Im1zZ18yMTMzNjE5NWQwMDFjYmJWRWZGT2JoeUNCaSIsIm9yZGVyIjoiZGVzYyIsImRpcmVjdGlvbiI6Im5leHQifQ"}},"states":[{"file":"00-execute-appends-called.json","reason":"called","at":1795618642309,"eventIndex":11,"part":{"type":"tool","id":"call_appends","name":"execute","time":{"created":1795618642303,"ran":1795618642309},"state":{"status":"running","input":{"code":"const w = Bun.file(\"/repo/files/log.txt\").writer()\nw.write('first\\n'); await w.flush()\nw.write('second\\nthird\\n'); await w.flush(); await w.end()\nawait Bun.write(\"/repo/files/logo.png\", new Uint8Array([137,80,78,71,13,10,26,10,0,0,0,13,255,0,1]))\nawait Bun.write(\"/repo/files/src/copy-dest.ts\", Bun.file(\"/repo/files/src/copy-src.ts\"))\nreturn 'ok'"},"metadata":{}},"executed":false}},{"file":"01-execute-appends-first-progress.json","reason":"first-progress","at":1795618642314,"eventIndex":14,"part":{"type":"tool","id":"call_appends","name":"execute","time":{"created":1795618642303,"ran":1795618642309},"state":{"status":"running","input":{"code":"const w = Bun.file(\"/repo/files/log.txt\").writer()\nw.write('first\\n'); await w.flush()\nw.write('second\\nthird\\n'); await w.flush(); await w.end()\nawait Bun.write(\"/repo/files/logo.png\", new Uint8Array([137,80,78,71,13,10,26,10,0,0,0,13,255,0,1]))\nawait Bun.write(\"/repo/files/src/copy-dest.ts\", Bun.file(\"/repo/files/src/copy-src.ts\"))\nreturn 'ok'"},"metadata":{"background":true}},"executed":false}},{"file":"02-execute-appends-progress.json","reason":"progress","at":1795618642317,"eventIndex":15,"part":{"type":"tool","id":"call_appends","name":"execute","time":{"created":1795618642303,"ran":1795618642309},"state":{"status":"running","input":{"code":"const w = Bun.file(\"/repo/files/log.txt\").writer()\nw.write('first\\n'); await w.flush()\nw.write('second\\nthird\\n'); await w.flush(); await w.end()\nawait Bun.write(\"/repo/files/logo.png\", new Uint8Array([137,80,78,71,13,10,26,10,0,0,0,13,255,0,1]))\nawait Bun.write(\"/repo/files/src/copy-dest.ts\", Bun.file(\"/repo/files/src/copy-src.ts\"))\nreturn 'ok'"},"metadata":{"toolCalls":[{"tool":"Bun","status":"running","input":{"method":"file","path":"/repo/files/log.txt"}}],"background":true}},"executed":false}},{"file":"03-execute-appends-final.json","reason":"final","at":1795618642330,"eventIndex":16,"part":{"type":"tool","id":"call_appends","name":"execute","time":{"created":1795618642303,"ran":1795618642309,"completed":1795618642330},"state":{"status":"completed","input":{"code":"const w = Bun.file(\"/repo/files/log.txt\").writer()\nw.write('first\\n'); await w.flush()\nw.write('second\\nthird\\n'); await w.flush(); await w.end()\nawait Bun.write(\"/repo/files/logo.png\", new Uint8Array([137,80,78,71,13,10,26,10,0,0,0,13,255,0,1]))\nawait Bun.write(\"/repo/files/src/copy-dest.ts\", Bun.file(\"/repo/files/src/copy-src.ts\"))\nreturn 'ok'"},"metadata":{"toolCalls":[{"tool":"Bun","status":"completed","input":{"method":"file","path":"/repo/files/log.txt"}},{"tool":"Bun","status":"completed","input":{"method":"write","path":"/repo/files/logo.png"}},{"tool":"Bun","status":"completed","input":{"method":"file","path":"/repo/files/src/copy-src.ts"}},{"tool":"Bun","status":"completed","input":{"method":"write","path":"/repo/files/src/copy-dest.ts","from":"/repo/files/src/copy-src.ts"}}],"files":[{"file":"files/log.txt","status":"added","additions":1,"deletions":0,"patch":"Index: files/log.txt\n===================================================================\n--- files/log.txt\n+++ files/log.txt\n@@ -0,0 +1,1 @@\n+first\n"},{"file":"files/log.txt","status":"modified","additions":2,"deletions":0},{"file":"files/logo.png","status":"modified"},{"file":"files/src/copy-dest.ts","status":"added"}],"truncated":false},"content":[{"type":"text","text":"ok"}]},"executed":false}}]} diff --git a/packages/session-ui/src/storybook/codemode-snapshots/backgrounded.json b/packages/session-ui/src/storybook/codemode-snapshots/backgrounded.json new file mode 100644 index 00000000000..a295c82361c --- /dev/null +++ b/packages/session-ui/src/storybook/codemode-snapshots/backgrounded.json @@ -0,0 +1 @@ +{"session":{"id":"ses_decc9ddbdffeIFo6sze1ens4aq","title":"backgrounded","directory":"/repo","time":{"created":1795618644548,"updated":1795618644548}},"messages":{"data":[{"id":"msg_213362e80001J3vTgrl5u1oPNf","time":{"created":1795618647680},"type":"idle","outcome":"succeeded"},{"id":"msg_213362e61001CD0yLchvRs39Dr","time":{"created":1795618647652,"firstToken":1795618647659,"streamed":1795618647674,"completed":1795618647676},"type":"assistant","agent":"build","model":{"id":"claude-opus-5-5","providerID":"simulation","variant":"default"},"content":[{"type":"text","text":"Done backgrounded (1)."}],"finish":"stop","rawFinish":"stop","cost":0,"tokens":{"input":0,"output":0,"reasoning":0,"cache":{"read":0,"write":0}}},{"id":"msg_213362271001Fo2ADVK4nZYxIA","metadata":{"source":"codemode","jobID":"cm_21336226d001kpfiJEHq4Afa1u","state":"completed"},"time":{"created":1795618647644},"text":"\nbackground done\n","description":"Script","type":"synthetic"},{"id":"msg_213362297001CiYiH6TmxpeC3Q","time":{"created":1795618644631},"type":"idle","outcome":"succeeded"},{"id":"msg_21336227c001cOE5LI16Gl28a2","time":{"created":1795618644607,"firstToken":1795618644618,"streamed":1795618644625,"completed":1795618644626},"type":"assistant","agent":"build","model":{"id":"claude-opus-5-5","providerID":"simulation","variant":"default"},"content":[{"type":"text","text":"Done backgrounded (1)."}],"finish":"stop","rawFinish":"stop","cost":0,"tokens":{"input":0,"output":0,"reasoning":0,"cache":{"read":0,"write":0}}},{"id":"msg_213362256001eB9sB3Emppf74O","time":{"created":1795618644568,"firstToken":1795618644576,"streamed":1795618644588,"completed":1795618644595},"type":"assistant","agent":"build","model":{"id":"claude-opus-5-5","providerID":"simulation","variant":"default"},"content":[{"type":"text","text":"Running backgrounded."},{"type":"tool","id":"call_backgrounded","name":"execute","executed":false,"state":{"status":"completed","input":{"code":"await Bun.write(\"/repo/files/src/bg-1.ts\", 'export const bg = 1\\n')\nawait tools.shell({ command: 'sleep 3' })\nawait Bun.write(\"/repo/files/src/bg-2.ts\", 'export const bg = 2\\n')\nreturn 'background done'","background":true},"content":[{"type":"text","text":"Script cm_21336226d001kpfiJEHq4Afa1u is still running; its result will arrive in this session."}],"metadata":{"jobID":"cm_21336226d001kpfiJEHq4Afa1u","truncated":false}},"time":{"created":1795618644581,"ran":1795618644586,"completed":1795618644594}}],"finish":"tool-calls","rawFinish":"tool_calls","cost":0,"tokens":{"input":0,"output":0,"reasoning":0,"cache":{"read":0,"write":0}}},{"id":"msg_213362248001YRixmHgGWQ4JRi","time":{"created":1795618644562},"text":"SCN:backgrounded please","type":"user"}],"cursor":{"previous":"eyJpZCI6Im1zZ18yMTMzNjJlODAwMDFKM3ZUZ3JsNXUxb1BOZiIsIm9yZGVyIjoiZGVzYyIsImRpcmVjdGlvbiI6InByZXZpb3VzIn0","next":"eyJpZCI6Im1zZ18yMTMzNjIyNDgwMDFZUml4bUhnR1dRNEpSaSIsIm9yZGVyIjoiZGVzYyIsImRpcmVjdGlvbiI6Im5leHQifQ"}},"states":[{"file":"00-execute-backgrounded-called.json","reason":"called","at":1795618644586,"eventIndex":11,"part":{"type":"tool","id":"call_backgrounded","name":"execute","time":{"created":1795618644581,"ran":1795618644586},"state":{"status":"running","input":{"code":"await Bun.write(\"/repo/files/src/bg-1.ts\", 'export const bg = 1\\n')\nawait tools.shell({ command: 'sleep 3' })\nawait Bun.write(\"/repo/files/src/bg-2.ts\", 'export const bg = 2\\n')\nreturn 'background done'","background":true},"metadata":{}},"executed":false}},{"file":"01-execute-backgrounded-first-progress.json","reason":"first-progress","at":1795618644589,"eventIndex":14,"part":{"type":"tool","id":"call_backgrounded","name":"execute","time":{"created":1795618644581,"ran":1795618644586},"state":{"status":"running","input":{"code":"await Bun.write(\"/repo/files/src/bg-1.ts\", 'export const bg = 1\\n')\nawait tools.shell({ command: 'sleep 3' })\nawait Bun.write(\"/repo/files/src/bg-2.ts\", 'export const bg = 2\\n')\nreturn 'background done'","background":true},"metadata":{"background":true}},"executed":false}},{"file":"02-execute-backgrounded-progress.json","reason":"progress","at":1795618644592,"eventIndex":15,"part":{"type":"tool","id":"call_backgrounded","name":"execute","time":{"created":1795618644581,"ran":1795618644586},"state":{"status":"running","input":{"code":"await Bun.write(\"/repo/files/src/bg-1.ts\", 'export const bg = 1\\n')\nawait tools.shell({ command: 'sleep 3' })\nawait Bun.write(\"/repo/files/src/bg-2.ts\", 'export const bg = 2\\n')\nreturn 'background done'","background":true},"metadata":{"toolCalls":[{"tool":"Bun","status":"running","input":{"method":"write","path":"/repo/files/src/bg-1.ts"}}],"background":true}},"executed":false}},{"file":"03-execute-backgrounded-final.json","reason":"final","at":1795618644594,"eventIndex":17,"part":{"type":"tool","id":"call_backgrounded","name":"execute","time":{"created":1795618644581,"ran":1795618644586,"completed":1795618644594},"state":{"status":"completed","input":{"code":"await Bun.write(\"/repo/files/src/bg-1.ts\", 'export const bg = 1\\n')\nawait tools.shell({ command: 'sleep 3' })\nawait Bun.write(\"/repo/files/src/bg-2.ts\", 'export const bg = 2\\n')\nreturn 'background done'","background":true},"metadata":{"jobID":"cm_21336226d001kpfiJEHq4Afa1u","truncated":false},"content":[{"type":"text","text":"Script cm_21336226d001kpfiJEHq4Afa1u is still running; its result will arrive in this session."}]},"executed":false}}]} diff --git a/packages/session-ui/src/storybook/codemode-snapshots/direct-patch.json b/packages/session-ui/src/storybook/codemode-snapshots/direct-patch.json new file mode 100644 index 00000000000..14cfe5aaa9d --- /dev/null +++ b/packages/session-ui/src/storybook/codemode-snapshots/direct-patch.json @@ -0,0 +1 @@ +{"session":{"id":"ses_decc8ef55ffeCsZyo21veFduRH","title":"direct-patch","directory":"/repo","time":{"created":1795618705579,"updated":1795618705579}},"messages":{"data":[{"id":"msg_21337113a001jJJFHTGE5Px7q5","time":{"created":1795618705722},"type":"idle","outcome":"succeeded"},{"id":"msg_2133711170014oWvs670LqgXWY","time":{"created":1795618705691,"firstToken":1795618705702,"streamed":1795618705714,"completed":1795618705716},"type":"assistant","agent":"build","model":{"id":"gpt-5","providerID":"simulation","variant":"default"},"content":[{"type":"text","text":"Done direct-patch."}],"finish":"stop","rawFinish":"stop","cost":0,"tokens":{"input":0,"output":0,"reasoning":0,"cache":{"read":0,"write":0}}},{"id":"msg_2133710ea001aA9EtBrpCreWme","time":{"created":1795618705646,"firstToken":1795618705658,"streamed":1795618705667,"completed":1795618705675},"type":"assistant","agent":"build","model":{"id":"gpt-5","providerID":"simulation","variant":"default"},"content":[{"type":"tool","id":"call_direct-patch_1","name":"patch","executed":false,"state":{"status":"completed","input":{"patchText":"*** Begin Patch\n*** Update File: /repo/files/src/app.ts\n@@\n-export const v20 = 20\n+export const v20 = 2000\n*** End Patch"},"content":[{"type":"text","text":"Success. Updated the following files:\nM files/src/app.ts"}],"metadata":{"files":[{"file":"files/src/app.ts","patch":"Index: /repo/files/src/app.ts\n===================================================================\n--- /repo/files/src/app.ts\n+++ /repo/files/src/app.ts\n@@ -17,9 +17,9 @@\n export const v16 = 16\n export const v17 = 17\n export const v18 = 18\n export const v19 = 19\n-export const v20 = 20\n+export const v20 = 2000\n export const v21 = 21\n export const v22 = 22\n export const v23 = 23\n export const v24 = 24\n","status":"modified","additions":1,"deletions":1}],"truncated":false}},"time":{"created":1795618705660,"ran":1795618705665,"completed":1795618705673}}],"finish":"tool-calls","rawFinish":"tool_calls","cost":0,"tokens":{"input":0,"output":0,"reasoning":0,"cache":{"read":0,"write":0}}},{"id":"msg_2133710c1001zPWKCAkzqoQlu3","time":{"created":1795618705604,"firstToken":1795618705614,"streamed":1795618705622,"completed":1795618705633},"type":"assistant","agent":"build","model":{"id":"gpt-5","providerID":"simulation","variant":"default"},"content":[{"type":"tool","id":"call_direct-patch_0","name":"patch","executed":false,"state":{"status":"completed","input":{"patchText":"*** Begin Patch\n*** Update File: /repo/files/src/app.ts\n@@\n-export const v3 = 3\n+export const v3 = 300\n*** End Patch"},"content":[{"type":"text","text":"Success. Updated the following files:\nM files/src/app.ts"}],"metadata":{"files":[{"file":"files/src/app.ts","patch":"Index: /repo/files/src/app.ts\n===================================================================\n--- /repo/files/src/app.ts\n+++ /repo/files/src/app.ts\n@@ -1,8 +1,8 @@\n export const v0 = 0\n export const v1 = 1\n export const v2 = 2\n-export const v3 = 3\n+export const v3 = 300\n export const v4 = 4\n export const v5 = 55\n export const v6 = 6\n export const v7 = 7\n","status":"modified","additions":1,"deletions":1}],"truncated":false}},"time":{"created":1795618705615,"ran":1795618705620,"completed":1795618705631}}],"finish":"tool-calls","rawFinish":"tool_calls","cost":0,"tokens":{"input":0,"output":0,"reasoning":0,"cache":{"read":0,"write":0}}},{"id":"msg_2133710b0001qg5bGHkQxqhcD3","time":{"created":1795618705596},"text":"SCN:direct-patch please","type":"user"}],"cursor":{"previous":"eyJpZCI6Im1zZ18yMTMzNzExM2EwMDFqSkpGSFRHRTVQeDdxNSIsIm9yZGVyIjoiZGVzYyIsImRpcmVjdGlvbiI6InByZXZpb3VzIn0","next":"eyJpZCI6Im1zZ18yMTMzNzEwYjAwMDFxZzViR0hrUXhxaGNEMyIsIm9yZGVyIjoiZGVzYyIsImRpcmVjdGlvbiI6Im5leHQifQ"}},"states":[{"file":"00-patch-rect-patch_0-called.json","reason":"called","at":1795618705620,"eventIndex":9,"part":{"type":"tool","id":"call_direct-patch_0","name":"patch","time":{"created":1795618705615,"ran":1795618705620},"state":{"status":"running","input":{"patchText":"*** Begin Patch\n*** Update File: /repo/files/src/app.ts\n@@\n-export const v3 = 3\n+export const v3 = 300\n*** End Patch"},"metadata":{}},"executed":false}},{"file":"01-patch-rect-patch_0-final.json","reason":"final","at":1795618705631,"eventIndex":11,"part":{"type":"tool","id":"call_direct-patch_0","name":"patch","time":{"created":1795618705615,"ran":1795618705620,"completed":1795618705631},"state":{"status":"completed","input":{"patchText":"*** Begin Patch\n*** Update File: /repo/files/src/app.ts\n@@\n-export const v3 = 3\n+export const v3 = 300\n*** End Patch"},"metadata":{"files":[{"file":"files/src/app.ts","patch":"Index: /repo/files/src/app.ts\n===================================================================\n--- /repo/files/src/app.ts\n+++ /repo/files/src/app.ts\n@@ -1,8 +1,8 @@\n export const v0 = 0\n export const v1 = 1\n export const v2 = 2\n-export const v3 = 3\n+export const v3 = 300\n export const v4 = 4\n export const v5 = 55\n export const v6 = 6\n export const v7 = 7\n","status":"modified","additions":1,"deletions":1}],"truncated":false},"content":[{"type":"text","text":"Success. Updated the following files:\nM files/src/app.ts"}]},"executed":false}},{"file":"02-patch-rect-patch_1-called.json","reason":"called","at":1795618705665,"eventIndex":18,"part":{"type":"tool","id":"call_direct-patch_1","name":"patch","time":{"created":1795618705660,"ran":1795618705665},"state":{"status":"running","input":{"patchText":"*** Begin Patch\n*** Update File: /repo/files/src/app.ts\n@@\n-export const v20 = 20\n+export const v20 = 2000\n*** End Patch"},"metadata":{}},"executed":false}},{"file":"03-patch-rect-patch_1-final.json","reason":"final","at":1795618705673,"eventIndex":20,"part":{"type":"tool","id":"call_direct-patch_1","name":"patch","time":{"created":1795618705660,"ran":1795618705665,"completed":1795618705673},"state":{"status":"completed","input":{"patchText":"*** Begin Patch\n*** Update File: /repo/files/src/app.ts\n@@\n-export const v20 = 20\n+export const v20 = 2000\n*** End Patch"},"metadata":{"files":[{"file":"files/src/app.ts","patch":"Index: /repo/files/src/app.ts\n===================================================================\n--- /repo/files/src/app.ts\n+++ /repo/files/src/app.ts\n@@ -17,9 +17,9 @@\n export const v16 = 16\n export const v17 = 17\n export const v18 = 18\n export const v19 = 19\n-export const v20 = 20\n+export const v20 = 2000\n export const v21 = 21\n export const v22 = 22\n export const v23 = 23\n export const v24 = 24\n","status":"modified","additions":1,"deletions":1}],"truncated":false},"content":[{"type":"text","text":"Success. Updated the following files:\nM files/src/app.ts"}]},"executed":false}}]} diff --git a/packages/session-ui/src/storybook/codemode-snapshots/direct.json b/packages/session-ui/src/storybook/codemode-snapshots/direct.json new file mode 100644 index 00000000000..31da0fba31e --- /dev/null +++ b/packages/session-ui/src/storybook/codemode-snapshots/direct.json @@ -0,0 +1 @@ +{"session":{"id":"ses_decc8f3d4ffe2I65hHW2kQLxbp","title":"direct","directory":"/repo","time":{"created":1795618704430,"updated":1795618704430}},"messages":{"data":[{"id":"msg_213370f6f001mmMVlQBi0hkltm","time":{"created":1795618705263},"type":"idle","outcome":"succeeded"},{"id":"msg_213370f53001DwDdJM2XDDGf3w","time":{"created":1795618705238,"firstToken":1795618705247,"streamed":1795618705255,"completed":1795618705256},"type":"assistant","agent":"build","model":{"id":"claude-opus-5-5","providerID":"simulation","variant":"default"},"content":[{"type":"text","text":"Done direct."}],"finish":"stop","rawFinish":"stop","cost":0,"tokens":{"input":0,"output":0,"reasoning":0,"cache":{"read":0,"write":0}}},{"id":"msg_213370f24001M7Rmn8lRkeNXIN","time":{"created":1795618705191,"firstToken":1795618705210,"streamed":1795618705218,"completed":1795618705226},"type":"assistant","agent":"build","model":{"id":"claude-opus-5-5","providerID":"simulation","variant":"default"},"content":[{"type":"tool","id":"call_direct_2","name":"write","executed":false,"state":{"status":"completed","input":{"path":"/repo/files/notes.md","content":"# Notes\n\n- rewritten\n"},"content":[{"type":"text","text":"Wrote file successfully: files/notes.md"}],"metadata":{"truncated":false}},"time":{"created":1795618705211,"ran":1795618705217,"completed":1795618705224}}],"finish":"tool-calls","rawFinish":"tool_calls","cost":0,"tokens":{"input":0,"output":0,"reasoning":0,"cache":{"read":0,"write":0}}},{"id":"msg_213370d97001MJ7NTgCW2Zj6wI","time":{"created":1795618704796,"firstToken":1795618704810,"streamed":1795618705075,"completed":1795618705176},"type":"assistant","agent":"build","model":{"id":"claude-opus-5-5","providerID":"simulation","variant":"default"},"content":[{"type":"tool","id":"call_direct_1","name":"write","executed":false,"state":{"status":"completed","input":{"path":"/repo/files/src/created.ts","content":"export const created = 1\n"},"content":[{"type":"text","text":"Created file successfully: files/src/created.ts"}],"metadata":{"truncated":false}},"time":{"created":1795618704811,"ran":1795618705074,"completed":1795618705174}}],"finish":"tool-calls","rawFinish":"tool_calls","cost":0,"tokens":{"input":0,"output":0,"reasoning":0,"cache":{"read":0,"write":0}}},{"id":"msg_213370d2e0012BtnuABBsZP8t2","time":{"created":1795618704693,"firstToken":1795618704719,"streamed":1795618704744,"completed":1795618704779},"type":"assistant","agent":"build","model":{"id":"claude-opus-5-5","providerID":"simulation","variant":"default"},"content":[{"type":"tool","id":"call_direct_0","name":"edit","executed":false,"state":{"status":"completed","input":{"path":"/repo/files/src/app.ts","oldString":"export const v5 = 5","newString":"export const v5 = 55"},"content":[{"type":"text","text":"Edited files/src/app.ts (1 replacement)"}],"metadata":{"files":[{"file":"files/src/app.ts","patch":"Index: files/src/app.ts\n===================================================================\n--- files/src/app.ts\n+++ files/src/app.ts\n@@ -2,9 +2,9 @@\n export const v1 = 1\n export const v2 = 2\n export const v3 = 3\n export const v4 = 4\n-export const v5 = 5\n+export const v5 = 55\n export const v6 = 6\n export const v7 = 7\n export const v8 = 8\n export const v9 = 9\n","status":"modified","additions":1,"deletions":1}],"truncated":false}},"time":{"created":1795618704722,"ran":1795618704739,"completed":1795618704775}}],"finish":"tool-calls","rawFinish":"tool_calls","cost":0,"tokens":{"input":0,"output":0,"reasoning":0,"cache":{"read":0,"write":0}}},{"id":"msg_213370c71001iSaq2aJdiIqhlV","time":{"created":1795618704666},"text":"SCN:direct please","type":"user"}],"cursor":{"previous":"eyJpZCI6Im1zZ18yMTMzNzBmNmYwMDFtbU1WbFFCaTBoa2x0bSIsIm9yZGVyIjoiZGVzYyIsImRpcmVjdGlvbiI6InByZXZpb3VzIn0","next":"eyJpZCI6Im1zZ18yMTMzNzBjNzEwMDFpU2FxMmFKZGlJcWhsViIsIm9yZGVyIjoiZGVzYyIsImRpcmVjdGlvbiI6Im5leHQifQ"}},"states":[{"file":"00-edit-direct_0-called.json","reason":"called","at":1795618704739,"eventIndex":9,"part":{"type":"tool","id":"call_direct_0","name":"edit","time":{"created":1795618704722,"ran":1795618704739},"state":{"status":"running","input":{"path":"/repo/files/src/app.ts","oldString":"export const v5 = 5","newString":"export const v5 = 55"},"metadata":{}},"executed":false}},{"file":"01-edit-direct_0-final.json","reason":"final","at":1795618704775,"eventIndex":11,"part":{"type":"tool","id":"call_direct_0","name":"edit","time":{"created":1795618704722,"ran":1795618704739,"completed":1795618704775},"state":{"status":"completed","input":{"path":"/repo/files/src/app.ts","oldString":"export const v5 = 5","newString":"export const v5 = 55"},"metadata":{"files":[{"file":"files/src/app.ts","patch":"Index: files/src/app.ts\n===================================================================\n--- files/src/app.ts\n+++ files/src/app.ts\n@@ -2,9 +2,9 @@\n export const v1 = 1\n export const v2 = 2\n export const v3 = 3\n export const v4 = 4\n-export const v5 = 5\n+export const v5 = 55\n export const v6 = 6\n export const v7 = 7\n export const v8 = 8\n export const v9 = 9\n","status":"modified","additions":1,"deletions":1}],"truncated":false},"content":[{"type":"text","text":"Edited files/src/app.ts (1 replacement)"}]},"executed":false}},{"file":"02-write-direct_1-called.json","reason":"called","at":1795618705074,"eventIndex":18,"part":{"type":"tool","id":"call_direct_1","name":"write","time":{"created":1795618704811,"ran":1795618705074},"state":{"status":"running","input":{"path":"/repo/files/src/created.ts","content":"export const created = 1\n"},"metadata":{}},"executed":false}},{"file":"03-write-direct_1-final.json","reason":"final","at":1795618705174,"eventIndex":20,"part":{"type":"tool","id":"call_direct_1","name":"write","time":{"created":1795618704811,"ran":1795618705074,"completed":1795618705174},"state":{"status":"completed","input":{"path":"/repo/files/src/created.ts","content":"export const created = 1\n"},"metadata":{"truncated":false},"content":[{"type":"text","text":"Created file successfully: files/src/created.ts"}]},"executed":false}},{"file":"04-write-direct_2-called.json","reason":"called","at":1795618705217,"eventIndex":27,"part":{"type":"tool","id":"call_direct_2","name":"write","time":{"created":1795618705211,"ran":1795618705217},"state":{"status":"running","input":{"path":"/repo/files/notes.md","content":"# Notes\n\n- rewritten\n"},"metadata":{}},"executed":false}},{"file":"05-write-direct_2-final.json","reason":"final","at":1795618705224,"eventIndex":29,"part":{"type":"tool","id":"call_direct_2","name":"write","time":{"created":1795618705211,"ran":1795618705217,"completed":1795618705224},"state":{"status":"completed","input":{"path":"/repo/files/notes.md","content":"# Notes\n\n- rewritten\n"},"metadata":{"truncated":false},"content":[{"type":"text","text":"Wrote file successfully: files/notes.md"}]},"executed":false}}]} diff --git a/packages/session-ui/src/storybook/codemode-snapshots/edits-editwrite.json b/packages/session-ui/src/storybook/codemode-snapshots/edits-editwrite.json new file mode 100644 index 00000000000..6f6d7fd1e0a --- /dev/null +++ b/packages/session-ui/src/storybook/codemode-snapshots/edits-editwrite.json @@ -0,0 +1 @@ +{"session":{"id":"ses_decc91a3dffePtirAQFYqyw7iI","title":"edits-editwrite","directory":"/repo","time":{"created":1795618694597,"updated":1795618694597}},"messages":{"data":[{"id":"msg_21336e8e8001PDPm12moea1mZG","time":{"created":1795618695400},"type":"idle","outcome":"succeeded"},{"id":"msg_21336e8c7001SafqsbsIQaoZRQ","time":{"created":1795618695370,"firstToken":1795618695380,"streamed":1795618695392,"completed":1795618695393},"type":"assistant","agent":"build","model":{"id":"claude-opus-5-5","providerID":"simulation","variant":"default"},"content":[{"type":"text","text":"Done edits-editwrite (1)."}],"finish":"stop","rawFinish":"stop","cost":0,"tokens":{"input":0,"output":0,"reasoning":0,"cache":{"read":0,"write":0}}},{"id":"msg_21336e6c5001Y8ajO9YCHlSgXg","time":{"created":1795618694860,"firstToken":1795618694883,"streamed":1795618695154,"completed":1795618695351},"type":"assistant","agent":"build","model":{"id":"claude-opus-5-5","providerID":"simulation","variant":"default"},"content":[{"type":"text","text":"Running edits-editwrite."},{"type":"tool","id":"call_edits_editwrite","name":"execute","executed":false,"state":{"status":"completed","input":{"code":"await tools.edit({ path: \"/repo/files/src/app.ts\", oldString: 'export const v5 = 5', newString: 'export const v5 = 55' })\nawait tools.write({ path: \"/repo/files/src/created.ts\", content: 'export const created = 1\\n' })\nawait tools.write({ path: \"/repo/files/notes.md\", content: '# Notes\\n\\n- rewritten\\n' })\nawait Bun.write(\"/repo/files/src/new.ts\", 'export const fresh = 1\\n')\nawait Bun.file(\"/repo/files/old.txt\").delete()\nreturn 'ok'"},"content":[{"type":"text","text":"ok"}],"metadata":{"toolCalls":[{"tool":"edit","status":"completed","input":{"path":"/repo/files/src/app.ts","oldString":"export const v5 = 5","newString":"export const v5 = 55"}},{"tool":"write","status":"completed","input":{"path":"/repo/files/src/created.ts","content":"export const created = 1\n"}},{"tool":"write","status":"completed","input":{"path":"/repo/files/notes.md","content":"# Notes\n\n- rewritten\n"}},{"tool":"Bun","status":"completed","input":{"method":"write","path":"/repo/files/src/new.ts"}},{"tool":"Bun","status":"completed","input":{"method":"file","path":"/repo/files/old.txt"}}],"files":[{"file":"files/src/app.ts","additions":1,"deletions":1,"patch":"Index: files/src/app.ts\n===================================================================\n--- files/src/app.ts\n+++ files/src/app.ts\n@@ -2,9 +2,9 @@\n export const v1 = 1\n export const v2 = 2\n export const v3 = 3\n export const v4 = 4\n-export const v5 = 5\n+export const v5 = 55\n export const v6 = 6\n export const v7 = 7\n export const v8 = 8\n export const v9 = 9\n","status":"modified"},{"file":"files/src/created.ts","status":"added","additions":1,"deletions":0,"patch":"Index: files/src/created.ts\n===================================================================\n--- files/src/created.ts\n+++ files/src/created.ts\n@@ -0,0 +1,1 @@\n+export const created = 1\n"},{"file":"files/notes.md","status":"modified"},{"file":"files/src/new.ts","status":"added","additions":1,"deletions":0,"patch":"Index: files/src/new.ts\n===================================================================\n--- files/src/new.ts\n+++ files/src/new.ts\n@@ -0,0 +1,1 @@\n+export const fresh = 1\n"},{"file":"files/old.txt","status":"deleted"}],"truncated":false}},"time":{"created":1795618695140,"ran":1795618695149,"completed":1795618695348}}],"finish":"tool-calls","rawFinish":"tool_calls","cost":0,"tokens":{"input":0,"output":0,"reasoning":0,"cache":{"read":0,"write":0}}},{"id":"msg_21336e601001i9FoOvKGfTBXS1","time":{"created":1795618694833},"text":"SCN:edits-editwrite please","type":"user"}],"cursor":{"previous":"eyJpZCI6Im1zZ18yMTMzNmU4ZTgwMDFQRFBtMTJtb2VhMW1aRyIsIm9yZGVyIjoiZGVzYyIsImRpcmVjdGlvbiI6InByZXZpb3VzIn0","next":"eyJpZCI6Im1zZ18yMTMzNmU2MDEwMDFpOUZvT3ZLR2ZUQlhTMSIsIm9yZGVyIjoiZGVzYyIsImRpcmVjdGlvbiI6Im5leHQifQ"}},"states":[{"file":"00-execute-ts_editwrite-called.json","reason":"called","at":1795618695149,"eventIndex":10,"part":{"type":"tool","id":"call_edits_editwrite","name":"execute","time":{"created":1795618695140,"ran":1795618695149},"state":{"status":"running","input":{"code":"await tools.edit({ path: \"/repo/files/src/app.ts\", oldString: 'export const v5 = 5', newString: 'export const v5 = 55' })\nawait tools.write({ path: \"/repo/files/src/created.ts\", content: 'export const created = 1\\n' })\nawait tools.write({ path: \"/repo/files/notes.md\", content: '# Notes\\n\\n- rewritten\\n' })\nawait Bun.write(\"/repo/files/src/new.ts\", 'export const fresh = 1\\n')\nawait Bun.file(\"/repo/files/old.txt\").delete()\nreturn 'ok'"},"metadata":{}},"executed":false}},{"file":"01-execute-ts_editwrite-first-progress.json","reason":"first-progress","at":1795618695241,"eventIndex":13,"part":{"type":"tool","id":"call_edits_editwrite","name":"execute","time":{"created":1795618695140,"ran":1795618695149},"state":{"status":"running","input":{"code":"await tools.edit({ path: \"/repo/files/src/app.ts\", oldString: 'export const v5 = 5', newString: 'export const v5 = 55' })\nawait tools.write({ path: \"/repo/files/src/created.ts\", content: 'export const created = 1\\n' })\nawait tools.write({ path: \"/repo/files/notes.md\", content: '# Notes\\n\\n- rewritten\\n' })\nawait Bun.write(\"/repo/files/src/new.ts\", 'export const fresh = 1\\n')\nawait Bun.file(\"/repo/files/old.txt\").delete()\nreturn 'ok'"},"metadata":{"background":true}},"executed":false}},{"file":"02-execute-ts_editwrite-progress.json","reason":"progress","at":1795618695287,"eventIndex":14,"part":{"type":"tool","id":"call_edits_editwrite","name":"execute","time":{"created":1795618695140,"ran":1795618695149},"state":{"status":"running","input":{"code":"await tools.edit({ path: \"/repo/files/src/app.ts\", oldString: 'export const v5 = 5', newString: 'export const v5 = 55' })\nawait tools.write({ path: \"/repo/files/src/created.ts\", content: 'export const created = 1\\n' })\nawait tools.write({ path: \"/repo/files/notes.md\", content: '# Notes\\n\\n- rewritten\\n' })\nawait Bun.write(\"/repo/files/src/new.ts\", 'export const fresh = 1\\n')\nawait Bun.file(\"/repo/files/old.txt\").delete()\nreturn 'ok'"},"metadata":{"toolCalls":[{"tool":"edit","status":"running","input":{"path":"/repo/files/src/app.ts","oldString":"export const v5 = 5","newString":"export const v5 = 55"}}],"background":true}},"executed":false}},{"file":"03-execute-ts_editwrite-final.json","reason":"final","at":1795618695348,"eventIndex":15,"part":{"type":"tool","id":"call_edits_editwrite","name":"execute","time":{"created":1795618695140,"ran":1795618695149,"completed":1795618695348},"state":{"status":"completed","input":{"code":"await tools.edit({ path: \"/repo/files/src/app.ts\", oldString: 'export const v5 = 5', newString: 'export const v5 = 55' })\nawait tools.write({ path: \"/repo/files/src/created.ts\", content: 'export const created = 1\\n' })\nawait tools.write({ path: \"/repo/files/notes.md\", content: '# Notes\\n\\n- rewritten\\n' })\nawait Bun.write(\"/repo/files/src/new.ts\", 'export const fresh = 1\\n')\nawait Bun.file(\"/repo/files/old.txt\").delete()\nreturn 'ok'"},"metadata":{"toolCalls":[{"tool":"edit","status":"completed","input":{"path":"/repo/files/src/app.ts","oldString":"export const v5 = 5","newString":"export const v5 = 55"}},{"tool":"write","status":"completed","input":{"path":"/repo/files/src/created.ts","content":"export const created = 1\n"}},{"tool":"write","status":"completed","input":{"path":"/repo/files/notes.md","content":"# Notes\n\n- rewritten\n"}},{"tool":"Bun","status":"completed","input":{"method":"write","path":"/repo/files/src/new.ts"}},{"tool":"Bun","status":"completed","input":{"method":"file","path":"/repo/files/old.txt"}}],"files":[{"file":"files/src/app.ts","additions":1,"deletions":1,"patch":"Index: files/src/app.ts\n===================================================================\n--- files/src/app.ts\n+++ files/src/app.ts\n@@ -2,9 +2,9 @@\n export const v1 = 1\n export const v2 = 2\n export const v3 = 3\n export const v4 = 4\n-export const v5 = 5\n+export const v5 = 55\n export const v6 = 6\n export const v7 = 7\n export const v8 = 8\n export const v9 = 9\n","status":"modified"},{"file":"files/src/created.ts","status":"added","additions":1,"deletions":0,"patch":"Index: files/src/created.ts\n===================================================================\n--- files/src/created.ts\n+++ files/src/created.ts\n@@ -0,0 +1,1 @@\n+export const created = 1\n"},{"file":"files/notes.md","status":"modified"},{"file":"files/src/new.ts","status":"added","additions":1,"deletions":0,"patch":"Index: files/src/new.ts\n===================================================================\n--- files/src/new.ts\n+++ files/src/new.ts\n@@ -0,0 +1,1 @@\n+export const fresh = 1\n"},{"file":"files/old.txt","status":"deleted"}],"truncated":false},"content":[{"type":"text","text":"ok"}]},"executed":false}}]} diff --git a/packages/session-ui/src/storybook/codemode-snapshots/edits-patch.json b/packages/session-ui/src/storybook/codemode-snapshots/edits-patch.json new file mode 100644 index 00000000000..810885f223b --- /dev/null +++ b/packages/session-ui/src/storybook/codemode-snapshots/edits-patch.json @@ -0,0 +1 @@ +{"session":{"id":"ses_decc9ece5ffeHRUwh60let08bm","title":"edits-patch","directory":"/repo","time":{"created":1795618640670,"updated":1795618640670}},"messages":{"data":[{"id":"msg_213361648001WE16dbCd7m5A7S","time":{"created":1795618641480},"type":"idle","outcome":"succeeded"},{"id":"msg_21336162d001yvDdr2fq0UteXW","time":{"created":1795618641456,"firstToken":1795618641465,"streamed":1795618641472,"completed":1795618641473},"type":"assistant","agent":"build","model":{"id":"gpt-5","providerID":"simulation","variant":"default"},"content":[{"type":"text","text":"Done edits-patch (1)."}],"finish":"stop","rawFinish":"stop","cost":0,"tokens":{"input":0,"output":0,"reasoning":0,"cache":{"read":0,"write":0}}},{"id":"msg_21336141f001YVX1PLR5xDTkp2","time":{"created":1795618640934,"firstToken":1795618640965,"streamed":1795618641021,"completed":1795618641355},"type":"assistant","agent":"build","model":{"id":"gpt-5","providerID":"simulation","variant":"default"},"content":[{"type":"text","text":"Running edits-patch."},{"type":"tool","id":"call_edits_patch","name":"execute","executed":false,"state":{"status":"completed","input":{"code":"await tools.patch({ patchText: \"*** Begin Patch\\n*** Update File: /repo/files/src/app.ts\\n@@\\n-export const v3 = 3\\n+export const v3 = 300\\n*** End Patch\" })\nawait tools.patch({ patchText: \"*** Begin Patch\\n*** Update File: /repo/files/src/app.ts\\n@@\\n-export const v20 = 20\\n+export const v20 = 2000\\n*** End Patch\" })\nawait Bun.write(\"/repo/files/src/new.ts\", 'export const fresh = 1\\n')\nawait Bun.file(\"/repo/files/old.txt\").delete()\nreturn 'ok'"},"content":[{"type":"text","text":"ok"}],"metadata":{"toolCalls":[{"tool":"patch","status":"completed","input":{"patchText":"*** Begin Patch\n*** Update File: /repo/files/src/app.ts\n@@\n-export const v3 = 3\n+export const v3 = 300\n*** End Patch"}},{"tool":"patch","status":"completed","input":{"patchText":"*** Begin Patch\n*** Update File: /repo/files/src/app.ts\n@@\n-export const v20 = 20\n+export const v20 = 2000\n*** End Patch"}},{"tool":"Bun","status":"completed","input":{"method":"write","path":"/repo/files/src/new.ts"}},{"tool":"Bun","status":"completed","input":{"method":"file","path":"/repo/files/old.txt"}}],"files":[{"file":"files/src/app.ts","additions":1,"deletions":1,"patch":"Index: /repo/files/src/app.ts\n===================================================================\n--- /repo/files/src/app.ts\n+++ /repo/files/src/app.ts\n@@ -1,8 +1,8 @@\n export const v0 = 0\n export const v1 = 1\n export const v2 = 2\n-export const v3 = 3\n+export const v3 = 300\n export const v4 = 4\n export const v5 = 5\n export const v6 = 6\n export const v7 = 7\n","status":"modified"},{"file":"files/src/app.ts","additions":1,"deletions":1,"patch":"Index: /repo/files/src/app.ts\n===================================================================\n--- /repo/files/src/app.ts\n+++ /repo/files/src/app.ts\n@@ -17,9 +17,9 @@\n export const v16 = 16\n export const v17 = 17\n export const v18 = 18\n export const v19 = 19\n-export const v20 = 20\n+export const v20 = 2000\n export const v21 = 21\n export const v22 = 22\n export const v23 = 23\n export const v24 = 24\n","status":"modified"},{"file":"files/src/new.ts","status":"added","additions":1,"deletions":0,"patch":"Index: files/src/new.ts\n===================================================================\n--- files/src/new.ts\n+++ files/src/new.ts\n@@ -0,0 +1,1 @@\n+export const fresh = 1\n"},{"file":"files/old.txt","status":"deleted"}],"truncated":false}},"time":{"created":1795618641007,"ran":1795618641016,"completed":1795618641349}}],"finish":"tool-calls","rawFinish":"tool_calls","cost":0,"tokens":{"input":0,"output":0,"reasoning":0,"cache":{"read":0,"write":0}}},{"id":"msg_21336135e0010lB4SmZWvQbMo4","time":{"created":1795618640906},"text":"SCN:edits-patch please","type":"user"}],"cursor":{"previous":"eyJpZCI6Im1zZ18yMTMzNjE2NDgwMDFXRTE2ZGJDZDdtNUE3UyIsIm9yZGVyIjoiZGVzYyIsImRpcmVjdGlvbiI6InByZXZpb3VzIn0","next":"eyJpZCI6Im1zZ18yMTMzNjEzNWUwMDEwbEI0U21aV3ZRYk1vNCIsIm9yZGVyIjoiZGVzYyIsImRpcmVjdGlvbiI6Im5leHQifQ"}},"states":[{"file":"00-execute-edits_patch-called.json","reason":"called","at":1795618641016,"eventIndex":11,"part":{"type":"tool","id":"call_edits_patch","name":"execute","time":{"created":1795618641007,"ran":1795618641016},"state":{"status":"running","input":{"code":"await tools.patch({ patchText: \"*** Begin Patch\\n*** Update File: /repo/files/src/app.ts\\n@@\\n-export const v3 = 3\\n+export const v3 = 300\\n*** End Patch\" })\nawait tools.patch({ patchText: \"*** Begin Patch\\n*** Update File: /repo/files/src/app.ts\\n@@\\n-export const v20 = 20\\n+export const v20 = 2000\\n*** End Patch\" })\nawait Bun.write(\"/repo/files/src/new.ts\", 'export const fresh = 1\\n')\nawait Bun.file(\"/repo/files/old.txt\").delete()\nreturn 'ok'"},"metadata":{}},"executed":false}},{"file":"01-execute-edits_patch-first-progress.json","reason":"first-progress","at":1795618641024,"eventIndex":14,"part":{"type":"tool","id":"call_edits_patch","name":"execute","time":{"created":1795618641007,"ran":1795618641016},"state":{"status":"running","input":{"code":"await tools.patch({ patchText: \"*** Begin Patch\\n*** Update File: /repo/files/src/app.ts\\n@@\\n-export const v3 = 3\\n+export const v3 = 300\\n*** End Patch\" })\nawait tools.patch({ patchText: \"*** Begin Patch\\n*** Update File: /repo/files/src/app.ts\\n@@\\n-export const v20 = 20\\n+export const v20 = 2000\\n*** End Patch\" })\nawait Bun.write(\"/repo/files/src/new.ts\", 'export const fresh = 1\\n')\nawait Bun.file(\"/repo/files/old.txt\").delete()\nreturn 'ok'"},"metadata":{"background":true}},"executed":false}},{"file":"02-execute-edits_patch-progress.json","reason":"progress","at":1795618641068,"eventIndex":15,"part":{"type":"tool","id":"call_edits_patch","name":"execute","time":{"created":1795618641007,"ran":1795618641016},"state":{"status":"running","input":{"code":"await tools.patch({ patchText: \"*** Begin Patch\\n*** Update File: /repo/files/src/app.ts\\n@@\\n-export const v3 = 3\\n+export const v3 = 300\\n*** End Patch\" })\nawait tools.patch({ patchText: \"*** Begin Patch\\n*** Update File: /repo/files/src/app.ts\\n@@\\n-export const v20 = 20\\n+export const v20 = 2000\\n*** End Patch\" })\nawait Bun.write(\"/repo/files/src/new.ts\", 'export const fresh = 1\\n')\nawait Bun.file(\"/repo/files/old.txt\").delete()\nreturn 'ok'"},"metadata":{"toolCalls":[{"tool":"patch","status":"running","input":{"patchText":"*** Begin Patch\n*** Update File: /repo/files/src/app.ts\n@@\n-export const v3 = 3\n+export const v3 = 300\n*** End Patch"}}],"background":true}},"executed":false}},{"file":"03-execute-edits_patch-files-1.json","reason":"files-1","at":1795618641335,"eventIndex":16,"part":{"type":"tool","id":"call_edits_patch","name":"execute","time":{"created":1795618641007,"ran":1795618641016},"state":{"status":"running","input":{"code":"await tools.patch({ patchText: \"*** Begin Patch\\n*** Update File: /repo/files/src/app.ts\\n@@\\n-export const v3 = 3\\n+export const v3 = 300\\n*** End Patch\" })\nawait tools.patch({ patchText: \"*** Begin Patch\\n*** Update File: /repo/files/src/app.ts\\n@@\\n-export const v20 = 20\\n+export const v20 = 2000\\n*** End Patch\" })\nawait Bun.write(\"/repo/files/src/new.ts\", 'export const fresh = 1\\n')\nawait Bun.file(\"/repo/files/old.txt\").delete()\nreturn 'ok'"},"metadata":{"toolCalls":[{"tool":"patch","status":"completed","input":{"patchText":"*** Begin Patch\n*** Update File: /repo/files/src/app.ts\n@@\n-export const v3 = 3\n+export const v3 = 300\n*** End Patch"}},{"tool":"patch","status":"running","input":{"patchText":"*** Begin Patch\n*** Update File: /repo/files/src/app.ts\n@@\n-export const v20 = 20\n+export const v20 = 2000\n*** End Patch"}}],"files":[{"file":"files/src/app.ts","additions":1,"deletions":1,"patch":"Index: /repo/files/src/app.ts\n===================================================================\n--- /repo/files/src/app.ts\n+++ /repo/files/src/app.ts\n@@ -1,8 +1,8 @@\n export const v0 = 0\n export const v1 = 1\n export const v2 = 2\n-export const v3 = 3\n+export const v3 = 300\n export const v4 = 4\n export const v5 = 5\n export const v6 = 6\n export const v7 = 7\n","status":"modified"}],"background":true}},"executed":false}},{"file":"04-execute-edits_patch-final.json","reason":"final","at":1795618641349,"eventIndex":17,"part":{"type":"tool","id":"call_edits_patch","name":"execute","time":{"created":1795618641007,"ran":1795618641016,"completed":1795618641349},"state":{"status":"completed","input":{"code":"await tools.patch({ patchText: \"*** Begin Patch\\n*** Update File: /repo/files/src/app.ts\\n@@\\n-export const v3 = 3\\n+export const v3 = 300\\n*** End Patch\" })\nawait tools.patch({ patchText: \"*** Begin Patch\\n*** Update File: /repo/files/src/app.ts\\n@@\\n-export const v20 = 20\\n+export const v20 = 2000\\n*** End Patch\" })\nawait Bun.write(\"/repo/files/src/new.ts\", 'export const fresh = 1\\n')\nawait Bun.file(\"/repo/files/old.txt\").delete()\nreturn 'ok'"},"metadata":{"toolCalls":[{"tool":"patch","status":"completed","input":{"patchText":"*** Begin Patch\n*** Update File: /repo/files/src/app.ts\n@@\n-export const v3 = 3\n+export const v3 = 300\n*** End Patch"}},{"tool":"patch","status":"completed","input":{"patchText":"*** Begin Patch\n*** Update File: /repo/files/src/app.ts\n@@\n-export const v20 = 20\n+export const v20 = 2000\n*** End Patch"}},{"tool":"Bun","status":"completed","input":{"method":"write","path":"/repo/files/src/new.ts"}},{"tool":"Bun","status":"completed","input":{"method":"file","path":"/repo/files/old.txt"}}],"files":[{"file":"files/src/app.ts","additions":1,"deletions":1,"patch":"Index: /repo/files/src/app.ts\n===================================================================\n--- /repo/files/src/app.ts\n+++ /repo/files/src/app.ts\n@@ -1,8 +1,8 @@\n export const v0 = 0\n export const v1 = 1\n export const v2 = 2\n-export const v3 = 3\n+export const v3 = 300\n export const v4 = 4\n export const v5 = 5\n export const v6 = 6\n export const v7 = 7\n","status":"modified"},{"file":"files/src/app.ts","additions":1,"deletions":1,"patch":"Index: /repo/files/src/app.ts\n===================================================================\n--- /repo/files/src/app.ts\n+++ /repo/files/src/app.ts\n@@ -17,9 +17,9 @@\n export const v16 = 16\n export const v17 = 17\n export const v18 = 18\n export const v19 = 19\n-export const v20 = 20\n+export const v20 = 2000\n export const v21 = 21\n export const v22 = 22\n export const v23 = 23\n export const v24 = 24\n","status":"modified"},{"file":"files/src/new.ts","status":"added","additions":1,"deletions":0,"patch":"Index: files/src/new.ts\n===================================================================\n--- files/src/new.ts\n+++ files/src/new.ts\n@@ -0,0 +1,1 @@\n+export const fresh = 1\n"},{"file":"files/old.txt","status":"deleted"}],"truncated":false},"content":[{"type":"text","text":"ok"}]},"executed":false}}]} diff --git a/packages/session-ui/src/storybook/codemode-snapshots/errors.json b/packages/session-ui/src/storybook/codemode-snapshots/errors.json new file mode 100644 index 00000000000..39d79d37bf9 --- /dev/null +++ b/packages/session-ui/src/storybook/codemode-snapshots/errors.json @@ -0,0 +1 @@ +{"session":{"id":"ses_decc9e290ffeaBjbhhiBUkyTSj","title":"errors","directory":"/repo","time":{"created":1795618643313,"updated":1795618643313}},"messages":{"data":[{"id":"msg_213361dc6001e1g85KPkNk5g45","time":{"created":1795618643398},"type":"idle","outcome":"succeeded"},{"id":"msg_213361db1001HiC3Ys3b6rvsJD","time":{"created":1795618643380,"firstToken":1795618643386,"streamed":1795618643393,"completed":1795618643394},"type":"assistant","agent":"build","model":{"id":"claude-opus-5-5","providerID":"simulation","variant":"default"},"content":[{"type":"text","text":"Done errors (1)."}],"finish":"stop","rawFinish":"stop","cost":0,"tokens":{"input":0,"output":0,"reasoning":0,"cache":{"read":0,"write":0}}},{"id":"msg_213361d82001HMKenyrDbgVXBe","time":{"created":1795618643333,"firstToken":1795618643340,"streamed":1795618643352,"completed":1795618643369},"type":"assistant","agent":"build","model":{"id":"claude-opus-5-5","providerID":"simulation","variant":"default"},"content":[{"type":"text","text":"Running errors."},{"type":"tool","id":"call_errors","name":"execute","executed":false,"state":{"status":"completed","input":{"code":"try { await tools.read({ path: \"/repo/files/missing.txt\" }) } catch (e) { }\nawait Bun.write(\"/repo/files/src/before-throw.ts\", 'export const x = 1\\n')\nawait tools.edit({ path: \"/repo/files/src/app.ts\", oldString: 'export const v7 = 7', newString: 'export const v7 = 77' })\nthrow new Error('boom after changes')"},"content":[{"type":"text","text":"Error: boom after changes"}],"metadata":{"toolCalls":[{"tool":"read","status":"error","input":{"path":"/repo/files/missing.txt"}},{"tool":"Bun","status":"completed","input":{"method":"write","path":"/repo/files/src/before-throw.ts"}},{"tool":"edit","status":"completed","input":{"path":"/repo/files/src/app.ts","oldString":"export const v7 = 7","newString":"export const v7 = 77"}}],"error":true,"files":[{"file":"files/src/before-throw.ts","status":"added","additions":1,"deletions":0,"patch":"Index: files/src/before-throw.ts\n===================================================================\n--- files/src/before-throw.ts\n+++ files/src/before-throw.ts\n@@ -0,0 +1,1 @@\n+export const x = 1\n"},{"file":"files/src/app.ts","additions":1,"deletions":1,"patch":"Index: files/src/app.ts\n===================================================================\n--- files/src/app.ts\n+++ files/src/app.ts\n@@ -4,9 +4,9 @@\n export const v3 = 300\n export const v4 = 4\n export const v5 = 55\n export const v6 = 6\n-export const v7 = 7\n+export const v7 = 77\n export const v8 = 8\n export const v9 = 9\n export const v10 = 10\n export const v11 = 11\n","status":"modified"}],"truncated":false}},"time":{"created":1795618643344,"ran":1795618643350,"completed":1795618643367}}],"finish":"tool-calls","rawFinish":"tool_calls","cost":0,"tokens":{"input":0,"output":0,"reasoning":0,"cache":{"read":0,"write":0}}},{"id":"msg_213361d740014xRF2yKHFIVmHa","time":{"created":1795618643326},"text":"SCN:errors please","type":"user"}],"cursor":{"previous":"eyJpZCI6Im1zZ18yMTMzNjFkYzYwMDFlMWc4NUtQa05rNWc0NSIsIm9yZGVyIjoiZGVzYyIsImRpcmVjdGlvbiI6InByZXZpb3VzIn0","next":"eyJpZCI6Im1zZ18yMTMzNjFkNzQwMDE0eFJGMnlLSEZJVm1IYSIsIm9yZGVyIjoiZGVzYyIsImRpcmVjdGlvbiI6Im5leHQifQ"}},"states":[{"file":"00-execute-errors-called.json","reason":"called","at":1795618643350,"eventIndex":11,"part":{"type":"tool","id":"call_errors","name":"execute","time":{"created":1795618643344,"ran":1795618643350},"state":{"status":"running","input":{"code":"try { await tools.read({ path: \"/repo/files/missing.txt\" }) } catch (e) { }\nawait Bun.write(\"/repo/files/src/before-throw.ts\", 'export const x = 1\\n')\nawait tools.edit({ path: \"/repo/files/src/app.ts\", oldString: 'export const v7 = 7', newString: 'export const v7 = 77' })\nthrow new Error('boom after changes')"},"metadata":{}},"executed":false}},{"file":"01-execute-errors-first-progress.json","reason":"first-progress","at":1795618643353,"eventIndex":14,"part":{"type":"tool","id":"call_errors","name":"execute","time":{"created":1795618643344,"ran":1795618643350},"state":{"status":"running","input":{"code":"try { await tools.read({ path: \"/repo/files/missing.txt\" }) } catch (e) { }\nawait Bun.write(\"/repo/files/src/before-throw.ts\", 'export const x = 1\\n')\nawait tools.edit({ path: \"/repo/files/src/app.ts\", oldString: 'export const v7 = 7', newString: 'export const v7 = 77' })\nthrow new Error('boom after changes')"},"metadata":{"background":true}},"executed":false}},{"file":"02-execute-errors-progress.json","reason":"progress","at":1795618643357,"eventIndex":15,"part":{"type":"tool","id":"call_errors","name":"execute","time":{"created":1795618643344,"ran":1795618643350},"state":{"status":"running","input":{"code":"try { await tools.read({ path: \"/repo/files/missing.txt\" }) } catch (e) { }\nawait Bun.write(\"/repo/files/src/before-throw.ts\", 'export const x = 1\\n')\nawait tools.edit({ path: \"/repo/files/src/app.ts\", oldString: 'export const v7 = 7', newString: 'export const v7 = 77' })\nthrow new Error('boom after changes')"},"metadata":{"toolCalls":[{"tool":"read","status":"running","input":{"path":"/repo/files/missing.txt"}}],"background":true}},"executed":false}},{"file":"03-execute-errors-final.json","reason":"final","at":1795618643367,"eventIndex":16,"part":{"type":"tool","id":"call_errors","name":"execute","time":{"created":1795618643344,"ran":1795618643350,"completed":1795618643367},"state":{"status":"completed","input":{"code":"try { await tools.read({ path: \"/repo/files/missing.txt\" }) } catch (e) { }\nawait Bun.write(\"/repo/files/src/before-throw.ts\", 'export const x = 1\\n')\nawait tools.edit({ path: \"/repo/files/src/app.ts\", oldString: 'export const v7 = 7', newString: 'export const v7 = 77' })\nthrow new Error('boom after changes')"},"metadata":{"toolCalls":[{"tool":"read","status":"error","input":{"path":"/repo/files/missing.txt"}},{"tool":"Bun","status":"completed","input":{"method":"write","path":"/repo/files/src/before-throw.ts"}},{"tool":"edit","status":"completed","input":{"path":"/repo/files/src/app.ts","oldString":"export const v7 = 7","newString":"export const v7 = 77"}}],"error":true,"files":[{"file":"files/src/before-throw.ts","status":"added","additions":1,"deletions":0,"patch":"Index: files/src/before-throw.ts\n===================================================================\n--- files/src/before-throw.ts\n+++ files/src/before-throw.ts\n@@ -0,0 +1,1 @@\n+export const x = 1\n"},{"file":"files/src/app.ts","additions":1,"deletions":1,"patch":"Index: files/src/app.ts\n===================================================================\n--- files/src/app.ts\n+++ files/src/app.ts\n@@ -4,9 +4,9 @@\n export const v3 = 300\n export const v4 = 4\n export const v5 = 55\n export const v6 = 6\n-export const v7 = 7\n+export const v7 = 77\n export const v8 = 8\n export const v9 = 9\n export const v10 = 10\n export const v11 = 11\n","status":"modified"}],"truncated":false},"content":[{"type":"text","text":"Error: boom after changes"}]},"executed":false}}]} diff --git a/packages/session-ui/src/storybook/codemode-snapshots/index.ts b/packages/session-ui/src/storybook/codemode-snapshots/index.ts new file mode 100644 index 00000000000..a96989c525f --- /dev/null +++ b/packages/session-ui/src/storybook/codemode-snapshots/index.ts @@ -0,0 +1,168 @@ +import type { SessionMessageInfo } from "@opencode/client/promise" +import type { SessionDocument } from "../../document" + +/** + * Code Mode `execute` parts captured from real core and server runs (origin/dev 7b8a065e29, and b6973f1b7b for + * `interleaved`; opencode-drive with its simulated model). Each scenario holds `GET /api/session/:id/message` as + * returned (newest first) and the tool part as the client store held it after each event that changed it. The drive run + * directory is shortened to `/repo`, and the 300 KB string literal in `large-patch`'s script is replaced by the + * expression that builds it. + */ +export type CodeModeToolPart = Extract< + Extract["content"][number], + { type: "tool" } +> + +export type CodeModeState = { + file: string + /** `called`, `first-progress`, `progress`, `files-N` or `final`. */ + reason: string + at: number + eventIndex: number + part: CodeModeToolPart +} + +type Capture = { + session: { id: string; title: string; directory: string; time: { created: number; updated: number } } + messages: { data: SessionMessageInfo[]; cursor?: unknown } + states: CodeModeState[] +} + +const captures = new Map( + Object.entries(import.meta.glob("./*.json", { eager: true, import: "default" })).map(([path, capture]) => [ + path.slice(2, -".json".length), + capture, + ]), +) + +export const codeModeScenarios = [ + { name: "running", description: "Sleeps between writes, so files grow 1, 2, 3 while it runs and 4 at the end." }, + { + name: "interleaved", + description: "Ten rounds of a thought and a script in one turn: reads, shells, edits, a failed read, a delete.", + }, + { name: "edits-patch", description: "Two patches to one file, a Bun write and a delete. app.ts is listed twice." }, + { name: "edits-editwrite", description: "Inner edit and write calls. Too fast for files to show before the final." }, + { name: "appends", description: "Writer flushes, one entry each with no patch, and a binary logo.png." }, + { name: "many-calls", description: "85 inner reads, past the toolCalls display cap." }, + { name: "errors", description: "A caught failing read, then a write and an edit before the script throws." }, + { name: "interrupted", description: "Interrupted during a sleep. The error part keeps the last progress metadata." }, + { name: "backgrounded", description: "background: true. The final part has only jobID; the result comes later." }, + { name: "timeout-bg", description: "timeout: 1500 moves the script to the background partway through." }, + { name: "large-patch", description: "A 6000-line write over the 200 KB budget: counts but no patch." }, + { name: "shell-truncated", description: "An inner shell with truncated output, visible only in the returned value." }, + { name: "direct", description: "Direct edit and write tools with Code Mode off. A direct write has no files." }, + { name: "direct-patch", description: "Two direct patch calls, each with metadata.files." }, +] as const + +export type CodeModeScenario = (typeof codeModeScenarios)[number]["name"] + +function capture(name: CodeModeScenario) { + const found = captures.get(name) + + if (!found) throw new Error(`No captured Code Mode scenario ${name}`) + + return found +} + +export const codeModeSession = (name: CodeModeScenario) => capture(name).session + +/** The session's messages in time order. */ +export const codeModeMessages = (name: CodeModeScenario) => [...capture(name).messages.data].reverse() + +export const codeModeStates = (name: CodeModeScenario) => capture(name).states + +/** + * The session as the timeline reads it. With a state file the session is cut at that moment: messages after the + * part's assistant message are dropped, the part is the client-store snapshot, and later content in that message is + * removed. While the part is running, the message is still open. `now` moves every timestamp so that moment is now, which keeps running durations realistic. + */ +export function codeModeDocument( + name: CodeModeScenario, + stateFile?: string, + options: { now?: number } = {}, +): SessionDocument { + const session = capture(name).session + let list = codeModeMessages(name) + let busy = false + let moment = Math.max(...list.map((message) => message.time.created)) + + if (stateFile) { + const state = codeModeStates(name).find((item) => item.file === stateFile || item.file.startsWith(stateFile)) + + if (!state) throw new Error(`No state ${stateFile} in ${name}`) + + const at = list.findIndex( + (message) => + message.type === "assistant" && + message.content.some((part) => part.type === "tool" && part.id === state.part.id), + ) + + // SAFETY: `at` is the assistant message that holds the part, found just above. + const message = structuredClone(list[at]) as Extract + const index = message.content.findIndex((part) => part.type === "tool" && part.id === state.part.id) + + message.content = [...message.content.slice(0, index), structuredClone(state.part)] + busy = state.part.state.status === "running" || state.part.state.status === "streaming" + + // What the end of the step sets had not happened yet. load.ts keeps `error`, which drew an interrupted turn + // while the script was still running. + if (busy) { + delete message.time.completed + delete message.finish + delete message.rawFinish + delete message.error + } + + list = [...list.slice(0, at), message] + moment = state.at + } + + const messages = options.now === undefined ? list : shiftTimes(list, options.now - moment) + + return { + sessionID: session.id, + messages, + status: busy ? { type: "busy" } : { type: "idle" }, + diffs: [], + } +} + +function shiftTimes(messages: SessionMessageInfo[], delta: number): SessionMessageInfo[] { + return messages.map((message) => { + if (message.type !== "assistant") return { ...message, time: shift(message.time, delta) } + + return { + ...message, + time: shift(message.time, delta), + content: message.content.map((part) => + part.type === "tool" ? { ...part, time: shift(part.time, delta) } : part, + ), + } + }) +} + +function shift(time: T, delta: number): T { + // SAFETY: every field of a message's or a tool part's `time` is epoch milliseconds. + return Object.fromEntries(Object.entries(time).map(([key, value]) => [key, (value as number) + delta])) as T +} + +/** The `execute` metadata fields this capture holds, as `core/src/codemode/tool.ts` writes them. */ +export type CodeModeMetadata = { + toolCalls?: { tool: string; status: string }[] + files?: { file: string; status?: string; additions?: number; deletions?: number; patch?: string }[] + background?: boolean + jobID?: string + error?: boolean + truncated?: boolean +} + +export function codeModeMetadata(part: CodeModeToolPart): CodeModeMetadata { + const state = part.state + + if (state.status !== "running" && state.status !== "completed" && state.status !== "error") return {} + + // SAFETY: the fixtures are the captured parts, whose metadata is Code Mode's output schema (tool.ts:47-52) or a + // direct edit or patch part's `files`. + return (state.metadata ?? {}) as CodeModeMetadata +} diff --git a/packages/session-ui/src/storybook/codemode-snapshots/interleaved.json b/packages/session-ui/src/storybook/codemode-snapshots/interleaved.json new file mode 100644 index 00000000000..808f1b83301 --- /dev/null +++ b/packages/session-ui/src/storybook/codemode-snapshots/interleaved.json @@ -0,0 +1 @@ +{"session":{"id":"ses_dec263964ffeKvN2kE7Wn20sKd","title":"interleaved","directory":"/repo","time":{"created":1795629368999,"updated":1795629368999}},"messages":{"data":[{"id":"msg_213d9d6a5001VhB7Qhl2g54YmV","time":{"created":1795629373093},"type":"idle","outcome":"succeeded"},{"id":"msg_213d9d679001203PO0NQOUFPfm","time":{"created":1795629373052,"firstToken":1795629373059,"streamed":1795629373084,"completed":1795629373085},"type":"assistant","agent":"build","model":{"id":"claude-opus-5-5","providerID":"simulation","variant":"default"},"content":[{"type":"reasoning","text":"All ten steps are done; time to summarize.","native":{"reasoningField":"reasoning_content"},"time":{"created":1795629373060,"completed":1795629373081}},{"type":"text","text":"Done: v3, v20 and v1 updated, util.ts added, old.txt removed, changelog written."}],"finish":"stop","rawFinish":"stop","cost":0,"tokens":{"input":0,"output":0,"reasoning":0,"cache":{"read":0,"write":0}}},{"id":"msg_213d9d636001AGcavk2T0ZSkiZ","time":{"created":1795629372985,"firstToken":1795629372996,"streamed":1795629373020,"completed":1795629373038},"type":"assistant","agent":"build","model":{"id":"claude-opus-5-5","providerID":"simulation","variant":"default"},"content":[{"type":"reasoning","text":"Everything lines up. A last check of the line counts, then a changelog entry.","native":{"reasoningField":"reasoning_content"},"time":{"created":1795629372997,"completed":1795629373016}},{"type":"tool","id":"call_interleaved_9","name":"execute","executed":false,"state":{"status":"completed","input":{"code":"const count = await tools.shell({ command: 'wc -l src/app.ts src/util.ts' })\nawait Bun.write(\"/repo/files/CHANGELOG.md\", '# Changelog\\n\\n- v3 = 300, v20 = 2000, v1 = 11\\n- util.ts: double, triple\\n')\nreturn count.exitCode"},"content":[{"type":"text","text":"1"}],"metadata":{"toolCalls":[{"tool":"shell","status":"completed","input":{"command":"wc -l src/app.ts src/util.ts"}},{"tool":"Bun","status":"completed","input":{"method":"write","path":"/repo/files/CHANGELOG.md"}}],"files":[{"file":"files/CHANGELOG.md","status":"added","additions":4,"deletions":0,"patch":"Index: files/CHANGELOG.md\n===================================================================\n--- files/CHANGELOG.md\n+++ files/CHANGELOG.md\n@@ -0,0 +1,4 @@\n+# Changelog\n+\n+- v3 = 300, v20 = 2000, v1 = 11\n+- util.ts: double, triple\n"}],"truncated":false}},"time":{"created":1795629373011,"ran":1795629373019,"completed":1795629373036}}],"finish":"tool-calls","rawFinish":"tool_calls","cost":0,"tokens":{"input":0,"output":0,"reasoning":0,"cache":{"read":0,"write":0}}},{"id":"msg_213d9d5f40017qDAKuA3AgS19z","time":{"created":1795629372920,"firstToken":1795629372928,"streamed":1795629372952,"completed":1795629372972},"type":"assistant","agent":"build","model":{"id":"claude-opus-5-5","providerID":"simulation","variant":"default"},"content":[{"type":"reasoning","text":"Let me re-read what I changed to make sure the pieces fit together.","native":{"reasoningField":"reasoning_content"},"time":{"created":1795629372930,"completed":1795629372946}},{"type":"text","text":"Checking the result."},{"type":"tool","id":"call_interleaved_8","name":"execute","executed":false,"state":{"status":"completed","input":{"code":"const notes = await tools.read({ path: \"/repo/files/notes.md\" })\nconst util = await tools.read({ path: \"/repo/files/src/util.ts\" })\nconst uses = await tools.shell({ command: 'grep -rn v3 src' })\nreturn [notes.type, util.type, uses.exitCode]"},"content":[{"type":"text","text":"[\"text\",\"text\",2]"}],"metadata":{"toolCalls":[{"tool":"read","status":"completed","input":{"path":"/repo/files/notes.md"}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/util.ts"}},{"tool":"shell","status":"completed","input":{"command":"grep -rn v3 src"}}],"truncated":false}},"time":{"created":1795629372944,"ran":1795629372949,"completed":1795629372971}}],"finish":"tool-calls","rawFinish":"tool_calls","cost":0,"tokens":{"input":0,"output":0,"reasoning":0,"cache":{"read":0,"write":0}}},{"id":"msg_213d9d5b9001OZOomHQg8lomG1","time":{"created":1795629372860,"firstToken":1795629372868,"streamed":1795629372890,"completed":1795629372904},"type":"assistant","agent":"build","model":{"id":"claude-opus-5-5","providerID":"simulation","variant":"default"},"content":[{"type":"reasoning","text":"old.txt is unused now; remove it and leave a short pointer in its place.","native":{"reasoningField":"reasoning_content"},"time":{"created":1795629372870,"completed":1795629372885}},{"type":"tool","id":"call_interleaved_7","name":"execute","executed":false,"state":{"status":"completed","input":{"code":"await Bun.file(\"/repo/files/old.txt\").delete()\nawait Bun.write(\"/repo/files/MOVED.md\", 'old.txt was removed; see notes.md\\n')\nreturn 'moved'"},"content":[{"type":"text","text":"moved"}],"metadata":{"toolCalls":[{"tool":"Bun","status":"completed","input":{"method":"file","path":"/repo/files/old.txt"}},{"tool":"Bun","status":"completed","input":{"method":"write","path":"/repo/files/MOVED.md"}}],"files":[{"file":"files/old.txt","status":"deleted"},{"file":"files/MOVED.md","status":"added","additions":1,"deletions":0,"patch":"Index: files/MOVED.md\n===================================================================\n--- files/MOVED.md\n+++ files/MOVED.md\n@@ -0,0 +1,1 @@\n+old.txt was removed; see notes.md\n"}],"truncated":false}},"time":{"created":1795629372882,"ran":1795629372888,"completed":1795629372902}}],"finish":"tool-calls","rawFinish":"tool_calls","cost":0,"tokens":{"input":0,"output":0,"reasoning":0,"cache":{"read":0,"write":0}}},{"id":"msg_213d9d57a001f2U4Gc0QKBFnsa","time":{"created":1795629372799,"firstToken":1795629372807,"streamed":1795629372834,"completed":1795629372847},"type":"assistant","agent":"build","model":{"id":"claude-opus-5-5","providerID":"simulation","variant":"default"},"content":[{"type":"reasoning","text":"v20 is the other constant the issue mentions, and util.ts should export a triple helper too.","native":{"reasoningField":"reasoning_content"},"time":{"created":1795629372809,"completed":1795629372829}},{"type":"tool","id":"call_interleaved_6","name":"execute","executed":false,"state":{"status":"completed","input":{"code":"await tools.edit({ path: \"/repo/files/src/app.ts\", oldString: 'export const v20 = 20', newString: 'export const v20 = 2000' })\nawait tools.edit({ path: \"/repo/files/src/util.ts\", oldString: 'export const double = (n: number) => n * 2', newString: 'export const double = (n: number) => n * 2\\nexport const triple = (n: number) => n * 3' })\nreturn 'ok'"},"content":[{"type":"text","text":"ok"}],"metadata":{"toolCalls":[{"tool":"edit","status":"completed","input":{"path":"/repo/files/src/app.ts","oldString":"export const v20 = 20","newString":"export const v20 = 2000"}},{"tool":"edit","status":"completed","input":{"path":"/repo/files/src/util.ts","oldString":"export const double = (n: number) => n * 2","newString":"export const double = (n: number) => n * 2\nexport const triple = (n: number) => n * 3"}}],"files":[{"file":"files/src/app.ts","additions":1,"deletions":1,"patch":"Index: files/src/app.ts\n===================================================================\n--- files/src/app.ts\n+++ files/src/app.ts\n@@ -17,9 +17,9 @@\n export const v16 = 16\n export const v17 = 17\n export const v18 = 18\n export const v19 = 19\n-export const v20 = 20\n+export const v20 = 2000\n export const v21 = 21\n export const v22 = 22\n export const v23 = 23\n export const v24 = 24\n","status":"modified"},{"file":"files/src/util.ts","additions":1,"deletions":0,"patch":"Index: files/src/util.ts\n===================================================================\n--- files/src/util.ts\n+++ files/src/util.ts\n@@ -1,1 +1,2 @@\n export const double = (n: number) => n * 2\n+export const triple = (n: number) => n * 3\n","status":"modified"}],"truncated":false}},"time":{"created":1795629372825,"ran":1795629372832,"completed":1795629372845}}],"finish":"tool-calls","rawFinish":"tool_calls","cost":0,"tokens":{"input":0,"output":0,"reasoning":0,"cache":{"read":0,"write":0}}},{"id":"msg_213d9d52f001taWRqlhWspRd5A","time":{"created":1795629372723,"firstToken":1795629372737,"streamed":1795629372766,"completed":1795629372785},"type":"assistant","agent":"build","model":{"id":"claude-opus-5-5","providerID":"simulation","variant":"default"},"content":[{"type":"reasoning","text":"There may be a CHANGES file to update; if not, the notes are where this goes.","native":{"reasoningField":"reasoning_content"},"time":{"created":1795629372739,"completed":1795629372759}},{"type":"text","text":"Recording the change in the notes."},{"type":"tool","id":"call_interleaved_5","name":"execute","executed":false,"state":{"status":"completed","input":{"code":"try { await tools.read({ path: \"/repo/files/CHANGES.md\" }) } catch (e) { }\nawait tools.edit({ path: \"/repo/files/notes.md\", oldString: '- one', newString: '- one\\n- v3 is 300, helpers in util.ts' })\nreturn 'notes updated'"},"content":[{"type":"text","text":"notes updated"}],"metadata":{"toolCalls":[{"tool":"read","status":"error","input":{"path":"/repo/files/CHANGES.md"}},{"tool":"edit","status":"completed","input":{"path":"/repo/files/notes.md","oldString":"- one","newString":"- one\n- v3 is 300, helpers in util.ts"}}],"files":[{"file":"files/notes.md","additions":1,"deletions":0,"patch":"Index: files/notes.md\n===================================================================\n--- files/notes.md\n+++ files/notes.md\n@@ -1,3 +1,4 @@\n # Notes\n \n - one\n+- v3 is 300, helpers in util.ts\n","status":"modified"}],"truncated":false}},"time":{"created":1795629372757,"ran":1795629372763,"completed":1795629372783}}],"finish":"tool-calls","rawFinish":"tool_calls","cost":0,"tokens":{"input":0,"output":0,"reasoning":0,"cache":{"read":0,"write":0}}},{"id":"msg_213d9cced001dk6mNq9j4ZCR7R","time":{"created":1795629370608,"firstToken":1795629370617,"streamed":1795629370643,"completed":1795629372704},"type":"assistant","agent":"build","model":{"id":"claude-opus-5-5","providerID":"simulation","variant":"default"},"content":[{"type":"reasoning","text":"The generated tables need the build step to settle between writes, so this one waits a moment after each change.","native":{"reasoningField":"reasoning_content"},"time":{"created":1795629370618,"completed":1795629370639}},{"type":"tool","id":"call_interleaved_4","name":"execute","executed":false,"state":{"status":"completed","input":{"code":"await Bun.write(\"/repo/files/src/step-1.ts\", 'export const s = 1\\n')\nawait tools.shell({ command: 'sleep 1' })\nawait tools.edit({ path: \"/repo/files/src/app.ts\", oldString: 'export const v1 = 1', newString: 'export const v1 = 11' })\nawait tools.shell({ command: 'sleep 1' })\nawait Bun.write(\"/repo/files/src/step-2.ts\", 'export const s = 2\\n')\nreturn 'settled'"},"content":[{"type":"text","text":"settled"}],"metadata":{"toolCalls":[{"tool":"Bun","status":"completed","input":{"method":"write","path":"/repo/files/src/step-1.ts"}},{"tool":"shell","status":"completed","input":{"command":"sleep 1"}},{"tool":"edit","status":"completed","input":{"path":"/repo/files/src/app.ts","oldString":"export const v1 = 1","newString":"export const v1 = 11"}},{"tool":"shell","status":"completed","input":{"command":"sleep 1"}},{"tool":"Bun","status":"completed","input":{"method":"write","path":"/repo/files/src/step-2.ts"}}],"files":[{"file":"files/src/step-1.ts","status":"added","additions":1,"deletions":0,"patch":"Index: files/src/step-1.ts\n===================================================================\n--- files/src/step-1.ts\n+++ files/src/step-1.ts\n@@ -0,0 +1,1 @@\n+export const s = 1\n"},{"file":"files/src/app.ts","additions":1,"deletions":1,"patch":"Index: files/src/app.ts\n===================================================================\n--- files/src/app.ts\n+++ files/src/app.ts\n@@ -1,6 +1,6 @@\n export const v0 = 0\n-export const v1 = 1\n+export const v1 = 11\n export const v2 = 2\n export const v3 = 300\n export const v4 = 4\n export const v5 = 5\n","status":"modified"},{"file":"files/src/step-2.ts","status":"added","additions":1,"deletions":0,"patch":"Index: files/src/step-2.ts\n===================================================================\n--- files/src/step-2.ts\n+++ files/src/step-2.ts\n@@ -0,0 +1,1 @@\n+export const s = 2\n"}],"truncated":false}},"time":{"created":1795629370636,"ran":1795629370642,"completed":1795629372700}}],"finish":"tool-calls","rawFinish":"tool_calls","cost":0,"tokens":{"input":0,"output":0,"reasoning":0,"cache":{"read":0,"write":0}}},{"id":"msg_213d9cc3b001tOobuUxMKScfH7","time":{"created":1795629370430,"firstToken":1795629370447,"streamed":1795629370483,"completed":1795629370592},"type":"assistant","agent":"build","model":{"id":"claude-opus-5-5","providerID":"simulation","variant":"default"},"content":[{"type":"reasoning","text":"Now generate the three lookup tables. Each needs a slice of app.ts, so I'll read it in chunks and write one file per table.","native":{"reasoningField":"reasoning_content"},"time":{"created":1795629370449,"completed":1795629370478}},{"type":"tool","id":"call_interleaved_3","name":"execute","executed":false,"state":{"status":"completed","input":{"code":"const chunks = []\nfor (let offset = 1; offset <= 25; offset += 3) chunks.push((await tools.read({ path: \"/repo/files/src/app.ts\", offset, limit: 3 })).type)\nfor (const name of ['a', 'b', 'c']) await Bun.write(\"/repo/files/src/gen/\" + name + '.ts', 'export const table = ' + JSON.stringify(name) + '\\n')\nreturn chunks.length"},"content":[{"type":"text","text":"9"}],"metadata":{"toolCalls":[{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","offset":1,"limit":3}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","offset":4,"limit":3}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","offset":7,"limit":3}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","offset":10,"limit":3}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","offset":13,"limit":3}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","offset":16,"limit":3}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","offset":19,"limit":3}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","offset":22,"limit":3}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","offset":25,"limit":3}},{"tool":"Bun","status":"completed","input":{"method":"write","path":"/repo/files/src/gen/a.ts"}},{"tool":"Bun","status":"completed","input":{"method":"write","path":"/repo/files/src/gen/b.ts"}},{"tool":"Bun","status":"completed","input":{"method":"write","path":"/repo/files/src/gen/c.ts"}}],"files":[{"file":"files/src/gen/a.ts","status":"added","additions":1,"deletions":0,"patch":"Index: files/src/gen/a.ts\n===================================================================\n--- files/src/gen/a.ts\n+++ files/src/gen/a.ts\n@@ -0,0 +1,1 @@\n+export const table = \"a\"\n"},{"file":"files/src/gen/b.ts","status":"added","additions":1,"deletions":0,"patch":"Index: files/src/gen/b.ts\n===================================================================\n--- files/src/gen/b.ts\n+++ files/src/gen/b.ts\n@@ -0,0 +1,1 @@\n+export const table = \"b\"\n"},{"file":"files/src/gen/c.ts","status":"added","additions":1,"deletions":0,"patch":"Index: files/src/gen/c.ts\n===================================================================\n--- files/src/gen/c.ts\n+++ files/src/gen/c.ts\n@@ -0,0 +1,1 @@\n+export const table = \"c\"\n"}],"truncated":false}},"time":{"created":1795629370476,"ran":1795629370481,"completed":1795629370550}}],"finish":"tool-calls","rawFinish":"tool_calls","cost":0,"tokens":{"input":0,"output":0,"reasoning":0,"cache":{"read":0,"write":0}}},{"id":"msg_213d9cbe4001hHxURxcBsCuEN3","time":{"created":1795629370343,"firstToken":1795629370350,"streamed":1795629370380,"completed":1795629370416},"type":"assistant","agent":"build","model":{"id":"claude-opus-5-5","providerID":"simulation","variant":"default"},"content":[{"type":"reasoning","text":"v3 should be 300, and the helpers belong in their own util module so app.ts stays data only.","native":{"reasoningField":"reasoning_content"},"time":{"created":1795629370352,"completed":1795629370374}},{"type":"text","text":"Starting with the constant and a small util module."},{"type":"tool","id":"call_interleaved_2","name":"execute","executed":false,"state":{"status":"completed","input":{"code":"await tools.edit({ path: \"/repo/files/src/app.ts\", oldString: 'export const v3 = 3', newString: 'export const v3 = 300' })\nawait Bun.write(\"/repo/files/src/util.ts\", 'export const double = (n: number) => n * 2\\n')\nreturn 'edited app.ts, added util.ts'"},"content":[{"type":"text","text":"edited app.ts, added util.ts"}],"metadata":{"toolCalls":[{"tool":"edit","status":"completed","input":{"path":"/repo/files/src/app.ts","oldString":"export const v3 = 3","newString":"export const v3 = 300"}},{"tool":"Bun","status":"completed","input":{"method":"write","path":"/repo/files/src/util.ts"}}],"files":[{"file":"files/src/app.ts","additions":1,"deletions":1,"patch":"Index: files/src/app.ts\n===================================================================\n--- files/src/app.ts\n+++ files/src/app.ts\n@@ -1,8 +1,8 @@\n export const v0 = 0\n export const v1 = 1\n export const v2 = 2\n-export const v3 = 3\n+export const v3 = 300\n export const v4 = 4\n export const v5 = 5\n export const v6 = 6\n export const v7 = 7\n","status":"modified"},{"file":"files/src/util.ts","status":"added","additions":1,"deletions":0,"patch":"Index: files/src/util.ts\n===================================================================\n--- files/src/util.ts\n+++ files/src/util.ts\n@@ -0,0 +1,1 @@\n+export const double = (n: number) => n * 2\n"}],"truncated":false}},"time":{"created":1795629370372,"ran":1795629370377,"completed":1795629370413}}],"finish":"tool-calls","rawFinish":"tool_calls","cost":0,"tokens":{"input":0,"output":0,"reasoning":0,"cache":{"read":0,"write":0}}},{"id":"msg_213d9cb9f001LWOa0NJN1IBr0q","time":{"created":1795629370274,"firstToken":1795629370283,"streamed":1795629370307,"completed":1795629370331},"type":"assistant","agent":"build","model":{"id":"claude-opus-5-5","providerID":"simulation","variant":"default"},"content":[{"type":"reasoning","text":"The module is a flat list of constants. Let me check the working tree and git state before editing.","native":{"reasoningField":"reasoning_content"},"time":{"created":1795629370285,"completed":1795629370303}},{"type":"tool","id":"call_interleaved_1","name":"execute","executed":false,"state":{"status":"completed","input":{"code":"const ls = await tools.shell({ command: 'ls -la' })\nconst status = await tools.shell({ command: 'git status --short' })\nreturn [ls.exitCode, status.exitCode]"},"content":[{"type":"text","text":"[0,128]"}],"metadata":{"toolCalls":[{"tool":"shell","status":"completed","input":{"command":"ls -la"}},{"tool":"shell","status":"completed","input":{"command":"git status --short"}}],"truncated":false}},"time":{"created":1795629370301,"ran":1795629370306,"completed":1795629370329}}],"finish":"tool-calls","rawFinish":"tool_calls","cost":0,"tokens":{"input":0,"output":0,"reasoning":0,"cache":{"read":0,"write":0}}},{"id":"msg_213d9c88e001zXuqoR6o7Ditbb","time":{"created":1795629369497,"firstToken":1795629369586,"streamed":1795629369958,"completed":1795629370257},"type":"assistant","agent":"build","model":{"id":"claude-opus-5-5","providerID":"simulation","variant":"default"},"content":[{"type":"reasoning","text":"Before changing anything I want to see how the project is laid out: the README, the main module and which TypeScript files exist.","native":{"reasoningField":"reasoning_content"},"time":{"created":1795629369591,"completed":1795629369950}},{"type":"tool","id":"call_interleaved_0","name":"execute","executed":false,"state":{"status":"completed","input":{"code":"const readme = await tools.read({ path: \"/repo/files/README.md\" })\nconst app = await tools.read({ path: \"/repo/files/src/app.ts\", limit: 10 })\nconst files = await tools.shell({ command: 'find src -name \"*.ts\"' })\nreturn { readme: readme.type, app: app.type, files: files.exitCode }"},"content":[{"type":"text","text":"{\"readme\":\"text\",\"app\":\"text\",\"files\":1}"}],"metadata":{"toolCalls":[{"tool":"read","status":"completed","input":{"path":"/repo/files/README.md"}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":10}},{"tool":"shell","status":"completed","input":{"command":"find src -name \"*.ts\""}}],"truncated":false}},"time":{"created":1795629369942,"ran":1795629369956,"completed":1795629370254}}],"finish":"tool-calls","rawFinish":"tool_calls","cost":0,"tokens":{"input":0,"output":0,"reasoning":0,"cache":{"read":0,"write":0}}},{"id":"msg_213d9c7140014b29zewbUKR2GM","time":{"created":1795629369457},"text":"SCN:interleaved please","type":"user"}],"cursor":{"previous":"eyJpZCI6Im1zZ18yMTNkOWQ2YTUwMDFWaEI3UWhsMmc1NFltViIsIm9yZGVyIjoiZGVzYyIsImRpcmVjdGlvbiI6InByZXZpb3VzIn0","next":"eyJpZCI6Im1zZ18yMTNkOWM3MTQwMDE0YjI5emV3YlVLUjJHTSIsIm9yZGVyIjoiZGVzYyIsImRpcmVjdGlvbiI6Im5leHQifQ"}},"states":[{"file":"00-execute-nterleaved_0-called.json","reason":"called","at":1795629369956,"eventIndex":13,"part":{"type":"tool","id":"call_interleaved_0","name":"execute","time":{"created":1795629369942,"ran":1795629369956},"state":{"status":"running","input":{"code":"const readme = await tools.read({ path: \"/repo/files/README.md\" })\nconst app = await tools.read({ path: \"/repo/files/src/app.ts\", limit: 10 })\nconst files = await tools.shell({ command: 'find src -name \"*.ts\"' })\nreturn { readme: readme.type, app: app.type, files: files.exitCode }"},"metadata":{}},"executed":false}},{"file":"01-execute-nterleaved_0-first-progress.json","reason":"first-progress","at":1795629370032,"eventIndex":15,"part":{"type":"tool","id":"call_interleaved_0","name":"execute","time":{"created":1795629369942,"ran":1795629369956},"state":{"status":"running","input":{"code":"const readme = await tools.read({ path: \"/repo/files/README.md\" })\nconst app = await tools.read({ path: \"/repo/files/src/app.ts\", limit: 10 })\nconst files = await tools.shell({ command: 'find src -name \"*.ts\"' })\nreturn { readme: readme.type, app: app.type, files: files.exitCode }"},"metadata":{"background":true}},"executed":false}},{"file":"02-execute-nterleaved_0-progress.json","reason":"progress","at":1795629370132,"eventIndex":16,"part":{"type":"tool","id":"call_interleaved_0","name":"execute","time":{"created":1795629369942,"ran":1795629369956},"state":{"status":"running","input":{"code":"const readme = await tools.read({ path: \"/repo/files/README.md\" })\nconst app = await tools.read({ path: \"/repo/files/src/app.ts\", limit: 10 })\nconst files = await tools.shell({ command: 'find src -name \"*.ts\"' })\nreturn { readme: readme.type, app: app.type, files: files.exitCode }"},"metadata":{"toolCalls":[{"tool":"read","status":"running","input":{"path":"/repo/files/README.md"}}],"background":true}},"executed":false}},{"file":"03-execute-nterleaved_0-progress.json","reason":"progress","at":1795629370235,"eventIndex":17,"part":{"type":"tool","id":"call_interleaved_0","name":"execute","time":{"created":1795629369942,"ran":1795629369956},"state":{"status":"running","input":{"code":"const readme = await tools.read({ path: \"/repo/files/README.md\" })\nconst app = await tools.read({ path: \"/repo/files/src/app.ts\", limit: 10 })\nconst files = await tools.shell({ command: 'find src -name \"*.ts\"' })\nreturn { readme: readme.type, app: app.type, files: files.exitCode }"},"metadata":{"toolCalls":[{"tool":"read","status":"completed","input":{"path":"/repo/files/README.md"}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":10}},{"tool":"shell","status":"running","input":{"command":"find src -name \"*.ts\""}}],"background":true}},"executed":false}},{"file":"04-execute-nterleaved_0-final.json","reason":"final","at":1795629370254,"eventIndex":20,"part":{"type":"tool","id":"call_interleaved_0","name":"execute","time":{"created":1795629369942,"ran":1795629369956,"completed":1795629370254},"state":{"status":"completed","input":{"code":"const readme = await tools.read({ path: \"/repo/files/README.md\" })\nconst app = await tools.read({ path: \"/repo/files/src/app.ts\", limit: 10 })\nconst files = await tools.shell({ command: 'find src -name \"*.ts\"' })\nreturn { readme: readme.type, app: app.type, files: files.exitCode }"},"metadata":{"toolCalls":[{"tool":"read","status":"completed","input":{"path":"/repo/files/README.md"}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":10}},{"tool":"shell","status":"completed","input":{"command":"find src -name \"*.ts\""}}],"truncated":false},"content":[{"type":"text","text":"{\"readme\":\"text\",\"app\":\"text\",\"files\":1}"}]},"executed":false}},{"file":"05-execute-nterleaved_1-called.json","reason":"called","at":1795629370306,"eventIndex":31,"part":{"type":"tool","id":"call_interleaved_1","name":"execute","time":{"created":1795629370301,"ran":1795629370306},"state":{"status":"running","input":{"code":"const ls = await tools.shell({ command: 'ls -la' })\nconst status = await tools.shell({ command: 'git status --short' })\nreturn [ls.exitCode, status.exitCode]"},"metadata":{}},"executed":false}},{"file":"06-execute-nterleaved_1-first-progress.json","reason":"first-progress","at":1795629370309,"eventIndex":33,"part":{"type":"tool","id":"call_interleaved_1","name":"execute","time":{"created":1795629370301,"ran":1795629370306},"state":{"status":"running","input":{"code":"const ls = await tools.shell({ command: 'ls -la' })\nconst status = await tools.shell({ command: 'git status --short' })\nreturn [ls.exitCode, status.exitCode]"},"metadata":{"background":true}},"executed":false}},{"file":"07-execute-nterleaved_1-progress.json","reason":"progress","at":1795629370312,"eventIndex":34,"part":{"type":"tool","id":"call_interleaved_1","name":"execute","time":{"created":1795629370301,"ran":1795629370306},"state":{"status":"running","input":{"code":"const ls = await tools.shell({ command: 'ls -la' })\nconst status = await tools.shell({ command: 'git status --short' })\nreturn [ls.exitCode, status.exitCode]"},"metadata":{"toolCalls":[{"tool":"shell","status":"running","input":{"command":"ls -la"}}],"background":true}},"executed":false}},{"file":"08-execute-nterleaved_1-final.json","reason":"final","at":1795629370329,"eventIndex":39,"part":{"type":"tool","id":"call_interleaved_1","name":"execute","time":{"created":1795629370301,"ran":1795629370306,"completed":1795629370329},"state":{"status":"completed","input":{"code":"const ls = await tools.shell({ command: 'ls -la' })\nconst status = await tools.shell({ command: 'git status --short' })\nreturn [ls.exitCode, status.exitCode]"},"metadata":{"toolCalls":[{"tool":"shell","status":"completed","input":{"command":"ls -la"}},{"tool":"shell","status":"completed","input":{"command":"git status --short"}}],"truncated":false},"content":[{"type":"text","text":"[0,128]"}]},"executed":false}},{"file":"09-execute-nterleaved_2-called.json","reason":"called","at":1795629370377,"eventIndex":52,"part":{"type":"tool","id":"call_interleaved_2","name":"execute","time":{"created":1795629370372,"ran":1795629370377},"state":{"status":"running","input":{"code":"await tools.edit({ path: \"/repo/files/src/app.ts\", oldString: 'export const v3 = 3', newString: 'export const v3 = 300' })\nawait Bun.write(\"/repo/files/src/util.ts\", 'export const double = (n: number) => n * 2\\n')\nreturn 'edited app.ts, added util.ts'"},"metadata":{}},"executed":false}},{"file":"10-execute-nterleaved_2-first-progress.json","reason":"first-progress","at":1795629370381,"eventIndex":55,"part":{"type":"tool","id":"call_interleaved_2","name":"execute","time":{"created":1795629370372,"ran":1795629370377},"state":{"status":"running","input":{"code":"await tools.edit({ path: \"/repo/files/src/app.ts\", oldString: 'export const v3 = 3', newString: 'export const v3 = 300' })\nawait Bun.write(\"/repo/files/src/util.ts\", 'export const double = (n: number) => n * 2\\n')\nreturn 'edited app.ts, added util.ts'"},"metadata":{"background":true}},"executed":false}},{"file":"11-execute-nterleaved_2-progress.json","reason":"progress","at":1795629370384,"eventIndex":56,"part":{"type":"tool","id":"call_interleaved_2","name":"execute","time":{"created":1795629370372,"ran":1795629370377},"state":{"status":"running","input":{"code":"await tools.edit({ path: \"/repo/files/src/app.ts\", oldString: 'export const v3 = 3', newString: 'export const v3 = 300' })\nawait Bun.write(\"/repo/files/src/util.ts\", 'export const double = (n: number) => n * 2\\n')\nreturn 'edited app.ts, added util.ts'"},"metadata":{"toolCalls":[{"tool":"edit","status":"running","input":{"path":"/repo/files/src/app.ts","oldString":"export const v3 = 3","newString":"export const v3 = 300"}}],"background":true}},"executed":false}},{"file":"12-execute-nterleaved_2-final.json","reason":"final","at":1795629370413,"eventIndex":57,"part":{"type":"tool","id":"call_interleaved_2","name":"execute","time":{"created":1795629370372,"ran":1795629370377,"completed":1795629370413},"state":{"status":"completed","input":{"code":"await tools.edit({ path: \"/repo/files/src/app.ts\", oldString: 'export const v3 = 3', newString: 'export const v3 = 300' })\nawait Bun.write(\"/repo/files/src/util.ts\", 'export const double = (n: number) => n * 2\\n')\nreturn 'edited app.ts, added util.ts'"},"metadata":{"toolCalls":[{"tool":"edit","status":"completed","input":{"path":"/repo/files/src/app.ts","oldString":"export const v3 = 3","newString":"export const v3 = 300"}},{"tool":"Bun","status":"completed","input":{"method":"write","path":"/repo/files/src/util.ts"}}],"files":[{"file":"files/src/app.ts","additions":1,"deletions":1,"patch":"Index: files/src/app.ts\n===================================================================\n--- files/src/app.ts\n+++ files/src/app.ts\n@@ -1,8 +1,8 @@\n export const v0 = 0\n export const v1 = 1\n export const v2 = 2\n-export const v3 = 3\n+export const v3 = 300\n export const v4 = 4\n export const v5 = 5\n export const v6 = 6\n export const v7 = 7\n","status":"modified"},{"file":"files/src/util.ts","status":"added","additions":1,"deletions":0,"patch":"Index: files/src/util.ts\n===================================================================\n--- files/src/util.ts\n+++ files/src/util.ts\n@@ -0,0 +1,1 @@\n+export const double = (n: number) => n * 2\n"}],"truncated":false},"content":[{"type":"text","text":"edited app.ts, added util.ts"}]},"executed":false}},{"file":"13-execute-nterleaved_3-called.json","reason":"called","at":1795629370481,"eventIndex":68,"part":{"type":"tool","id":"call_interleaved_3","name":"execute","time":{"created":1795629370476,"ran":1795629370481},"state":{"status":"running","input":{"code":"const chunks = []\nfor (let offset = 1; offset <= 25; offset += 3) chunks.push((await tools.read({ path: \"/repo/files/src/app.ts\", offset, limit: 3 })).type)\nfor (const name of ['a', 'b', 'c']) await Bun.write(\"/repo/files/src/gen/\" + name + '.ts', 'export const table = ' + JSON.stringify(name) + '\\n')\nreturn chunks.length"},"metadata":{}},"executed":false}},{"file":"14-execute-nterleaved_3-first-progress.json","reason":"first-progress","at":1795629370484,"eventIndex":70,"part":{"type":"tool","id":"call_interleaved_3","name":"execute","time":{"created":1795629370476,"ran":1795629370481},"state":{"status":"running","input":{"code":"const chunks = []\nfor (let offset = 1; offset <= 25; offset += 3) chunks.push((await tools.read({ path: \"/repo/files/src/app.ts\", offset, limit: 3 })).type)\nfor (const name of ['a', 'b', 'c']) await Bun.write(\"/repo/files/src/gen/\" + name + '.ts', 'export const table = ' + JSON.stringify(name) + '\\n')\nreturn chunks.length"},"metadata":{"background":true}},"executed":false}},{"file":"15-execute-nterleaved_3-progress.json","reason":"progress","at":1795629370488,"eventIndex":71,"part":{"type":"tool","id":"call_interleaved_3","name":"execute","time":{"created":1795629370476,"ran":1795629370481},"state":{"status":"running","input":{"code":"const chunks = []\nfor (let offset = 1; offset <= 25; offset += 3) chunks.push((await tools.read({ path: \"/repo/files/src/app.ts\", offset, limit: 3 })).type)\nfor (const name of ['a', 'b', 'c']) await Bun.write(\"/repo/files/src/gen/\" + name + '.ts', 'export const table = ' + JSON.stringify(name) + '\\n')\nreturn chunks.length"},"metadata":{"toolCalls":[{"tool":"read","status":"running","input":{"path":"/repo/files/src/app.ts","offset":1,"limit":3}}],"background":true}},"executed":false}},{"file":"16-execute-nterleaved_3-final.json","reason":"final","at":1795629370550,"eventIndex":72,"part":{"type":"tool","id":"call_interleaved_3","name":"execute","time":{"created":1795629370476,"ran":1795629370481,"completed":1795629370550},"state":{"status":"completed","input":{"code":"const chunks = []\nfor (let offset = 1; offset <= 25; offset += 3) chunks.push((await tools.read({ path: \"/repo/files/src/app.ts\", offset, limit: 3 })).type)\nfor (const name of ['a', 'b', 'c']) await Bun.write(\"/repo/files/src/gen/\" + name + '.ts', 'export const table = ' + JSON.stringify(name) + '\\n')\nreturn chunks.length"},"metadata":{"toolCalls":[{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","offset":1,"limit":3}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","offset":4,"limit":3}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","offset":7,"limit":3}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","offset":10,"limit":3}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","offset":13,"limit":3}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","offset":16,"limit":3}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","offset":19,"limit":3}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","offset":22,"limit":3}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","offset":25,"limit":3}},{"tool":"Bun","status":"completed","input":{"method":"write","path":"/repo/files/src/gen/a.ts"}},{"tool":"Bun","status":"completed","input":{"method":"write","path":"/repo/files/src/gen/b.ts"}},{"tool":"Bun","status":"completed","input":{"method":"write","path":"/repo/files/src/gen/c.ts"}}],"files":[{"file":"files/src/gen/a.ts","status":"added","additions":1,"deletions":0,"patch":"Index: files/src/gen/a.ts\n===================================================================\n--- files/src/gen/a.ts\n+++ files/src/gen/a.ts\n@@ -0,0 +1,1 @@\n+export const table = \"a\"\n"},{"file":"files/src/gen/b.ts","status":"added","additions":1,"deletions":0,"patch":"Index: files/src/gen/b.ts\n===================================================================\n--- files/src/gen/b.ts\n+++ files/src/gen/b.ts\n@@ -0,0 +1,1 @@\n+export const table = \"b\"\n"},{"file":"files/src/gen/c.ts","status":"added","additions":1,"deletions":0,"patch":"Index: files/src/gen/c.ts\n===================================================================\n--- files/src/gen/c.ts\n+++ files/src/gen/c.ts\n@@ -0,0 +1,1 @@\n+export const table = \"c\"\n"}],"truncated":false},"content":[{"type":"text","text":"9"}]},"executed":false}},{"file":"17-execute-nterleaved_4-called.json","reason":"called","at":1795629370642,"eventIndex":83,"part":{"type":"tool","id":"call_interleaved_4","name":"execute","time":{"created":1795629370636,"ran":1795629370642},"state":{"status":"running","input":{"code":"await Bun.write(\"/repo/files/src/step-1.ts\", 'export const s = 1\\n')\nawait tools.shell({ command: 'sleep 1' })\nawait tools.edit({ path: \"/repo/files/src/app.ts\", oldString: 'export const v1 = 1', newString: 'export const v1 = 11' })\nawait tools.shell({ command: 'sleep 1' })\nawait Bun.write(\"/repo/files/src/step-2.ts\", 'export const s = 2\\n')\nreturn 'settled'"},"metadata":{}},"executed":false}},{"file":"18-execute-nterleaved_4-first-progress.json","reason":"first-progress","at":1795629370644,"eventIndex":85,"part":{"type":"tool","id":"call_interleaved_4","name":"execute","time":{"created":1795629370636,"ran":1795629370642},"state":{"status":"running","input":{"code":"await Bun.write(\"/repo/files/src/step-1.ts\", 'export const s = 1\\n')\nawait tools.shell({ command: 'sleep 1' })\nawait tools.edit({ path: \"/repo/files/src/app.ts\", oldString: 'export const v1 = 1', newString: 'export const v1 = 11' })\nawait tools.shell({ command: 'sleep 1' })\nawait Bun.write(\"/repo/files/src/step-2.ts\", 'export const s = 2\\n')\nreturn 'settled'"},"metadata":{"background":true}},"executed":false}},{"file":"19-execute-nterleaved_4-progress.json","reason":"progress","at":1795629370647,"eventIndex":86,"part":{"type":"tool","id":"call_interleaved_4","name":"execute","time":{"created":1795629370636,"ran":1795629370642},"state":{"status":"running","input":{"code":"await Bun.write(\"/repo/files/src/step-1.ts\", 'export const s = 1\\n')\nawait tools.shell({ command: 'sleep 1' })\nawait tools.edit({ path: \"/repo/files/src/app.ts\", oldString: 'export const v1 = 1', newString: 'export const v1 = 11' })\nawait tools.shell({ command: 'sleep 1' })\nawait Bun.write(\"/repo/files/src/step-2.ts\", 'export const s = 2\\n')\nreturn 'settled'"},"metadata":{"toolCalls":[{"tool":"Bun","status":"running","input":{"method":"write","path":"/repo/files/src/step-1.ts"}}],"background":true}},"executed":false}},{"file":"20-execute-nterleaved_4-files-1.json","reason":"files-1","at":1795629370749,"eventIndex":88,"part":{"type":"tool","id":"call_interleaved_4","name":"execute","time":{"created":1795629370636,"ran":1795629370642},"state":{"status":"running","input":{"code":"await Bun.write(\"/repo/files/src/step-1.ts\", 'export const s = 1\\n')\nawait tools.shell({ command: 'sleep 1' })\nawait tools.edit({ path: \"/repo/files/src/app.ts\", oldString: 'export const v1 = 1', newString: 'export const v1 = 11' })\nawait tools.shell({ command: 'sleep 1' })\nawait Bun.write(\"/repo/files/src/step-2.ts\", 'export const s = 2\\n')\nreturn 'settled'"},"metadata":{"toolCalls":[{"tool":"Bun","status":"completed","input":{"method":"write","path":"/repo/files/src/step-1.ts"}},{"tool":"shell","status":"running","input":{"command":"sleep 1"}}],"files":[{"file":"files/src/step-1.ts","status":"added","additions":1,"deletions":0,"patch":"Index: files/src/step-1.ts\n===================================================================\n--- files/src/step-1.ts\n+++ files/src/step-1.ts\n@@ -0,0 +1,1 @@\n+export const s = 1\n"}],"background":true}},"executed":false}},{"file":"21-execute-nterleaved_4-progress.json","reason":"progress","at":1795629371667,"eventIndex":89,"part":{"type":"tool","id":"call_interleaved_4","name":"execute","time":{"created":1795629370636,"ran":1795629370642},"state":{"status":"running","input":{"code":"await Bun.write(\"/repo/files/src/step-1.ts\", 'export const s = 1\\n')\nawait tools.shell({ command: 'sleep 1' })\nawait tools.edit({ path: \"/repo/files/src/app.ts\", oldString: 'export const v1 = 1', newString: 'export const v1 = 11' })\nawait tools.shell({ command: 'sleep 1' })\nawait Bun.write(\"/repo/files/src/step-2.ts\", 'export const s = 2\\n')\nreturn 'settled'"},"metadata":{"toolCalls":[{"tool":"Bun","status":"completed","input":{"method":"write","path":"/repo/files/src/step-1.ts"}},{"tool":"shell","status":"completed","input":{"command":"sleep 1"}}],"files":[{"file":"files/src/step-1.ts","status":"added","additions":1,"deletions":0,"patch":"Index: files/src/step-1.ts\n===================================================================\n--- files/src/step-1.ts\n+++ files/src/step-1.ts\n@@ -0,0 +1,1 @@\n+export const s = 1\n"}],"background":true}},"executed":false}},{"file":"22-execute-nterleaved_4-files-2.json","reason":"files-2","at":1795629371769,"eventIndex":92,"part":{"type":"tool","id":"call_interleaved_4","name":"execute","time":{"created":1795629370636,"ran":1795629370642},"state":{"status":"running","input":{"code":"await Bun.write(\"/repo/files/src/step-1.ts\", 'export const s = 1\\n')\nawait tools.shell({ command: 'sleep 1' })\nawait tools.edit({ path: \"/repo/files/src/app.ts\", oldString: 'export const v1 = 1', newString: 'export const v1 = 11' })\nawait tools.shell({ command: 'sleep 1' })\nawait Bun.write(\"/repo/files/src/step-2.ts\", 'export const s = 2\\n')\nreturn 'settled'"},"metadata":{"toolCalls":[{"tool":"Bun","status":"completed","input":{"method":"write","path":"/repo/files/src/step-1.ts"}},{"tool":"shell","status":"completed","input":{"command":"sleep 1"}},{"tool":"edit","status":"completed","input":{"path":"/repo/files/src/app.ts","oldString":"export const v1 = 1","newString":"export const v1 = 11"}},{"tool":"shell","status":"running","input":{"command":"sleep 1"}}],"files":[{"file":"files/src/step-1.ts","status":"added","additions":1,"deletions":0,"patch":"Index: files/src/step-1.ts\n===================================================================\n--- files/src/step-1.ts\n+++ files/src/step-1.ts\n@@ -0,0 +1,1 @@\n+export const s = 1\n"},{"file":"files/src/app.ts","additions":1,"deletions":1,"patch":"Index: files/src/app.ts\n===================================================================\n--- files/src/app.ts\n+++ files/src/app.ts\n@@ -1,6 +1,6 @@\n export const v0 = 0\n-export const v1 = 1\n+export const v1 = 11\n export const v2 = 2\n export const v3 = 300\n export const v4 = 4\n export const v5 = 5\n","status":"modified"}],"background":true}},"executed":false}},{"file":"23-execute-nterleaved_4-progress.json","reason":"progress","at":1795629372694,"eventIndex":93,"part":{"type":"tool","id":"call_interleaved_4","name":"execute","time":{"created":1795629370636,"ran":1795629370642},"state":{"status":"running","input":{"code":"await Bun.write(\"/repo/files/src/step-1.ts\", 'export const s = 1\\n')\nawait tools.shell({ command: 'sleep 1' })\nawait tools.edit({ path: \"/repo/files/src/app.ts\", oldString: 'export const v1 = 1', newString: 'export const v1 = 11' })\nawait tools.shell({ command: 'sleep 1' })\nawait Bun.write(\"/repo/files/src/step-2.ts\", 'export const s = 2\\n')\nreturn 'settled'"},"metadata":{"toolCalls":[{"tool":"Bun","status":"completed","input":{"method":"write","path":"/repo/files/src/step-1.ts"}},{"tool":"shell","status":"completed","input":{"command":"sleep 1"}},{"tool":"edit","status":"completed","input":{"path":"/repo/files/src/app.ts","oldString":"export const v1 = 1","newString":"export const v1 = 11"}},{"tool":"shell","status":"completed","input":{"command":"sleep 1"}}],"files":[{"file":"files/src/step-1.ts","status":"added","additions":1,"deletions":0,"patch":"Index: files/src/step-1.ts\n===================================================================\n--- files/src/step-1.ts\n+++ files/src/step-1.ts\n@@ -0,0 +1,1 @@\n+export const s = 1\n"},{"file":"files/src/app.ts","additions":1,"deletions":1,"patch":"Index: files/src/app.ts\n===================================================================\n--- files/src/app.ts\n+++ files/src/app.ts\n@@ -1,6 +1,6 @@\n export const v0 = 0\n-export const v1 = 1\n+export const v1 = 11\n export const v2 = 2\n export const v3 = 300\n export const v4 = 4\n export const v5 = 5\n","status":"modified"}],"background":true}},"executed":false}},{"file":"24-execute-nterleaved_4-final.json","reason":"final","at":1795629372700,"eventIndex":95,"part":{"type":"tool","id":"call_interleaved_4","name":"execute","time":{"created":1795629370636,"ran":1795629370642,"completed":1795629372700},"state":{"status":"completed","input":{"code":"await Bun.write(\"/repo/files/src/step-1.ts\", 'export const s = 1\\n')\nawait tools.shell({ command: 'sleep 1' })\nawait tools.edit({ path: \"/repo/files/src/app.ts\", oldString: 'export const v1 = 1', newString: 'export const v1 = 11' })\nawait tools.shell({ command: 'sleep 1' })\nawait Bun.write(\"/repo/files/src/step-2.ts\", 'export const s = 2\\n')\nreturn 'settled'"},"metadata":{"toolCalls":[{"tool":"Bun","status":"completed","input":{"method":"write","path":"/repo/files/src/step-1.ts"}},{"tool":"shell","status":"completed","input":{"command":"sleep 1"}},{"tool":"edit","status":"completed","input":{"path":"/repo/files/src/app.ts","oldString":"export const v1 = 1","newString":"export const v1 = 11"}},{"tool":"shell","status":"completed","input":{"command":"sleep 1"}},{"tool":"Bun","status":"completed","input":{"method":"write","path":"/repo/files/src/step-2.ts"}}],"files":[{"file":"files/src/step-1.ts","status":"added","additions":1,"deletions":0,"patch":"Index: files/src/step-1.ts\n===================================================================\n--- files/src/step-1.ts\n+++ files/src/step-1.ts\n@@ -0,0 +1,1 @@\n+export const s = 1\n"},{"file":"files/src/app.ts","additions":1,"deletions":1,"patch":"Index: files/src/app.ts\n===================================================================\n--- files/src/app.ts\n+++ files/src/app.ts\n@@ -1,6 +1,6 @@\n export const v0 = 0\n-export const v1 = 1\n+export const v1 = 11\n export const v2 = 2\n export const v3 = 300\n export const v4 = 4\n export const v5 = 5\n","status":"modified"},{"file":"files/src/step-2.ts","status":"added","additions":1,"deletions":0,"patch":"Index: files/src/step-2.ts\n===================================================================\n--- files/src/step-2.ts\n+++ files/src/step-2.ts\n@@ -0,0 +1,1 @@\n+export const s = 2\n"}],"truncated":false},"content":[{"type":"text","text":"settled"}]},"executed":false}},{"file":"25-execute-nterleaved_5-called.json","reason":"called","at":1795629372763,"eventIndex":108,"part":{"type":"tool","id":"call_interleaved_5","name":"execute","time":{"created":1795629372757,"ran":1795629372763},"state":{"status":"running","input":{"code":"try { await tools.read({ path: \"/repo/files/CHANGES.md\" }) } catch (e) { }\nawait tools.edit({ path: \"/repo/files/notes.md\", oldString: '- one', newString: '- one\\n- v3 is 300, helpers in util.ts' })\nreturn 'notes updated'"},"metadata":{}},"executed":false}},{"file":"26-execute-nterleaved_5-first-progress.json","reason":"first-progress","at":1795629372767,"eventIndex":111,"part":{"type":"tool","id":"call_interleaved_5","name":"execute","time":{"created":1795629372757,"ran":1795629372763},"state":{"status":"running","input":{"code":"try { await tools.read({ path: \"/repo/files/CHANGES.md\" }) } catch (e) { }\nawait tools.edit({ path: \"/repo/files/notes.md\", oldString: '- one', newString: '- one\\n- v3 is 300, helpers in util.ts' })\nreturn 'notes updated'"},"metadata":{"background":true}},"executed":false}},{"file":"27-execute-nterleaved_5-progress.json","reason":"progress","at":1795629372773,"eventIndex":112,"part":{"type":"tool","id":"call_interleaved_5","name":"execute","time":{"created":1795629372757,"ran":1795629372763},"state":{"status":"running","input":{"code":"try { await tools.read({ path: \"/repo/files/CHANGES.md\" }) } catch (e) { }\nawait tools.edit({ path: \"/repo/files/notes.md\", oldString: '- one', newString: '- one\\n- v3 is 300, helpers in util.ts' })\nreturn 'notes updated'"},"metadata":{"toolCalls":[{"tool":"read","status":"running","input":{"path":"/repo/files/CHANGES.md"}}],"background":true}},"executed":false}},{"file":"28-execute-nterleaved_5-final.json","reason":"final","at":1795629372783,"eventIndex":113,"part":{"type":"tool","id":"call_interleaved_5","name":"execute","time":{"created":1795629372757,"ran":1795629372763,"completed":1795629372783},"state":{"status":"completed","input":{"code":"try { await tools.read({ path: \"/repo/files/CHANGES.md\" }) } catch (e) { }\nawait tools.edit({ path: \"/repo/files/notes.md\", oldString: '- one', newString: '- one\\n- v3 is 300, helpers in util.ts' })\nreturn 'notes updated'"},"metadata":{"toolCalls":[{"tool":"read","status":"error","input":{"path":"/repo/files/CHANGES.md"}},{"tool":"edit","status":"completed","input":{"path":"/repo/files/notes.md","oldString":"- one","newString":"- one\n- v3 is 300, helpers in util.ts"}}],"files":[{"file":"files/notes.md","additions":1,"deletions":0,"patch":"Index: files/notes.md\n===================================================================\n--- files/notes.md\n+++ files/notes.md\n@@ -1,3 +1,4 @@\n # Notes\n \n - one\n+- v3 is 300, helpers in util.ts\n","status":"modified"}],"truncated":false},"content":[{"type":"text","text":"notes updated"}]},"executed":false}},{"file":"29-execute-nterleaved_6-called.json","reason":"called","at":1795629372832,"eventIndex":124,"part":{"type":"tool","id":"call_interleaved_6","name":"execute","time":{"created":1795629372825,"ran":1795629372832},"state":{"status":"running","input":{"code":"await tools.edit({ path: \"/repo/files/src/app.ts\", oldString: 'export const v20 = 20', newString: 'export const v20 = 2000' })\nawait tools.edit({ path: \"/repo/files/src/util.ts\", oldString: 'export const double = (n: number) => n * 2', newString: 'export const double = (n: number) => n * 2\\nexport const triple = (n: number) => n * 3' })\nreturn 'ok'"},"metadata":{}},"executed":false}},{"file":"30-execute-nterleaved_6-first-progress.json","reason":"first-progress","at":1795629372835,"eventIndex":126,"part":{"type":"tool","id":"call_interleaved_6","name":"execute","time":{"created":1795629372825,"ran":1795629372832},"state":{"status":"running","input":{"code":"await tools.edit({ path: \"/repo/files/src/app.ts\", oldString: 'export const v20 = 20', newString: 'export const v20 = 2000' })\nawait tools.edit({ path: \"/repo/files/src/util.ts\", oldString: 'export const double = (n: number) => n * 2', newString: 'export const double = (n: number) => n * 2\\nexport const triple = (n: number) => n * 3' })\nreturn 'ok'"},"metadata":{"background":true}},"executed":false}},{"file":"31-execute-nterleaved_6-progress.json","reason":"progress","at":1795629372838,"eventIndex":127,"part":{"type":"tool","id":"call_interleaved_6","name":"execute","time":{"created":1795629372825,"ran":1795629372832},"state":{"status":"running","input":{"code":"await tools.edit({ path: \"/repo/files/src/app.ts\", oldString: 'export const v20 = 20', newString: 'export const v20 = 2000' })\nawait tools.edit({ path: \"/repo/files/src/util.ts\", oldString: 'export const double = (n: number) => n * 2', newString: 'export const double = (n: number) => n * 2\\nexport const triple = (n: number) => n * 3' })\nreturn 'ok'"},"metadata":{"toolCalls":[{"tool":"edit","status":"running","input":{"path":"/repo/files/src/app.ts","oldString":"export const v20 = 20","newString":"export const v20 = 2000"}}],"background":true}},"executed":false}},{"file":"32-execute-nterleaved_6-final.json","reason":"final","at":1795629372845,"eventIndex":128,"part":{"type":"tool","id":"call_interleaved_6","name":"execute","time":{"created":1795629372825,"ran":1795629372832,"completed":1795629372845},"state":{"status":"completed","input":{"code":"await tools.edit({ path: \"/repo/files/src/app.ts\", oldString: 'export const v20 = 20', newString: 'export const v20 = 2000' })\nawait tools.edit({ path: \"/repo/files/src/util.ts\", oldString: 'export const double = (n: number) => n * 2', newString: 'export const double = (n: number) => n * 2\\nexport const triple = (n: number) => n * 3' })\nreturn 'ok'"},"metadata":{"toolCalls":[{"tool":"edit","status":"completed","input":{"path":"/repo/files/src/app.ts","oldString":"export const v20 = 20","newString":"export const v20 = 2000"}},{"tool":"edit","status":"completed","input":{"path":"/repo/files/src/util.ts","oldString":"export const double = (n: number) => n * 2","newString":"export const double = (n: number) => n * 2\nexport const triple = (n: number) => n * 3"}}],"files":[{"file":"files/src/app.ts","additions":1,"deletions":1,"patch":"Index: files/src/app.ts\n===================================================================\n--- files/src/app.ts\n+++ files/src/app.ts\n@@ -17,9 +17,9 @@\n export const v16 = 16\n export const v17 = 17\n export const v18 = 18\n export const v19 = 19\n-export const v20 = 20\n+export const v20 = 2000\n export const v21 = 21\n export const v22 = 22\n export const v23 = 23\n export const v24 = 24\n","status":"modified"},{"file":"files/src/util.ts","additions":1,"deletions":0,"patch":"Index: files/src/util.ts\n===================================================================\n--- files/src/util.ts\n+++ files/src/util.ts\n@@ -1,1 +1,2 @@\n export const double = (n: number) => n * 2\n+export const triple = (n: number) => n * 3\n","status":"modified"}],"truncated":false},"content":[{"type":"text","text":"ok"}]},"executed":false}},{"file":"33-execute-nterleaved_7-called.json","reason":"called","at":1795629372888,"eventIndex":139,"part":{"type":"tool","id":"call_interleaved_7","name":"execute","time":{"created":1795629372882,"ran":1795629372888},"state":{"status":"running","input":{"code":"await Bun.file(\"/repo/files/old.txt\").delete()\nawait Bun.write(\"/repo/files/MOVED.md\", 'old.txt was removed; see notes.md\\n')\nreturn 'moved'"},"metadata":{}},"executed":false}},{"file":"34-execute-nterleaved_7-first-progress.json","reason":"first-progress","at":1795629372892,"eventIndex":141,"part":{"type":"tool","id":"call_interleaved_7","name":"execute","time":{"created":1795629372882,"ran":1795629372888},"state":{"status":"running","input":{"code":"await Bun.file(\"/repo/files/old.txt\").delete()\nawait Bun.write(\"/repo/files/MOVED.md\", 'old.txt was removed; see notes.md\\n')\nreturn 'moved'"},"metadata":{"background":true}},"executed":false}},{"file":"35-execute-nterleaved_7-progress.json","reason":"progress","at":1795629372895,"eventIndex":142,"part":{"type":"tool","id":"call_interleaved_7","name":"execute","time":{"created":1795629372882,"ran":1795629372888},"state":{"status":"running","input":{"code":"await Bun.file(\"/repo/files/old.txt\").delete()\nawait Bun.write(\"/repo/files/MOVED.md\", 'old.txt was removed; see notes.md\\n')\nreturn 'moved'"},"metadata":{"toolCalls":[{"tool":"Bun","status":"running","input":{"method":"file","path":"/repo/files/old.txt"}}],"background":true}},"executed":false}},{"file":"36-execute-nterleaved_7-final.json","reason":"final","at":1795629372902,"eventIndex":143,"part":{"type":"tool","id":"call_interleaved_7","name":"execute","time":{"created":1795629372882,"ran":1795629372888,"completed":1795629372902},"state":{"status":"completed","input":{"code":"await Bun.file(\"/repo/files/old.txt\").delete()\nawait Bun.write(\"/repo/files/MOVED.md\", 'old.txt was removed; see notes.md\\n')\nreturn 'moved'"},"metadata":{"toolCalls":[{"tool":"Bun","status":"completed","input":{"method":"file","path":"/repo/files/old.txt"}},{"tool":"Bun","status":"completed","input":{"method":"write","path":"/repo/files/MOVED.md"}}],"files":[{"file":"files/old.txt","status":"deleted"},{"file":"files/MOVED.md","status":"added","additions":1,"deletions":0,"patch":"Index: files/MOVED.md\n===================================================================\n--- files/MOVED.md\n+++ files/MOVED.md\n@@ -0,0 +1,1 @@\n+old.txt was removed; see notes.md\n"}],"truncated":false},"content":[{"type":"text","text":"moved"}]},"executed":false}},{"file":"37-execute-nterleaved_8-called.json","reason":"called","at":1795629372949,"eventIndex":156,"part":{"type":"tool","id":"call_interleaved_8","name":"execute","time":{"created":1795629372944,"ran":1795629372949},"state":{"status":"running","input":{"code":"const notes = await tools.read({ path: \"/repo/files/notes.md\" })\nconst util = await tools.read({ path: \"/repo/files/src/util.ts\" })\nconst uses = await tools.shell({ command: 'grep -rn v3 src' })\nreturn [notes.type, util.type, uses.exitCode]"},"metadata":{}},"executed":false}},{"file":"38-execute-nterleaved_8-first-progress.json","reason":"first-progress","at":1795629372953,"eventIndex":159,"part":{"type":"tool","id":"call_interleaved_8","name":"execute","time":{"created":1795629372944,"ran":1795629372949},"state":{"status":"running","input":{"code":"const notes = await tools.read({ path: \"/repo/files/notes.md\" })\nconst util = await tools.read({ path: \"/repo/files/src/util.ts\" })\nconst uses = await tools.shell({ command: 'grep -rn v3 src' })\nreturn [notes.type, util.type, uses.exitCode]"},"metadata":{"background":true}},"executed":false}},{"file":"39-execute-nterleaved_8-progress.json","reason":"progress","at":1795629372956,"eventIndex":160,"part":{"type":"tool","id":"call_interleaved_8","name":"execute","time":{"created":1795629372944,"ran":1795629372949},"state":{"status":"running","input":{"code":"const notes = await tools.read({ path: \"/repo/files/notes.md\" })\nconst util = await tools.read({ path: \"/repo/files/src/util.ts\" })\nconst uses = await tools.shell({ command: 'grep -rn v3 src' })\nreturn [notes.type, util.type, uses.exitCode]"},"metadata":{"toolCalls":[{"tool":"read","status":"running","input":{"path":"/repo/files/notes.md"}}],"background":true}},"executed":false}},{"file":"40-execute-nterleaved_8-final.json","reason":"final","at":1795629372971,"eventIndex":163,"part":{"type":"tool","id":"call_interleaved_8","name":"execute","time":{"created":1795629372944,"ran":1795629372949,"completed":1795629372971},"state":{"status":"completed","input":{"code":"const notes = await tools.read({ path: \"/repo/files/notes.md\" })\nconst util = await tools.read({ path: \"/repo/files/src/util.ts\" })\nconst uses = await tools.shell({ command: 'grep -rn v3 src' })\nreturn [notes.type, util.type, uses.exitCode]"},"metadata":{"toolCalls":[{"tool":"read","status":"completed","input":{"path":"/repo/files/notes.md"}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/util.ts"}},{"tool":"shell","status":"completed","input":{"command":"grep -rn v3 src"}}],"truncated":false},"content":[{"type":"text","text":"[\"text\",\"text\",2]"}]},"executed":false}},{"file":"41-execute-nterleaved_9-called.json","reason":"called","at":1795629373019,"eventIndex":174,"part":{"type":"tool","id":"call_interleaved_9","name":"execute","time":{"created":1795629373011,"ran":1795629373019},"state":{"status":"running","input":{"code":"const count = await tools.shell({ command: 'wc -l src/app.ts src/util.ts' })\nawait Bun.write(\"/repo/files/CHANGELOG.md\", '# Changelog\\n\\n- v3 = 300, v20 = 2000, v1 = 11\\n- util.ts: double, triple\\n')\nreturn count.exitCode"},"metadata":{}},"executed":false}},{"file":"42-execute-nterleaved_9-first-progress.json","reason":"first-progress","at":1795629373021,"eventIndex":176,"part":{"type":"tool","id":"call_interleaved_9","name":"execute","time":{"created":1795629373011,"ran":1795629373019},"state":{"status":"running","input":{"code":"const count = await tools.shell({ command: 'wc -l src/app.ts src/util.ts' })\nawait Bun.write(\"/repo/files/CHANGELOG.md\", '# Changelog\\n\\n- v3 = 300, v20 = 2000, v1 = 11\\n- util.ts: double, triple\\n')\nreturn count.exitCode"},"metadata":{"background":true}},"executed":false}},{"file":"43-execute-nterleaved_9-progress.json","reason":"progress","at":1795629373024,"eventIndex":177,"part":{"type":"tool","id":"call_interleaved_9","name":"execute","time":{"created":1795629373011,"ran":1795629373019},"state":{"status":"running","input":{"code":"const count = await tools.shell({ command: 'wc -l src/app.ts src/util.ts' })\nawait Bun.write(\"/repo/files/CHANGELOG.md\", '# Changelog\\n\\n- v3 = 300, v20 = 2000, v1 = 11\\n- util.ts: double, triple\\n')\nreturn count.exitCode"},"metadata":{"toolCalls":[{"tool":"shell","status":"running","input":{"command":"wc -l src/app.ts src/util.ts"}}],"background":true}},"executed":false}},{"file":"44-execute-nterleaved_9-final.json","reason":"final","at":1795629373036,"eventIndex":180,"part":{"type":"tool","id":"call_interleaved_9","name":"execute","time":{"created":1795629373011,"ran":1795629373019,"completed":1795629373036},"state":{"status":"completed","input":{"code":"const count = await tools.shell({ command: 'wc -l src/app.ts src/util.ts' })\nawait Bun.write(\"/repo/files/CHANGELOG.md\", '# Changelog\\n\\n- v3 = 300, v20 = 2000, v1 = 11\\n- util.ts: double, triple\\n')\nreturn count.exitCode"},"metadata":{"toolCalls":[{"tool":"shell","status":"completed","input":{"command":"wc -l src/app.ts src/util.ts"}},{"tool":"Bun","status":"completed","input":{"method":"write","path":"/repo/files/CHANGELOG.md"}}],"files":[{"file":"files/CHANGELOG.md","status":"added","additions":4,"deletions":0,"patch":"Index: files/CHANGELOG.md\n===================================================================\n--- files/CHANGELOG.md\n+++ files/CHANGELOG.md\n@@ -0,0 +1,4 @@\n+# Changelog\n+\n+- v3 = 300, v20 = 2000, v1 = 11\n+- util.ts: double, triple\n"}],"truncated":false},"content":[{"type":"text","text":"1"}]},"executed":false}}]} diff --git a/packages/session-ui/src/storybook/codemode-snapshots/interrupted.json b/packages/session-ui/src/storybook/codemode-snapshots/interrupted.json new file mode 100644 index 00000000000..eda6e16bc1f --- /dev/null +++ b/packages/session-ui/src/storybook/codemode-snapshots/interrupted.json @@ -0,0 +1 @@ +{"session":{"id":"ses_decc9e101ffeXSo9ICcdOrsZA3","title":"interrupted","directory":"/repo","time":{"created":1795618643712,"updated":1795618643712}},"messages":{"data":[{"id":"msg_21336210c00235EsxF29ch6924","time":{"created":1795618644236},"type":"idle","outcome":"interrupted"},{"id":"msg_213361f14001ckvg47FGTjMPRw","time":{"created":1795618643734,"firstToken":1795618643744,"streamed":1795618643756,"completed":1795618644234},"type":"assistant","agent":"build","model":{"id":"claude-opus-5-5","providerID":"simulation","variant":"default"},"content":[{"type":"text","text":"Running interrupted."},{"type":"tool","id":"call_interrupted","name":"execute","executed":false,"state":{"status":"error","input":{"code":"await Bun.write(\"/repo/files/src/partial.ts\", 'export const partial = 1\\n')\nawait tools.edit({ path: \"/repo/files/src/app.ts\", oldString: 'export const v9 = 9', newString: 'export const v9 = 99' })\nawait tools.shell({ command: 'sleep 30' })\nawait Bun.write(\"/repo/files/src/never.ts\", 'x')\nreturn 'unreachable'"},"error":{"type":"aborted","message":"Tool execution interrupted"},"metadata":{"toolCalls":[{"tool":"Bun","status":"completed","input":{"method":"write","path":"/repo/files/src/partial.ts"}},{"tool":"edit","status":"completed","input":{"path":"/repo/files/src/app.ts","oldString":"export const v9 = 9","newString":"export const v9 = 99"}},{"tool":"shell","status":"error","input":{"command":"sleep 30"}}],"files":[{"file":"files/src/partial.ts","status":"added","additions":1,"deletions":0,"patch":"Index: files/src/partial.ts\n===================================================================\n--- files/src/partial.ts\n+++ files/src/partial.ts\n@@ -0,0 +1,1 @@\n+export const partial = 1\n"},{"file":"files/src/app.ts","additions":1,"deletions":1,"patch":"Index: files/src/app.ts\n===================================================================\n--- files/src/app.ts\n+++ files/src/app.ts\n@@ -6,9 +6,9 @@\n export const v5 = 55\n export const v6 = 6\n export const v7 = 77\n export const v8 = 8\n-export const v9 = 9\n+export const v9 = 99\n export const v10 = 10\n export const v11 = 11\n export const v12 = 12\n export const v13 = 13\n","status":"modified"}],"background":true}},"time":{"created":1795618643749,"ran":1795618643754,"completed":1795618644231}}],"finish":"error","rawFinish":"tool_calls","cost":0,"tokens":{"input":0,"output":0,"reasoning":0,"cache":{"read":0,"write":0}},"error":{"type":"aborted","message":"Step interrupted"}},{"id":"msg_213361f04001J0Gm1kqqhUiNY0","time":{"created":1795618643727},"text":"SCN:interrupted please","type":"user"}],"cursor":{"previous":"eyJpZCI6Im1zZ18yMTMzNjIxMGMwMDIzNUVzeEYyOWNoNjkyNCIsIm9yZGVyIjoiZGVzYyIsImRpcmVjdGlvbiI6InByZXZpb3VzIn0","next":"eyJpZCI6Im1zZ18yMTMzNjFmMDQwMDFKMEdtMWtxcWhVaU5ZMCIsIm9yZGVyIjoiZGVzYyIsImRpcmVjdGlvbiI6Im5leHQifQ"}},"states":[{"file":"00-execute-interrupted-called.json","reason":"called","at":1795618643754,"eventIndex":11,"part":{"type":"tool","id":"call_interrupted","name":"execute","time":{"created":1795618643749,"ran":1795618643754},"state":{"status":"running","input":{"code":"await Bun.write(\"/repo/files/src/partial.ts\", 'export const partial = 1\\n')\nawait tools.edit({ path: \"/repo/files/src/app.ts\", oldString: 'export const v9 = 9', newString: 'export const v9 = 99' })\nawait tools.shell({ command: 'sleep 30' })\nawait Bun.write(\"/repo/files/src/never.ts\", 'x')\nreturn 'unreachable'"},"metadata":{}},"executed":false}},{"file":"01-execute-interrupted-first-progress.json","reason":"first-progress","at":1795618643758,"eventIndex":14,"part":{"type":"tool","id":"call_interrupted","name":"execute","time":{"created":1795618643749,"ran":1795618643754},"state":{"status":"running","input":{"code":"await Bun.write(\"/repo/files/src/partial.ts\", 'export const partial = 1\\n')\nawait tools.edit({ path: \"/repo/files/src/app.ts\", oldString: 'export const v9 = 9', newString: 'export const v9 = 99' })\nawait tools.shell({ command: 'sleep 30' })\nawait Bun.write(\"/repo/files/src/never.ts\", 'x')\nreturn 'unreachable'"},"metadata":{"background":true}},"executed":false}},{"file":"02-execute-interrupted-progress.json","reason":"progress","at":1795618643760,"eventIndex":15,"part":{"type":"tool","id":"call_interrupted","name":"execute","time":{"created":1795618643749,"ran":1795618643754},"state":{"status":"running","input":{"code":"await Bun.write(\"/repo/files/src/partial.ts\", 'export const partial = 1\\n')\nawait tools.edit({ path: \"/repo/files/src/app.ts\", oldString: 'export const v9 = 9', newString: 'export const v9 = 99' })\nawait tools.shell({ command: 'sleep 30' })\nawait Bun.write(\"/repo/files/src/never.ts\", 'x')\nreturn 'unreachable'"},"metadata":{"toolCalls":[{"tool":"Bun","status":"running","input":{"method":"write","path":"/repo/files/src/partial.ts"}}],"background":true}},"executed":false}},{"file":"03-execute-interrupted-files-2.json","reason":"files-2","at":1795618643861,"eventIndex":17,"part":{"type":"tool","id":"call_interrupted","name":"execute","time":{"created":1795618643749,"ran":1795618643754},"state":{"status":"running","input":{"code":"await Bun.write(\"/repo/files/src/partial.ts\", 'export const partial = 1\\n')\nawait tools.edit({ path: \"/repo/files/src/app.ts\", oldString: 'export const v9 = 9', newString: 'export const v9 = 99' })\nawait tools.shell({ command: 'sleep 30' })\nawait Bun.write(\"/repo/files/src/never.ts\", 'x')\nreturn 'unreachable'"},"metadata":{"toolCalls":[{"tool":"Bun","status":"completed","input":{"method":"write","path":"/repo/files/src/partial.ts"}},{"tool":"edit","status":"completed","input":{"path":"/repo/files/src/app.ts","oldString":"export const v9 = 9","newString":"export const v9 = 99"}},{"tool":"shell","status":"running","input":{"command":"sleep 30"}}],"files":[{"file":"files/src/partial.ts","status":"added","additions":1,"deletions":0,"patch":"Index: files/src/partial.ts\n===================================================================\n--- files/src/partial.ts\n+++ files/src/partial.ts\n@@ -0,0 +1,1 @@\n+export const partial = 1\n"},{"file":"files/src/app.ts","additions":1,"deletions":1,"patch":"Index: files/src/app.ts\n===================================================================\n--- files/src/app.ts\n+++ files/src/app.ts\n@@ -6,9 +6,9 @@\n export const v5 = 55\n export const v6 = 6\n export const v7 = 77\n export const v8 = 8\n-export const v9 = 9\n+export const v9 = 99\n export const v10 = 10\n export const v11 = 11\n export const v12 = 12\n export const v13 = 13\n","status":"modified"}],"background":true}},"executed":false}},{"file":"04-execute-interrupted-progress.json","reason":"progress","at":1795618644230,"eventIndex":20,"part":{"type":"tool","id":"call_interrupted","name":"execute","time":{"created":1795618643749,"ran":1795618643754},"state":{"status":"running","input":{"code":"await Bun.write(\"/repo/files/src/partial.ts\", 'export const partial = 1\\n')\nawait tools.edit({ path: \"/repo/files/src/app.ts\", oldString: 'export const v9 = 9', newString: 'export const v9 = 99' })\nawait tools.shell({ command: 'sleep 30' })\nawait Bun.write(\"/repo/files/src/never.ts\", 'x')\nreturn 'unreachable'"},"metadata":{"toolCalls":[{"tool":"Bun","status":"completed","input":{"method":"write","path":"/repo/files/src/partial.ts"}},{"tool":"edit","status":"completed","input":{"path":"/repo/files/src/app.ts","oldString":"export const v9 = 9","newString":"export const v9 = 99"}},{"tool":"shell","status":"error","input":{"command":"sleep 30"}}],"files":[{"file":"files/src/partial.ts","status":"added","additions":1,"deletions":0,"patch":"Index: files/src/partial.ts\n===================================================================\n--- files/src/partial.ts\n+++ files/src/partial.ts\n@@ -0,0 +1,1 @@\n+export const partial = 1\n"},{"file":"files/src/app.ts","additions":1,"deletions":1,"patch":"Index: files/src/app.ts\n===================================================================\n--- files/src/app.ts\n+++ files/src/app.ts\n@@ -6,9 +6,9 @@\n export const v5 = 55\n export const v6 = 6\n export const v7 = 77\n export const v8 = 8\n-export const v9 = 9\n+export const v9 = 99\n export const v10 = 10\n export const v11 = 11\n export const v12 = 12\n export const v13 = 13\n","status":"modified"}],"background":true}},"executed":false}},{"file":"05-execute-interrupted-final.json","reason":"final","at":1795618644231,"eventIndex":21,"part":{"type":"tool","id":"call_interrupted","name":"execute","time":{"created":1795618643749,"ran":1795618643754,"completed":1795618644231},"state":{"status":"error","error":{"type":"aborted","message":"Tool execution interrupted"},"input":{"code":"await Bun.write(\"/repo/files/src/partial.ts\", 'export const partial = 1\\n')\nawait tools.edit({ path: \"/repo/files/src/app.ts\", oldString: 'export const v9 = 9', newString: 'export const v9 = 99' })\nawait tools.shell({ command: 'sleep 30' })\nawait Bun.write(\"/repo/files/src/never.ts\", 'x')\nreturn 'unreachable'"},"metadata":{"toolCalls":[{"tool":"Bun","status":"completed","input":{"method":"write","path":"/repo/files/src/partial.ts"}},{"tool":"edit","status":"completed","input":{"path":"/repo/files/src/app.ts","oldString":"export const v9 = 9","newString":"export const v9 = 99"}},{"tool":"shell","status":"error","input":{"command":"sleep 30"}}],"files":[{"file":"files/src/partial.ts","status":"added","additions":1,"deletions":0,"patch":"Index: files/src/partial.ts\n===================================================================\n--- files/src/partial.ts\n+++ files/src/partial.ts\n@@ -0,0 +1,1 @@\n+export const partial = 1\n"},{"file":"files/src/app.ts","additions":1,"deletions":1,"patch":"Index: files/src/app.ts\n===================================================================\n--- files/src/app.ts\n+++ files/src/app.ts\n@@ -6,9 +6,9 @@\n export const v5 = 55\n export const v6 = 6\n export const v7 = 77\n export const v8 = 8\n-export const v9 = 9\n+export const v9 = 99\n export const v10 = 10\n export const v11 = 11\n export const v12 = 12\n export const v13 = 13\n","status":"modified"}],"background":true}},"executed":false}}]} diff --git a/packages/session-ui/src/storybook/codemode-snapshots/large-patch.json b/packages/session-ui/src/storybook/codemode-snapshots/large-patch.json new file mode 100644 index 00000000000..40537c054a4 --- /dev/null +++ b/packages/session-ui/src/storybook/codemode-snapshots/large-patch.json @@ -0,0 +1 @@ +{"session":{"id":"ses_decc99e27ffe0FS9o0710zKbZ2","title":"large-patch","directory":"/repo","time":{"created":1795618660826,"updated":1795618660826}},"messages":{"data":[{"id":"msg_213366254001jN7FuXWBT4ARTo","time":{"created":1795618660948},"type":"idle","outcome":"succeeded"},{"id":"msg_213366233001pb2DXn9M9u0f02","time":{"created":1795618660919,"firstToken":1795618660935,"streamed":1795618660942,"completed":1795618660943},"type":"assistant","agent":"build","model":{"id":"claude-opus-5-5","providerID":"simulation","variant":"default"},"content":[{"type":"text","text":"Done large-patch (1)."}],"finish":"stop","rawFinish":"stop","cost":0,"tokens":{"input":0,"output":0,"reasoning":0,"cache":{"read":0,"write":0}}},{"id":"msg_2133661ed001zEhjmSIc1SwjTF","time":{"created":1795618660848,"firstToken":1795618660856,"streamed":1795618660881,"completed":1795618660905},"type":"assistant","agent":"build","model":{"id":"claude-opus-5-5","providerID":"simulation","variant":"default"},"content":[{"type":"text","text":"Running large-patch."},{"type":"tool","id":"call_large_patch","name":"execute","executed":false,"state":{"status":"completed","input":{"code":"await Bun.write(\"/repo/files/big.txt\", Array.from({ length: 6000 }, (_, i) => `line ${i} ${\"x\".repeat(40)}\\n`).join(\"\"))\nawait Bun.write(\"/repo/files/small.txt\", 'small\\n')\nreturn 'ok'"},"content":[{"type":"text","text":"ok"}],"metadata":{"toolCalls":[{"tool":"Bun","status":"completed","input":{"method":"write","path":"/repo/files/big.txt"}},{"tool":"Bun","status":"completed","input":{"method":"write","path":"/repo/files/small.txt"}}],"files":[{"file":"files/big.txt","status":"added","additions":6000,"deletions":0},{"file":"files/small.txt","status":"added","additions":1,"deletions":0,"patch":"Index: files/small.txt\n===================================================================\n--- files/small.txt\n+++ files/small.txt\n@@ -0,0 +1,1 @@\n+small\n"}],"truncated":false}},"time":{"created":1795618660869,"ran":1795618660876,"completed":1795618660901}}],"finish":"tool-calls","rawFinish":"tool_calls","cost":0,"tokens":{"input":0,"output":0,"reasoning":0,"cache":{"read":0,"write":0}}},{"id":"msg_2133661de001gHR3piLBMfYeXR","time":{"created":1795618660841},"text":"SCN:large-patch please","type":"user"}],"cursor":{"previous":"eyJpZCI6Im1zZ18yMTMzNjYyNTQwMDFqTjdGdVhXQlQ0QVJUbyIsIm9yZGVyIjoiZGVzYyIsImRpcmVjdGlvbiI6InByZXZpb3VzIn0","next":"eyJpZCI6Im1zZ18yMTMzNjYxZGUwMDFnSFIzcGlMQk1mWWVYUiIsIm9yZGVyIjoiZGVzYyIsImRpcmVjdGlvbiI6Im5leHQifQ"}},"states":[{"file":"00-execute-large_patch-called.json","reason":"called","at":1795618660876,"eventIndex":11,"part":{"type":"tool","id":"call_large_patch","name":"execute","time":{"created":1795618660869,"ran":1795618660876},"state":{"status":"running","input":{"code":"await Bun.write(\"/repo/files/big.txt\", Array.from({ length: 6000 }, (_, i) => `line ${i} ${\"x\".repeat(40)}\\n`).join(\"\"))\nawait Bun.write(\"/repo/files/small.txt\", 'small\\n')\nreturn 'ok'"},"metadata":{}},"executed":false}},{"file":"01-execute-large_patch-first-progress.json","reason":"first-progress","at":1795618660885,"eventIndex":14,"part":{"type":"tool","id":"call_large_patch","name":"execute","time":{"created":1795618660869,"ran":1795618660876},"state":{"status":"running","input":{"code":"await Bun.write(\"/repo/files/big.txt\", Array.from({ length: 6000 }, (_, i) => `line ${i} ${\"x\".repeat(40)}\\n`).join(\"\"))\nawait Bun.write(\"/repo/files/small.txt\", 'small\\n')\nreturn 'ok'"},"metadata":{"background":true}},"executed":false}},{"file":"02-execute-large_patch-progress.json","reason":"progress","at":1795618660893,"eventIndex":15,"part":{"type":"tool","id":"call_large_patch","name":"execute","time":{"created":1795618660869,"ran":1795618660876},"state":{"status":"running","input":{"code":"await Bun.write(\"/repo/files/big.txt\", Array.from({ length: 6000 }, (_, i) => `line ${i} ${\"x\".repeat(40)}\\n`).join(\"\"))\nawait Bun.write(\"/repo/files/small.txt\", 'small\\n')\nreturn 'ok'"},"metadata":{"toolCalls":[{"tool":"Bun","status":"running","input":{"method":"write","path":"/repo/files/big.txt"}}],"background":true}},"executed":false}},{"file":"03-execute-large_patch-final.json","reason":"final","at":1795618660901,"eventIndex":16,"part":{"type":"tool","id":"call_large_patch","name":"execute","time":{"created":1795618660869,"ran":1795618660876,"completed":1795618660901},"state":{"status":"completed","input":{"code":"await Bun.write(\"/repo/files/big.txt\", Array.from({ length: 6000 }, (_, i) => `line ${i} ${\"x\".repeat(40)}\\n`).join(\"\"))\nawait Bun.write(\"/repo/files/small.txt\", 'small\\n')\nreturn 'ok'"},"metadata":{"toolCalls":[{"tool":"Bun","status":"completed","input":{"method":"write","path":"/repo/files/big.txt"}},{"tool":"Bun","status":"completed","input":{"method":"write","path":"/repo/files/small.txt"}}],"files":[{"file":"files/big.txt","status":"added","additions":6000,"deletions":0},{"file":"files/small.txt","status":"added","additions":1,"deletions":0,"patch":"Index: files/small.txt\n===================================================================\n--- files/small.txt\n+++ files/small.txt\n@@ -0,0 +1,1 @@\n+small\n"}],"truncated":false},"content":[{"type":"text","text":"ok"}]},"executed":false}}]} diff --git a/packages/session-ui/src/storybook/codemode-snapshots/many-calls.json b/packages/session-ui/src/storybook/codemode-snapshots/many-calls.json new file mode 100644 index 00000000000..a1bbebcec94 --- /dev/null +++ b/packages/session-ui/src/storybook/codemode-snapshots/many-calls.json @@ -0,0 +1 @@ +{"session":{"id":"ses_decc915d3ffeJV3bnUpJABSgpL","title":"many-calls","directory":"/repo","time":{"created":1795618695726,"updated":1795618695726}},"messages":{"data":[{"id":"msg_21336eb72001IdgGIQQvOgJ3q2","time":{"created":1795618696050},"type":"idle","outcome":"succeeded"},{"id":"msg_21336eb59001Zu4hKdnZRn5uv6","time":{"created":1795618696027,"firstToken":1795618696039,"streamed":1795618696045,"completed":1795618696046},"type":"assistant","agent":"build","model":{"id":"claude-opus-5-5","providerID":"simulation","variant":"default"},"content":[{"type":"text","text":"Done many-calls (1)."}],"finish":"stop","rawFinish":"stop","cost":0,"tokens":{"input":0,"output":0,"reasoning":0,"cache":{"read":0,"write":0}}},{"id":"msg_21336ea42001oTmQU7Kqxj5vLP","time":{"created":1795618695749,"firstToken":1795618695756,"streamed":1795618695772,"completed":1795618696016},"type":"assistant","agent":"build","model":{"id":"claude-opus-5-5","providerID":"simulation","variant":"default"},"content":[{"type":"text","text":"Running many-calls."},{"type":"tool","id":"call_many_calls","name":"execute","executed":false,"state":{"status":"completed","input":{"code":"const out = []\nfor (let i = 0; i < 60; i++) out.push((await tools.read({ path: \"/repo/files/src/app.ts\", limit: 2 })).type)\nfor (let i = 0; i < 25; i++) out.push((await tools.read({ path: \"/repo/files/notes.md\" })).type)\nreturn out.length"},"content":[{"type":"text","text":"85"}],"metadata":{"toolCalls":[{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/notes.md"}},{"tool":"read","status":"completed","input":{"path":"/repo/files/notes.md"}},{"tool":"read","status":"completed","input":{"path":"/repo/files/notes.md"}},{"tool":"read","status":"completed","input":{"path":"/repo/files/notes.md"}},{"tool":"read","status":"completed","input":{"path":"/repo/files/notes.md"}},{"tool":"read","status":"completed","input":{"path":"/repo/files/notes.md"}},{"tool":"read","status":"completed","input":{"path":"/repo/files/notes.md"}},{"tool":"read","status":"completed","input":{"path":"/repo/files/notes.md"}},{"tool":"read","status":"completed","input":{"path":"/repo/files/notes.md"}},{"tool":"read","status":"completed","input":{"path":"/repo/files/notes.md"}},{"tool":"read","status":"completed","input":{"path":"/repo/files/notes.md"}},{"tool":"read","status":"completed","input":{"path":"/repo/files/notes.md"}},{"tool":"read","status":"completed","input":{"path":"/repo/files/notes.md"}},{"tool":"read","status":"completed","input":{"path":"/repo/files/notes.md"}},{"tool":"read","status":"completed","input":{"path":"/repo/files/notes.md"}},{"tool":"read","status":"completed","input":{"path":"/repo/files/notes.md"}},{"tool":"read","status":"completed","input":{"path":"/repo/files/notes.md"}},{"tool":"read","status":"completed","input":{"path":"/repo/files/notes.md"}},{"tool":"read","status":"completed","input":{"path":"/repo/files/notes.md"}},{"tool":"read","status":"completed","input":{"path":"/repo/files/notes.md"}},{"tool":"read","status":"completed","input":{"path":"/repo/files/notes.md"}},{"tool":"read","status":"completed","input":{"path":"/repo/files/notes.md"}},{"tool":"read","status":"completed","input":{"path":"/repo/files/notes.md"}},{"tool":"read","status":"completed","input":{"path":"/repo/files/notes.md"}},{"tool":"read","status":"completed","input":{"path":"/repo/files/notes.md"}}],"truncated":false}},"time":{"created":1795618695764,"ran":1795618695769,"completed":1795618696013}}],"finish":"tool-calls","rawFinish":"tool_calls","cost":0,"tokens":{"input":0,"output":0,"reasoning":0,"cache":{"read":0,"write":0}}},{"id":"msg_21336ea320019dbnYN1NOsacdX","time":{"created":1795618695742},"text":"SCN:many-calls please","type":"user"}],"cursor":{"previous":"eyJpZCI6Im1zZ18yMTMzNmViNzIwMDFJZGdHSVFRdk9nSjNxMiIsIm9yZGVyIjoiZGVzYyIsImRpcmVjdGlvbiI6InByZXZpb3VzIn0","next":"eyJpZCI6Im1zZ18yMTMzNmVhMzIwMDE5ZGJuWU4xTk9zYWNkWCIsIm9yZGVyIjoiZGVzYyIsImRpcmVjdGlvbiI6Im5leHQifQ"}},"states":[{"file":"00-execute-many_calls-called.json","reason":"called","at":1795618695769,"eventIndex":11,"part":{"type":"tool","id":"call_many_calls","name":"execute","time":{"created":1795618695764,"ran":1795618695769},"state":{"status":"running","input":{"code":"const out = []\nfor (let i = 0; i < 60; i++) out.push((await tools.read({ path: \"/repo/files/src/app.ts\", limit: 2 })).type)\nfor (let i = 0; i < 25; i++) out.push((await tools.read({ path: \"/repo/files/notes.md\" })).type)\nreturn out.length"},"metadata":{}},"executed":false}},{"file":"01-execute-many_calls-first-progress.json","reason":"first-progress","at":1795618695773,"eventIndex":14,"part":{"type":"tool","id":"call_many_calls","name":"execute","time":{"created":1795618695764,"ran":1795618695769},"state":{"status":"running","input":{"code":"const out = []\nfor (let i = 0; i < 60; i++) out.push((await tools.read({ path: \"/repo/files/src/app.ts\", limit: 2 })).type)\nfor (let i = 0; i < 25; i++) out.push((await tools.read({ path: \"/repo/files/notes.md\" })).type)\nreturn out.length"},"metadata":{"background":true}},"executed":false}},{"file":"02-execute-many_calls-progress.json","reason":"progress","at":1795618695778,"eventIndex":15,"part":{"type":"tool","id":"call_many_calls","name":"execute","time":{"created":1795618695764,"ran":1795618695769},"state":{"status":"running","input":{"code":"const out = []\nfor (let i = 0; i < 60; i++) out.push((await tools.read({ path: \"/repo/files/src/app.ts\", limit: 2 })).type)\nfor (let i = 0; i < 25; i++) out.push((await tools.read({ path: \"/repo/files/notes.md\" })).type)\nreturn out.length"},"metadata":{"toolCalls":[{"tool":"read","status":"running","input":{"path":"/repo/files/src/app.ts","limit":2}}],"background":true}},"executed":false}},{"file":"03-execute-many_calls-progress.json","reason":"progress","at":1795618695909,"eventIndex":16,"part":{"type":"tool","id":"call_many_calls","name":"execute","time":{"created":1795618695764,"ran":1795618695769},"state":{"status":"running","input":{"code":"const out = []\nfor (let i = 0; i < 60; i++) out.push((await tools.read({ path: \"/repo/files/src/app.ts\", limit: 2 })).type)\nfor (let i = 0; i < 25; i++) out.push((await tools.read({ path: \"/repo/files/notes.md\" })).type)\nreturn out.length"},"metadata":{"toolCalls":[{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"running","input":{"path":"/repo/files/src/app.ts","limit":2}}],"background":true}},"executed":false}},{"file":"04-execute-many_calls-final.json","reason":"final","at":1795618696013,"eventIndex":17,"part":{"type":"tool","id":"call_many_calls","name":"execute","time":{"created":1795618695764,"ran":1795618695769,"completed":1795618696013},"state":{"status":"completed","input":{"code":"const out = []\nfor (let i = 0; i < 60; i++) out.push((await tools.read({ path: \"/repo/files/src/app.ts\", limit: 2 })).type)\nfor (let i = 0; i < 25; i++) out.push((await tools.read({ path: \"/repo/files/notes.md\" })).type)\nreturn out.length"},"metadata":{"toolCalls":[{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/src/app.ts","limit":2}},{"tool":"read","status":"completed","input":{"path":"/repo/files/notes.md"}},{"tool":"read","status":"completed","input":{"path":"/repo/files/notes.md"}},{"tool":"read","status":"completed","input":{"path":"/repo/files/notes.md"}},{"tool":"read","status":"completed","input":{"path":"/repo/files/notes.md"}},{"tool":"read","status":"completed","input":{"path":"/repo/files/notes.md"}},{"tool":"read","status":"completed","input":{"path":"/repo/files/notes.md"}},{"tool":"read","status":"completed","input":{"path":"/repo/files/notes.md"}},{"tool":"read","status":"completed","input":{"path":"/repo/files/notes.md"}},{"tool":"read","status":"completed","input":{"path":"/repo/files/notes.md"}},{"tool":"read","status":"completed","input":{"path":"/repo/files/notes.md"}},{"tool":"read","status":"completed","input":{"path":"/repo/files/notes.md"}},{"tool":"read","status":"completed","input":{"path":"/repo/files/notes.md"}},{"tool":"read","status":"completed","input":{"path":"/repo/files/notes.md"}},{"tool":"read","status":"completed","input":{"path":"/repo/files/notes.md"}},{"tool":"read","status":"completed","input":{"path":"/repo/files/notes.md"}},{"tool":"read","status":"completed","input":{"path":"/repo/files/notes.md"}},{"tool":"read","status":"completed","input":{"path":"/repo/files/notes.md"}},{"tool":"read","status":"completed","input":{"path":"/repo/files/notes.md"}},{"tool":"read","status":"completed","input":{"path":"/repo/files/notes.md"}},{"tool":"read","status":"completed","input":{"path":"/repo/files/notes.md"}},{"tool":"read","status":"completed","input":{"path":"/repo/files/notes.md"}},{"tool":"read","status":"completed","input":{"path":"/repo/files/notes.md"}},{"tool":"read","status":"completed","input":{"path":"/repo/files/notes.md"}},{"tool":"read","status":"completed","input":{"path":"/repo/files/notes.md"}},{"tool":"read","status":"completed","input":{"path":"/repo/files/notes.md"}}],"truncated":false},"content":[{"type":"text","text":"85"}]},"executed":false}}]} diff --git a/packages/session-ui/src/storybook/codemode-snapshots/running.json b/packages/session-ui/src/storybook/codemode-snapshots/running.json new file mode 100644 index 00000000000..5c754d03d17 --- /dev/null +++ b/packages/session-ui/src/storybook/codemode-snapshots/running.json @@ -0,0 +1 @@ +{"session":{"id":"ses_decc9b74bffehwFK6HD9eilgVa","title":"running","directory":"/repo","time":{"created":1795618654390,"updated":1795618654390}},"messages":{"data":[{"id":"msg_2133660a0001cZnO7C0NTwqKCb","time":{"created":1795618660512},"type":"idle","outcome":"succeeded"},{"id":"msg_21336608a001U5IReEAD6G5QKB","time":{"created":1795618660493,"firstToken":1795618660502,"streamed":1795618660507,"completed":1795618660508},"type":"assistant","agent":"build","model":{"id":"claude-opus-5-5","providerID":"simulation","variant":"default"},"content":[{"type":"text","text":"Done running (1)."}],"finish":"stop","rawFinish":"stop","cost":0,"tokens":{"input":0,"output":0,"reasoning":0,"cache":{"read":0,"write":0}}},{"id":"msg_2133648c9001mrpxiD5pKHHhtV","time":{"created":1795618654411,"firstToken":1795618654418,"streamed":1795618654432,"completed":1795618660480},"type":"assistant","agent":"build","model":{"id":"claude-opus-5-5","providerID":"simulation","variant":"default"},"content":[{"type":"text","text":"Running running."},{"type":"tool","id":"call_running","name":"execute","executed":false,"state":{"status":"completed","input":{"code":"await Bun.write(\"/repo/files/src/step-1.ts\", 'export const s = 1\\n')\nawait tools.shell({ command: 'sleep 2' })\nawait Bun.write(\"/repo/files/src/step-2.ts\", 'export const s = 2\\n')\nawait tools.shell({ command: 'sleep 2' })\nawait tools.edit({ path: \"/repo/files/src/app.ts\", oldString: 'export const v1 = 1', newString: 'export const v1 = 11' })\nawait tools.shell({ command: 'sleep 2' })\nawait Bun.write(\"/repo/files/src/step-1.ts\", 'export const s = 100\\n')\nreturn 'ok'"},"content":[{"type":"text","text":"ok"}],"metadata":{"toolCalls":[{"tool":"Bun","status":"completed","input":{"method":"write","path":"/repo/files/src/step-1.ts"}},{"tool":"shell","status":"completed","input":{"command":"sleep 2"}},{"tool":"Bun","status":"completed","input":{"method":"write","path":"/repo/files/src/step-2.ts"}},{"tool":"shell","status":"completed","input":{"command":"sleep 2"}},{"tool":"edit","status":"completed","input":{"path":"/repo/files/src/app.ts","oldString":"export const v1 = 1","newString":"export const v1 = 11"}},{"tool":"shell","status":"completed","input":{"command":"sleep 2"}},{"tool":"Bun","status":"completed","input":{"method":"write","path":"/repo/files/src/step-1.ts"}}],"files":[{"file":"files/src/step-1.ts","status":"added","additions":1,"deletions":0,"patch":"Index: files/src/step-1.ts\n===================================================================\n--- files/src/step-1.ts\n+++ files/src/step-1.ts\n@@ -0,0 +1,1 @@\n+export const s = 1\n"},{"file":"files/src/step-2.ts","status":"added","additions":1,"deletions":0,"patch":"Index: files/src/step-2.ts\n===================================================================\n--- files/src/step-2.ts\n+++ files/src/step-2.ts\n@@ -0,0 +1,1 @@\n+export const s = 2\n"},{"file":"files/src/app.ts","additions":1,"deletions":1,"patch":"Index: files/src/app.ts\n===================================================================\n--- files/src/app.ts\n+++ files/src/app.ts\n@@ -1,6 +1,6 @@\n export const v0 = 0\n-export const v1 = 1\n+export const v1 = 11\n export const v2 = 2\n export const v3 = 300\n export const v4 = 4\n export const v5 = 55\n","status":"modified"},{"file":"files/src/step-1.ts","status":"modified","additions":1,"deletions":1,"patch":"Index: files/src/step-1.ts\n===================================================================\n--- files/src/step-1.ts\n+++ files/src/step-1.ts\n@@ -1,1 +1,1 @@\n-export const s = 1\n+export const s = 100\n"}],"truncated":false}},"time":{"created":1795618654423,"ran":1795618654429,"completed":1795618660477}}],"finish":"tool-calls","rawFinish":"tool_calls","cost":0,"tokens":{"input":0,"output":0,"reasoning":0,"cache":{"read":0,"write":0}}},{"id":"msg_2133648ba0015Nf7w0z73jav6F","time":{"created":1795618654404},"text":"SCN:running please","type":"user"}],"cursor":{"previous":"eyJpZCI6Im1zZ18yMTMzNjYwYTAwMDFjWm5PN0MwTlR3cUtDYiIsIm9yZGVyIjoiZGVzYyIsImRpcmVjdGlvbiI6InByZXZpb3VzIn0","next":"eyJpZCI6Im1zZ18yMTMzNjQ4YmEwMDE1TmY3dzB6NzNqYXY2RiIsIm9yZGVyIjoiZGVzYyIsImRpcmVjdGlvbiI6Im5leHQifQ"}},"states":[{"file":"00-execute-running-called.json","reason":"called","at":1795618654429,"eventIndex":11,"part":{"type":"tool","id":"call_running","name":"execute","time":{"created":1795618654423,"ran":1795618654429},"state":{"status":"running","input":{"code":"await Bun.write(\"/repo/files/src/step-1.ts\", 'export const s = 1\\n')\nawait tools.shell({ command: 'sleep 2' })\nawait Bun.write(\"/repo/files/src/step-2.ts\", 'export const s = 2\\n')\nawait tools.shell({ command: 'sleep 2' })\nawait tools.edit({ path: \"/repo/files/src/app.ts\", oldString: 'export const v1 = 1', newString: 'export const v1 = 11' })\nawait tools.shell({ command: 'sleep 2' })\nawait Bun.write(\"/repo/files/src/step-1.ts\", 'export const s = 100\\n')\nreturn 'ok'"},"metadata":{}},"executed":false}},{"file":"01-execute-running-first-progress.json","reason":"first-progress","at":1795618654433,"eventIndex":14,"part":{"type":"tool","id":"call_running","name":"execute","time":{"created":1795618654423,"ran":1795618654429},"state":{"status":"running","input":{"code":"await Bun.write(\"/repo/files/src/step-1.ts\", 'export const s = 1\\n')\nawait tools.shell({ command: 'sleep 2' })\nawait Bun.write(\"/repo/files/src/step-2.ts\", 'export const s = 2\\n')\nawait tools.shell({ command: 'sleep 2' })\nawait tools.edit({ path: \"/repo/files/src/app.ts\", oldString: 'export const v1 = 1', newString: 'export const v1 = 11' })\nawait tools.shell({ command: 'sleep 2' })\nawait Bun.write(\"/repo/files/src/step-1.ts\", 'export const s = 100\\n')\nreturn 'ok'"},"metadata":{"background":true}},"executed":false}},{"file":"02-execute-running-progress.json","reason":"progress","at":1795618654436,"eventIndex":15,"part":{"type":"tool","id":"call_running","name":"execute","time":{"created":1795618654423,"ran":1795618654429},"state":{"status":"running","input":{"code":"await Bun.write(\"/repo/files/src/step-1.ts\", 'export const s = 1\\n')\nawait tools.shell({ command: 'sleep 2' })\nawait Bun.write(\"/repo/files/src/step-2.ts\", 'export const s = 2\\n')\nawait tools.shell({ command: 'sleep 2' })\nawait tools.edit({ path: \"/repo/files/src/app.ts\", oldString: 'export const v1 = 1', newString: 'export const v1 = 11' })\nawait tools.shell({ command: 'sleep 2' })\nawait Bun.write(\"/repo/files/src/step-1.ts\", 'export const s = 100\\n')\nreturn 'ok'"},"metadata":{"toolCalls":[{"tool":"Bun","status":"running","input":{"method":"write","path":"/repo/files/src/step-1.ts"}}],"background":true}},"executed":false}},{"file":"03-execute-running-files-1.json","reason":"files-1","at":1795618654539,"eventIndex":17,"part":{"type":"tool","id":"call_running","name":"execute","time":{"created":1795618654423,"ran":1795618654429},"state":{"status":"running","input":{"code":"await Bun.write(\"/repo/files/src/step-1.ts\", 'export const s = 1\\n')\nawait tools.shell({ command: 'sleep 2' })\nawait Bun.write(\"/repo/files/src/step-2.ts\", 'export const s = 2\\n')\nawait tools.shell({ command: 'sleep 2' })\nawait tools.edit({ path: \"/repo/files/src/app.ts\", oldString: 'export const v1 = 1', newString: 'export const v1 = 11' })\nawait tools.shell({ command: 'sleep 2' })\nawait Bun.write(\"/repo/files/src/step-1.ts\", 'export const s = 100\\n')\nreturn 'ok'"},"metadata":{"toolCalls":[{"tool":"Bun","status":"completed","input":{"method":"write","path":"/repo/files/src/step-1.ts"}},{"tool":"shell","status":"running","input":{"command":"sleep 2"}}],"files":[{"file":"files/src/step-1.ts","status":"added","additions":1,"deletions":0,"patch":"Index: files/src/step-1.ts\n===================================================================\n--- files/src/step-1.ts\n+++ files/src/step-1.ts\n@@ -0,0 +1,1 @@\n+export const s = 1\n"}],"background":true}},"executed":false}},{"file":"04-execute-running-progress.json","reason":"progress","at":1795618656449,"eventIndex":18,"part":{"type":"tool","id":"call_running","name":"execute","time":{"created":1795618654423,"ran":1795618654429},"state":{"status":"running","input":{"code":"await Bun.write(\"/repo/files/src/step-1.ts\", 'export const s = 1\\n')\nawait tools.shell({ command: 'sleep 2' })\nawait Bun.write(\"/repo/files/src/step-2.ts\", 'export const s = 2\\n')\nawait tools.shell({ command: 'sleep 2' })\nawait tools.edit({ path: \"/repo/files/src/app.ts\", oldString: 'export const v1 = 1', newString: 'export const v1 = 11' })\nawait tools.shell({ command: 'sleep 2' })\nawait Bun.write(\"/repo/files/src/step-1.ts\", 'export const s = 100\\n')\nreturn 'ok'"},"metadata":{"toolCalls":[{"tool":"Bun","status":"completed","input":{"method":"write","path":"/repo/files/src/step-1.ts"}},{"tool":"shell","status":"completed","input":{"command":"sleep 2"}}],"files":[{"file":"files/src/step-1.ts","status":"added","additions":1,"deletions":0,"patch":"Index: files/src/step-1.ts\n===================================================================\n--- files/src/step-1.ts\n+++ files/src/step-1.ts\n@@ -0,0 +1,1 @@\n+export const s = 1\n"}],"background":true}},"executed":false}},{"file":"05-execute-running-files-2.json","reason":"files-2","at":1795618656550,"eventIndex":21,"part":{"type":"tool","id":"call_running","name":"execute","time":{"created":1795618654423,"ran":1795618654429},"state":{"status":"running","input":{"code":"await Bun.write(\"/repo/files/src/step-1.ts\", 'export const s = 1\\n')\nawait tools.shell({ command: 'sleep 2' })\nawait Bun.write(\"/repo/files/src/step-2.ts\", 'export const s = 2\\n')\nawait tools.shell({ command: 'sleep 2' })\nawait tools.edit({ path: \"/repo/files/src/app.ts\", oldString: 'export const v1 = 1', newString: 'export const v1 = 11' })\nawait tools.shell({ command: 'sleep 2' })\nawait Bun.write(\"/repo/files/src/step-1.ts\", 'export const s = 100\\n')\nreturn 'ok'"},"metadata":{"toolCalls":[{"tool":"Bun","status":"completed","input":{"method":"write","path":"/repo/files/src/step-1.ts"}},{"tool":"shell","status":"completed","input":{"command":"sleep 2"}},{"tool":"Bun","status":"completed","input":{"method":"write","path":"/repo/files/src/step-2.ts"}},{"tool":"shell","status":"running","input":{"command":"sleep 2"}}],"files":[{"file":"files/src/step-1.ts","status":"added","additions":1,"deletions":0,"patch":"Index: files/src/step-1.ts\n===================================================================\n--- files/src/step-1.ts\n+++ files/src/step-1.ts\n@@ -0,0 +1,1 @@\n+export const s = 1\n"},{"file":"files/src/step-2.ts","status":"added","additions":1,"deletions":0,"patch":"Index: files/src/step-2.ts\n===================================================================\n--- files/src/step-2.ts\n+++ files/src/step-2.ts\n@@ -0,0 +1,1 @@\n+export const s = 2\n"}],"background":true}},"executed":false}},{"file":"06-execute-running-progress.json","reason":"progress","at":1795618658461,"eventIndex":22,"part":{"type":"tool","id":"call_running","name":"execute","time":{"created":1795618654423,"ran":1795618654429},"state":{"status":"running","input":{"code":"await Bun.write(\"/repo/files/src/step-1.ts\", 'export const s = 1\\n')\nawait tools.shell({ command: 'sleep 2' })\nawait Bun.write(\"/repo/files/src/step-2.ts\", 'export const s = 2\\n')\nawait tools.shell({ command: 'sleep 2' })\nawait tools.edit({ path: \"/repo/files/src/app.ts\", oldString: 'export const v1 = 1', newString: 'export const v1 = 11' })\nawait tools.shell({ command: 'sleep 2' })\nawait Bun.write(\"/repo/files/src/step-1.ts\", 'export const s = 100\\n')\nreturn 'ok'"},"metadata":{"toolCalls":[{"tool":"Bun","status":"completed","input":{"method":"write","path":"/repo/files/src/step-1.ts"}},{"tool":"shell","status":"completed","input":{"command":"sleep 2"}},{"tool":"Bun","status":"completed","input":{"method":"write","path":"/repo/files/src/step-2.ts"}},{"tool":"shell","status":"completed","input":{"command":"sleep 2"}}],"files":[{"file":"files/src/step-1.ts","status":"added","additions":1,"deletions":0,"patch":"Index: files/src/step-1.ts\n===================================================================\n--- files/src/step-1.ts\n+++ files/src/step-1.ts\n@@ -0,0 +1,1 @@\n+export const s = 1\n"},{"file":"files/src/step-2.ts","status":"added","additions":1,"deletions":0,"patch":"Index: files/src/step-2.ts\n===================================================================\n--- files/src/step-2.ts\n+++ files/src/step-2.ts\n@@ -0,0 +1,1 @@\n+export const s = 2\n"}],"background":true}},"executed":false}},{"file":"07-execute-running-files-3.json","reason":"files-3","at":1795618658562,"eventIndex":25,"part":{"type":"tool","id":"call_running","name":"execute","time":{"created":1795618654423,"ran":1795618654429},"state":{"status":"running","input":{"code":"await Bun.write(\"/repo/files/src/step-1.ts\", 'export const s = 1\\n')\nawait tools.shell({ command: 'sleep 2' })\nawait Bun.write(\"/repo/files/src/step-2.ts\", 'export const s = 2\\n')\nawait tools.shell({ command: 'sleep 2' })\nawait tools.edit({ path: \"/repo/files/src/app.ts\", oldString: 'export const v1 = 1', newString: 'export const v1 = 11' })\nawait tools.shell({ command: 'sleep 2' })\nawait Bun.write(\"/repo/files/src/step-1.ts\", 'export const s = 100\\n')\nreturn 'ok'"},"metadata":{"toolCalls":[{"tool":"Bun","status":"completed","input":{"method":"write","path":"/repo/files/src/step-1.ts"}},{"tool":"shell","status":"completed","input":{"command":"sleep 2"}},{"tool":"Bun","status":"completed","input":{"method":"write","path":"/repo/files/src/step-2.ts"}},{"tool":"shell","status":"completed","input":{"command":"sleep 2"}},{"tool":"edit","status":"completed","input":{"path":"/repo/files/src/app.ts","oldString":"export const v1 = 1","newString":"export const v1 = 11"}},{"tool":"shell","status":"running","input":{"command":"sleep 2"}}],"files":[{"file":"files/src/step-1.ts","status":"added","additions":1,"deletions":0,"patch":"Index: files/src/step-1.ts\n===================================================================\n--- files/src/step-1.ts\n+++ files/src/step-1.ts\n@@ -0,0 +1,1 @@\n+export const s = 1\n"},{"file":"files/src/step-2.ts","status":"added","additions":1,"deletions":0,"patch":"Index: files/src/step-2.ts\n===================================================================\n--- files/src/step-2.ts\n+++ files/src/step-2.ts\n@@ -0,0 +1,1 @@\n+export const s = 2\n"},{"file":"files/src/app.ts","additions":1,"deletions":1,"patch":"Index: files/src/app.ts\n===================================================================\n--- files/src/app.ts\n+++ files/src/app.ts\n@@ -1,6 +1,6 @@\n export const v0 = 0\n-export const v1 = 1\n+export const v1 = 11\n export const v2 = 2\n export const v3 = 300\n export const v4 = 4\n export const v5 = 55\n","status":"modified"}],"background":true}},"executed":false}},{"file":"08-execute-running-progress.json","reason":"progress","at":1795618660473,"eventIndex":26,"part":{"type":"tool","id":"call_running","name":"execute","time":{"created":1795618654423,"ran":1795618654429},"state":{"status":"running","input":{"code":"await Bun.write(\"/repo/files/src/step-1.ts\", 'export const s = 1\\n')\nawait tools.shell({ command: 'sleep 2' })\nawait Bun.write(\"/repo/files/src/step-2.ts\", 'export const s = 2\\n')\nawait tools.shell({ command: 'sleep 2' })\nawait tools.edit({ path: \"/repo/files/src/app.ts\", oldString: 'export const v1 = 1', newString: 'export const v1 = 11' })\nawait tools.shell({ command: 'sleep 2' })\nawait Bun.write(\"/repo/files/src/step-1.ts\", 'export const s = 100\\n')\nreturn 'ok'"},"metadata":{"toolCalls":[{"tool":"Bun","status":"completed","input":{"method":"write","path":"/repo/files/src/step-1.ts"}},{"tool":"shell","status":"completed","input":{"command":"sleep 2"}},{"tool":"Bun","status":"completed","input":{"method":"write","path":"/repo/files/src/step-2.ts"}},{"tool":"shell","status":"completed","input":{"command":"sleep 2"}},{"tool":"edit","status":"completed","input":{"path":"/repo/files/src/app.ts","oldString":"export const v1 = 1","newString":"export const v1 = 11"}},{"tool":"shell","status":"completed","input":{"command":"sleep 2"}}],"files":[{"file":"files/src/step-1.ts","status":"added","additions":1,"deletions":0,"patch":"Index: files/src/step-1.ts\n===================================================================\n--- files/src/step-1.ts\n+++ files/src/step-1.ts\n@@ -0,0 +1,1 @@\n+export const s = 1\n"},{"file":"files/src/step-2.ts","status":"added","additions":1,"deletions":0,"patch":"Index: files/src/step-2.ts\n===================================================================\n--- files/src/step-2.ts\n+++ files/src/step-2.ts\n@@ -0,0 +1,1 @@\n+export const s = 2\n"},{"file":"files/src/app.ts","additions":1,"deletions":1,"patch":"Index: files/src/app.ts\n===================================================================\n--- files/src/app.ts\n+++ files/src/app.ts\n@@ -1,6 +1,6 @@\n export const v0 = 0\n-export const v1 = 1\n+export const v1 = 11\n export const v2 = 2\n export const v3 = 300\n export const v4 = 4\n export const v5 = 55\n","status":"modified"}],"background":true}},"executed":false}},{"file":"09-execute-running-final.json","reason":"final","at":1795618660477,"eventIndex":28,"part":{"type":"tool","id":"call_running","name":"execute","time":{"created":1795618654423,"ran":1795618654429,"completed":1795618660477},"state":{"status":"completed","input":{"code":"await Bun.write(\"/repo/files/src/step-1.ts\", 'export const s = 1\\n')\nawait tools.shell({ command: 'sleep 2' })\nawait Bun.write(\"/repo/files/src/step-2.ts\", 'export const s = 2\\n')\nawait tools.shell({ command: 'sleep 2' })\nawait tools.edit({ path: \"/repo/files/src/app.ts\", oldString: 'export const v1 = 1', newString: 'export const v1 = 11' })\nawait tools.shell({ command: 'sleep 2' })\nawait Bun.write(\"/repo/files/src/step-1.ts\", 'export const s = 100\\n')\nreturn 'ok'"},"metadata":{"toolCalls":[{"tool":"Bun","status":"completed","input":{"method":"write","path":"/repo/files/src/step-1.ts"}},{"tool":"shell","status":"completed","input":{"command":"sleep 2"}},{"tool":"Bun","status":"completed","input":{"method":"write","path":"/repo/files/src/step-2.ts"}},{"tool":"shell","status":"completed","input":{"command":"sleep 2"}},{"tool":"edit","status":"completed","input":{"path":"/repo/files/src/app.ts","oldString":"export const v1 = 1","newString":"export const v1 = 11"}},{"tool":"shell","status":"completed","input":{"command":"sleep 2"}},{"tool":"Bun","status":"completed","input":{"method":"write","path":"/repo/files/src/step-1.ts"}}],"files":[{"file":"files/src/step-1.ts","status":"added","additions":1,"deletions":0,"patch":"Index: files/src/step-1.ts\n===================================================================\n--- files/src/step-1.ts\n+++ files/src/step-1.ts\n@@ -0,0 +1,1 @@\n+export const s = 1\n"},{"file":"files/src/step-2.ts","status":"added","additions":1,"deletions":0,"patch":"Index: files/src/step-2.ts\n===================================================================\n--- files/src/step-2.ts\n+++ files/src/step-2.ts\n@@ -0,0 +1,1 @@\n+export const s = 2\n"},{"file":"files/src/app.ts","additions":1,"deletions":1,"patch":"Index: files/src/app.ts\n===================================================================\n--- files/src/app.ts\n+++ files/src/app.ts\n@@ -1,6 +1,6 @@\n export const v0 = 0\n-export const v1 = 1\n+export const v1 = 11\n export const v2 = 2\n export const v3 = 300\n export const v4 = 4\n export const v5 = 55\n","status":"modified"},{"file":"files/src/step-1.ts","status":"modified","additions":1,"deletions":1,"patch":"Index: files/src/step-1.ts\n===================================================================\n--- files/src/step-1.ts\n+++ files/src/step-1.ts\n@@ -1,1 +1,1 @@\n-export const s = 1\n+export const s = 100\n"}],"truncated":false},"content":[{"type":"text","text":"ok"}]},"executed":false}}]} diff --git a/packages/session-ui/src/storybook/codemode-snapshots/shell-truncated.json b/packages/session-ui/src/storybook/codemode-snapshots/shell-truncated.json new file mode 100644 index 00000000000..bf0b0a14b11 --- /dev/null +++ b/packages/session-ui/src/storybook/codemode-snapshots/shell-truncated.json @@ -0,0 +1 @@ +{"session":{"id":"ses_decc99c70ffe1L2Bf3ntn9k06N","title":"shell-truncated","directory":"/repo","time":{"created":1795618661264,"updated":1795618661264}},"messages":{"data":[{"id":"msg_2133663e3001oAgJBx2K3crHbF","time":{"created":1795618661347},"type":"idle","outcome":"succeeded"},{"id":"msg_2133663d2001Ztdwi7YshvOm8s","time":{"created":1795618661332,"firstToken":1795618661338,"streamed":1795618661343,"completed":1795618661344},"type":"assistant","agent":"build","model":{"id":"claude-opus-5-5","providerID":"simulation","variant":"default"},"content":[{"type":"text","text":"Done shell-truncated (1)."}],"finish":"stop","rawFinish":"stop","cost":0,"tokens":{"input":0,"output":0,"reasoning":0,"cache":{"read":0,"write":0}}},{"id":"msg_2133663a2001mJlt8efcsxDvq2","time":{"created":1795618661285,"firstToken":1795618661292,"streamed":1795618661302,"completed":1795618661322},"type":"assistant","agent":"build","model":{"id":"claude-opus-5-5","providerID":"simulation","variant":"default"},"content":[{"type":"text","text":"Running shell-truncated."},{"type":"tool","id":"call_shell_truncated","name":"execute","executed":false,"state":{"status":"completed","input":{"code":"const r = await tools.shell({ command: 'seq 1 3000' })\nreturn { truncated: r.truncated, outputPath: r.outputPath, exit: r.exitCode }"},"content":[{"type":"text","text":"{\"outputPath\":\"/repo/logs/opencode/shell/4bceb1d1c52a253f8e4d7cb1b9f5ee8dcc169637/sh_2133663be001EYWRQ8LYgYWO3g.out\",\"exit\":0}"}],"metadata":{"toolCalls":[{"tool":"shell","status":"completed","input":{"command":"seq 1 3000"}}],"truncated":false}},"time":{"created":1795618661296,"ran":1795618661300,"completed":1795618661320}}],"finish":"tool-calls","rawFinish":"tool_calls","cost":0,"tokens":{"input":0,"output":0,"reasoning":0,"cache":{"read":0,"write":0}}},{"id":"msg_213366394001Z9MLIvHrzYNFtK","time":{"created":1795618661278},"text":"SCN:shell-truncated please","type":"user"}],"cursor":{"previous":"eyJpZCI6Im1zZ18yMTMzNjYzZTMwMDFvQWdKQngySzNjckhiRiIsIm9yZGVyIjoiZGVzYyIsImRpcmVjdGlvbiI6InByZXZpb3VzIn0","next":"eyJpZCI6Im1zZ18yMTMzNjYzOTQwMDFaOU1MSXZIcnpZTkZ0SyIsIm9yZGVyIjoiZGVzYyIsImRpcmVjdGlvbiI6Im5leHQifQ"}},"states":[{"file":"00-execute-ll_truncated-called.json","reason":"called","at":1795618661300,"eventIndex":11,"part":{"type":"tool","id":"call_shell_truncated","name":"execute","time":{"created":1795618661296,"ran":1795618661300},"state":{"status":"running","input":{"code":"const r = await tools.shell({ command: 'seq 1 3000' })\nreturn { truncated: r.truncated, outputPath: r.outputPath, exit: r.exitCode }"},"metadata":{}},"executed":false}},{"file":"01-execute-ll_truncated-first-progress.json","reason":"first-progress","at":1795618661304,"eventIndex":14,"part":{"type":"tool","id":"call_shell_truncated","name":"execute","time":{"created":1795618661296,"ran":1795618661300},"state":{"status":"running","input":{"code":"const r = await tools.shell({ command: 'seq 1 3000' })\nreturn { truncated: r.truncated, outputPath: r.outputPath, exit: r.exitCode }"},"metadata":{"background":true}},"executed":false}},{"file":"02-execute-ll_truncated-progress.json","reason":"progress","at":1795618661308,"eventIndex":15,"part":{"type":"tool","id":"call_shell_truncated","name":"execute","time":{"created":1795618661296,"ran":1795618661300},"state":{"status":"running","input":{"code":"const r = await tools.shell({ command: 'seq 1 3000' })\nreturn { truncated: r.truncated, outputPath: r.outputPath, exit: r.exitCode }"},"metadata":{"toolCalls":[{"tool":"shell","status":"running","input":{"command":"seq 1 3000"}}],"background":true}},"executed":false}},{"file":"03-execute-ll_truncated-final.json","reason":"final","at":1795618661320,"eventIndex":18,"part":{"type":"tool","id":"call_shell_truncated","name":"execute","time":{"created":1795618661296,"ran":1795618661300,"completed":1795618661320},"state":{"status":"completed","input":{"code":"const r = await tools.shell({ command: 'seq 1 3000' })\nreturn { truncated: r.truncated, outputPath: r.outputPath, exit: r.exitCode }"},"metadata":{"toolCalls":[{"tool":"shell","status":"completed","input":{"command":"seq 1 3000"}}],"truncated":false},"content":[{"type":"text","text":"{\"outputPath\":\"/repo/logs/opencode/shell/4bceb1d1c52a253f8e4d7cb1b9f5ee8dcc169637/sh_2133663be001EYWRQ8LYgYWO3g.out\",\"exit\":0}"}]},"executed":false}}]} diff --git a/packages/session-ui/src/storybook/codemode-snapshots/timeout-bg.json b/packages/session-ui/src/storybook/codemode-snapshots/timeout-bg.json new file mode 100644 index 00000000000..4dcf5f55e27 --- /dev/null +++ b/packages/session-ui/src/storybook/codemode-snapshots/timeout-bg.json @@ -0,0 +1 @@ +{"session":{"id":"ses_decc9ca79ffedLx0NNPDpOtwWe","title":"timeout-bg","directory":"/repo","time":{"created":1795618649480,"updated":1795618649480}},"messages":{"data":[{"id":"msg_2133641a0001pt31lTm43yhTsz","time":{"created":1795618652576},"type":"idle","outcome":"succeeded"},{"id":"msg_21336418c001ILgTyxZsl4bsks","time":{"created":1795618652559,"firstToken":1795618652565,"streamed":1795618652571,"completed":1795618652572},"type":"assistant","agent":"build","model":{"id":"claude-opus-5-5","providerID":"simulation","variant":"default"},"content":[{"type":"text","text":"Done timeout-bg (1)."}],"finish":"stop","rawFinish":"stop","cost":0,"tokens":{"input":0,"output":0,"reasoning":0,"cache":{"read":0,"write":0}}},{"id":"msg_213363b9a0018klETRxr22EIBc","metadata":{"source":"codemode","jobID":"cm_2133635b40014aOT2Z7EG8Hdmk","state":"completed"},"time":{"created":1795618652551},"text":"\ntimeout done\n","description":"Script","type":"synthetic"},{"id":"msg_213363bb9001G1jWCvVmTcB1j6","time":{"created":1795618651065},"type":"idle","outcome":"succeeded"},{"id":"msg_213363ba5001rPv2sieX1FyDUg","time":{"created":1795618651048,"firstToken":1795618651055,"streamed":1795618651061,"completed":1795618651062},"type":"assistant","agent":"build","model":{"id":"claude-opus-5-5","providerID":"simulation","variant":"default"},"content":[{"type":"text","text":"Done timeout-bg (1)."}],"finish":"stop","rawFinish":"stop","cost":0,"tokens":{"input":0,"output":0,"reasoning":0,"cache":{"read":0,"write":0}}},{"id":"msg_21336359d001E0LEJ1NsrnZOsP","time":{"created":1795618649504,"firstToken":1795618649511,"streamed":1795618649523,"completed":1795618651037},"type":"assistant","agent":"build","model":{"id":"claude-opus-5-5","providerID":"simulation","variant":"default"},"content":[{"type":"text","text":"Running timeout-bg."},{"type":"tool","id":"call_timeout_bg","name":"execute","executed":false,"state":{"status":"completed","input":{"code":"await Bun.write(\"/repo/files/src/to-1.ts\", 'export const t = 1\\n')\nawait tools.shell({ command: 'sleep 3' })\nawait Bun.write(\"/repo/files/src/to-2.ts\", 'export const t = 2\\n')\nreturn 'timeout done'","timeout":1500},"content":[{"type":"text","text":"Script cm_2133635b40014aOT2Z7EG8Hdmk is still running; its result will arrive in this session."}],"metadata":{"jobID":"cm_2133635b40014aOT2Z7EG8Hdmk","truncated":false}},"time":{"created":1795618649516,"ran":1795618649521,"completed":1795618651035}}],"finish":"tool-calls","rawFinish":"tool_calls","cost":0,"tokens":{"input":0,"output":0,"reasoning":0,"cache":{"read":0,"write":0}}},{"id":"msg_21336358d001pTtmxpbp2IOj3M","time":{"created":1795618649497},"text":"SCN:timeout-bg please","type":"user"}],"cursor":{"previous":"eyJpZCI6Im1zZ18yMTMzNjQxYTAwMDFwdDMxbFRtNDN5aFRzeiIsIm9yZGVyIjoiZGVzYyIsImRpcmVjdGlvbiI6InByZXZpb3VzIn0","next":"eyJpZCI6Im1zZ18yMTMzNjM1OGQwMDFwVHRteHBicDJJT2ozTSIsIm9yZGVyIjoiZGVzYyIsImRpcmVjdGlvbiI6Im5leHQifQ"}},"states":[{"file":"00-execute-timeout_bg-called.json","reason":"called","at":1795618649521,"eventIndex":11,"part":{"type":"tool","id":"call_timeout_bg","name":"execute","time":{"created":1795618649516,"ran":1795618649521},"state":{"status":"running","input":{"code":"await Bun.write(\"/repo/files/src/to-1.ts\", 'export const t = 1\\n')\nawait tools.shell({ command: 'sleep 3' })\nawait Bun.write(\"/repo/files/src/to-2.ts\", 'export const t = 2\\n')\nreturn 'timeout done'","timeout":1500},"metadata":{}},"executed":false}},{"file":"01-execute-timeout_bg-first-progress.json","reason":"first-progress","at":1795618649525,"eventIndex":14,"part":{"type":"tool","id":"call_timeout_bg","name":"execute","time":{"created":1795618649516,"ran":1795618649521},"state":{"status":"running","input":{"code":"await Bun.write(\"/repo/files/src/to-1.ts\", 'export const t = 1\\n')\nawait tools.shell({ command: 'sleep 3' })\nawait Bun.write(\"/repo/files/src/to-2.ts\", 'export const t = 2\\n')\nreturn 'timeout done'","timeout":1500},"metadata":{"background":true}},"executed":false}},{"file":"02-execute-timeout_bg-progress.json","reason":"progress","at":1795618649527,"eventIndex":15,"part":{"type":"tool","id":"call_timeout_bg","name":"execute","time":{"created":1795618649516,"ran":1795618649521},"state":{"status":"running","input":{"code":"await Bun.write(\"/repo/files/src/to-1.ts\", 'export const t = 1\\n')\nawait tools.shell({ command: 'sleep 3' })\nawait Bun.write(\"/repo/files/src/to-2.ts\", 'export const t = 2\\n')\nreturn 'timeout done'","timeout":1500},"metadata":{"toolCalls":[{"tool":"Bun","status":"running","input":{"method":"write","path":"/repo/files/src/to-1.ts"}}],"background":true}},"executed":false}},{"file":"03-execute-timeout_bg-files-1.json","reason":"files-1","at":1795618649631,"eventIndex":17,"part":{"type":"tool","id":"call_timeout_bg","name":"execute","time":{"created":1795618649516,"ran":1795618649521},"state":{"status":"running","input":{"code":"await Bun.write(\"/repo/files/src/to-1.ts\", 'export const t = 1\\n')\nawait tools.shell({ command: 'sleep 3' })\nawait Bun.write(\"/repo/files/src/to-2.ts\", 'export const t = 2\\n')\nreturn 'timeout done'","timeout":1500},"metadata":{"toolCalls":[{"tool":"Bun","status":"completed","input":{"method":"write","path":"/repo/files/src/to-1.ts"}},{"tool":"shell","status":"running","input":{"command":"sleep 3"}}],"files":[{"file":"files/src/to-1.ts","status":"added","additions":1,"deletions":0,"patch":"Index: files/src/to-1.ts\n===================================================================\n--- files/src/to-1.ts\n+++ files/src/to-1.ts\n@@ -0,0 +1,1 @@\n+export const t = 1\n"}],"background":true}},"executed":false}},{"file":"04-execute-timeout_bg-final.json","reason":"final","at":1795618651035,"eventIndex":19,"part":{"type":"tool","id":"call_timeout_bg","name":"execute","time":{"created":1795618649516,"ran":1795618649521,"completed":1795618651035},"state":{"status":"completed","input":{"code":"await Bun.write(\"/repo/files/src/to-1.ts\", 'export const t = 1\\n')\nawait tools.shell({ command: 'sleep 3' })\nawait Bun.write(\"/repo/files/src/to-2.ts\", 'export const t = 2\\n')\nreturn 'timeout done'","timeout":1500},"metadata":{"jobID":"cm_2133635b40014aOT2Z7EG8Hdmk","truncated":false},"content":[{"type":"text","text":"Script cm_2133635b40014aOT2Z7EG8Hdmk is still running; its result will arrive in this session."}]},"executed":false}}]} diff --git a/packages/session-ui/src/storybook/current-session-story.tsx b/packages/session-ui/src/storybook/current-session-story.tsx index f53ca480945..dc3abb4b52b 100644 --- a/packages/session-ui/src/storybook/current-session-story.tsx +++ b/packages/session-ui/src/storybook/current-session-story.tsx @@ -11,14 +11,19 @@ import { CURRENT_SESSION_ID, STORY_TIME } from "./current-session-fixtures" export function CurrentSessionProviders(props: { document: SessionDocument + /** The session's directory, which paths in the timeline are shown relative to. */ + directory?: string + /** The location's resolved feature flags, as the app passes them. */ + flags?: Readonly> readMedia?: ReadMediaUrlFn turnDiff?: TurnDiffSource children: JSX.Element }) { return ( /** Summarize each finished turn's changed files after it. */ turnDiffs?: Accessor + /** The server's `full_codemode` flag: without it, a script's changes neither show nor count. */ + scriptDiffs?: Accessor }) { const sessionMessageByID = createMemo( () => new Map(input.sessionMessages().map((message) => [message.id, message] as const)), @@ -141,7 +143,7 @@ export function createNextTimelineProjection(input: { ) const textVisible = createMemo(() => new Map>(textParts())) - const factOf = placeFacts(input.sessionMessages) + const factOf = placeFacts(input.sessionMessages, input.scriptDiffs) const projection = createMemo(() => { const detail = input.timelineDetail() diff --git a/packages/session-ui/src/timeline-next/row.tsx b/packages/session-ui/src/timeline-next/row.tsx index acc42277bb0..0818e91c79e 100644 --- a/packages/session-ui/src/timeline-next/row.tsx +++ b/packages/session-ui/src/timeline-next/row.tsx @@ -31,10 +31,19 @@ import { useData } from "../context" import { useSources } from "../context/sources" import { turnSources } from "../sources/sources" import { SessionReadToolGroup, SessionUserMessage } from "../message/current-message" -import { FileChangeRuns, fileRuns, runDisclosureKey, ScriptChanges, taskAgentName } from "../tools/tool-renderer" +import { + FileChangeRuns, + fileRuns, + runDisclosureKey, + ScriptChanges, + ScriptOutputProvider, + taskAgentName, + type ScriptOutputPlacement, +} from "../tools/tool-renderer" import { SessionRetry } from "../components/session-retry" import { SessionError } from "../components/session-error" import type { TimelineDetail } from "../timeline/detail" +import { scriptOutputLayout } from "../timeline/script-output" import { TimelineRow, type PartRef } from "../timeline/timeline-row" import { userMessageRuns, userRunSpring } from "../timeline/user-runs" import { IDLE_TURN_PHASE, sameRef, viewTurnPhase } from "../timeline/turn-phase-machine" @@ -787,10 +796,22 @@ export function createNextTimelineRowRenderer(input: { // Each row's only space is the gap below it, which sets the row below apart. A message joining the user's message // above sits its run's 4 px below it instead, which its turn gap springs to. + const following = createMemo(() => { + const rows = input.projection.rows() + + return new Map(rows.map((row, index) => [TimelineRow.key(row), rows[index + 1]] as const)) + }) + + // Blocks stand a step further apart than a script stands from its own changes, which keep the small gap. const gap = (row: TimelineRow.TimelineRow) => { if (Predicate.isTagged(row, "TurnGap") && runs().get(row.userMessageID)?.above) return undefined + const value = gaps().get(TimelineRow.key(row)) + const next = following().get(TimelineRow.key(row)) - return gaps().get(TimelineRow.key(row)) + if (value !== "s" || !Predicate.isTagged(row, "AssistantPart") || (next && TimelineRow.scriptChanges(next))) + return value + + return "m" } const Frame = (props: { row: FramedTimelineRow; grow?: boolean; children: JSX.Element }) => ( @@ -1601,11 +1622,23 @@ export function createNextTimelineRowRenderer(input: { ) } + // Where each script's Output row goes, from the rows: after its changes when they are drawn right after it. + const scriptOutput = createMemo(() => + scriptOutputLayout(input.projection.rows(), input.projection.messageByID(), data.flag("full_codemode")), + ) + + const scriptPlacement: ScriptOutputPlacement = { + afterChanges: (partID) => scriptOutput().afterChanges.has(partID), + outputAfter: (fileID) => scriptOutput().outputAfter.get(fileID), + } + function Row(props: { row: Accessor; onSizeChange?: () => void }) { return ( - - {(_key) => render(props.row, props.onSizeChange)} - + + + {(_key) => render(props.row, props.onSizeChange)} + + ) } diff --git a/packages/session-ui/src/timeline-next/stories/codemode-captured.stories.tsx b/packages/session-ui/src/timeline-next/stories/codemode-captured.stories.tsx new file mode 100644 index 00000000000..ace56ebb68b --- /dev/null +++ b/packages/session-ui/src/timeline-next/stories/codemode-captured.stories.tsx @@ -0,0 +1,654 @@ +import { Button } from "@opencode/ui/button" +import { Collapsible } from "@opencode/ui/collapsible" +import { SegmentedControl, SegmentedControlItem } from "@opencode/ui/segmented-control" +import { TextShimmer } from "@opencode/ui/text-shimmer" +import { Predicate } from "effect" +import { For, Show, createEffect, createMemo, createSignal, onCleanup, onMount, type JSX } from "solid-js" +import { BackgroundMoveHint } from "../../../../app/src/session/timeline/message-timeline" +import { createStore, reconcile } from "solid-js/store" +import type { SessionDocument } from "../../document" +import { + codeModeDocument, + codeModeMetadata, + codeModeScenarios, + codeModeSession, + codeModeStates, + type CodeModeScenario, + type CodeModeState, +} from "../../storybook/codemode-snapshots" +import { CurrentSessionProviders } from "../../storybook/current-session-story" +import { timelinePresets, type TimelineDetail } from "../../timeline/detail" +import { Timeline, createReactiveTimelineProjection, type ReasoningMode } from "../../timeline/projection" +import { SessionTimeline } from "../../timeline/session-timeline" +import { createNextTimelineProjection } from "../projection" +import { laneGap } from "../spacing" +import { timelineStatus } from "../status" +import { StatusLane } from "../status-line" +import { NextSessionTimeline } from "./session-timeline" + +/** + * Code Mode `execute` parts captured from real runs, drawn by the real timelines at each state the client store held: + * called, first progress, progress, each time the files list grew, and final. The last step is the whole session, + * with what came after the call. Play steps through them once a second, as the live updates arrived. + * + * The controls live in the address: `?id=codemode-captured-states--captured&scenario=running&step=3&metadata=open`. + * Left and right arrows step too. + */ +export default { + title: "Code Mode/Captured states", + id: "codemode-captured-states", + parameters: { layout: "fullscreen" }, +} + +const timelines = [ + { id: "old", label: "Old" }, + { id: "new", label: "New" }, + { id: "both", label: "Side by side" }, +] as const + +const presetLabels = { + everything: "Everything", + detailed: "Detailed", + compact: "Compact", + quiet: "Quiet", + "text-only": "Messages only", +} as const + +// The control's default is a fixed 232px of equal segments, too narrow for these labels. +const segments = { width: "auto" } + +const segment = { flex: "none" } + +type Step = { label: string; file?: string; state: CodeModeState } + +const names = codeModeScenarios.map((scenario) => scenario.name) + +// Each state of the scenario's tool parts, then the whole session. +const steps = (name: CodeModeScenario): Step[] => { + const states = codeModeStates(name) + const calls = [...new Map(states.map((state) => [state.part.id, state.part.name])).entries()] + + // A session of several calls labels each state with its call, numbered where a tool runs more than once. + const call = (state: CodeModeState) => { + const named = calls.filter(([, tool]) => tool === state.part.name) + + if (named.length < 2) return state.part.name + + return `${state.part.name} ${named.findIndex(([id]) => id === state.part.id) + 1}` + } + + return [ + ...states.map((state) => ({ + label: calls.length > 1 ? `${call(state)} · ${state.reason}` : state.reason, + file: state.file, + state, + })), + { label: "session end", state: states.at(-1)! }, + ] +} + +export const Captured = { + render: () => { + const query = new URLSearchParams(location.search) + + const [state, setState] = createStore({ + scenario: names.find((name) => name === query.get("scenario")) ?? names[0], + step: query.has("step") ? Number(query.get("step")) : Number.MAX_SAFE_INTEGER, + timeline: timelines.find((item) => item.id === query.get("timeline"))?.id ?? timelines[2].id, + preset: timelinePresets.find((item) => item.id === query.get("preset"))?.id ?? timelinePresets[1].id, + // The server's `full_codemode` flag, which draws the flat execute layout. + flat: query.get("flag") !== "off", + playing: false, + metadata: query.get("metadata") === "open", + }) + + const list = createMemo(() => steps(state.scenario)) + const index = createMemo(() => Math.max(0, Math.min(state.step, list().length - 1))) + const step = createMemo(() => list()[index()]!) + const last = () => index() === list().length - 1 + const detail = createMemo(() => timelinePresets.find((preset) => preset.id === state.preset)!.value) + const session = createMemo(() => codeModeSession(state.scenario)) + + // One document that the store reconciles, so each step updates the rows the way a live progress event does. + const [view, setView] = createStore<{ document: SessionDocument }>({ + document: codeModeDocument(state.scenario, step().file, { now: Date.now() }), + }) + + createEffect(() => + setView("document", reconcile(codeModeDocument(state.scenario, step().file, { now: Date.now() }))), + ) + + createEffect(() => { + const address = new URLSearchParams(location.search) + + address.set("scenario", state.scenario) + address.set("step", String(index())) + address.set("timeline", state.timeline) + address.set("preset", state.preset) + + if (state.flat) address.delete("flag") + else address.set("flag", "off") + + if (state.metadata) address.set("metadata", "open") + else address.delete("metadata") + + history.replaceState(history.state, "", `?${address}`) + }) + + createEffect(() => { + if (!state.playing) return + + const timer = setInterval(() => { + if (last()) return setState("playing", false) + setState("step", index() + 1) + }, 1_000) + + onCleanup(() => clearInterval(timer)) + }) + + const go = (next: number) => setState({ step: Math.max(0, Math.min(next, list().length - 1)), playing: false }) + + const play = () => { + if (state.playing) return setState("playing", false) + setState({ step: last() ? 0 : index(), playing: true }) + } + + const pick = (scenario: CodeModeScenario) => setState({ scenario, step: Number.MAX_SAFE_INTEGER, playing: false }) + + const keys = (event: KeyboardEvent) => { + if (event.target instanceof HTMLElement && event.target.closest("input, textarea, select")) return + + if (event.key === "ArrowRight") go(index() + 1) + else if (event.key === "ArrowLeft") go(index() - 1) + else return + + event.preventDefault() + } + + onMount(() => window.addEventListener("keydown", keys)) + onCleanup(() => window.removeEventListener("keydown", keys)) + + // As MessageTimeline lays out a session: rows the width of the session column, then the status lane below them. + const pane = (next: boolean) => ( +
+ + + } + > + + + + +
+ ) + + return ( +
+ +
+
+ + { + const item = timelines.find((timeline) => timeline.id === value) + + if (item) setState("timeline", item.id) + }} + > + + {(item) => ( + + {item.label} + + )} + + + + + { + const preset = timelinePresets.find((item) => item.id === value) + + if (preset) setState("preset", preset.id) + }} + > + + {(preset) => ( + + {presetLabels[preset.id]} + + )} + + + + + value && setState("flat", value === "on")} + > + + On + + + Off + + + +
+
+
+ +
+
+ + {(item, at) => ( + + )} + +
+ setState("metadata", open)} + /> +
+ + {pane(state.timeline === "new")} +
+ } + > +
+ + {(next) => ( +
+
+ {next ? "New timeline" : "Old timeline"} +
+
+ {pane(next)} +
+
+ )} +
+
+ +
+ + ) + }, +} + +function Labeled(props: { label: string; children: JSX.Element }) { + return ( +
+ {props.label} + {props.children} +
+ ) +} + +// The state's raw `metadata`, as the store held it, for checking what the timeline was given. +function Metadata(props: { + state: CodeModeState + file?: string + open: boolean + onOpenChange: (open: boolean) => void +}) { + const part = () => props.state.part + const metadata = createMemo(() => codeModeMetadata(part())) + const calls = createMemo(() => metadata().toolCalls ?? []) + const files = createMemo(() => metadata().files) + + const counts = createMemo(() => + [...new Set(calls().map((call) => call.status))] + .map((status) => `${calls().filter((call) => call.status === status).length} ${status}`) + .join(", "), + ) + + const flags = createMemo(() => + (["background", "jobID", "error", "truncated"] as const).flatMap((key) => + metadata()[key] === undefined ? [] : [`${key}: ${String(metadata()[key])}`], + ), + ) + + const error = () => { + const state = part().state + + return state.status === "error" ? JSON.stringify(state.error) : undefined + } + + return ( + + + + metadata + + {part().name} · {part().state.status} · {calls().length} toolCalls · {files()?.length ?? "no"} files + {(flag) => <> · {flag}} + + + +
+ state + {props.file ?? "session end (last state)"} + status + + {part().state.status} + {(text) => <> · {text()}} + + toolCalls + + {calls().length} + {(text) => ({text()})} + + files +
+ absent}> + {(entries) => ( + 0} fallback={[]}> + + {(entry) => ( + + {entry.file} {entry.status} + + {" "} + +{entry.additions ?? 0} −{entry.deletions ?? 0} + + + no patch + + + )} + + + )} + +
+ 0}> + flags + {flags().join(" · ")} + +
+
+
+ ) +} + +const padding = "px-4 md:px-6" + +const statusLabels = { + waitingApproval: "Waiting for approval", + waitingAnswer: "Waiting for your answer", + waitingShell: "Waiting for shell", + working: "Working", +} as const + +/** The old timeline's settings as the app's timeline controller derives them from the detail setting. */ +function sessionTimelineSettings(detail: TimelineDetail) { + const reasoningMode: ReasoningMode = + detail.thinking.placement === "hidden" ? "hidden" : detail.thinking.details === "expanded" ? "full" : "compact" + + return { + reasoningMode, + shellToolDefaultOpen: detail.shell.details === "expanded", + editToolDefaultOpen: detail.edit.details === "expanded", + } +} + +/** + * The line below a working turn, as `MessageTimeline` in the app draws it at the bottom of the timeline: the New + * timeline's status lane spaced like the turn's next row, or the old 36px lane, each with Working when the app shows + * it and the offer to move a blocking call to the background. A story session has no permissions, questions, queued + * input or background tasks, so those cases are left out. + */ +function SessionStatusLane(props: { + document: SessionDocument + timelineDetail: TimelineDetail + next: boolean + flat: boolean +}) { + const input = { + sessionMessages: () => props.document.messages, + status: () => props.document.status, + scriptDiffs: () => props.flat, + timelineDetail: () => props.timelineDetail, + turnDiffs: () => false, + } + + const settings = () => sessionTimelineSettings(props.timelineDetail) + + const projection = props.next + ? createNextTimelineProjection(input) + : createReactiveTimelineProjection({ + ...input, + reasoningMode: () => settings().reasoningMode, + shellToolDefaultOpen: () => settings().shellToolDefaultOpen, + editToolDefaultOpen: () => settings().editToolDefaultOpen, + }) + + const busy = () => props.document.status.type === "busy" + + const assistant = () => { + const active = projection.activeMessageID() + + return active ? projection.assistantMessagesByParent().get(active)?.at(-1) : undefined + } + + const laneSpacing = createMemo(() => { + const active = projection.activeMessageID() + + return props.next && active ? laneGap(projection.rows(), active, projection.messageByID()) : undefined + }) + + // MessageTimeline's showWorking, the old timeline's Working. + const showWorking = createMemo(() => { + if (!busy()) return false + const active = projection.activeMessageID() + + if (!active) return false + const last = assistant() + + if (last?.retry || last?.error) return false + const content = last?.content.at(-1) + + if ( + last?.time.completed === undefined && + last?.time.streamed === undefined && + content?.type === "text" && + content.text.trim() + ) + return false + + return !projection.rows().some((row) => { + if (row.userMessageID !== active) return false + + if (Predicate.isTagged(row, "Thinking")) return true + + if (Predicate.isTagged(row, "Notice")) { + const message = projection.messageByID().get(row.messageID) + + return message?.type === "compaction" && message.status === "running" + } + + if (!Predicate.isTagged(row, "AssistantPart")) return false + + if (row.group.type === "context" && projection.lastAssistantGroupKey().get(active) === row.group.key) + return row.group.refs.every( + (ref) => + Timeline.resolveContent(projection.messageByID().get(ref.messageID), ref.partID)?.type === "reasoning", + ) + + if (row.group.type === "context" || row.group.type === "read") return false + + return (row.group.type === "part" ? [row.group.ref] : row.group.refs).some((ref) => { + const content = Timeline.resolveContent(projection.messageByID().get(ref.messageID), ref.partID) + + return content?.type === "tool" && (content.state.status === "streaming" || content.state.status === "running") + }) + }) + }) + + const nextStatus = createMemo(() => + busy() && projection.activeMessageID() ? timelineStatus({ content: assistant()?.content ?? [] }) : undefined, + ) + + const liveThought = createMemo(() => + projection + .rows() + .some((row) => Predicate.isTagged(row, "Thinking") && row.userMessageID === projection.activeMessageID()), + ) + + const working = () => { + if (!props.next) return showWorking() + const status = nextStatus() + + return !!status && (status !== "working" || !liveThought()) + } + + // The app offers the move for a foreground shell, subagent or Code Mode script, which its background service + // reports as blocking; the New timeline waits until the call has run for 300ms. + const blocking = createMemo(() => { + if (!busy()) return + const last = assistant() + + return last?.content.findLast( + (part): part is Extract => + part.type === "tool" && part.state.status === "running" && ["shell", "subagent", "execute"].includes(part.name), + ) + }) + + const [hint, setHint] = createSignal(false) + + createEffect(() => { + const part = blocking() + + if (!part) return setHint(false) + + const wait = props.next ? Math.max(0, (part.time.ran ?? part.time.created) + 300 - Date.now()) : 0 + const timer = setTimeout(() => setHint(true), wait) + + onCleanup(() => clearTimeout(timer)) + }) + + const move = () => ( + +
+ +
+
+ ) + + return ( +
+ + +
+ +
+
+ {move()} +
+ } + > + + {move()} + + + + ) +} diff --git a/packages/session-ui/src/timeline-next/stories/session-timeline.tsx b/packages/session-ui/src/timeline-next/stories/session-timeline.tsx index 34d9a710ced..635603a1b14 100644 --- a/packages/session-ui/src/timeline-next/stories/session-timeline.tsx +++ b/packages/session-ui/src/timeline-next/stories/session-timeline.tsx @@ -1,5 +1,6 @@ import { For, createMemo } from "solid-js" import { createStore } from "solid-js/store" +import { useData } from "../../context" import type { SessionDocument } from "../../document" import type { TimelineDetail } from "../../timeline/detail" import { TimelineRow } from "../../timeline/timeline-row" @@ -12,11 +13,14 @@ export function NextSessionTimeline(props: { timelineDetail: TimelineDetail turnDiffs?: boolean }) { + const data = useData() + const projection = createNextTimelineProjection({ sessionMessages: () => props.document.messages, status: () => props.document.status, timelineDetail: () => props.timelineDetail, turnDiffs: () => props.turnDiffs ?? false, + scriptDiffs: () => data.flag("full_codemode"), }) const [disclosure, setDisclosure] = createStore>({}) diff --git a/packages/session-ui/src/timeline-next/timeline-next.css b/packages/session-ui/src/timeline-next/timeline-next.css index a5201b4b6db..6dbb010470f 100644 --- a/packages/session-ui/src/timeline-next/timeline-next.css +++ b/packages/session-ui/src/timeline-next/timeline-next.css @@ -49,6 +49,11 @@ margin-top: var(--timeline-gap-s); } +/* A script's Output row after its last change sits as far below it as its changes sit from each other. */ +[data-timeline="next"] [data-script-changes] > [data-script-output] { + margin-top: var(--timeline-gap-s); +} + /* Each changed file is its own accordion, rather than one stacked group, as far from the next as any two rows. */ [data-timeline="next"] [data-component="accordion"][data-scope="apply-patch"] { @@ -445,6 +450,13 @@ padding-top: 0; } + /* An opened group spaces its items as the timeline spaces blocks; a script's changes stay by the script. */ + [data-component="context-tool-group-list"] + > [data-slot="context-tool-group-item"] + + [data-slot="context-tool-group-item"]:not([data-script-change]) { + margin-top: calc(var(--timeline-gap-m) - var(--timeline-gap-s)); + } + [data-component="context-tool-group-list"] [data-slot="context-tool-group-item"], [data-component="context-tool-group-list"] [data-slot="timeline-event-item"], [data-component="timeline-event-list"] [data-slot="timeline-event-item"] { @@ -472,6 +484,32 @@ } } + /* An open group's header stands as far above its first item as blocks stand apart (after the rule above, which + would give it the small gap). */ + [data-component="collapsed-tool-group"] + > [data-component="collapsible"].tool-collapsible + > [data-slot="collapsible-trigger"][aria-expanded="true"] { + height: calc(var(--line-height-compact) + 6px + var(--timeline-gap-m)); + padding-bottom: var(--timeline-gap-m); + } + + /* A script's static title's text sits above its first call's text as far as one call's text sits above the next: + the calls' 6px gap, plus half of how much taller a call's line is than the title's. The title sits on its own line, + not the taller line of the row around it. */ + [data-component="collapsible"].tool-collapsible:has( + > [data-slot="collapsible-content"] > [data-component="execute-tool-calls"][data-execute-layout="flat"] + ) + > [data-slot="collapsible-trigger"][data-locked] { + --execute-title-gap: calc(6px + (var(--line-height-base) - var(--line-height-compact)) / 2); + margin-bottom: 0; + padding-bottom: var(--execute-title-gap); + height: calc(var(--line-height-compact) + 6px + var(--execute-title-gap)); + + [data-slot="basic-tool-tool-info"] { + line-height: var(--line-height-compact); + } + } + /* Answers are spaced by the row gaps and trimmed to their text, as the agent's text is. */ [data-component="question-answers"] { gap: var(--timeline-gap-s); diff --git a/packages/session-ui/src/timeline-next/tools/context-group.tsx b/packages/session-ui/src/timeline-next/tools/context-group.tsx index ef4705ea967..7bb24b12e2b 100644 --- a/packages/session-ui/src/timeline-next/tools/context-group.tsx +++ b/packages/session-ui/src/timeline-next/tools/context-group.tsx @@ -288,7 +288,14 @@ export function ContextGroup(props: { } > - {(part) =>
{part.render()}
} + {(part) => ( +
+ {part.render()} +
+ )} } > diff --git a/packages/session-ui/src/timeline/facts.test.ts b/packages/session-ui/src/timeline/facts.test.ts index e6a46abc771..bb12cb5ffd7 100644 --- a/packages/session-ui/src/timeline/facts.test.ts +++ b/packages/session-ui/src/timeline/facts.test.ts @@ -1,7 +1,7 @@ import type { JsonValue } from "@opencode/client/promise" import { describe, expect, test } from "bun:test" import { storyTool } from "../storybook/current-session-scenarios" -import { factsOf, sameFileFact, summarize, type FileFact } from "./facts" +import { factsOf, placeFactOf, sameFileFact, summarize, type FileFact } from "./facts" import { categoryOf } from "./place" describe("timeline facts", () => { @@ -113,4 +113,18 @@ describe("timeline facts", () => { expect(sameFileFact(before!, after!)).toBe(true) expect(sameFileFact(before!, scriptFiles("completed", { files: liveFiles })[0]!)).toBe(false) }) + + test("a script's changes show and count only with full_codemode, and a direct edit's always do", () => { + const script = storyTool("s1", "execute", "completed", { code: "…" }, { metadata: { files: liveFiles } }) + const edit = storyTool("e1", "edit", "completed", { path: "/repo/b.ts" }) + const kinds = (facts: ReturnType) => facts.map((fact) => fact.kind) + + expect(kinds(factsOf([script, edit], true))).toEqual(["call", "file", "call", "file"]) + expect(summarize(factsOf([script, edit], true)).files).toEqual(["/repo/a.ts", "/repo/b.ts"]) + expect(placeFactOf(script, script.id, true).changes).toBe(1) + + expect(kinds(factsOf([script, edit], false))).toEqual(["call", "call", "file"]) + expect(summarize(factsOf([script, edit], false)).files).toEqual(["/repo/b.ts"]) + expect(placeFactOf(script, script.id, false).changes).toBe(0) + }) }) diff --git a/packages/session-ui/src/timeline/facts.ts b/packages/session-ui/src/timeline/facts.ts index 670ee405b3f..98cae78bbbf 100644 --- a/packages/session-ui/src/timeline/facts.ts +++ b/packages/session-ui/src/timeline/facts.ts @@ -120,13 +120,14 @@ const modes = new Map( /** * The facts in a list of parts, in order. Not cached: stores update a part in place as it streams, so its identity - * says nothing about whether its facts changed. Callers read it inside a memo. + * says nothing about whether its facts changed. Callers read it inside a memo. Without `scriptDiffs` (the server's + * `full_codemode` flag off), a script's changes are not facts: they neither show nor count. */ -export function factsOf(parts: readonly FactPart[]): Fact[] { - return parts.flatMap(partFacts) +export function factsOf(parts: readonly FactPart[], scriptDiffs = true): Fact[] { + return parts.flatMap((part) => partFacts(part, scriptDiffs)) } -function partFacts(part: FactPart): Fact[] { +function partFacts(part: FactPart, scriptDiffs: boolean): Fact[] { const id = part.messageID ? `${part.messageID}:${part.id ?? ""}` : (part.id ?? "") if (part.type === "text") return [{ kind: "text", id }] @@ -155,7 +156,7 @@ function partFacts(part: FactPart): Fact[] { }, ] - return toolFacts(part, id) + return toolFacts(part, id, scriptDiffs) } const decodeFile = Schema.decodeUnknownOption( @@ -190,12 +191,15 @@ function reads(tool: Tool): Reads { } } -/** What placing a call reads of it. Reads input and metadata only where they can move the call or open it. */ -export function placeFactOf(tool: Tool, id = tool.id): PlaceFact { - return placeFact(tool, id, reads(tool)) +/** + * What placing a call reads of it. Reads input and metadata only where they can move the call or open it. Without + * `scriptDiffs`, a script places no changes. + */ +export function placeFactOf(tool: Tool, id = tool.id, scriptDiffs = true): PlaceFact { + return placeFact(tool, id, reads(tool), scriptDiffs) } -function placeFact(tool: Tool, id: string, read: Reads): PlaceFact { +function placeFact(tool: Tool, id: string, read: Reads, scriptDiffs = true): PlaceFact { const name = toolName(tool.name) const state = tool.state const stopped = toolStopped(tool) @@ -216,7 +220,7 @@ function placeFact(tool: Tool, id: string, read: Reads): PlaceFact { !readImagePath(read.input()) && !currentToolHasLoadedFiles(tool), background: name === "subagent" || (name === "shell" && read.input().background === true), - changes: name === "execute" ? scriptChanges(tool, read).length : 0, + changes: name === "execute" && scriptDiffs ? scriptChanges(tool, read).length : 0, } } @@ -253,9 +257,9 @@ export function launchOf(tool: Tool) { return placeFact(tool, tool.id, read).background ? launch(tool, toolName(tool.name), read) : undefined } -function toolFacts(tool: Tool, id: string): Fact[] { +function toolFacts(tool: Tool, id: string, scriptDiffs: boolean): Fact[] { const read = reads(tool) - const fact = placeFact(tool, id, read) + const fact = placeFact(tool, id, read, scriptDiffs) const raw = read.input().path const path = Predicate.isString(raw) && raw ? raw : undefined const metadata = read.metadata() @@ -276,6 +280,8 @@ function toolFacts(tool: Tool, id: string): Fact[] { if (Predicate.isNumber(metadata.matches)) call.matches = metadata.matches + if (fact.name === "execute" && !scriptDiffs) return [call] + if (fact.name === "execute") return [ call, @@ -478,6 +484,11 @@ export function sameFileFact(previous: FileFact, next: FileFact) { const scriptFilePart = /^(.*?):file:(\d+):/ +/** Whether a part id names a change a script made, which draws as part of the script's block. */ +export function isScriptFilePartID(partID: string) { + return scriptFilePart.test(partID) +} + /** The change a script made that a part id names, read from that one entry of the script's part in the message. */ export function scriptFileFact(content: readonly Content[], messageID: string, partID: string) { const match = scriptFilePart.exec(partID) diff --git a/packages/session-ui/src/timeline/projection.ts b/packages/session-ui/src/timeline/projection.ts index 9a5cbfd9c52..c5d9327a3f0 100644 --- a/packages/session-ui/src/timeline/projection.ts +++ b/packages/session-ui/src/timeline/projection.ts @@ -158,6 +158,8 @@ export function createReactiveTimelineProjection(input: { queuedCompactionIDs?: Accessor /** Summarize each finished turn's changed files after it. */ turnDiffs?: Accessor + /** The server's `full_codemode` flag: without it, a script's changes neither show nor count. */ + scriptDiffs?: Accessor }) { const sessionMessageByID = createMemo( () => new Map(input.sessionMessages().map((message) => [message.id, message] as const)), @@ -184,7 +186,7 @@ export function createReactiveTimelineProjection(input: { ) const textVisible = createMemo(() => new Map>(textParts())) - const factOf = placeFacts(input.sessionMessages) + const factOf = placeFacts(input.sessionMessages, input.scriptDiffs) const projection = createMemo(() => Timeline.constructSessionMessageRows( @@ -1219,28 +1221,32 @@ function messageParts( * Reads what placing each call needs through a signal per call. Streamed input and progress reports change a call many * times a second without moving it, and a signal notifies the rows only when what they read of it changes. */ -export function placeFacts(messages: Accessor): PlaceFactOf { +export function placeFacts( + messages: Accessor, + /** The server's `full_codemode` flag: without it, a script places no changes. */ + scriptDiffs: Accessor = () => true, +): PlaceFactOf { const parts = mapArray( messageParts(messages, (message) => message.type === "assistant" ? message.content.filter((content): content is Tool => content.type === "tool") : [], ), (tool) => { const [fact, setFact] = createSignal( - untrack(() => placeFactOf(tool)), + untrack(() => placeFactOf(tool, tool.id, scriptDiffs())), { equals: samePlaceFact }, ) - createComputed(() => setFact(placeFactOf(tool))) + createComputed(() => setFact(placeFactOf(tool, tool.id, scriptDiffs()))) // The signal only says when the fact changes, one computation after the write that changed it, so the value // comes from the part itself. - return [tool, () => (fact(), untrack(() => placeFactOf(tool)))] as const + return [tool, () => (fact(), untrack(() => placeFactOf(tool, tool.id, scriptDiffs())))] as const }, ) const byTool = createMemo(() => new Map>(parts())) - return (tool) => byTool().get(tool)?.() ?? placeFactOf(tool) + return (tool) => byTool().get(tool)?.() ?? placeFactOf(tool, tool.id, scriptDiffs()) } const placeFactKeys = [ diff --git a/packages/session-ui/src/timeline/script-output.test.ts b/packages/session-ui/src/timeline/script-output.test.ts new file mode 100644 index 00000000000..a7c6feb8d57 --- /dev/null +++ b/packages/session-ui/src/timeline/script-output.test.ts @@ -0,0 +1,57 @@ +import { describe, expect, test } from "bun:test" +import type { SessionMessageInfo } from "@opencode/client/promise" +import { storyTool } from "../storybook/current-session-scenarios" +import { scriptOutputLayout } from "./script-output" +import { TimelineRow } from "./timeline-row" + +const messages = new Map([ + [ + "msg_a", + { + id: "msg_a", + type: "assistant", + agent: "build", + model: { id: "model", providerID: "provider" }, + time: { created: 1 }, + content: [storyTool("script", "execute", "completed", { code: "…" }, { output: "ok" })], + }, + ], +]) + +// The script's row, then its changes drawn as cards in the row after it, as Detailed places them. +const rows = [ + new TimelineRow.AssistantPart({ + userMessageID: "msg_u", + group: { key: "part:msg_a:script", type: "part", ref: { messageID: "msg_a", partID: "script" } }, + previousAssistantPart: false, + }), + new TimelineRow.AssistantPart({ + userMessageID: "msg_u", + group: { + key: "part:msg_a:script:file:0:a.ts", + type: "file", + refs: [ + { messageID: "msg_a", partID: "script:file:0:a.ts" }, + { messageID: "msg_a", partID: "script:file:1:b.ts" }, + ], + }, + previousAssistantPart: true, + spacing: "tool", + }), +] + +describe("scriptOutputLayout", () => { + test("moves a script's Output after its last change in the flat layout", () => { + const layout = scriptOutputLayout(rows, messages, true) + + expect([...layout.afterChanges]).toEqual(["script"]) + expect([...layout.outputAfter.keys()]).toEqual(["msg_a:script:file:1:b.ts"]) + }) + + test("moves nothing without the flat layout", () => { + const layout = scriptOutputLayout(rows, messages, false) + + expect(layout.afterChanges.size).toBe(0) + expect(layout.outputAfter.size).toBe(0) + }) +}) diff --git a/packages/session-ui/src/timeline/script-output.ts b/packages/session-ui/src/timeline/script-output.ts new file mode 100644 index 00000000000..81678b56e18 --- /dev/null +++ b/packages/session-ui/src/timeline/script-output.ts @@ -0,0 +1,78 @@ +import type { SessionMessageAssistant, SessionMessageInfo } from "@opencode/client/promise" +import { Predicate } from "effect" +import { TimelineRow } from "./timeline-row" + +type Tool = Extract + +/** + * Where each script's Output row goes. A script whose changes are drawn right after it, as the next items of its group or + * as the row after its own, reads steps, then changes, then Output: its Output row follows its last change. Anywhere + * else, as when its changes are hidden or grouped apart from it, its Output row stays under its steps. + */ +export type ScriptOutputLayout = { + /** Scripts, by part id, whose Output row follows their changes. */ + afterChanges: ReadonlySet + /** The script whose Output row follows a change, by the change's fact id (`messageID:partID`). */ + outputAfter: ReadonlyMap +} + +export function scriptOutputLayout( + rows: readonly TimelineRow.TimelineRow[], + messageByID: ReadonlyMap, + /** The flat execute layout (`full_codemode`); without it every Output row stays under its steps. */ + flat: boolean, +): ScriptOutputLayout { + const afterChanges = new Set() + const outputAfter = new Map() + + if (!flat) return { afterChanges, outputAfter } + + const script = (messageID: string, partID: string) => { + const message = messageByID.get(messageID) + + const part = + message?.type === "assistant" + ? message.content.find((item) => item.type === "tool" && item.id === partID) + : undefined + + return part?.type === "tool" && part.name === "execute" ? part : undefined + } + + // The changes of the script at refs[from - 1] that come next, in order. + const changesOf = (refs: readonly { messageID: string; partID: string }[], from: number, scriptID: string) => { + const end = refs.findIndex((ref, index) => index >= from && !ref.partID.startsWith(`${scriptID}:file:`)) + + return refs.slice(from, end < 0 ? refs.length : end) + } + + const place = (tool: Tool, changes: readonly { messageID: string; partID: string }[]) => { + const last = changes.at(-1) + + if (!last) return + afterChanges.add(tool.id) + outputAfter.set(`${last.messageID}:${last.partID}`, tool) + } + + rows.forEach((row, index) => { + if (!Predicate.isTagged(row, "AssistantPart")) return + const refs = row.group.type === "part" ? [row.group.ref] : row.group.refs + + refs.forEach((ref, at) => { + const tool = script(ref.messageID, ref.partID) + + if (!tool) return + + // Its changes follow it in the same group. + if (at < refs.length - 1) return place(tool, changesOf(refs, at + 1, tool.id)) + const next = rows[index + 1] + + // Or they are the row after its own, drawn as cards. + if (!next || !Predicate.isTagged(next, "AssistantPart") || !TimelineRow.scriptChanges(next)) return + const nextRefs = next.group.type === "part" ? [next.group.ref] : next.group.refs + + place(tool, changesOf(nextRefs, 0, tool.id)) + }) + }) + + return { afterChanges, outputAfter } +} diff --git a/packages/session-ui/src/timeline/session-timeline-row.tsx b/packages/session-ui/src/timeline/session-timeline-row.tsx index ad13abacfc3..bca2453035a 100644 --- a/packages/session-ui/src/timeline/session-timeline-row.tsx +++ b/packages/session-ui/src/timeline/session-timeline-row.tsx @@ -50,15 +50,18 @@ import { fileRuns, runDisclosureKey, ScriptChanges, + ScriptOutputProvider, taskAgentName, ToolRegistry, type ContextGroupPart, + type ScriptOutputPlacement, } from "../tools/tool-renderer" import { GenericTool } from "../components/basic-tool" import { SessionRetry } from "../components/session-retry" import { SessionError } from "../components/session-error" import type { TimelineDetail } from "./detail" import { scriptFileFact, type FileFact } from "./facts" +import { scriptOutputLayout } from "./script-output" import { diffOpens, placeContent } from "./place" import { userMessageRuns, userRunSpring } from "./user-runs" import { attached } from "../components/message-file" @@ -806,8 +809,14 @@ export function createSessionTimelineRowRenderer(input: { classList={{ "min-w-0 w-full max-w-full": true, "md:max-w-session md:mx-auto": input.centered?.(), - "pt-2": Predicate.isTagged(props.row, "AssistantPart") && props.row.spacing === "tool", - "pt-4": Predicate.isTagged(props.row, "AssistantPart") && props.row.spacing === "content", + // Blocks stand a step further apart than a script stands from its own changes. + "pt-2": + Predicate.isTagged(props.row, "AssistantPart") && + props.row.spacing === "tool" && + TimelineRow.scriptChanges(props.row), + "pt-4": + Predicate.isTagged(props.row, "AssistantPart") && + (props.row.spacing === "content" || (props.row.spacing === "tool" && !TimelineRow.scriptChanges(props.row))), "pt-6": Predicate.isTagged(props.row, "Error"), }} > @@ -1548,11 +1557,23 @@ export function createSessionTimelineRowRenderer(input: { ) } + // Where each script's Output row goes, from the rows: after its changes when they are drawn right after it. + const scriptOutput = createMemo(() => + scriptOutputLayout(input.projection.rows(), input.projection.messageByID(), data.flag("full_codemode")), + ) + + const scriptPlacement: ScriptOutputPlacement = { + afterChanges: (partID) => scriptOutput().afterChanges.has(partID), + outputAfter: (fileID) => scriptOutput().outputAfter.get(fileID), + } + function Row(props: { row: Accessor; onSizeChange?: () => void }) { return ( - - {(_key) => render(props.row, props.onSizeChange)} - + + + {(_key) => render(props.row, props.onSizeChange)} + + ) } diff --git a/packages/session-ui/src/timeline/session-timeline.tsx b/packages/session-ui/src/timeline/session-timeline.tsx index 10a7faae08f..9ff8064bfc5 100644 --- a/packages/session-ui/src/timeline/session-timeline.tsx +++ b/packages/session-ui/src/timeline/session-timeline.tsx @@ -2,6 +2,7 @@ import { For, createMemo } from "solid-js" import { createStore } from "solid-js/store" import type { SessionDocument } from "../document" import type { SessionUserActions } from "../actions" +import { useData } from "../context" import type { TimelineDetail } from "./detail" import { createReactiveTimelineProjection, TimelineRow, type ReasoningMode } from "./projection" import { createSessionTimelineRowRenderer, type SessionUserPresentation } from "./session-timeline-row" @@ -22,6 +23,8 @@ export type SessionTimelineProps = { } export function SessionTimeline(props: SessionTimelineProps) { + const data = useData() + const projection = createReactiveTimelineProjection({ sessionMessages: () => props.document.messages, status: () => props.document.status, @@ -30,6 +33,7 @@ export function SessionTimeline(props: SessionTimelineProps) { editToolDefaultOpen: () => props.editToolDefaultOpen ?? false, timelineDetail: props.timelineDetail && (() => props.timelineDetail!), turnDiffs: () => props.turnDiffs ?? false, + scriptDiffs: () => data.flag("full_codemode"), }) const [toolOpen, setToolOpen] = createStore>({}) diff --git a/packages/session-ui/src/timeline/timeline-row.ts b/packages/session-ui/src/timeline/timeline-row.ts index fb524245bf6..99944253785 100644 --- a/packages/session-ui/src/timeline/timeline-row.ts +++ b/packages/session-ui/src/timeline/timeline-row.ts @@ -1,4 +1,5 @@ import { Data, Match, Predicate } from "effect" +import { isScriptFilePartID } from "./facts" export type PartRef = { messageID: string @@ -186,6 +187,14 @@ export namespace TimelineRow { Activity: () => (other: TimelineRow) => Predicate.isTagged(other, "Activity"), }) + /** A row of the changes a script made, which belongs to the script's block above it. */ + export function scriptChanges(row: TimelineRow) { + if (!Predicate.isTagged(row, "AssistantPart")) return false + const refs = row.group.type === "part" ? [row.group.ref] : row.group.refs + + return refs.length > 0 && refs.every((ref) => isScriptFilePartID(ref.partID)) + } + export function equals(a: TimelineRow, b: TimelineRow) { return a === b || (a.userMessageID === b.userMessageID && sameFields(a)(b)) } diff --git a/packages/session-ui/src/tools/tool-renderer.tsx b/packages/session-ui/src/tools/tool-renderer.tsx index 6c1e8c1995d..25a2e535871 100644 --- a/packages/session-ui/src/tools/tool-renderer.tsx +++ b/packages/session-ui/src/tools/tool-renderer.tsx @@ -7,6 +7,7 @@ import { createEffect, createMemo, createSignal, + createContext, createUniqueId, For, Match, @@ -17,6 +18,7 @@ import { Index, on, untrack, + useContext, type JSX, } from "solid-js" import { createStore } from "solid-js/store" @@ -613,7 +615,14 @@ export function CurrentContextToolGroup(props: { } > - {(part) =>
{part.render()}
} + {(part) => ( +
+ {part.render()} +
+ )} } > @@ -1042,6 +1051,31 @@ export function CurrentFileToolGroup(props: { ) } +/** + * Where a script's Output row goes, from the timeline's rows (`scriptOutputLayout`): after its last change when its + * changes are drawn right after it, else under its steps. + */ +export type ScriptOutputPlacement = { + afterChanges: (partID: string) => boolean + outputAfter: (fileID: string) => SessionMessageAssistantTool | undefined +} + +const ScriptOutputContext = createContext({ + afterChanges: () => false, + outputAfter: () => undefined, +}) + +export const ScriptOutputProvider = ScriptOutputContext.Provider + +// What a script returned, shown as its Output row. A failure shows on its failing row instead. +function scriptOutputText(status: string | undefined, output: string | undefined, metadata: ToolProps["metadata"]) { + if (status === "error" || metadata.error === true) return "" + + return stripAnsi(output ?? "") + .replace(/\r\n?/g, "\n") + .trim() +} + /** A file group holding a script's changes: each run in order, direct calls drawn as their own group. */ export function FileChangeRuns(props: { runs: readonly FileRun[] @@ -1109,6 +1143,16 @@ export function ScriptChanges(props: { onSizeChange?: () => void }) { const i18n = useI18n() + const placement = useContext(ScriptOutputContext) + + // The Output row of a script whose last change this is, when its changes are drawn right after it. + const outputAfter = (file: FileFact) => { + const script = placement.outputAfter(file.id) + + return script + ? scriptOutputText(script.state.status, currentToolOutput(script), currentToolMetadata(script)) + : undefined + } // One wrapper, as a direct patch's files share one, so the turn's gap falls around the list and not between changes. return ( @@ -1203,6 +1247,13 @@ export function ScriptChanges(props: { ) }} + + {(value) => ( +
+ +
+ )} +
) } @@ -1266,6 +1317,8 @@ function currentContextToolTrigger(tool: SessionMessageAssistantTool, i18n: Retu // SAFETY: tool input and metadata are open per-tool records. GenericTool shows arbitrary input keys, and // renderers decode the fields they read with `toolInput` and `toolMetadata`. export interface ToolProps { + /** The call's part id, where the timeline passes it. */ + id?: string // oxlint-disable-next-line anti-slop/no-unsafe-dictionary-type -- see SAFETY above input: Record error?: string @@ -2049,10 +2102,13 @@ ToolRegistry.register({ name: "execute", render(props) { const i18n = useI18n() + const data = useData() const dialog = useDialog() const pending = () => props.status === "streaming" || props.status === "running" const count = createMemo(() => executeToolCallCount(props.metadata)) const subtitle = createMemo(() => executeToolSubtitle(props.metadata)) + // `full_codemode` draws the flat layout: a static title over steps that always show, Output after its changes. + const flat = () => data.flag("full_codemode") const code = createMemo(() => (toolInput(props.input).code ?? "").trimEnd()) // A runtime failure shows its output on the failing row; a successful script shows its result below the calls. @@ -2064,13 +2120,10 @@ ToolRegistry.register({ return text.replace(/^Error:\s*/, "").trim() || fallback }) - const output = createMemo(() => - error() - ? "" - : stripAnsi(props.output ?? "") - .replace(/\r\n?/g, "\n") - .trim(), - ) + const output = createMemo(() => scriptOutputText(props.status, props.output, props.metadata)) + // When its changes are drawn right after it, its Output row follows them: steps, changes, then Output. + const placement = useContext(ScriptOutputContext) + const outputHere = () => !!output() && !(flat() && props.id && placement.afterChanges(props.id)) // A runtime failure belongs to the call that raised it; scripts can also fail outside any call. const owner = createMemo(() => executeToolErrorIndex(props.metadata)) @@ -2099,23 +2152,28 @@ ToolRegistry.register({ const openDetails = () => dialog.show(() => ) + // Flat, the title is static and the calls always show under it: the block never collapses, whatever the timeline asks. return ( 0 || !!error() || !!output()} + hasContent={count() > 0 || !!error() || outputHere()} compact allowOpenWhilePending + locked={flat() || props.locked} + open={flat() ? true : props.open} + forceOpen={flat() || props.forceOpen} + onOpenChange={flat() ? undefined : props.onOpenChange} trigger={(open) => (
- + - + {(text) => }
@@ -2136,7 +2194,7 @@ ToolRegistry.register({ ) : undefined } > -
+
{(count) => (
) @@ -2298,7 +2358,7 @@ function selectsRowText(row: HTMLElement) { return row.contains(selection.anchorNode) || row.contains(selection.focusNode) } -function ExecuteOutputRow(props: { output: string }) { +function ExecuteOutputRow(props: { output: string; flat?: boolean }) { const i18n = useI18n() const [open, setOpen] = createSignal(false) const text = createMemo(() => formatExecuteOutput(props.output).text) @@ -2323,9 +2383,11 @@ function ExecuteOutputRow(props: { output: string }) { toggle(event) }} > - - › - + + + › + + {i18n.t("ui.tool.execute.output")} {i18n.plural("ui.tool.execute.lines", text().split("\n").length)} @@ -2340,7 +2402,7 @@ function ExecuteOutputRow(props: { output: string }) { ) } -function ExecuteCallRow(props: { call?: ExecuteToolCall; error?: string }) { +function ExecuteCallRow(props: { call?: ExecuteToolCall; error?: string; flat?: boolean }) { const [open, setOpen] = createSignal(false) const args = createMemo(() => (props.call ? executeToolCallArgs(props.call) : [])) const input = createMemo(() => Object.entries(props.call?.input ?? {})) @@ -2372,10 +2434,12 @@ function ExecuteCallRow(props: { call?: ExecuteToolCall; error?: string }) { toggle(event) }} > - ›}> - - - + + ›}> + + + + {(call) => ( @@ -2386,6 +2450,12 @@ function ExecuteCallRow(props: { call?: ExecuteToolCall; error?: string }) { )} + {/* Flat, after the name, so every call's name lines up with the title; a failure without a call leads with it. */} + + + + + {(text) => (