Skip to content

feat(term): synchronized output (DEC mode 2026) via the sync-output capability - #139

Open
natemoo-re wants to merge 3 commits into
mainfrom
feat/sync-output
Open

natemoo-re wants to merge 3 commits into
mainfrom
feat/sync-output

Conversation

@natemoo-re

@natemoo-re natemoo-re commented Oct 9, 2026 •

Copy link
Copy Markdown
Member

Implements synchronized output (DEC mode 2026), previously deferred in renderer-spec §7.8.

When RuntimeCapabilities.syncOutput is true, each full-screen frame is wrapped in BSU/ESU (CSI ? 2026 h / CSI ? 2026 l) so the terminal presents it as one atomic repaint, which prevents tearing mid-frame.

… capability

Full-screen frames wrap in BSU/ESU when RuntimeCapabilities.syncOutput is
true; the flag rides reduce() per frame so a capability flip takes effect
on the next rendered frame with no invalidation signal. Zero-diff frames
emit zero bytes even when wrapped, and line mode is never wrapped.

Renderer-spec 7.9 discharges the deferral recorded in 7.8.
@bombshell-cooper

bombshell-cooper Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Changeset suggestion

The current changeset no longer matches this PR. This review contains a corrected replacement.

Why: Changeset package scope does not match the affected packages confidently. Changeset contains implementation or roadmap noise.

View the proposed changeset
---
'@bomb.sh/tty': minor
---

Adds synchronized output (DEC mode 2026) driven by the `sync-output` capability.

When `RuntimeCapabilities.syncOutput` is true, every full-screen render is wrapped in Begin/End Synchronized Update (`CSI ? 2026 h` / `CSI ? 2026 l`) so the terminal presents the frame as one atomic repaint. No-op frames emit nothing even when wrapping is active. Line-mode renders are never wrapped.

`syncOutput` is raised by three channels: the `Sync` extended capability in the parsed terminfo entry, the `TMUX` environment variable, and probe replies (DECRPM 2026 and XTGETTCAP `Sync`). Probe replies take precedence in both directions — a DECRPM 0 or 4 reply clears the capability even when detection seeded it.

#### Migration

`Capabilities` gains a new required field and `reduce` gains a new `sync` parameter.

```diff
- interface Capabilities {
+ interface Capabilities {
    readonly styledUnderline: boolean;
+   readonly syncOutput: boolean;
  }
```

```diff
- reduce(ct, buf, len, mode, row, deltaTime);
+ reduce(ct, buf, len, mode, row, deltaTime, sync);
```

Pass `0` for `sync` to preserve the previous unwrapped behaviour, or forward `RuntimeCapabilities.syncOutput ? 1 : 0` to enable wrapping.

Review this changeset manually

If this draft is correct, react with 🚀 and Cooper will commit it to this branch.

@@ -0,0 +1,7 @@
---

@bombshell-cooper bombshell-cooper Bot Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Changeset needs revision.

Changeset package scope does not match the affected packages confidently. Changeset contains implementation or roadmap noise.

View the proposed replacement
---
'@bomb.sh/tty': minor
---

Adds synchronized output (DEC mode 2026) driven by the `sync-output` capability.

When `RuntimeCapabilities.syncOutput` is true, every full-screen render is wrapped in Begin/End Synchronized Update (`CSI ? 2026 h` / `CSI ? 2026 l`) so the terminal presents the frame as one atomic repaint. No-op frames emit nothing even when wrapping is active. Line-mode renders are never wrapped.

`syncOutput` is raised by three channels: the `Sync` extended capability in the parsed terminfo entry, the `TMUX` environment variable, and probe replies (DECRPM 2026 and XTGETTCAP `Sync`). Probe replies take precedence in both directions — a DECRPM 0 or 4 reply clears the capability even when detection seeded it.

#### Migration

`Capabilities` gains a new required field and `reduce` gains a new `sync` parameter.

```diff
- interface Capabilities {
+ interface Capabilities {
    readonly styledUnderline: boolean;
+   readonly syncOutput: boolean;
  }
```

```diff
- reduce(ct, buf, len, mode, row, deltaTime);
+ reduce(ct, buf, len, mode, row, deltaTime, sync);
```

Pass `0` for `sync` to preserve the previous unwrapped behaviour, or forward `RuntimeCapabilities.syncOutput ? 1 : 0` to enable wrapping.

@github-actions

github-actions Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Size Increased — +0.6 KB

123.3 KB unpacked

@pkg-pr-new

pkg-pr-new Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@bomb.sh/tty@139

commit: 2494d02

Per the approved spec amendment (terminfo-spec §6.1/§6.3/§7.1/§7.2/§8/§9.1,
renderer-spec §7.9): syncOutput is raised only on positive evidence from
three channels.

- Probe row 8: XTGETTCAP Sync (DCS + q 53796e63) as its own request —
  some terminals honor only one capability per XTGETTCAP request, so it
  must not merge into the RGB;Tc query. A value-carrying reply confirms;
  a reply naming Sync without a value denies. Sync replies never touch
  the colordepth tally.
- Static Capabilities gains syncOutput, seeded from the Sync extended
  capability in the parsed terminfo entry and from TMUX environment
  evidence (tmux consumes mode 2026 from inner applications).
- TINV-3 precedence: probe replies outrank detect-time seeding in both
  directions; runtimeFromStatic now flows the seeded field through.

The reply's sequence value is discarded in v1: emission remains the
DEC mode 2026 form, unchanged from §7.9's normative rules.
@natemoo-re
natemoo-re marked this pull request as ready for review October 12, 2026 01:04
Comment thread term.ts
mode,
row,
dt,
currentCaps.syncOutput ? 1 : 0,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I thought we were going to move capabilities into the native state rather than copy them over on every call.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

That was indeed the direction we discussed! Oversight on my part, I'll take another pass at this.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants