Conversation
Kind `video` decided from the bytes (MP4/MOV ftyp brands, WebM EBML
DocType), with an MP4/MOV's length and frame size read from its header by
seeking (moov may follow a huge mdat). A `video` route and `/download`
answer HTTP Range by hand from the already opened, checked descriptor
(206, 416, If-Range, ETag). The phone door forwards Range and If-Range and
returns the window's 206 unchanged; a relay command carries no Range and
gets the whole file (or 413), as before.
The window plays the film in a native <video>, with a rail of comment dots
that seek, a comment row (time chip, paused frame, Mark up, Comment) where
typing pauses and pins the moment, and the frame kept through the markups
route. Comments are `blockId: "video"` with `inboxVideo: { time }`; Send
lists them by time with "At 1:42 (102.4 s of 7:41)" and the frame's path,
in the window and the phone surface's export_feedback alike.
Design record: .product/approved/inbox-video (approved 2026-10-15).
# Conflicts: # AGENTS.md # adr/implementation/inbox-mobile.md # packages/server/inbox-devices.ts # tests/e2e/playwright.config.ts
…mocked - File handles: Bun 1.3.14 loses a FileHandle.close() made while a read is in flight (an aborting client's cancel arrives mid-read), and a client gone before the answer starts gets a stream Bun never reads or cancels. The stream now closes after the read in flight returns, and an idle watchdog (30 s, streamIdleMs for tests) closes any body left unpulled. The image route's stream is the same one now. Tests count open descriptors back to baseline after both kinds of disconnect (lsof / /proc/self/fd). - ETag: the current file's stat tag is strong (If-Range compares strongly); a weak If-Range never matches. - exportLocation: dropped from a client's annotation on store, and from a stored record at export, so only the computed line prints. - Panel: "Comments · By time", the moment and the frame atop each video card without the repeated quote (AnnotationPanel title / titleNote / cardParts); the tile counts "· 2 comments".
Bun 1.3.14 pulls a streamed body as fast as the file reads, whatever the client's socket takes, so a slow viewer on bytes=0- of a large film had the whole range read into memory. A 206 now carries at most 8 MiB: an open-ended or longer range is answered from its start for 8 MiB with the matching Content-Range, and the player asks again from there (RFC 9110 allows a shorter answer). Applies to /video and to Range requests on /download; a plain no-Range download is unchanged (noted in the backlog). Contract and docs say a 206 may cover less than asked. Tests: the cap table, one capped answer reads at most 8 MiB from the file, and a player reading and seeking a 30 MB film across capped answers. Also fixes the door's allowlist comment to name all three forwarded headers.
1 task
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.
Video attachments in the Inbox: the person watches a film an agent attached and comments at moments. Built as approved (design record
.product/approved/inbox-video/, approved 2026-10-15, with the owner's answers: the paused frame rides each Mac comment, the phone app plays natively, v1 plays over the Wi-Fi or the tailnet only).What changed
Kind
video, from the bytes (packages/shared/inbox/video.ts)ftypbrands (a video major or compatible brand; an image or audio major brand such asavif,heicorM4Astays out). WebM by its EBML DocTypewebm; Matroska staysfile. Image sniffing runs first, so AVIF stays an image.duration_ms,widthandheightcome from a seek-based walk of the boxes (moov/mvhd, the firstvidetrack'stkhd) through the send's own descriptor. Amoovafter a 461 MBmdatis reached in a few small reads. A file whose tracks hold no video staysfile.media_type,duration_ms,width,height. Older readers seefile.Range (
packages/server/inbox-byte-range.ts)GET /api/inbox/attachments/:id/video[?version=sent]: kindvideoonly (415 attachment_not_video), GET only, sniffedvideo/*type, inline, the image route's sandbox CSP, nosniff, CORP same-origin, cross-site refused./downloadtakes the same Range handling.Bun.file(path):206withContent-Range;200;416withbytes */size;If-Rangethat does not match:200.Content-Length. A longer answer streams and Bun sends it chunked (checked on 1.3.14: Bun dropsContent-Lengthon a stream that does not finish at once). The total is inContent-Range. This is noted in the contract.Phone door
attachments/:id/video.RangeandIf-Range(only those two) and returns the window's206,Content-Range,Accept-RangesandETagunchanged. This covers/downloadtoo.asDevice): a sealed command carries no headers in v1. It gets the whole file, or413 result_too_largepast one frame, without reading it. This is documented.Mac window (
VideoAttachmentView.tsx)<video controls preload="metadata">(#t=0.001as a poster), fit to the stage, with full screen.<video>to a canvas and kept as a JPEG through/api/inbox/markups.compareAnnotationsprop onAnnotationPanel; with it absent, the panel is unchanged.Comments and Send
blockId: "video",inboxVideo: { time }, and the frame inimages.video, and refuses anotherblockIdor a missing or negative time.At 1:42 (102.4 s of 7:41)under each heading, with the frame's path. This uses ui's new export-onlyexportLocation; nothing else's output changes. It is the same function the phone surface'sexport_feedbackcalls.Also
mp4,m4v,movandwebm(bytes re-checked at launch).inbox --helpattachment descriptions mention videos; the mod's bundled tool list was regenerated.Docs: CLAUDE.md (Attachments, Range, Phones, relay, routes table),
adr/implementation/inbox-mobile.md(allowlist rows and new section 11 from CONTRACT-ADDITIONS.md), the marketing Inbox reference, and the ui README.Tests
packages/shared/inbox/video.test.ts:packages/server/inbox-byte-range.test.ts: the Range decision table.packages/server/inbox-video.test.ts, against a real Inbox:If-Range, HEAD and other kinds refused, cross-site refused;/downloadRange;If-Rangewith matching headers;asDevicecommand getting the whole file.packages/inbox/videoAttachment.test.tsx(DOM; added to the workflow's DOM list): tile, player src, dots seek, panel pills seek, typing pauses and pins, frame upload then save, unplayable card, phone layout, feedback text.tests/e2e/inbox-video.spec.ts(compiled binary): a VP8 WebM that Playwright records in the test.wait_for_reply, with the JPEG and the PNG on disk.tests/e2e/surface.spec.ts: anexport_feedbackwith video records keeps them, by time.'video'as the "unknown kind" now use a made-up kind.Results:
bun run typecheck: clean.bun test: 8175 pass, 0 fail.inbox-video,inbox-attachments-kinds,inbox-attachment-steppingandsurfaceall pass on the compiled binary.No binary fixtures are committed: every film is built in the test.
Not in this PR
At 0:02 (2.2 s)without "of …".