@native-sdk/cli 0.8.3 → 0.9.0

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 (188) hide show
  1. package/build/app.zig +905 -61
  2. package/build.zig +674 -373
  3. package/build.zig.zon +1 -0
  4. package/native-sdk.d.ts +6 -0
  5. package/package.json +12 -11
  6. package/packages/core/compile-surface/core.ts +455 -3
  7. package/packages/core/package-lock.json +11 -11
  8. package/packages/core/package.json +2 -2
  9. package/packages/core/scripts/compiler_typecheck.mjs +116 -15
  10. package/packages/core/scripts/gen_service_surface.mjs +268 -0
  11. package/packages/core/scripts/npm_static_spike.mjs +64 -0
  12. package/packages/core/scripts/run_external_core_compiler.mjs +77 -6
  13. package/packages/core/scripts/run_external_service_compiler.mjs +240 -0
  14. package/packages/core/scripts/stage_external_core.mjs +9 -1
  15. package/packages/core/scripts/stage_external_services.mjs +172 -0
  16. package/packages/core/scripts/surface_manifest_diff.mjs +253 -0
  17. package/packages/core/scripts/vendor_service_packages.mjs +189 -0
  18. package/packages/core/sdk/core.d.ts +214 -2
  19. package/packages/core/sdk/core.ts +715 -42
  20. package/packages/core/sdk/events.d.ts +50 -0
  21. package/packages/core/sdk/events.ts +75 -0
  22. package/packages/core/src/checker.ts +528 -15
  23. package/packages/core/src/cli.ts +143 -3
  24. package/packages/core/src/contract.ts +26 -5
  25. package/packages/core/src/devhost.ts +1849 -18
  26. package/packages/core/src/devhost_journal.mjs +181 -0
  27. package/packages/core/src/devhost_resolver.mjs +17 -1
  28. package/packages/core/src/devhost_service_worker.mjs +90 -0
  29. package/packages/core/src/diagnostics.ts +84 -18
  30. package/packages/core/src/frontend.ts +204 -34
  31. package/packages/core/src/modules.ts +129 -80
  32. package/packages/core/src/service_contract.ts +597 -0
  33. package/packages/core/src/sqlite_cli.ts +93 -0
  34. package/packages/core/src/sqlite_codegen.ts +806 -0
  35. package/packages/core/src/sqlite_runtime_policy.ts +364 -0
  36. package/packages/core/src/typed_ast.ts +36 -8
  37. package/skill-data/core/SKILL.md +4 -2
  38. package/skill-data/core/references/project-anatomy.md +3 -2
  39. package/skill-data/core/references/web-engines-packaging-debugging.md +3 -1
  40. package/skill-data/native-ui/SKILL.md +55 -8
  41. package/skill-data/ts-core/SKILL.md +92 -40
  42. package/skill-data/ts-services/SKILL.md +126 -0
  43. package/skill-data/ts-services/references/service-surface.md +603 -0
  44. package/skill-data/zig/SKILL.md +1 -1
  45. package/skills/native-sdk/SKILL.md +1 -1
  46. package/src/app_runner/no_migrations.zig +3 -0
  47. package/src/app_runner/no_services.zig +20 -0
  48. package/src/app_runner/root.zig +104 -4
  49. package/src/app_runner/ts_core_main.zig +268 -4
  50. package/src/automation/snapshot.zig +23 -5
  51. package/src/embed/app_exports.zig +11 -1
  52. package/src/embed/c_api.zig +48 -2
  53. package/src/embed/conversions.zig +4 -5
  54. package/src/embed/host.zig +115 -1
  55. package/src/embed/root.zig +7 -0
  56. package/src/embed/tests.zig +213 -0
  57. package/src/embed/types.zig +51 -0
  58. package/src/embed/ui_host.zig +121 -5
  59. package/src/platform/android/NativeSdkActivity.java +131 -0
  60. package/src/platform/android/android_host.c +182 -1
  61. package/src/platform/android/native_sdk_app.h +17 -0
  62. package/src/platform/ios/native_sdk_app.h +17 -0
  63. package/src/platform/ios/uikit_host.m +115 -0
  64. package/src/platform/linux/cef_host.cpp +1 -1
  65. package/src/platform/linux/gtk_host.c +89 -17
  66. package/src/platform/linux/gtk_host.h +3 -0
  67. package/src/platform/linux/root.zig +41 -18
  68. package/src/platform/macos/appkit_host.h +26 -3
  69. package/src/platform/macos/appkit_host.m +1051 -129
  70. package/src/platform/macos/capture_info_plist.c +25 -0
  71. package/src/platform/macos/cef_host.mm +270 -36
  72. package/src/platform/macos/root.zig +312 -34
  73. package/src/platform/null_platform.zig +281 -19
  74. package/src/platform/null_platform_tests.zig +74 -0
  75. package/src/platform/root.zig +16 -0
  76. package/src/platform/types.zig +279 -15
  77. package/src/platform/windows/root.zig +243 -21
  78. package/src/platform/windows/webview2_host.cpp +464 -46
  79. package/src/primitives/app_manifest/comptime_scene.zig +2 -0
  80. package/src/primitives/app_manifest/root.zig +4 -0
  81. package/src/primitives/app_manifest/tests.zig +3 -0
  82. package/src/primitives/app_manifest/types.zig +34 -0
  83. package/src/primitives/app_manifest/validation.zig +19 -1
  84. package/src/primitives/canvas/code_tests.zig +9 -9
  85. package/src/primitives/canvas/events.zig +12 -11
  86. package/src/primitives/canvas/frame.zig +44 -9
  87. package/src/primitives/canvas/icons/mic.svg +1 -0
  88. package/src/primitives/canvas/icons.zig +2 -0
  89. package/src/primitives/canvas/root.zig +8 -0
  90. package/src/primitives/canvas/text_span_tests.zig +39 -0
  91. package/src/primitives/canvas/ui.zig +23 -4
  92. package/src/primitives/canvas/ui_markup.zig +15 -0
  93. package/src/primitives/canvas/ui_markup_compiled.zig +9 -0
  94. package/src/primitives/canvas/ui_markup_compiled_tests.zig +1 -1
  95. package/src/primitives/canvas/ui_markup_tests.zig +5 -0
  96. package/src/primitives/canvas/ui_markup_view.zig +9 -0
  97. package/src/primitives/canvas/ui_markup_view_tests.zig +9 -6
  98. package/src/primitives/canvas/ui_schema.zig +19 -10
  99. package/src/primitives/canvas/ui_schema_tests.zig +5 -3
  100. package/src/primitives/canvas/ui_tests.zig +18 -4
  101. package/src/primitives/canvas/widget_invalidation.zig +9 -2
  102. package/src/primitives/canvas/widget_render.zig +296 -114
  103. package/src/primitives/canvas/widget_runtime_tests.zig +133 -0
  104. package/src/primitives/canvas/widget_text_input.zig +10 -10
  105. package/src/primitives/canvas/widget_tree.zig +1 -1
  106. package/src/primitives/canvas/widgets.zig +29 -5
  107. package/src/root.zig +56 -0
  108. package/src/runtime/api.zig +11 -0
  109. package/src/runtime/automation_snapshot.zig +4 -0
  110. package/src/runtime/automation_widget_dispatch.zig +1 -0
  111. package/src/runtime/bridge_payload.zig +2 -0
  112. package/src/runtime/bridge_permission_tests.zig +23 -2
  113. package/src/runtime/bridge_responses.zig +3 -1
  114. package/src/runtime/canvas_frame.zig +31 -13
  115. package/src/runtime/canvas_frame_animation_tests.zig +4 -0
  116. package/src/runtime/canvas_frame_invalidation_tests.zig +35 -10
  117. package/src/runtime/canvas_widget_anchored_tests.zig +83 -0
  118. package/src/runtime/canvas_widget_events.zig +69 -24
  119. package/src/runtime/canvas_widget_runtime.zig +101 -6
  120. package/src/runtime/canvas_widget_scroll_driver_tests.zig +47 -4
  121. package/src/runtime/canvas_widget_scroll_drivers.zig +3 -3
  122. package/src/runtime/canvas_widget_semantics_tests.zig +2 -0
  123. package/src/runtime/canvas_widget_split_tree_tests.zig +228 -0
  124. package/src/runtime/canvas_widget_state.zig +6 -1
  125. package/src/runtime/canvas_widget_text_tests.zig +112 -3
  126. package/src/runtime/clock.zig +13 -1
  127. package/src/runtime/core.zig +133 -1
  128. package/src/runtime/credentials_store.zig +115 -0
  129. package/src/runtime/effects.zig +2568 -75
  130. package/src/runtime/effects_audio_capture_tests.zig +251 -0
  131. package/src/runtime/effects_credentials_tests.zig +332 -0
  132. package/src/runtime/effects_host_tests.zig +208 -1
  133. package/src/runtime/effects_relational_tests.zig +314 -0
  134. package/src/runtime/effects_store_tests.zig +211 -0
  135. package/src/runtime/flow.zig +14 -1
  136. package/src/runtime/gpu_surface_events.zig +6 -1
  137. package/src/runtime/native_command_event_tests.zig +42 -0
  138. package/src/runtime/persist_store.zig +666 -0
  139. package/src/runtime/record_store.zig +788 -0
  140. package/src/runtime/relational_store.zig +854 -0
  141. package/src/runtime/root.zig +52 -0
  142. package/src/runtime/runtime_event_tests.zig +70 -0
  143. package/src/runtime/service_host.zig +711 -0
  144. package/src/runtime/service_pool.zig +1314 -0
  145. package/src/runtime/session_blobs.zig +1 -1
  146. package/src/runtime/session_journal.zig +102 -0
  147. package/src/runtime/session_record.zig +177 -0
  148. package/src/runtime/session_replay.zig +109 -4
  149. package/src/runtime/shell_layout.zig +1 -0
  150. package/src/runtime/shell_layout_tests.zig +120 -0
  151. package/src/runtime/sqlite_engine.zig +474 -0
  152. package/src/runtime/state.zig +6 -0
  153. package/src/runtime/system_services.zig +49 -10
  154. package/src/runtime/tests.zig +5 -0
  155. package/src/runtime/ts_core_host.zig +1189 -118
  156. package/src/runtime/ts_core_host_tests.zig +638 -11
  157. package/src/runtime/ts_ui_app.zig +537 -1
  158. package/src/runtime/ui_app.zig +160 -19
  159. package/src/runtime/ui_app_tests.zig +203 -5
  160. package/src/runtime/validation.zig +22 -0
  161. package/src/runtime/view.zig +11 -0
  162. package/src/runtime/view_widget_scroll.zig +56 -5
  163. package/src/runtime/view_widget_text.zig +24 -5
  164. package/src/runtime/view_widget_tree.zig +1 -1
  165. package/src/runtime/window_storage.zig +1 -0
  166. package/src/runtime/window_view_runtime.zig +2 -3
  167. package/src/runtime/window_views.zig +19 -0
  168. package/src/tooling/android.zig +21 -16
  169. package/src/tooling/db.zig +160 -0
  170. package/src/tooling/ios.zig +7 -1
  171. package/src/tooling/manifest.zig +1248 -2
  172. package/src/tooling/package.zig +953 -6
  173. package/src/tooling/raw_manifest.zig +65 -0
  174. package/src/tooling/root.zig +1 -0
  175. package/src/tooling/templates.zig +216 -4
  176. package/src/tooling/ts_core.zig +283 -17
  177. package/src/tooling/verbs.zig +7 -0
  178. package/third_party/sqlite/README.md +13 -0
  179. package/third_party/sqlite/sqlite3.c +269649 -0
  180. package/third_party/sqlite/sqlite3.h +14349 -0
  181. package/tools/corewire/core_abi.zig +14 -2
  182. package/tools/corewire/emit.zig +98 -29
  183. package/tools/corewire/emit_facade.zig +414 -23
  184. package/tools/corewire/emit_profile.zig +6 -2
  185. package/tools/corewire/emit_service.zig +924 -0
  186. package/tools/corewire/main.zig +122 -0
  187. package/tools/corewire/service_contract.zig +250 -0
  188. package/tools/corewire/sidecar.zig +26 -15
@@ -611,6 +611,62 @@ test "widget render state dirty bounds tracks changed runtime states" {
611
611
  );
612
612
  }
613
613
 
614
+ test "quiet logical menu focus paints and dirties the active row without an outline" {
615
+ const children = [_]Widget{
616
+ .{
617
+ .id = 2,
618
+ .kind = .menu_item,
619
+ .frame = geometry.RectF.init(10, 12, 120, 32),
620
+ .text = "Duplicate",
621
+ },
622
+ .{
623
+ .id = 3,
624
+ .kind = .menu_item,
625
+ .frame = geometry.RectF.init(10, 52, 120, 32),
626
+ .text = "Rename",
627
+ },
628
+ };
629
+ var nodes: [3]WidgetLayoutNode = undefined;
630
+ const layout = try layoutWidgetTree(.{ .kind = .stack, .children = &children }, geometry.RectF.init(0, 0, 160, 100), &nodes);
631
+
632
+ // A pointer-opened menu keeps focus-visible quiet, but ArrowDown
633
+ // still establishes a logical active row. That row needs the menu
634
+ // wash so the movement is perceptible, without acquiring the focus
635
+ // outline reserved for keyboard traversal between controls.
636
+ var commands: [16]CanvasCommand = undefined;
637
+ var builder = Builder.init(&commands);
638
+ try layout.emitDisplayListWithState(&builder, .{}, .{ .focused_id = 2 });
639
+ var duplicate_wash = false;
640
+ var rename_wash = false;
641
+ var duplicate_outline = false;
642
+ for (builder.displayList().commands) |command| switch (command) {
643
+ .fill_rounded_rect => |fill| {
644
+ if (fill.id == widgetPartId(2, 1)) duplicate_wash = true;
645
+ if (fill.id == widgetPartId(3, 1)) rename_wash = true;
646
+ },
647
+ .stroke_rect => |stroke| {
648
+ if (stroke.id == widgetPartId(2, 2)) duplicate_outline = true;
649
+ },
650
+ else => {},
651
+ };
652
+ try std.testing.expect(duplicate_wash);
653
+ try std.testing.expect(!rename_wash);
654
+ try std.testing.expect(!duplicate_outline);
655
+
656
+ // Moving to the next row changes pixels on both the old and new
657
+ // rows; retained rendering must invalidate the complete union.
658
+ const duplicate_frame = layout.findById(2).?.frame;
659
+ const rename_frame = layout.findById(3).?.frame;
660
+ const dirty = layout.renderStateDirtyBounds(
661
+ .{ .focused_id = 2 },
662
+ .{ .focused_id = 3 },
663
+ ).?;
664
+ try std.testing.expect(dirty.x <= @min(duplicate_frame.x, rename_frame.x));
665
+ try std.testing.expect(dirty.y <= @min(duplicate_frame.y, rename_frame.y));
666
+ try std.testing.expect(dirty.maxX() >= @max(duplicate_frame.maxX(), rename_frame.maxX()));
667
+ try std.testing.expect(dirty.maxY() >= @max(duplicate_frame.maxY(), rename_frame.maxY()));
668
+ }
669
+
614
670
  test "widget render state dirty bounds tracks terminal logical focus" {
615
671
  const rows = [_]canvas.TerminalRow{.{ .cells = &.{} }};
616
672
  var grid = canvas.TerminalGrid{
@@ -2796,6 +2852,83 @@ test "drag landing layout motion escapes its scroll lane clip" {
2796
2852
  try std.testing.expect(saw_landing_motion);
2797
2853
  }
2798
2854
 
2855
+ test "rich text remains visible in floating drag and landing passes" {
2856
+ const source = "Lifted rich text";
2857
+ const spans = [_]canvas.TextSpan{.{ .text = source }};
2858
+ const root_frame = geometry.RectF.init(0, 0, 320, 140);
2859
+ const scroll_frame = geometry.RectF.init(10, 10, 140, 60);
2860
+ const card_frame = geometry.RectF.init(12, 80, 120, 36);
2861
+ const text_frame = geometry.RectF.init(18, 86, 108, 24);
2862
+ const nodes = [_]WidgetLayoutNode{
2863
+ .{
2864
+ .widget = .{ .id = 1, .kind = .panel, .frame = root_frame },
2865
+ .frame = root_frame,
2866
+ .depth = 0,
2867
+ },
2868
+ .{
2869
+ .widget = .{ .id = 2, .kind = .scroll_view, .frame = scroll_frame },
2870
+ .frame = scroll_frame,
2871
+ .depth = 1,
2872
+ .parent_index = 0,
2873
+ },
2874
+ .{
2875
+ .widget = .{
2876
+ .id = 3,
2877
+ .kind = .row,
2878
+ .frame = card_frame,
2879
+ .style = .{ .background = Color.rgb8(240, 240, 240), .radius = 6 },
2880
+ },
2881
+ .frame = card_frame,
2882
+ .depth = 2,
2883
+ .parent_index = 1,
2884
+ },
2885
+ .{
2886
+ .widget = .{
2887
+ .id = 4,
2888
+ .kind = .text,
2889
+ .frame = text_frame,
2890
+ .text = source,
2891
+ .spans = &spans,
2892
+ },
2893
+ .frame = text_frame,
2894
+ .depth = 3,
2895
+ .parent_index = 2,
2896
+ },
2897
+ };
2898
+ const layout = WidgetLayoutTree{ .nodes = &nodes };
2899
+
2900
+ var preview_commands: [64]CanvasCommand = undefined;
2901
+ var preview_builder = Builder.init(&preview_commands);
2902
+ try layout.emitDisplayListWithState(&preview_builder, .{}, .{
2903
+ .drag_preview_id = 3,
2904
+ .drag_preview_origin = geometry.PointF.init(card_frame.x, card_frame.y),
2905
+ .drag_preview_offset = geometry.OffsetF.init(0, -60),
2906
+ });
2907
+
2908
+ var preview_has_text = false;
2909
+ for (preview_builder.displayList().commands) |command| switch (command) {
2910
+ .draw_text => |draw| preview_has_text = preview_has_text or std.mem.eql(u8, source, draw.text),
2911
+ else => {},
2912
+ };
2913
+ try std.testing.expect(preview_has_text);
2914
+
2915
+ const layout_motions = [_]WidgetLayoutMotion{.{
2916
+ .id = 3,
2917
+ .offset = geometry.OffsetF.init(0, -60),
2918
+ .escape_ancestor_clips = true,
2919
+ }};
2920
+ var landing_commands: [64]CanvasCommand = undefined;
2921
+ var landing_builder = Builder.init(&landing_commands);
2922
+ try layout.emitDisplayListWithState(&landing_builder, .{}, .{ .layout_motions = &layout_motions });
2923
+
2924
+ var landing_has_text = false;
2925
+ for (landing_builder.displayList().commands) |command| switch (command) {
2926
+ .draw_text => |draw| landing_has_text = landing_has_text or std.mem.eql(u8, source, draw.text),
2927
+ else => {},
2928
+ };
2929
+ try std.testing.expect(landing_has_text);
2930
+ }
2931
+
2799
2932
  test "input-group wears the focus ring for its focused descendant" {
2800
2933
  const tokens = DesignTokens{};
2801
2934
  const group_children = [_]Widget{
@@ -191,14 +191,14 @@ fn widgetTextInputLineHeight(text_size: f32) f32 {
191
191
  }
192
192
 
193
193
  fn widgetTextInputWrap(widget: Widget, line_height: f32) TextWrap {
194
- if (widget.code_editor) return if (widget.text_no_wrap) .none else .word;
194
+ if (widget.runtime_flags.code_editor) return if (widget.text_no_wrap) .none else .word;
195
195
  if (widget.kind == .textarea) return .word;
196
196
  if (widget.kind == .text_field and widget.frame.height >= line_height * 2.25) return .word;
197
197
  return .none;
198
198
  }
199
199
 
200
200
  fn widgetTextInputVerticalInset(widget: Widget, tokens: DesignTokens, text_size: f32, options: TextLayoutOptions) f32 {
201
- if (widget.code_editor) return 0;
201
+ if (widget.runtime_flags.code_editor) return 0;
202
202
  if (options.wrap != .none) return widget_metrics.widgetControlInset(widget, tokens, tokens.spacing.sm);
203
203
  return @max(0, (widget.frame.height - widgetTextInputLineHeight(text_size)) * 0.5);
204
204
  }
@@ -220,7 +220,7 @@ const text_input_caret_reserve: f32 = 1;
220
220
  /// unscrolled field always has.
221
221
  fn widgetTextInputHorizontalScrollOffset(widget: Widget, tokens: DesignTokens, text_size: f32, text_inset: f32, options: TextLayoutOptions) f32 {
222
222
  if (options.wrap != .none) return 0;
223
- const offset = if (widget.code_editor) widget.value_x else widget.value;
223
+ const offset = if (widget.runtime_flags.code_editor) widget.value_x else widget.value;
224
224
  return std.math.clamp(offset, 0, widgetTextInputMaxHorizontalScrollOffset(widget, tokens, text_size, text_inset, options));
225
225
  }
226
226
 
@@ -232,7 +232,7 @@ fn widgetTextInputMaxHorizontalScrollOffset(widget: Widget, tokens: DesignTokens
232
232
  // paints — so a value holding a line break scrolls by the same
233
233
  // single-line extent it draws.
234
234
  const font_id = widgetTextInputFontId(widget, tokens);
235
- const text_width = if (widget.code_editor)
235
+ const text_width = if (widget.runtime_flags.code_editor)
236
236
  if (codeContentWidthCacheCurrent(widget, font_id, text_size))
237
237
  widget.code_content_width
238
238
  else
@@ -243,7 +243,7 @@ fn widgetTextInputMaxHorizontalScrollOffset(widget: Widget, tokens: DesignTokens
243
243
  }
244
244
 
245
245
  pub fn widgetTextInputOrigin(widget: Widget, tokens: DesignTokens, text_size: f32, inset: f32, options: TextLayoutOptions) geometry.PointF {
246
- if (widget.code_editor) {
246
+ if (widget.runtime_flags.code_editor) {
247
247
  return geometry.PointF.init(
248
248
  widget.frame.x + inset - widgetTextInputHorizontalScrollOffset(widget, tokens, text_size, inset, options),
249
249
  widget.frame.y + text_size - widgetTextInputScrollOffset(widget, tokens, text_size, inset, options),
@@ -365,7 +365,7 @@ pub fn textInputCaretVisibleScrollOffsetForWidget(widget: Widget, tokens: Design
365
365
  // selection rects measure with — the PRESENTED bytes (byte offsets
366
366
  // are interchangeable: the presentation substitutes 1:1).
367
367
  const caret_offset = snapTextOffset(widget.text, selection.focus);
368
- const caret_line_start = if (widget.code_editor)
368
+ const caret_line_start = if (widget.runtime_flags.code_editor)
369
369
  (std.mem.lastIndexOfScalar(u8, widget.text[0..caret_offset], '\n') orelse 0) +
370
370
  @as(usize, @intFromBool(std.mem.lastIndexOfScalar(u8, widget.text[0..caret_offset], '\n') != null))
371
371
  else
@@ -464,7 +464,7 @@ pub fn widgetTextInputDrawText(
464
464
  }
465
465
 
466
466
  pub fn widgetTextInputInset(widget: Widget, tokens: DesignTokens) f32 {
467
- if (widget.code_editor) return widget_metrics.widgetCodeLineNumberGutterWidth(widget, tokens);
467
+ if (widget.runtime_flags.code_editor) return widget_metrics.widgetCodeLineNumberGutterWidth(widget, tokens);
468
468
  const text_size = widgetTextInputSize(widget, tokens);
469
469
  return switch (widget.kind) {
470
470
  .search_field, .combobox => widget_metrics.widgetControlInset(widget, tokens, tokens.spacing.md) + @max(widget_metrics.widgetSizedDensityValue(widget, tokens, 8), text_size - 2) + widget_metrics.widgetControlInset(widget, tokens, tokens.spacing.sm),
@@ -473,7 +473,7 @@ pub fn widgetTextInputInset(widget: Widget, tokens: DesignTokens) f32 {
473
473
  }
474
474
 
475
475
  fn widgetTextInputFontId(widget: Widget, tokens: DesignTokens) FontId {
476
- return if (widget.code_editor) tokens.typography.mono_font_id else tokens.typography.font_id;
476
+ return if (widget.runtime_flags.code_editor) tokens.typography.mono_font_id else tokens.typography.font_id;
477
477
  }
478
478
 
479
479
  fn codeContentWidthCacheCurrent(widget: Widget, font_id: FontId, text_size: f32) bool {
@@ -489,7 +489,7 @@ fn codeContentWidthCacheCurrent(widget: Widget, font_id: FontId, text_size: f32)
489
489
  /// Runtime reconciliation carries this cache across unchanged app rebuilds;
490
490
  /// edits invalidate it before caret scrolling recomputes the new document.
491
491
  pub fn cacheTextInputContentWidthForWidget(widget: *Widget, tokens: DesignTokens) void {
492
- if (widget.kind != .textarea or !widget.code_editor or !widget.text_no_wrap) return;
492
+ if (widget.kind != .textarea or !widget.runtime_flags.code_editor or !widget.text_no_wrap) return;
493
493
  if (widget.hasCodeDiff()) return;
494
494
  const text_size = widgetTextInputSize(widget.*, tokens);
495
495
  const font_id = widgetTextInputFontId(widget.*, tokens);
@@ -578,7 +578,7 @@ fn widgetTextInputTrailingInset(widget: Widget, text_size: f32, inset: f32) f32
578
578
  // field padding. Its source viewport runs all the way to the trailing
579
579
  // edge; mirroring the gutter here invents horizontal overflow for lines
580
580
  // that visibly fit beside the numbers.
581
- if (widget.code_editor) return 0;
581
+ if (widget.runtime_flags.code_editor) return 0;
582
582
  if (widget.kind == .combobox) return inset + @max(8, text_size - 4);
583
583
  // A search field holding text reserves the trailing slot for the
584
584
  // built-in clear affordance so the text never runs under the x.
@@ -128,7 +128,7 @@ pub fn widgetScrollsAxis(widget: Widget, axis: token_model.ScrollAxis) bool {
128
128
  return switch (axis) {
129
129
  .vertical => widget.kind != .scroll_view or widget.scroll_axes.scrollsVertically() or widget.layout.virtualized,
130
130
  .horizontal => (widget.kind == .scroll_view and widget.scroll_axes.scrollsHorizontally() and !widget.layout.virtualized) or
131
- (widget.kind == .textarea and widget.code_editor and widget.text_no_wrap),
131
+ (widget.kind == .textarea and widget.runtime_flags.code_editor and widget.text_no_wrap),
132
132
  };
133
133
  }
134
134
 
@@ -264,6 +264,18 @@ pub const WidgetState = struct {
264
264
  invalid: bool = false,
265
265
  };
266
266
 
267
+ /// Engine-owned widget markers share one byte so adding runtime policy does
268
+ /// not expand every retained `Widget`. Builder-facing behavior remains on
269
+ /// ordinary named fields; these bits are stamped only by engine code.
270
+ pub const WidgetRuntimeFlags = packed struct(u8) {
271
+ /// `Ui.code` stamped this textarea as the editor surface.
272
+ code_editor: bool = false,
273
+ /// The runtime installed an OS-native scroll driver; engine-drawn
274
+ /// scrollbar and kinetic physics stand down for this scroll view.
275
+ native_scroll: bool = false,
276
+ _reserved: u6 = 0,
277
+ };
278
+
267
279
  /// Two 128-line masks for code-only diff presentation. `Widget` packs them
268
280
  /// into fields dormant on decorated code so ordinary widgets do not grow.
269
281
  pub const CodeDiffLines = struct {
@@ -947,7 +959,14 @@ pub const Widget = struct {
947
959
  /// selection, and accessibility paths all apply; this bit only swaps
948
960
  /// the textarea's visual/geometry policy to bare monospace highlighted
949
961
  /// code (no control fill, border, radius, focus ring, or inset).
950
- code_editor: bool = false,
962
+ runtime_flags: WidgetRuntimeFlags = .{},
963
+ /// Textarea Enter policy (`ElementOptions.submit_on_enter` / markup
964
+ /// `submit-on-enter`): plain Enter submits instead of editing, while
965
+ /// Shift+Enter remains a newline. False keeps the ordinary multiline
966
+ /// contract. Ignored by non-textarea kinds. The engine-only booleans in
967
+ /// `runtime_flags` share a byte so adding this policy does not grow every
968
+ /// retained widget.
969
+ submit_on_enter: bool = false,
951
970
  /// Syntax grammar for an editable `Ui.code` surface. Editable code
952
971
  /// retains one plain source span and tokenizes only visible logical
953
972
  /// lines during paint, so large documents do not consume the view's
@@ -1033,10 +1052,6 @@ pub const Widget = struct {
1033
1052
  semantics: WidgetSemantics = .{},
1034
1053
  /// App-declared native context menu for this widget (empty = none).
1035
1054
  context_menu: []const WidgetContextMenuItem = &.{},
1036
- /// True when the runtime installed a native scroll driver for this
1037
- /// `.scroll_view`: the engine's drawn scrollbar and kinetic physics
1038
- /// stand down — the OS scroller owns feel and the overlay scroller.
1039
- native_scroll: bool = false,
1040
1055
  /// Per-region edge behavior for scroll containers (`overscroll:` in
1041
1056
  /// the builder, `overscroll=` in markup): `.default` follows the
1042
1057
  /// `ScrollPhysics.overscroll` token (off unless a theme flips it),
@@ -1618,3 +1633,12 @@ fn mergeLayoutDefaults(explicit: WidgetLayoutStyle, defaults: WidgetLayoutStyle)
1618
1633
  if (explicit.min_size.width == 0 and explicit.min_size.height == 0) merged.min_size = defaults.min_size;
1619
1634
  return merged;
1620
1635
  }
1636
+
1637
+ test "Widget keeps the retained hot-path footprint after textarea policy flags" {
1638
+ // One layout tree holds thousands of Widgets by value. On the 64-bit
1639
+ // targets that run the renderer, 776 bytes is the reviewed footprint;
1640
+ // packing engine-only markers keeps the new textarea policy within it.
1641
+ if (@sizeOf(usize) == 8) {
1642
+ try std.testing.expectEqual(@as(usize, 776), @sizeOf(Widget));
1643
+ }
1644
+ }
package/src/root.zig CHANGED
@@ -46,6 +46,38 @@ pub const EffectFetchOutcome = runtime.EffectFetchOutcome;
46
46
  pub const EffectFileOp = runtime.EffectFileOp;
47
47
  pub const EffectFileOutcome = runtime.EffectFileOutcome;
48
48
  pub const EffectFileResult = runtime.EffectFileResult;
49
+ pub const EffectCredentialsOperation = runtime.EffectCredentialsOperation;
50
+ pub const EffectCredentialsOutcome = runtime.EffectCredentialsOutcome;
51
+ pub const EffectCredentialsResult = runtime.EffectCredentialsResult;
52
+ pub const EffectPersistOutcome = runtime.EffectPersistOutcome;
53
+ pub const EffectPersistResult = runtime.EffectPersistResult;
54
+ pub const max_effect_persist_snapshot_bytes = runtime.max_effect_persist_snapshot_bytes;
55
+ pub const EffectStoreOutcome = runtime.EffectStoreOutcome;
56
+ pub const EffectStoreOp = runtime.EffectStoreOp;
57
+ pub const RecordStoreBinding = runtime.RecordStoreBinding;
58
+ pub const EffectDbValue = runtime.EffectDbValue;
59
+ pub const EffectDbStatement = runtime.EffectDbStatement;
60
+ pub const EffectDbOutcome = runtime.EffectDbOutcome;
61
+ pub const EffectDbResultKind = runtime.EffectDbResultKind;
62
+ pub const EffectDbResult = runtime.EffectDbResult;
63
+ pub const RelationalStoreBinding = runtime.RelationalStoreBinding;
64
+ pub const max_db_effects = runtime.max_db_effects;
65
+ pub const max_effect_db_sql_bytes = runtime.max_effect_db_sql_bytes;
66
+ pub const max_effect_db_parameters = runtime.max_effect_db_parameters;
67
+ pub const max_effect_db_exec_statements = runtime.max_effect_db_exec_statements;
68
+ pub const max_effect_db_parameter_bytes = runtime.max_effect_db_parameter_bytes;
69
+ pub const max_effect_db_exec_parameter_bytes = runtime.max_effect_db_exec_parameter_bytes;
70
+ pub const default_effect_db_page_rows = runtime.default_effect_db_page_rows;
71
+ pub const max_effect_db_page_bytes = runtime.max_effect_db_page_bytes;
72
+ pub const max_effect_db_result_rows = runtime.max_effect_db_result_rows;
73
+ pub const max_effect_db_result_bytes = runtime.max_effect_db_result_bytes;
74
+ pub const max_effect_store_key_bytes = runtime.max_effect_store_key_bytes;
75
+ pub const max_effect_store_value_bytes = runtime.max_effect_store_value_bytes;
76
+ pub const max_effect_store_batch_entries = runtime.max_effect_store_batch_entries;
77
+ pub const max_effect_store_batch_bytes = runtime.max_effect_store_batch_bytes;
78
+ pub const max_effect_store_result_bytes = runtime.max_effect_store_result_bytes;
79
+ pub const default_effect_store_scan_limit = runtime.default_effect_store_scan_limit;
80
+ pub const max_effect_store_scan_limit = runtime.max_effect_store_scan_limit;
49
81
  pub const effect_error_exit_code = runtime.effect_error_exit_code;
50
82
  pub const max_effects = runtime.max_effects;
51
83
  pub const max_effect_argv = runtime.max_effect_argv;
@@ -64,6 +96,14 @@ pub const max_effect_body_bytes = runtime.max_effect_body_bytes;
64
96
  pub const default_effect_fetch_timeout_ms = runtime.default_effect_fetch_timeout_ms;
65
97
  pub const max_effect_file_path_bytes = runtime.max_effect_file_path_bytes;
66
98
  pub const max_effect_file_bytes = runtime.max_effect_file_bytes;
99
+ pub const persist_store = runtime.persist_store;
100
+ pub const PersistStore = runtime.PersistStore;
101
+ pub const PersistOutcome = runtime.PersistOutcome;
102
+ pub const max_persist_snapshot_bytes = runtime.max_persist_snapshot_bytes;
103
+ pub const record_store = runtime.record_store;
104
+ pub const RecordStore = runtime.RecordStore;
105
+ pub const relational_store = runtime.relational_store;
106
+ pub const RelationalStore = runtime.RelationalStore;
67
107
  pub const EffectClipboardOp = runtime.EffectClipboardOp;
68
108
  pub const EffectClipboardOutcome = runtime.EffectClipboardOutcome;
69
109
  pub const EffectClipboardResult = runtime.EffectClipboardResult;
@@ -74,6 +114,9 @@ pub const EffectTimerOutcome = runtime.EffectTimerOutcome;
74
114
  pub const max_effect_timers = runtime.max_effect_timers;
75
115
  pub const EffectAudio = runtime.EffectAudio;
76
116
  pub const EffectAudioEventKind = runtime.EffectAudioEventKind;
117
+ pub const EffectAudioCaptureEvent = runtime.EffectAudioCaptureEvent;
118
+ pub const EffectAudioCaptureEventKind = runtime.EffectAudioCaptureEventKind;
119
+ pub const decodeAudioCaptureChannelEvent = runtime.decodeAudioCaptureChannelEvent;
77
120
  pub const EffectAudioSource = runtime.EffectAudioSource;
78
121
  pub const audioCachePath = runtime.audioCachePath;
79
122
  pub const max_effect_audio_path_bytes = runtime.max_effect_audio_path_bytes;
@@ -101,6 +144,11 @@ pub const max_effect_pty_write_bytes = runtime.max_effect_pty_write_bytes;
101
144
  pub const max_effect_pty_term_bytes = runtime.max_effect_pty_term_bytes;
102
145
  pub const EffectHostResult = runtime.EffectHostResult;
103
146
  pub const HostCallBinding = runtime.HostCallBinding;
147
+ pub const HostCallCompletion = runtime.HostCallCompletion;
148
+ pub const ServiceHost = runtime.ServiceHost;
149
+ pub const serviceEnvironmentVariableAllowed = runtime.serviceEnvironmentVariableAllowed;
150
+ pub const ServicePool = runtime.ServicePool;
151
+ pub const service_pool = runtime.service_pool;
104
152
  pub const max_effect_host_name_bytes = runtime.max_effect_host_name_bytes;
105
153
  pub const max_effect_host_payload_bytes = runtime.max_effect_host_payload_bytes;
106
154
  pub const max_effect_host_result_bytes = runtime.max_effect_host_result_bytes;
@@ -133,6 +181,13 @@ pub const WebViewSourceKind = platform.WebViewSourceKind;
133
181
  pub const WebViewAssetSource = platform.WebViewAssetSource;
134
182
  pub const WebEngine = platform.WebEngine;
135
183
  pub const PlatformFeature = platform.PlatformFeature;
184
+ pub const AudioCaptureSource = platform.AudioCaptureSource;
185
+ pub const AudioCaptureFormat = platform.AudioCaptureFormat;
186
+ pub const AudioCaptureEvent = platform.AudioCaptureEvent;
187
+ pub const AudioCaptureEventKind = platform.AudioCaptureEventKind;
188
+ pub const AudioCaptureSink = platform.AudioCaptureSink;
189
+ pub const AudioCapturePushResult = platform.AudioCapturePushResult;
190
+ pub const max_audio_capture_pcm_bytes = platform.max_audio_capture_pcm_bytes;
136
191
  pub const ViewKind = platform.ViewKind;
137
192
  pub const ViewOptions = platform.ViewOptions;
138
193
  pub const ViewPatch = platform.ViewPatch;
@@ -161,6 +216,7 @@ pub const FormFactor = platform.FormFactor;
161
216
  pub const WindowDragRegion = platform.WindowDragRegion;
162
217
  pub const WindowShowMode = platform.WindowShowMode;
163
218
  pub const WindowClosePolicy = platform.WindowClosePolicy;
219
+ pub const LaunchAtLoginStatus = platform.LaunchAtLoginStatus;
164
220
  pub const Menu = platform.Menu;
165
221
  pub const MenuItem = platform.MenuItem;
166
222
  pub const Shortcut = platform.Shortcut;
@@ -489,6 +489,17 @@ pub const Options = struct {
489
489
  shortcuts: []const platform.Shortcut = &.{},
490
490
  automation: ?automation.Server = null,
491
491
  window_state_store: ?window_state.Store = null,
492
+ /// Engine-owned record-store service. The app runner sets this only
493
+ /// when app.zon declares the `store` capability; replay leaves it null
494
+ /// because journaled effect results are the whole external world.
495
+ record_store: ?runtime_effects.RecordStoreBinding = null,
496
+ /// Engine-owned relational database, installed only for the `sqlite`
497
+ /// capability. Replay keeps it null and feeds journaled DB results.
498
+ relational_store: ?runtime_effects.RelationalStoreBinding = null,
499
+ /// Whether the app declared the `credentials` capability. Permission is
500
+ /// checked separately; both gates must be open before core effects may
501
+ /// reach the platform keychain.
502
+ credentials_enabled: bool = false,
492
503
  js_window_api: bool = false,
493
504
  /// Whether this build ships the embedded web layer. The app runner
494
505
  /// sets it from the build graph's app.zon inference (declare-to-use:
@@ -93,6 +93,10 @@ pub fn RuntimeAutomationSnapshot(comptime Runtime: type) type {
93
93
  .command = item.command,
94
94
  .separator = item.separator,
95
95
  .enabled = item.enabled,
96
+ .detail = item.detail,
97
+ .role = item.role,
98
+ .key = item.key,
99
+ .modifiers = item.modifiers,
96
100
  };
97
101
  }
98
102
  return .{
@@ -508,6 +508,7 @@ pub fn RuntimeAutomationWidgetDispatch(comptime Runtime: type) type {
508
508
  self.views[view_index].recordGpuSurfaceInputTimestamp(automationInputTimestampNs());
509
509
  try CanvasWidgetEventMethods().invalidateForCanvasWidgetRenderStateChange(self, view_index, previous_state, self.views[view_index].canvasWidgetRenderState());
510
510
  }
511
+ _ = try self.views[view_index].ensureCanvasWidgetFocusedTextCaret();
511
512
  }
512
513
 
513
514
  pub fn dispatchAutomationWidgetKey(self: *Runtime, app: runtime_api.App(Runtime), view_index: usize, id: canvas.ObjectId, key: []const u8) anyerror!void {
@@ -125,6 +125,8 @@ pub fn platformFeatureFromString(value: []const u8) ?platform.PlatformFeature {
125
125
  if (std.mem.eql(u8, value, "audioPlayback")) return .audio_playback;
126
126
  if (std.mem.eql(u8, value, "audioStreaming")) return .audio_streaming;
127
127
  if (std.mem.eql(u8, value, "audioSpectrum")) return .audio_spectrum;
128
+ if (std.mem.eql(u8, value, "microphoneCapture")) return .microphone_capture;
129
+ if (std.mem.eql(u8, value, "systemAudioCapture")) return .system_audio_capture;
128
130
  if (std.mem.eql(u8, value, "windowHideOnClose")) return .window_hide_on_close;
129
131
  if (std.mem.eql(u8, value, "videoPlayback")) return .video_playback;
130
132
  return null;
@@ -320,22 +320,43 @@ test "runtime validates native OS actions before platform dispatch" {
320
320
 
321
321
  try std.testing.expectError(error.InvalidTrayOptions, harness.runtime.createTray(.{ .items = &.{.{ .label = "" }} }));
322
322
  try std.testing.expectError(error.InvalidTrayOptions, harness.runtime.updateTrayMenu(&.{.{ .label = "" }}));
323
+ try std.testing.expectError(error.InvalidTrayOptions, harness.runtime.createTray(.{ .presentation = .{ .width = -1 } }));
324
+ try std.testing.expectError(error.InvalidTrayOptions, harness.runtime.createTray(.{ .presentation = .{ .icon_opacity = 1.1 } }));
325
+ try std.testing.expectError(error.InvalidTrayOptions, harness.runtime.updateTrayMenu(&.{.{ .id = 7, .label = "Readout", .command = "app.bad", .role = .info }}));
326
+ try std.testing.expectError(error.InvalidTrayOptions, harness.runtime.updateTrayMenu(&.{.{ .id = 7, .label = "Command", .detail = "not allowed" }}));
327
+ try std.testing.expectError(error.InvalidTrayOptions, harness.runtime.updateTrayMenu(&.{.{ .id = 7, .label = "No command", .key = "q" }}));
328
+ try std.testing.expectError(error.InvalidTrayOptions, harness.runtime.updateTrayMenu(&.{.{ .id = 7, .label = "Bad key", .command = "app.bad-key", .key = "not-a-key", .modifiers = .{ .command = true } }}));
329
+ try std.testing.expectError(error.InvalidTrayOptions, harness.runtime.updateTrayMenu(&.{.{ .id = 7, .label = "Unsafe key", .command = "app.unsafe-key", .key = "q" }}));
323
330
  try harness.runtime.createTray(.{
324
331
  .icon_path = "/tmp/tray.png",
325
332
  .tooltip = "native-sdk",
333
+ .presentation = .{ .title = "LIVE", .width = 62, .tone = .warning, .icon_opacity = 0.5, .monospaced = true },
334
+ .activation_command = "app.refresh",
335
+ .alternate_activation_command = "app.mode",
336
+ .open_command = "app.opened",
326
337
  .items = &.{
327
- .{ .id = 1, .label = "Open" },
338
+ .{ .id = 1, .label = "Open", .detail = "ready", .role = .info },
328
339
  .{ .separator = true },
329
- .{ .id = 2, .label = "Quit", .enabled = false },
340
+ .{ .id = 2, .label = "Quit", .command = "app.quit", .enabled = false, .detail = "warning", .role = .agent, .key = "q", .modifiers = .{ .command = true } },
330
341
  },
331
342
  });
332
343
  try std.testing.expectEqual(@as(usize, 1), harness.null_platform.trayCreateCount());
333
344
  try std.testing.expectEqualStrings("/tmp/tray.png", harness.null_platform.lastTrayIconPath());
334
345
  try std.testing.expectEqualStrings("native-sdk", harness.null_platform.lastTrayTooltip());
346
+ try std.testing.expectEqualStrings("LIVE", harness.null_platform.lastTrayTitle());
347
+ try std.testing.expectEqualStrings("app.refresh", harness.null_platform.lastTrayActivationCommand());
348
+ try std.testing.expectEqualStrings("app.mode", harness.null_platform.lastTrayAlternateActivationCommand());
349
+ try std.testing.expectEqualStrings("app.opened", harness.null_platform.lastTrayOpenCommand());
350
+ try std.testing.expectEqual(platform.TrayTone.warning, harness.null_platform.lastTrayPresentation().tone);
351
+ try std.testing.expectEqual(@as(f32, 62), harness.null_platform.lastTrayPresentation().width);
335
352
  try std.testing.expectEqual(@as(usize, 3), harness.null_platform.trayItems().len);
336
353
  try std.testing.expectEqualStrings("Open", harness.null_platform.trayItems()[0].label);
337
354
  try std.testing.expect(harness.null_platform.trayItems()[1].separator);
338
355
  try std.testing.expect(!harness.null_platform.trayItems()[2].enabled);
356
+ try std.testing.expectEqual(platform.TrayItemRole.agent, harness.null_platform.trayItems()[2].role);
357
+ try std.testing.expectEqualStrings("warning", harness.null_platform.trayItems()[2].detail);
358
+ try std.testing.expectEqualStrings("q", harness.null_platform.trayItems()[2].key);
359
+ try std.testing.expect(harness.null_platform.trayItems()[2].modifiers.command);
339
360
  try harness.runtime.updateTrayMenu(&.{.{ .id = 3, .label = "Settings" }});
340
361
  try std.testing.expectEqual(@as(usize, 2), harness.null_platform.trayUpdateCount());
341
362
  try std.testing.expectEqualStrings("Settings", harness.null_platform.trayItems()[0].label);
@@ -83,7 +83,7 @@ pub fn writeViewJsonToWriter(view: platform.ViewInfo, writer: anytype) !void {
83
83
  try json.writeString(writer, view.command);
84
84
  try writer.writeAll(",\"url\":");
85
85
  try json.writeString(writer, view.url);
86
- try writer.print(",\"x\":{d},\"y\":{d},\"width\":{d},\"height\":{d},\"layer\":{d},\"visible\":{},\"enabled\":{},\"transparent\":{},\"bridge\":{},\"gpuWidth\":{d},\"gpuHeight\":{d},\"gpuScale\":{d},\"gpuFrame\":{d},\"gpuTimestampNs\":{d},\"gpuFrameIntervalNs\":{d},\"gpuInputTimestampNs\":{d},\"gpuInputLatencyNs\":{d},\"gpuInputLatencyBudgetNs\":{d},\"gpuInputLatencyBudgetExceededCount\":{d},\"gpuInputLatencyBudgetOk\":{},\"gpuFirstFrameLatencyNs\":{d},\"gpuFirstFrameLatencyBudgetNs\":{d},\"gpuFirstFrameLatencyBudgetExceededCount\":{d},\"gpuFirstFrameLatencyBudgetOk\":{},\"gpuNonblank\":{},\"gpuSampleColor\":{d},\"gpuBackend\":", .{
86
+ try writer.print(",\"x\":{d},\"y\":{d},\"width\":{d},\"height\":{d},\"layer\":{d},\"visible\":{},\"enabled\":{},\"transparent\":{},\"bridge\":{},\"gpuWidth\":{d},\"gpuHeight\":{d},\"gpuScale\":{d},\"gpuFrame\":{d},\"gpuTimestampNs\":{d},\"gpuFrameIntervalNs\":{d},\"gpuInputCount\":{d},\"gpuInputTimestampNs\":{d},\"gpuInputLatencyNs\":{d},\"gpuInputLatencyBudgetNs\":{d},\"gpuInputLatencyBudgetExceededCount\":{d},\"gpuInputLatencyBudgetOk\":{},\"gpuFirstFrameLatencyNs\":{d},\"gpuFirstFrameLatencyBudgetNs\":{d},\"gpuFirstFrameLatencyBudgetExceededCount\":{d},\"gpuFirstFrameLatencyBudgetOk\":{},\"gpuNonblank\":{},\"gpuOccluded\":{},\"gpuSampleColor\":{d},\"gpuBackend\":", .{
87
87
  view.frame.x,
88
88
  view.frame.y,
89
89
  view.frame.width,
@@ -99,6 +99,7 @@ pub fn writeViewJsonToWriter(view: platform.ViewInfo, writer: anytype) !void {
99
99
  view.gpu_frame_index,
100
100
  view.gpu_timestamp_ns,
101
101
  view.gpu_frame_interval_ns,
102
+ view.gpu_input_event_count,
102
103
  view.gpu_input_timestamp_ns,
103
104
  view.gpu_input_latency_ns,
104
105
  view.gpu_input_latency_budget_ns,
@@ -109,6 +110,7 @@ pub fn writeViewJsonToWriter(view: platform.ViewInfo, writer: anytype) !void {
109
110
  view.gpu_first_frame_latency_budget_exceeded_count,
110
111
  view.gpu_first_frame_latency_budget_ok,
111
112
  view.gpu_frame_nonblank,
113
+ view.gpu_occluded,
112
114
  view.gpu_sample_color,
113
115
  });
114
116
  try json.writeString(writer, @tagName(view.gpu_backend));
@@ -220,6 +220,7 @@ pub fn RuntimeCanvasFrames(comptime Runtime: type) type {
220
220
 
221
221
  var frame_options = options;
222
222
  if (frame_options.surface_size.isEmpty()) frame_options.surface_size = self.views[index].frame.size();
223
+ frame_options.backdrop_blur_sample_extent_multiplier = backdropBlurSampleExtentMultiplier(self.options.platform.name);
223
224
  return self.views[index].canvasDisplayList().framePlan(previous, frame_options, storage);
224
225
  }
225
226
 
@@ -874,6 +875,7 @@ pub fn RuntimeCanvasFrames(comptime Runtime: type) type {
874
875
  launch_timing.lapOnce("first_plan_begin");
875
876
  defer launch_timing.lapOnce("first_plan_done");
876
877
  var frame_options = options;
878
+ frame_options.backdrop_blur_sample_extent_multiplier = backdropBlurSampleExtentMultiplier(self.options.platform.name);
877
879
  if (frame_options.surface_size.isEmpty()) {
878
880
  frame_options.surface_size = if (self.views[index].gpu_size.isEmpty()) self.views[index].frame.size() else self.views[index].gpu_size;
879
881
  }
@@ -1134,6 +1136,7 @@ pub fn RuntimeCanvasFrames(comptime Runtime: type) type {
1134
1136
  render_plan.commands,
1135
1137
  dirty_bounds,
1136
1138
  dirty_rects[0..dirty_rect_count],
1139
+ frame_options.backdrop_blur_sample_extent_multiplier,
1137
1140
  )) {
1138
1141
  // A blur's apron must be reconstructed from the scene as
1139
1142
  // it existed before that command. Retained pixels beyond
@@ -1195,9 +1198,7 @@ pub fn RuntimeCanvasFrames(comptime Runtime: type) type {
1195
1198
  if (self.views[index].pruneCompletedNoopCanvasRenderAnimations(frame_options.timestamp_ns)) {
1196
1199
  self.views[index].compactCanvasFrameRenderOverrideNoops();
1197
1200
  }
1198
- if (self.views[index].canvasRenderAnimationsActive(frame_options.timestamp_ns)) {
1199
- self.invalidateFor(.state, self.views[index].frame);
1200
- }
1201
+ const render_animation_active = self.views[index].canvasRenderAnimationsActive(frame_options.timestamp_ns);
1201
1202
  // An armed tooltip show delay — and a running anchor-gap
1202
1203
  // transit grace — only fire on a presented frame's
1203
1204
  // timestamp, so frames must keep coming while either is
@@ -1210,8 +1211,17 @@ pub fn RuntimeCanvasFrames(comptime Runtime: type) type {
1210
1211
  // requested). Settled shown tooltips and the warm
1211
1212
  // window need no pump: both step on journaled input
1212
1213
  // timestamps.
1213
- if (self.views[index].canvasTooltipIntentArmed()) {
1214
+ const tooltip_intent_armed = self.views[index].canvasTooltipIntentArmed();
1215
+ if (render_animation_active or tooltip_intent_armed) {
1214
1216
  self.invalidateFor(.state, self.views[index].frame);
1217
+ // Invalidation keeps snapshots/diagnostics honest but
1218
+ // does not itself wake an idle retained surface. The
1219
+ // current completion consumed its one-shot request, so
1220
+ // explicitly arm the next one while time-based pixels
1221
+ // still have work. Without this leg animations render
1222
+ // their click endpoints and then park until unrelated
1223
+ // input happens to wake the view.
1224
+ try requestCanvasFrameForView(self, index);
1215
1225
  }
1216
1226
  } else {
1217
1227
  self.views[index].recordCanvasFrame(canvas_frame);
@@ -1316,14 +1326,22 @@ fn incrementalCanvasDamageIntersectsBackdropBlur(
1316
1326
  commands: []const canvas.RenderCommand,
1317
1327
  dirty_bounds: ?geometry.RectF,
1318
1328
  dirty_rects: []const geometry.RectF,
1329
+ sample_extent_multiplier: f32,
1319
1330
  ) bool {
1320
- if (dirty_rects.len == 0) return canvas.incrementalDamageIntersectsBackdropBlur(commands, dirty_bounds);
1331
+ if (dirty_rects.len == 0) return canvas.incrementalDamageIntersectsBackdropBlurWithSampleExtent(commands, dirty_bounds, sample_extent_multiplier);
1321
1332
  for (dirty_rects) |dirty_rect| {
1322
- if (canvas.incrementalDamageIntersectsBackdropBlur(commands, dirty_rect)) return true;
1333
+ if (canvas.incrementalDamageIntersectsBackdropBlurWithSampleExtent(commands, dirty_rect, sample_extent_multiplier)) return true;
1323
1334
  }
1324
1335
  return false;
1325
1336
  }
1326
1337
 
1338
+ /// AppKit approximates its Gaussian with three consecutive box filters, so
1339
+ /// one output pixel can depend on the sum of three box radii. Other renderers
1340
+ /// retain the shared one-radius footprint.
1341
+ fn backdropBlurSampleExtentMultiplier(platform_name: []const u8) f32 {
1342
+ return if (std.mem.eql(u8, platform_name, "macos")) 3 else 1;
1343
+ }
1344
+
1327
1345
  /// Rework a planned frame's incremental damage for the present's
1328
1346
  /// EFFECTIVE scale. Two obligations when the scales differ:
1329
1347
  /// - A COARSER presentation scale carries a larger device pixel than
@@ -1369,15 +1387,15 @@ const CanvasPacketPatchStats = struct {
1369
1387
  };
1370
1388
 
1371
1389
  /// Stamp `gpu_input_latency` at the RESPONDING present's completion:
1372
- /// the present call above just returned synchronously, so the wall
1373
- /// clock NOW (the domain every host and automation input timestamp
1374
- /// uses) is the moment the input's pixels reached the swapchain. The
1375
- /// paced completion event that used to stamp this arrives up to a
1376
- /// frame interval later and measured the pacing channel, not the
1377
- /// glass; it remains the fallback for inputs that present nothing.
1390
+ /// the present call above just returned synchronously, so monotonic NOW
1391
+ /// (the domain every host and automation input timestamp uses) is the
1392
+ /// moment the input's pixels reached the swapchain. The paced completion
1393
+ /// event that used to stamp this arrives up to a frame interval later and
1394
+ /// measured the pacing channel, not the glass; it remains the fallback for
1395
+ /// inputs that present nothing.
1378
1396
  fn recordCanvasPresentInputLatency(view: anytype) void {
1379
1397
  if (view.gpu_pending_input_timestamp_ns == 0) return;
1380
- view.recordGpuSurfaceInputLatencyForFrame(runtime_clock.timestampToU64(runtime_clock.nowNanoseconds()));
1398
+ view.recordGpuSurfaceInputLatencyForFrame(runtime_clock.monotonicNanoseconds());
1381
1399
  }
1382
1400
 
1383
1401
  /// Build the frame's CURRENT keyed command list — every supported render