@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
@@ -109,6 +109,156 @@ fn retainedTextExists(runtime: *core.Runtime, text: []const u8) !bool {
109
109
  return false;
110
110
  }
111
111
 
112
+ const RelationalUiModel = struct {
113
+ pages: u32 = 0,
114
+ rows: u32 = 0,
115
+ done: u32 = 0,
116
+ execs: u32 = 0,
117
+ };
118
+
119
+ const RelationalUiMsg = union(enum) {
120
+ add,
121
+ db: effects_mod.EffectDbResult,
122
+ };
123
+
124
+ const RelationalUiApp = ui_app_model.UiApp(RelationalUiModel, RelationalUiMsg);
125
+ const RelationalUiEffects = RelationalUiApp.Effects;
126
+
127
+ fn relationalUiInit(_: *RelationalUiModel, fx: *RelationalUiEffects) void {
128
+ fx.dbExec(.{
129
+ .key = 101,
130
+ .statements = &.{.{ .sql = "CREATE TABLE note(id INTEGER PRIMARY KEY) STRICT;" }},
131
+ .on_result = RelationalUiEffects.dbMsg(.db),
132
+ });
133
+ fx.dbSubscribe(.{
134
+ .key = 102,
135
+ .sql = "SELECT id FROM note ORDER BY id;",
136
+ .tables = &.{"note"},
137
+ .on_result = RelationalUiEffects.dbMsg(.db),
138
+ });
139
+ fx.dbExec(.{
140
+ .key = 103,
141
+ .statements = &.{.{ .sql = "INSERT INTO note(id) VALUES(1);" }},
142
+ .on_result = RelationalUiEffects.dbMsg(.db),
143
+ });
144
+ }
145
+
146
+ fn relationalUiUpdate(model: *RelationalUiModel, msg: RelationalUiMsg, fx: *RelationalUiEffects) void {
147
+ switch (msg) {
148
+ .add => fx.dbExec(.{
149
+ .key = 104,
150
+ .statements = &.{.{ .sql = "INSERT INTO note(id) VALUES(2);" }},
151
+ .on_result = RelationalUiEffects.dbMsg(.db),
152
+ }),
153
+ .db => |result| {
154
+ if (result.outcome != .ok) return;
155
+ switch (result.kind) {
156
+ .page => {
157
+ model.pages += 1;
158
+ model.rows += std.mem.readInt(u32, result.bytes[4..8], .little);
159
+ },
160
+ .done => model.done += 1,
161
+ .exec => model.execs += 1,
162
+ }
163
+ },
164
+ }
165
+ }
166
+
167
+ fn relationalUiView(ui: *RelationalUiApp.Ui, model: *const RelationalUiModel) RelationalUiApp.Ui.Node {
168
+ return ui.text(.{}, ui.fmt("{d} relational pages", .{model.pages}));
169
+ }
170
+
171
+ test "record-store test harness binds one hermetic in-memory database" {
172
+ const harness = try core.TestHarness().createWithRecordStore(std.testing.allocator, .{ .size = geometry.SizeF.init(400, 300) });
173
+ defer harness.destroy(std.testing.allocator);
174
+ try std.testing.expect(harness.record_store != null);
175
+ try std.testing.expect(harness.runtime.options.record_store != null);
176
+ harness.null_platform.gpu_surfaces = true;
177
+
178
+ const app_state = try std.testing.allocator.create(CounterApp);
179
+ defer std.testing.allocator.destroy(app_state);
180
+ app_state.* = CounterApp.init(std.heap.page_allocator, .{}, counterOptions());
181
+ defer app_state.deinit();
182
+ const app = app_state.app();
183
+ try harness.start(app);
184
+ try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_frame = .{
185
+ .label = canvas_label,
186
+ .size = geometry.SizeF.init(400, 300),
187
+ .scale_factor = 1,
188
+ .frame_index = 1,
189
+ .timestamp_ns = 1_000_000,
190
+ .nonblank = true,
191
+ } });
192
+ try app_state.dispatch(&harness.runtime, 1, .increment);
193
+ try std.testing.expect(app_state.effects.record_store_binding != null);
194
+ try harness.stop(app);
195
+ }
196
+
197
+ test "relational test harness binds one hermetic in-memory database" {
198
+ const harness = try core.TestHarness().createWithRelationalStore(std.testing.allocator, .{ .size = geometry.SizeF.init(400, 300) });
199
+ defer harness.destroy(std.testing.allocator);
200
+ try std.testing.expect(harness.relational_store != null);
201
+ try std.testing.expect(harness.runtime.options.relational_store != null);
202
+ harness.null_platform.gpu_surfaces = true;
203
+
204
+ const app_state = try std.testing.allocator.create(CounterApp);
205
+ defer std.testing.allocator.destroy(app_state);
206
+ app_state.* = CounterApp.init(std.heap.page_allocator, .{}, counterOptions());
207
+ defer app_state.deinit();
208
+ const app = app_state.app();
209
+ try harness.start(app);
210
+ try app_state.dispatch(&harness.runtime, 1, .increment);
211
+ try std.testing.expect(app_state.effects.relational_store_binding != null);
212
+ try harness.stop(app);
213
+ }
214
+
215
+ test "ui app flushes relational live queries after init and update command batches" {
216
+ const harness = try core.TestHarness().createWithRelationalStore(std.testing.allocator, .{ .size = geometry.SizeF.init(400, 300) });
217
+ defer harness.destroy(std.testing.allocator);
218
+ harness.null_platform.gpu_surfaces = true;
219
+
220
+ const app_state = try std.testing.allocator.create(RelationalUiApp);
221
+ defer std.testing.allocator.destroy(app_state);
222
+ app_state.* = RelationalUiApp.init(std.heap.page_allocator, .{}, .{
223
+ .name = "ui-app-relational-live",
224
+ .scene = counter_scene,
225
+ .canvas_label = canvas_label,
226
+ .update_fx = relationalUiUpdate,
227
+ .init_fx = relationalUiInit,
228
+ .view = relationalUiView,
229
+ });
230
+ defer app_state.deinit();
231
+ const app = app_state.app();
232
+ try harness.start(app);
233
+ try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_frame = .{
234
+ .label = canvas_label,
235
+ .size = geometry.SizeF.init(400, 300),
236
+ .scale_factor = 1,
237
+ .frame_index = 1,
238
+ .timestamp_ns = 1_000_000,
239
+ .nonblank = true,
240
+ } });
241
+
242
+ // init_fx creates the table, subscribes while it is empty, then inserts.
243
+ // Its one flush therefore delivers the initial empty page and one
244
+ // refreshed one-row page.
245
+ try app_state.drainEffects(&harness.runtime);
246
+ try std.testing.expectEqual(@as(u32, 2), app_state.model.pages);
247
+ try std.testing.expectEqual(@as(u32, 1), app_state.model.rows);
248
+ try std.testing.expectEqual(@as(u32, 2), app_state.model.done);
249
+ try std.testing.expectEqual(@as(u32, 2), app_state.model.execs);
250
+
251
+ // A later update_fx transaction must invalidate and rerun the same live
252
+ // query without the Zig app manually reaching into the effects host.
253
+ try app_state.dispatch(&harness.runtime, 1, .add);
254
+ try app_state.drainEffects(&harness.runtime);
255
+ try std.testing.expectEqual(@as(u32, 3), app_state.model.pages);
256
+ try std.testing.expectEqual(@as(u32, 3), app_state.model.rows);
257
+ try std.testing.expectEqual(@as(u32, 3), app_state.model.done);
258
+ try std.testing.expectEqual(@as(u32, 3), app_state.model.execs);
259
+ try harness.stop(app);
260
+ }
261
+
112
262
  test "ui app owns install, dispatch, and rebuild end to end" {
113
263
  // The runtime and the app are both large structs; keep them off the
114
264
  // test thread's stack.
@@ -3745,14 +3895,140 @@ test "ui app status item installs a tray and dispatches its commands" {
3745
3895
  try std.testing.expectEqual(@as(usize, 1), harness.null_platform.trayCreateCount());
3746
3896
 
3747
3897
  // Selecting the item dispatches its command through on_command.
3748
- try harness.runtime.dispatchPlatformEvent(app, .{ .tray_action = 1 });
3898
+ try harness.runtime.dispatchPlatformEvent(app, .{ .tray_action = .{ .item_id = 1 } });
3749
3899
  try std.testing.expectEqual(@as(u32, 1), app_state.model.refresh_count);
3750
3900
  // Items without commands fall back to the generic name and map to
3751
3901
  // no Msg here.
3752
- try harness.runtime.dispatchPlatformEvent(app, .{ .tray_action = 2 });
3902
+ try harness.runtime.dispatchPlatformEvent(app, .{ .tray_action = .{ .item_id = 2 } });
3753
3903
  try std.testing.expectEqual(@as(u32, 1), app_state.model.refresh_count);
3754
3904
  }
3755
3905
 
3906
+ const MultiStatusModel = struct {
3907
+ spend: u32 = 7,
3908
+ controls_visible: bool = true,
3909
+ spend_visible: bool = true,
3910
+ };
3911
+
3912
+ const MultiStatusMsg = union(enum) { bump_spend, toggle_controls, remove_spend };
3913
+ const MultiStatusApp = ui_app_model.UiApp(MultiStatusModel, MultiStatusMsg);
3914
+
3915
+ fn multiStatusUpdate(model: *MultiStatusModel, msg: MultiStatusMsg) void {
3916
+ switch (msg) {
3917
+ .bump_spend => model.spend += 1,
3918
+ .toggle_controls => model.controls_visible = !model.controls_visible,
3919
+ .remove_spend => model.spend_visible = false,
3920
+ }
3921
+ }
3922
+
3923
+ fn multiStatusView(ui: *MultiStatusApp.Ui, model: *const MultiStatusModel) MultiStatusApp.Ui.Node {
3924
+ return ui.text(.{}, ui.fmt("Spend {d}", .{model.spend}));
3925
+ }
3926
+
3927
+ fn multiStatusCommand(name: []const u8) ?MultiStatusMsg {
3928
+ if (std.mem.eql(u8, name, "spend.bump")) return .bump_spend;
3929
+ if (std.mem.eql(u8, name, "control.toggle") or std.mem.eql(u8, name, "control.hide") or std.mem.eql(u8, name, "control.show")) return .toggle_controls;
3930
+ if (std.mem.eql(u8, name, "spend.remove")) return .remove_spend;
3931
+ return null;
3932
+ }
3933
+
3934
+ fn multiStatusItems(model: *const MultiStatusModel, scratch: *MultiStatusApp.StatusItemsScratch) []const MultiStatusApp.StatusItemDescriptor {
3935
+ var count: usize = 0;
3936
+ if (model.spend_visible) {
3937
+ const title = std.fmt.bufPrint(&scratch.title_buffers[count], "${d}", .{model.spend}) catch "$";
3938
+ scratch.items[0] = .{ .id = 1, .label = "Refresh spend", .command = "spend.bump" };
3939
+ scratch.items[1] = .{ .id = 2, .label = "Remove spend", .command = "spend.remove" };
3940
+ scratch.status_items[count] = .{
3941
+ .id = 100,
3942
+ .state = .{
3943
+ .presentation = .{ .title = title, .monospaced = true },
3944
+ .icon_path = if (model.spend % 2 == 0) "spend-even.png" else "spend-odd.png",
3945
+ .tooltip = "Vercel spend",
3946
+ .items = scratch.items[0..2],
3947
+ },
3948
+ };
3949
+ count += 1;
3950
+ }
3951
+ const row_start = zero_platform.max_tray_items;
3952
+ scratch.items[row_start] = .{
3953
+ .id = 1,
3954
+ .label = if (model.controls_visible) "Hide controls" else "Show controls",
3955
+ .command = "control.toggle",
3956
+ };
3957
+ scratch.status_items[count] = .{
3958
+ .id = 200,
3959
+ .visible = model.controls_visible,
3960
+ .state = .{
3961
+ .presentation = .{ .title = "V" },
3962
+ .icon_path = if (model.controls_visible) "control-on.png" else "control-off.png",
3963
+ .tooltip = if (model.controls_visible) "Controls visible" else "Controls hidden",
3964
+ .activation_command = if (model.controls_visible) "control.hide" else "control.show",
3965
+ .items = scratch.items[row_start .. row_start + 1],
3966
+ },
3967
+ };
3968
+ count += 1;
3969
+ return scratch.status_items[0..count];
3970
+ }
3971
+
3972
+ test "ui app reconciles multiple status items independently by id" {
3973
+ const harness = try core.TestHarness().create(std.testing.allocator, .{ .size = geometry.SizeF.init(400, 300) });
3974
+ defer harness.destroy(std.testing.allocator);
3975
+ harness.null_platform.gpu_surfaces = true;
3976
+
3977
+ const app_state = try std.testing.allocator.create(MultiStatusApp);
3978
+ defer std.testing.allocator.destroy(app_state);
3979
+ app_state.* = MultiStatusApp.init(std.heap.page_allocator, .{}, .{
3980
+ .name = "ui-app-multi-status",
3981
+ .scene = counter_scene,
3982
+ .canvas_label = canvas_label,
3983
+ .update = multiStatusUpdate,
3984
+ .view = multiStatusView,
3985
+ .on_command = multiStatusCommand,
3986
+ .status_items_fn = multiStatusItems,
3987
+ });
3988
+ defer app_state.deinit();
3989
+ const app = app_state.app();
3990
+ try harness.start(app);
3991
+ try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_frame = .{
3992
+ .label = canvas_label,
3993
+ .size = geometry.SizeF.init(400, 300),
3994
+ .scale_factor = 1,
3995
+ .frame_index = 1,
3996
+ .timestamp_ns = 1_000_000,
3997
+ .nonblank = true,
3998
+ } });
3999
+
4000
+ try std.testing.expectEqual(@as(usize, 2), harness.null_platform.statusItemCount());
4001
+ try std.testing.expectEqual(@as(usize, 2), harness.null_platform.trayCreateCount());
4002
+ try std.testing.expectEqualStrings("$7", harness.null_platform.statusItemTitle(100));
4003
+ try std.testing.expectEqualStrings("V", harness.null_platform.statusItemTitle(200));
4004
+ try std.testing.expectEqualStrings("spend-odd.png", harness.null_platform.statusItemIconPath(100));
4005
+ try std.testing.expectEqualStrings("control.hide", harness.null_platform.statusItemActivationCommand(200));
4006
+
4007
+ // Both menus deliberately reuse row id 1; the status-item id keeps
4008
+ // command resolution independent.
4009
+ try harness.runtime.dispatchPlatformEvent(app, .{ .tray_action = .{ .status_item_id = 100, .item_id = 1 } });
4010
+ try std.testing.expectEqual(@as(u32, 8), app_state.model.spend);
4011
+ try std.testing.expectEqualStrings("$8", harness.null_platform.statusItemTitle(100));
4012
+ try std.testing.expectEqualStrings("spend-even.png", harness.null_platform.statusItemIconPath(100));
4013
+ try std.testing.expectEqual(@as(usize, 2), harness.null_platform.trayCreateCount());
4014
+
4015
+ try harness.runtime.dispatchPlatformEvent(app, .{ .tray_action = .{ .status_item_id = 200, .item_id = 1 } });
4016
+ try std.testing.expect(!harness.null_platform.statusItemVisible(200));
4017
+ try std.testing.expectEqualStrings("control-off.png", harness.null_platform.statusItemIconPath(200));
4018
+ try std.testing.expectEqualStrings("Controls hidden", harness.null_platform.statusItemTooltip(200));
4019
+ try std.testing.expectEqualStrings("control.show", harness.null_platform.statusItemActivationCommand(200));
4020
+ try std.testing.expectEqualStrings("Show controls", harness.null_platform.statusItemMenu(200)[0].label);
4021
+ try std.testing.expectEqual(@as(usize, 2), harness.null_platform.trayCreateCount());
4022
+ try std.testing.expectEqual(@as(usize, 2), harness.null_platform.trayShellUpdateCount());
4023
+ try std.testing.expectEqual(@as(usize, 3), harness.null_platform.trayUpdateCount());
4024
+
4025
+ try harness.runtime.dispatchPlatformEvent(app, .{ .tray_action = .{ .status_item_id = 100, .item_id = 2 } });
4026
+ try std.testing.expect(!harness.null_platform.statusItemExists(100));
4027
+ try std.testing.expect(harness.null_platform.statusItemExists(200));
4028
+ try std.testing.expectEqual(@as(usize, 1), harness.null_platform.statusItemCount());
4029
+ try std.testing.expectEqual(@as(usize, 1), harness.null_platform.trayRemoveCount());
4030
+ }
4031
+
3756
4032
  // ------------------------------------------------ model-driven status item
3757
4033
 
3758
4034
  const TrayStateModel = struct {
@@ -3851,7 +4127,7 @@ test "ui app status_item_fn drives the tray title and menu from the model" {
3851
4127
 
3852
4128
  // A model change that only affects the TITLE re-titles the live
3853
4129
  // button without rebuilding the menu or re-creating the item.
3854
- try harness.runtime.dispatchPlatformEvent(app, .{ .tray_action = 1 });
4130
+ try harness.runtime.dispatchPlatformEvent(app, .{ .tray_action = .{ .item_id = 1 } });
3855
4131
  try std.testing.expectEqual(@as(u32, 4), app_state.model.open_count);
3856
4132
  try std.testing.expectEqualStrings("ZN 4", harness.null_platform.lastTrayTitle());
3857
4133
  try std.testing.expectEqual(@as(usize, 1), harness.null_platform.trayTitleUpdateCount());
@@ -3860,7 +4136,7 @@ test "ui app status_item_fn drives the tray title and menu from the model" {
3860
4136
 
3861
4137
  // Selecting a dropdown row closes the loop: tray action -> command ->
3862
4138
  // Msg -> model, and the menu (not the title) re-applies.
3863
- try harness.runtime.dispatchPlatformEvent(app, .{ .tray_action = 11 });
4139
+ try harness.runtime.dispatchPlatformEvent(app, .{ .tray_action = .{ .item_id = 11 } });
3864
4140
  try std.testing.expectEqual(@as(u32, 1), app_state.model.selected_issue);
3865
4141
  try std.testing.expectEqual(updates_after_install + 1, harness.null_platform.trayUpdateCount());
3866
4142
  try std.testing.expectEqual(@as(usize, 1), harness.null_platform.trayTitleUpdateCount());
@@ -3868,7 +4144,7 @@ test "ui app status_item_fn drives the tray title and menu from the model" {
3868
4144
 
3869
4145
  // A rebuild whose tray output is unchanged touches nothing (the
3870
4146
  // repeat selection Msg still rebuilds the view).
3871
- try harness.runtime.dispatchPlatformEvent(app, .{ .tray_action = 11 });
4147
+ try harness.runtime.dispatchPlatformEvent(app, .{ .tray_action = .{ .item_id = 11 } });
3872
4148
  try std.testing.expectEqual(updates_after_install + 1, harness.null_platform.trayUpdateCount());
3873
4149
  try std.testing.expectEqual(@as(usize, 1), harness.null_platform.trayTitleUpdateCount());
3874
4150
  try std.testing.expectEqual(@as(usize, 1), harness.null_platform.trayCreateCount());
@@ -3914,7 +4190,7 @@ test "ui app tray state rides automation snapshots and tray-action drives a row"
3914
4190
  try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_frame = frame_event });
3915
4191
 
3916
4192
  // The snapshot exposes the applied tray: model-derived title, every
3917
- // dropdown row with id/label/command/enabled, and separators —
4193
+ // dropdown row with its action and rich presentation fields, and separators —
3918
4194
  // the menu bar is outside every window capture, so this is the only
3919
4195
  // automation-visible evidence the model-driven tray exists.
3920
4196
  {
@@ -3922,11 +4198,11 @@ test "ui app tray state rides automation snapshots and tray-action drives a row"
3922
4198
  var writer = std.Io.Writer.fixed(&buffer);
3923
4199
  try automation.snapshot.writeText(harness.runtime.automationSnapshot("Tray"), &writer);
3924
4200
  const text = writer.buffered();
3925
- try std.testing.expect(std.mem.indexOf(u8, text, "tray title=\"ZN 3\" items=4\n") != null);
3926
- try std.testing.expect(std.mem.indexOf(u8, text, " tray-item #1 label=\"Refresh\" command=\"app.refresh\" enabled=true\n") != null);
4201
+ try std.testing.expect(std.mem.indexOf(u8, text, "tray #1 title=\"ZN 3\" visible=true items=4\n") != null);
4202
+ try std.testing.expect(std.mem.indexOf(u8, text, " tray-item #1 label=\"Refresh\" command=\"app.refresh\" enabled=true detail=\"\" role=command key=\"\" modifiers=(primary=false,command=false,control=false,option=false,shift=false)\n") != null);
3927
4203
  try std.testing.expect(std.mem.indexOf(u8, text, " tray-item separator\n") != null);
3928
4204
  // The fixture disables the SELECTED row (initially issue 0).
3929
- try std.testing.expect(std.mem.indexOf(u8, text, " tray-item #10 label=\"Fix crash on resize\" command=\"issue.select.0\" enabled=false\n") != null);
4205
+ try std.testing.expect(std.mem.indexOf(u8, text, " tray-item #10 label=\"Fix crash on resize\" command=\"issue.select.0\" enabled=false detail=\"\" role=command key=\"\" modifiers=(primary=false,command=false,control=false,option=false,shift=false)\n") != null);
3930
4206
  }
3931
4207
 
3932
4208
  // `tray-action <id>` drives a dropdown row through the same platform
@@ -3939,8 +4215,8 @@ test "ui app tray state rides automation snapshots and tray-action drives a row"
3939
4215
  var writer = std.Io.Writer.fixed(&buffer);
3940
4216
  try automation.snapshot.writeText(harness.runtime.automationSnapshot("Tray"), &writer);
3941
4217
  const text = writer.buffered();
3942
- try std.testing.expect(std.mem.indexOf(u8, text, " tray-item #11 label=\"Adopt the tray seam\" command=\"issue.select.1\" enabled=false\n") != null);
3943
- try std.testing.expect(std.mem.indexOf(u8, text, " tray-item #10 label=\"Fix crash on resize\" command=\"issue.select.0\" enabled=true\n") != null);
4218
+ try std.testing.expect(std.mem.indexOf(u8, text, " tray-item #11 label=\"Adopt the tray seam\" command=\"issue.select.1\" enabled=false detail=\"\" role=command key=\"\" modifiers=(primary=false,command=false,control=false,option=false,shift=false)\n") != null);
4219
+ try std.testing.expect(std.mem.indexOf(u8, text, " tray-item #10 label=\"Fix crash on resize\" command=\"issue.select.0\" enabled=true detail=\"\" role=command key=\"\" modifiers=(primary=false,command=false,control=false,option=false,shift=false)\n") != null);
3944
4220
  }
3945
4221
 
3946
4222
  // Unknown or malformed item ids are loud driver misuse, never a
@@ -669,6 +669,7 @@ test "a padded secondary drag header keeps its layout (no double reservation)" {
669
669
 
670
670
  const VerbModel = struct {
671
671
  settings_open: bool = true,
672
+ close_policy: app_manifest.WindowClosePolicy = .quit,
672
673
  };
673
674
 
674
675
  const VerbMsg = union(enum) {
@@ -709,6 +710,7 @@ fn verbWindows(model: *const VerbModel, scratch: *VerbApp.WindowsScratch) []cons
709
710
  .title = "Settings",
710
711
  .width = 320,
711
712
  .height = 240,
713
+ .close_policy = model.close_policy,
712
714
  .on_close = .settings_closed,
713
715
  };
714
716
  count += 1;
@@ -837,6 +839,7 @@ test "the .hide close then showWindow round-trip: tray Open brings the hidden wi
837
839
  .window_view = verbWindowView,
838
840
  });
839
841
  defer app_state.destroy();
842
+ app_state.model.close_policy = .hide;
840
843
  const app = app_state.app();
841
844
  try harness.start(app);
842
845
  try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_frame = .{
@@ -853,17 +856,32 @@ test "the .hide close then showWindow round-trip: tray Open brings the hidden wi
853
856
  if (std.mem.eql(u8, info.label, settings_window_label)) settings_id = info.id;
854
857
  }
855
858
  try std.testing.expect(settings_id != 0);
859
+ try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_frame = .{
860
+ .window_id = settings_id,
861
+ .label = settings_canvas_label,
862
+ .size = geometry.SizeF.init(320, 240),
863
+ .scale_factor = 2,
864
+ .frame_index = 1,
865
+ .timestamp_ns = 2_000_000,
866
+ .nonblank = true,
867
+ } });
868
+ _ = try harness.runtime.canvasWidgetLayout(settings_id, settings_canvas_label);
856
869
 
857
- // Give the live window the .hide policy at the platform (the seam a
858
- // manifest declaration rides) and close it as the user: hidden, not
859
- // gone.
860
- for (harness.null_platform.windows[0..harness.null_platform.window_count], 0..) |window, index| {
861
- if (window.id == settings_id) harness.null_platform.window_close_policy[index] = .hide;
862
- }
870
+ // The model-declared descriptor's policy reached the REAL platform
871
+ // create seam. Closing as the user hides the window instead of
872
+ // tearing down its slot, views, or model declaration.
873
+ try std.testing.expectEqual(support.platform.WindowClosePolicy.hide, harness.null_platform.closePolicyForWindow(settings_id).?);
863
874
  const hide_event = harness.null_platform.userCloseWindow(settings_id).?;
864
875
  try harness.runtime.dispatchPlatformEvent(app, hide_event);
876
+ try std.testing.expect(app_state.model.settings_open);
877
+ try std.testing.expectEqual(@as(usize, 1), app_state.window_slot_count);
878
+ // The canvas tree and view stay installed under the same identity.
879
+ _ = try harness.runtime.canvasWidgetLayout(settings_id, settings_canvas_label);
865
880
  for (harness.runtime.listWindows(&buffer)) |info| {
866
- if (info.id == settings_id) try std.testing.expect(info.hidden);
881
+ if (info.id == settings_id) {
882
+ try std.testing.expect(info.open);
883
+ try std.testing.expect(info.hidden);
884
+ }
867
885
  }
868
886
 
869
887
  // The tray "Open" consequence: the model returns the show verb, the
@@ -882,6 +900,42 @@ test "the .hide close then showWindow round-trip: tray Open brings the hidden wi
882
900
  }
883
901
  }
884
902
 
903
+ test "a model-declared .hide window is refused on a host that cannot bring it back" {
904
+ const harness = try core.TestHarness().create(std.testing.allocator, .{ .size = geometry.SizeF.init(400, 300) });
905
+ defer harness.destroy(std.testing.allocator);
906
+ harness.null_platform.gpu_surfaces = true;
907
+ harness.null_platform.window_hide_on_close = false;
908
+ const app_state = try VerbApp.create(std.heap.page_allocator, .{
909
+ .name = "ui-app-hide-unsupported",
910
+ .scene = panel_scene,
911
+ .canvas_label = canvas_label,
912
+ .update_fx = verbUpdate,
913
+ .view = verbView,
914
+ .windows_fn = verbWindows,
915
+ .window_view = verbWindowView,
916
+ });
917
+ defer app_state.destroy();
918
+ app_state.model.close_policy = .hide;
919
+ const app = app_state.app();
920
+ try harness.start(app);
921
+ try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_frame = .{
922
+ .label = canvas_label,
923
+ .size = geometry.SizeF.init(400, 300),
924
+ .scale_factor = 2,
925
+ .frame_index = 1,
926
+ .timestamp_ns = 1_000_000,
927
+ .nonblank = true,
928
+ } });
929
+
930
+ // UiApp creation failures degrade to a warning, so the observable
931
+ // contract is that no unreachable window or retained slot exists.
932
+ var buffer: [support.platform.max_windows]support.platform.WindowInfo = undefined;
933
+ for (harness.runtime.listWindows(&buffer)) |info| {
934
+ try std.testing.expect(!std.mem.eql(u8, info.label, settings_window_label));
935
+ }
936
+ try std.testing.expectEqual(@as(usize, 0), app_state.window_slot_count);
937
+ }
938
+
885
939
  // ------------------------------------- close_policy (.quit | .hide)
886
940
 
887
941
  test "close_policy .hide: the user close hides the window, nothing tears down, and the reopen re-shows it" {
@@ -77,9 +77,14 @@ fn validateDialogString(value: []const u8, max_len: usize, allow_empty: bool) !v
77
77
 
78
78
  pub fn validateNotificationOptions(options: platform.NotificationOptions) !void {
79
79
  if (options.title.len == 0) return error.InvalidNotificationOptions;
80
+ try validateNotificationField(options.id, platform.max_notification_id_bytes);
80
81
  try validateNotificationField(options.title, platform.max_notification_title_bytes);
81
82
  try validateNotificationField(options.subtitle, platform.max_notification_subtitle_bytes);
82
83
  try validateNotificationField(options.body, platform.max_notification_body_bytes);
84
+ try validateNotificationField(options.action_label, platform.max_notification_action_label_bytes);
85
+ try validateNotificationField(options.action_command, platform.max_notification_action_command_bytes);
86
+ if ((options.action_label.len == 0) != (options.action_command.len == 0)) return error.InvalidNotificationOptions;
87
+ if (options.action_command.len > 0) try validateCommandName(options.action_command);
83
88
  }
84
89
 
85
90
  pub fn validateClipboardData(data: platform.ClipboardData) !void {
@@ -119,19 +124,52 @@ fn validateCredentialField(value: []const u8, max_len: usize) !void {
119
124
  pub fn validateTrayOptions(options: platform.TrayOptions) !void {
120
125
  try validateTrayField(options.icon_path, platform.max_tray_icon_path_bytes);
121
126
  try validateTrayField(options.title, platform.max_tray_title_bytes);
127
+ try validateTrayPresentation(options.presentation);
122
128
  try validateTrayField(options.tooltip, platform.max_tray_tooltip_bytes);
129
+ try validateTrayField(options.activation_command, platform.max_tray_item_command_bytes);
130
+ try validateTrayField(options.alternate_activation_command, platform.max_tray_item_command_bytes);
131
+ try validateTrayField(options.open_command, platform.max_tray_item_command_bytes);
132
+ if (options.activation_command.len > 0) try validateCommandName(options.activation_command);
133
+ if (options.alternate_activation_command.len > 0) try validateCommandName(options.alternate_activation_command);
134
+ if (options.open_command.len > 0) try validateCommandName(options.open_command);
123
135
  try validateTrayMenuItems(options.items);
124
136
  }
125
137
 
138
+ pub fn validateStatusItemId(status_item_id: platform.StatusItemId) !void {
139
+ if (status_item_id == 0) return error.InvalidTrayOptions;
140
+ }
141
+
142
+ pub fn validateTrayShell(shell: platform.TrayShell) !void {
143
+ try validateTrayField(shell.icon_path, platform.max_tray_icon_path_bytes);
144
+ try validateTrayField(shell.tooltip, platform.max_tray_tooltip_bytes);
145
+ try validateTrayField(shell.activation_command, platform.max_tray_item_command_bytes);
146
+ try validateTrayField(shell.alternate_activation_command, platform.max_tray_item_command_bytes);
147
+ try validateTrayField(shell.open_command, platform.max_tray_item_command_bytes);
148
+ if (shell.activation_command.len > 0) try validateCommandName(shell.activation_command);
149
+ if (shell.alternate_activation_command.len > 0) try validateCommandName(shell.alternate_activation_command);
150
+ if (shell.open_command.len > 0) try validateCommandName(shell.open_command);
151
+ }
152
+
126
153
  pub fn validateTrayTitle(title: []const u8) !void {
127
154
  try validateTrayField(title, platform.max_tray_title_bytes);
128
155
  }
129
156
 
157
+ pub fn validateTrayPresentation(presentation: platform.TrayPresentation) !void {
158
+ try validateTrayTitle(presentation.title);
159
+ if (!std.math.isFinite(presentation.width) or presentation.width < 0) return error.InvalidTrayOptions;
160
+ if (!std.math.isFinite(presentation.icon_opacity) or presentation.icon_opacity < 0 or presentation.icon_opacity > 1) return error.InvalidTrayOptions;
161
+ }
162
+
130
163
  pub fn validateTrayMenuItems(items: []const platform.TrayMenuItem) !void {
131
164
  if (items.len > platform.max_tray_items) return error.InvalidTrayOptions;
132
165
  for (items, 0..) |item, index| {
133
166
  try validateTrayField(item.label, platform.max_tray_item_label_bytes);
134
167
  try validateTrayField(item.command, platform.max_tray_item_command_bytes);
168
+ try validateTrayField(item.detail, platform.max_tray_item_detail_bytes);
169
+ try validateTrayField(item.key, platform.max_menu_key_bytes);
170
+ if (item.role != .command and item.role != .agent and item.command.len > 0) return error.InvalidTrayOptions;
171
+ if (item.detail.len > 0 and item.role != .info and item.role != .hero and item.role != .agent and item.role != .context) return error.InvalidTrayOptions;
172
+ if (item.separator and (item.detail.len > 0 or item.role != .command)) return error.InvalidTrayOptions;
135
173
  if (item.id != 0) {
136
174
  for (items[0..index]) |previous| {
137
175
  if (previous.id == item.id) return error.InvalidTrayOptions;
@@ -142,6 +180,10 @@ pub fn validateTrayMenuItems(items: []const platform.TrayMenuItem) !void {
142
180
  try validateCommandName(item.command);
143
181
  }
144
182
  if (!item.separator and item.label.len == 0) return error.InvalidTrayOptions;
183
+ if (item.key.len > 0) {
184
+ if (item.separator or item.command.len == 0) return error.InvalidTrayOptions;
185
+ if (!platform.isValidShortcutBinding(item.key, item.modifiers)) return error.InvalidTrayOptions;
186
+ }
145
187
  }
146
188
  }
147
189
 
@@ -203,7 +203,12 @@ pub const RuntimeView = struct {
203
203
  gpu_scale_factor: f32 = 1,
204
204
  gpu_frame_index: u64 = 0,
205
205
  gpu_timestamp_ns: u64 = 0,
206
+ /// Profiling-only completion stamp. Kept separate from gpu_timestamp_ns
207
+ /// so `profile on` can start an honest interval window without erasing
208
+ /// the live frame clock used by animation and diagnostics.
209
+ gpu_frame_profile_timestamp_ns: u64 = 0,
206
210
  gpu_frame_interval_ns: u64 = platform.default_gpu_frame_interval_ns,
211
+ gpu_input_event_count: u64 = 0,
207
212
  gpu_pending_input_timestamp_ns: u64 = 0,
208
213
  gpu_input_timestamp_ns: u64 = 0,
209
214
  gpu_input_latency_ns: u64 = 0,
@@ -218,6 +223,7 @@ pub const RuntimeView = struct {
218
223
  gpu_first_frame_latency_budget_ok: bool = true,
219
224
  gpu_first_frame_latency_recorded: bool = false,
220
225
  gpu_frame_nonblank: bool = false,
226
+ gpu_occluded: bool = false,
221
227
  gpu_sample_color: u32 = 0,
222
228
  /// Immutable creation-time backend request. `gpu_backend` below is
223
229
  /// completion state and changes to the concrete presenter reported by
@@ -1089,6 +1095,7 @@ pub const RuntimeView = struct {
1089
1095
  .gpu_frame_index = self.gpu_frame_index,
1090
1096
  .gpu_timestamp_ns = self.gpu_timestamp_ns,
1091
1097
  .gpu_frame_interval_ns = self.gpu_frame_interval_ns,
1098
+ .gpu_input_event_count = self.gpu_input_event_count,
1092
1099
  .gpu_input_timestamp_ns = self.gpu_input_timestamp_ns,
1093
1100
  .gpu_input_latency_ns = self.gpu_input_latency_ns,
1094
1101
  .gpu_input_latency_budget_ns = self.gpu_input_latency_budget_ns,
@@ -1099,6 +1106,7 @@ pub const RuntimeView = struct {
1099
1106
  .gpu_first_frame_latency_budget_exceeded_count = self.gpu_first_frame_latency_budget_exceeded_count,
1100
1107
  .gpu_first_frame_latency_budget_ok = self.gpu_first_frame_latency_budget_ok,
1101
1108
  .gpu_frame_nonblank = self.gpu_frame_nonblank,
1109
+ .gpu_occluded = self.gpu_occluded,
1102
1110
  .gpu_sample_color = self.gpu_sample_color,
1103
1111
  .gpu_backend = self.gpu_backend,
1104
1112
  .gpu_pixel_format = self.gpu_pixel_format,
@@ -1192,6 +1200,7 @@ pub const RuntimeView = struct {
1192
1200
  }
1193
1201
 
1194
1202
  pub fn recordGpuSurfaceInputTimestamp(self: *RuntimeView, timestamp_ns: u64) void {
1203
+ self.gpu_input_event_count +|= 1;
1195
1204
  if (timestamp_ns == 0) return;
1196
1205
  self.gpu_pending_input_timestamp_ns = timestamp_ns;
1197
1206
  self.gpu_input_timestamp_ns = timestamp_ns;
@@ -178,6 +178,7 @@ pub fn RuntimeWindowStorage(comptime Runtime: type) type {
178
178
  self.windows[index].info.frame = native_info.frame;
179
179
  self.windows[index].info.scale_factor = native_info.scale_factor;
180
180
  self.windows[index].info.open = native_info.open;
181
+ self.windows[index].info.hidden = native_info.hidden;
181
182
  if (!self.windows[index].main_frame_set) {
182
183
  self.windows[index].main_frame = geometry.RectF.init(0, 0, native_info.frame.width, native_info.frame.height);
183
184
  }
@@ -26,8 +26,7 @@ const viewInfoFromWebView = bridge_responses.viewInfoFromWebView;
26
26
  const RuntimeWebView = runtime_state.RuntimeWebView;
27
27
  const FocusTraversalDirection = runtime_state.FocusTraversalDirection;
28
28
  const sourceWebViewUrl = runtime_state.sourceWebViewUrl;
29
- const nowNanoseconds = runtime_clock.nowNanoseconds;
30
- const timestampToU64 = runtime_clock.timestampToU64;
29
+ const monotonicNanoseconds = runtime_clock.monotonicNanoseconds;
31
30
  const CommandSource = runtime_api.CommandSource;
32
31
 
33
32
  fn copyInto(buffer: []u8, value: []const u8) ![]const u8 {
@@ -492,7 +491,7 @@ pub fn RuntimeWindowViewRuntime(comptime Runtime: type) type {
492
491
  .gpu_color_space = if (options.kind == .gpu_surface) options.gpu_surface.color_space else .none,
493
492
  .gpu_vsync = options.kind == .gpu_surface and options.gpu_surface.vsync,
494
493
  .gpu_status = if (options.kind == .gpu_surface) .ready else .unavailable,
495
- .gpu_surface_created_timestamp_ns = if (options.kind == .gpu_surface) timestampToU64(nowNanoseconds()) else 0,
494
+ .gpu_surface_created_timestamp_ns = if (options.kind == .gpu_surface) monotonicNanoseconds() else 0,
496
495
  .focused = false,
497
496
  .keyboard_active = windowKeyboardActive(self, options.window_id),
498
497
  .open = true,
@@ -146,6 +146,24 @@ pub fn RuntimeWindowViews(comptime Runtime: type) type {
146
146
  try self.options.platform.services.minimizeWindow(window_id);
147
147
  }
148
148
 
149
+ /// Keep a live window and its views, but order it offscreen until
150
+ /// `showWindow` brings it back. This is an app-driven hide, not a
151
+ /// close, so identity and rendered state are retained.
152
+ pub fn hideWindow(self: *Runtime, window_id: platform.WindowId) anyerror!void {
153
+ const index = Self.findWindowIndexById(self, window_id) orelse return error.WindowNotFound;
154
+ if (!self.windows[index].info.open) return error.WindowNotFound;
155
+ const was_hidden = self.windows[index].info.hidden;
156
+ const was_focused = self.windows[index].info.focused;
157
+ self.windows[index].info.hidden = true;
158
+ self.windows[index].info.focused = false;
159
+ self.options.platform.services.hideWindow(window_id) catch |err| {
160
+ self.windows[index].info.hidden = was_hidden;
161
+ self.windows[index].info.focused = was_focused;
162
+ return err;
163
+ };
164
+ self.invalidated = true;
165
+ }
166
+
149
167
  /// The real OS show verb: unhide and order front — the counterpart
150
168
  /// to a `close_policy = .hide` hide, and what a tray "Open"
151
169
  /// action resolves to. Like `closeWindow`, the runtime flag
@@ -232,6 +250,7 @@ pub fn RuntimeWindowViews(comptime Runtime: type) type {
232
250
  .always_on_top = shell_window.always_on_top,
233
251
  .click_through = shell_window.click_through,
234
252
  .activate_on_show = shell_window.activate_on_show,
253
+ .allows_fullscreen = shell_window.allows_fullscreen,
235
254
  .min_width = shell_window.min_width,
236
255
  .min_height = shell_window.min_height,
237
256
  .close_policy = shell_layout.shellClosePolicy(shell_window.close_policy),