Skip to content

A new file is drawn as highlighted code; the agent page reopens a session by address - #604

Merged
danbarua merged 2 commits into
mainfrom
write-file-card
Sep 30, 2026
Merged

danbarua merged 2 commits into
mainfrom
write-file-card

Conversation

@danbarua

@danbarua danbarua commented Sep 30, 2026 •

Copy link
Copy Markdown
Owner

What changes

  • A tool result that is a diff with no old text is a new file. The card draws it as the file: line numbers, syntax highlighting chosen from the file extension, and only the first five non-blank lines until "Show N more lines" is pressed. A file in a language the highlighter does not know is plain text.
  • A changed file is still drawn as a diff.
  • When a diff is drawn, the card no longer repeats the same text in the Input section, in the "Wrote N bytes" line, or under Raw output. An argument the diff does not show (anything other than the text and the path) still appears under Input.
  • The "Raw output" label is set like the "Input" and "Result" headings.
  • The gallery has a new tile, "A new file".

Reopening a session in the web app

  • /app/agent/{sessionId} loads that session from the agent. /app/agent starts a session and then takes that session's address, so reloading the page reopens it. The "agent" link in the bar is a full page load and starts a new session.
  • Checked in the browser against the fake agent: a new session moved to /app/agent/fake-1 without reconnecting, a reload redrew the same transcript, and an unknown id shows the agent's error.
  • Not checked against a real agent. The agent keeps sessions under .labkit-dev/agent-workspace of the checkout it was started from, so a session can only be reopened from that checkout.

How

  • packages/ui/code.tsx: CodeView, using lowlight (highlight.js grammars: pure JavaScript, no WASM or eval, and colours are classes in ui.css). The cut is a React style prop, as the context meter's width already is. Not run in the VS Code webview. The whole file is highlighted once and the cut is a max-height in lines, so a string or comment that crosses the cut keeps its colour.
  • packages/ui/tool.tsx: the rules are on the diff content, not on the tool's name, so any agent's new-file diff gets the same treatment.
  • Colours come from the existing theme tokens, in light and dark.

Checked

  • bun run check: all 28 passed, on both commits.
  • In the browser, light and dark: the tile opens on 9 lines (5 non-blank), "Show 9 more lines" expands to all 18, "Show less" restores it.

Not in this change

  • write_file still returns the whole written text (and, for an overwrite, the whole previous text) to the model as its tool result: packages/core-agent/host/commands/tools.ts:231 serialises the tool's entire output. The diff shown on reopening a session is rebuilt from that same output, so trimming it needs a separate place to keep what is shown.
  • A path argument written differently from the diff's path (./app.py) still shows under Input.
  • Rolling up a turn's diffs in a side pane.

🤖 Generated with Claude Code

https://claude.ai/code/session_01GVjyjkaADPAqLvtnf3xUNs

…ing lines

A diff with no old text is a new file. It is drawn as the file, numbered and
highlighted by the language its path names, showing its first five non-blank
lines with a control to show the rest. A changed file is still a diff.

The input and the raw output of a call are not drawn when a diff already shows
what they hold: the written text and the path.

The "Raw output" label is set like the "Input" and "Result" headings.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GVjyjkaADPAqLvtnf3xUNs
@github-actions github-actions Bot added area:web The web app and shared UI: app-web, ui, design, records, view-model, acp-client area:agent The agent and its hosts: core-agent, app-acp, app-vscode, acp-fake, acp-scenarios, acp-transcripts labels Sep 30, 2026
@danbarua danbarua changed the title A new file a tool wrote is drawn as highlighted code, cut to its opening lines A new file is drawn as highlighted code; the agent page reopens a session by address Sep 30, 2026
/agent/{sessionId} loads that session from the agent. /agent starts a session
and then takes that session's address, so reloading the page reopens it. The
"agent" link in the bar is a full page load and starts a new session.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GVjyjkaADPAqLvtnf3xUNs
@danbarua
danbarua marked this pull request as ready for review September 30, 2026 16:45
@danbarua
danbarua merged commit 59eed1c into main Sep 30, 2026
10 checks passed
@danbarua
danbarua deleted the write-file-card branch September 30, 2026 16:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:agent The agent and its hosts: core-agent, app-acp, app-vscode, acp-fake, acp-scenarios, acp-transcripts area:web The web app and shared UI: app-web, ui, design, records, view-model, acp-client

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant