Skip to content

Tests: follow the sandbox save and snippet name helpers the Files menu split out - #19320

Merged
danielhanchen merged 1 commit into
mainfrom
ci/follow-files-menu-refactor
Nov 24, 2026
Merged

danielhanchen merged 1 commit into
mainfrom
ci/follow-files-menu-refactor

Conversation

@danielhanchen

@danielhanchen danielhanchen commented Nov 24, 2026 •

Copy link
Copy Markdown
Member

Problem

Four source-contract tests fail on main since #19172 (Files menu for chat), so PRs based on main go red on them:

  • studio/backend/tests/test_sandbox_files_and_storage_roots.py
    • test_a_large_file_is_streamed_rather_than_buffered
    • test_a_native_download_gets_an_absolute_url
    • test_the_file_download_button_refreshes_the_session_first
  • tests/studio/test_desktop_reliability_frontend_contract.py::test_generated_download_buttons_use_the_native_save_boundary

Cause

#19172 is a correct refactor. The Files menu needed the same two pieces of logic as existing components, so it moved them into shared modules without changing them:

  • the sandbox file save (HEAD probe through authFetch, then a streamed download to an absolute apiUrl(...) carrying the bearer) moved from SandboxFileRow's save callback in sandbox-files-view.tsx to saveSandboxFile in sandbox-download.ts, which the view now calls;
  • getCodeFilename (the snippet extension table and fallbackExt) moved from markdown-text.tsx to code-filename.ts, which markdown-text.tsx now imports.

The tests read only the original files, so they lost sight of code that still exists. #19172's last (Python 3.13, rest) run already showed the sandbox three as red.

Fix

Test only. The guards now read the code where it lives and also pin the delegation, so a later edit cannot quietly route around the shared helper:

  • _sandbox_file_save_sources() requires the view to import saveSandboxFile from ./sandbox-download and call it from the Save button, and returns the body of saveSandboxFile for the three tests. The checks on that body are the same as before (streamed, no response.blob(), token= in the URL, absolute URL, authFetch HEAD before getAuthToken()), plus one new one: a refused probe throws before downloadUrlStreaming, so a 401 body is never saved as the file.
  • The desktop contract requires markdown-text.tsx to import getCodeFilename from ./code-filename and call getCodeFilename(language), and reads fallbackExt and rust: "rs" from code-filename.ts.

Verification

  • Both files: 46 passed and 321 passed (4 failed on main).
  • Sabotage, one at a time, each makes the matching test fail:
    • a relative download URL in saveSandboxFile;
    • reading the token before the HEAD probe;
    • dropping the if (!probe.ok) throw;
    • the view's Save button no longer calling saveSandboxFile (all three sandbox tests);
    • markdown-text.tsx importing the snippet helper from another module;
    • removing rust: "rs" from code-filename.ts.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-24T17:50:02.931113Z a45c205 Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Bravo.

Reviewed commit: a45c205b10

ℹ️ 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".

@danielhanchen
danielhanchen merged commit fc1d0fa into main Nov 24, 2026
1 of 19 checks passed
@danielhanchen
danielhanchen deleted the ci/follow-files-menu-refactor branch November 24, 2026 17:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant