fix: stdin handling for empty submissions#9556
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull request overview
This PR fixes stdin handling so empty frontend submissions are sent to the kernel and backend stdin file-style reads treat them as blank lines rather than EOF.
Changes:
- Allows Enter on an empty console stdin input to submit
""while keeping empty values out of history. - Moves shared
readline()/readlines()behavior to theStdinbase class and appends"\n"for file-protocol consumers. - Updates Python/Pyodide and frontend tests for empty stdin behavior.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
frontend/src/components/editor/output/console/ConsoleOutput.tsx |
Updates stdin submission and response rendering. |
frontend/src/components/editor/output/console/__tests__/ConsoleOutput.test.tsx |
Adds tests for empty stdin submission and history behavior. |
marimo/_messaging/types.py |
Adds shared stdin readline/readlines implementation. |
marimo/_messaging/streams.py |
Removes duplicate ThreadSafeStdin read methods. |
marimo/_pyodide/streams.py |
Removes duplicate PyodideStdin read methods. |
tests/_messaging/test_streams.py |
Updates stdin expectations and adds builtins input empty-response coverage. |
tests/_pyodide/test_pyodide_streams.py |
Updates Pyodide stdin expectations and adds empty submission coverage. |
There was a problem hiding this comment.
1 issue found across 5 files (changes from recent commits).
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/components/editor/renderers/vertical-layout/vertical-layout.tsx">
<violation number="1" location="frontend/src/components/editor/renderers/vertical-layout/vertical-layout.tsx:408">
P2: Use the cell's actual `interrupted` state instead of hardcoding `false`. Hardcoding `false` means that if a cell was interrupted (e.g., Ctrl+C) while waiting for stdin input, the ConsoleOutput will still show the `>` icon and `(empty)` placeholder for the interrupted stdin response, which is misleading.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
4e86ded to
e9f5337
Compare
Bundle ReportChanges will increase total bundle size by 10.4kB (0.04%) ⬆️. This is within the configured threshold ✅ Detailed changes
Affected Assets, Files, and Routes:view changes for bundle: marimo-esmAssets Changed:
Files in
Files in
Files in
|
|
🚀 Development release published. You may be able to view the changes at https://marimo.app?v=0.23.7-dev76 |
📝 Summary
input("Press Enter to continue:")(e.g.logfire,click.prompt,rich.prompt,pdb) would hang forever.builtins.input()raisedEOFErroron blank submissions becauseThreadSafeStdin.readline()returned""— which CPython'sinput()interprets as EOF rather than a blank line.Fix
Frontend (
ConsoleOutput.tsx)StdInputnow submits on Enter even when empty (history skip preserved).StdInputWithResponserenders past responses with a>chevron, sky-11 color, and an(empty)placeholder so user-typed responses are visually distinct from stdout — even when the prompt half is empty (which happens when CLIsprint()the prompt themselves before callinginput()).Backend (
marimo/_messaging/types.py,streams.py,_pyodide/streams.py)Stdin.readline()now appends"\n"so blank submissions surface as"\n"rather than"".readlines()simplified to[readline()].readline/readlinesto theStdinbase class — both subclasses had identical implementations._readline_with_promptunchanged: still returns the bare response, soinput_overridecontinues to satisfy Python'sinput()contract.📋 Pre-Review Checklist
✅ Merge Checklist