Pasted command gets a stray 1R prefix after returning to a terminal
iamnbutler opened ·
While preparing a canary release in Ace, an existing terminal prefixed a pasted command with stray characters. The command failed until the prompt was cleared.
### Observed sequence
1. Switch from another channel to `keen-orbit`. 2. Select its existing `term` tab. 3. Paste and run: ```sh sh /tmp/ace-canary-preflight.sh > /tmp/ace-canary-preflight.log 2>&1 ``` 4. The redirected log reports `zsh: command not found: 1Rsh`. 5. Clear the prompt with Ctrl+U, then paste and run the same command again. It succeeds.
This was observed once during dogfooding. The exact incoming/outgoing terminal bytes were not captured, and the successful retry replaced the redirected log. The failure is observed; the explanation below is not confirmed.
### Suspected replay interaction
- [Host terminal output](https://github.com/githubnext/ace2/blob/ce1bd9bde77955b15521a5cbeee1236bdc14fa13/apps/host/src/terminals.ts#L85) is retained as raw PTY chunks. [Reattachment](https://github.com/githubnext/ace2/blob/ce1bd9bde77955b15521a5cbeee1236bdc14fa13/apps/host/src/terminals.ts#L62) replays those chunks without identifying a replay boundary. - The [client input listener](https://github.com/githubnext/ace2/blob/ce1bd9bde77955b15521a5cbeee1236bdc14fa13/apps/app/src/panels/terminal.tsx#L165) forwards every xterm `onData` event to the live PTY. During [reattachment](https://github.com/githubnext/ace2/blob/ce1bd9bde77955b15521a5cbeee1236bdc14fa13/apps/app/src/panels/terminal.tsx#L223), that listener is active while the client resets xterm and writes replayed output. - Installed xterm source (`src/common/InputHandler.ts:2653` and `src/common/services/CoreService.ts:61`) answers a cursor-position query (`CSI 6 n`) with `CSI row;column R` through the same `onData` event. Replaying an old query could therefore send an unsolicited response into the current shell prompt. The `1R` suffix is consistent with that possibility, but does not prove it.
Normal tab selection keeps panels mounted; returning to a channel and first viewing its restored terminal can reattach it. Reconnection also reattaches. Do not assume every tab switch triggers replay.
### Expected
- Returning to an existing terminal must leave the live shell input unchanged; the first pasted command must run exactly as entered. - Investigate raw-output replay and generated terminal responses. Preserve responses to live queries while preventing historical output from generating new shell input. - Verify channel navigation, reload/reconnect, normal typing and pasting, and live terminal queries with a real shell.
No matching open or closed issue was found in the repository. Related terminal issues #11 and #18 cover different work. Tracked by #5.
iamnbutlerparent-issue-addedlast month on GitHub
iamnbutlerreferenced this in Embed native desktop inspection in Ace #47last month on GitHub
iamnbutlerreferenced this in [Meta] Dogfood Ace end to end #5last month on GitHub
iamnbutlerreferenced this in fix(host): keep replayed terminal queries out of the shell's input #60last month on GitHub