Skip to content

fix: stdin handling for empty submissions#9556

Merged
Light2Dark merged 7 commits into
mainfrom
sham/fix-empty-input
May 21, 2026
Merged

fix: stdin handling for empty submissions#9556
Light2Dark merged 7 commits into
mainfrom
sham/fix-empty-input

Conversation

@Light2Dark
Copy link
Copy Markdown
Collaborator

@Light2Dark Light2Dark commented May 15, 2026

📝 Summary

  • Pressing Enter with no input in marimo's stdin box was silently swallowed by the frontend, so any CLI calling input("Press Enter to continue:") (e.g. logfire, click.prompt, rich.prompt, pdb) would hang forever.
  • Once unblocked, a second bug surfaced: builtins.input() raised EOFError on blank submissions because ThreadSafeStdin.readline() returned "" — which CPython's input() interprets as EOF rather than a blank line.

Fix

Frontend (ConsoleOutput.tsx)

  • StdInput now submits on Enter even when empty (history skip preserved).
  • StdInputWithResponse renders 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 CLIs print() the prompt themselves before calling input()).
image

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()].
  • Lifted readline/readlines to the Stdin base class — both subclasses had identical implementations.
  • _readline_with_prompt unchanged: still returns the bare response, so input_override continues to satisfy Python's input() contract.

📋 Pre-Review Checklist

  • For large changes, or changes that affect the public API: this change was discussed or approved through an issue, on Discord, or the community discussions (Please provide a link if applicable).
  • Any AI generated code has been reviewed line-by-line by the human PR author, who stands by it.
  • Video or media evidence is provided for any visual changes (optional).

✅ Merge Checklist

  • I have read the contributor guidelines.
  • Documentation has been updated where applicable, including docstrings for API changes.
  • Tests have been added for the changes made.

Copilot AI review requested due to automatic review settings May 15, 2026 06:55
@vercel
Copy link
Copy Markdown

vercel Bot commented May 15, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
marimo-docs Ready Ready Preview, Comment May 19, 2026 2:03pm

Request Review

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 7 files

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 the Stdin base 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.

Comment thread frontend/src/components/editor/output/console/ConsoleOutput.tsx
@Light2Dark Light2Dark added the bug Something isn't working label May 15, 2026
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread frontend/src/components/editor/renderers/vertical-layout/vertical-layout.tsx Outdated
mscolnick
mscolnick previously approved these changes May 18, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 19, 2026

Bundle Report

Changes will increase total bundle size by 10.4kB (0.04%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
marimo-esm 25.18MB 10.4kB (0.04%) ⬆️

Affected Assets, Files, and Routes:

view changes for bundle: marimo-esm

Assets Changed:

Asset Name Size Change Total Size Change (%)
assets/cells-*.js 3.16kB 709.93kB 0.45%
assets/index-*.js 196 bytes 607.76kB 0.03%
assets/JsonOutput-*.js 6.28kB 367.23kB 1.74%
assets/index-*.css 349 bytes 366.31kB 0.1%
assets/dist-*.js -172 bytes 104 bytes -62.32%
assets/dist-*.js 73 bytes 177 bytes 70.19% ⚠️
assets/dist-*.js 152 bytes 335 bytes 83.06% ⚠️
assets/dist-*.js -119 bytes 137 bytes -46.48%
assets/dist-*.js 80 bytes 256 bytes 45.45% ⚠️
assets/dist-*.js -111 bytes 276 bytes -28.68%
assets/dist-*.js -122 bytes 137 bytes -47.1%
assets/dist-*.js 19 bytes 183 bytes 11.59% ⚠️
assets/dist-*.js 155 bytes 259 bytes 149.04% ⚠️
assets/dist-*.js 72 bytes 176 bytes 69.23% ⚠️
assets/dist-*.js -81 bytes 102 bytes -44.26%
assets/dist-*.js 6 bytes 183 bytes 3.39%
assets/dist-*.js 68 bytes 403 bytes 20.3% ⚠️
assets/dist-*.js -299 bytes 104 bytes -74.19%
assets/dist-*.js 2 bytes 104 bytes 1.96%
assets/dist-*.js 250 bytes 387 bytes 182.48% ⚠️
assets/dist-*.js 27 bytes 164 bytes 19.71% ⚠️
assets/edit-*.js 52 bytes 325.14kB 0.02%
assets/layout-*.js 307 bytes 198.54kB 0.15%
assets/input-*.js 46 bytes 60.48kB 0.08%
assets/scratchpad-*.js 15 bytes 8.4kB 0.18%

Files in assets/edit-*.js:

  • ./src/components/editor/notebook-cell.tsx → Total Size: 34.04kB

Files in assets/layout-*.js:

  • ./src/components/editor/renderers/vertical-layout/vertical-layout.tsx → Total Size: 17.3kB

  • ./src/components/editor/output/console/ConsoleOutput.tsx → Total Size: 14.34kB

Files in assets/scratchpad-*.js:

  • ./src/components/scratchpad/scratchpad.tsx → Total Size: 11.42kB

@Light2Dark Light2Dark enabled auto-merge (squash) May 20, 2026 01:40
Copy link
Copy Markdown
Member

@kirangadhave kirangadhave left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

@Light2Dark Light2Dark merged commit 9d7a8fe into main May 21, 2026
54 of 63 checks passed
@Light2Dark Light2Dark deleted the sham/fix-empty-input branch May 21, 2026 17:20
@github-actions
Copy link
Copy Markdown

🚀 Development release published. You may be able to view the changes at https://marimo.app?v=0.23.7-dev76

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants