@native-sdk/cli 0.5.4 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (149) hide show
  1. package/build/app.zig +50 -1
  2. package/build.zig +534 -3
  3. package/build.zig.zon +7 -0
  4. package/native-sdk.d.ts +3 -1
  5. package/package.json +9 -9
  6. package/packages/core/package-lock.json +2 -2
  7. package/packages/core/package.json +1 -1
  8. package/packages/core/rt/rt.zig +280 -8
  9. package/packages/core/sdk/core.ts +481 -2
  10. package/packages/core/sdk/events.ts +17 -8
  11. package/packages/core/src/checker.ts +305 -2
  12. package/packages/core/src/diagnostics.ts +12 -0
  13. package/packages/core/src/emitter.ts +599 -3
  14. package/packages/core/src/typed_ast.ts +51 -4
  15. package/packages/core/src/types.ts +34 -1
  16. package/skill-data/native-ui/SKILL.md +39 -2
  17. package/skill-data/ts-core/SKILL.md +4 -2
  18. package/src/app_runner/root.zig +32 -10
  19. package/src/automation/layout_fingerprint.zig +160 -0
  20. package/src/automation/protocol.zig +82 -33
  21. package/src/automation/root.zig +1 -0
  22. package/src/automation/server.zig +1 -1
  23. package/src/automation/snapshot.zig +68 -9
  24. package/src/automation/watcher.zig +1 -1
  25. package/src/embed/host.zig +5 -0
  26. package/src/embed/ui_host.zig +13 -0
  27. package/src/platform/linux/gtk_host.c +527 -13
  28. package/src/platform/linux/gtk_host.h +25 -0
  29. package/src/platform/linux/root.zig +280 -7
  30. package/src/platform/macos/appkit_host.h +104 -6
  31. package/src/platform/macos/appkit_host.m +1283 -66
  32. package/src/platform/macos/cef_host.mm +110 -1
  33. package/src/platform/macos/root.zig +287 -7
  34. package/src/platform/null_platform.zig +398 -4
  35. package/src/platform/null_platform_tests.zig +35 -0
  36. package/src/platform/root.zig +9 -0
  37. package/src/platform/types.zig +386 -14
  38. package/src/platform/windows/root.zig +298 -9
  39. package/src/platform/windows/webview2_host.cpp +330 -5
  40. package/src/primitives/app_manifest/validation.zig +18 -0
  41. package/src/primitives/canvas/a11y_audit.zig +33 -11
  42. package/src/primitives/canvas/a11y_audit_tests.zig +20 -0
  43. package/src/primitives/canvas/drawing.zig +25 -0
  44. package/src/primitives/canvas/equality.zig +8 -0
  45. package/src/primitives/canvas/events.zig +103 -16
  46. package/src/primitives/canvas/frame.zig +125 -1
  47. package/src/primitives/canvas/layout_audit.zig +22 -5
  48. package/src/primitives/canvas/markdown_hostile_tests.zig +8 -4
  49. package/src/primitives/canvas/render_tests.zig +13 -10
  50. package/src/primitives/canvas/root.zig +48 -0
  51. package/src/primitives/canvas/terminal_box.zig +471 -0
  52. package/src/primitives/canvas/terminal_grid.zig +978 -0
  53. package/src/primitives/canvas/terminal_grid_tests.zig +1093 -0
  54. package/src/primitives/canvas/test_support.zig +1 -0
  55. package/src/primitives/canvas/tests.zig +1 -0
  56. package/src/primitives/canvas/text_tests.zig +39 -4
  57. package/src/primitives/canvas/tokens.zig +115 -12
  58. package/src/primitives/canvas/ui.zig +524 -5
  59. package/src/primitives/canvas/ui_markup.zig +195 -2
  60. package/src/primitives/canvas/ui_markup_compiled.zig +172 -1
  61. package/src/primitives/canvas/ui_markup_compiled_tests.zig +133 -8
  62. package/src/primitives/canvas/ui_markup_contract.zig +88 -5
  63. package/src/primitives/canvas/ui_markup_contract_tests.zig +39 -1
  64. package/src/primitives/canvas/ui_markup_huge_model_tests.zig +1 -0
  65. package/src/primitives/canvas/ui_markup_reflect.zig +75 -24
  66. package/src/primitives/canvas/ui_markup_tests.zig +149 -0
  67. package/src/primitives/canvas/ui_markup_view.zig +191 -0
  68. package/src/primitives/canvas/ui_markup_view_tests.zig +403 -19
  69. package/src/primitives/canvas/ui_schema.zig +97 -17
  70. package/src/primitives/canvas/ui_schema_tests.zig +18 -11
  71. package/src/primitives/canvas/ui_tests.zig +141 -9
  72. package/src/primitives/canvas/widget_access.zig +28 -2
  73. package/src/primitives/canvas/widget_anchored_tests.zig +48 -0
  74. package/src/primitives/canvas/widget_invalidation.zig +81 -1
  75. package/src/primitives/canvas/widget_layout.zig +59 -11
  76. package/src/primitives/canvas/widget_layout_tests.zig +125 -4
  77. package/src/primitives/canvas/widget_render.zig +272 -18
  78. package/src/primitives/canvas/widget_render_scroll.zig +108 -27
  79. package/src/primitives/canvas/widget_routing.zig +59 -7
  80. package/src/primitives/canvas/widget_runtime.zig +23 -0
  81. package/src/primitives/canvas/widget_runtime_tests.zig +149 -0
  82. package/src/primitives/canvas/widget_semantics.zig +119 -11
  83. package/src/primitives/canvas/widget_semantics_tests.zig +409 -0
  84. package/src/primitives/canvas/widget_tree.zig +17 -0
  85. package/src/primitives/canvas/widgets.zig +132 -0
  86. package/src/root.zig +16 -0
  87. package/src/runtime/api.zig +70 -1
  88. package/src/runtime/automation_commands.zig +20 -1
  89. package/src/runtime/automation_snapshot.zig +25 -1
  90. package/src/runtime/automation_widget_dispatch.zig +73 -8
  91. package/src/runtime/bridge_payload.zig +1 -0
  92. package/src/runtime/canvas_frame.zig +62 -7
  93. package/src/runtime/canvas_frame_animation_tests.zig +5 -4
  94. package/src/runtime/canvas_frame_helpers.zig +190 -1
  95. package/src/runtime/canvas_frame_invalidation_tests.zig +531 -0
  96. package/src/runtime/canvas_frame_patch_tests.zig +161 -10
  97. package/src/runtime/canvas_frame_retained_tests.zig +5 -2
  98. package/src/runtime/canvas_widget_accessibility_tests.zig +1 -1
  99. package/src/runtime/canvas_widget_clipboard_tests.zig +40 -0
  100. package/src/runtime/canvas_widget_context_menu.zig +269 -32
  101. package/src/runtime/canvas_widget_context_menu_tests.zig +640 -14
  102. package/src/runtime/canvas_widget_display.zig +1 -1
  103. package/src/runtime/canvas_widget_event_tests.zig +1823 -0
  104. package/src/runtime/canvas_widget_events.zig +240 -24
  105. package/src/runtime/canvas_widget_runtime.zig +213 -29
  106. package/src/runtime/canvas_widget_scroll_driver_tests.zig +170 -7
  107. package/src/runtime/canvas_widget_scroll_drivers.zig +151 -17
  108. package/src/runtime/canvas_widget_scroll_tests.zig +435 -23
  109. package/src/runtime/canvas_widget_state.zig +6 -0
  110. package/src/runtime/canvas_widget_text_tests.zig +1 -1
  111. package/src/runtime/core.zig +73 -2
  112. package/src/runtime/effects.zig +6389 -54
  113. package/src/runtime/effects_channel_tests.zig +3519 -0
  114. package/src/runtime/effects_pty_tests.zig +1362 -0
  115. package/src/runtime/effects_tests.zig +14 -9
  116. package/src/runtime/effects_video_tests.zig +3609 -0
  117. package/src/runtime/flow.zig +25 -4
  118. package/src/runtime/gpu_surface_events.zig +473 -13
  119. package/src/runtime/media_surface.zig +116 -11
  120. package/src/runtime/media_surface_tests.zig +61 -0
  121. package/src/runtime/pty.zig +1252 -0
  122. package/src/runtime/pty_windows.zig +1780 -0
  123. package/src/runtime/root.zig +25 -0
  124. package/src/runtime/runtime_event_tests.zig +20 -1
  125. package/src/runtime/session_journal.zig +367 -61
  126. package/src/runtime/session_record.zig +16 -0
  127. package/src/runtime/session_replay.zig +395 -11
  128. package/src/runtime/session_tests.zig +109 -15
  129. package/src/runtime/terminal_session.zig +1569 -0
  130. package/src/runtime/terminal_session_tests.zig +450 -0
  131. package/src/runtime/terminal_vt_ghostty.zig +15 -0
  132. package/src/runtime/terminal_vt_stub.zig +13 -0
  133. package/src/runtime/tests.zig +6 -0
  134. package/src/runtime/ts_core_host.zig +980 -140
  135. package/src/runtime/ts_core_host_tests.zig +1059 -1
  136. package/src/runtime/ts_ui_app.zig +16 -5
  137. package/src/runtime/ui_app.zig +2333 -63
  138. package/src/runtime/ui_app_tests.zig +3171 -744
  139. package/src/runtime/ui_app_virtual_variable_tests.zig +4 -2
  140. package/src/runtime/ui_app_window_tests.zig +268 -0
  141. package/src/runtime/view.zig +190 -2
  142. package/src/runtime/view_widget_scroll.zig +218 -68
  143. package/src/runtime/view_widget_text.zig +11 -2
  144. package/src/runtime/view_widget_tree.zig +111 -3
  145. package/src/runtime/window_storage.zig +45 -2
  146. package/src/runtime/window_view_runtime.zig +34 -2
  147. package/src/runtime/window_views.zig +1 -0
  148. package/src/terminal_session_tests_root.zig +15 -0
  149. package/src/tooling/templates.zig +25 -7
@@ -1,43 +1,79 @@
1
1
  const std = @import("std");
2
+ const layout_fingerprint = @import("layout_fingerprint.zig");
2
3
 
3
4
  pub const default_dir = ".zig-cache/native-sdk-automation";
4
5
  pub const max_command_bytes: usize = 16 * 1024 + 64;
5
6
 
6
- /// CLI <-> app dropbox protocol version. Both binaries bake this
7
- /// constant at THEIR build time: the app stamps it into every snapshot
8
- /// header (`protocol=N`), the CLI refuses a snapshot whose version is not
9
- /// its own — so a stale `native` binary driving a freshly built app (or
10
- /// the reverse) fails loudly, naming both versions, instead of silently
11
- /// reading yesterday's state. Bump on ANY shape change a stale binary
12
- /// would misread: the dropbox directory name, the snapshot header/format,
13
- /// or the command vocabulary.
7
+ /// CLI <-> app dropbox protocol identity. Both binaries bake this
8
+ /// fingerprint at THEIR build time: the app stamps it into every
9
+ /// snapshot header (`protocol=0x...`), the CLI refuses a snapshot whose
10
+ /// fingerprint is not its own — so a stale `native` binary driving a
11
+ /// freshly built app (or the reverse) fails loudly, naming both
12
+ /// fingerprints, instead of silently reading yesterday's state.
14
13
  ///
15
- /// History: 1 = the first stamped version (post-rename dropbox
16
- /// `.zig-cache/native-sdk-automation`, publisher_pid liveness, stdout
17
- /// payloads). 2 = the gesture verbs (`widget-hold`,
18
- /// `widget-context-press`) and per-window snapshot view/widget scoping.
19
- /// 3 = the `profile on|off` verb and the snapshot's `frame_profile`
20
- /// per-stage timing line.
21
- /// 4 = the `provenance` verb (widget id or point -> authored markup) and
22
- /// its `provenance.txt` response artifact, the write-back read half.
23
- /// 5 = the `widget-context-menu` verb (invoke a declared context-menu
24
- /// item by target widget + item index, through the same
25
- /// `context_menu_action` dispatch a native selection takes) and the
26
- /// snapshot's per-widget `context_menu=[...]` item listing.
27
- /// 6 = the queued command dropbox: numbered `command-<n>.txt` entries
28
- /// (claimed exclusively by writers, consumed lowest-number-first by the
29
- /// app, DELETED as the consumption ack) replace the single-entry
14
+ /// This replaces the manually-bumped integer counter the handshake
15
+ /// carried through v8. No skew is ever migrated — both sides always
16
+ /// rebuild from one checkout — so an ORDERED version carried no
17
+ /// information ("same or different" is the entire question) while
18
+ /// costing two recurring failures: parallel branches contending for the
19
+ /// next integer, and forgettable bumps. The fingerprint is a comptime
20
+ /// Wyhash over a canonical description of the protocol surface this
21
+ /// file declares (see `layoutDescription`), so any change to that
22
+ /// surface moves the identity with no manual step.
23
+ ///
24
+ /// History of the retired integer counter, kept because the refusal
25
+ /// teachings it produced are still in the field: 1 = the first stamped
26
+ /// version (post-rename dropbox `.zig-cache/native-sdk-automation`,
27
+ /// publisher_pid liveness, stdout payloads). 2 = the gesture verbs
28
+ /// (`widget-hold`, `widget-context-press`) and per-window snapshot
29
+ /// view/widget scoping. 3 = the `profile on|off` verb and the
30
+ /// snapshot's `frame_profile` per-stage timing line. 4 = the
31
+ /// `provenance` verb (widget id or point -> authored markup) and its
32
+ /// `provenance.txt` response artifact, the write-back read half. 5 =
33
+ /// the `widget-context-menu` verb and the snapshot's per-widget
34
+ /// `context_menu=[...]` item listing. 6 = the queued command dropbox:
35
+ /// numbered `command-<n>.txt` entries replace the single-entry
30
36
  /// `command.txt` slot that rapid back-to-back writers could overwrite
31
- /// before the app drained it. A v5 CLI against a v6 app writes a
32
- /// `command.txt` the app never touches (and times out loudly on its own
33
- /// consumption wait); a v6 CLI against a v5 app queues files the app
34
- /// never touches (same loud timeout) — and both directions are refused
35
- /// up front by this handshake whenever a live snapshot exists.
36
- /// Snapshots without a `protocol=` field predate the handshake entirely.
37
- /// 7 = the `widget-pinch` verb (drive a trackpad pinch gesture as the
38
- /// real begin/change/end platform input events, journaled like every
39
- /// synthesized input).
40
- pub const version: u32 = 7;
37
+ /// before the app drained it (snapshots without a `protocol=` field
38
+ /// predate the handshake entirely). 7 = the `widget-pinch` verb. 8 =
39
+ /// context-menu action tokens as per-request generations, not widget
40
+ /// ids — a SEMANTIC break with identical bytes, exactly the shape
41
+ /// `semantic_epoch` now expresses.
42
+ pub const fingerprint: u64 = layout_fingerprint.hash(layoutDescription(semantic_epoch));
43
+
44
+ /// The escape hatch for protocol changes `layoutDescription` cannot
45
+ /// see. Bump this ONLY for: a same-bytes MEANING change (the
46
+ /// per-request context-menu action-token generations were exactly that
47
+ /// — identical layout, values a stale peer could never match), a
48
+ /// snapshot text-format change a stale binary would misread
49
+ /// (snapshot.zig hand-writes that layout), or a verb spelling change in
50
+ /// `Command.parse` (the wire strings live there, not in the `Action`
51
+ /// enum). Declared-shape changes — new verbs, renamed actions, budget
52
+ /// or naming changes — need NO action here: the fingerprint moves on
53
+ /// its own.
54
+ pub const semantic_epoch: u32 = 1;
55
+
56
+ /// The canonical description the protocol fingerprint hashes: the
57
+ /// command vocabulary (the `Action` enum, reflected — names and values,
58
+ /// so additions, removals, renames, and reorders all move the
59
+ /// identity), the `Command` shape, the dropbox directory and
60
+ /// queue-entry naming, and the size budgets. Deliberate constants cover
61
+ /// what reflection cannot see; anything else invisible to this string
62
+ /// is `semantic_epoch`'s job (see its doc).
63
+ fn layoutDescription(comptime epoch: u32) []const u8 {
64
+ comptime {
65
+ @setEvalBranchQuota(200_000);
66
+ return "native-sdk automation protocol layout\n" ++
67
+ std.fmt.comptimePrint("semantic_epoch={d}\n", .{epoch}) ++
68
+ "dropbox_dir=" ++ default_dir ++ "\n" ++
69
+ "queue_entry=" ++ queue_file_prefix ++ "<n>" ++ queue_file_suffix ++ "\n" ++
70
+ std.fmt.comptimePrint("max_command_bytes={d} max_queued_commands={d} max_screenshot_label_bytes={d}\n", .{
71
+ max_command_bytes, max_queued_commands, max_screenshot_label_bytes,
72
+ }) ++
73
+ "actions=" ++ layout_fingerprint.describe(Action) ++ "\n" ++
74
+ "command=" ++ layout_fingerprint.describe(Command) ++ "\n";
75
+ }
76
+ }
41
77
 
42
78
  /// How many commands may sit in the dropbox queue at once. Automation
43
79
  /// drivers are scripts, not firehoses: the app drains one command per
@@ -294,6 +330,19 @@ test "queue entry names round-trip and reject non-queue files" {
294
330
  try std.testing.expectEqual(@as(?u64, null), queueFileSequence("bridge-response.txt"));
295
331
  }
296
332
 
333
+ test "semantic epoch moves the protocol fingerprint" {
334
+ // Same layout, bumped epoch: the combined identity must move, so a
335
+ // meaning-only change still refuses stale peers loudly.
336
+ const bumped = layout_fingerprint.hash(comptime layoutDescription(semantic_epoch + 1));
337
+ try std.testing.expect(bumped != fingerprint);
338
+ }
339
+
340
+ test {
341
+ // The description builder's own suite (including the pinned proof
342
+ // that an added field moves a fingerprint with no manual step).
343
+ _ = layout_fingerprint;
344
+ }
345
+
297
346
  test "screenshot file names stay inside the automation directory" {
298
347
  var buffer: [128]u8 = undefined;
299
348
  try std.testing.expectEqualStrings("screenshot-inbox-canvas.png", try screenshotFileName("inbox-canvas", &buffer));
@@ -1,3 +1,4 @@
1
+ pub const layout_fingerprint = @import("layout_fingerprint.zig");
1
2
  pub const protocol = @import("protocol.zig");
2
3
  pub const snapshot = @import("snapshot.zig");
3
4
  pub const server = @import("server.zig");
@@ -448,7 +448,7 @@ test "server reports pending commands without consuming them" {
448
448
 
449
449
  // An empty dropbox is idle, and so is one holding only non-queue
450
450
  // files — response artifacts and, pointedly, a retired-v5 writer's
451
- // `command.txt` slot, which this protocol version must never consume
451
+ // `command.txt` slot, which this protocol must never consume
452
452
  // (acking it would tell that stale CLI its command dispatched).
453
453
  try std.testing.expect(!server.hasPendingCommand());
454
454
  try writePath(std.testing.io, server.path("command.txt", &path_buffer), "widget-click canvas 7\n");
@@ -73,11 +73,26 @@ pub const FrameProfile = struct {
73
73
  /// verb targeted.
74
74
  pub const DispatchError = struct {
75
75
  timestamp_ns: u64 = 0,
76
- event: []const u8 = "",
76
+ event_storage: [max_dispatch_error_event_bytes]u8 = undefined,
77
+ event_len: u8 = 0,
77
78
  error_name: []const u8 = "",
78
79
  detail_storage: [max_dispatch_error_detail_bytes]u8 = undefined,
79
80
  detail_len: u8 = 0,
80
81
 
82
+ /// The event name is INLINE storage like `detail`, never a borrowed
83
+ /// slice: records are copied by value into a ring that outlives any
84
+ /// caller's buffer, so a name passed from stack or reusable storage
85
+ /// must be owned at record time.
86
+ pub fn event(self: *const DispatchError) []const u8 {
87
+ return self.event_storage[0..self.event_len];
88
+ }
89
+
90
+ pub fn setEvent(self: *DispatchError, text: []const u8) void {
91
+ const len = @min(text.len, self.event_storage.len);
92
+ @memcpy(self.event_storage[0..len], text[0..len]);
93
+ self.event_len = @intCast(len);
94
+ }
95
+
81
96
  pub fn detail(self: *const DispatchError) []const u8 {
82
97
  return self.detail_storage[0..self.detail_len];
83
98
  }
@@ -89,6 +104,10 @@ pub const DispatchError = struct {
89
104
  }
90
105
  };
91
106
 
107
+ /// Event-name bytes kept per degraded dispatch error (a truncated copy,
108
+ /// owned by the record — the ring outlives every caller's buffer).
109
+ pub const max_dispatch_error_event_bytes: usize = 64;
110
+
92
111
  /// Detail context kept per degraded dispatch error (a truncated copy of
93
112
  /// the failing automation command's arguments).
94
113
  pub const max_dispatch_error_detail_bytes: usize = 48;
@@ -238,6 +257,29 @@ pub const Audio = struct {
238
257
  spectrum_bands: []const u8 = &.{},
239
258
  };
240
259
 
260
+ /// Live video playback state (the effects channel's single player), as
261
+ /// the runtime last mirrored it — the audio snapshot's twin. The
262
+ /// advancing `position_ms` and the `.loaded` dimensions are the
263
+ /// automation-visible evidence a video is actually decoding; `surface`
264
+ /// names the media-surface texture channel its frames feed. Like the
265
+ /// media-surface texture itself, this line prints in the FULL snapshot
266
+ /// only, never the a11y text session fingerprints hash — playback
267
+ /// transport is journaled effect truth, not tree state, so a replay
268
+ /// with no producer stays fingerprint-identical by construction.
269
+ pub const Video = struct {
270
+ key: u64 = 0,
271
+ surface: u64 = 0,
272
+ playing: bool = false,
273
+ buffering: bool = false,
274
+ looping: bool = false,
275
+ muted: bool = false,
276
+ source: []const u8 = "local",
277
+ position_ms: u64 = 0,
278
+ duration_ms: u64 = 0,
279
+ width: u64 = 0,
280
+ height: u64 = 0,
281
+ };
282
+
241
283
  pub const Input = struct {
242
284
  windows: []const Window,
243
285
  views: []const platform.ViewInfo = &.{},
@@ -263,6 +305,8 @@ pub const Input = struct {
263
305
  /// Live audio playback, when the app started any (null once stopped
264
306
  /// or failed — an idle player is honest, not zeroed-out noise).
265
307
  audio: ?Audio = null,
308
+ /// Live video playback, same contract as `audio`.
309
+ video: ?Video = null,
266
310
  /// The most recent degraded dispatch errors, oldest first (bounded
267
311
  /// ring; `diagnostics.dispatch_error_count` is the lifetime total).
268
312
  errors: []const DispatchError = &.{},
@@ -271,11 +315,11 @@ pub const Input = struct {
271
315
 
272
316
  pub fn writeText(input: Input, writer: anytype) !void {
273
317
  // `protocol=` is the CLI/app handshake: the publishing app
274
- // stamps ITS baked-in protocol version so a stale `native` binary
275
- // (or a stale app) is refused loudly instead of silently driving
276
- // yesterday's dropbox shape.
277
- try writer.print("ready=true protocol={d} frame={d} commands={d} runtime_uptime_ns={d} dispatch_errors={d} dropped_trace_records={d} publisher_pid={d} markup_watch={s}\n", .{
278
- protocol.version,
318
+ // stamps ITS baked-in protocol fingerprint so a stale `native`
319
+ // binary (or a stale app) is refused loudly instead of silently
320
+ // driving yesterday's dropbox shape.
321
+ try writer.print("ready=true protocol=0x{x:0>16} frame={d} commands={d} runtime_uptime_ns={d} dispatch_errors={d} dropped_trace_records={d} publisher_pid={d} markup_watch={s}\n", .{
322
+ protocol.fingerprint,
279
323
  input.diagnostics.frame_index,
280
324
  input.diagnostics.command_count,
281
325
  input.diagnostics.runtime_uptime_ns,
@@ -577,17 +621,32 @@ pub fn writeText(input: Input, writer: anytype) !void {
577
621
  }
578
622
  try writer.print("\n", .{});
579
623
  }
624
+ if (input.video) |video| {
625
+ try writer.print("video key={d} surface={d} state={s} source={s} position_ms={d} duration_ms={d} dimensions={d}x{d} loop={any} muted={any}\n", .{
626
+ video.key,
627
+ video.surface,
628
+ // The audio line's honest third state, verbatim.
629
+ if (video.buffering) "buffering" else if (video.playing) "playing" else "paused",
630
+ video.source,
631
+ video.position_ms,
632
+ video.duration_ms,
633
+ video.width,
634
+ video.height,
635
+ video.looping,
636
+ video.muted,
637
+ });
638
+ }
580
639
  for (input.errors) |dispatch_error| {
581
640
  if (dispatch_error.detail_len > 0) {
582
641
  try writer.print(" error event={s} name={s} detail=\"{s}\" timestamp_ns={d}\n", .{
583
- dispatch_error.event,
642
+ dispatch_error.event(),
584
643
  dispatch_error.error_name,
585
644
  dispatch_error.detail(),
586
645
  dispatch_error.timestamp_ns,
587
646
  });
588
647
  } else {
589
648
  try writer.print(" error event={s} name={s} timestamp_ns={d}\n", .{
590
- dispatch_error.event,
649
+ dispatch_error.event(),
591
650
  dispatch_error.error_name,
592
651
  dispatch_error.timestamp_ns,
593
652
  });
@@ -809,7 +868,7 @@ test "snapshot emits window and source" {
809
868
  try std.testing.expect(std.mem.indexOf(u8, writer.buffered(), "runtime_uptime_ns=42") != null);
810
869
  try std.testing.expect(std.mem.indexOf(u8, writer.buffered(), "publisher_pid=4242") != null);
811
870
  var protocol_field_buffer: [32]u8 = undefined;
812
- const protocol_field = try std.fmt.bufPrint(&protocol_field_buffer, "protocol={d} ", .{protocol.version});
871
+ const protocol_field = try std.fmt.bufPrint(&protocol_field_buffer, "protocol=0x{x:0>16} ", .{protocol.fingerprint});
813
872
  try std.testing.expect(std.mem.indexOf(u8, writer.buffered(), protocol_field) != null);
814
873
  try std.testing.expect(std.mem.indexOf(u8, writer.buffered(), "@w1") != null);
815
874
  try std.testing.expect(std.mem.indexOf(u8, writer.buffered(), "view @w1/main kind=webview") != null);
@@ -134,7 +134,7 @@ test "watcher requests frames while a command is pending" {
134
134
  // Idle queue: give the watcher a few polls; no frame requests. A
135
135
  // leftover non-queue file (a retired-v5 writer's `command.txt`)
136
136
  // stays invisible — the watcher must not wake the loop for traffic
137
- // this protocol version never consumes.
137
+ // this protocol never consumes.
138
138
  var path_buffer: [96]u8 = undefined;
139
139
  try cwd.writeFile(std.testing.io, .{
140
140
  .sub_path = try std.fmt.bufPrint(&path_buffer, "{s}/command.txt", .{directory}),
@@ -725,6 +725,11 @@ pub const MobileHostApp = struct {
725
725
  // below so the runtime's service table starts without audio.
726
726
  self.null_platform.audio_playback = false;
727
727
  self.null_platform.audio_streaming = false;
728
+ // Video is declined the same way: no mobile shim registers a
729
+ // decoder yet, and the null platform's fake player belongs to
730
+ // hermetic tests — a load that "succeeds" but never decodes
731
+ // would be a lie. Apps hear one honest failed event instead.
732
+ self.null_platform.video_playback = false;
728
733
  self.last_error = null;
729
734
  self.activation_count = 0;
730
735
  self.deactivation_count = 0;
@@ -178,6 +178,19 @@ pub fn UiAppHost(comptime AppDef: type) type {
178
178
  // its heap-owned registrations (registered canvas font
179
179
  // bytes) before the host storage goes.
180
180
  self.embedded.deinit();
181
+ // The embedded null platform lives inside `self`, so freeing
182
+ // `self` IS this path's platform destruction — and an
183
+ // abandoned channel wake call may still enter that platform
184
+ // at any later time (see
185
+ // `PlatformServices.note_channel_wake_abandoned_fn`; the
186
+ // null platform's own enqueue-only wake never triggers it,
187
+ // but a shim-registered service could). Consult the latch
188
+ // like every first-party destroy path: skip the free and
189
+ // leak the host storage, process-lived, with one loud line.
190
+ if (self.null_platform.channel_wake_abandoned.load(.seq_cst)) {
191
+ std.debug.print("mobile ui host teardown: an abandoned channel wake call may still enter the embedded platform; skipping the host free and leaking it, process-lived, so the stale call stays safe\n", .{});
192
+ return;
193
+ }
181
194
  std.heap.page_allocator.destroy(self);
182
195
  }
183
196