Skip to content

Commit 1675db0

Browse files
committed
[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.
1 parent 22d2e30 commit 1675db0

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

rusty/src/core/runtime.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,14 @@ mod tests {
234234
assert!(json.to_string().contains("Hello from runtime"));
235235
}
236236

237+
#[tokio::test]
238+
async fn test_runtime_build_populates_tree() {
239+
let mut runtime = Runtime::new(TestView);
240+
assert!(runtime.current_tree().await.is_none());
241+
runtime.build().await;
242+
assert!(runtime.current_tree().await.is_some());
243+
}
244+
237245
#[tokio::test]
238246
async fn test_runtime_build_assigns_ids_automatically() {
239247
use crate::widgets::layout::Layout;

rusty/src/server/ws.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ async fn handle_socket(socket: WebSocket, state: Arc<AppState>) {
159159
// Send initial render from this session's own runtime
160160
{
161161
let mut session = session_arc.write().await;
162+
session.runtime.build().await;
162163
if let Some(tree) = session.runtime.current_tree().await {
163164
let msg = ServerMessage::Refresh {
164165
widgets: tree.clone(),

0 commit comments

Comments
 (0)