Skip to content

fix(core): Mime.detect has no ftyp brand dispatch — HEIC/HEIF/M4A attachments sniff as application/octet-stream, and detected AVIF cannot be ingested by the read tool #2150

Closed

Description

@dezren39

Summary

Core Mime.detect (packages/core/src/mime.ts) has no ISO-BMFF brand dispatch: its only ftyp handling (lines 12–15) recognizes the avif/avis major brands, and every other ftyp container falls through to the text/binary fallback. The AI package's sniffer got exactly this fix in #2127 (PR #2144, merged today: brand table FTYP_BRANDS in packages/ai/src/utils/media-type.ts); the core detector — the one prompt attachments and the read tool actually use — still has the pre-fix shape.

Evidence

Probe probe-core.test.ts (laptop worktree probe-2026-11-08-creator-1235 @ main 391e43eb36, packages/core/, against the real module), each input a 16-byte ftyp box (size + ftyp + major brand):

  • brand heic → application/octet-stream (a HEIC photo is not recognized as an image at all)
  • brand M4A → application/octet-stream (an M4A audio file is not recognized as audio)
  • brand avif → image/avif (the one brand family that is recognized)

Consumers and consequences:

  • packages/core/src/session/prompt.ts:116 — a HEIC photo attached to a prompt is published with mime application/octet-stream, so the provider receives an opaque binary file instead of an image (or rejects it), with no error pointing at the real cause.
  • packages/core/src/tool/read-filesystem.ts:21 — MEDIA_MIMES is {image/png, image/jpeg, image/gif, image/webp, application/pdf}: even the formats core detect does recognize beyond that set (image/avif, image/bmp) are not ingestible as media by the read tool, so an AVIF file is handled as a binary/text read instead. Detector and ingest set disagree.

Why it matters

HEIC is the default photo format on iPhones; M4A is a common voice-memo format. A user attaching either to a session in the core app gets a silently useless attachment. The fork already paid for this exact design once today — the AI sniffer's brand table (#2127 / PR #2144) is the model — the core detector just never received the same treatment, and its read-tool ingest set was never reconciled with what it can detect.

Acceptance criteria

  • Mime.detect dispatches on the ftyp major brand at least for the image/audio brands the AI sniffer now claims (heic/heix → image/heic, mif1/msf1 → image/heif, avif/avis → image/avif, M4A /M4B → audio/mp4), with tests pinning each brand and an unknown-brand control falling through to the existing fallback.
  • The read tool's MEDIA_MIMES and the prompt path's handling are reconciled with the enlarged detection set in the same change (every newly detected media type is either ingestible or the gap is explicitly dispositioned on the issue).
  • Unknown/other ftyp brands keep today's behavior unless triage dispositions them.
  • Existing core suites that touch attachments stay green.

Notes

Activity

  1. added
    kind/bugSomething isn't working (prefixed form of the classic bug label)
    task/triageQueue packet kind: verify, reproduce, and route this item
    source/creatorFiled by the new-issue-creator job
    priority/normalOrdinary priority (the default)
    queue/queuedHas a queued task in the Supabase agent queue
    app/corePackage: core (pkgs/ or apps/ in this repo)
    on Nov 8, 2026
  2. dezren39 commented on Nov 8, 2026

    @dezren39
    Author

    🤖 Agent note · filed

  3. developing-today commented on Nov 8, 2026

    @developing-today

    Triage verdict (task 13910, lane opencode-a): CONFIRMED REAL on fresh origin/main e61c8e6. packages/core/src/mime.ts detect() ftyp check recognizes only avif/avis; heic/heix/mif1/msf1/M4A/M4B fall through to application/octet-stream. read-filesystem.ts MEDIA_MIMES omits image/avif and image/bmp, both already detectable. The ai FTYP_BRANDS table (media-type.ts) is the mirror source. No hard-stop labels. Routed to a follow-on small_fix task: brand dispatch in core detect + MEDIA_MIMES reconciliation, tests per brand plus unknown-brand control; video/mp4 brands dispositioned out of core scope. agent-note:v1 repo-queue-worker-shift-opencode lane-a task 13910

  4. added
    work/assignedAn agent holds this item via the queue (claimed task)
    queue/claimedA queue worker has claimed the task for this item
    and removed
    queue/queuedHas a queued task in the Supabase agent queue
    on Nov 8, 2026
  5. dezren39 commented on Nov 8, 2026

    @dezren39
    Author

    🤖 Agent note · picked up — queue task 13976

  6. added
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    status/parkedDeliberately paused with a recorded resume condition
    and removed
    queue/claimedA queue worker has claimed the task for this item
    on Nov 8, 2026
  7. dezren39 commented on Nov 8, 2026

    @dezren39
    Author

    🤖 Agent note · PR opened — #2174

    • Agent: repo-worker-opencode (lane 3fe37e8a-c61b-419c-9e97-769ecd264d5d)
    • Task: Queue task 13976; implementation is in PR fix(core): dispatch ftyp media brands #2174 targeting main.
    • Verification: 106 targeted core tests pass; bun typecheck and root bun run check pass.
    • Next: Check CI/review; current PR state is OPEN and CLEAN.
  8. dezren39 commented on Nov 8, 2026

    @dezren39
    Author

    🤖 Agent note · parked — waiting for CI on PR #2174

    • Agent: repo-worker-opencode (lane 3fe37e8a-c61b-419c-9e97-769ecd264d5d)
    • Task: Queue task 13976 parked for 20 minutes (ready at 2026-11-08T22:41:25Z).
    • Evidence: PR fix(core): dispatch ftyp media brands #2174 is OPEN and CLEAN; gh pr checks reports no checks yet. No merge or review decision was reported.
    • Resume: Revalidate issue and PR state, then proceed only after checks are reported; do not hold a claim while CI is pending.
  9. removed
    status/parkedDeliberately paused with a recorded resume condition
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    work/assignedAn agent holds this item via the queue (claimed task)
    on Nov 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    app/corePackage: core (pkgs/ or apps/ in this repo)kind/bugSomething isn't working (prefixed form of the classic bug label)priority/normalOrdinary priority (the default)source/creatorFiled by the new-issue-creator jobtask/triageQueue packet kind: verify, reproduce, and route this item

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions