@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.
- package/build/app.zig +1178 -74
- package/build.zig +715 -17
- package/build.zig.zon +1 -0
- package/native-sdk.d.ts +10 -0
- package/package.json +12 -11
- package/packages/core/compile-surface/core.ts +435 -3
- package/packages/core/package-lock.json +11 -11
- package/packages/core/package.json +2 -2
- package/packages/core/scripts/compiler_typecheck.mjs +116 -15
- package/packages/core/scripts/gen_service_surface.mjs +268 -0
- package/packages/core/scripts/merge_static_archives.mjs +78 -0
- package/packages/core/scripts/npm_static_spike.mjs +64 -0
- package/packages/core/scripts/run_external_core_compiler.mjs +122 -6
- package/packages/core/scripts/run_external_service_compiler.mjs +280 -0
- package/packages/core/scripts/stage_external_core.mjs +9 -1
- package/packages/core/scripts/stage_external_services.mjs +172 -0
- package/packages/core/scripts/surface_manifest_diff.mjs +253 -0
- package/packages/core/scripts/vendor_service_packages.mjs +189 -0
- package/packages/core/sdk/core.d.ts +224 -0
- package/packages/core/sdk/core.ts +694 -22
- package/packages/core/sdk/events.d.ts +89 -0
- package/packages/core/sdk/events.ts +128 -0
- package/packages/core/src/checker.ts +936 -15
- package/packages/core/src/cli.ts +156 -3
- package/packages/core/src/contract.ts +28 -5
- package/packages/core/src/devhost.ts +1876 -16
- package/packages/core/src/devhost_journal.mjs +183 -0
- package/packages/core/src/devhost_resolver.mjs +17 -1
- package/packages/core/src/devhost_service_worker.mjs +90 -0
- package/packages/core/src/diagnostics.ts +179 -22
- package/packages/core/src/frontend.ts +210 -34
- package/packages/core/src/infer.ts +24 -0
- package/packages/core/src/modules.ts +129 -80
- package/packages/core/src/service_contract.ts +597 -0
- package/packages/core/src/sqlite_cli.ts +93 -0
- package/packages/core/src/sqlite_codegen.ts +806 -0
- package/packages/core/src/sqlite_runtime_policy.ts +364 -0
- package/packages/core/src/typed_ast.ts +36 -8
- package/skill-data/automation/SKILL.md +1 -1
- package/skill-data/core/references/project-anatomy.md +1 -1
- package/skill-data/native-ui/SKILL.md +58 -5
- package/skill-data/ts-core/SKILL.md +123 -41
- package/skill-data/ts-services/SKILL.md +126 -0
- package/skill-data/ts-services/references/service-surface.md +604 -0
- package/skill-data/zig/SKILL.md +1 -1
- package/skills/native-sdk/SKILL.md +1 -1
- package/src/app_runner/no_migrations.zig +3 -0
- package/src/app_runner/no_services.zig +20 -0
- package/src/app_runner/root.zig +133 -4
- package/src/app_runner/ts_core_main.zig +254 -8
- package/src/app_runner/ts_core_mobile.zig +241 -0
- package/src/automation/protocol.zig +5 -1
- package/src/automation/snapshot.zig +31 -11
- package/src/embed/app_exports.zig +12 -1
- package/src/embed/c_api.zig +48 -2
- package/src/embed/conversions.zig +4 -5
- package/src/embed/host.zig +109 -1
- package/src/embed/root.zig +8 -0
- package/src/embed/tests.zig +241 -0
- package/src/embed/types.zig +51 -0
- package/src/embed/ui_host.zig +185 -5
- package/src/platform/android/NativeSdkActivity.java +131 -0
- package/src/platform/android/android_host.c +182 -1
- package/src/platform/android/native_sdk_app.h +17 -0
- package/src/platform/ios/native_sdk_app.h +17 -0
- package/src/platform/ios/uikit_host.m +115 -0
- package/src/platform/linux/cef_host.cpp +8 -2
- package/src/platform/linux/gtk_host.c +289 -22
- package/src/platform/linux/gtk_host.h +5 -1
- package/src/platform/linux/root.zig +109 -22
- package/src/platform/macos/appkit_host.h +24 -7
- package/src/platform/macos/appkit_host.m +686 -64
- package/src/platform/macos/cef_host.mm +400 -66
- package/src/platform/macos/root.zig +304 -47
- package/src/platform/null_platform.zig +435 -48
- package/src/platform/null_platform_tests.zig +113 -0
- package/src/platform/root.zig +19 -0
- package/src/platform/types.zig +281 -28
- package/src/platform/windows/root.zig +207 -27
- package/src/platform/windows/webview2_host.cpp +334 -51
- package/src/primitives/app_manifest/comptime_scene.zig +2 -0
- package/src/primitives/app_manifest/root.zig +4 -0
- package/src/primitives/app_manifest/tests.zig +3 -0
- package/src/primitives/app_manifest/types.zig +32 -0
- package/src/primitives/app_manifest/validation.zig +19 -1
- package/src/root.zig +53 -0
- package/src/runtime/api.zig +19 -0
- package/src/runtime/automation_commands.zig +35 -2
- package/src/runtime/automation_snapshot.zig +32 -20
- package/src/runtime/bridge_permission_tests.zig +58 -3
- package/src/runtime/bridge_responses.zig +4 -2
- package/src/runtime/builtin_bridge.zig +11 -1
- package/src/runtime/canvas_frame.zig +18 -11
- package/src/runtime/canvas_frame_animation_tests.zig +4 -0
- package/src/runtime/clock.zig +13 -1
- package/src/runtime/core.zig +145 -7
- package/src/runtime/credentials_store.zig +115 -0
- package/src/runtime/effects.zig +3701 -231
- package/src/runtime/effects_credentials_tests.zig +332 -0
- package/src/runtime/effects_file_tests.zig +587 -0
- package/src/runtime/effects_host_tests.zig +208 -1
- package/src/runtime/effects_notification_tests.zig +11 -0
- package/src/runtime/effects_relational_tests.zig +314 -0
- package/src/runtime/effects_store_tests.zig +211 -0
- package/src/runtime/file_access.zig +400 -0
- package/src/runtime/file_effect_crash_helper.zig +28 -0
- package/src/runtime/file_effect_crash_tests.zig +37 -0
- package/src/runtime/flow.zig +35 -10
- package/src/runtime/gpu_surface_events.zig +6 -1
- package/src/runtime/native_command_event_tests.zig +86 -2
- package/src/runtime/persist_store.zig +666 -0
- package/src/runtime/pty.zig +5 -2
- package/src/runtime/record_store.zig +788 -0
- package/src/runtime/relational_store.zig +854 -0
- package/src/runtime/root.zig +54 -0
- package/src/runtime/runtime_event_tests.zig +70 -0
- package/src/runtime/service_host.zig +711 -0
- package/src/runtime/service_pool.zig +1314 -0
- package/src/runtime/session_blobs.zig +4 -1
- package/src/runtime/session_journal.zig +158 -5
- package/src/runtime/session_record.zig +215 -0
- package/src/runtime/session_replay.zig +206 -11
- package/src/runtime/session_tests.zig +81 -0
- package/src/runtime/shell_layout.zig +1 -0
- package/src/runtime/shell_layout_tests.zig +120 -0
- package/src/runtime/sqlite_engine.zig +474 -0
- package/src/runtime/state.zig +16 -0
- package/src/runtime/system_services.zig +170 -38
- package/src/runtime/tests.zig +4 -0
- package/src/runtime/ts_core_host.zig +1067 -95
- package/src/runtime/ts_core_host_tests.zig +325 -11
- package/src/runtime/ts_ui_app.zig +953 -2
- package/src/runtime/ui_app.zig +434 -96
- package/src/runtime/ui_app_tests.zig +287 -11
- package/src/runtime/ui_app_window_tests.zig +61 -7
- package/src/runtime/validation.zig +42 -0
- package/src/runtime/view.zig +9 -0
- package/src/runtime/window_storage.zig +1 -0
- package/src/runtime/window_view_runtime.zig +2 -3
- package/src/runtime/window_views.zig +19 -0
- package/src/tooling/android.zig +21 -16
- package/src/tooling/db.zig +160 -0
- package/src/tooling/ios.zig +7 -1
- package/src/tooling/manifest.zig +214 -2
- package/src/tooling/package.zig +116 -0
- package/src/tooling/raw_manifest.zig +30 -0
- package/src/tooling/root.zig +1 -0
- package/src/tooling/templates.zig +189 -4
- package/src/tooling/ts_core.zig +366 -17
- package/src/tooling/verbs.zig +7 -0
- package/third_party/sqlite/README.md +13 -0
- package/third_party/sqlite/sqlite3.c +269649 -0
- package/third_party/sqlite/sqlite3.h +14349 -0
- package/tools/corewire/core_abi.zig +14 -2
- package/tools/corewire/emit.zig +98 -29
- package/tools/corewire/emit_facade.zig +442 -27
- package/tools/corewire/emit_profile.zig +6 -2
- package/tools/corewire/emit_service.zig +924 -0
- package/tools/corewire/main.zig +122 -0
- package/tools/corewire/service_contract.zig +250 -0
- package/tools/corewire/sidecar.zig +26 -15
|
@@ -178,6 +178,13 @@ pub fn replaySession(
|
|
|
178
178
|
},
|
|
179
179
|
.effect => |effect_record| {
|
|
180
180
|
var effect = effect_record;
|
|
181
|
+
if (effect.kind == .file and fileRecordDamaged(effect)) {
|
|
182
|
+
std.debug.print(
|
|
183
|
+
"replay refused after event {d}: file record for key {d} has an invalid stream/stat payload shape\n",
|
|
184
|
+
.{ report.events_replayed, effect.key },
|
|
185
|
+
);
|
|
186
|
+
return error.ReplayDamagedRecord;
|
|
187
|
+
}
|
|
181
188
|
// A `.loaded` image record ALWAYS names source bytes:
|
|
182
189
|
// the recorder journals `.loaded` only after those
|
|
183
190
|
// exact bytes decoded and registered (a failed decode
|
|
@@ -318,6 +325,27 @@ pub fn replaySession(
|
|
|
318
325
|
);
|
|
319
326
|
return error.ReplayDamagedRecord;
|
|
320
327
|
}
|
|
328
|
+
if (effect.kind == .persist and persistRecordDamaged(effect)) {
|
|
329
|
+
std.debug.print(
|
|
330
|
+
"replay refused after event {d}: model-restore record claims .{s} with {d} inline bytes and a {d}-byte blob - only .ok may carry canonical snapshot bytes, always out of line and bounded at {d}; re-record the session\n",
|
|
331
|
+
.{ report.events_replayed, @tagName(effect.persist_outcome), effect.payload.len, effect.persist_blob_len, runtime_effects.max_effect_persist_snapshot_bytes },
|
|
332
|
+
);
|
|
333
|
+
return error.ReplayDamagedRecord;
|
|
334
|
+
}
|
|
335
|
+
if (effect.kind == .db and dbRecordDamaged(effect)) {
|
|
336
|
+
std.debug.print(
|
|
337
|
+
"replay refused after event {d}: relational record for key {d} has a kind, outcome, payload, blob, or provenance shape the recorder never writes - the journal is damaged or hand-edited; re-record the session\n",
|
|
338
|
+
.{ report.events_replayed, effect.key },
|
|
339
|
+
);
|
|
340
|
+
return error.ReplayDamagedRecord;
|
|
341
|
+
}
|
|
342
|
+
if (effect.kind == .credentials and credentialsRecordDamaged(effect)) {
|
|
343
|
+
std.debug.print(
|
|
344
|
+
"replay refused after event {d}: credential record for key {d} has a payload or redaction shape the recorder never writes - the journal is damaged or hand-edited; re-record the session\n",
|
|
345
|
+
.{ report.events_replayed, effect.key },
|
|
346
|
+
);
|
|
347
|
+
return error.ReplayDamagedRecord;
|
|
348
|
+
}
|
|
321
349
|
if (effectRegeneratesUnderReplay(effect)) {
|
|
322
350
|
report.effects_skipped += 1;
|
|
323
351
|
continue;
|
|
@@ -332,7 +360,7 @@ pub fn replaySession(
|
|
|
332
360
|
var blob_scratch: ?[]u8 = null;
|
|
333
361
|
defer if (blob_scratch) |scratch| std.heap.page_allocator.free(scratch);
|
|
334
362
|
if (effect.kind == .pty and effect.pty_blob_len > 0) {
|
|
335
|
-
const bytes = resolveBlob(effect.pty_blob_hash, effect.pty_blob_len, options.blobs, &blob_scratch) catch |err| {
|
|
363
|
+
const bytes = resolveBlob(effect.pty_blob_hash, effect.pty_blob_len, runtime_effects.max_effect_pty_chunk_bytes, options.blobs, &blob_scratch) catch |err| {
|
|
336
364
|
std.debug.print(
|
|
337
365
|
"replay refused after event {d}: pty record for key {d} references blob {s} ({d} bytes) that could not be resolved ({s}) - replay needs the journal's blobs/ directory beside it\n",
|
|
338
366
|
.{ report.events_replayed, effect.key, session_blobs.hexName(effect.pty_blob_hash), effect.pty_blob_len, @errorName(err) },
|
|
@@ -341,8 +369,18 @@ pub fn replaySession(
|
|
|
341
369
|
};
|
|
342
370
|
effect.payload = bytes;
|
|
343
371
|
}
|
|
372
|
+
if (effect.kind == .file and effect.file_blob_len > 0) {
|
|
373
|
+
const bytes = resolveBlob(effect.file_blob_hash, effect.file_blob_len, runtime_effects.effect_file_stream_chunk_bytes, options.blobs, &blob_scratch) catch |err| {
|
|
374
|
+
std.debug.print(
|
|
375
|
+
"replay refused after event {d}: file stream for key {d} references blob {s} ({d} bytes) that could not be resolved ({s})\n",
|
|
376
|
+
.{ report.events_replayed, effect.key, session_blobs.hexName(effect.file_blob_hash), effect.file_blob_len, @errorName(err) },
|
|
377
|
+
);
|
|
378
|
+
return error.ReplayMissingBlob;
|
|
379
|
+
};
|
|
380
|
+
effect.payload = bytes;
|
|
381
|
+
}
|
|
344
382
|
if (effect.kind == .image and effect.image_blob_len > 0) {
|
|
345
|
-
const bytes = resolveBlob(effect.image_blob_hash, effect.image_blob_len, options.blobs, &blob_scratch) catch |err| {
|
|
383
|
+
const bytes = resolveBlob(effect.image_blob_hash, effect.image_blob_len, runtime_effects.max_effect_image_bytes, options.blobs, &blob_scratch) catch |err| {
|
|
346
384
|
std.debug.print(
|
|
347
385
|
"replay refused after event {d}: image record for id {d} references blob {s} ({d} bytes) that could not be resolved ({s}) - replay needs the journal's blobs/ directory beside it\n",
|
|
348
386
|
.{ report.events_replayed, effect.key, session_blobs.hexName(effect.image_blob_hash), effect.image_blob_len, @errorName(err) },
|
|
@@ -351,6 +389,26 @@ pub fn replaySession(
|
|
|
351
389
|
};
|
|
352
390
|
effect.payload = bytes;
|
|
353
391
|
}
|
|
392
|
+
if (effect.kind == .persist and effect.persist_blob_len > 0) {
|
|
393
|
+
const bytes = resolveBlob(effect.persist_blob_hash, effect.persist_blob_len, runtime_effects.max_effect_persist_snapshot_bytes, options.blobs, &blob_scratch) catch |err| {
|
|
394
|
+
std.debug.print(
|
|
395
|
+
"replay refused after event {d}: model restore references blob {s} ({d} bytes) that could not be resolved ({s}) - replay needs the journal's blobs/ directory beside it\n",
|
|
396
|
+
.{ report.events_replayed, session_blobs.hexName(effect.persist_blob_hash), effect.persist_blob_len, @errorName(err) },
|
|
397
|
+
);
|
|
398
|
+
return error.ReplayMissingBlob;
|
|
399
|
+
};
|
|
400
|
+
effect.payload = bytes;
|
|
401
|
+
}
|
|
402
|
+
if (effect.kind == .db and effect.db_blob_len > 0) {
|
|
403
|
+
const bytes = resolveBlob(effect.db_blob_hash, effect.db_blob_len, runtime_effects.max_effect_db_page_bytes, options.blobs, &blob_scratch) catch |err| {
|
|
404
|
+
std.debug.print(
|
|
405
|
+
"replay refused after event {d}: relational page for key {d} references blob {s} ({d} bytes) that could not be resolved ({s}) - replay needs the journal's blobs/ directory beside it\n",
|
|
406
|
+
.{ report.events_replayed, effect.key, session_blobs.hexName(effect.db_blob_hash), effect.db_blob_len, @errorName(err) },
|
|
407
|
+
);
|
|
408
|
+
return error.ReplayMissingBlob;
|
|
409
|
+
};
|
|
410
|
+
effect.payload = bytes;
|
|
411
|
+
}
|
|
354
412
|
// Feed with back-pressure: results journal in delivery
|
|
355
413
|
// order, so one recorded drain pass can carry more
|
|
356
414
|
// results than the completion queue holds (a live
|
|
@@ -449,11 +507,12 @@ pub fn replaySession(
|
|
|
449
507
|
fn resolveBlob(
|
|
450
508
|
blob_hash: [runtime_effects.effect_image_blob_hash_len]u8,
|
|
451
509
|
blob_len_field: u64,
|
|
510
|
+
max_bytes: usize,
|
|
452
511
|
blobs: ?session_blobs.SessionBlobSource,
|
|
453
512
|
scratch_out: *?[]u8,
|
|
454
513
|
) anyerror![]const u8 {
|
|
455
514
|
const blob_source = blobs orelse return error.BlobMissing;
|
|
456
|
-
if (blob_len_field >
|
|
515
|
+
if (blob_len_field > max_bytes) return error.BlobOverBudget;
|
|
457
516
|
const blob_len: usize = @intCast(blob_len_field);
|
|
458
517
|
// One spare byte proves the stored blob is not LONGER than the
|
|
459
518
|
// record claims (the source reads at most the buffer).
|
|
@@ -525,6 +584,61 @@ fn ptyRecordDamaged(record: journal.EffectResultRecord) bool {
|
|
|
525
584
|
return false;
|
|
526
585
|
}
|
|
527
586
|
|
|
587
|
+
fn persistRecordDamaged(record: journal.EffectResultRecord) bool {
|
|
588
|
+
if (record.payload.len > 0) return true;
|
|
589
|
+
if (record.persist_blob_len > runtime_effects.max_effect_persist_snapshot_bytes) return true;
|
|
590
|
+
return record.persist_outcome != .ok and record.persist_blob_len > 0;
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
fn dbRecordDamaged(record: journal.EffectResultRecord) bool {
|
|
594
|
+
const kind = runtime_effects.dbKindFromJournalCode(record.code) orelse return true;
|
|
595
|
+
const outcome = runtime_effects.dbOutcomeFromJournalCode(record.code) orelse return true;
|
|
596
|
+
if (record.code != runtime_effects.dbJournalCode(kind, outcome)) return true;
|
|
597
|
+
// `.rejected` provenance identifies an admission refusal that replay
|
|
598
|
+
// regenerates. An executor may also return the closed `.rejected`
|
|
599
|
+
// outcome (for example when a result crosses its total bound); that
|
|
600
|
+
// terminal is external truth and correctly keeps `.exited` provenance.
|
|
601
|
+
if (record.exit_reason != .exited and record.exit_reason != .rejected) return true;
|
|
602
|
+
if (record.exit_reason == .rejected and outcome != .rejected) return true;
|
|
603
|
+
if (record.db_blob_len > runtime_effects.max_effect_db_page_bytes) return true;
|
|
604
|
+
return switch (kind) {
|
|
605
|
+
.page => outcome != .ok or
|
|
606
|
+
(record.payload.len == 0) == (record.db_blob_len == 0) or
|
|
607
|
+
record.payload.len > runtime_effects.max_effect_db_page_bytes,
|
|
608
|
+
.done, .exec => record.payload.len > 0 or record.db_blob_len > 0,
|
|
609
|
+
};
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
fn fileRecordDamaged(record: journal.EffectResultRecord) bool {
|
|
613
|
+
if (record.file_rejected_admission) switch (record.file_outcome) {
|
|
614
|
+
.rejected => {},
|
|
615
|
+
.sink_missing, .out_of_order => if (record.file_op != .write_stream_chunk and record.file_op != .write_stream_close) return true,
|
|
616
|
+
else => return true,
|
|
617
|
+
};
|
|
618
|
+
if (record.file_blob_len > runtime_effects.effect_file_stream_chunk_bytes) return true;
|
|
619
|
+
if (record.file_event == .chunk) {
|
|
620
|
+
return record.file_op != .read_stream or record.file_outcome != .ok or
|
|
621
|
+
record.payload.len != 0 or record.file_blob_len == 0;
|
|
622
|
+
}
|
|
623
|
+
if (record.file_blob_len != 0) return true;
|
|
624
|
+
if (record.file_event == .done) {
|
|
625
|
+
return record.file_op != .read_stream or record.file_outcome != .ok or record.payload.len != 0;
|
|
626
|
+
}
|
|
627
|
+
if (record.file_op == .stat and record.file_outcome == .ok) return record.payload.len != 0;
|
|
628
|
+
return record.file_total != 0 or record.file_mtime_ms != 0 or record.file_exists;
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
fn credentialsRecordDamaged(record: journal.EffectResultRecord) bool {
|
|
632
|
+
if (record.payload.len != 0 or record.exit_reason != .exited) return true;
|
|
633
|
+
const redacted_get = record.credentials_operation == .get and record.credentials_outcome == .ok;
|
|
634
|
+
if (redacted_get) return record.credentials_secret_len > runtime_effects.max_effect_credentials_secret_bytes or
|
|
635
|
+
std.mem.allEqual(u8, &record.credentials_salt, 0) or
|
|
636
|
+
std.mem.allEqual(u8, &record.credentials_digest, 0);
|
|
637
|
+
if (record.credentials_secret_len != 0) return true;
|
|
638
|
+
return !std.mem.allEqual(u8, &record.credentials_salt, 0) or
|
|
639
|
+
!std.mem.allEqual(u8, &record.credentials_digest, 0);
|
|
640
|
+
}
|
|
641
|
+
|
|
528
642
|
/// Recorder truth for pty provenance: output records always carry
|
|
529
643
|
/// `.exited` (the live drain never touches the exit reason on an
|
|
530
644
|
/// output); every reason is legal on an `.exit` record (`.rejected` =
|
|
@@ -653,15 +767,13 @@ fn effectRegeneratesUnderReplay(record: journal.EffectResultRecord) bool {
|
|
|
653
767
|
return switch (record.kind) {
|
|
654
768
|
.timer => true,
|
|
655
769
|
.exit => record.exit_reason == .rejected,
|
|
656
|
-
// Only DETERMINISTIC admission
|
|
657
|
-
//
|
|
658
|
-
//
|
|
659
|
-
//
|
|
660
|
-
// are external inputs and must be fed, even when their reason
|
|
661
|
-
// is `.rejected`.
|
|
770
|
+
// Only DETERMINISTIC admission/protocol results regenerate — marked
|
|
771
|
+
// by each effect family's provenance bit. Executor-truth terminals —
|
|
772
|
+
// start failures, platform refusals, output, and real exits — are
|
|
773
|
+
// external inputs and must be fed, even when their reason is rejected.
|
|
662
774
|
.pty => record.pty_kind == .exit and record.truncated,
|
|
663
775
|
.response => record.fetch_outcome == .rejected,
|
|
664
|
-
.file => record.
|
|
776
|
+
.file => record.file_rejected_admission,
|
|
665
777
|
.clipboard => record.clipboard_outcome == .rejected,
|
|
666
778
|
// Audio rejections are loop-side validation (path bounds) that
|
|
667
779
|
// refuses again; everything else — loaded acknowledgments,
|
|
@@ -681,6 +793,8 @@ fn effectRegeneratesUnderReplay(record: journal.EffectResultRecord) bool {
|
|
|
681
793
|
// Host-request rejections mark themselves with the exit reason
|
|
682
794
|
// (the `.host` record encoding); host answers must be fed.
|
|
683
795
|
.host => record.exit_reason == .rejected,
|
|
796
|
+
.db => record.exit_reason == .rejected,
|
|
797
|
+
.credentials => false,
|
|
684
798
|
// Image `.rejected` terminals journal from BOTH sides of the
|
|
685
799
|
// executor seam, so the outcome alone is not provenance: only
|
|
686
800
|
// loop-side validation refusals — which the replayed
|
|
@@ -707,10 +821,66 @@ fn effectRegeneratesUnderReplay(record: journal.EffectResultRecord) bool {
|
|
|
707
821
|
// Launch-env deliveries are exactly what must NOT regenerate:
|
|
708
822
|
// the recorded values feed the replayed envMsgs dispatch so the
|
|
709
823
|
// replay launch's environment is never consulted.
|
|
710
|
-
.line, .clock, .env => false,
|
|
824
|
+
.line, .clock, .env, .persist => false,
|
|
711
825
|
};
|
|
712
826
|
}
|
|
713
827
|
|
|
828
|
+
test "only admission-tagged file results regenerate" {
|
|
829
|
+
try std.testing.expect(effectRegeneratesUnderReplay(.{
|
|
830
|
+
.kind = .file,
|
|
831
|
+
.key = 1,
|
|
832
|
+
.file_outcome = .rejected,
|
|
833
|
+
.file_rejected_admission = true,
|
|
834
|
+
}));
|
|
835
|
+
try std.testing.expect(!fileRecordDamaged(.{
|
|
836
|
+
.kind = .file,
|
|
837
|
+
.key = 2,
|
|
838
|
+
.file_op = .write_stream_chunk,
|
|
839
|
+
.file_outcome = .sink_missing,
|
|
840
|
+
.file_rejected_admission = true,
|
|
841
|
+
}));
|
|
842
|
+
try std.testing.expect(fileRecordDamaged(.{
|
|
843
|
+
.kind = .file,
|
|
844
|
+
.key = 2,
|
|
845
|
+
.file_op = .write_stream_chunk,
|
|
846
|
+
.file_outcome = .ok,
|
|
847
|
+
.file_rejected_admission = true,
|
|
848
|
+
}));
|
|
849
|
+
try std.testing.expect(!effectRegeneratesUnderReplay(.{
|
|
850
|
+
.kind = .file,
|
|
851
|
+
.key = 1,
|
|
852
|
+
.file_op = .read_stream,
|
|
853
|
+
.file_outcome = .rejected,
|
|
854
|
+
}));
|
|
855
|
+
try std.testing.expect(effectRegeneratesUnderReplay(.{
|
|
856
|
+
.kind = .file,
|
|
857
|
+
.key = 2,
|
|
858
|
+
.file_op = .write_stream_chunk,
|
|
859
|
+
.file_outcome = .sink_missing,
|
|
860
|
+
.file_rejected_admission = true,
|
|
861
|
+
}));
|
|
862
|
+
try std.testing.expect(effectRegeneratesUnderReplay(.{
|
|
863
|
+
.kind = .file,
|
|
864
|
+
.key = 3,
|
|
865
|
+
.file_op = .write_stream_close,
|
|
866
|
+
.file_outcome = .out_of_order,
|
|
867
|
+
.file_rejected_admission = true,
|
|
868
|
+
}));
|
|
869
|
+
try std.testing.expect(!fileRecordDamaged(.{
|
|
870
|
+
.kind = .file,
|
|
871
|
+
.key = 4,
|
|
872
|
+
.file_op = .write_stream_chunk,
|
|
873
|
+
.file_outcome = .ok,
|
|
874
|
+
}));
|
|
875
|
+
try std.testing.expect(fileRecordDamaged(.{
|
|
876
|
+
.kind = .file,
|
|
877
|
+
.key = 4,
|
|
878
|
+
.file_op = .write_stream_chunk,
|
|
879
|
+
.file_outcome = .ok,
|
|
880
|
+
.file_total = 1,
|
|
881
|
+
}));
|
|
882
|
+
}
|
|
883
|
+
|
|
714
884
|
/// Re-render a journaled screenshot mark through the same deterministic
|
|
715
885
|
/// reference renderer the automation `screenshot` verb used at record
|
|
716
886
|
/// time, and hash the PNG.
|
|
@@ -801,6 +971,31 @@ test "audio records outside the exact-integer scalar window are damaged" {
|
|
|
801
971
|
try std.testing.expect(audioScalarsDamaged(record));
|
|
802
972
|
}
|
|
803
973
|
|
|
974
|
+
test "relational rejection provenance distinguishes admission from executor truth" {
|
|
975
|
+
var record: journal.EffectResultRecord = .{
|
|
976
|
+
.kind = .db,
|
|
977
|
+
.key = 1,
|
|
978
|
+
.code = runtime_effects.dbJournalCode(.done, .rejected),
|
|
979
|
+
.exit_reason = .exited,
|
|
980
|
+
};
|
|
981
|
+
|
|
982
|
+
// A bounded executor result is a real terminal which replay must feed.
|
|
983
|
+
try std.testing.expect(!dbRecordDamaged(record));
|
|
984
|
+
|
|
985
|
+
// A deterministic admission refusal regenerates instead and uses the
|
|
986
|
+
// same outcome with explicit rejected provenance.
|
|
987
|
+
record.exit_reason = .rejected;
|
|
988
|
+
try std.testing.expect(!dbRecordDamaged(record));
|
|
989
|
+
|
|
990
|
+
// Rejected provenance cannot decorate a successful result, and DB
|
|
991
|
+
// records never carry process-only exit reasons.
|
|
992
|
+
record.code = runtime_effects.dbJournalCode(.done, .ok);
|
|
993
|
+
try std.testing.expect(dbRecordDamaged(record));
|
|
994
|
+
record.code = runtime_effects.dbJournalCode(.done, .rejected);
|
|
995
|
+
record.exit_reason = .cancelled;
|
|
996
|
+
try std.testing.expect(dbRecordDamaged(record));
|
|
997
|
+
}
|
|
998
|
+
|
|
804
999
|
/// Debug aid: `NATIVE_SDK_SESSION_REPLAY_DUMP=<dir>` writes each
|
|
805
1000
|
/// replay-rendered screenshot PNG so a mismatching pixel mark can be
|
|
806
1001
|
/// diffed against the recording's artifact.
|
|
@@ -1448,6 +1448,8 @@ const ImageSessionModel = struct {
|
|
|
1448
1448
|
exits: u32 = 0,
|
|
1449
1449
|
exits_rejected: u32 = 0,
|
|
1450
1450
|
files: u32 = 0,
|
|
1451
|
+
stream_bytes: u64 = 0,
|
|
1452
|
+
stream_done: bool = false,
|
|
1451
1453
|
/// Armed by `.arm_fetch_chain` / `.arm_file_chain`: the NEXT
|
|
1452
1454
|
/// terminal of that family answers by reissuing the SAME key from
|
|
1453
1455
|
/// inside its own update (one-shot) — the poll/reload idiom whose
|
|
@@ -1475,6 +1477,7 @@ const ImageSessionMsg = union(enum) {
|
|
|
1475
1477
|
fetch_cover,
|
|
1476
1478
|
spawn_cover,
|
|
1477
1479
|
read_note,
|
|
1480
|
+
stream_note,
|
|
1478
1481
|
line: effects_mod.EffectLine,
|
|
1479
1482
|
image: effects_mod.EffectImageResult,
|
|
1480
1483
|
response: effects_mod.EffectResponse,
|
|
@@ -1519,6 +1522,7 @@ fn imageSessionUpdate(model: *ImageSessionModel, msg: ImageSessionMsg, fx: *Imag
|
|
|
1519
1522
|
// A file read on its own key (26 — never colliding with the
|
|
1520
1523
|
// image/fetch/spawn probes above).
|
|
1521
1524
|
.read_note => fx.readFile(.{ .key = 26, .path = "notes/session.txt", .on_result = ImageSessionApp.Effects.fileMsg(.file) }),
|
|
1525
|
+
.stream_note => fx.readFileStream(.{ .key = 27, .path = "notes/large.bin", .on_result = ImageSessionApp.Effects.fileMsg(.file) }),
|
|
1522
1526
|
// Aimed at the cover's id: against a running load this marks
|
|
1523
1527
|
// it cancelled; against a staged start-failure rejection (no
|
|
1524
1528
|
// slot exists) it is a no-op and the rejection stands.
|
|
@@ -1547,6 +1551,10 @@ fn imageSessionUpdate(model: *ImageSessionModel, msg: ImageSessionMsg, fx: *Imag
|
|
|
1547
1551
|
},
|
|
1548
1552
|
.file => |result| {
|
|
1549
1553
|
model.files += 1;
|
|
1554
|
+
if (result.op == .read_stream) {
|
|
1555
|
+
if (result.event == .chunk) model.stream_bytes += result.bytes.len;
|
|
1556
|
+
if (result.event == .done) model.stream_done = true;
|
|
1557
|
+
}
|
|
1550
1558
|
// The armed reload idiom, the fetch chain's file twin.
|
|
1551
1559
|
if (model.chain_next_file and result.key == 26) {
|
|
1552
1560
|
model.chain_next_file = false;
|
|
@@ -1590,6 +1598,7 @@ fn imageSessionView(ui: *ImageSessionApp.Ui, model: *const ImageSessionModel) Im
|
|
|
1590
1598
|
ui.text(.{}, ui.fmt("{d} lines, {d} before image", .{ model.lines_seen, model.lines_before_image })),
|
|
1591
1599
|
ui.text(.{}, ui.fmt("{d}/{d} responses, {d}/{d} exits rejected", .{ model.responses_rejected, model.responses, model.exits_rejected, model.exits })),
|
|
1592
1600
|
ui.text(.{}, ui.fmt("{d} files", .{model.files})),
|
|
1601
|
+
ui.text(.{}, ui.fmt("stream {d} done {}", .{ model.stream_bytes, model.stream_done })),
|
|
1593
1602
|
});
|
|
1594
1603
|
}
|
|
1595
1604
|
|
|
@@ -1604,6 +1613,7 @@ fn imageSessionCommand(name: []const u8) ?ImageSessionMsg {
|
|
|
1604
1613
|
if (std.mem.eql(u8, name, "image.fetch-chain")) return .arm_fetch_chain;
|
|
1605
1614
|
if (std.mem.eql(u8, name, "image.file-chain")) return .arm_file_chain;
|
|
1606
1615
|
if (std.mem.eql(u8, name, "image.read-note")) return .read_note;
|
|
1616
|
+
if (std.mem.eql(u8, name, "image.stream-note")) return .stream_note;
|
|
1607
1617
|
if (std.mem.eql(u8, name, "image.cancel")) return .cancel_cover;
|
|
1608
1618
|
if (std.mem.eql(u8, name, "image.chatty")) return .start_chatty;
|
|
1609
1619
|
if (std.mem.eql(u8, name, "image.fetch-cover")) return .fetch_cover;
|
|
@@ -2522,6 +2532,77 @@ test "a same-key retry from a fetch or file terminal handler is accepted live an
|
|
|
2522
2532
|
try std.testing.expectEqual(recorded.fingerprint, harness.runtime.sessionStateFingerprint());
|
|
2523
2533
|
}
|
|
2524
2534
|
|
|
2535
|
+
test "a multi-megabyte file stream records through blobs and replays byte-identically" {
|
|
2536
|
+
const gpa = std.testing.allocator;
|
|
2537
|
+
const buffer = try std.heap.page_allocator.create(JournalBuffer);
|
|
2538
|
+
defer std.heap.page_allocator.destroy(buffer);
|
|
2539
|
+
buffer.len = 0;
|
|
2540
|
+
var store = session_blobs.MemoryBlobStore.init(gpa);
|
|
2541
|
+
defer store.deinit();
|
|
2542
|
+
|
|
2543
|
+
const recorder = try std.heap.page_allocator.create(session_record.SessionRecorder);
|
|
2544
|
+
defer std.heap.page_allocator.destroy(recorder);
|
|
2545
|
+
recorder.* = session_record.SessionRecorder.init(buffer.sink());
|
|
2546
|
+
recorder.blob_sink = store.sink();
|
|
2547
|
+
recorder.begin(.{ .platform_name = "test", .app_name = "file-stream-session", .window_width = 400, .window_height = 300 });
|
|
2548
|
+
|
|
2549
|
+
const harness = try core.TestHarness().create(gpa, .{ .size = geometry.SizeF.init(400, 300) });
|
|
2550
|
+
defer harness.destroy(gpa);
|
|
2551
|
+
harness.null_platform.gpu_surfaces = true;
|
|
2552
|
+
harness.runtime.options.session_recorder = recorder;
|
|
2553
|
+
const app_state = try gpa.create(ImageSessionApp);
|
|
2554
|
+
defer gpa.destroy(app_state);
|
|
2555
|
+
app_state.* = ImageSessionApp.init(std.heap.page_allocator, .{}, imageSessionOptions());
|
|
2556
|
+
defer app_state.deinit();
|
|
2557
|
+
app_state.effects.executor = .fake;
|
|
2558
|
+
const app = app_state.app();
|
|
2559
|
+
try harness.start(app);
|
|
2560
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_frame = .{
|
|
2561
|
+
.label = image_canvas_label,
|
|
2562
|
+
.size = geometry.SizeF.init(400, 300),
|
|
2563
|
+
.scale_factor = 1,
|
|
2564
|
+
.frame_index = 1,
|
|
2565
|
+
.timestamp_ns = 1_000_000,
|
|
2566
|
+
} });
|
|
2567
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .menu_command = .{ .name = "image.stream-note", .window_id = 1 } });
|
|
2568
|
+
const stream_key: u64 = 27;
|
|
2569
|
+
const chunk = try gpa.alloc(u8, effects_mod.effect_file_stream_chunk_bytes);
|
|
2570
|
+
defer gpa.free(chunk);
|
|
2571
|
+
var total: u64 = 0;
|
|
2572
|
+
for (0..5) |chunk_index| {
|
|
2573
|
+
for (chunk, 0..) |*byte, index| byte.* = @truncate(index + chunk_index * 17);
|
|
2574
|
+
total += chunk.len;
|
|
2575
|
+
try app_state.effects.feedFileResultDetailed(.{ .key = stream_key, .op = .read_stream, .event = .chunk, .outcome = .ok, .bytes = chunk, .total = total });
|
|
2576
|
+
try harness.runtime.dispatchPlatformEvent(app, .wake);
|
|
2577
|
+
}
|
|
2578
|
+
try std.testing.expect(total > effects_mod.max_effect_file_bytes);
|
|
2579
|
+
try app_state.effects.feedFileResultDetailed(.{ .key = stream_key, .op = .read_stream, .event = .done, .outcome = .ok, .total = total });
|
|
2580
|
+
try harness.runtime.dispatchPlatformEvent(app, .wake);
|
|
2581
|
+
try harness.runtime.dispatchPlatformEvent(app, .frame_requested);
|
|
2582
|
+
recorder.finish();
|
|
2583
|
+
try std.testing.expect(!recorder.failed);
|
|
2584
|
+
try std.testing.expectEqual(@as(usize, 5), store.count);
|
|
2585
|
+
const recorded_model = app_state.model;
|
|
2586
|
+
const recorded_fingerprint = harness.runtime.sessionStateFingerprint();
|
|
2587
|
+
|
|
2588
|
+
const replay_harness = try core.TestHarness().create(gpa, .{ .size = geometry.SizeF.init(400, 300) });
|
|
2589
|
+
defer replay_harness.destroy(gpa);
|
|
2590
|
+
replay_harness.null_platform.gpu_surfaces = true;
|
|
2591
|
+
const replay_app = try gpa.create(ImageSessionApp);
|
|
2592
|
+
defer gpa.destroy(replay_app);
|
|
2593
|
+
replay_app.* = ImageSessionApp.init(std.heap.page_allocator, .{}, imageSessionOptions());
|
|
2594
|
+
defer replay_app.deinit();
|
|
2595
|
+
const report = try session_replay.replaySession(&replay_harness.runtime, replay_app.app(), buffer.journalBytes(), .{
|
|
2596
|
+
.verify = true,
|
|
2597
|
+
.require_same_platform = false,
|
|
2598
|
+
.blobs = store.source(),
|
|
2599
|
+
});
|
|
2600
|
+
try std.testing.expect(report.ok());
|
|
2601
|
+
try std.testing.expectEqual(@as(u64, 6), report.effects_fed);
|
|
2602
|
+
try std.testing.expectEqualDeep(recorded_model, replay_app.model);
|
|
2603
|
+
try std.testing.expectEqual(recorded_fingerprint, replay_harness.runtime.sessionStateFingerprint());
|
|
2604
|
+
}
|
|
2605
|
+
|
|
2525
2606
|
/// Record the queue-saturation reference session: a chatty spawn and
|
|
2526
2607
|
/// an image load whose results journal as ONE unbroken run — 64 line
|
|
2527
2608
|
/// records (the completion queue's whole capacity) followed by the
|
|
@@ -233,6 +233,7 @@ pub fn shellClosePolicy(policy: app_manifest.WindowClosePolicy) platform.WindowC
|
|
|
233
233
|
/// user never sees a blank window while the first frame renders. Webview
|
|
234
234
|
/// windows keep immediate visibility — their engine owns first paint.
|
|
235
235
|
pub fn shellWindowShowMode(shell_window: app_manifest.ShellWindow) platform.WindowShowMode {
|
|
236
|
+
if (shell_window.initially_hidden) return .hidden;
|
|
236
237
|
for (shell_window.views) |view| {
|
|
237
238
|
if (view.kind == .gpu_surface) return .on_first_present;
|
|
238
239
|
}
|
|
@@ -660,6 +660,63 @@ test "canvas shell windows present before they become visible" {
|
|
|
660
660
|
try std.testing.expect(harness.null_platform.window_visible[i]);
|
|
661
661
|
}
|
|
662
662
|
}
|
|
663
|
+
|
|
664
|
+
// An explicitly hidden startup/menu-bar surface is stronger than
|
|
665
|
+
// present-before-show: even a completed first canvas frame does not
|
|
666
|
+
// reveal it. Only the app's show/focus verb does.
|
|
667
|
+
const hidden_views = [_]app_manifest.ShellView{
|
|
668
|
+
.{ .label = "agent-canvas", .kind = .gpu_surface, .fill = true },
|
|
669
|
+
};
|
|
670
|
+
const hidden = try harness.runtime.createShellWindow(.{
|
|
671
|
+
.label = "agent-host",
|
|
672
|
+
.title = "Agent Host",
|
|
673
|
+
.initially_hidden = true,
|
|
674
|
+
.views = &hidden_views,
|
|
675
|
+
}, null);
|
|
676
|
+
const hidden_index = for (harness.null_platform.windows[0..harness.null_platform.window_count], 0..) |info, i| {
|
|
677
|
+
if (info.id == hidden.id) break i;
|
|
678
|
+
} else return error.WindowNotFound;
|
|
679
|
+
try std.testing.expectEqual(platform.WindowShowMode.hidden, harness.null_platform.window_show[hidden_index]);
|
|
680
|
+
const hidden_runtime_index = for (harness.runtime.windows[0..harness.runtime.window_count], 0..) |entry, i| {
|
|
681
|
+
if (entry.info.id == hidden.id) break i;
|
|
682
|
+
} else return error.WindowNotFound;
|
|
683
|
+
try std.testing.expect(harness.runtime.windows[hidden_runtime_index].info.hidden);
|
|
684
|
+
try harness.runtime.options.platform.services.presentGpuSurfacePacket(.{
|
|
685
|
+
.window_id = hidden.id,
|
|
686
|
+
.label = "agent-canvas",
|
|
687
|
+
.surface_size = geometry.SizeF.init(720, 480),
|
|
688
|
+
.json = "{\"v\":1}",
|
|
689
|
+
});
|
|
690
|
+
try std.testing.expect(!harness.null_platform.window_visible[hidden_index]);
|
|
691
|
+
try harness.runtime.showWindow(hidden.id);
|
|
692
|
+
try std.testing.expect(harness.null_platform.window_visible[hidden_index]);
|
|
693
|
+
|
|
694
|
+
// An app-driven hide has the same strength even when it lands while
|
|
695
|
+
// an ordinary canvas window is still waiting for its first present.
|
|
696
|
+
// Neither that present nor the native fallback may undo the hide.
|
|
697
|
+
const deferred_hidden_views = [_]app_manifest.ShellView{
|
|
698
|
+
.{ .label = "deferred-canvas", .kind = .gpu_surface, .fill = true },
|
|
699
|
+
};
|
|
700
|
+
const deferred_hidden = try harness.runtime.createShellWindow(.{
|
|
701
|
+
.label = "deferred-hidden",
|
|
702
|
+
.title = "Deferred Hidden",
|
|
703
|
+
.views = &deferred_hidden_views,
|
|
704
|
+
}, null);
|
|
705
|
+
const deferred_hidden_index = for (harness.null_platform.windows[0..harness.null_platform.window_count], 0..) |info, i| {
|
|
706
|
+
if (info.id == deferred_hidden.id) break i;
|
|
707
|
+
} else return error.WindowNotFound;
|
|
708
|
+
try std.testing.expectEqual(platform.WindowShowMode.on_first_present, harness.null_platform.window_show[deferred_hidden_index]);
|
|
709
|
+
try harness.runtime.hideWindow(deferred_hidden.id);
|
|
710
|
+
try harness.runtime.options.platform.services.presentGpuSurfacePacket(.{
|
|
711
|
+
.window_id = deferred_hidden.id,
|
|
712
|
+
.label = "deferred-canvas",
|
|
713
|
+
.surface_size = geometry.SizeF.init(720, 480),
|
|
714
|
+
.json = "{\"v\":1}",
|
|
715
|
+
});
|
|
716
|
+
try std.testing.expect(!harness.null_platform.window_visible[deferred_hidden_index]);
|
|
717
|
+
try std.testing.expect(harness.null_platform.windows[deferred_hidden_index].hidden);
|
|
718
|
+
try harness.runtime.showWindow(deferred_hidden.id);
|
|
719
|
+
try std.testing.expect(harness.null_platform.window_visible[deferred_hidden_index]);
|
|
663
720
|
}
|
|
664
721
|
|
|
665
722
|
test "overlay window presentation reaches create and passive show preserves focus" {
|
|
@@ -685,6 +742,7 @@ test "overlay window presentation reaches create and passive show preserves focu
|
|
|
685
742
|
.always_on_top = true,
|
|
686
743
|
.click_through = true,
|
|
687
744
|
.activate_on_show = false,
|
|
745
|
+
.allows_fullscreen = false,
|
|
688
746
|
.views = &views,
|
|
689
747
|
}, platform.WebViewSource.html("<h1>Overlay</h1>"));
|
|
690
748
|
const index = for (harness.null_platform.windows[0..harness.null_platform.window_count], 0..) |window, i| {
|
|
@@ -695,6 +753,7 @@ test "overlay window presentation reaches create and passive show preserves focu
|
|
|
695
753
|
try std.testing.expect(harness.null_platform.window_always_on_top[index]);
|
|
696
754
|
try std.testing.expect(harness.null_platform.window_click_through[index]);
|
|
697
755
|
try std.testing.expect(!harness.null_platform.window_activate_on_show[index]);
|
|
756
|
+
try std.testing.expect(!harness.null_platform.window_allows_fullscreen[index]);
|
|
698
757
|
|
|
699
758
|
const runtime_index = for (harness.runtime.windows[0..harness.runtime.window_count], 0..) |window, i| {
|
|
700
759
|
if (window.info.id == info.id) break i;
|
|
@@ -709,6 +768,18 @@ test "overlay window presentation reaches create and passive show preserves focu
|
|
|
709
768
|
// whose implicit creation/show policy is passive.
|
|
710
769
|
try harness.runtime.focusWindow(info.id);
|
|
711
770
|
try std.testing.expect(harness.runtime.windows[runtime_index].info.focused);
|
|
771
|
+
|
|
772
|
+
// App-driven hide retains the window and its views; show is the
|
|
773
|
+
// inverse, and a refused hide rolls the optimistic state back.
|
|
774
|
+
try harness.runtime.hideWindow(info.id);
|
|
775
|
+
try std.testing.expect(harness.runtime.windows[runtime_index].info.hidden);
|
|
776
|
+
try std.testing.expect(!harness.runtime.windows[runtime_index].info.focused);
|
|
777
|
+
try std.testing.expectEqual(@as(u32, 1), harness.null_platform.hideCountForWindow(info.id));
|
|
778
|
+
try harness.runtime.showWindow(info.id);
|
|
779
|
+
try std.testing.expect(!harness.runtime.windows[runtime_index].info.hidden);
|
|
780
|
+
harness.null_platform.fail_next_hide_window = true;
|
|
781
|
+
try std.testing.expectError(error.HideFailed, harness.runtime.hideWindow(info.id));
|
|
782
|
+
try std.testing.expect(!harness.runtime.windows[runtime_index].info.hidden);
|
|
712
783
|
}
|
|
713
784
|
|
|
714
785
|
test "runtime lays out created shell windows with native returned bounds" {
|
|
@@ -945,6 +1016,55 @@ test "startup scene adoption preserves manifest passive show policy" {
|
|
|
945
1016
|
try std.testing.expect(!runtime.windows[0].info.focused);
|
|
946
1017
|
}
|
|
947
1018
|
|
|
1019
|
+
test "startup hidden policy is visible to the start hook" {
|
|
1020
|
+
const TestApp = struct {
|
|
1021
|
+
saw_startup_window: bool = false,
|
|
1022
|
+
saw_hidden: bool = false,
|
|
1023
|
+
|
|
1024
|
+
fn start(context: *anyopaque, runtime: *Runtime) anyerror!void {
|
|
1025
|
+
const self: *@This() = @ptrCast(@alignCast(context));
|
|
1026
|
+
var windows_buffer: [1]platform.WindowInfo = undefined;
|
|
1027
|
+
const windows = runtime.listWindows(&windows_buffer);
|
|
1028
|
+
self.saw_startup_window = windows.len == 1;
|
|
1029
|
+
self.saw_hidden = windows.len == 1 and windows[0].hidden;
|
|
1030
|
+
}
|
|
1031
|
+
|
|
1032
|
+
fn scene(context: *anyopaque) anyerror!app_manifest.ShellConfig {
|
|
1033
|
+
_ = context;
|
|
1034
|
+
return .{};
|
|
1035
|
+
}
|
|
1036
|
+
|
|
1037
|
+
fn app(self: *@This()) App {
|
|
1038
|
+
return .{
|
|
1039
|
+
.context = self,
|
|
1040
|
+
.name = "hidden-startup-state",
|
|
1041
|
+
.start_fn = start,
|
|
1042
|
+
.scene_fn = scene,
|
|
1043
|
+
};
|
|
1044
|
+
}
|
|
1045
|
+
};
|
|
1046
|
+
|
|
1047
|
+
var null_platform = platform.NullPlatform.initWithOptions(.{}, .system, .{
|
|
1048
|
+
.app_name = "Hidden Startup",
|
|
1049
|
+
.main_window = .{
|
|
1050
|
+
.label = "main",
|
|
1051
|
+
.show = .hidden,
|
|
1052
|
+
},
|
|
1053
|
+
});
|
|
1054
|
+
const runtime = try std.testing.allocator.create(Runtime);
|
|
1055
|
+
defer std.testing.allocator.destroy(runtime);
|
|
1056
|
+
Runtime.initAt(runtime, .{ .platform = null_platform.platform() });
|
|
1057
|
+
defer runtime.deinit();
|
|
1058
|
+
var app_state: TestApp = .{};
|
|
1059
|
+
|
|
1060
|
+
try runtime.dispatchPlatformEvent(app_state.app(), .app_start);
|
|
1061
|
+
|
|
1062
|
+
try std.testing.expect(app_state.saw_startup_window);
|
|
1063
|
+
try std.testing.expect(app_state.saw_hidden);
|
|
1064
|
+
try std.testing.expect(runtime.windows[0].info.hidden);
|
|
1065
|
+
try std.testing.expect(!runtime.windows[0].info.focused);
|
|
1066
|
+
}
|
|
1067
|
+
|
|
948
1068
|
test "runtime loads canvas-only startup shell without implicit main webview" {
|
|
949
1069
|
const TestApp = struct {
|
|
950
1070
|
const scene_views = [_]app_manifest.ShellView{.{
|