Repository navigation
Conversation
ymichael
merged commit Sep 25, 2026
180a584
into
bb/investigate-and-fix-reported-github-issue-thr_vqhcbgtd94
18 checks passed
ymichael
added a commit
that referenced
this pull request
Sep 25, 2026
## Human comments ## What was wrong Thread-storage videos could not seek reliably because the raw-file route ignored HTTP byte ranges. The initial range fix still read and transferred each whole file through the daemon, so large videos exceeded the whole-file cap. ## What changed Thread-storage responses now serve single bounded, open-ended, and suffix ranges with `206`; unsatisfiable ranges return `416`, while malformed or unsupported ranges fall back to `200`. The server streams bounded file chunks from the daemon with backpressure, cancellation, and file-revision checks. HEAD and cache hits avoid content reads. HTML previews retain their size limit and security headers. Markdown video uses sanitized HTML `<video>` and `<source>` elements with local file routing. Plain Markdown retains incremental rendering. Storage ETags are now weak metadata validators; `If-Range` therefore falls back to a full `200`. The host-daemon protocol moves from 218 to 219, and the Plugin SDK from 0.5.27 to 0.5.28. The public SDK and CLI request shapes do not change. Details and limits are documented in `docs/debugging-and-qa.md`. This PR includes the streaming and Markdown video work from #4351, which was squash merged into this branch. The 2 KiB raw and 256-byte compressed thread-route bundle budget adjustment accounts for the new Markdown video renderer after merging current `main`; the built closure is 2281.5 KiB raw and 613.6 KiB brotli. ## How you verified - Server streaming tests: 33 passed, covering ranges, conditional requests, HEAD, large files, backpressure, cancellation, and file changes. - Public thread-data route tests: 88 passed. Daemon file tests: 27 passed. Host-daemon contract tests: 72 passed. - Markdown renderer: 122 targeted app tests passed, including chat/plugin file routing and sanitizer behavior. App lint and typecheck passed. - A 33,861,556-byte H.264 MP4 returned correct `206` ranges and matching bytes. Chromium and iOS 26.5 Simulator Safari played and sought the video through a local proxy; authenticated public Connect playback remains unverified. - CI passed for #4351's final head before the squash merge. The combined #4343 branch plus current `main` reproduced a 1.7 KiB raw bundle-budget failure; after the documented budget adjustment, the local app build and bundle check pass. CI on this head is running. Fixes #4339 > AGENT GENERATED
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.
Human comments
What was wrong
The HTTP range fix in #4343 still read and transferred the entire file through the daemon for every range. Seeking repeated that work, and videos larger than the daemon's 25 MiB whole-file cap could not be served.
What changed
Adds
host.read_file_chunk: a root-confined, metadata-only or bounded byte read (at most 1 MiB) with an explicit revision guard. Thread-storage responses now stream these chunks with backpressure, stop future reads on cancellation, and check file revision before and after each daemon read. HEAD, cache hits, and unsatisfiable ranges do not read content. Overwrite, truncation, replacement, short reads, and later stream failures cannot silently complete with mixed or incomplete data.Host-daemon protocol 218 → 219 requires daemon updates. Plugin SDK 0.5.27 → 0.5.28 is required because the daemon command expands the generated declarations. Existing whole-file RPCs and other routes remain unchanged. Thread-storage downloads bypass their former size caps; HTML previews retain their 5 MiB limit and security headers.
Storage ETags change from content SHA-256 to weak metadata validators, avoiding whole-file hashing. If-None-Match still supports 304; any If-Range falls back to full 200 because the ETag is weak. Revision checking detects normal filesystem changes but is not an immutable snapshot guarantee. Public SDK/CLI request shapes are unchanged. Behavior and compatibility are documented in
docs/debugging-and-qa.md.This PR is stacked on #4343; review its incremental diff against that branch.
Markdown video uses standard HTML markup,
<video src="clip.mp4" controls></video>, through the existing rehype-raw/rehype-sanitize path. Added video/source attributes to the sanitizer, reused local file routing for src and poster, and enabled sanitized HTML in chat and plugin Markdown. The previous image-syntax extension is removed:remains an image. Existing directives and mentions survive sanitization. Plain Markdown keeps incremental rendering; HTML-containing documents use the existing whole-document HTML path. No new SDK members, CLI flags, or wire changes in this UI update.How you verified
Server streaming tests: 33 passed, covering ranges, conditional requests, HEAD, empty files, 40 MiB logical streams, backpressure, cancellation, aborts, short/misaligned chunks, and stream failures.
Public thread-data route tests: 88 passed, including the new RPC path, preview protections, oversized HTML rejection before content reads, and retryable file-change conflicts.
Existing whole-file response tests: 6 passed.
Daemon file tests: 27 passed, including a sparse file beyond 32 MiB, tiny ranged reads, unchanged legacy cap, stale revisions, root escapes, directories, and FIFOs.
Host-daemon contract suite: 72 passed, including chunk bounds and required confinement.
Turbo typechecks for server, host daemon, and host-daemon contract passed.
Built full head/base
pnpm start:worktreeservers at exact commits. The same 33,861,556-byte H.264 MP4 (with a padding box) yields 413 on Fix byte ranges for thread-storage videos #4343 and correct 206 byte ranges here. Full download and range bodies match source bytes.Actual iOS 26.5 Safari in iPhone 17 Pro Simulator, via a local proxy omitting Content-Length: large video plays, emits seeked at 8.0008 seconds, and pauses without a media error. The base cannot load it. Controls were invoked through WebDriver script; native-touch automation and macOS Safari remain unverified.
Actual Chromium clicks in the full inline thread preview play, seek, and pause the large video.
Changing a 40 MiB file during a live transfer terminates its response after 2 MiB; it does not complete with mixed versions.
All executed CI checks pass at final head
c425c4b4bd0481fcec3224a9b21e2761eed4c3e9; optional iOS and Node compatibility jobs were skipped by the workflow. The rebuilt final-head server also passes the large-file range check.Follow-up to #4339 and #4343.
HTML Markdown renderer: 122 targeted app tests pass, covering chat/plugin file routing, sanitizer protections, nested source/poster, preserved directives and mentions, text-only previews, and video DOM retention. App lint and typecheck pass. Chromium and real iOS Simulator Safari played and sought the 32.3 MiB stored file through a local cookie-enforcing streaming proxy using the HTML markup at this head (Safari 1.922s playing, 8.812s after seeking; no media errors). Live HTML-in-Markdown video test. Authenticated public Connect still awaits user verification.