Skip to content

fix(terminal): chunk oversized input before backpressure - #83

Merged
wolfiesch merged 1 commit into
mainfrom
codex/current-main-terminal-proof
Jul 27, 2026
Merged

fix(terminal): chunk oversized input before backpressure#83
wolfiesch merged 1 commit into
mainfrom
codex/current-main-terminal-proof

Conversation

@wolfiesch

Copy link
Copy Markdown
Owner

What changed

  • bound terminal input writes to 4,096 characters before they cross the live PTY bridge
  • keep any unaccepted suffix ahead of later queued input
  • add a regression for an oversized first write and refresh terminal stabilization evidence

Why

A 33,000-character paste could exceed the live bridge's pending-input window before any write was accepted. The store queued the whole payload, but no write was in flight, so no later drain event existed to retry it and the terminal remained paused.

Impact

Large pastes now enter the existing ordered backpressure path in bounded chunks instead of deadlocking on the first write. Normal terminal input behavior is unchanged.

Validation

  • pnpm check
  • pnpm --filter @t4-code/web test — 87 files, 1,259 tests
  • pnpm test:tooling — 136 passed, 1 skipped
  • pnpm test:e2e — 32 passed
  • signed packaged macOS app launches and connects with the corrected renderer
  • pnpm verify:affected reached Android after all checks above; Android was environment-blocked because this machine has no JDK 21

Native drawer resize and the final 33,000-character installed-app rerun remain explicitly recorded as follow-up proof boundaries.

@wolfiesch
wolfiesch merged commit 8a096d5 into main Jul 27, 2026
15 checks passed
@wolfiesch
wolfiesch deleted the codex/current-main-terminal-proof branch July 27, 2026 03:00

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 36b13a5f54

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

function writeAvailable(pty: PtySession, data: string): string {
let offset = 0;
while (offset < data.length) {
const chunk = data.slice(offset, offset + MAX_TERMINAL_INPUT_WRITE_CHARS);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Avoid splitting surrogate pairs across terminal writes

When a large paste places an astral character such as an emoji across a 4,096-code-unit boundary, slice sends its high and low surrogates in separate terminal.input frames. The host converts each frame independently with Buffer.from(data, "utf8") in packages/host-service/src/operations/pty.ts, so both halves become replacement characters and the pasted command or data is corrupted. Adjust the boundary to preserve surrogate pairs or chunk the encoded bytes instead.

Useful? React with 👍 / 👎.

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