Repository navigation
fix(core): preserve derived MIME in attachment materialization fallbacks - #807
Merged
Merged
Conversation
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
agenteinstinct1-max
marked this pull request as ready for review
November 2, 2026 11:42
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Files Reviewed (2 files)
Reviewed by free · Input: 26.1K · Output: 1K · Cached: 99.4K |
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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 #806
Type of change
What does this PR do?
PromptInput.FileAttachmentaccepts attachments withoutmime, while durablePrompt.FileAttachmentrequiresmime: string. Inpackages/core/src/attachment-store.ts,AttachmentStore.materializealready derivedmimewithfinalMime(attachment.uri, undefined, attachment.name)on the happy path, but three non-persisting branches (Effect.catcherror fallback, unsupported-URI scheme, and post-readbytes.length > MAX_BYTES) spread the MIME-less input intoFileAttachment.create({ ...attachment, ... } as FileAttachment)and rejected withExpected string, got undefined at ["mime"].This change computes
idandmimevia the existingfinalMimehelper and builds the unmaterializedFileAttachmentexplicitly (removing allas FileAttachmentcasts) across the error fallback, unsupported-URI, and oversize branches:finalMime(text/plain,image/png,application/pdf,image/svg+xml,application/zip,video/mp4,application/json, orapplication/octet-streamwhen unknown) rather than guessingtext/plain.id(or assigns one ascendingid),uri,name,description, andsourcewhile leavingpathandsizeunset soAttachmentStore.inventoryflags unmaterialized entriesunavailable: trueandcopyTofails on its typedErrorchannel.external_directory,read, andwebpermission checks,PermissionV2.BlockedErrorgraceful degradation,PermissionV2.DeclinedErrordefect propagation,MAX_BYTESbudgets, and fiber interruption/resource cleanup.Scope and separation:
0143c2697c015a8cd954104764e012321c404fc2:packages/core/src/attachment-store.tsandpackages/core/test/attachment-materialize-fallback.test.tsonly (incoming#804harness files from0143c269retained unchanged via normal merge).#806separate from#790: the tests exercise the realAttachmentStoreservice (AttachmentStore.node) with injected dependencies rather than the full production dependency graph, and do not identify#790's historical focused-run trigger (which remains unknown).How did you verify your code works?
Linux x64, Bun
1.3.14(npm_config_nodedir=/usr/local bun install --frozen-lockfile).Baseline counterfactual against unmodified
packages/core/src/attachment-store.tsat20492cd738dca7592b1cbdc9a7aa31cc4f46eb13:cd packages/core && bun test test/attachment-materialize-fallback.test.ts --timeout 15000: 2 pass, 6 fail, 19 expect() calls across 1 file (723ms) — success and fiber-cancellation controls passed; filesystem read failure, managed write / HTTP fetch failure, blocked permission fallback, unsupported-URI (:234), post-read oversize bytes (:236), andstat/Content-Lengthoversize budget cases each failed withExpected string, got undefined at ["mime"].Exact merged head
dbd9a299adcb16543efba08e6ffe992f99738bc0(parents903ffe2and accepteddev-vibecodedtip0143c2697c015a8cd954104764e012321c404fc2):cd packages/core && bun test test/attachment-materialize-fallback.test.ts --timeout 15000: 8 pass, 0 fail, 64 expect() calls across 1 file (808ms).cd packages/core && bun test test/attachment-materialize-fallback.test.ts test/session-runner-attachment.test.ts --timeout 15000: 11 pass, 0 fail, 71 expect() calls across 2 files (736ms).cd packages/opencode && bun test test/tool/attachment-readiness.test.ts --timeout 30000: 1 pass, 0 fail, 3 expect() calls across 1 file (3.54s).cd packages/core && bun test --timeout 15000 --only-failures: 1524 pass, 3 skip, 0 fail, 4257 expect() calls across 168 files (54.39s).cd packages/opencode && bun test --timeout 30000 --only-failures: 4934 pass, 25 skip, 1 todo, 0 fail, 50 snapshots, 21345 expect() calls across 343 files (1290.30s).NODE_OPTIONS=--max-old-space-size=3072 bun turbo typecheck --concurrency=1: 17/17 tasks successful (1m17.821s) (plus earlier uncached 17/17 run in 2m11.458s)../node_modules/.bin/prettier --check,./node_modules/.bin/oxlint(0 warnings, 0 errors), andgit diff --checkon the two changed files: exit 0..husky/pre-pushhook duringgit push -u origin arena/061af746-silvercode: 17/17 tasks successful, exit 0.Screenshots / recordings
N/A (no UI changes).
Checklist