Skip to content

fix: an empty REPL line no longer quits the chapter silently - #569

Open
L4XB wants to merge 1 commit into
shareAI-lab:mainfrom
L4XB:fix/repl-empty-line-does-not-quit
Open

L4XB wants to merge 1 commit into
shareAI-lab:mainfrom
L4XB:fix/repl-empty-line-does-not-quit

Conversation

@L4XB

@L4XB L4XB commented Sep 11, 2026

Copy link
Copy Markdown

Fixes #567.

Every chapter REPL treated an empty line as a quit command (in ("q", "exit", "") / {"q", "exit", ""}) and exited with status 0 without printing anything, while the banner only promises Type q to quit. As the issue describes, VS Code's Python extension often injects its environment-activation line into stdin after the program started, so under the debugger the first thing the REPL read was a blank line and the chapter vanished right after its banner.

Change (16 chapters, s01–s16; s17 already did this): an empty line is skipped and the prompt comes back; q / exit still quit; EOF / Ctrl-C still end the loop. In s13_agent_teams the payload is None case (CLI quit event) keeps breaking out, and only the empty payload is skipped.

if not query.strip():
    continue
if query.strip().lower() in ("q", "exit"):
    break

Test: tests/test_repl_quit_commands.py parses every s*/code.py and asserts that each quit check exists, that "" is not among its commands, and that the blank-input skip precedes it (s17 excluded, it already had the guard in the other order). pytest tests passes except test_goal_loop.py::test_bash_output_keeps_exit_code_when_the_tail_is_trimmed, which fails identically on main on this machine.

Every chapter REPL treated an empty line as a quit command and exited with
status 0 without a word, while the banner only promises "Type q to quit".
Under VS Code's debugger the Python extension's environment-activation line
is often injected into stdin after the program started, so the first thing
the REPL read was a blank line and the chapter vanished right after its
banner.

An empty line is now ignored and the prompt comes back; q and exit still
quit, and EOF/Ctrl-C still end the loop. s17 already behaved this way. A
static test keeps every chapter's quit check free of the empty string.

Fixes shareAI-lab#567

This branch has not been deployed

No deployments
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.

REPL 空行静默退出,与 "Type q to quit" 横幅不符,且会被 VS Code 的 stdin 注入放大

1 participant