Repository navigation
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
| const START_MAX_SHORT_SIDE = 1080; | ||
| const HLS_PLAYLIST_FILE_PATTERN = /^[A-Za-z0-9_-]+\.m3u8$/; | ||
| const HLS_MEDIA_FILE_PATTERN = /^[A-Za-z0-9_-]+\.m4s$/; | ||
| const SEGMENTS_FILE_PATTERN = /^(video|audio)\/segment_(\d{3})\.m4s$/; |
There was a problem hiding this comment.
With segments=short, recordings that reach segment 1000 get URLs such as video/segment_1000.m4s. This pattern accepts exactly three digits, so segments-file returns 404 and playback stops or seeking fails. padStart(3) sets a minimum width, not a maximum. Accept three or more digits and keep the existing manifest membership check.
| const SEGMENTS_FILE_PATTERN = /^(video|audio)\/segment_(\d{3})\.m4s$/; | |
| const SEGMENTS_FILE_PATTERN = /^(video|audio)\/segment_(\d{3,})\.m4s$/; |
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/web/app/api/playlist/route.ts
Line: 72
Comment:
**Long recordings stop playing**
With `segments=short`, recordings that reach segment 1000 get URLs such as `video/segment_1000.m4s`. This pattern accepts exactly three digits, so `segments-file` returns 404 and playback stops or seeking fails. `padStart(3)` sets a minimum width, not a maximum. Accept three or more digits and keep the existing manifest membership check.
```suggestion
const SEGMENTS_FILE_PATTERN = /^(video|audio)\/segment_(\d{3,})\.m4s$/;
```
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.There was a problem hiding this comment.
Note
🤖 claude-opus-5-5 on behalf of Aatman AJ Jain
Fixed in d5c350e. SEGMENTS_FILE_PATTERN now accepts \d{3,}, and the parsed file must round-trip to the canonical padStart(3) name (so segment_0001 / segment_01 still 404) before the existing manifest membership check runs. The short playlist builder and the file route share one segmentsFileName helper. New tests in segment-playlist-route.test.ts list and redirect video/segment_1000.m4s from a 1000-segment manifest and reject non-canonical or unlisted names.
| headers: { | ||
| ...getHeaders(origin), | ||
| "Cache-Control": | ||
| query.public && !request.headers.get("cookie") | ||
| ? "public, max-age=300, s-maxage=300" | ||
| : "private, max-age=300", | ||
| }, |
There was a problem hiding this comment.
Cached thumbnails mix allowed origins
The newly cacheable thumbnail response needs Vary: Origin. getHeaders(origin) reflects each trusted origin, but shared caches are not told to separate those responses. If a shared cache reuses a response from https://cap.so for https://cap.link, the browser blocks it because Access-Control-Allow-Origin names the wrong origin.
| headers: { | |
| ...getHeaders(origin), | |
| "Cache-Control": | |
| query.public && !request.headers.get("cookie") | |
| ? "public, max-age=300, s-maxage=300" | |
| : "private, max-age=300", | |
| }, | |
| headers: { | |
| ...getHeaders(origin), | |
| Vary: "Origin", | |
| "Cache-Control": | |
| query.public && !request.headers.get("cookie") | |
| ? "public, max-age=300, s-maxage=300" | |
| : "private, max-age=300", | |
| }, |
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/web/app/api/thumbnail/route.ts
Line: 108-114
Comment:
**Cached thumbnails mix allowed origins**
The newly cacheable thumbnail response needs `Vary: Origin`. `getHeaders(origin)` reflects each trusted origin, but shared caches are not told to separate those responses. If a shared cache reuses a response from `https://cap.so` for `https://cap.link`, the browser blocks it because `Access-Control-Allow-Origin` names the wrong origin.
```suggestion
headers: {
...getHeaders(origin),
Vary: "Origin",
"Cache-Control":
query.public && !request.headers.get("cookie")
? "public, max-age=300, s-maxage=300"
: "private, max-age=300",
},
```
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.There was a problem hiding this comment.
Note
🤖 claude-opus-5-5 on behalf of Aatman AJ Jain
Fixed in 043b956. The thumbnail response now sends Vary: Origin, and the public scope additionally requires the video to have no password (query.password), so password-protected videos never get shared-cache headers even before the cookie check. thumbnail-published-output.test.ts covers public, password-protected, private and signed-in cases and asserts Vary: Origin on each.
| if ( | ||
| body.byteLength >= COMPRESSED_PLAYLIST_MIN_BYTES && | ||
| acceptEncoding.toLowerCase().includes("gzip") | ||
| ) { | ||
| return HttpServerResponse.uint8Array(gzipSync(body), { | ||
| headers: { ...headers, "Content-Encoding": "gzip" }, |
There was a problem hiding this comment.
Checking whether Accept-Encoding contains gzip also accepts gzip;q=0, which explicitly forbids gzip. Playlists over 1 KB are then compressed despite the client's stated restriction. Parse the encoding preferences and only compress when gzip has a positive quality value.
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/web/app/api/playlist/route.ts
Line: 100-105
Comment:
**Disabled gzip is still sent**
Checking whether `Accept-Encoding` contains `gzip` also accepts `gzip;q=0`, which explicitly forbids gzip. Playlists over 1 KB are then compressed despite the client's stated restriction. Parse the encoding preferences and only compress when gzip has a positive quality value.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.There was a problem hiding this comment.
Note
🤖 claude-opus-5-5 on behalf of Aatman AJ Jain
Fixed in e3514b0. acceptsGzip parses Accept-Encoding entries with their q values: an explicit gzip/x-gzip entry wins, otherwise * applies, and compression only happens when the resulting quality is above 0. Tests cover gzip, br, gzip;q=0.5 and * (compressed) and gzip;q=0, gzip; q=0.0, br, *;q=0, identity and empty (plain text, still Vary: Accept-Encoding).
|
Thanks @AatmanAJ, this looks like a useful change. Before we can merge it:
Once those are sorted, request a re-review from Greptile. |
The ladder-master playlist route moves to CapSoftware#4832 with its endpoint.
2d6038f to
d4ae850
Compare
|
@AatmanAJ is attempting to deploy a commit to the Cap Software Inc Team on Vercel. A member of the Team first needs to authorize it. |
|
Note 🤖 @richiemcilroy all three open points are fixed on the new head (rebased onto current
Also in this PR now: d4ae850 moves the share-page caller for the ladder endpoint here from #4835, so the endpoint and its only caller ship together. A non-segmented source with a non-empty Private and password-protected videos never get @greptileai review |
| const key = (video.source as { hlsMasterKey?: unknown }).hlsMasterKey; | ||
| if (typeof key !== "string" || !key.endsWith(".m3u8")) return null; |
There was a problem hiding this comment.
For a video whose stored source includes hlsMasterKey, the share page selects ladder-master. But getByIdForViewing loads the video through VideosRepo.decodeRow, which calls Video.Video.decodeSync. The source schema does not include hlsMasterKey, so decoding removes it. This check then returns null, and the playlist request returns 404 instead of playing the video.
Add hlsMasterKey to the shared source schema so the page and API agree.
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/web/app/api/playlist/route.ts
Line: 244-245
Comment:
**Ladder videos cannot play**
For a video whose stored source includes `hlsMasterKey`, the share page selects `ladder-master`. But `getByIdForViewing` loads the video through `VideosRepo.decodeRow`, which calls `Video.Video.decodeSync`. The `source` schema does not include `hlsMasterKey`, so decoding removes it. This check then returns `null`, and the playlist request returns 404 instead of playing the video.
Add `hlsMasterKey` to the shared source schema so the page and API agree.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.There was a problem hiding this comment.
Note
🤖 claude-opus-5-5 on behalf of Aatman AJ Jain
Valid. Fixed in 5ba1d3c. hlsMasterKey: Schema.optional(Schema.String) is now part of the shared Video.source schema, so VideosRepo.decodeRow keeps it and getHlsMasterKey reads video.source.hlsMasterKey directly instead of casting. The route tests previously returned plain objects and skipped decoding. The new test in legacy-playlist-route.test.ts serves the video through Video.Video.decodeSync and plays ladder-master then ladder-rendition end to end. Without the schema field it fails as you described.
|
Note 🤖 Greptile's new P1 on d4ae850 was valid: the decoded @greptileai review |
Problem
Share playback revalidated completed playlists on every load, collapsed legacy multivariant HLS masters to one rendition, and proxied media/preview responses with cache-defeating headers. Long playlists also required serial or unbounded signing work.
What changed
publiconly for credential-free public access, otherwiseprivate); growing/live segment playlists remainno-store.source.hlsMasterKeyladder master/rendition/media routing with signed fMP4 URLs and optional short playlists.source.hlsMasterKeythrough the HLS player viavideoType=ladder-master; all other sources are unchanged.Accept-Rangesand ETag/conditional handling.Verification
bun run typecheckbun run biome check --writeon all touched filesbunx vitest runfor the playlist, storage object, thumbnail, and preview route unit tests, plus the share-page ladder dispatch test (151 focused tests passing)Confidence Score: 5/5

The PR appears safe to merge; all previous findings are fixed and no new actionable issues were found.Summary
The PR adds playlist caching and compression, preserves adaptive HLS choices, and improves media, preview, and thumbnail caching.
Reviews (3) · Last reviewed commit: "fix(web): keep hlsMasterKey when decodin..." · Reviewed by Greptile