fix(opencode): omit unsafe delete diffs
Draft
TR
1mo ago+119+119+012345678901234567890123456789-61-61-01234567890123456789
Issue for this PR
Closes #41733
Type of change
- Bug fix
- New feature
- Refactor / code improvement
- Documentation
What does this PR do?
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 typecheckfrompackages/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.
Screenshots / recordings
Not applicable; this is a core tool metadata fix.
Checklist
- I have tested my changes locally
- I have not included unrelated changes in this PR