@native-sdk/cli 0.5.4 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (149) hide show
  1. package/build/app.zig +50 -1
  2. package/build.zig +588 -32
  3. package/build.zig.zon +7 -0
  4. package/native-sdk.d.ts +3 -1
  5. package/package.json +9 -9
  6. package/packages/core/package-lock.json +2 -2
  7. package/packages/core/package.json +1 -1
  8. package/packages/core/rt/rt.zig +280 -8
  9. package/packages/core/sdk/core.ts +481 -2
  10. package/packages/core/sdk/events.ts +17 -8
  11. package/packages/core/src/checker.ts +305 -2
  12. package/packages/core/src/diagnostics.ts +12 -0
  13. package/packages/core/src/emitter.ts +599 -3
  14. package/packages/core/src/typed_ast.ts +51 -4
  15. package/packages/core/src/types.ts +34 -1
  16. package/skill-data/native-ui/SKILL.md +39 -2
  17. package/skill-data/ts-core/SKILL.md +4 -2
  18. package/src/app_runner/root.zig +32 -10
  19. package/src/automation/layout_fingerprint.zig +160 -0
  20. package/src/automation/protocol.zig +82 -33
  21. package/src/automation/root.zig +1 -0
  22. package/src/automation/server.zig +1 -1
  23. package/src/automation/snapshot.zig +68 -9
  24. package/src/automation/watcher.zig +1 -1
  25. package/src/embed/host.zig +5 -0
  26. package/src/embed/ui_host.zig +13 -0
  27. package/src/platform/linux/gtk_host.c +527 -13
  28. package/src/platform/linux/gtk_host.h +25 -0
  29. package/src/platform/linux/root.zig +280 -7
  30. package/src/platform/macos/appkit_host.h +104 -6
  31. package/src/platform/macos/appkit_host.m +1368 -74
  32. package/src/platform/macos/cef_host.mm +110 -1
  33. package/src/platform/macos/root.zig +287 -7
  34. package/src/platform/null_platform.zig +398 -4
  35. package/src/platform/null_platform_tests.zig +35 -0
  36. package/src/platform/root.zig +9 -0
  37. package/src/platform/types.zig +386 -14
  38. package/src/platform/windows/root.zig +298 -9
  39. package/src/platform/windows/webview2_host.cpp +330 -5
  40. package/src/primitives/app_manifest/validation.zig +18 -0
  41. package/src/primitives/canvas/a11y_audit.zig +33 -11
  42. package/src/primitives/canvas/a11y_audit_tests.zig +20 -0
  43. package/src/primitives/canvas/drawing.zig +25 -0
  44. package/src/primitives/canvas/equality.zig +8 -0
  45. package/src/primitives/canvas/events.zig +103 -16
  46. package/src/primitives/canvas/frame.zig +125 -1
  47. package/src/primitives/canvas/layout_audit.zig +22 -5
  48. package/src/primitives/canvas/markdown_hostile_tests.zig +8 -4
  49. package/src/primitives/canvas/render_tests.zig +13 -10
  50. package/src/primitives/canvas/root.zig +48 -0
  51. package/src/primitives/canvas/terminal_box.zig +471 -0
  52. package/src/primitives/canvas/terminal_grid.zig +978 -0
  53. package/src/primitives/canvas/terminal_grid_tests.zig +1093 -0
  54. package/src/primitives/canvas/test_support.zig +1 -0
  55. package/src/primitives/canvas/tests.zig +1 -0
  56. package/src/primitives/canvas/text_tests.zig +39 -4
  57. package/src/primitives/canvas/tokens.zig +115 -12
  58. package/src/primitives/canvas/ui.zig +524 -5
  59. package/src/primitives/canvas/ui_markup.zig +195 -2
  60. package/src/primitives/canvas/ui_markup_compiled.zig +172 -1
  61. package/src/primitives/canvas/ui_markup_compiled_tests.zig +133 -8
  62. package/src/primitives/canvas/ui_markup_contract.zig +88 -5
  63. package/src/primitives/canvas/ui_markup_contract_tests.zig +39 -1
  64. package/src/primitives/canvas/ui_markup_huge_model_tests.zig +1 -0
  65. package/src/primitives/canvas/ui_markup_reflect.zig +75 -24
  66. package/src/primitives/canvas/ui_markup_tests.zig +149 -0
  67. package/src/primitives/canvas/ui_markup_view.zig +191 -0
  68. package/src/primitives/canvas/ui_markup_view_tests.zig +403 -19
  69. package/src/primitives/canvas/ui_schema.zig +97 -17
  70. package/src/primitives/canvas/ui_schema_tests.zig +18 -11
  71. package/src/primitives/canvas/ui_tests.zig +141 -9
  72. package/src/primitives/canvas/widget_access.zig +28 -2
  73. package/src/primitives/canvas/widget_anchored_tests.zig +48 -0
  74. package/src/primitives/canvas/widget_invalidation.zig +81 -1
  75. package/src/primitives/canvas/widget_layout.zig +59 -11
  76. package/src/primitives/canvas/widget_layout_tests.zig +125 -4
  77. package/src/primitives/canvas/widget_render.zig +272 -18
  78. package/src/primitives/canvas/widget_render_scroll.zig +108 -27
  79. package/src/primitives/canvas/widget_routing.zig +59 -7
  80. package/src/primitives/canvas/widget_runtime.zig +23 -0
  81. package/src/primitives/canvas/widget_runtime_tests.zig +149 -0
  82. package/src/primitives/canvas/widget_semantics.zig +119 -11
  83. package/src/primitives/canvas/widget_semantics_tests.zig +409 -0
  84. package/src/primitives/canvas/widget_tree.zig +17 -0
  85. package/src/primitives/canvas/widgets.zig +132 -0
  86. package/src/root.zig +16 -0
  87. package/src/runtime/api.zig +76 -6
  88. package/src/runtime/automation_commands.zig +20 -1
  89. package/src/runtime/automation_snapshot.zig +25 -1
  90. package/src/runtime/automation_widget_dispatch.zig +73 -8
  91. package/src/runtime/bridge_payload.zig +1 -0
  92. package/src/runtime/canvas_frame.zig +62 -7
  93. package/src/runtime/canvas_frame_animation_tests.zig +5 -4
  94. package/src/runtime/canvas_frame_helpers.zig +190 -1
  95. package/src/runtime/canvas_frame_invalidation_tests.zig +531 -0
  96. package/src/runtime/canvas_frame_patch_tests.zig +161 -10
  97. package/src/runtime/canvas_frame_retained_tests.zig +5 -2
  98. package/src/runtime/canvas_widget_accessibility_tests.zig +1 -1
  99. package/src/runtime/canvas_widget_clipboard_tests.zig +40 -0
  100. package/src/runtime/canvas_widget_context_menu.zig +269 -32
  101. package/src/runtime/canvas_widget_context_menu_tests.zig +640 -14
  102. package/src/runtime/canvas_widget_display.zig +1 -1
  103. package/src/runtime/canvas_widget_event_tests.zig +1823 -0
  104. package/src/runtime/canvas_widget_events.zig +268 -26
  105. package/src/runtime/canvas_widget_runtime.zig +213 -29
  106. package/src/runtime/canvas_widget_scroll_driver_tests.zig +170 -7
  107. package/src/runtime/canvas_widget_scroll_drivers.zig +151 -17
  108. package/src/runtime/canvas_widget_scroll_tests.zig +435 -23
  109. package/src/runtime/canvas_widget_state.zig +6 -0
  110. package/src/runtime/canvas_widget_text_tests.zig +1 -1
  111. package/src/runtime/core.zig +73 -2
  112. package/src/runtime/effects.zig +6389 -54
  113. package/src/runtime/effects_channel_tests.zig +3519 -0
  114. package/src/runtime/effects_pty_tests.zig +1362 -0
  115. package/src/runtime/effects_tests.zig +14 -9
  116. package/src/runtime/effects_video_tests.zig +3609 -0
  117. package/src/runtime/flow.zig +25 -4
  118. package/src/runtime/gpu_surface_events.zig +475 -15
  119. package/src/runtime/media_surface.zig +116 -11
  120. package/src/runtime/media_surface_tests.zig +61 -0
  121. package/src/runtime/pty.zig +1252 -0
  122. package/src/runtime/pty_windows.zig +1780 -0
  123. package/src/runtime/root.zig +25 -0
  124. package/src/runtime/runtime_event_tests.zig +20 -1
  125. package/src/runtime/session_journal.zig +367 -61
  126. package/src/runtime/session_record.zig +16 -0
  127. package/src/runtime/session_replay.zig +395 -11
  128. package/src/runtime/session_tests.zig +114 -19
  129. package/src/runtime/terminal_session.zig +1569 -0
  130. package/src/runtime/terminal_session_tests.zig +450 -0
  131. package/src/runtime/terminal_vt_ghostty.zig +15 -0
  132. package/src/runtime/terminal_vt_stub.zig +13 -0
  133. package/src/runtime/tests.zig +6 -0
  134. package/src/runtime/ts_core_host.zig +980 -140
  135. package/src/runtime/ts_core_host_tests.zig +1059 -1
  136. package/src/runtime/ts_ui_app.zig +16 -5
  137. package/src/runtime/ui_app.zig +2338 -67
  138. package/src/runtime/ui_app_tests.zig +3171 -744
  139. package/src/runtime/ui_app_virtual_variable_tests.zig +4 -2
  140. package/src/runtime/ui_app_window_tests.zig +268 -0
  141. package/src/runtime/view.zig +190 -2
  142. package/src/runtime/view_widget_scroll.zig +218 -68
  143. package/src/runtime/view_widget_text.zig +11 -2
  144. package/src/runtime/view_widget_tree.zig +111 -3
  145. package/src/runtime/window_storage.zig +45 -2
  146. package/src/runtime/window_view_runtime.zig +34 -2
  147. package/src/runtime/window_views.zig +1 -0
  148. package/src/terminal_session_tests_root.zig +15 -0
  149. package/src/tooling/templates.zig +25 -7
@@ -243,15 +243,15 @@ test "runtime dispatches canvas widget scroll events for wheel and kinetic scrol
243
243
 
244
244
  try std.testing.expectEqual(@as(u32, 1), app_state.scroll_event_count);
245
245
  try std.testing.expectEqual(@as(canvas.ObjectId, 1), app_state.last_id);
246
- try std.testing.expectEqual(@as(f32, 24), app_state.last_scroll.offset);
247
- try std.testing.expectEqual(@as(f32, 72), app_state.last_scroll.viewport_extent);
248
- try std.testing.expectEqual(@as(f32, 120), app_state.last_scroll.content_extent);
249
- try std.testing.expectEqual(@as(f32, 48), app_state.last_scroll.maxOffset());
246
+ try std.testing.expectEqual(@as(f32, 24), app_state.last_scroll.offset_y);
247
+ try std.testing.expectEqual(@as(f32, 72), app_state.last_scroll.viewport_extent_y);
248
+ try std.testing.expectEqual(@as(f32, 120), app_state.last_scroll.content_extent_y);
249
+ try std.testing.expectEqual(@as(f32, 48), app_state.last_scroll.axis(.vertical).maxOffset());
250
250
 
251
251
  // The wheel left momentum; the first frame after input skips the
252
252
  // kinetic step (pending-input frame), the second one steps it and
253
253
  // delivers a fresh event with the advanced offset.
254
- try std.testing.expect(harness.runtime.views[0].widget_scroll_states[0].velocity > 0);
254
+ try std.testing.expect(harness.runtime.views[0].widget_scroll_states[0].velocity_y > 0);
255
255
  try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_frame = .{
256
256
  .window_id = 1,
257
257
  .label = "canvas",
@@ -273,10 +273,10 @@ test "runtime dispatches canvas widget scroll events for wheel and kinetic scrol
273
273
  } });
274
274
  try std.testing.expectEqual(@as(u32, 2), app_state.scroll_event_count);
275
275
  try std.testing.expectEqual(@as(canvas.ObjectId, 1), app_state.last_id);
276
- try std.testing.expect(app_state.last_scroll.offset > 24);
276
+ try std.testing.expect(app_state.last_scroll.offset_y > 24);
277
277
  try std.testing.expectEqual(
278
278
  harness.runtime.views[0].widget_layout_nodes[0].widget.value,
279
- app_state.last_scroll.offset,
279
+ app_state.last_scroll.offset_y,
280
280
  );
281
281
  }
282
282
 
@@ -398,7 +398,7 @@ test "runtime wheel input scrolls retained canvas scroll views" {
398
398
  }
399
399
  try std.testing.expect(saw_scrolled_button);
400
400
 
401
- try std.testing.expect(harness.runtime.views[0].widget_scroll_states[0].velocity > 0);
401
+ try std.testing.expect(harness.runtime.views[0].widget_scroll_states[0].velocity_y > 0);
402
402
  harness.runtime.invalidated = false;
403
403
  harness.runtime.dirty_region_count = 0;
404
404
  harness.null_platform.gpu_surface_frame_request_count = 0;
@@ -439,7 +439,7 @@ test "runtime wheel input scrolls retained canvas scroll views" {
439
439
  try std.testing.expectApproxEqAbs(@as(f32, -47.04), kinetic_layout.nodes[1].frame.y, 0.01);
440
440
  try std.testing.expectApproxEqAbs(@as(f32, -3.04), kinetic_layout.nodes[2].frame.y, 0.01);
441
441
  try std.testing.expectApproxEqAbs(@as(f32, 40.96), kinetic_layout.nodes[3].frame.y, 0.01);
442
- try std.testing.expect(harness.runtime.views[0].widget_scroll_states[0].velocity > 0);
442
+ try std.testing.expect(harness.runtime.views[0].widget_scroll_states[0].velocity_y > 0);
443
443
 
444
444
  const kinetic_display_list = try harness.runtime.canvasDisplayList(1, "canvas");
445
445
  var saw_kinetic_scrolled_button = false;
@@ -469,7 +469,7 @@ test "runtime wheel input scrolls retained canvas scroll views" {
469
469
  try std.testing.expectApproxEqAbs(@as(f32, -48), kinetic_layout.nodes[1].frame.y, 0.01);
470
470
  try std.testing.expectApproxEqAbs(@as(f32, -4), kinetic_layout.nodes[2].frame.y, 0.01);
471
471
  try std.testing.expectApproxEqAbs(@as(f32, 40), kinetic_layout.nodes[3].frame.y, 0.01);
472
- try std.testing.expectEqual(@as(f32, 0), harness.runtime.views[0].widget_scroll_states[0].velocity);
472
+ try std.testing.expectEqual(@as(f32, 0), harness.runtime.views[0].widget_scroll_states[0].velocity_y);
473
473
 
474
474
  var settle_frame: usize = 0;
475
475
  while (settle_frame < 48) : (settle_frame += 1) {
@@ -477,7 +477,7 @@ test "runtime wheel input scrolls retained canvas scroll views" {
477
477
  harness.runtime.dirty_region_count = 0;
478
478
  _ = try harness.runtime.stepCanvasWidgetKineticScroll(1, "canvas", 16);
479
479
  kinetic_layout = try harness.runtime.canvasWidgetLayout(1, "canvas");
480
- if (@abs(kinetic_layout.nodes[0].widget.value - 48) <= 0.01 and harness.runtime.views[0].widget_scroll_states[0].velocity == 0) break;
480
+ if (@abs(kinetic_layout.nodes[0].widget.value - 48) <= 0.01 and harness.runtime.views[0].widget_scroll_states[0].velocity_y == 0) break;
481
481
  }
482
482
 
483
483
  try std.testing.expect(settle_frame < 48);
@@ -485,7 +485,7 @@ test "runtime wheel input scrolls retained canvas scroll views" {
485
485
  try std.testing.expectApproxEqAbs(@as(f32, -48), kinetic_layout.nodes[1].frame.y, 0.01);
486
486
  try std.testing.expectApproxEqAbs(@as(f32, -4), kinetic_layout.nodes[2].frame.y, 0.01);
487
487
  try std.testing.expectApproxEqAbs(@as(f32, 40), kinetic_layout.nodes[3].frame.y, 0.01);
488
- try std.testing.expectEqual(@as(f32, 0), harness.runtime.views[0].widget_scroll_states[0].velocity);
488
+ try std.testing.expectEqual(@as(f32, 0), harness.runtime.views[0].widget_scroll_states[0].velocity_y);
489
489
 
490
490
  const settled_revision = harness.runtime.views[0].widget_revision;
491
491
  harness.runtime.invalidated = false;
@@ -745,13 +745,13 @@ test "runtime applies stored design token scroll physics" {
745
745
  var retained = try harness.runtime.canvasWidgetLayout(1, "canvas");
746
746
  try std.testing.expectEqual(@as(f32, 20), retained.nodes[0].widget.value);
747
747
  try std.testing.expectEqual(@as(f32, -20), retained.nodes[1].frame.y);
748
- try std.testing.expectEqual(@as(f32, 80), harness.runtime.views[0].widget_scroll_states[0].velocity);
748
+ try std.testing.expectEqual(@as(f32, 80), harness.runtime.views[0].widget_scroll_states[0].velocity_y);
749
749
 
750
750
  _ = try harness.runtime.stepCanvasWidgetKineticScroll(1, "canvas", 16);
751
751
  retained = try harness.runtime.canvasWidgetLayout(1, "canvas");
752
752
  try std.testing.expectApproxEqAbs(@as(f32, 21.28), retained.nodes[0].widget.value, 0.001);
753
753
  try std.testing.expectApproxEqAbs(@as(f32, -21.28), retained.nodes[1].frame.y, 0.001);
754
- try std.testing.expectEqual(@as(f32, 80), harness.runtime.views[0].widget_scroll_states[0].velocity);
754
+ try std.testing.expectEqual(@as(f32, 80), harness.runtime.views[0].widget_scroll_states[0].velocity_y);
755
755
  }
756
756
 
757
757
  test "runtime refreshes hovered canvas widget after scroll clipping" {
@@ -959,7 +959,7 @@ test "runtime clears focused canvas widget after kinetic scroll clipping" {
959
959
  _ = try harness.runtime.setCanvasWidgetLayout(1, "canvas", layout);
960
960
  try harness.runtime.focusView(1, "canvas");
961
961
  harness.runtime.views[0].canvas_widget_focused_id = 2;
962
- harness.runtime.views[0].widget_scroll_states[0].velocity = 2500;
962
+ harness.runtime.views[0].widget_scroll_states[0].velocity_y = 2500;
963
963
  _ = try harness.runtime.emitCanvasWidgetDisplayList(1, "canvas", .{});
964
964
 
965
965
  harness.runtime.invalidated = false;
@@ -1129,7 +1129,7 @@ test "runtime reconciles canvas widget scroll momentum across layout replacement
1129
1129
  .y = 20,
1130
1130
  .delta_y = 24,
1131
1131
  } });
1132
- try std.testing.expect(harness.runtime.views[0].widget_scroll_states[0].velocity > 0);
1132
+ try std.testing.expect(harness.runtime.views[0].widget_scroll_states[0].velocity_y > 0);
1133
1133
 
1134
1134
  const scrolled = try harness.runtime.canvasWidgetLayout(1, "canvas");
1135
1135
  const current_offset = scrolled.findById(1).?.widget.value;
@@ -1152,7 +1152,7 @@ test "runtime reconciles canvas widget scroll momentum across layout replacement
1152
1152
 
1153
1153
  const refreshed = try harness.runtime.canvasWidgetLayout(1, "canvas");
1154
1154
  try std.testing.expectEqual(@as(f32, 24), refreshed.findById(1).?.widget.value);
1155
- try std.testing.expect(harness.runtime.views[0].widget_scroll_states[2].velocity > 0);
1155
+ try std.testing.expect(harness.runtime.views[0].widget_scroll_states[2].velocity_y > 0);
1156
1156
 
1157
1157
  harness.runtime.invalidated = false;
1158
1158
  harness.runtime.dirty_region_count = 0;
@@ -1225,8 +1225,8 @@ test "runtime clamps canvas scroll offset after layout replacement shrinks conte
1225
1225
  retained = try harness.runtime.canvasWidgetLayout(1, "canvas");
1226
1226
  try std.testing.expectEqual(@as(f32, 0), retained.findById(1).?.widget.value);
1227
1227
  try std.testing.expectEqual(@as(f32, 0), retained.findById(2).?.frame.y);
1228
- try std.testing.expectEqual(@as(f32, 0), harness.runtime.views[0].widget_scroll_states[0].offset);
1229
- try std.testing.expectEqual(@as(f32, 0), harness.runtime.views[0].widget_scroll_states[0].velocity);
1228
+ try std.testing.expectEqual(@as(f32, 0), harness.runtime.views[0].widget_scroll_states[0].offset_y);
1229
+ try std.testing.expectEqual(@as(f32, 0), harness.runtime.views[0].widget_scroll_states[0].velocity_y);
1230
1230
 
1231
1231
  const snapshot = harness.runtime.automationSnapshot("Widgets");
1232
1232
  try std.testing.expectEqual(@as(usize, 2), snapshot.widgets.len);
@@ -1324,8 +1324,8 @@ test "runtime chains wheel input from saturated nested canvas scroll views" {
1324
1324
  try std.testing.expectEqualDeep(geometry.RectF.init(0, -60, 180, 32), retained.nodes[2].frame);
1325
1325
  try std.testing.expectEqualDeep(geometry.RectF.init(0, -16, 180, 32), retained.nodes[3].frame);
1326
1326
  try std.testing.expectEqualDeep(geometry.RectF.init(0, 96, 180, 32), retained.nodes[4].frame);
1327
- try std.testing.expect(harness.runtime.views[0].widget_scroll_states[0].velocity > 0);
1328
- try std.testing.expectEqual(@as(f32, 0), harness.runtime.views[0].widget_scroll_states[1].velocity);
1327
+ try std.testing.expect(harness.runtime.views[0].widget_scroll_states[0].velocity_y > 0);
1328
+ try std.testing.expectEqual(@as(f32, 0), harness.runtime.views[0].widget_scroll_states[1].velocity_y);
1329
1329
  }
1330
1330
 
1331
1331
  test "runtime leaves virtualized canvas scroll views app driven" {
@@ -1534,8 +1534,8 @@ test "engine wheel scrolls a windowed virtual list against its declared extent"
1534
1534
  // The scroll state reports the DECLARED virtual extent (1000 x 20),
1535
1535
  // not the four mounted rows.
1536
1536
  const state = harness.runtime.views[0].canvasWidgetScrollStateById(1).?;
1537
- try std.testing.expectEqual(@as(f32, 20_000), state.content_extent);
1538
- try std.testing.expectEqual(@as(f32, 64), state.viewport_extent);
1537
+ try std.testing.expectEqual(@as(f32, 20_000), state.content_extent_y);
1538
+ try std.testing.expectEqual(@as(f32, 64), state.viewport_extent_y);
1539
1539
 
1540
1540
  // A rebuild whose source offset overshoots the end clamps against
1541
1541
  // the virtual extent (max offset 20_000 - 64).
@@ -1547,3 +1547,415 @@ test "engine wheel scrolls a windowed virtual list against its declared extent"
1547
1547
  retained = try harness.runtime.canvasWidgetLayout(1, "canvas");
1548
1548
  try std.testing.expectEqual(@as(f32, 19_936), retained.findById(1).?.widget.value);
1549
1549
  }
1550
+
1551
+ test "runtime wheel delta_x scrolls a horizontal scroll view and quiets its vertical axis" {
1552
+ const TestApp = struct {
1553
+ scroll_event_count: u32 = 0,
1554
+ last_scroll: canvas.ScrollState = .{},
1555
+
1556
+ fn app(self: *@This()) App {
1557
+ return .{ .context = self, .name = "gpu-widget-horizontal-scroll", .source = platform.WebViewSource.html("<h1>Hello</h1>"), .event_fn = event };
1558
+ }
1559
+
1560
+ fn event(context: *anyopaque, runtime: *Runtime, event_value: Event) anyerror!void {
1561
+ _ = runtime;
1562
+ const self: *@This() = @ptrCast(@alignCast(context));
1563
+ switch (event_value) {
1564
+ .canvas_widget_scroll => |scroll_event| {
1565
+ self.scroll_event_count += 1;
1566
+ self.last_scroll = scroll_event.scroll;
1567
+ },
1568
+ else => {},
1569
+ }
1570
+ }
1571
+ };
1572
+
1573
+ const harness = try TestHarness().create(std.testing.allocator, .{});
1574
+ defer harness.destroy(std.testing.allocator);
1575
+ harness.null_platform.gpu_surfaces = true;
1576
+ var app_state: TestApp = .{};
1577
+ const app = app_state.app();
1578
+ try harness.start(app);
1579
+
1580
+ _ = try harness.runtime.createView(.{
1581
+ .window_id = 1,
1582
+ .label = "canvas",
1583
+ .kind = .gpu_surface,
1584
+ .frame = geometry.RectF.init(10, 20, 180, 72),
1585
+ });
1586
+
1587
+ // A shelf: three fixed-width tiles in a row, reaching x = 460 inside
1588
+ // a 180-wide viewport (max horizontal offset 280).
1589
+ const tiles = [_]canvas.Widget{
1590
+ .{ .id = 2, .kind = .panel, .frame = geometry.RectF.init(0, 0, 140, 60) },
1591
+ .{ .id = 3, .kind = .panel, .frame = geometry.RectF.init(160, 0, 140, 60) },
1592
+ .{ .id = 4, .kind = .panel, .frame = geometry.RectF.init(320, 0, 140, 60) },
1593
+ };
1594
+ const shelf = canvas.Widget{
1595
+ .id = 1,
1596
+ .kind = .scroll_view,
1597
+ .scroll_axes = .horizontal,
1598
+ .children = &tiles,
1599
+ };
1600
+ var nodes: [5]canvas.WidgetLayoutNode = undefined;
1601
+ const layout = try canvas.layoutWidgetTree(shelf, geometry.RectF.init(0, 0, 180, 72), &nodes);
1602
+ _ = try harness.runtime.setCanvasWidgetLayout(1, "canvas", layout);
1603
+
1604
+ // A diagonal wheel: delta_x scrolls the shelf, delta_y dies (the
1605
+ // region grants no vertical axis).
1606
+ try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_input = .{
1607
+ .window_id = 1,
1608
+ .label = "canvas",
1609
+ .timestamp_ns = 1_000_000_000,
1610
+ .kind = .scroll,
1611
+ .x = 20,
1612
+ .y = 20,
1613
+ .delta_x = 24,
1614
+ .delta_y = 16,
1615
+ } });
1616
+
1617
+ const retained = try harness.runtime.canvasWidgetLayout(1, "canvas");
1618
+ try std.testing.expectEqual(@as(f32, 24), retained.findById(1).?.widget.value_x);
1619
+ try std.testing.expectEqual(@as(f32, 0), retained.findById(1).?.widget.value);
1620
+ try std.testing.expectEqualDeep(geometry.RectF.init(-24, 0, 140, 60), retained.findById(2).?.frame);
1621
+ try std.testing.expectEqualDeep(geometry.RectF.init(136, 0, 140, 60), retained.findById(3).?.frame);
1622
+
1623
+ // The observation delivers the two-axis state: a live horizontal
1624
+ // axis and a QUIET vertical one (content pinned to the viewport).
1625
+ try std.testing.expectEqual(@as(u32, 1), app_state.scroll_event_count);
1626
+ try std.testing.expectEqual(@as(f32, 24), app_state.last_scroll.offset_x);
1627
+ try std.testing.expectEqual(@as(f32, 180), app_state.last_scroll.viewport_extent_x);
1628
+ try std.testing.expectEqual(@as(f32, 460), app_state.last_scroll.content_extent_x);
1629
+ try std.testing.expectEqual(@as(f32, 0), app_state.last_scroll.offset_y);
1630
+ try std.testing.expectEqual(@as(f32, 72), app_state.last_scroll.content_extent_y);
1631
+ try std.testing.expectEqual(@as(f32, 0), app_state.last_scroll.axis(.vertical).maxOffset());
1632
+
1633
+ // The wheel left horizontal momentum for the kinetic stepper.
1634
+ try std.testing.expect(harness.runtime.views[0].widget_scroll_states[0].velocity_x > 0);
1635
+ try std.testing.expectEqual(@as(f32, 0), harness.runtime.views[0].widget_scroll_states[0].velocity_y);
1636
+ try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_frame = .{
1637
+ .window_id = 1,
1638
+ .label = "canvas",
1639
+ .size = geometry.SizeF.init(180, 72),
1640
+ .scale_factor = 1,
1641
+ .frame_index = 1,
1642
+ .timestamp_ns = 1_016_000_000,
1643
+ .frame_interval_ns = 16_000_000,
1644
+ } });
1645
+ try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_frame = .{
1646
+ .window_id = 1,
1647
+ .label = "canvas",
1648
+ .size = geometry.SizeF.init(180, 72),
1649
+ .scale_factor = 1,
1650
+ .frame_index = 2,
1651
+ .timestamp_ns = 1_032_000_000,
1652
+ .frame_interval_ns = 16_000_000,
1653
+ } });
1654
+ const stepped = try harness.runtime.canvasWidgetLayout(1, "canvas");
1655
+ try std.testing.expect(stepped.findById(1).?.widget.value_x > 24);
1656
+ try std.testing.expectEqual(@as(f32, 0), stepped.findById(1).?.widget.value);
1657
+ }
1658
+
1659
+ test "nested regions route each wheel axis to the nearest ancestor scrolling that axis" {
1660
+ const TestApp = struct {
1661
+ fn app(self: *@This()) App {
1662
+ return .{ .context = self, .name = "gpu-widget-nested-axis-routing", .source = platform.WebViewSource.html("<h1>Hello</h1>") };
1663
+ }
1664
+ };
1665
+
1666
+ const harness = try TestHarness().create(std.testing.allocator, .{});
1667
+ defer harness.destroy(std.testing.allocator);
1668
+ harness.null_platform.gpu_surfaces = true;
1669
+ var app_state: TestApp = .{};
1670
+ const app = app_state.app();
1671
+ try harness.start(app);
1672
+
1673
+ _ = try harness.runtime.createView(.{
1674
+ .window_id = 1,
1675
+ .label = "canvas",
1676
+ .kind = .gpu_surface,
1677
+ .frame = geometry.RectF.init(10, 20, 180, 72),
1678
+ });
1679
+
1680
+ // The reported nested shape: a HORIZONTAL timeline (id 1) holding a
1681
+ // VERTICAL list (id 2) whose rows overflow its height. The wheel
1682
+ // lands over the list.
1683
+ const rows = [_]canvas.Widget{
1684
+ .{ .id = 3, .kind = .button, .frame = geometry.RectF.init(0, 0, 120, 32), .text = "One" },
1685
+ .{ .id = 4, .kind = .button, .frame = geometry.RectF.init(0, 44, 120, 32), .text = "Two" },
1686
+ .{ .id = 5, .kind = .button, .frame = geometry.RectF.init(0, 88, 120, 32), .text = "Three" },
1687
+ };
1688
+ const inner = canvas.Widget{
1689
+ .id = 2,
1690
+ .kind = .scroll_view,
1691
+ .frame = geometry.RectF.init(0, 0, 120, 72),
1692
+ .children = &rows,
1693
+ };
1694
+ const spacer = canvas.Widget{ .id = 6, .kind = .panel, .frame = geometry.RectF.init(130, 0, 300, 60) };
1695
+ const timeline = canvas.Widget{
1696
+ .id = 1,
1697
+ .kind = .scroll_view,
1698
+ .scroll_axes = .horizontal,
1699
+ .children = &.{ inner, spacer },
1700
+ };
1701
+ var nodes: [8]canvas.WidgetLayoutNode = undefined;
1702
+ const layout = try canvas.layoutWidgetTree(timeline, geometry.RectF.init(0, 0, 180, 72), &nodes);
1703
+ _ = try harness.runtime.setCanvasWidgetLayout(1, "canvas", layout);
1704
+
1705
+ // One diagonal gesture over the inner list: delta_y scrolls the
1706
+ // LIST (the nearest vertical scrollable), delta_x passes through it
1707
+ // to the TIMELINE (the nearest horizontal scrollable).
1708
+ try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_input = .{
1709
+ .window_id = 1,
1710
+ .label = "canvas",
1711
+ .timestamp_ns = 1_000_000_000,
1712
+ .kind = .scroll,
1713
+ .x = 20,
1714
+ .y = 20,
1715
+ .delta_x = 30,
1716
+ .delta_y = 24,
1717
+ } });
1718
+
1719
+ var retained = try harness.runtime.canvasWidgetLayout(1, "canvas");
1720
+ try std.testing.expectEqual(@as(f32, 24), retained.findById(2).?.widget.value);
1721
+ try std.testing.expectEqual(@as(f32, 0), retained.findById(2).?.widget.value_x);
1722
+ try std.testing.expectEqual(@as(f32, 30), retained.findById(1).?.widget.value_x);
1723
+ try std.testing.expectEqual(@as(f32, 0), retained.findById(1).?.widget.value);
1724
+ // The list's rows moved UP by the consumed delta_y AND left by the
1725
+ // timeline's consumed delta_x (the list itself rides the timeline).
1726
+ try std.testing.expectEqualDeep(geometry.RectF.init(-30, -24, 120, 32), retained.findById(3).?.frame);
1727
+
1728
+ // A purely horizontal follow-up over the same point keeps the list
1729
+ // still and moves only the timeline.
1730
+ try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_input = .{
1731
+ .window_id = 1,
1732
+ .label = "canvas",
1733
+ .timestamp_ns = 1_032_000_000,
1734
+ .kind = .scroll,
1735
+ .x = 20,
1736
+ .y = 20,
1737
+ .delta_x = 10,
1738
+ } });
1739
+ retained = try harness.runtime.canvasWidgetLayout(1, "canvas");
1740
+ try std.testing.expectEqual(@as(f32, 24), retained.findById(2).?.widget.value);
1741
+ try std.testing.expectEqual(@as(f32, 40), retained.findById(1).?.widget.value_x);
1742
+ }
1743
+
1744
+ test "horizontal-only scroll views take the whole keymap on their one axis" {
1745
+ const TestApp = struct {
1746
+ fn app(self: *@This()) App {
1747
+ return .{ .context = self, .name = "gpu-widget-horizontal-keymap", .source = platform.WebViewSource.html("<h1>Hello</h1>") };
1748
+ }
1749
+ };
1750
+
1751
+ const harness = try TestHarness().create(std.testing.allocator, .{});
1752
+ defer harness.destroy(std.testing.allocator);
1753
+ harness.null_platform.gpu_surfaces = true;
1754
+ var app_state: TestApp = .{};
1755
+ const app = app_state.app();
1756
+ try harness.start(app);
1757
+
1758
+ _ = try harness.runtime.createView(.{
1759
+ .window_id = 1,
1760
+ .label = "canvas",
1761
+ .kind = .gpu_surface,
1762
+ .frame = geometry.RectF.init(10, 20, 180, 72),
1763
+ });
1764
+
1765
+ const tiles = [_]canvas.Widget{
1766
+ .{ .id = 2, .kind = .panel, .frame = geometry.RectF.init(0, 0, 140, 60) },
1767
+ .{ .id = 3, .kind = .panel, .frame = geometry.RectF.init(160, 0, 140, 60) },
1768
+ .{ .id = 4, .kind = .panel, .frame = geometry.RectF.init(320, 0, 140, 60) },
1769
+ };
1770
+ const shelf = canvas.Widget{
1771
+ .id = 1,
1772
+ .kind = .scroll_view,
1773
+ .scroll_axes = .horizontal,
1774
+ .children = &tiles,
1775
+ };
1776
+ var nodes: [5]canvas.WidgetLayoutNode = undefined;
1777
+ const layout = try canvas.layoutWidgetTree(shelf, geometry.RectF.init(0, 0, 180, 72), &nodes);
1778
+ _ = try harness.runtime.setCanvasWidgetLayout(1, "canvas", layout);
1779
+ try harness.runtime.focusView(1, "canvas");
1780
+ harness.runtime.views[0].canvas_widget_focused_id = 1;
1781
+
1782
+ // ArrowRight steps a line on the ONE axis the region grants: the
1783
+ // viewport-width-derived step (max(24, 180 * 0.35) = 63).
1784
+ try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_input = .{
1785
+ .window_id = 1,
1786
+ .label = "canvas",
1787
+ .kind = .key_down,
1788
+ .key = "arrowright",
1789
+ } });
1790
+ var retained = try harness.runtime.canvasWidgetLayout(1, "canvas");
1791
+ try std.testing.expectEqual(@as(f32, 63), retained.findById(1).?.widget.value_x);
1792
+ try std.testing.expectEqual(@as(f32, 0), retained.findById(1).?.widget.value);
1793
+
1794
+ // End jumps to the horizontal terminus (content 460 - viewport 180).
1795
+ try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_input = .{
1796
+ .window_id = 1,
1797
+ .label = "canvas",
1798
+ .kind = .key_down,
1799
+ .key = "end",
1800
+ } });
1801
+ retained = try harness.runtime.canvasWidgetLayout(1, "canvas");
1802
+ try std.testing.expectEqual(@as(f32, 280), retained.findById(1).?.widget.value_x);
1803
+ try std.testing.expectEqualDeep(geometry.RectF.init(-280, 0, 140, 60), retained.findById(2).?.frame);
1804
+
1805
+ // Home returns to the origin.
1806
+ try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_input = .{
1807
+ .window_id = 1,
1808
+ .label = "canvas",
1809
+ .kind = .key_down,
1810
+ .key = "home",
1811
+ } });
1812
+ retained = try harness.runtime.canvasWidgetLayout(1, "canvas");
1813
+ try std.testing.expectEqual(@as(f32, 0), retained.findById(1).?.widget.value_x);
1814
+ try std.testing.expectEqualDeep(geometry.RectF.init(0, 0, 140, 60), retained.findById(2).?.frame);
1815
+ }
1816
+
1817
+ test "horizontal content extent counts only honestly reachable descendants" {
1818
+ const TestApp = struct {
1819
+ fn app(self: *@This()) App {
1820
+ return .{ .context = self, .name = "gpu-widget-horizontal-extent", .source = platform.WebViewSource.html("<h1>Hello</h1>") };
1821
+ }
1822
+ };
1823
+
1824
+ const harness = try TestHarness().create(std.testing.allocator, .{});
1825
+ defer harness.destroy(std.testing.allocator);
1826
+ harness.null_platform.gpu_surfaces = true;
1827
+ var app_state: TestApp = .{};
1828
+ try harness.start(app_state.app());
1829
+
1830
+ _ = try harness.runtime.createView(.{
1831
+ .window_id = 1,
1832
+ .label = "canvas",
1833
+ .kind = .gpu_surface,
1834
+ .frame = geometry.RectF.init(10, 20, 180, 72),
1835
+ });
1836
+
1837
+ // Hand-built pre-order layout under a horizontal region (id 1):
1838
+ // - a NESTED CLIP SCOPE (scroll view, id 2) whose clipped child
1839
+ // (id 3) reaches x = 500: the scope's own 120-wide frame is how
1840
+ // far it reaches;
1841
+ // - an ANCHORED floating surface (id 4) at x = 500..800: out of
1842
+ // flow, window-clipped, never scrollable range;
1843
+ // - a CLOSED accordion (id 5) whose concealed child (id 6)
1844
+ // reaches x = 600: unreachable sideways;
1845
+ // - an OPEN (settled) accordion (id 7) whose live child (id 8)
1846
+ // reaches x = 460: the honest rightmost reach.
1847
+ const nodes = [_]canvas.WidgetLayoutNode{
1848
+ .{ .widget = .{ .id = 1, .kind = .scroll_view, .scroll_axes = .horizontal, .frame = geometry.RectF.init(0, 0, 180, 72) }, .frame = geometry.RectF.init(0, 0, 180, 72), .depth = 0 },
1849
+ .{ .widget = .{ .id = 2, .kind = .scroll_view, .frame = geometry.RectF.init(0, 0, 120, 60) }, .frame = geometry.RectF.init(0, 0, 120, 60), .depth = 1, .parent_index = 0 },
1850
+ .{ .widget = .{ .id = 3, .kind = .panel, .frame = geometry.RectF.init(0, 0, 500, 40) }, .frame = geometry.RectF.init(0, 0, 500, 40), .depth = 2, .parent_index = 1 },
1851
+ .{ .widget = .{ .id = 4, .kind = .panel, .frame = geometry.RectF.init(500, 0, 300, 40), .layout = .{ .anchor = .{ .placement = .below } } }, .frame = geometry.RectF.init(500, 0, 300, 40), .depth = 1, .parent_index = 0 },
1852
+ .{ .widget = .{ .id = 5, .kind = .accordion, .frame = geometry.RectF.init(0, 0, 160, 40), .state = .{ .selected = false } }, .frame = geometry.RectF.init(0, 0, 160, 40), .depth = 1, .parent_index = 0 },
1853
+ .{ .widget = .{ .id = 6, .kind = .panel, .frame = geometry.RectF.init(8, 44, 600, 20) }, .frame = geometry.RectF.init(8, 44, 600, 20), .depth = 2, .parent_index = 4 },
1854
+ .{ .widget = .{ .id = 7, .kind = .accordion, .frame = geometry.RectF.init(0, 0, 200, 72), .state = .{ .selected = true } }, .frame = geometry.RectF.init(0, 0, 200, 72), .depth = 1, .parent_index = 0 },
1855
+ .{ .widget = .{ .id = 8, .kind = .panel, .frame = geometry.RectF.init(8, 40, 452, 20) }, .frame = geometry.RectF.init(8, 40, 452, 20), .depth = 2, .parent_index = 6 },
1856
+ };
1857
+ _ = try harness.runtime.setCanvasWidgetLayout(1, "canvas", .{ .nodes = &nodes });
1858
+
1859
+ const state = harness.runtime.views[0].canvasWidgetScrollStateById(1).?;
1860
+ try std.testing.expectEqual(@as(f32, 460), state.content_extent_x);
1861
+ try std.testing.expectEqual(@as(f32, 180), state.viewport_extent_x);
1862
+ }
1863
+
1864
+ test "a surface anchored to the scroll region itself never rides its content" {
1865
+ const TestApp = struct {
1866
+ fn app(self: *@This()) App {
1867
+ return .{ .context = self, .name = "gpu-widget-anchored-scroll", .source = platform.WebViewSource.html("<h1>Hello</h1>") };
1868
+ }
1869
+ };
1870
+
1871
+ const harness = try TestHarness().create(std.testing.allocator, .{});
1872
+ defer harness.destroy(std.testing.allocator);
1873
+ harness.null_platform.gpu_surfaces = true;
1874
+ var app_state: TestApp = .{};
1875
+ const app = app_state.app();
1876
+ try harness.start(app);
1877
+
1878
+ _ = try harness.runtime.createView(.{
1879
+ .window_id = 1,
1880
+ .label = "canvas",
1881
+ .kind = .gpu_surface,
1882
+ .frame = geometry.RectF.init(10, 20, 180, 72),
1883
+ });
1884
+
1885
+ // A vertical region with tall content (id 2), a surface anchored to
1886
+ // the REGION ITSELF (id 3 — its anchor base never moves when the
1887
+ // content does), and a surface anchored to a widget INSIDE the
1888
+ // content (id 4 — its anchor base scrolls, so it rides along).
1889
+ const nodes = [_]canvas.WidgetLayoutNode{
1890
+ .{ .widget = .{ .id = 1, .kind = .scroll_view, .frame = geometry.RectF.init(0, 0, 180, 72) }, .frame = geometry.RectF.init(0, 0, 180, 72), .depth = 0 },
1891
+ .{ .widget = .{ .id = 2, .kind = .panel, .frame = geometry.RectF.init(0, 0, 160, 200) }, .frame = geometry.RectF.init(0, 0, 160, 200), .depth = 1, .parent_index = 0 },
1892
+ .{ .widget = .{ .id = 4, .kind = .popover, .frame = geometry.RectF.init(20, 40, 100, 30), .layout = .{ .anchor = .{ .placement = .below } } }, .frame = geometry.RectF.init(20, 40, 100, 30), .depth = 2, .parent_index = 1 },
1893
+ .{ .widget = .{ .id = 3, .kind = .popover, .frame = geometry.RectF.init(10, 72, 100, 30), .layout = .{ .anchor = .{ .placement = .below } } }, .frame = geometry.RectF.init(10, 72, 100, 30), .depth = 1, .parent_index = 0 },
1894
+ };
1895
+ _ = try harness.runtime.setCanvasWidgetLayout(1, "canvas", .{ .nodes = &nodes });
1896
+
1897
+ try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_input = .{
1898
+ .window_id = 1,
1899
+ .label = "canvas",
1900
+ .timestamp_ns = 1_000_000_000,
1901
+ .kind = .scroll,
1902
+ .x = 20,
1903
+ .y = 20,
1904
+ .delta_y = 24,
1905
+ } });
1906
+
1907
+ const retained = try harness.runtime.canvasWidgetLayout(1, "canvas");
1908
+ try std.testing.expectEqual(@as(f32, 24), retained.findById(1).?.widget.value);
1909
+ // Content and the content-anchored surface moved up together...
1910
+ try std.testing.expectEqualDeep(geometry.RectF.init(0, -24, 160, 200), retained.findById(2).?.frame);
1911
+ try std.testing.expectEqualDeep(geometry.RectF.init(20, 16, 100, 30), retained.findById(4).?.frame);
1912
+ // ...while the region-anchored surface stayed put.
1913
+ try std.testing.expectEqualDeep(geometry.RectF.init(10, 72, 100, 30), retained.findById(3).?.frame);
1914
+ }
1915
+
1916
+ test "assistive steps on a both-axes region page its live axis" {
1917
+ const TestApp = struct {
1918
+ fn app(self: *@This()) App {
1919
+ return .{ .context = self, .name = "gpu-widget-both-axes-step", .source = platform.WebViewSource.html("<h1>Hello</h1>") };
1920
+ }
1921
+ };
1922
+
1923
+ const harness = try TestHarness().create(std.testing.allocator, .{});
1924
+ defer harness.destroy(std.testing.allocator);
1925
+ harness.null_platform.gpu_surfaces = true;
1926
+ var app_state: TestApp = .{};
1927
+ const app = app_state.app();
1928
+ try harness.start(app);
1929
+
1930
+ _ = try harness.runtime.createView(.{
1931
+ .window_id = 1,
1932
+ .label = "canvas",
1933
+ .kind = .gpu_surface,
1934
+ .frame = geometry.RectF.init(10, 20, 180, 72),
1935
+ });
1936
+
1937
+ // A BOTH-axes region whose content only overflows SIDEWAYS: the
1938
+ // assistive increment must move the live (horizontal) axis instead
1939
+ // of paging the zero-range vertical one and reporting success.
1940
+ const sheet = canvas.Widget{
1941
+ .id = 1,
1942
+ .kind = .scroll_view,
1943
+ .scroll_axes = .both,
1944
+ .children = &[_]canvas.Widget{.{ .id = 2, .kind = .panel, .frame = geometry.RectF.init(0, 0, 500, 60) }},
1945
+ };
1946
+ var nodes: [3]canvas.WidgetLayoutNode = undefined;
1947
+ const layout = try canvas.layoutWidgetTree(sheet, geometry.RectF.init(0, 0, 180, 72), &nodes);
1948
+ _ = try harness.runtime.setCanvasWidgetLayout(1, "canvas", layout);
1949
+ try harness.runtime.focusView(1, "canvas");
1950
+ harness.runtime.views[0].canvas_widget_focused_id = 1;
1951
+
1952
+ try dispatchAutomationWidgetAction(&harness.runtime, app, .{ .view_label = "canvas", .id = 1, .action = .increment });
1953
+ var retained = try harness.runtime.canvasWidgetLayout(1, "canvas");
1954
+ // The both-keymap's horizontal line step: max(24, 180 * 0.35) = 63.
1955
+ try std.testing.expectEqual(@as(f32, 63), retained.findById(1).?.widget.value_x);
1956
+ try std.testing.expectEqual(@as(f32, 0), retained.findById(1).?.widget.value);
1957
+
1958
+ try dispatchAutomationWidgetAction(&harness.runtime, app, .{ .view_label = "canvas", .id = 1, .action = .decrement });
1959
+ retained = try harness.runtime.canvasWidgetLayout(1, "canvas");
1960
+ try std.testing.expectEqual(@as(f32, 0), retained.findById(1).?.widget.value_x);
1961
+ }
@@ -147,6 +147,12 @@ pub fn RuntimeCanvasWidgetState(comptime Runtime: type) type {
147
147
  const disclosure_plan = planCanvasWidgetDisclosureTween(self, index, previous_layout, reconciled_layout);
148
148
  const previous_cursor = self.views[index].canvas_widget_cursor;
149
149
  const previous_widget_revision = self.views[index].widget_revision;
150
+ // The adoption witness (`canvas_widget_layout_adoptions`)
151
+ // moves INSIDE the copy, at its destructive boundary: a
152
+ // per-node failure mid-copy leaves a torn retained tree
153
+ // that hover currency must treat as adopted-and-stale,
154
+ // while the copy's up-front validation rejects with the
155
+ // witness unmoved.
150
156
  try self.views[index].copyWidgetLayoutTree(reconciled_layout, &self.canvas_widget_copy_scratch);
151
157
  try self.views[index].copyCanvasWidgetSourceText(layout);
152
158
  self.views[index].copyCanvasWidgetSourceScroll(layout);
@@ -2012,7 +2012,7 @@ test "a widget text budget overflow on input degrades instead of exiting" {
2012
2012
  try std.testing.expectEqual(filler.len, retained.nodes[1].widget.text.len);
2013
2013
  const errors = harness.runtime.dispatchErrors();
2014
2014
  try std.testing.expect(errors.len >= 1);
2015
- try std.testing.expectEqualStrings("gpu_surface_input", errors[errors.len - 1].event);
2015
+ try std.testing.expectEqualStrings("gpu_surface_input", errors[errors.len - 1].event());
2016
2016
  try std.testing.expectEqualStrings("WidgetTextTooLarge", errors[errors.len - 1].error_name);
2017
2017
 
2018
2018
  // The next interaction dispatches clean.