Repository navigation
The embedding point: WidgetKind.Platform and Prop.View, on GTK and Android (docs/17 step 1) - #146
Conversation
…droid (docs/17 step 1) A view made by a module of its own (the camera preview next), shown by the renderers generically, as docs/17 §17.3 proposed and the owner approved: - renderer-api: WidgetKind.Platform, Prop.View, trait PlatformView. - core: dsl.Platform(view | Signal[view]); TestRenderer records the view. - GTK: GtkPlatformView.create(): Ptr[GtkWidget], held in a GtkBox. - Android: AndroidPlatformView.create(context): View, held in a FrameLayout. Both release the native view while it is still alive, then remove it; a changed view replaces the child; a view with nothing for the renderer shows "<description>: not available on GTK/Android". The tracking table is a per-handle table, so destroy sweeps it and the leak checks count it. - Apple: a label, "... not available on AppKit/UIKit yet", until #145. - Gallery: a Platform section; GTK and Android make a native label themselves (GtkLabel, TextView), and a view no platform has says so. Measured: checkLinux exit 0; PlatformSpec 2/2 (core 172). GTK gallery 144 (138 + 6), todo 69, under a headless gnome-shell (desktop locked). Android gallery 95 (90 + 5) on s2test. platforms/Test/compile 0 errors. Falsified: release skipped or after removal fails "released while still alive" on GTK and Android (GTK also logs Gtk-CRITICAL GTK_IS_WIDGET); an empty "not available" label fails "says so" on both; a Platform ignoring its signal fails PlatformSpec. Not run: the Apple galleries (#145). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Note
Copilot was unable to complete this review at the selected tier due to model policy or plan restrictions.
🟡 Changes recommended
Several unresolved review findings remain, including moderate-severity unbounded growth of NativeLabel.made retaining views/widgets across recreations (plus minor documentation/date inconsistencies), so the changes need fixes before approval.
4 open issues
What changed in this PR
Implements the “embedding point” abstraction (docs/17 step 1) by adding a Platform widget capable of hosting renderer-specific native views. GTK and Android renderers support creating/replacing hosted views with a release lifecycle hook; Apple currently degrades to a “not available yet” placeholder. Core DSL, tests, gallery self-tests, and docs are updated accordingly.
Changes:
- Add renderer contract pieces:
WidgetKind.Platform,Prop.View(view), andPlatformView. - Add core DSL
dsl.Platform(view | Signal[view])plus reconciliation tests for signal-driven replacement. - Implement GTK (
GtkBox) and Android (FrameLayout) hosting/replacement + lifecycle (create/release) handling; Apple placeholder behavior. - Extend gallery + self-tests and update documentation/status/counts.
| File | Summary / Notes |
|---|---|
README.md |
Updates published test/self-test counts. Nit: “Counts as of” date should match updated numbers/date. |
modules/renderer-gtk/src/main/scala/thicket/renderer/gtk/GtkRenderer.scala |
Wires WidgetKind.Platform + Prop.View into GTK renderer lifecycle (create/update/destroy). |
modules/renderer-gtk/src/main/scala/thicket/renderer/gtk/GtkPlatformView.scala |
Adds GTK-facing GtkPlatformView + hosting/replacement logic. |
modules/renderer-apple/src/main/scala/thicket/renderer/apple/AppleRenderer.scala |
Temporary Platform handling on Apple via placeholder “not available yet” label. |
modules/renderer-api/shared/src/main/scala/thicket/renderer/Renderer.scala |
Extends renderer API with WidgetKind.Platform, Prop.View, and PlatformView. |
modules/renderer-android/src/main/scala/thicket/renderer/android/AndroidRenderer.scala |
Wires WidgetKind.Platform + Prop.View into Android renderer lifecycle (create/update/destroy). |
modules/renderer-android/src/main/scala/thicket/renderer/android/AndroidPlatformView.scala |
Adds Android-facing AndroidPlatformView + hosting/replacement logic. |
modules/core/shared/src/test/scala/thicket/core/TestRenderer.scala |
Updates test renderer to record/handle Prop.View for platform tests. |
modules/core/shared/src/test/scala/thicket/core/PlatformSpec.scala |
Adds tests validating dsl.Platform emits Prop.View and supports signal-driven replacement. |
modules/core/shared/src/main/scala/thicket/core/Element.scala |
Adds `dsl.Platform(view |
examples/gallery/shared/shared/src/main/scala/example/gallery/Gallery.scala |
Adds Platform gallery section/state. Nit: fix mis-attached ScalaDoc so deliberate and nativeLabelText are documented correctly. |
examples/gallery/README.md |
Documents the new Platform section and its self-test expectations. |
examples/gallery/gtk/src/main/scala/example/gallery/GalleryGtk.scala |
GTK gallery platform view + self-test wiring. Moderate: bound NativeLabel.made to avoid unbounded growth retaining old widget pointers. |
examples/gallery/android/scala/src/main/scala/example/gallery/android/GallerySelfTest.scala |
Adds Android self-test coverage for hosted platform views (presence/replacement/release/table stability). |
examples/gallery/android/scala/src/main/scala/example/gallery/android/GalleryActivity.scala |
Android platform view factory for gallery. Moderate: bound NativeLabel.made to avoid unbounded growth retaining View instances. |
docs/decisions.md |
Records decision/log entry for the embedding point implementation. |
docs/17-camera-preview.md |
Updates camera preview doc/status to reflect embedding point completion (step 1). |
docs/12-component-status.md |
Updates contract/status tables and measured counts. Nit: update “Last updated” header date to reflect new measurements. |
This pull request requires changes.
Review effort: Balanced
Conflict only in docs/decisions.md: both 2026-11-02 entries kept, the embedding point's on top. #142 is Apple code, the Apple galleries and tooling, so the GTK (144) and Android (95) counts measured on this branch stand. Checked here: sbt scalafmtAll, Test/compile and platforms/Test/compile, 0 errors. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Updated CI test counts and clarified test environments. Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Conflict only in docs/decisions.md: both 2026-11-02 entries kept, the embedding point's on top; the 11-01 camera-preview entry appears once (#144). #143 and #144 are Apple code and docs, so the GTK (144) and Android (95) counts measured on this branch stand. Checked here: sbt scalafmtAll, Test/compile and platforms/Test/compile, 0 errors. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>


Step 1 of docs/17 §17.7: the embedding point (§17.3) that the owner approved on 2026-11-01. The live camera preview (step 2) builds on it. The Apple half is #145.
What it is
renderer-api:WidgetKind.Platform,Prop.View(view)andtrait PlatformView { def description: String }.core:dsl.Platform(view: PlatformView | Signal[PlatformView]).How a view is made: each renderer extends the trait with how to make the native view, which is the "factory" in §17.3's wording:
GtkPlatformView.create(): Ptr[GtkWidget]AndroidPlatformView.create(context): ViewEach also has a
releasethat does nothing by default. A module that provides a view implements the trait for each platform it supports, so the renderers never depend on it. There is no registry.How the renderers handle it (GTK and Android):
GtkBoxor aFrameLayout) holding the one native view. A changed view replaces the child; the handle stays.releaseruns while the native view is still alive and parented; then the view is removed.destroysweeps it and the leak checks count it.<description>: not available on GTK(or Android).Apple: a label reading
… not available on AppKit/UIKit yetuntil Apple embedding point: host a platform view (WidgetKind.Platform / Prop.View) in the AppKit and UIKit shims #145. The Scala type-checks here; nothing has been run on a Mac.Gallery: a new Platform section. The GTK and Android hosts make a native label themselves (a
GtkLabel, aTextView), and a second view, one no platform has, says it's unavailable.Measured
checkLinuxPlatformSpec2/2)gnome-shell, because the desktop was locked.s2testThe checks:
release, Android checks the view's parent.Falsified
releaseskipped, or called after removal: check 4 fails on both platforms. GTK also logsGtk-CRITICAL … GTK_IS_WIDGET.Platformthat ignores its signal:PlatformSpec's second test fails.Not done
🤖 Generated with Claude Code