Skip to content

terminal: adopt embedded runtime 1.4 improvements - #224

Merged
khoi merged 16 commits into
mainfrom
t3code/review-ghostty-upstream-improvements
Sep 1, 2026
Merged

terminal: adopt embedded runtime 1.4 improvements#224
khoi merged 16 commits into
mainfrom
t3code/review-ghostty-upstream-improvements

Conversation

@khoi

@khoi khoi commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Why

Our embedded terminal fork had fallen behind the 1.4 core and its reference macOS host. The gap included scrollback compression, hidden-surface GPU release, idle renderer parking, binary multi-format clipboard support, committed-text handling, keyboard-layout refresh, and smaller correctness and allocation fixes.

Updating the core alone would leave Supaterm on old callback contracts and keep renderer resources alive for panes hidden by its own spaces, tabs, splits, restoration, and screenshot paths. This syncs the fork and host so the app layer follows actual pane visibility and the new protocol behavior.

What changed

The fork now places six Supaterm commits directly above the current upstream head, with no merge commits. Supaterm adopts the matching macOS host behavior across these cases:

  • Hidden panes release renderer resources across windows, spaces, tabs, and splits; restored panes become hidden as soon as each surface exists, and screenshot capture restores prior occlusion.
  • Clipboard reads and writes preserve binary multi-MIME data, enforce protocol limits and approval rules, share aliased payload storage, and publish pasteboard representations on demand.
  • Committed text, dropped text, physical shortcuts, live keyboard-layout changes, working-directory normalization, and shortcut-conflict refresh follow the current host contracts.
  • The updater dependency, permission copy, security guide, and earlier release wording now match the shipped behavior.

Note

This does not copy standalone-app window, tab, toolbar, or settings UI that Supaterm replaces with spaces, tabs, panes, and its own chrome.

Memory measurement

Two isolated arm64 Release builds used the same saved 1228×768 window frame, five idle login-shell tabs, and five footprint samples after each workload settled. Values are the stable median and are rounded by footprint.

Workload origin/main This branch Change
Visible, no added history 158 MB 160 MB +2 MB
Minimized, no added history 105 MB 59 MB -46 MB (-44%)
Visible after 120,000 repeated 65-byte lines 162 MB 164 MB +2 MB
Minimized after the same history 163 MB 117 MB -46 MB (-28%)

The minimized branch build releases its 45 MB IOSurface allocation to 128 KB. The old fork already had scrollback compression, which is why both visible builds add only 4 MB for the scrollback workload. This update preserves that win and adds the app-layer occlusion path needed to release GPU resources.

Verification

Regression coverage checks shared clipboard payload ownership, lazy pasteboard delivery, binary MIME selection, callback validation and off-main delivery, permission grants, hidden-surface transitions, restoration order, capture cleanup, keyboard-layout changes, shortcut refresh, and canonical working directories.

The fork's core build, full Zig test suite, and reference macOS unit tests pass. The full Supaterm macOS unit suite passes, including the new clipboard bridge tests and the existing occlusion, clipboard, input, shortcut, and working-directory suites. Swift formatting, SwiftLint, and diff checks pass. Computer Use verified a live Metal-backed window restoring after its minimized renderer resources were released.

khoi added 10 commits August 31, 2026 10:08
Read exact and mapped MIME representations before falling back to native
pasteboard synthesis while preserving complete multi-file URI lists.

Keep the reference macOS host on the same callback contract and document
the read and write approval model.
Use the active input source for IME mode changes and refresh shortcut
collision data whenever the selected keyboard layout changes.
Standardize service URLs before shared separator normalization so equivalent
dotted paths deduplicate while terminal and agent paths keep one spelling.
Clipboard protocols can expose many MIME names for one payload. Owning the
borrowed bytes and publishing pasteboard data once per alias made memory
scale with the alias count.

Share each unique payload across its aliases and defer pasteboard data
requests until a consumer asks for a representation.
Restoring many hidden panes kept each surface's renderer resources alive
until the full layout finished, and screenshot capture could leave a
hidden surface visible to the renderer after forcing a draw.

Apply hidden state as each restored surface is created and restore it
after hidden captures so renderer memory follows actual visibility.
The permission copy implied that writes prompt by default and that a
denied request could be remembered. Neither matches the terminal policy.

State the defaults exactly and name the optional session approval as an
allow-only choice.
Terminal configuration can change while Settings remains open. Refresh
reserved terminal bindings when the Shortcuts tab becomes active so its
conflict state reflects the current configuration.
@tuist

tuist Bot commented Aug 31, 2026

Copy link
Copy Markdown

🛠️ Tuist Run Report 🛠️

Tests 🧪

Scheme Status Cache hit rate Tests Skipped Ran Commit
supatermUITests 0 % 73 0 73 becdc726d

Builds 🔨

Scheme Status Duration Commit
supatermUITests 2m 12s becdc726d

khoi added 6 commits August 31, 2026 17:00
Clipboard writes could retain stale pasteboard items, while aliased data
crossed the C boundary through pointer identity. Replace pasteboard contents
and preserve explicit payload IDs instead.

Hidden pane captures also changed logical terminal visibility while restoring
renderer resources. Use a renderer-only transition and centralize pane
activity updates around tree and focus state changes.

Split callback, pasteboard, payload, and shortcut work out of the runtime, and
route keyboard-layout changes through its existing config event.
The embedded runtime no longer copies each selection on macOS by default.
Validate the private pasteboard before offering Paste Selection, and stop
UI tests from relying on the removed side effect.
@khoi
khoi merged commit b34c85c into main Sep 1, 2026
42 of 44 checks passed
@khoi
khoi deleted the t3code/review-ghostty-upstream-improvements branch September 1, 2026 00:10
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