Skip to content

fix(terminal): render completed synchronized frames immediately - #2521

Closed
binaricat wants to merge 6 commits into
mainfrom
codex/xterm-sync-render
Closed

fix(terminal): render completed synchronized frames immediately#2521
binaricat wants to merge 6 commits into
mainfrom
codex/xterm-sync-render

Conversation

@binaricat

@binaricat binaricat commented Jul 27, 2026

Copy link
Copy Markdown
Owner

Summary

Render each completed DEC 2026 synchronized-output frame immediately, so continuous terminal animations do not stall at roughly one frame per second.

This is the narrow xterm-side fix extracted from #2489. It deliberately excludes frame dropping, flow-control changes, write watchdogs, and terminal settings. The original implementation commit keeps @s-celles as author.

The fix covers both xterm builds used by development and production. It only forces an immediate refresh when synchronized output actually changes from open to closed; redundant close commands retain xterm's normal batched refresh behavior.

Type of Change

  • Bug fix
  • New feature
  • Refactor / code cleanup
  • Documentation update
  • Build / CI change
  • Other (please describe):

Related Issue (optional)

Related to #2467 and #2489. Inspired by xtermjs/xterm.js#6073, with additional handling for complete frames delivered in one input chunk.

Changes Made

  • Apply the synchronized-render fix during postinstall to both xterm builds.
  • Validate the exact dependency version and complete surrounding code before changing either build.
  • Fail the install without partial changes when the expected dependency shape is missing, mixed, or ambiguous.
  • Clear Vite's cached xterm prebundle after installation so development uses the patched dependency.
  • Run a real Electron/xterm regression in CI with split input, combined input, and redundant close commands.

Screenshots / Demo

With pristine xterm, both CJS and ESM builds report zero renders before the next synchronized frame closes in all three input layouts. With this fix, both builds report one immediate render in all three layouts. One hundred redundant close commands still produce zero immediate renders and one normal batched render.

Testing

  • Real Electron regression passes for CJS and ESM (npm run test:xterm-sync-render)
  • The same regression confirms pristine xterm fails all six positive cases
  • Patch install, repeat install, migration, upstream-present, mixed, ambiguous, and wrong-version cases pass
  • Vite cache removal verified with a populated cache directory
  • Linting passes (npm run lint)
  • Full test baseline: 7,424 passed; 4 failures and 1 unfinished test reproduce unchanged on clean origin/main (SSH auth retry and SFTP resume baseline)
  • Production build passes (npm run build)

Checklist

  • My code follows the existing project style
  • I have added focused regression coverage
  • I have not introduced any breaking changes

s-celles and others added 2 commits July 27, 2026 11:44
Adds scripts/patch-xterm-sync-render.cjs (run from postinstall, after the
existing webgl atlas patch) to render a synchronized-output frame the
moment it closes instead of on the next debounced tick.

xterm buffers rows while DEC 2026 synchronized output is on and, on
close, schedules the paint through the render debouncer. Under a
continuous full-screen animation the next frame opens a new 2026 block
before that rAF fires, and `_renderRows` skips while sync is on, so the
paint is dropped and the frame only appears on the 1000ms sync timeout —
pinning the display at ~1fps. The patch renders synchronously when a sync
buffer was just flushed, so a completed frame paints before the next can
reopen the mode. Measured against a 30fps animated-background TUI: ~1fps
to the frame arrival rate, coherent (no partial-frame tearing).

Idempotent and marker-guarded, like patch-xterm-webgl-atlas.cjs; a
version bump that moves the minified target fails the install rather than
silently losing the fix. Upstreamable to xterm.js.

Assisted by AI.
@binaricat binaricat added the automation:codex-loop Own/bot PR waiting on Codex review↔fix loop label Jul 27, 2026
@binaricat
binaricat marked this pull request as draft July 27, 2026 04:01
@binaricat

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: 752f80ba37

ℹ️ 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".

@netcatty-bot
netcatty-bot marked this pull request as ready for review July 27, 2026 04:03
@netcatty-bot netcatty-bot added automation:bot-pr PR created or owned by Cursor automation automation:codex-clean Last Codex review reported clean and removed automation:codex-loop Own/bot PR waiting on Codex review↔fix loop labels Jul 27, 2026
@netcatty-bot

Copy link
Copy Markdown
Collaborator

Codex reported no major issues. This PR is marked ready for human review/merge.

@binaricat binaricat added automation:codex-loop Own/bot PR waiting on Codex review↔fix loop and removed automation:codex-clean Last Codex review reported clean labels Jul 27, 2026
@binaricat

Copy link
Copy Markdown
Owner Author

@codex review

@binaricat
binaricat marked this pull request as draft July 27, 2026 04:11
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

Reviewed commit: 55ef19d483

ℹ️ 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".

@netcatty-bot
netcatty-bot marked this pull request as ready for review July 27, 2026 04:14
@netcatty-bot netcatty-bot added automation:codex-clean Last Codex review reported clean and removed automation:codex-loop Own/bot PR waiting on Codex review↔fix loop labels Jul 27, 2026
@netcatty-bot

Copy link
Copy Markdown
Collaborator

Codex reported no major issues. This PR is marked ready for human review/merge.

1 similar comment
@netcatty-bot

Copy link
Copy Markdown
Collaborator

Codex reported no major issues. This PR is marked ready for human review/merge.

@binaricat binaricat added automation:codex-loop Own/bot PR waiting on Codex review↔fix loop and removed automation:codex-clean Last Codex review reported clean labels Jul 27, 2026
@binaricat

Copy link
Copy Markdown
Owner Author

@codex review

@binaricat
binaricat marked this pull request as draft July 27, 2026 04:21

@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: a6bdae1ca7

ℹ️ 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".

Comment thread package.json Outdated
@netcatty-bot

Copy link
Copy Markdown
Collaborator

Automatic Codex fix did not finish cleanly (agent, protected paths, or verification failed). Marking for human review.

@netcatty-bot netcatty-bot removed the automation:codex-loop Own/bot PR waiting on Codex review↔fix loop label Jul 27, 2026
@netcatty-bot netcatty-bot added the ready-for-human Requires human implementation label Jul 27, 2026
@binaricat binaricat added the automation:codex-loop Own/bot PR waiting on Codex review↔fix loop label Jul 27, 2026
@binaricat

Copy link
Copy Markdown
Owner Author

@codex review

@binaricat

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Can't wait for the next one!

Reviewed commit: 1d0b7904bd

ℹ️ 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".

@netcatty-bot
netcatty-bot marked this pull request as ready for review July 27, 2026 04:34
@netcatty-bot netcatty-bot added automation:codex-clean Last Codex review reported clean and removed automation:codex-loop Own/bot PR waiting on Codex review↔fix loop ready-for-human Requires human implementation labels Jul 27, 2026
@netcatty-bot

Copy link
Copy Markdown
Collaborator

Codex reported no major issues. This PR is marked ready for human review/merge.

1 similar comment
@netcatty-bot

Copy link
Copy Markdown
Collaborator

Codex reported no major issues. This PR is marked ready for human review/merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automation:bot-pr PR created or owned by Cursor automation automation:codex-clean Last Codex review reported clean

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants