Skip to content

fix(tui): prevent split Alt+Enter from interrupting - #7899

Merged
badlogic merged 3 commits into
earendil-works:mainfrom
powerfooI:fix/stdin-buffer-esc-timeout
Aug 11, 2026
Merged

badlogic merged 3 commits into
earendil-works:mainfrom
powerfooI:fix/stdin-buffer-esc-timeout

Conversation

@powerfooI

Copy link
Copy Markdown
Contributor

Problem

Without the Kitty keyboard protocol, Alt+Enter arrives as ESC + CR. If stdin delivers the bytes more than 10ms apart, StdinBuffer flushes the lone ESC, which coding-agent handles as app.interrupt, aborting the active turn.

Change

  • Use a 100ms escape-sequence timeout when SSH_CONNECTION or SSH_TTY is present.
  • Support a PI_TUI_ESC_TIMEOUT override for other high-latency terminal paths.
  • Keep the existing 10ms default outside SSH, preserving local Escape responsiveness.
  • Add regression coverage for split ESC + CR, key parsing, timeout selection, and Kitty negotiation timing.

This adds at most 90ms to bare Escape dispatch over SSH while avoiding destructive Alt+Enter misclassification.

Validation

  • npm run check
  • PATH="$HOME/.bun/bin:$PATH" ./test.sh
  • node --test test/stdin-buffer.test.ts test/terminal.test.ts

Fixes #7876

Increase the escape-sequence timeout over SSH and allow high-latency terminals to override it with PI_TUI_ESC_TIMEOUT.

Fixes earendil-works#7876
@badlogic
badlogic merged commit 06ed871 into earendil-works:main Aug 11, 2026
@badlogic

Copy link
Copy Markdown
Collaborator

cheers!

@powerfooI

Copy link
Copy Markdown
Contributor Author

Thanks for the review and merge! Looking forward to the next release — I've been saying a little prayer every time I queue a follow-up message over the poor SSH connection. 😭

@powerfooI
powerfooI deleted the fix/stdin-buffer-esc-timeout branch August 11, 2026 12:47
dadezzz pushed a commit to dadezzz/forgejo-agent that referenced this pull request Aug 19, 2026
….2 (#213)

This PR contains the following updates:

| Package | Change | [Age](https://docs.renovatebot.com/merge-confidence/) | [Confidence](https://docs.renovatebot.com/merge-confidence/) |
|---|---|---|---|
| [@earendil-works/pi-coding-agent](https://github.com/earendil-works/pi) ([source](https://github.com/earendil-works/pi/tree/HEAD/packages/coding-agent)) | [`0.84.1` → `0.84.2`](https://renovatebot.com/diffs/npm/@earendil-works%2fpi-coding-agent/0.84.1/0.84.2) | ![age](https://developer.mend.io/api/mc/badges/age/npm/@earendil-works%2fpi-coding-agent/0.84.2?slim=true) | ![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@earendil-works%2fpi-coding-agent/0.84.1/0.84.2?slim=true) |

---

### Release Notes

<details>
<summary>earendil-works/pi (@&#8203;earendil-works/pi-coding-agent)</summary>

### [`v0.84.2`](https://github.com/earendil-works/pi/blob/HEAD/packages/coding-agent/CHANGELOG.md#0842---2026-08-14)

[Compare Source](earendil-works/pi@v0.84.1...v0.84.2)

##### New Features

- **Fullscreen transcript search** — Search and navigate matches in fullscreen mode. See [TUI Fullscreen Viewport](docs/keybindings.md#tui-fullscreen-viewport).
- **Configurable default tools** — Choose startup built-in tools globally or per project. See [Tools](docs/settings.md#tools).
- **Configurable fullscreen exit output** — Print the transcript or only a resume hint on exit. See [Interactive Mode](docs/usage.md#interactive-mode).

##### Added

- Added fullscreen transcript search with `Ctrl+Shift+F`, incremental match highlighting, configurable search match theme colors, and next/previous navigation with `Enter`/`Ctrl+G` and `Shift+Enter`/`Ctrl+Shift+G`.
- Added experimental strict JSON-schema constrained sampling for the default `read`, `bash`, `edit`, and `write` tools under `PI_EXPERIMENTAL=1`.
- Added a fullscreen exit output setting to choose between printing the final transcript and only a session resume hint.
- Added the `defaultTools` setting for configuring the initial built-in tool selection globally or per project.
- Added `--use-theme <name[/name]>` to choose an initial per-run interactive theme without changing saved settings ([#&#8203;7722](earendil-works/pi#7722) by [@&#8203;rwachtler](https://github.com/rwachtler)).
- Added `expandPromptTemplates` to extension `pi.sendUserMessage()` options for explicitly dispatching commands and expanding skills and prompt templates. See [`pi.sendUserMessage()`](docs/extensions.md#pisendusermessagecontent-options) ([#&#8203;7857](earendil-works/pi#7857) by [@&#8203;mrexodia](https://github.com/mrexodia)).
- Added inherited `createGatewayBindingFetch()` for routing Cloudflare AI Gateway requests through a Workers AI binding without an API token ([#&#8203;7901](earendil-works/pi#7901) by [@&#8203;Maximo-Guk](https://github.com/Maximo-Guk)).
- Added inherited `AssistantMessage.endTurn` to preserve OpenAI Codex's terminal `end_turn` signal for diagnostics ([#&#8203;7766](earendil-works/pi#7766)).
- Added inherited unbound single-line transcript scrolling actions for fullscreen mode. See [TUI Fullscreen Viewport](docs/keybindings.md#tui-fullscreen-viewport) ([#&#8203;7903](earendil-works/pi#7903) by [@&#8203;midastruth](https://github.com/midastruth)).

##### Changed

- Changed inherited Kimi Coding requests to use pi's runtime `User-Agent` header.
- Replaced the inherited Mistral SDK transport with a native Chat Completions HTTP stream, eliminating its generated client and schema runtime overhead.
- Documented the generic `AI_AGENT=pi` process marker and how it differs from `PI_CODING_AGENT=true` ([#&#8203;7747](earendil-works/pi#7747)).
- Changed inherited OpenAI Responses deferred tool loading to prefer message-anchored `additional_tools` where supported while retaining tool-search and top-level fallbacks ([#&#8203;7709](earendil-works/pi#7709)).
- Reduced inherited fullscreen rendering allocation churn by painting full-width layout rows directly instead of recompositing them on every frame.

##### Fixed

- Fixed root Markdown files such as `README.md` and `AGENTS.md` in skill directories being reported as broken skills unless they declare valid skill frontmatter ([#&#8203;7805](earendil-works/pi#7805)).
- Fixed single-object `edit` tool inputs failing validation by accepting them as one-edit arrays in both coding-agent and harness edit tools ([#&#8203;7835](earendil-works/pi#7835)).
- Fixed managed-tool downloads delaying TUI startup and hiding diagnostics in fullscreen mode by mounting the TUI first and showing download progress and warnings inside it.
- Fixed opening a model selector immediately after startup cancelling and restarting the in-progress model catalog refresh.
- Fixed inherited GitHub Copilot login triggering API rate limits while enabling model policies by limiting concurrent policy updates ([#&#8203;6187](earendil-works/pi#6187)).
- Fixed fullscreen transcript search snapping back to the current match during manual scrolling and fragmented mouse input leaking into the search query.
- Fixed inherited required LaTeX arguments starting on a new line being parsed as empty ([#&#8203;7760](earendil-works/pi#7760)).
- Updated the transitive `nanoid` development dependency to address a denial-of-service vulnerability.
- Fixed fallback rendering for extension tool results to collapse long output and honor tool expansion ([#&#8203;7979](earendil-works/pi#7979)).
- Fixed JSON and RPC `message_update` events dropping cumulative usage during streaming. See [JSON Event Mode](docs/json.md) and [RPC `message_update`](docs/rpc.md#message_update-streaming) ([#&#8203;7982](earendil-works/pi#7982) by [@&#8203;christianklotz](https://github.com/christianklotz)).
- Fixed `pi.sendMessage(..., { triggerTurn: false })` steering an active run instead of only recording the custom message ([#&#8203;8022](earendil-works/pi#8022) by [@&#8203;cristinaponcela](https://github.com/cristinaponcela)).
- Fixed the `defaultTools` setting dropping extension and SDK custom tools when selecting built-in defaults.
- Fixed the subagent example rejecting YAML array syntax for the `tools` frontmatter field ([#&#8203;7598](earendil-works/pi#7598) by [@&#8203;alexsavio](https://github.com/alexsavio)).
- Fixed the subagent example dropping parent session model, thinking, and tool configuration ([#&#8203;7897](earendil-works/pi#7897) by [@&#8203;virtuald](https://github.com/virtuald)).
- Fixed custom system prompts concatenating the current working directory with later appended prompt content ([#&#8203;7887](earendil-works/pi#7887) by [@&#8203;distributedlock](https://github.com/distributedlock)).
- Fixed inherited OpenAI Responses function and custom tool calls losing namespaces during streaming, proxying, and replay ([#&#8203;7709](earendil-works/pi#7709)).
- Fixed inherited upstream request buffer failures not triggering automatic assistant retries.
- Fixed inherited built-in and custom DeepSeek API models sending output limits through an unsupported field.
- Fixed inherited Amazon Bedrock replay rejecting tool arguments that contain empty object keys while preserving all valid nested values ([#&#8203;7882](earendil-works/pi#7882) by [@&#8203;muyiyr](https://github.com/muyiyr)).
- Fixed inherited DeepSeek compatibility detection for base URLs whose hostname contains uppercase letters ([#&#8203;7933](earendil-works/pi#7933) by [@&#8203;yearth](https://github.com/yearth)).
- Fixed inherited Google Generative AI and Vertex AI responses with tool calls incorrectly treating output-limit or provider-error stops as normal tool use ([#&#8203;8059](earendil-works/pi#8059)).
- Fixed inherited fullscreen mouse drag selection and OSC 8 link activation in terminals that report generic SGR mouse release button codes ([#&#8203;7963](earendil-works/pi#7963)).
- Fixed inherited focused fullscreen overlays not receiving mouse wheel or viewport scroll keys such as PageUp and PageDown ([#&#8203;7894](earendil-works/pi#7894)).
- Fixed inherited LaTeX control spaces split across line endings causing complete expressions to fall back to raw source.
- Fixed split `Alt+Enter` input over SSH being misread as Escape, added `PI_TUI_ESC_TIMEOUT` for high-latency terminals, and limited that timeout to lone Escape input ([#&#8203;7899](earendil-works/pi#7899) by [@&#8203;powerfooI](https://github.com/powerfooI)).
- Fixed inherited idle fullscreen sessions repainting and clearing text selection when the terminal loses focus ([#&#8203;7892](earendil-works/pi#7892) by [@&#8203;terrorobe](https://github.com/terrorobe)).
- Fixed fullscreen selection copy to use the host clipboard and report failure instead of claiming success when OSC 52 is unsupported ([#&#8203;8110](earendil-works/pi#8110) by [@&#8203;Panoplos](https://github.com/Panoplos)).

</details>

---

### Configuration

📅 **Schedule**: (UTC)

- Branch creation
  - At any time (no schedule defined)
- Automerge
  - At any time (no schedule defined)

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Mend Renovate CLI](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0NC4zMS4wIiwidXBkYXRlZEluVmVyIjoiNDQuMzEuMCIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOltdfQ==-->
eleboucher pushed a commit to eleboucher/memini that referenced this pull request Aug 28, 2026
This PR contains the following updates:

| Package | Change | [Age](https://docs.renovatebot.com/merge-confidence/) | [Confidence](https://docs.renovatebot.com/merge-confidence/) |
|---|---|---|---|
| [@earendil-works/pi-tui](https://github.com/earendil-works/pi) ([source](https://github.com/earendil-works/pi/tree/HEAD/packages/tui)) | [`0.84.1` → `0.84.3`](https://renovatebot.com/diffs/npm/@earendil-works%2fpi-tui/0.84.1/0.84.3) | ![age](https://developer.mend.io/api/mc/badges/age/npm/@earendil-works%2fpi-tui/0.84.3?slim=true) | ![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@earendil-works%2fpi-tui/0.84.1/0.84.3?slim=true) |

---

> ⚠️ **Warning**
>
> Some dependencies could not be looked up. Check the [Dependency Dashboard](issues/3) for more information.

---

### Release Notes

<details>
<summary>earendil-works/pi (@&#8203;earendil-works/pi-tui)</summary>

### [`v0.84.3`](https://github.com/earendil-works/pi/blob/HEAD/packages/tui/CHANGELOG.md#0843---2026-08-24)

[Compare Source](earendil-works/pi@v0.84.2...v0.84.3)

##### Fixed

- Fixed duplicate fullscreen right-click paste in VS Code-based terminals on Windows ([#&#8203;8186](earendil-works/pi#8186)).
- Fixed padded text exceeding narrow terminal widths ([#&#8203;8252](earendil-works/pi#8252)).
- Fixed wrapped Markdown table links leaking color into borders and neighboring cells, including tables inside blockquotes ([#&#8203;8335](earendil-works/pi#8335)).

### [`v0.84.2`](https://github.com/earendil-works/pi/blob/HEAD/packages/tui/CHANGELOG.md#0842---2026-08-14)

[Compare Source](earendil-works/pi@v0.84.1...v0.84.2)

##### Added

- Added unbound single-line transcript scrolling actions, `tui.altScreen.lineUp` and `tui.altScreen.lineDown`, for fullscreen TUI keybindings ([#&#8203;7903](earendil-works/pi#7903) by [@&#8203;midastruth](https://github.com/midastruth)).
- Added incremental primary-scroll-view search to the fullscreen TUI with configurable match styles, `Ctrl+Shift+F`, and next/previous navigation with `Enter`/`Ctrl+G` and `Shift+Enter`/`Ctrl+Shift+G`.

##### Changed

- Reduced alternate-screen per-frame allocation churn roughly 9-18x by painting full-width layout rows as direct line references instead of recompositing every visible row through ANSI/grapheme segmentation on each frame.

##### Fixed

- Fixed fullscreen mouse drag selection and OSC 8 link activation in terminals that report generic SGR mouse release button codes ([#&#8203;7963](earendil-works/pi#7963)).
- Fixed fullscreen transcript search snapping back to the current match during manual scrolling and fragmented SGR mouse input leaking into the search query.
- Fixed required LaTeX arguments starting on a new line being parsed as empty ([#&#8203;7760](earendil-works/pi#7760)).
- Fixed LaTeX control spaces split across line endings causing complete expressions to fall back to raw source.
- Fixed focused fullscreen overlays not receiving mouse wheel or viewport scroll keys such as PageUp and PageDown ([#&#8203;7894](earendil-works/pi#7894)).
- Fixed split `Alt+Enter` input over SSH being misread as Escape, added `PI_TUI_ESC_TIMEOUT` for high-latency terminals, and limited that timeout to lone Escape input ([#&#8203;7899](earendil-works/pi#7899) by [@&#8203;powerfooI](https://github.com/powerfooI)).
- Fixed idle fullscreen sessions repainting and clearing text selection when the terminal loses focus ([#&#8203;7892](earendil-works/pi#7892) by [@&#8203;terrorobe](https://github.com/terrorobe)).
- Fixed fullscreen selection copy falsely reporting success when OSC 52 is unsupported by allowing host clipboard integration and reporting verified failures ([#&#8203;8110](earendil-works/pi#8110) by [@&#8203;Panoplos](https://github.com/Panoplos)).

</details>

---

### Configuration

📅 **Schedule**: (UTC)

- Branch creation
  - Between 12:00 AM and 03:59 AM, only on Monday (`* 0-3 * * 1`)
- Automerge
  - At any time (no schedule defined)

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Mend Renovate CLI](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0NC4zMS4wIiwidXBkYXRlZEluVmVyIjoiNDQuMzkuMyIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiZGVwZW5kZW5jaWVzIl19-->

Reviewed-on: https://git.erwanleboucher.dev/eleboucher/memini/pulls/212
jinhuang712 pushed a commit to jinhuang712/pi that referenced this pull request Sep 11, 2026
)

* fix(tui): prevent split Alt+Enter from interrupting

Increase the escape-sequence timeout over SSH and allow high-latency terminals to override it with PI_TUI_ESC_TIMEOUT.

Fixes earendil-works#7876

* docs(coding-agent): shorten escape timeout description

---------

Co-authored-by: Mario Zechner <badlogicgames@gmail.com>
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.

Alt+Enter (queue follow-up) intermittently aborts the running task — 10ms StdinBuffer ESC timeout splits ESC+CR

2 participants