Skip to content

feat(nsh): replace GPUI with native desktop and terminal backends - #6674

Merged
M4n5ter merged 1 commit into
rust-previewfrom
feat/native-terminal-remove-gpui
Nov 8, 2026
Merged

M4n5ter merged 1 commit into
rust-previewfrom
feat/native-terminal-remove-gpui

Conversation

@M4n5ter

@M4n5ter M4n5ter commented Nov 6, 2026 •

Copy link
Copy Markdown
Member

Summary

Replace GPUI desktop and pixel-terminal rendering with the platform-native NSH backends while keeping third-party/nsh changes restricted to GPUI removal, nsh-terminal, and required host/backend capabilities and bug fixes.

  • Add shared terminal transport, frame receipts, focus admission, and input contracts in nsh-terminal.
  • Render terminal pixels through hidden AppKit/Direct2D surfaces on macOS and Windows; Linux terminal explicitly falls back to character rendering without a display server, while Linux desktop uses GTK4.
  • Remove GPUI vendor/backend trees (crates/gpui, third-party/gpui-wgpu, examples/embed-gpui), update CI suites, font attribution, and reviewed dependency notices, and revert non-essential third-party/nsh docs/website/CI/CLI churn to keep upstream NSH sync minimal.
  • Resolve Windows & Unix native desktop, terminal & host regressions uncovered by real-host end-to-end execution:
    • Order Direct2D/DirectWrite thread-local teardown before graphics device state on ExitProcess (nsh-platform-windows).
    • Gate native editor focus on ancestor visibility and active modal focus scope across Windows and macOS (navigation::in_focus_scope / navigation::focus_scope), blur covered responders on modal presentation, preserve queued modal autoFocus across background blur in the same mount batch, bump focus generation when an existing view becomes editable, arm pending-focus fencing during terminal IME preedit, cancel uncommitted field-editor preedit before NSTextField ends editing, and bypass unsettled focus fencing on plain Escape so Linux GTK4 matches macOS and Windows (nsh-platform-windows, nsh-platform-macos, nsh-platform-linux).
    • Allocate premultiplied RGBA bitmaps retagged as sRGB and unpremultiply to straight RGBA in macOS view capture, invalidate and wake terminal captures when async native images/canvases finish decoding, initialize macOS TerminalSurface lifecycle and wake notifications on engine commits, and map terminal Home/End to line caret movement (nsh-platform-macos).
    • Scope Windows TerminalSurface::pressable_bounds to the active modal (navigation::focus_scope) and filter disabled / PointerEvents::None / parked / dying subtrees (nsh-platform-windows).
    • Wait for in-flight model resolution (modelDetails().kind === 'loading') before consuming prefill autoSend or rejecting interactive sends as 'Model unavailable', and clear stale transcript errors before announcing 'live' (Conversation.tsx).
    • Cancel ACP interaction client waits via child CancellationToken instead of aborting spawned tasks mid-Client call (maka-acp), and release SQLite actor custody pins and slot/capacity permits before waking reply waiters (maka-event-log).
    • Handle Windows named-pipe LocalStream::poll_flush clean peer disconnects (ERROR_NO_DATA / os error 232 when no buffered write is pending) and skip empty 0-byte probes on clean flushes/shutdowns (maka-host-runtime), propagate test host SandboxMode across candidate restarts, release idle cap_std::fs::Dir handles in PublishedDirectory so active workspace directories remain renamable on Windows (maka-fs-tools), and normalize verbatim \\?\ paths across Windows workspace bindings and private rules (maka-fs-tools, maka-workspace-support).

Breaking change

GPUI embedding APIs in Maka and GPUI vendor crates in third-party/nsh are removed without compatibility shims; desktop and pixel-terminal surfaces run directly on AppKit, Win32/Direct2D, GTK4, or character-terminal fallback.

Verification

Rebased onto origin/rust-preview and verified across WSL (Linux), native Windows (x86_64-pc-windows-msvc), macOS cross-target (aarch64-apple-darwin), and GitHub Actions CI:

  • Tooling, formatting, contracts & product (WSL + Windows):
    • node scripts/ci.mjs check format and git diff --check: passed.
    • node scripts/ci.mjs check tooling-tests (264 tests) and Windows node.exe --test scripts/ci.test.mjs (windows-ci): passed.
    • node scripts/ci.mjs check licenses and node scripts/ci.mjs check notices: passed.
    • node scripts/ci.mjs run contracts and node scripts/ci.mjs run product: passed.
  • Third-party workspaces (WSL + Windows + macOS cross-check):
    • node scripts/ci.mjs run termina: passed (including x86_64-pc-windows-msvc target checks).
    • node scripts/ci.mjs run nsh: passed (nsh-* unit/integration/doc tests + web runtime tests, 57 passed).
    • Windows windows-nsh: cargo test --locked --manifest-path third-party/nsh/Cargo.toml -p nsh-platform-windows --features terminal --lib with -D warnings (192 passed, 0 failed).
    • macOS cross-check (aarch64-apple-darwin): cargo check --locked --manifest-path third-party/nsh/Cargo.toml --target aarch64-apple-darwin -p nsh-platform-macos --features dev,terminal --tests with -D warnings: passed.
  • Maka native desktop, pixel-terminal & workspace suites (Windows + WSL):
    • Windows desktop (cargo test --locked -p maka-cli --no-default-features --features desktop-tests --test native-desktop -- --test-threads=1 with -D warnings): 22 passed, 0 failed (locally and in CI/native-windows).
    • Windows pixels (cargo test --locked -p maka-terminal-shell --test native-pixels -- --test-threads=1 with -D warnings): 2 passed, 0 failed.
    • Windows windows-desktop (maka-desktop-shell, 3 passed, 0 failed), maka-host-runtime (ipc::windows, 2 passed, 0 failed), windows-skills (maka-skills-native), windows-shell (maka-process Git Bash & maka-settings-native shell setting), and maka-workspace-support with -D warnings: passed.
    • WSL maka-event-log, maka-acp, maka-cli (acp::tests::*, terminal::*, candidate::crash::*, distribution), maka-terminal-shell, maka-workbench, maka-fs-tools, maka-workspace-support, maka-host-runtime, and maka-process with -D warnings: passed.
  • CI runner coverage:
    • macOS native suites (CI/native-macos), Windows native suites (CI/native-windows), and Linux GTK display tests (CI/linux-nsh under Xvfb) run on GitHub Actions runners.

AI use

  • No generative tool made a substantive contribution
  • Generative tooling made a substantive contribution

Tool(s) and scope: OpenAI Codex authored the initial GPUI-to-native migration; Google Antigravity rebased onto rust-preview, pruned non-essential third-party/nsh changes, diagnosed and fixed Windows, macOS & Linux native host/focus/modal/capture/IPC/filesystem/ACP/event-log issues, and ran local WSL + Windows verification. The commit carries Generated-by: trailers. Automated PR update; independent human review is required.

Checklist

  • Tests cover the change and fail without it
  • Format, typecheck and the affected suites pass locally

Does this PR entail a change in behavior?

  • Yes — described under Summary above
  • No

@github-actions github-actions Bot added the effort/XXL Over 2500 readable lines label Nov 7, 2026
@M4n5ter
M4n5ter force-pushed the feat/native-terminal-remove-gpui branch 5 times, most recently from 2e2afa9 to 8df8b48 Compare November 8, 2026 00:29
Replace GPUI desktop and pixel-terminal rendering with the platform-native NSH backends (AppKit, Win32/Direct2D, GTK4) and shared `nsh-terminal` contracts while keeping `third-party/nsh` changes minimal.

Fix Windows Direct2D thread-local teardown ordering, Windows/macOS/Linux modal focus scoping, queued `autoFocus` preservation, terminal IME preedit and plain-Escape fencing, macOS sRGB premultiplied bitmap capture and async image/canvas capture invalidation, macOS terminal wake/lifecycle/Home-End caret handling, modal-scoped pressable bounds, named-pipe clean stream flushing (`ERROR_NO_DATA`), conversation model-loading send race, ACP callback cancellation across in-flight Host calls, SQLite actor custody release before reply wakeup, test host sandbox propagation, idle workspace directory handle retention, and verbatim path normalization.

Generated-by: OpenAI Codex
Generated-by: Google Antigravity
@M4n5ter
M4n5ter force-pushed the feat/native-terminal-remove-gpui branch from 8df8b48 to 32a064b Compare November 8, 2026 00:49
@M4n5ter
M4n5ter marked this pull request as ready for review November 8, 2026 00:51
@M4n5ter
M4n5ter merged commit 57470e4 into rust-preview Nov 8, 2026
12 of 14 checks passed
@M4n5ter
M4n5ter deleted the feat/native-terminal-remove-gpui branch November 8, 2026 00:51

@Astro-Han Astro-Han left a comment •

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.

I reviewed the final two-file test correction from 2e2afa9586dcd7bb98253c381df2459a2b124d1d to 32a064b06769c2cd79ad5566f28c9fe457d908f4: 142 additions and 56 deletions in the Linux input test module and macOS terminal tests. The broader 537-file native-backend migration, ACP cancellation and SQLite resource-lifetime changes still require complete review and native validation.

The Linux fixtures now collect intermediate log events, wait for the relevant UI event acknowledgements, use onChange/bindProp, and key replacement input subtrees by their version. The macOS fixtures use a non-animated Dialog with Escape dismissal and exercise both a bound Escape shortcut and the ordinary cancel-composition → blur → dismiss sequence. I checked the complete final delta and its surrounding tests. The Linux production section is byte-identical to the preceding revision; these last changes correct the fixtures and their synchronization.

Current hosted evidence:

  • The complete Linux composing_escape_cancels_preedit_before_leaving_field_or_closing_modal case passed in 0.197s in final run 42431500636 and 0.174s in merged run 42431703925. The scoped/fallback keybindings case also passed in both runs. The earlier Escape failure is therefore superseded for this final test revision.
  • Both Linux jobs still failed pending_focus_event_holds_keys_paste_and_pause_input_without_queued_text. At third-party/nsh/crates/nsh-platform-linux/src/text_input.rs:3287, the expected Ok(()) from pause_input was instead Err("pending input has no editable focus target"). Each job reports 81 passed, one failed, five not run and two skipped. I have not established whether the remaining failure is in the fixture or the production focus transition.
  • The macOS desktop_composing_escape_cancels_marked_text_without_blurring_or_dismissing_modal case also failed in both runs, in 5.263s and 5.270s respectively. At third-party/nsh/crates/nsh-platform-macos/tests/terminal/cases.rs:513, the shared five-second AppKit event-pump wait timed out. The logs do not identify which invocation of that shared wait failed, so they do not establish the specific focus/composition phase or its cause. Both platform-library suites passed 86 tests, and the delayed-image capture case passed, which does not establish complete native desktop acceptance.
  • Both overall CI runs are now completed/failure. Both Windows native jobs passed, including their 192-test platform suites (one skipped), 22-test desktop journeys, and two pixel tests. The PR job checked out synthetic merge 42cb30eed6e7833e07ebd72d3afde7b3bf0bc060; its Git tree is identical to the final and merged commits. The Linux and macOS failures above remain the failed job results; Windows success does not establish complete migration acceptance.

I did not run these native suites locally, and this comment supplies no native migration acceptance or approval. The change is already merged as 57470e4c1542431d89e99dad4205270b8845f383; the remaining Linux failure and the unvalidated migration scope remain open.


Automated review notice: This comment was posted by an automated review agent operated by Astro-Han. It is not an independent human review and does not replace one.

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

Labels

effort/XXL Over 2500 readable lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants