feat(vercel/sandbox): fix interactive shell#236
Merged
Conversation
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
LukeSheard
approved these changes
Jun 30, 2026
AndyW22
reviewed
Jun 30, 2026
Co-authored-by: Andy <76787794+AndyW22@users.noreply.github.com>
AndyW22
approved these changes
Jun 30, 2026
…t readline non-printing markers, so bash overcounts the prompt width and miscalculates cursor position on long/wrapping lines and during line editing. This commit fixes the issue reported at packages/sandbox/src/interactive-shell/interactive-shell.ts:25 ## Bug In `packages/sandbox/src/interactive-shell/interactive-shell.ts` the prompt was changed to: ```ts const PS1 = `▲ \x1b[2m$PWD/\x1b[0m `; ``` This is sent verbatim as the `PS1` env var to the interactive session's shell. The color escape sequences `\x1b[2m` (dim) and `\x1b[0m` (reset) are invisible but occupy ~4 bytes each on the wire. Bash's readline counts **every** character in `PS1` toward the displayed prompt width *unless* it is wrapped in the non-printing markers `[ ... ]` (which bash decodes into the raw readline bytes `\001` = `RL_PROMPT_START_IGNORE` and `\002` = `RL_PROMPT_END_IGNORE`). The previous prompt correctly used those markers: `▲ [\e[2m]\w/[\e[0m]` . The new one dropped them. ### Failure mode / trigger When the customer image's `/bin/sh` is **bash** (very common), readline now believes the prompt is ~8 columns wider than it actually is. Concrete symptoms: * Typing a command line long enough to wrap past `$COLUMNS` causes the cursor to land on the wrong column / row. * Pressing Up/Down through history, or editing (Ctrl-A, arrow keys) on a wrapped line, redraws at the wrong position, leaving visual garbage. It is reproducible whenever the typed line length approaches the terminal width. Severity is cosmetic (no data loss), but it is a real, deterministic regression for bash sessions. ### Why the PR removed the markers The intent was portability: `[`, `]`, `\e`, `\w` are bash-specific and are printed literally by dash/busybox-ash, so the old prompt rendered raw escape text under those shells. Using literal ESC bytes + `$PWD` fixes that for non-bash shells. ## Fix Wrap the escape sequences in the **raw** readline ignore bytes `\x01`/`\x02` rather than the bash-only `[`/`]` text macros: ```ts const PS1 = `▲ \x01\x1b[2m\x02$PWD/\x01\x1b[0m\x02 `; ``` * **bash**: `\x01`/`\x02` *are* `RL_PROMPT_START_IGNORE`/`RL_PROMPT_END_IGNORE` — exactly the bytes that `[`/`]` decode to — so readline correctly excludes the escapes from prompt-width tracking. Width math is restored. * **dash / busybox-ash / zsh**: these are C0 control characters (SOH/STX) that terminal emulators render as non-printing, so the visible prompt is unchanged and `$PWD` + color still render. This keeps the cross-shell portability the PR was aiming for. This achieves both goals with a single PS1 string, so the limitation noted in the issue (no string works across bash and dash) turns out to be avoidable using the raw readline markers instead of the bash-specific text form. Co-authored-by: Vercel <vercel[bot]@users.noreply.github.com> Co-authored-by: marc-vercel <marc.codina@vercel.com>
Merged
marc-vercel
pushed a commit
that referenced
this pull request
Jun 30, 2026
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. # Releases ## sandbox@3.3.1 ### Patch Changes - Fix the interactive shell prompt so that it is built from POSIX-portable primitives — it renders correctly regardless of which POSIX compatible shell (`bash`, `dash`, busybox `ash`) a custom image ships as `/bin/sh`. ([#236](#236)) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.
Fix interactive shell, so that we render the Vercel icon correctly between different shells.
Before, with a custom image:
Now: