Repository navigation
Carry a file edit's old and new text to the Diff pane - #450
Merged
abhishekgahlot2 merged 1 commit intoNov 14, 2026
Merged
Conversation
Part of useagenthq#448. The pinned runtime does not send the text yet, so nothing changes for users until it does. Diff pane in the local app, with step rows built by the backend's own functions: before https://github.com/coolestnick/useagent/blob/pr-448-screenshots/before-pane.png?raw=true after https://github.com/coolestnick/useagent/blob/pr-448-screenshots/after-pane.png?raw=true
Contributor
|
Merged, thanks @coolestnick. Mapping the runtime's strings onto the keys the Diff pane already reads, capping them at 16 KiB, storing them once and running them through the same redaction as other tool input is careful groundwork. A small marker when an edit is over the cap would let the pane say why later. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #448
On a thread that ran on the native runtime, the Diff pane shows "Patch content not recorded" for every file the agent edited, because the runtime strips an edit's text before the backend sees it. This is the backend half of the fix: when a runtime sends the string an edit replaced and the string it wrote, the backend carries them into the step the Diff pane reads.
By itself it changes nothing a user sees: the pinned runtime (
c3a1dd480534) sends neither string. The other half is a small change to the runtime fork, which I cannot release. A tested patch for it is at the end, and the "after" picture below is a real run on a runtime built with that patch.What changed
oldStr/newStrinto its step asold_string/new_string, the keys the Diff pane already reads. A change that is running, stopped or failed carries nothing, and neither does one that names several files.runtimeActivityProviderEventtakes the activity through the newledgerRuntimeActivity, which leaves it out. Redaction can lengthen text, so in the ledger it could push a payload over the 32 KiB limit that replaces a payload whole, and nothing reads it there.v2record both leave it out. A failed change keepsdiffStrinv2, as today.diffStris not carried, on purpose. The redactor reads text as it was written, and a diff puts a marker in front of every line: a removed line that starts withpmatches the-p<password>pattern and is rewritten, and a secret that spans several lines stops matching its value. The two strings are the file's own text and redact like any other tool input.turn-projector.tsis untouched, and the frontend needed no source change.Shown working
Two real OpenCode runs (OpenCode 2.2.5,
google/gemini-3.7-flashthrough the gateway) with the same prompt: writegreet.py, then edit it twice. Both ran on this branch's backend, on thelocalprovider with a runner on my machine, in a sandbox image built from the repo's recipe (deploy/local-sandbox, arm64).c3a1dd480534. The three file steps record{files, file_path}and the pane shows the note.new_string(the write) andold_string/new_string(the two edits), and the pane shows them. The step's copy of the activity and itsv2record hold no text, and none of the run's 42 ledger events does.The header's count (+12 -4 above 10 added rows) is the existing
diffStat, which counts a trailing newline as a line. Not changed here.What still shows the note, and why
diffStr), not the two strings. Carrying a diff needs a redactor that understands diff lines first, for the reason above. Separate work. Not run: my stack is set up for OpenCode only.diffStris the tool's reply), so it needs a runtime change that fills them from its edit and write input. Not run, for the same reason.Order
This can merge first: it does nothing until a runtime sends the text. In the other order, a backend without this change would keep the text, cut at the record's string limit, in the item's bounded
v2record, in the step and in the ledger.Tests
backend/src/engines/runtime-v2-view.test.ts, seven new ones: the two strings reach the step once and the ledger event equals the one a change without text gets; a whole file written carries only the new string;diffStris never carried in any of four shapes; a running, stopped, failed or several-file change carries nothing and a failed one keeps its error; the limit is whole or nothing and counts bytes; text that grows past the ledger limit when redacted cannot reach the ledger; a registered secret is redacted in the step, across lines too.backend/test/runtime-file-change-text.test.tsdrives the real turn projector against the database: the emitted step holds the strings and the stored ledger rows hold neither.frontend/components/session-ui/file-diff-view.test.tsxpins the step shape the pane reads. It passes on main too, since the frontend did not need to change.Checks
bun run typecheckat the root -> okcd backend && bun run teston my own database -> 3645 pass, 3 skip, 0 fail, then the Slack suite 119 pass, 0 failcd frontend && bun run test-> 2013 pass, 0 failcd frontend && bun run lint-> no new warningscd frontend && bun run build-> okbun test scripts/agent-docs.test.ts-> 5 passThe runtime change
Two small parts, both in the fork:
apps/server/src/orchestration-v2/WireProjection.ts): the fork's item 11 (docs/operations/t3-upstream.md), applied to a file change. A finished change carriesoldStr/newStrwhole when together they are at most 16,384 bytes, and neither when they are longer; neverdiffStr; a change in any other state carries nothing; a failed one keeps its boundeddiffStras today. The detail read returns the same.packages/provider-opencode/src/server/toolItems.ts): it calls any tool whose name containsedit,writeorpatcha file change, so an MCP tool named like one would have itscontentshown as a file's text under the tool's name. The two strings are now filled only when the input names a file, and exactly as given (a string of blank lines was dropped before, which made such an edit look like a whole file written).Patch on
c3a1dd480534, with testsChecked in a checkout of the fork source (upstream
9c161462c9plus the release patch, whose sha256 matchesthird_party/t3code-fork.lock), in a Linux arm64 container:vp test run src/orchestration-v2/WireProjection.test.ts-> 31 pass (29 before: one test replaced, three added)packages/provider-opencode: the newtoolItems.test.ts-> 4 pass, and each fails with its half of the change taken out;adapter.test.ts-> 48 passvp test runinapps/server-> 6343 pass, 14 fail, 50 skipped. The failures are in eight files (CLI theme, keybindings, the two ACP adapters, migration 026, the browser preview, the terminal manager, usage), and the same eight fail on the source without this patch.vp test runinpackages/provider-opencode-> 213 pass, 5 fail, all inOpenCodeServerLedger.test.ts, which fails the same way without this patch.vp fmt --checkandvp linton the four files -> ok, 0 warningstsc-rs --noEmitinapps/serverand inpackages/provider-opencode-> 0 errorsvp run --filter t3 buildand packaged the waydeploy/t3/package-runtime.shdoes: the same files as the release archive, with one chunk renamed, the one that holds this code.Three things the text follows that the runtime already does, for whoever takes the patch:
OrchestratorMcpService) prints a file change'snewStr. It is off in our sandboxes (T3_PROVIDER_MCP=off).outputOmittedfor a command.Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.