You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
apply_patch previously read every deleted file as UTF-8 and generated a full unified diff. For binary or very large files, that could duplicate hundreds of megabytes in session metadata and crash the Desktop sidecar.
This change reuses the read tool's binary detection and omits content diffs for binary files and files larger than 1 MiB. The delete still succeeds, but metadata contains a short marker instead of the file contents.
How did you verify your code works?
bun test test/tool/apply_patch.test.ts --timeout 30000 --only-failures (29 passed)
bun test test/tool/read.test.ts --timeout 30000 --only-failures (40 passed)
bun typecheck from packages/opencode
Root bun typecheck (30 packages passed)
The new regression cases cover both binary and oversized text deletions and assert that neither result nor permission metadata embeds the contents.
This PR appears to address a similar concern about storing large patch text in session metadata. While it may focus on summary diffs rather than delete diffs specifically, it's part of the same effort to reduce metadata bloat from file operations.
However, this is likely a complementary fix rather than a duplicate, since PR #41734 specifically targets the apply_patch delete operation and binary file handling, while #40861 addresses session summary diffs more broadly.
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
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.
Issue for this PR
Closes#41733
Type of change
What does this PR do?
apply_patchpreviously read every deleted file as UTF-8 and generated a full unified diff. For binary or very large files, that could duplicate hundreds of megabytes in session metadata and crash the Desktop sidecar.This change reuses the read tool's binary detection and omits content diffs for binary files and files larger than 1 MiB. The delete still succeeds, but metadata contains a short marker instead of the file contents.
How did you verify your code works?
bun test test/tool/apply_patch.test.ts --timeout 30000 --only-failures(29 passed)bun test test/tool/read.test.ts --timeout 30000 --only-failures(40 passed)bun typecheckfrompackages/opencodebun typecheck(30 packages passed)The new regression cases cover both binary and oversized text deletions and assert that neither result nor permission metadata embeds the contents.
Screenshots / recordings
Not applicable; this is a core tool metadata fix.
Checklist