Skip to content

fix(website): route trailing bytes to a program launched mid-chunk in tutorial shell#245

Open
dormouse-bot wants to merge 1 commit into
mainfrom
fix/tutorial-shell-midchunk-program
Open

fix(website): route trailing bytes to a program launched mid-chunk in tutorial shell#245
dormouse-bot wants to merge 1 commit into
mainfrom
fix/tutorial-shell-midchunk-program

Conversation

@dormouse-bot

Copy link
Copy Markdown
Collaborator

Surfaced by the nightly code-quality survey.

TutorialShell.handleInput checks this.activeProgram only once, at the top of the method. Inside the per-character loop, when a \r/\n triggers processCommand and that launches an interactive program, the loop keeps going and treats the rest of the chunk as shell line-editor input.

When input arrives one keystroke per chunk (normal typing) this never bites, because the \r is the last byte. But a single chunk that carries both the command and its first keystroke — e.g. a paste of ascii-splash\rq — mis-routes the q into the shell's lineBuffer instead of forwarding it to the just-started program. The existing tests split these across two handleInput calls, so the case was uncovered.

The fix forwards any bytes remaining after a mid-chunk program launch to that program and stops parsing the chunk.

The added regression test (forwards trailing bytes to a program launched within the same chunk) fails before the fix (program.handleInput called 0 times) and passes after.

… tutorial shell

TutorialShell.handleInput only checked activeProgram at the top of the
method, so when a single input chunk both launched an interactive program
(via a trailing \r) and carried the program's first keystroke — as a paste
of "cmd\rinput" would — the leftover bytes were parsed as shell line-editor
input instead of being forwarded to the just-started program.

Forward any bytes remaining after a program launch to that program and stop
parsing the chunk. Adds a regression test that fails without the fix.
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying mouseterm with  Cloudflare Pages  Cloudflare Pages

Latest commit: 3c0f562
Status: ✅  Deploy successful!
Preview URL: https://5ada2456.mouseterm.pages.dev
Branch Preview URL: https://fix-tutorial-shell-midchunk.mouseterm.pages.dev

View logs

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