Repository navigation
Studio: accept subtitle, caption and the rest of the common attachment formats - #9738
Conversation
|
@codex review |
Two limits bind a decode at once, the thirty-minute clock and a rate-independent sample count, and the decode refuses at whichever is smaller. The buffer sizing did not read the same bound. The initial allocation clamped only to the sample count, so an 8 kHz file declaring three hours reserved 86.4M floats (330 MB) on the way to being refused at 14.4M (55 MB), and the doubling that covers an under-reported duration was not clamped at all: 48 kHz declaring twenty minutes and holding twenty-one grew to 115.2M against an 86.4M limit, with the old buffer still live for the copy. _decoded_sample_ceiling is now the single source for all three, so the allocation, the growth target and the refusal cannot drift apart. The growth clamp cannot starve a write, since the sample count has already been checked against that same ceiling.
|
@codex review |
1 similar comment
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7cfe5986c2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const decoder = new TextDecoder("windows-1252"); | ||
| if (decoder.decode(bytes.subarray(0, 5)).toLowerCase() !== "<?xml") { | ||
| return null; |
There was a problem hiding this comment.
Detect BOM-less UTF-16 XML declarations
For a BOM-less UTF-16LE/BE XML attachment whose prolog explicitly declares that encoding, decoding the first five bytes as Windows-1252 produces interleaved NULs, so this check never recognizes <?xml. The file then falls through to strict UTF-8 decoding, which either rejects it when it contains non-ASCII text or sends NUL-padded gibberish when it is ASCII-only. Detect the standard UTF-16 byte patterns before scanning the prolog so these XML, plist, SVG, and project-file attachments use their declared encoding.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Leaving this one: the input it describes is not well-formed XML.
XML 1.0 5th edition section 4.3.3 is explicit that entities encoded in UTF-16 MUST begin with the Byte Order Mark, and appendix F treats FE FF / FF FE as the autodetection signature precisely because the declaration cannot be read before the encoding is known. RFC 3023, restated in RFC 7303, is the other half: utf-16le and utf-16be MUST NOT carry a BOM and SHOULD carry an encoding declaration, but those are labels a transport applies, and there is no transport here. A file dropped onto the composer has only its bytes, so the only conforming way for it to be UTF-16 is to start with a BOM.
Both BOMs are already handled, ahead of the prolog scan, and they decode as strictly as everything else rather than being stripped and guessed at. So a conforming UTF-16 XML, plist, SVG or project file is read through its declared encoding today; what is being asked for is recovery of a file the spec says must not exist, and buying that means sniffing NUL interleaving on every text attachment, which is a guess that ASCII-with-embedded-NULs and some UTF-16 text both answer the same way.
The PyAV path was fixed to write each block into a single growing buffer, but the soundfile path kept the branch that motivated it. When libsndfile reports no usable frame count, or one past the ceiling, the declared length is dropped, nothing is preallocated, and every block is held until a final concatenate allocates a second copy of the recording. Measured with a source reporting zero frames for a 30-minute 48 kHz decode: 592.6 MB peak against a 329.6 MB waveform. Now one append-only buffer that doubles when it runs short and is clamped to _decoded_sample_ceiling: 352.0 MB for the same decode, with the returned array byte-identical. An honest header is still only trusted once the decode has met half of it, so it sizes the growth rather than buying an array up front, and ordering is now correct by construction rather than by a latch. Two tests asserted the old mechanism instead of the behaviour and were restated: one required the final concatenate to happen, and one required no allocation at all before the cap refuses, which a streaming buffer cannot promise. The guarantee they were protecting, that nothing the header claims is allocated, is now asserted directly against the ceiling.
|
@codex review |
1 similar comment
|
@codex review |
|
Codex Review: Didn't find any major issues. More of your lovely PRs please. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
Note on the red The failing step is
So main is already over on its own, and CI agrees: the same step failed on main at 87ab4ed with That means it cannot be cleared from this branch. Taking the attachment work to zero bytes still leaves main 3.7 KB over, and raising The 6.6 KB this branch adds is real and worth trimming separately. The charset detection and the five binary sniffers in |
|
CI has finished on
The The digest pin and the AppImage checksum should clear on their own once someone updates them on main. The bundle budget will not, for the reason in the previous comment. Separately, a cross-platform replication of this branch ran on a staging repo to keep it off the org queue: 15 green, 4 red, and the 4 are the same pre-existing set ( |
A user reported that Studio refuses
.srtand.vttwhen it should take them. It does, and the same gap covers a long tail of other formats.What was wrong
.srtand.vttare plain UTF-8, but neither was on any allowlist, so the file picker greyed them out and a native drag and drop was refused with "Unsupported attachment type". Chat attachments are gated by five separate hand-maintained lists (three in TypeScript, two in Rust), and they had drifted well behind what the pipeline can actually handle..jsonc/.json5.aac,.opus,.aiff,.wma,.amr, even though the backend decodes all of them.m4v,.mpg,.wmv,.flv,.3gp,.ogvWhat changed
Text: 80 extensions to 285. Subtitles (
.srt .vtt .sbv .ass .ssa .sub .lrc), docs (.tex .bib .adoc .org .rmd .qmd), data (.jsonc .json5 .geojson .har .plist .avsc), localisation (.po .strings .resx .xliff .ics .vcf .eml), templates (.erb .ejs .hbs .jinja .twig .liquid .razor .pug), and around 120 more languages (.hs .ml .ex .erl .fs .clj .zig .nim .cr .cu .cuh .sol .cairo .mojo .f90 .cob .ada), plus shaders, shells and build files.Audio:
.opus .aac .aiff .aif .aifc .caf .wma .amr .mp2. Every one of these already decodes through libsndfile or the librosa/ffmpeg fallback in_decode_audio_mono, so the picker was stricter than the pipeline behind it..webmand.mp4deliberately stay off the extension list, since the audio adapter runs before the video adapter and would claim video files.Video:
.m4v .mpg .mpeg .wmv .flv .3gp .ogv, all of which ffmpeg reads..tsand.mtsstay off, since they are TypeScript here.Deduplication.
native_clipboard.rscarried a hand-copied 70-extension duplicate of the text list. It now falls back toTEXT_ATTACHMENT_EXTS, so it cannot drift again. The Rust and TypeScript lists are mirrored as before, and the existing parity tests keep them honest.Syntax highlighting gains 167 shiki mappings so the new formats colour in the preview dialog instead of rendering flat. Unknown ids already degrade to plain text in
code-plugin.ts, so this is safe either way.What I deliberately left alone
Images stay at jpeg/png/webp/gif. Files go to the model as raw base64, and the external providers accept only those four, so adding
.bmp/.heic/.tiffwould fail at the model instead of at the picker, which is a worse experience than the current message. Doing it properly needs client side transcoding, and Chromium cannot decode HEIC or TIFF anyway.Knowledge base uploads stay at the 7 RAG types. The native drop router treats "is a RAG type" as "index it rather than attach it inline", so widening that list would silently divert dropped source files into the knowledge base instead of the chat.
Testing
cargo checkclean with no unreachable match arms.tsc --noEmitclean,npm run buildclean.