feat(native): expose native integration snapshots - #61
Open
monotykamary wants to merge 2 commits into
Open
Conversation
Expose borrowed platform handles and last-painted geometry through two queries. Keep native child ownership and synchronization in applications. Add public contracts, generated types, encoding and renderer regressions.
monotykamary
marked this pull request as draft
September 9, 2026 05:13
Decode file URLs before importing subprocess fixtures and derive clipping positions from the native viewport rather than the requested window size.
monotykamary
marked this pull request as ready for review
September 9, 2026 05:24
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Expose two observational primitives for trusted native integrations:
getNativeWindowHandle()returns a tagged, lossless native-byte-order handle, with the display connection where required.getElementPaintState(id)returns last-painted logical bounds, rectangular clipping, and scale without forcing a render.Add generated native declarations, React types/test forwarding, focused regressions, a small diagnostic example, README contracts, and a changeset.
Scope and API rationale
No CEF, WebView, terminal, native-child host, callbacks, new style behavior, or Zed submodule change. Existing GPUI
HasWindowHandle/HasDisplayHandleand paint-time bounds are sufficient; this does not depend on remorses/zed#8.The boundary follows Electron's native-handle Buffer, raw-window-handle's borrowed lifetime/thread constraints, and Qt's explicit foreign-window ownership. Bytes do not retain a window. These snapshots are not leases, safe FFI callbacks, or native-child lifecycle guarantees. Applications own synchronization, parenting, focus, stacking, and cleanup.
Geometry is recorded during paint, not speculative virtual-list prepaint. It is scoped to the renderer owning the latest paint records, may be stale until another paint, and does not imply visibility or hit-test acceptance. Rounded clipping and occlusion are not represented. README documents null/error cases and platform handle widths.
Upstream research confirmed merged zed-industries/zed#24327, zed-industries/zed#50768, and zed-industries/zed#62775; no new GPUI API is required.
Validation
On macOS Apple Silicon, against the freshly rebuilt release addon:
git diff --checkpassed.Windows/Linux encoding is unit-tested, but their desktop runtimes were not exercised locally.
cargo fmt --checkreports three unchanged baseline regions inaccessibility.rs,custom_elements/img.rs, andcustom_elements/input.rs; this PR does not reformat unrelated code.Grok 4.6 reviewed the design and code. Findings about offscreen handle semantics and generated comments were fixed; an unrelated visibility change was removed. Final review: APPROVE.
Agent provenance
Harness: Pi coding agent with Fabric
Agent: Main, with isolated
dynamic-image-pr/embedding-primplementation agentsModel:
openai-codex/gpt-6-astraDesign and code review:
xai/grok-4.6User prompts driving these primitive PRs (verbatim)
Perfect. Recall what PRs we wanted to do once the zed PR we made was merged.
Does GPUIx need them baked in? Or leave it up to the user? Our colleague wants to make sure we expose primitives and create small scoped PRs.
Help me add (1) and (2) while considering carefully best practices of related primitives out in the wild (feel free to search the web and check). Make sure grok 4.6 reviews your work and code; it needs to be tight and small in scope and PR, follow code conventions and most importantly good code style. Create those PRs for me.
gh watch the CI and resolve the issues.
I've converted them to a draft. Open them back up once all fixed. Proceed.
CI follow-up
Commit
199da00fixes Windows subprocess file-URL conversion and derives clipping expectations from the actual native viewport. Targeted local tests: 78 passed; package build passed. Grok 4.6 approved the test-only changes. All platform builds, macOS/Windows test jobs, and the publish job passed in CI run 34314125640. Marked ready only after the exact updated head was green.