From 1675db083a7adfaaf9dabc58e0782754e1ae0b8d Mon Sep 17 00:00:00 2001 From: rorychatt Date: Fri, 17 Apr 2026 14:21:28 +0200 Subject: [PATCH] [00286] Fix widget_harness missing initial build in WebSocket handler Add runtime.build().await before current_tree() check in handle_socket so the initial refresh message is sent to WebSocket clients. Also add a unit test verifying build() populates the tree. --- rusty/src/core/runtime.rs | 8 ++++++++ rusty/src/server/ws.rs | 1 + 2 files changed, 9 insertions(+) diff --git a/rusty/src/core/runtime.rs b/rusty/src/core/runtime.rs index e1ce210..a9cdf41 100644 --- a/rusty/src/core/runtime.rs +++ b/rusty/src/core/runtime.rs @@ -234,6 +234,14 @@ mod tests { assert!(json.to_string().contains("Hello from runtime")); } + #[tokio::test] + async fn test_runtime_build_populates_tree() { + let mut runtime = Runtime::new(TestView); + assert!(runtime.current_tree().await.is_none()); + runtime.build().await; + assert!(runtime.current_tree().await.is_some()); + } + #[tokio::test] async fn test_runtime_build_assigns_ids_automatically() { use crate::widgets::layout::Layout; diff --git a/rusty/src/server/ws.rs b/rusty/src/server/ws.rs index 41f476a..87fd933 100644 --- a/rusty/src/server/ws.rs +++ b/rusty/src/server/ws.rs @@ -159,6 +159,7 @@ async fn handle_socket(socket: WebSocket, state: Arc) { // Send initial render from this session's own runtime { let mut session = session_arc.write().await; + session.runtime.build().await; if let Some(tree) = session.runtime.current_tree().await { let msg = ServerMessage::Refresh { widgets: tree.clone(),