@native-sdk/cli 0.8.4 → 0.9.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 (161) hide show
  1. package/build/app.zig +1178 -74
  2. package/build.zig +715 -17
  3. package/build.zig.zon +1 -0
  4. package/native-sdk.d.ts +10 -0
  5. package/package.json +12 -11
  6. package/packages/core/compile-surface/core.ts +435 -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/merge_static_archives.mjs +78 -0
  12. package/packages/core/scripts/npm_static_spike.mjs +64 -0
  13. package/packages/core/scripts/run_external_core_compiler.mjs +122 -6
  14. package/packages/core/scripts/run_external_service_compiler.mjs +280 -0
  15. package/packages/core/scripts/stage_external_core.mjs +9 -1
  16. package/packages/core/scripts/stage_external_services.mjs +172 -0
  17. package/packages/core/scripts/surface_manifest_diff.mjs +253 -0
  18. package/packages/core/scripts/vendor_service_packages.mjs +189 -0
  19. package/packages/core/sdk/core.d.ts +224 -0
  20. package/packages/core/sdk/core.ts +694 -22
  21. package/packages/core/sdk/events.d.ts +89 -0
  22. package/packages/core/sdk/events.ts +128 -0
  23. package/packages/core/src/checker.ts +936 -15
  24. package/packages/core/src/cli.ts +156 -3
  25. package/packages/core/src/contract.ts +28 -5
  26. package/packages/core/src/devhost.ts +1876 -16
  27. package/packages/core/src/devhost_journal.mjs +183 -0
  28. package/packages/core/src/devhost_resolver.mjs +17 -1
  29. package/packages/core/src/devhost_service_worker.mjs +90 -0
  30. package/packages/core/src/diagnostics.ts +179 -22
  31. package/packages/core/src/frontend.ts +210 -34
  32. package/packages/core/src/infer.ts +24 -0
  33. package/packages/core/src/modules.ts +129 -80
  34. package/packages/core/src/service_contract.ts +597 -0
  35. package/packages/core/src/sqlite_cli.ts +93 -0
  36. package/packages/core/src/sqlite_codegen.ts +806 -0
  37. package/packages/core/src/sqlite_runtime_policy.ts +364 -0
  38. package/packages/core/src/typed_ast.ts +36 -8
  39. package/skill-data/automation/SKILL.md +1 -1
  40. package/skill-data/core/references/project-anatomy.md +1 -1
  41. package/skill-data/native-ui/SKILL.md +58 -5
  42. package/skill-data/ts-core/SKILL.md +123 -41
  43. package/skill-data/ts-services/SKILL.md +126 -0
  44. package/skill-data/ts-services/references/service-surface.md +604 -0
  45. package/skill-data/zig/SKILL.md +1 -1
  46. package/skills/native-sdk/SKILL.md +1 -1
  47. package/src/app_runner/no_migrations.zig +3 -0
  48. package/src/app_runner/no_services.zig +20 -0
  49. package/src/app_runner/root.zig +133 -4
  50. package/src/app_runner/ts_core_main.zig +254 -8
  51. package/src/app_runner/ts_core_mobile.zig +241 -0
  52. package/src/automation/protocol.zig +5 -1
  53. package/src/automation/snapshot.zig +31 -11
  54. package/src/embed/app_exports.zig +12 -1
  55. package/src/embed/c_api.zig +48 -2
  56. package/src/embed/conversions.zig +4 -5
  57. package/src/embed/host.zig +109 -1
  58. package/src/embed/root.zig +8 -0
  59. package/src/embed/tests.zig +241 -0
  60. package/src/embed/types.zig +51 -0
  61. package/src/embed/ui_host.zig +185 -5
  62. package/src/platform/android/NativeSdkActivity.java +131 -0
  63. package/src/platform/android/android_host.c +182 -1
  64. package/src/platform/android/native_sdk_app.h +17 -0
  65. package/src/platform/ios/native_sdk_app.h +17 -0
  66. package/src/platform/ios/uikit_host.m +115 -0
  67. package/src/platform/linux/cef_host.cpp +8 -2
  68. package/src/platform/linux/gtk_host.c +289 -22
  69. package/src/platform/linux/gtk_host.h +5 -1
  70. package/src/platform/linux/root.zig +109 -22
  71. package/src/platform/macos/appkit_host.h +24 -7
  72. package/src/platform/macos/appkit_host.m +686 -64
  73. package/src/platform/macos/cef_host.mm +400 -66
  74. package/src/platform/macos/root.zig +304 -47
  75. package/src/platform/null_platform.zig +435 -48
  76. package/src/platform/null_platform_tests.zig +113 -0
  77. package/src/platform/root.zig +19 -0
  78. package/src/platform/types.zig +281 -28
  79. package/src/platform/windows/root.zig +207 -27
  80. package/src/platform/windows/webview2_host.cpp +334 -51
  81. package/src/primitives/app_manifest/comptime_scene.zig +2 -0
  82. package/src/primitives/app_manifest/root.zig +4 -0
  83. package/src/primitives/app_manifest/tests.zig +3 -0
  84. package/src/primitives/app_manifest/types.zig +32 -0
  85. package/src/primitives/app_manifest/validation.zig +19 -1
  86. package/src/root.zig +53 -0
  87. package/src/runtime/api.zig +19 -0
  88. package/src/runtime/automation_commands.zig +35 -2
  89. package/src/runtime/automation_snapshot.zig +32 -20
  90. package/src/runtime/bridge_permission_tests.zig +58 -3
  91. package/src/runtime/bridge_responses.zig +4 -2
  92. package/src/runtime/builtin_bridge.zig +11 -1
  93. package/src/runtime/canvas_frame.zig +18 -11
  94. package/src/runtime/canvas_frame_animation_tests.zig +4 -0
  95. package/src/runtime/clock.zig +13 -1
  96. package/src/runtime/core.zig +145 -7
  97. package/src/runtime/credentials_store.zig +115 -0
  98. package/src/runtime/effects.zig +3701 -231
  99. package/src/runtime/effects_credentials_tests.zig +332 -0
  100. package/src/runtime/effects_file_tests.zig +587 -0
  101. package/src/runtime/effects_host_tests.zig +208 -1
  102. package/src/runtime/effects_notification_tests.zig +11 -0
  103. package/src/runtime/effects_relational_tests.zig +314 -0
  104. package/src/runtime/effects_store_tests.zig +211 -0
  105. package/src/runtime/file_access.zig +400 -0
  106. package/src/runtime/file_effect_crash_helper.zig +28 -0
  107. package/src/runtime/file_effect_crash_tests.zig +37 -0
  108. package/src/runtime/flow.zig +35 -10
  109. package/src/runtime/gpu_surface_events.zig +6 -1
  110. package/src/runtime/native_command_event_tests.zig +86 -2
  111. package/src/runtime/persist_store.zig +666 -0
  112. package/src/runtime/pty.zig +5 -2
  113. package/src/runtime/record_store.zig +788 -0
  114. package/src/runtime/relational_store.zig +854 -0
  115. package/src/runtime/root.zig +54 -0
  116. package/src/runtime/runtime_event_tests.zig +70 -0
  117. package/src/runtime/service_host.zig +711 -0
  118. package/src/runtime/service_pool.zig +1314 -0
  119. package/src/runtime/session_blobs.zig +4 -1
  120. package/src/runtime/session_journal.zig +158 -5
  121. package/src/runtime/session_record.zig +215 -0
  122. package/src/runtime/session_replay.zig +206 -11
  123. package/src/runtime/session_tests.zig +81 -0
  124. package/src/runtime/shell_layout.zig +1 -0
  125. package/src/runtime/shell_layout_tests.zig +120 -0
  126. package/src/runtime/sqlite_engine.zig +474 -0
  127. package/src/runtime/state.zig +16 -0
  128. package/src/runtime/system_services.zig +170 -38
  129. package/src/runtime/tests.zig +4 -0
  130. package/src/runtime/ts_core_host.zig +1067 -95
  131. package/src/runtime/ts_core_host_tests.zig +325 -11
  132. package/src/runtime/ts_ui_app.zig +953 -2
  133. package/src/runtime/ui_app.zig +434 -96
  134. package/src/runtime/ui_app_tests.zig +287 -11
  135. package/src/runtime/ui_app_window_tests.zig +61 -7
  136. package/src/runtime/validation.zig +42 -0
  137. package/src/runtime/view.zig +9 -0
  138. package/src/runtime/window_storage.zig +1 -0
  139. package/src/runtime/window_view_runtime.zig +2 -3
  140. package/src/runtime/window_views.zig +19 -0
  141. package/src/tooling/android.zig +21 -16
  142. package/src/tooling/db.zig +160 -0
  143. package/src/tooling/ios.zig +7 -1
  144. package/src/tooling/manifest.zig +214 -2
  145. package/src/tooling/package.zig +116 -0
  146. package/src/tooling/raw_manifest.zig +30 -0
  147. package/src/tooling/root.zig +1 -0
  148. package/src/tooling/templates.zig +189 -4
  149. package/src/tooling/ts_core.zig +366 -17
  150. package/src/tooling/verbs.zig +7 -0
  151. package/third_party/sqlite/README.md +13 -0
  152. package/third_party/sqlite/sqlite3.c +269649 -0
  153. package/third_party/sqlite/sqlite3.h +14349 -0
  154. package/tools/corewire/core_abi.zig +14 -2
  155. package/tools/corewire/emit.zig +98 -29
  156. package/tools/corewire/emit_facade.zig +442 -27
  157. package/tools/corewire/emit_profile.zig +6 -2
  158. package/tools/corewire/emit_service.zig +924 -0
  159. package/tools/corewire/main.zig +122 -0
  160. package/tools/corewire/service_contract.zig +250 -0
  161. package/tools/corewire/sidecar.zig +26 -15
@@ -12,12 +12,14 @@
12
12
  //! view. Shell command events can map into messages through `on_command`.
13
13
  //!
14
14
  //! Secondary windows are model-declared: `Options.windows_fn` returns the
15
- //! window descriptors that should exist right now (presence IS
16
- //! visibility), `Options.window_view` builds each declared window's
15
+ //! window descriptors that should exist right now (presence IS liveness;
16
+ //! a `.hide` close policy may temporarily hide one),
17
+ //! `Options.window_view` builds each declared window's
17
18
  //! canvas tree, the runtime reconciles declared against live windows
18
19
  //! after every rebuild, input from any window dispatches Msgs with its
19
- //! window identity, and a user close dispatches the descriptor's
20
- //! `on_close` Msg — the dismissal precedent, applied to windows.
20
+ //! window identity, and a `.quit` user close dispatches the descriptor's
21
+ //! `on_close` Msg while `.hide` retains it — the platform close-policy
22
+ //! contract applied to model-declared windows.
21
23
  //!
22
24
  //! Markup apps choose an engine per build: `Options.markup` runs the
23
25
  //! runtime parser/interpreter (dev, hot reload), while
@@ -32,6 +34,7 @@ const builtin = @import("builtin");
32
34
  const geometry = @import("geometry");
33
35
  const canvas = @import("canvas");
34
36
  const app_manifest = @import("app_manifest");
37
+ const security = @import("../security/root.zig");
35
38
  const platform = @import("../platform/root.zig");
36
39
  const core = @import("core.zig");
37
40
  const canvas_frame = @import("canvas_frame.zig");
@@ -250,18 +253,43 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
250
253
  /// Menu items: `label` is the visible title, `command` the
251
254
  /// name handed to `on_command`, `id` a unique non-zero id.
252
255
  items: []const platform.TrayMenuItem = &.{},
256
+ /// Optional lifecycle commands: ordinary click (then open),
257
+ /// Option-click (without opening), and every menu-open. All
258
+ /// enter the same `on_command` route as menu rows.
259
+ activation_command: []const u8 = "",
260
+ alternate_activation_command: []const u8 = "",
261
+ open_command: []const u8 = "",
253
262
  };
254
263
 
255
264
  /// Model-derived status-item state returned by
256
- /// `Options.status_item_fn`: the live button title and menu.
265
+ /// `Options.status_item_fn`: install-time shell fields plus the
266
+ /// live button presentation and menu.
257
267
  /// Slices may point at the scratch the fn received, the model, or
258
268
  /// static strings — they only need to outlive the apply (the
259
269
  /// runtime and platform copy what they keep).
260
270
  pub const StatusItemState = struct {
261
271
  title: []const u8 = "",
272
+ presentation: platform.TrayPresentation = .{},
273
+ /// Install-time shell fields. A TypeScript core has no Zig
274
+ /// options block, so its statusItem record supplies these on
275
+ /// the first frame. Empty fields inherit StatusItemOptions.
276
+ icon_path: []const u8 = "",
277
+ tooltip: []const u8 = "",
278
+ activation_command: []const u8 = "",
279
+ alternate_activation_command: []const u8 = "",
280
+ open_command: []const u8 = "",
262
281
  items: []const platform.TrayMenuItem = &.{},
263
282
  };
264
283
 
284
+ /// One entry in the model-declared status-item collection.
285
+ /// `id` is stable identity; dropping the entry removes that
286
+ /// native status item, while every other field patches in place.
287
+ pub const StatusItemDescriptor = struct {
288
+ id: platform.StatusItemId,
289
+ visible: bool = true,
290
+ state: StatusItemState = .{},
291
+ };
292
+
265
293
  /// Scratch handed to `status_item_fn` so a derived title
266
294
  /// (`std.fmt.bufPrint(&scratch.title_buffer, "{d} open", ...)`)
267
295
  /// and a built-up item list need no model-side storage. Lives on
@@ -269,23 +297,43 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
269
297
  /// apply.
270
298
  pub const StatusItemScratch = struct {
271
299
  title_buffer: [platform.max_tray_title_bytes]u8 = undefined,
300
+ arena_buffer: [2048]u8 = undefined,
272
301
  items: [platform.max_tray_items]platform.TrayMenuItem = undefined,
273
302
  };
274
303
 
304
+ /// Scratch for `status_items_fn`. The flat row store gives each
305
+ /// of the eight status items its full 32-row budget without heap
306
+ /// allocation; TypeScript adapters partition it by descriptor.
307
+ pub const StatusItemsScratch = struct {
308
+ status_items: [platform.max_status_items]StatusItemDescriptor = undefined,
309
+ title_buffers: [platform.max_status_items][platform.max_tray_title_bytes]u8 = undefined,
310
+ arena_buffer: [platform.max_status_items * 2048]u8 = undefined,
311
+ items: [platform.max_status_items * platform.max_tray_items]platform.TrayMenuItem = undefined,
312
+ };
313
+
314
+ const AppliedStatusItem = struct {
315
+ id: platform.StatusItemId = 0,
316
+ active: bool = false,
317
+ shell_hash: u64 = 0,
318
+ presentation_hash: u64 = 0,
319
+ menu_hash: u64 = 0,
320
+ shell_unsupported: bool = false,
321
+ presentation_unsupported: bool = false,
322
+ };
323
+
275
324
  /// Budget for model-declared secondary windows (see
276
325
  /// `canvas_limits.max_ui_app_windows` for the sizing rationale).
277
326
  pub const max_ui_windows: usize = canvas_limits.max_ui_app_windows;
278
327
 
279
328
  /// A model-declared secondary window (`Options.windows_fn`):
280
329
  /// settings, about, inspectors. Identity is `label`; PRESENCE in
281
- /// the returned slice is visibility — the runtime reconciles the
330
+ /// the returned slice is liveness — the runtime reconciles the
282
331
  /// declared set against live windows after every rebuild,
283
332
  /// creating the missing and closing the no-longer-declared.
284
- /// There is deliberately no `visible` flag: the platform window
285
- /// channel is create/focus/close with no hide, so a
286
- /// hidden-but-open descriptor would lie about what exists. The
287
- /// model bool that `windows_fn` consults IS the visibility
288
- /// channel, exactly like a dismissible surface's open flag.
333
+ /// There is deliberately no `visible` flag: transient visibility
334
+ /// is host state, changed through `hideWindow`/`showWindow` or a
335
+ /// `.hide` close policy. Stop declaring the window to close it and
336
+ /// release its retained views.
289
337
  pub const WindowDescriptor = struct {
290
338
  /// Window label: the stable identity across rebuilds, and
291
339
  /// the label automation snapshots print for the window.
@@ -329,8 +377,19 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
329
377
  always_on_top: bool = false,
330
378
  click_through: bool = false,
331
379
  activate_on_show: bool = true,
380
+ /// Whether macOS offers native fullscreen for this window.
381
+ /// False leaves the window resizable but disables the green
382
+ /// fullscreen affordance and fullscreen command.
383
+ allows_fullscreen: bool = true,
384
+ /// What the USER'S close affordance does. `.quit` (the
385
+ /// default) really closes the window; `.hide` retains its
386
+ /// native identity and views for a later `showWindow`. Fixed
387
+ /// at create like the titlebar. Unsupported hosts refuse
388
+ /// `.hide` rather than strand an unreachable hidden window.
389
+ close_policy: app_manifest.WindowClosePolicy = .quit,
332
390
  /// Msg dispatched when the USER closes the window (never for
333
- /// a reconcile close the model itself initiated). The
391
+ /// a `.hide` policy hide or a reconcile close the model itself
392
+ /// initiated). The
334
393
  /// dismissal precedent: the window is already gone as an
335
394
  /// optimistic echo; the model clears its open flag in
336
395
  /// `update` — or keeps declaring the window and the next
@@ -709,17 +768,24 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
709
768
  /// tray title seam keep the menu updates and log the title
710
769
  /// gap once.
711
770
  status_item_fn: ?*const fn (model: *const ModelT, scratch: *StatusItemScratch) StatusItemState = null,
771
+ /// Model-declared status-item collection. Stable non-zero
772
+ /// identifiers own native identity; presence creates,
773
+ /// absence removes, and changed shell/presentation/menu
774
+ /// fields patch the existing item independently. Mutually
775
+ /// exclusive with `status_item` and `status_item_fn`.
776
+ status_items_fn: ?*const fn (model: *const ModelT, scratch: *StatusItemsScratch) []const StatusItemDescriptor = null,
712
777
  /// Model-declared secondary windows, reconciled after every
713
778
  /// rebuild (and on the installing frame): windows the model
714
779
  /// declares exist, windows it stops declaring close — the
715
780
  /// `status_item_fn` shape applied to the window set, so a
716
781
  /// settings window is `if (model.settings_open)` declaring a
717
782
  /// descriptor, opened by a Msg and closed by one. Requires
718
- /// `window_view`. A user close dispatches the descriptor's
719
- /// `on_close` Msg (the dismissal precedent: the engine
720
- /// already closed it; the model's next declared set is
721
- /// truth). Reconcile failures degrade to logged warnings —
722
- /// a failed create never takes the render loop down.
783
+ /// `window_view`. A `.quit` user close dispatches the
784
+ /// descriptor's `on_close` Msg (the dismissal precedent: the
785
+ /// engine already closed it; the model's next declared set is
786
+ /// truth); `.hide` retains the declared window and dispatches
787
+ /// no close Msg. Reconcile failures degrade to logged warnings
788
+ /// — a failed create never takes the render loop down.
723
789
  windows_fn: ?*const fn (model: *const ModelT, scratch: *WindowsScratch) []const WindowDescriptor = null,
724
790
  /// Per-window view for declared secondary windows, keyed by
725
791
  /// the descriptor's window label — the `view` seam with the
@@ -764,6 +830,12 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
764
830
  canvas_label_storage: [app_manifest.max_view_label_bytes]u8 = undefined,
765
831
  canvas_label_len: usize = 0,
766
832
  window_id: platform.WindowId = 0,
833
+ /// Owned copy of `on_close`: windows outlive the callback pass
834
+ /// that declared them, and TypeScript channel messages in
835
+ /// particular may point into a per-cycle decode arena. Keep the
836
+ /// payload alive until the user closes the window (or the model
837
+ /// replaces the declaration).
838
+ on_close_arena: std.heap.ArenaAllocator,
767
839
  on_close: ?MsgT = null,
768
840
  /// The descriptor's top-level alpha contract also controls
769
841
  /// this slot's gpu alpha mode and frame clear. Without both,
@@ -800,10 +872,27 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
800
872
  arenas: [2]std.heap.ArenaAllocator,
801
873
 
802
874
  fn init(backing: std.mem.Allocator) WindowSlot {
803
- return .{ .arenas = .{
804
- std.heap.ArenaAllocator.init(backing),
805
- std.heap.ArenaAllocator.init(backing),
806
- } };
875
+ return .{
876
+ .on_close_arena = std.heap.ArenaAllocator.init(backing),
877
+ .arenas = .{
878
+ std.heap.ArenaAllocator.init(backing),
879
+ std.heap.ArenaAllocator.init(backing),
880
+ },
881
+ };
882
+ }
883
+
884
+ fn setOnClose(self: *WindowSlot, msg: ?MsgT) error{ OutOfMemory, HoverCapturePayloadUnsupported }!void {
885
+ _ = self.on_close_arena.reset(.retain_capacity);
886
+ self.on_close = null;
887
+ if (msg) |value| {
888
+ self.on_close = try Self.deepCopyMsgValue(MsgT, value, self.on_close_arena.allocator(), 0);
889
+ }
890
+ }
891
+
892
+ fn deinit(self: *WindowSlot) void {
893
+ self.on_close_arena.deinit();
894
+ self.arenas[0].deinit();
895
+ self.arenas[1].deinit();
807
896
  }
808
897
 
809
898
  fn label(self: *const WindowSlot) []const u8 {
@@ -939,19 +1028,15 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
939
1028
  web_pane_state_count: usize = 0,
940
1029
  /// Exactly-once guard for `Options.status_item`/`status_item_fn`.
941
1030
  status_item_installed: bool = false,
942
- /// True once `createTray` succeeded — the gate for model-driven
943
- /// tray updates (`status_item_fn`).
944
- tray_created: bool = false,
945
- /// The platform reported no tray-title seam; stop retrying (menu
946
- /// updates keep flowing).
947
- tray_title_unsupported: bool = false,
948
- /// Hashes of the last APPLIED model-derived tray state, so
949
- /// rebuilds only touch the platform when the output changed.
950
- tray_title_hash: u64 = 0,
951
- tray_menu_hash: u64 = 0,
1031
+ /// Last successfully created status-item identities and their
1032
+ /// applied channel hashes. Each channel patches independently;
1033
+ /// menu changes never replace the native item.
1034
+ applied_status_items: [platform.max_status_items]AppliedStatusItem = [_]AppliedStatusItem{.{}} ** platform.max_status_items,
1035
+ applied_status_item_count: usize = 0,
952
1036
  /// Scratch handed to `status_item_fn`; on the app struct so the
953
1037
  /// returned slices outlive the apply.
954
1038
  tray_scratch: StatusItemScratch = .{},
1039
+ status_items_scratch: StatusItemsScratch = .{},
955
1040
  /// Press-and-hold gesture state (`ElementOptions.on_hold`): the
956
1041
  /// widget id whose press armed the hold timer, and whether the
957
1042
  /// timer fired for the current gesture (a fired hold suppresses
@@ -1336,8 +1421,7 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
1336
1421
  }
1337
1422
  }
1338
1423
  for (&self.window_slots) |*slot| {
1339
- slot.arenas[0].deinit();
1340
- slot.arenas[1].deinit();
1424
+ slot.deinit();
1341
1425
  }
1342
1426
  for (&self.hover_msg_leave_arenas) |*arena| arena.deinit();
1343
1427
  self.drag_msg_template_arena.deinit();
@@ -1383,15 +1467,47 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
1383
1467
  fn bindEffectsChannel(self: *Self, runtime: *Runtime) void {
1384
1468
  self.effects.bindServices(&runtime.options.platform.services);
1385
1469
  self.effects.bindEnviron(runtime.options.environ);
1470
+ if (runtime.options.record_store) |binding| {
1471
+ self.effects.bindRecordStore(binding);
1472
+ }
1473
+ if (runtime.options.relational_store) |binding| {
1474
+ self.effects.bindRelationalStore(binding);
1475
+ }
1476
+ self.effects.bindCredentialsStore(.{
1477
+ .services = &runtime.options.platform.services,
1478
+ .service = runtime.options.platform.app_info.bundle_id,
1479
+ .permitted = runtime.options.credentials_enabled and
1480
+ security.hasPermission(runtime.options.security.permissions, security.permission_credentials),
1481
+ });
1482
+ if (runtime.options.file_access) |binding| {
1483
+ self.effects.bindFileAccess(binding);
1484
+ } else if (!builtin.is_test and !self.effects.replayArmed()) {
1485
+ // Fail closed for custom/older runners that omit the new path
1486
+ // policy. Replay is exempt: the journal is the whole world and
1487
+ // fake file requests must park without consulting live paths.
1488
+ self.effects.bindFileAccess(.{
1489
+ .roots = &.{},
1490
+ .permitted = security.hasPermission(runtime.options.security.permissions, security.permission_filesystem),
1491
+ .enforce = true,
1492
+ });
1493
+ }
1386
1494
  self.effects.bindImages(runtime.canvasImageRegistryBinding());
1387
1495
  self.effects.bindMediaSurfaces(runtime.mediaSurfaceBinding());
1388
1496
  self.effects.bindWindowActions(.{
1389
1497
  .context = runtime,
1390
1498
  .close_fn = effectsCloseWindowByLabel,
1391
1499
  .minimize_fn = effectsMinimizeWindowByLabel,
1500
+ .hide_fn = effectsHideWindowByLabel,
1392
1501
  .show_fn = effectsShowWindowByLabel,
1502
+ .dock_presence_fn = effectsSetDockPresence,
1393
1503
  .quit_fn = effectsQuitApp,
1394
1504
  });
1505
+ self.effects.bindSystemServices(.{
1506
+ .context = runtime,
1507
+ .open_external_url_fn = effectsOpenExternalUrl,
1508
+ .reveal_path_fn = effectsRevealPath,
1509
+ .format_local_time_fn = effectsFormatLocalTime,
1510
+ });
1395
1511
  if (runtime.options.session_recorder) |recorder| {
1396
1512
  self.effects.bindJournal(recorder.effectJournal());
1397
1513
  }
@@ -1450,19 +1566,42 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
1450
1566
  record.truncated,
1451
1567
  record.dropped,
1452
1568
  ),
1453
- .file => try self.effects.feedFileResult(record.key, record.file_outcome, record.payload),
1569
+ .file => try self.effects.feedFileResultDetailed(.{
1570
+ .key = record.key,
1571
+ .op = record.file_op,
1572
+ .event = record.file_event,
1573
+ .outcome = record.file_outcome,
1574
+ .bytes = record.payload,
1575
+ .total = record.file_total,
1576
+ .mtime_ms = record.file_mtime_ms,
1577
+ .exists = record.file_exists,
1578
+ }),
1454
1579
  .clipboard => try self.effects.feedClipboardResult(record.key, record.clipboard_outcome, record.payload),
1455
1580
  // `.host` records ride the route in `code` (0 ok / 1
1456
1581
  // err); rejections never reach here — they carry
1457
1582
  // `.rejected` and regenerate from the same
1458
1583
  // deterministic validation, like `.timer` records.
1459
1584
  .host => try self.effects.feedHostResult(record.key, record.code == 0, record.payload),
1585
+ .credentials => try self.effects.feedCredentialsResult(
1586
+ record.key,
1587
+ record.credentials_operation,
1588
+ record.credentials_outcome,
1589
+ record.credentials_secret_len,
1590
+ record.credentials_digest,
1591
+ ),
1592
+ .db => try self.effects.feedDbResult(
1593
+ record.key,
1594
+ runtime_effects.dbKindFromJournalCode(record.code) orelse return error.ReplayDamagedRecord,
1595
+ runtime_effects.dbOutcomeFromJournalCode(record.code) orelse return error.ReplayDamagedRecord,
1596
+ record.payload,
1597
+ ),
1460
1598
  .clock => try self.effects.pushReplayClock(record.clock_wall_ms),
1461
1599
  // `.env` records carry the arm name in `stderr_tail`
1462
1600
  // and the value in `payload`; the TS adapter's
1463
1601
  // envMsgs dispatch consumes the queue on the
1464
1602
  // replayed installing frame (zero env reads).
1465
1603
  .env => try self.effects.pushReplayEnv(record.stderr_tail, record.payload),
1604
+ .persist => try self.effects.pushReplayPersist(record.persist_outcome, record.payload),
1466
1605
  // `.image` records deliver the RECORDED terminal
1467
1606
  // verbatim (byte-identical Msg stream on any host)
1468
1607
  // and re-register the journaled source bytes —
@@ -1619,6 +1758,10 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
1619
1758
  } else {
1620
1759
  self.options.update.?(&self.model, msg);
1621
1760
  }
1761
+ // One update call is one complete command batch. Re-run live
1762
+ // relational reads only after the batch has walked so several
1763
+ // writes touching the same table still coalesce into one result.
1764
+ self.effects.flushDbSubscriptions();
1622
1765
  }
1623
1766
 
1624
1767
  /// Drain the effect completion queue on the loop thread: every
@@ -2607,7 +2750,7 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
2607
2750
  for (declared) |descriptor| {
2608
2751
  if (self.windowSlotIndexByLabel(descriptor.label)) |slot_index| {
2609
2752
  // Already live: the close Msg follows the model.
2610
- self.window_slots[slot_index].on_close = descriptor.on_close;
2753
+ self.setWindowSlotOnClose(&self.window_slots[slot_index], descriptor.on_close);
2611
2754
  continue;
2612
2755
  }
2613
2756
  self.createWindowSlot(runtime, descriptor);
@@ -2678,8 +2821,10 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
2678
2821
  .always_on_top = descriptor.always_on_top,
2679
2822
  .click_through = descriptor.click_through,
2680
2823
  .activate_on_show = descriptor.activate_on_show,
2824
+ .allows_fullscreen = descriptor.allows_fullscreen,
2681
2825
  .min_width = descriptor.min_width,
2682
2826
  .min_height = descriptor.min_height,
2827
+ .close_policy = descriptor.close_policy,
2683
2828
  // Deterministic reopen: the descriptor is the geometry
2684
2829
  // channel, not a persisted frame store.
2685
2830
  .restore_state = false,
@@ -2695,7 +2840,7 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
2695
2840
  slot.canvas_label_len = descriptor.canvas_label.len;
2696
2841
  @memcpy(slot.canvas_label_storage[0..descriptor.canvas_label.len], descriptor.canvas_label);
2697
2842
  slot.window_id = info.id;
2698
- slot.on_close = descriptor.on_close;
2843
+ self.setWindowSlotOnClose(slot, descriptor.on_close);
2699
2844
  slot.transparent = descriptor.transparent;
2700
2845
  slot.installed = false;
2701
2846
  slot.canvas_size = .{ .width = descriptor.width, .height = descriptor.height };
@@ -2708,6 +2853,24 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
2708
2853
  self.window_slot_count += 1;
2709
2854
  }
2710
2855
 
2856
+ fn setWindowSlotOnClose(self: *Self, slot: *WindowSlot, msg: ?MsgT) void {
2857
+ _ = self;
2858
+ slot.setOnClose(msg) catch |err| {
2859
+ slot.on_close = null;
2860
+ _ = slot.on_close_arena.reset(.free_all);
2861
+ switch (err) {
2862
+ error.OutOfMemory => ui_app_log.warn(
2863
+ "declared window '{s}' could not retain its on_close message: out of memory; user close will not dispatch it",
2864
+ .{slot.label()},
2865
+ ),
2866
+ error.HoverCapturePayloadUnsupported => ui_app_log.warn(
2867
+ "declared window '{s}' has an on_close payload that cannot be owned; bind scalar, record, union, array, optional, or slice data",
2868
+ .{slot.label()},
2869
+ ),
2870
+ }
2871
+ };
2872
+ }
2873
+
2711
2874
  /// The gpu_surface shell view for a declared window: the
2712
2875
  /// descriptor's canvas label wearing the MAIN canvas's declared
2713
2876
  /// gpu options (backend, pixel format, present mode...), so a
@@ -2754,8 +2917,7 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
2754
2917
  self.window_slots[index] = self.window_slots[last];
2755
2918
  self.window_slots[last] = WindowSlot.init(self.backing);
2756
2919
  self.window_slot_count = last;
2757
- removed.arenas[0].deinit();
2758
- removed.arenas[1].deinit();
2920
+ removed.deinit();
2759
2921
  runtime.closeWindow(window_id) catch |err| {
2760
2922
  ui_app_log.warn("declared window close failed: {s}", .{@errorName(err)});
2761
2923
  };
@@ -2763,17 +2925,19 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
2763
2925
 
2764
2926
  /// Drop a slot whose runtime window is ALREADY gone (the user
2765
2927
  /// closed it): bookkeeping only, no platform call.
2766
- fn forgetWindowSlot(self: *Self, index: usize) ?MsgT {
2928
+ fn forgetWindowSlot(self: *Self, index: usize) WindowSlot {
2767
2929
  self.releaseContextMenuSnapshotForWindow(self.window_slots[index].window_id);
2768
- const on_close = self.window_slots[index].on_close;
2769
2930
  const last = self.window_slot_count - 1;
2770
2931
  var removed = self.window_slots[index];
2771
2932
  self.window_slots[index] = self.window_slots[last];
2772
2933
  self.window_slots[last] = WindowSlot.init(self.backing);
2773
2934
  self.window_slot_count = last;
2935
+ // The retained tree is dead with the native window. Keep only
2936
+ // the on-close arena alive through the synchronous dispatch
2937
+ // below, then release it there as well.
2774
2938
  removed.arenas[0].deinit();
2775
2939
  removed.arenas[1].deinit();
2776
- return on_close;
2940
+ return removed;
2777
2941
  }
2778
2942
 
2779
2943
  /// Rebuild every installed secondary window's tree from the
@@ -3610,69 +3774,177 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
3610
3774
  /// menu): ~350 ms press-and-hold.
3611
3775
  pub const press_hold_duration_ns: u64 = 350 * std.time.ns_per_ms;
3612
3776
 
3613
- /// Install the menu-bar extra once, on the installing frame.
3614
- /// Selecting one of its items dispatches the item's `command`
3615
- /// through the ordinary `on_command` path (source `.tray`).
3616
- /// Unsupported platforms degrade to a logged warning. With a
3617
- /// `status_item_fn`, the model's derived title/items win from
3618
- /// the very first frame (the static options keep icon+tooltip).
3777
+ /// Install the declarative status-item surface on the installing
3778
+ /// frame. Collection entries reconcile by stable id; the legacy
3779
+ /// singular channel occupies the reserved primary id.
3619
3780
  fn installStatusItem(self: *Self, runtime: *Runtime) void {
3620
3781
  if (self.status_item_installed) return;
3621
- if (self.options.status_item == null and self.options.status_item_fn == null) return;
3782
+ if (self.options.status_item == null and self.options.status_item_fn == null and self.options.status_items_fn == null) return;
3783
+ if (self.options.status_items_fn != null and (self.options.status_item != null or self.options.status_item_fn != null)) {
3784
+ @panic("UiApp status_items_fn is mutually exclusive with status_item/status_item_fn");
3785
+ }
3622
3786
  self.status_item_installed = true;
3623
- const static = self.options.status_item orelse StatusItemOptions{};
3624
- var title = static.title;
3625
- var items = static.items;
3626
- if (self.options.status_item_fn) |state_fn| {
3627
- const state = state_fn(&self.model, &self.tray_scratch);
3628
- title = state.title;
3629
- items = state.items;
3787
+ self.reconcileStatusItems(runtime, self.desiredStatusItems());
3788
+ }
3789
+
3790
+ /// Re-derive the status-item collection after every committed
3791
+ /// rebuild and patch shell, presentation, and menu independently.
3792
+ fn applyStatusItem(self: *Self, runtime: *Runtime) void {
3793
+ if (!self.status_item_installed) return;
3794
+ if (self.options.status_item_fn == null and self.options.status_items_fn == null) return;
3795
+ self.reconcileStatusItems(runtime, self.desiredStatusItems());
3796
+ }
3797
+
3798
+ fn desiredStatusItems(self: *Self) []const StatusItemDescriptor {
3799
+ if (self.options.status_items_fn) |items_fn| {
3800
+ return items_fn(&self.model, &self.status_items_scratch);
3630
3801
  }
3631
- runtime.createTray(.{
3632
- .title = title,
3802
+ const static = self.options.status_item orelse StatusItemOptions{};
3803
+ var state: StatusItemState = .{
3804
+ .title = static.title,
3805
+ .presentation = .{ .title = static.title },
3633
3806
  .icon_path = static.icon_path,
3634
3807
  .tooltip = static.tooltip,
3635
- .items = items,
3636
- }) catch |err| {
3637
- ui_app_log.warn("status item install failed: {s}", .{@errorName(err)});
3638
- return;
3808
+ .activation_command = static.activation_command,
3809
+ .alternate_activation_command = static.alternate_activation_command,
3810
+ .open_command = static.open_command,
3811
+ .items = static.items,
3812
+ };
3813
+ if (self.options.status_item_fn) |state_fn| {
3814
+ state = state_fn(&self.model, &self.tray_scratch);
3815
+ if (state.presentation.title.len == 0) state.presentation.title = state.title;
3816
+ if (state.icon_path.len == 0) state.icon_path = static.icon_path;
3817
+ if (state.tooltip.len == 0) state.tooltip = static.tooltip;
3818
+ if (state.activation_command.len == 0) state.activation_command = static.activation_command;
3819
+ if (state.alternate_activation_command.len == 0) state.alternate_activation_command = static.alternate_activation_command;
3820
+ if (state.open_command.len == 0) state.open_command = static.open_command;
3821
+ }
3822
+ self.status_items_scratch.status_items[0] = .{
3823
+ .id = platform.primary_status_item_id,
3824
+ .state = state,
3639
3825
  };
3640
- self.tray_created = true;
3641
- self.tray_title_hash = hashTrayTitle(title);
3642
- self.tray_menu_hash = hashTrayMenu(items);
3826
+ return self.status_items_scratch.status_items[0..1];
3643
3827
  }
3644
3828
 
3645
- /// Re-derive the tray state from the model after a rebuild and
3646
- /// patch only what changed — the `web_panes` shape for the menu
3647
- /// bar. Failures degrade to a logged warning; a rejected
3648
- /// state is remembered so a static model does not warn per frame.
3649
- fn applyStatusItem(self: *Self, runtime: *Runtime) void {
3650
- const state_fn = self.options.status_item_fn orelse return;
3651
- if (!self.tray_created) return;
3652
- const state = state_fn(&self.model, &self.tray_scratch);
3653
-
3654
- const title_hash = hashTrayTitle(state.title);
3655
- if (title_hash != self.tray_title_hash) {
3656
- self.tray_title_hash = title_hash;
3657
- if (!self.tray_title_unsupported) {
3658
- runtime.updateTrayTitle(state.title) catch |err| {
3659
- if (err == error.UnsupportedService) {
3660
- self.tray_title_unsupported = true;
3661
- ui_app_log.warn("status item title updates unsupported on this platform: the menu keeps updating, the button title stays \"{s}\"-era static", .{state.title});
3662
- } else {
3663
- ui_app_log.warn("status item title update failed: {s}", .{@errorName(err)});
3664
- }
3829
+ fn reconcileStatusItems(self: *Self, runtime: *Runtime, declared: []const StatusItemDescriptor) void {
3830
+ if (declared.len > platform.max_status_items) {
3831
+ ui_app_log.warn("status item collection has {d} entries; at most {d} are supported", .{ declared.len, platform.max_status_items });
3832
+ }
3833
+ const desired = declared[0..@min(declared.len, platform.max_status_items)];
3834
+
3835
+ for (&self.applied_status_items) |*applied| {
3836
+ if (!applied.active or statusItemDeclared(desired, applied.id)) continue;
3837
+ runtime.removeStatusItem(applied.id) catch |err| {
3838
+ ui_app_log.warn("status item #{d} remove failed: {s}", .{ applied.id, @errorName(err) });
3839
+ continue;
3840
+ };
3841
+ applied.* = .{};
3842
+ self.applied_status_item_count -= 1;
3843
+ }
3844
+
3845
+ for (desired, 0..) |raw_descriptor, index| {
3846
+ if (raw_descriptor.id == 0 or statusItemIdAppearedEarlier(desired, index, raw_descriptor.id)) {
3847
+ ui_app_log.warn("status item declaration ignored: identifiers must be unique and non-zero (got {d})", .{raw_descriptor.id});
3848
+ continue;
3849
+ }
3850
+ var descriptor = raw_descriptor;
3851
+ if (descriptor.state.presentation.title.len == 0) descriptor.state.presentation.title = descriptor.state.title;
3852
+ const shell = platform.TrayShell{
3853
+ .icon_path = descriptor.state.icon_path,
3854
+ .tooltip = descriptor.state.tooltip,
3855
+ .visible = descriptor.visible,
3856
+ .activation_command = descriptor.state.activation_command,
3857
+ .alternate_activation_command = descriptor.state.alternate_activation_command,
3858
+ .open_command = descriptor.state.open_command,
3859
+ };
3860
+ const shell_hash = hashTrayShell(shell);
3861
+ const presentation_hash = hashTrayPresentation(descriptor.state.presentation);
3862
+ const menu_hash = hashTrayMenu(descriptor.state.items);
3863
+
3864
+ const applied = self.findAppliedStatusItem(descriptor.id) orelse self.emptyAppliedStatusItem() orelse {
3865
+ ui_app_log.warn("status item #{d} ignored: status-item capacity is full", .{descriptor.id});
3866
+ continue;
3867
+ };
3868
+ if (!applied.active) {
3869
+ runtime.createStatusItem(descriptor.id, .{
3870
+ .title = descriptor.state.presentation.title,
3871
+ .icon_path = shell.icon_path,
3872
+ .tooltip = shell.tooltip,
3873
+ .visible = shell.visible,
3874
+ .items = descriptor.state.items,
3875
+ .presentation = descriptor.state.presentation,
3876
+ .activation_command = shell.activation_command,
3877
+ .alternate_activation_command = shell.alternate_activation_command,
3878
+ .open_command = shell.open_command,
3879
+ }) catch |err| {
3880
+ ui_app_log.warn("status item #{d} install failed: {s}", .{ descriptor.id, @errorName(err) });
3881
+ continue;
3882
+ };
3883
+ applied.* = .{
3884
+ .id = descriptor.id,
3885
+ .active = true,
3886
+ .shell_hash = shell_hash,
3887
+ .presentation_hash = presentation_hash,
3888
+ .menu_hash = menu_hash,
3889
+ };
3890
+ self.applied_status_item_count += 1;
3891
+ continue;
3892
+ }
3893
+
3894
+ if (shell_hash != applied.shell_hash) {
3895
+ applied.shell_hash = shell_hash;
3896
+ if (!applied.shell_unsupported) {
3897
+ runtime.updateStatusItemShell(descriptor.id, shell) catch |err| {
3898
+ if (err == error.UnsupportedService) applied.shell_unsupported = true;
3899
+ ui_app_log.warn("status item #{d} shell update failed: {s}", .{ descriptor.id, @errorName(err) });
3900
+ };
3901
+ }
3902
+ }
3903
+ if (presentation_hash != applied.presentation_hash) {
3904
+ applied.presentation_hash = presentation_hash;
3905
+ if (!applied.presentation_unsupported) {
3906
+ runtime.updateStatusItemPresentation(descriptor.id, descriptor.state.presentation) catch |err| {
3907
+ if (err == error.UnsupportedService) applied.presentation_unsupported = true;
3908
+ ui_app_log.warn("status item #{d} presentation update failed: {s}", .{ descriptor.id, @errorName(err) });
3909
+ };
3910
+ }
3911
+ }
3912
+ if (menu_hash != applied.menu_hash) {
3913
+ applied.menu_hash = menu_hash;
3914
+ runtime.updateStatusItemMenu(descriptor.id, descriptor.state.items) catch |err| {
3915
+ ui_app_log.warn("status item #{d} menu update failed: {s}", .{ descriptor.id, @errorName(err) });
3665
3916
  };
3666
3917
  }
3667
3918
  }
3919
+ }
3668
3920
 
3669
- const menu_hash = hashTrayMenu(state.items);
3670
- if (menu_hash != self.tray_menu_hash) {
3671
- self.tray_menu_hash = menu_hash;
3672
- runtime.updateTrayMenu(state.items) catch |err| {
3673
- ui_app_log.warn("status item menu update failed: {s} (items must carry unique non-zero ids and validated command names)", .{@errorName(err)});
3674
- };
3921
+ fn findAppliedStatusItem(self: *Self, id: platform.StatusItemId) ?*AppliedStatusItem {
3922
+ for (&self.applied_status_items) |*applied| {
3923
+ if (applied.active and applied.id == id) return applied;
3924
+ }
3925
+ return null;
3926
+ }
3927
+
3928
+ fn emptyAppliedStatusItem(self: *Self) ?*AppliedStatusItem {
3929
+ if (self.applied_status_item_count >= self.applied_status_items.len) return null;
3930
+ for (&self.applied_status_items) |*applied| {
3931
+ if (!applied.active) return applied;
3932
+ }
3933
+ return null;
3934
+ }
3935
+
3936
+ fn statusItemDeclared(declared: []const StatusItemDescriptor, id: platform.StatusItemId) bool {
3937
+ for (declared) |descriptor| {
3938
+ if (descriptor.id == id) return true;
3675
3939
  }
3940
+ return false;
3941
+ }
3942
+
3943
+ fn statusItemIdAppearedEarlier(declared: []const StatusItemDescriptor, index: usize, id: platform.StatusItemId) bool {
3944
+ for (declared[0..index]) |descriptor| {
3945
+ if (descriptor.id == id) return true;
3946
+ }
3947
+ return false;
3676
3948
  }
3677
3949
 
3678
3950
  /// The video channel snapshot in the builder's chrome shape
@@ -4072,8 +4344,9 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
4072
4344
  // in its place), a non-owner just drops out of the table.
4073
4345
  self.captureSlotVideoDeclaration(closed.window_id, null);
4074
4346
  self.applyVideoDeclaration(runtime);
4075
- const on_close = self.forgetWindowSlot(index);
4076
- if (on_close) |msg| {
4347
+ var removed = self.forgetWindowSlot(index);
4348
+ defer removed.on_close_arena.deinit();
4349
+ if (removed.on_close) |msg| {
4077
4350
  try self.dispatch(runtime, self.canvas_window_id, msg);
4078
4351
  }
4079
4352
  }
@@ -4195,6 +4468,10 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
4195
4468
  self.init_fx_ran = true;
4196
4469
  self.bindEffectsChannel(runtime);
4197
4470
  init_fx(&self.model, &self.effects);
4471
+ // init_fx has the same batch contract as update_fx;
4472
+ // subscriptions dirtied by boot transactions must be
4473
+ // current before their staged results are drained.
4474
+ self.effects.flushDbSubscriptions();
4198
4475
  self.publishAudioState(runtime);
4199
4476
  // Launch lap (env-gated): boot-effect cost (asset
4200
4477
  // decode/registration) splits out of the
@@ -4464,9 +4741,29 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
4464
4741
  /// Change-detection hashes for the model-derived tray state:
4465
4742
  /// field lengths are folded in so adjacent slices can
4466
4743
  /// never alias across boundaries.
4467
- fn hashTrayTitle(title: []const u8) u64 {
4468
- var hasher = std.hash.Wyhash.init(0x7261795f7469746c); // "ray_titl"
4469
- hasher.update(title);
4744
+ fn hashTrayShell(shell: platform.TrayShell) u64 {
4745
+ var hasher = std.hash.Wyhash.init(0x7261795f7368656c); // "ray_shel"
4746
+ const fields = [_][]const u8{
4747
+ shell.icon_path,
4748
+ shell.tooltip,
4749
+ shell.activation_command,
4750
+ shell.alternate_activation_command,
4751
+ shell.open_command,
4752
+ };
4753
+ for (fields) |field| {
4754
+ hasher.update(std.mem.asBytes(&field.len));
4755
+ hasher.update(field);
4756
+ }
4757
+ hasher.update(&.{@intFromBool(shell.visible)});
4758
+ return hasher.final();
4759
+ }
4760
+
4761
+ fn hashTrayPresentation(presentation: platform.TrayPresentation) u64 {
4762
+ var hasher = std.hash.Wyhash.init(0x7261795f70726573); // "ray_pres"
4763
+ hasher.update(presentation.title);
4764
+ hasher.update(std.mem.asBytes(&presentation.width));
4765
+ hasher.update(std.mem.asBytes(&presentation.icon_opacity));
4766
+ hasher.update(&.{ @intFromEnum(presentation.tone), @intFromBool(presentation.monospaced) });
4470
4767
  return hasher.final();
4471
4768
  }
4472
4769
 
@@ -4479,7 +4776,20 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
4479
4776
  hasher.update(item.label);
4480
4777
  hasher.update(std.mem.asBytes(&item.command.len));
4481
4778
  hasher.update(item.command);
4482
- hasher.update(&.{ @intFromBool(item.separator), @intFromBool(item.enabled) });
4779
+ hasher.update(std.mem.asBytes(&item.detail.len));
4780
+ hasher.update(item.detail);
4781
+ hasher.update(std.mem.asBytes(&item.key.len));
4782
+ hasher.update(item.key);
4783
+ hasher.update(&.{
4784
+ @intFromBool(item.separator),
4785
+ @intFromBool(item.enabled),
4786
+ @intFromEnum(item.role),
4787
+ @intFromBool(item.modifiers.primary),
4788
+ @intFromBool(item.modifiers.command),
4789
+ @intFromBool(item.modifiers.control),
4790
+ @intFromBool(item.modifiers.option),
4791
+ @intFromBool(item.modifiers.shift),
4792
+ });
4483
4793
  }
4484
4794
  return hasher.final();
4485
4795
  }
@@ -6091,6 +6401,13 @@ fn effectsMinimizeWindowByLabel(context: *anyopaque, window_label: []const u8) b
6091
6401
  return true;
6092
6402
  }
6093
6403
 
6404
+ fn effectsHideWindowByLabel(context: *anyopaque, window_label: []const u8) bool {
6405
+ const runtime: *Runtime = @ptrCast(@alignCast(context));
6406
+ const window_id = effectsWindowIdByLabel(runtime, window_label) orelse return false;
6407
+ runtime.hideWindow(window_id) catch return false;
6408
+ return true;
6409
+ }
6410
+
6094
6411
  fn effectsShowWindowByLabel(context: *anyopaque, window_label: []const u8) bool {
6095
6412
  const runtime: *Runtime = @ptrCast(@alignCast(context));
6096
6413
  // A policy-hidden window keeps `open` true, so the same live-window
@@ -6100,12 +6417,33 @@ fn effectsShowWindowByLabel(context: *anyopaque, window_label: []const u8) bool
6100
6417
  return true;
6101
6418
  }
6102
6419
 
6420
+ fn effectsSetDockPresence(context: *anyopaque, visible: bool) bool {
6421
+ const runtime: *Runtime = @ptrCast(@alignCast(context));
6422
+ runtime.options.platform.services.setDockPresence(visible) catch return false;
6423
+ return true;
6424
+ }
6425
+
6103
6426
  fn effectsQuitApp(context: *anyopaque) bool {
6104
6427
  const runtime: *Runtime = @ptrCast(@alignCast(context));
6105
6428
  runtime.quitApp() catch return false;
6106
6429
  return true;
6107
6430
  }
6108
6431
 
6432
+ fn effectsOpenExternalUrl(context: *anyopaque, url: []const u8) anyerror!void {
6433
+ const runtime: *Runtime = @ptrCast(@alignCast(context));
6434
+ return runtime.openExternalUrl(url);
6435
+ }
6436
+
6437
+ fn effectsRevealPath(context: *anyopaque, path: []const u8) anyerror!void {
6438
+ const runtime: *Runtime = @ptrCast(@alignCast(context));
6439
+ return runtime.revealPath(path);
6440
+ }
6441
+
6442
+ fn effectsFormatLocalTime(context: *anyopaque, timestamp_ms: i64, style: platform.LocalTimeStyle, buffer: []u8) anyerror![]const u8 {
6443
+ const runtime: *Runtime = @ptrCast(@alignCast(context));
6444
+ return runtime.formatLocalTime(timestamp_ms, style, buffer);
6445
+ }
6446
+
6109
6447
  /// The build storage pinned under a presented native context menu:
6110
6448
  /// which canvas's arena pair and which generation (index) of that pair
6111
6449
  /// built the presented tree. The canvas is named by STABLE window