Skip to content

gpui: Let embedded views mount JS roots inline - #2974

Merged
huacnlee merged 2 commits into
longbridge:mainfrom
wabzqem:gpui/restore-inline-embedding
Nov 23, 2026
Merged

huacnlee merged 2 commits into
longbridge:mainfrom
wabzqem:gpui/restore-inline-embedding

Conversation

@wabzqem

@wabzqem wabzqem commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Description

After #2307, a plain JS root loaded by an embedded AppView opens an implicit desktop window instead of rendering in the host. That leaves the host without inline content for the height API from #2569 to measure.

Embedders can now pass AppOptions { inline_root: true, ..Default::default() } to AppView::new to keep a plain root in the host view. This is opt-in so load and own_window can remain in either order without silently changing existing desktop behavior. The flag defaults to false, and standalone launchers ignore it. Explicit windows, window closing, and quit policy are unchanged.

Public API

  • nsh-platform-gpui: AppOptions::inline_root: bool — opt into inline mounting for plain JS roots.

Rust source compatibility

Exhaustive AppOptions literals must add inline_root or use ..Default::default(). Existing default and struct-update callers need no changes.

Verification

  • GPUI headless tests: opt-in on/off in both call orders, standalone launcher ignores the inline flag, restored inline embedding cases, and offscreen image/scroll rendering.
  • QuickJS keeps the inline host reference when a detached window is named main.
  • Standalone JS window and configurable last-window quit tests.
  • Locked GPUI Clippy with default + shot features and minimal js features; targeted nightly formatting.

Keep Window Model v2 as the default. Let embedders opt into an inline plain root without changing the order of load and own_window.
@huacnlee

Copy link
Copy Markdown
Member

💡 Needs a maintainer call on the API shape: the fix is wanted, but it adds a parallel constructor plus a re-exported engine helper.

What it fixes. Since #2307 a plain JS root in an embedded AppView opens an implicit window instead of rendering inline, so the embedder has nothing to measure (#2569). Tests that were #[ignore]d are re-enabled for the inline path; two window-state cases move to a separate ignored standalone_windows group.

Public API added.

  • nsh-platform-gpui: AppView::new_inline(options, window, cx)
  • nsh-js / nsh-engine: with_inline_root(EngineContext) -> EngineContext

Concern. new_inline is a second entry point that differs from new only by one flag, and with_inline_root exposes engine plumbing that embedders should not need to touch. A smaller shape would be an option on the existing type, e.g.

AppView::new(AppOptions { inline: true, ..Default::default() }, window, cx)

keeping with_inline_root crate-internal. Also worth confirming whether inline should simply be the default for an embedded AppView that never calls own_window, which would need no new API at all.

Reviewed 517404b by reading the diff; not built locally.

🤖 Noop (reviewer) · AI agent acting for @huacnlee

@huacnlee

Copy link
Copy Markdown
Member

❌ Needs an API change before merge: please make inline rendering an AppOptions field instead of a new AppView::new_inline constructor.

The fix itself is wanted (embedded plain-JS roots opening a separate window since #2307). The maintainers prefer extending the existing entry point over adding a parallel one:

  • Replace AppView::new_inline(...) with a field on the existing options, e.g. AppOptions { inline: true, .. } (name open to discussion), consumed by AppView::new.
  • Keep with_inline_root crate-internal (pub(crate)); it should not be part of the public export surface.
  • Please keep the regression test and adapt it to the option.

Reviewed head 517404b (diff only, not built locally).

🤖 Noop (reviewer) · AI agent acting for @huacnlee

@wabzqem

wabzqem commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

Addressed in 3aa8e45a6: AppView::new now reads AppOptions::inline_root (default false), and the cross-crate bridge is hidden from the public docs. The shared standalone launcher ignores the flag. The GPUI tests still cover both load/own_window orders with the flag on and off, and now also verify that passing it to the standalone launcher keeps the implicit window. Those tests, the offscreen render tests, and GPUI Clippy passed locally.

@huacnlee huacnlee left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

✅ LGTM: inline mounting is now the AppOptions::inline_root opt-in requested in the previous review.

Reviewed at 3aa8e45. AppView::new_inline is gone, with_inline_root stays internal, the field defaults to false, and open_app_window / run_app reset it so standalone launches keep the implicit window (covered by the new test case). Docs (en, zh-CN) and the embed-gpui example follow the new shape. I read the diff only; CI is still running on this head.

🤖 Noop (reviewer) · AI agent acting for @huacnlee

@huacnlee
huacnlee merged commit a6265e7 into longbridge:main Nov 23, 2026
9 of 24 checks passed
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.

2 participants