From 8f0aec449aff86000746ae88c3ae166b212f0cbf Mon Sep 17 00:00:00 2001 From: iris <2+iris@noreply.localhost> Date: Sat, 5 Sep 2026 12:55:29 -0400 Subject: [PATCH] transcript-ui: build_tree, the screen without claiming the window root (RUST.md's E4) build() always finished by calling ui_state.set_root(), which is right for a window that *is* the transcript screen and wrong for a caller embedding it beside something else (the desktop app's session list). build_tree() is build() minus that last step, returning the widget tree instead of planting it; build() is now one line on top of it, so nothing else changes for existing callers. Co-Authored-By: Claude Fable 5.1 --- iris/transcript-ui/src/lib.rs | 37 ++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/iris/transcript-ui/src/lib.rs b/iris/transcript-ui/src/lib.rs index dfe4809..07a8827 100644 --- a/iris/transcript-ui/src/lib.rs +++ b/iris/transcript-ui/src/lib.rs @@ -88,6 +88,25 @@ pub fn build( ui_state: &mut impl HasRoot, rows: Vec, ) -> TranscriptScreen +where + Rsc::State: FocusHost, +{ + let (screen, tree) = build_tree(rsc, rows); + ui_state.set_root(tree); + screen +} + +/// The same widget tree [`build`] makes, without claiming the window's +/// whole root -- what a caller embedding this screen alongside something +/// else of its own needs (RUST.md's E4: a session list beside the +/// transcript on the desktop). `build` is `build_tree` plus +/// `ui_state.set_root(tree)`; kept as its own function since most callers +/// (the winit example, an eventual Android cdylib) want the screen to *be* +/// the window and don't need the strong handle back. +pub fn build_tree( + rsc: &mut Rsc, + rows: Vec, +) -> (TranscriptScreen, StrongWidget) where Rsc::State: FocusHost, { @@ -111,13 +130,17 @@ where let (composer, composer_bar) = composer::build_composer(rsc); - (list.width(rest(1)).height(rest(1)), composer_bar) + let tree = (list.width(rest(1)).height(rest(1)), composer_bar) .span(Dir::DOWN) - .set_root(rsc, ui_state); + .add_strong(rsc) + .any(); - TranscriptScreen { - list, - composer, - selection, - } + ( + TranscriptScreen { + list, + composer, + selection, + }, + tree, + ) }