Terminal canvas: concurrent send_terminal_input calls race and corrupt PTY input (intermittent binary garbage)
Nobody has claimed this yet.
- Dominant language
- No language data
- Stars
- 2.1k
- Forks
- 157
- PR merge metrics
- No merged PRs in 30d
Description
Summary
When multiple send_terminal_input actions are delivered to a Terminal canvas in rapid succession (e.g. an agent emitting them as parallel tool calls in one turn), the writes are not serialized at the PTY layer. The byte streams interleave, producing corrupted terminal input. In mild cases commands collide/jumble; in severe cases the terminal receives uninitialized/stale memory bytes as input.
Observed (severe form)
Garbage typed into the shell, e.g.:
> X?op?op??%?*bX?
X?op?op??%?*bX?: The term 'X?op?op??%?*bX?' is not recognized...
> ??op4h}0?op??? ?op@?H?op^C
? = invalid UTF-8 bytes; repeating op + control bytes look like buffer/memory garbage; trailing ^C is the shell aborting the mangled line.
Reproduction (mild form, reliable)
- Open a Terminal canvas (pwsh on macOS).
- Issue several
send_terminal_inputcalls back-to-back with no read/wait between them (e.g.echo A,echo B,echo C, then Up-arrow\u001b[A, then Enter\r). - Read output — commands are dropped/interleaved:
> echo canvas-test-1echo C
canvas-test-1echo
C
Single sends (one call, wait, read) are always clean.
Environment
- macOS, shell = PowerShell 7.6.0 (
pwsh) - GitHub Copilot desktop app, Terminal canvas
- CLI version 1.0.84-4
Expected
Concurrent/rapid send_terminal_input writes should be queued and serialized (or the write buffer locked) so input can never interleave or emit uninitialized bytes. A write should only ever contain the exact input bytes provided.
Impact
Corrupted commands run in the user's real shell; the garbage variant is alarming and can, in principle, execute unintended input.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the Terminal canvas send_terminal_input entry point and reproduce the issue with several back-to-back calls, then trace the PTY write path. Done means concurrent inputs are queued or serialized so each write contains only its provided bytes; verify the reproduction no longer interleaves commands or emits garbage.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- powershell
- Domain
- cli, desktop-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100