fix: export filenames are unreadable in molab - #10478
Open
Light2Dark wants to merge 2 commits into
Open
Conversation
molab instant-launch serves the editor from the session host but calls the kernel on the sandbox host, so Content-Disposition is not visible to JS. Use notebook-derived defaults instead of failing the download. Co-authored-by: Cursor <cursoragent@cursor.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Light2Dark
marked this pull request as ready for review
August 6, 2026 17:52
Contributor
There was a problem hiding this comment.
2 issues found across 6 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="frontend/src/core/network/api.ts">
<violation number="1" location="frontend/src/core/network/api.ts:28">
P2: Malformed percent-encoding in a readable `filename*` causes export handling to throw instead of using `opts.defaultFilename`; catch decode failures and return `undefined` so the existing fallback runs.</violation>
</file>
<file name="frontend/src/core/network/export-filename.ts">
<violation number="1" location="frontend/src/core/network/export-filename.ts:23">
P2: Exports for notebooks whose filename uses Windows separators receive a path-containing download name instead of the notebook basename. Splitting both separators or reusing `Paths.basename` keeps the fallback filename portable.</violation>
</file>
Architecture diagram
sequenceDiagram
participant Editor as Editor UI (Browser)
participant Network as Network Requests
participant Kernel as Kernel Backend (Molab)
participant Filename as Default Filename Resolver
participant Store as Jotai Store (filenameAtom)
participant Api as API Client (api.ts)
Note over Editor,Kernel: Export flow (HTML, Markdown, Script, IPYNB, PDF)
Editor->>Network: Trigger export (e.g., Download as HTML)
Network->>Kernel: POST export endpoint with format params
Kernel-->>Network: Export body + Content-Disposition header
Note over Network,Api: Molab cross-origin: editor domain differs from kernel domain, so Content-Disposition may not be exposed to JS
alt Markdown export
Network->>Filename: NEW: getDefaultMarkdownExportFilename(flavor)
Filename->>Filename: Map flavor to extension (.qmd, .md, .myst.md)
else Other export types
Network->>Filename: NEW: getDefaultExportFilename(extension)
end
Filename->>Store: Read current notebook filename
alt Notebook has a name
Store-->>Filename: "folder/my_notebook.py"
Filename-->>Network: "my_notebook.html"
else Notebook is unnamed or filename missing
Store-->>Filename: null
Filename-->>Network: "download.html"
end
Network->>Api: NEW: handleExportResponse(response, { defaultFilename })
Api->>Api: Parse export body (blob/text)
alt Content-Disposition header readable
Api->>Api: CHANGED: Parse RFC5987, quoted, or unquoted filename
Api-->>Network: Use filename from header
else Header missing or unparsable
Api-->>Network: NEW: Use defaultFilename
end
Api->>Api: Read Content-Type media type
alt Content-Type missing
Api-->>Network: Reject export (missing media type)
else Valid response
Api-->>Network: ExportedFile { contents, filename, mediaType }
Network-->>Editor: Trigger browser download with resolved filename
end
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
Wrap malformed RFC 5987 decoding in try/catch so default filenames apply, and use Paths.basename for notebook stems on Windows paths. Co-authored-by: Cursor <cursoragent@cursor.com>
Contributor
|
All contributors have signed the CLA ✍️ ✅ |
Contributor
Coverage Report for ./frontend
File Coverage
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
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.
📝 Summary
Fixes molab export downloads failing with
Export response is missing a filename.After #10349, exports required reading
Content-Dispositionfrom the fetch response. In molab instant-launch, the editor runs on{sandbox}-session.sb.molab.runbut calls the kernel on{sandbox}.sb.molab.run, so that header is not visible to JS cross-origin. The export body still succeeds; only the filename lookup failed.This adds client-side default filenames (notebook name, or
download.*) when the header cannot be read, and broadensContent-Dispositionparsing.The root cause fix is on molab-side, but regardless, downloads shouldn't fail when the header cannot be read.
📋 Pre-Review Checklist
✅ Merge Checklist