8000 The embedding point: WidgetKind.Platform and Prop.View, on GTK and Android (docs/17 step 1) by rleibman · Pull Request #146 · rleibman/thicket · GitHub
[go: up one dir, main page]

Skip to content

The embedding point: WidgetKind.Platform and Prop.View, on GTK and Android (docs/17 step 1) - #146

Merged
rleibman merged 7 commits into
mainfrom
feat/platform-view
Nov 3, 2026
Merged

rleibman merged 7 commits into
mainfrom
feat/platform-view

Conversation

@rleibman
@rleibman rleibman commented Nov 3, 2026
Copy link
Copy Markdown
Owner

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) and trait 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:

    • GTK: GtkPlatformView.create(): Ptr[GtkWidget]
    • Android: AndroidPlatformView.create(context): View

    Each also has a release that 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):

    • The handle is a container (a GtkBox or a FrameLayout) holding the one native view. A changed view replaces the child; the handle stays.
    • release runs while the native view is still alive and parented; then the view is removed.
    • The renderer tracks the view in one of its per-handle tables, so destroy sweeps it and the leak checks count it.
    • A view the renderer has nothing for shows <description>: not available on GTK (or Android).
  • Apple: a label reading … not available on AppKit/UIKit yet until 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, a TextView), and a second view, one no platform has, says it's unavailable.

Measured

Before After
checkLinux exit 0
core tests 170 172 (PlatformSpec 2/2)
GTK gallery / todo 138 / 69 144 / 69 (the section's heading plus 5 checks). Run under a headless gnome-shell, because the desktop was locked.
Android gallery on s2test 90 95

The checks:

  1. The very widget the host's view made is in the window, with its text.
  2. A view the platform has nothing for says so.
  3. After the view is replaced, a new widget is in the old one's place.
  4. The old widget was released while still alive: GTK reads the label's text inside release, Android checks the view's parent.
  5. The renderer's table count is unchanged.

Falsified

  • release skipped, or called after removal: check 4 fails on both platforms. GTK also logs Gtk-CRITICAL … GTK_IS_WIDGET.
  • An empty "not available" label: check 2 fails on both.
  • A Platform that ignores its signal: PlatformSpec's second test fails.

Not done

🤖 Generated with Claude Code

…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>
Copilot AI 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.

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), and PlatformView.
  • 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

Comment thread README.md Resolved
rleibman and others added 6 commits November 3, 2026 09:46
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>
@rleibman
rleibman merged commit fb9882e into main Nov 3, 2026
2 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

0