Repository navigation
Studio: write transcoded WAV blocks raw and fix the header once on close - #15917
Merged
Merged
Conversation
Member
Author
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Member
Author
|
@codex review |
|
Codex Review: Didn't find any major issues. 🎉 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". |
danielhanchen
added a commit
that referenced
this pull request
Oct 29, 2026
…s in flight (#15953) ## Summary `Chat UI Tests (extra)` fails now and then in `tests/studio/playwright_ui_font_scale.py`, on PRs that do not touch the UI (#15917, #15859): ``` [font-scale] FAIL in step 'default restores exactly' after 0.3s: default drifted for navFont: 13.5938 -> 18.125 ``` 18.125 is the nav font at UI size 20 (13.5938 x 20 / 15), so a size the test had left two steps earlier came back after it set the default. The test is right; this is a real product race in `usePersonalizationSync`: 1. On load, the hook GETs `/api/settings/personalization` and, when the answer arrives, `replaceAll`s the appearance store with the server copy. 2. Saves are debounced by 800 ms, so a size changed shortly before a navigation is in localStorage but not on the server. In the run above, 20 was saved, then 12 was set and the page reloaded inside the debounce. 3. After the reload the user (here, the test) sets the size again. If the GET resolves after that, the server's stale 20 replaces the value they just picked. A user who changes a setting in the first moments after opening Studio can see it snap back the same way. ## What changed - `use-personalization-sync.ts` notes the appearance customization when the load starts. If the store holds a different object when the server answers, the user edited during the request, so local wins: the store is not overwritten, and because the baseline records the server's values, the normal debounced push uploads the edit. - Without an edit in flight, nothing changes: a saved server customization still replaces the local one. ## Verification - Two tests in `studio/frontend/tests/personalization-locale-hydration.test.ts`, using its existing hook harness with the GET held open: - an edit made while the request is in flight survives and is the value that gets saved (fails on main: the size becomes the server's 20) - with no edit in flight, the server customization still wins - The whole file: 14 pass. Against the unfixed hook, only the in-flight test fails. - `npm run typecheck` passes and eslint is clean on both files. Biome reports the same 2 errors as on main, all in lines this change does not touch. The fix changes when a setting is kept, not anything drawn, so there is nothing to screenshot. The Playwright font-scale check in `Chat UI Tests (extra)` is the end-to-end cover.
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.
What changes
transcode()writes each resampled block (about 1024 samples) withwave.Wave_write.writeframes. In CPython that iswriteframesrawfollowed by_patchheader()whenever the header's data length is stale, which on a stream of unknown length is every block: seek to the header, rewrite the RIFF and data sizes, seek back. This switches towriteframesraw;Wave_write.close(), whichtranscode()already calls beforeos.replacepublishes the file, patches the header once with the final sizes. Per the Pythonwavedocs,writeframesrawwrites frames "without correcting nframes", andwriteframeswrites them "and make[s] sure nframes is correct";close()makes sure nframes is correct. The output file is a regular seekable temp file, which header patching requires. Python 3.9 and 3.14 have the samewriteframesandcloselogic.Decoding, resampling, clipping, channel selection, the 413 cut-off and the published bytes are unchanged.
Results
Parity: 17 inputs (WAV s16/u8/f32, MP3, FLAC incl. 4 channel, Ogg Vorbis, AAC 5.1, MP4 and WebM video, 8 kHz to 96 kHz, 10 ms to 30 min, truncated, empty, no audio) x 6 option sets (default, 24 kHz mono, forced stereo, 16 kHz mono cut at 5 s, refused past 5 s, 8 kHz cut at 12.3 ms): 120 results, identical info dicts, errors and output SHA-256 against main. The
save_from_mediamatrix (340 requests) is also identical.Header rewrites (
_patchheadercalls) for the 102 small-input transcodes: 54001 on main, 68 here. For the 18 long-input transcodes: 297333 on main, 15 here.Wall time,
transcode()default options, median (main run twice for noise):This applies to every upload, voice reference, transcription input and media cut that goes through
transcode().Tests
test_transcode_writes_the_wav_header_sizes_once_at_close: one header patch with the final data size, correct frame count and info. Fails on main (one patch per block), passes here.test_audio_inputs.py,test_account_media_isolation.py,test_audio_voices.py,test_audio_edit_route.py,test_audio_edit_requests.py,test_audio_run_extras.py,test_video_gallery.py,test_audio_cpp_clone_requests.py,test_audio_cpp_convert_requests.py: 258 passed on main, 259 passed here, no failures on either side.Not covered
Measured on Linux only; the saving per block is a seek pair and a small write, so it should be larger on Windows file systems, but that was not run.