create-mercato-app 0.7.1-develop.7150.1.c1941e0c22 → 0.7.1-develop.7152.1.a69e92f9c9

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 (119) hide show
  1. package/agentic/shared/ai/harness/cases.json +4 -2
  2. package/dist/agentic/guides/module-facts.json +828 -149
  3. package/dist/agentic/guides/module-facts.v2.json +828 -149
  4. package/dist/agentic/guides/modules/ai_assistant/index.md +1 -1
  5. package/dist/agentic/guides/modules/api_docs/index.md +1 -1
  6. package/dist/agentic/guides/modules/api_keys/index.md +1 -1
  7. package/dist/agentic/guides/modules/attachments/index.md +1 -1
  8. package/dist/agentic/guides/modules/audit_logs/index.md +1 -1
  9. package/dist/agentic/guides/modules/auth/index.md +1 -1
  10. package/dist/agentic/guides/modules/business_rules/index.md +1 -1
  11. package/dist/agentic/guides/modules/catalog/index.md +1 -1
  12. package/dist/agentic/guides/modules/channel_apns/index.md +1 -1
  13. package/dist/agentic/guides/modules/channel_discord/index.md +1 -1
  14. package/dist/agentic/guides/modules/channel_expo/index.md +1 -1
  15. package/dist/agentic/guides/modules/channel_fcm/index.md +1 -1
  16. package/dist/agentic/guides/modules/channel_gmail/index.md +1 -1
  17. package/dist/agentic/guides/modules/channel_imap/index.md +1 -1
  18. package/dist/agentic/guides/modules/channel_resend/acl-features.md +12 -0
  19. package/dist/agentic/guides/modules/channel_resend/contribution-resolutions.md +11 -0
  20. package/dist/agentic/guides/modules/channel_resend/di-registrations-rich.md +12 -0
  21. package/dist/agentic/guides/modules/channel_resend/exact-override-targets.md +16 -0
  22. package/dist/agentic/guides/modules/channel_resend/index.md +18 -0
  23. package/dist/agentic/guides/modules/channel_resend/owned-contract-module-metadata.md +11 -0
  24. package/dist/agentic/guides/modules/channel_resend/setup.md +11 -0
  25. package/dist/agentic/guides/modules/channel_resend/umes-contributions.md +11 -0
  26. package/dist/agentic/guides/modules/channel_ses/acl-features.md +12 -0
  27. package/dist/agentic/guides/modules/channel_ses/contribution-resolutions.md +11 -0
  28. package/dist/agentic/guides/modules/channel_ses/di-registrations-rich.md +12 -0
  29. package/dist/agentic/guides/modules/channel_ses/exact-override-targets.md +16 -0
  30. package/dist/agentic/guides/modules/channel_ses/index.md +18 -0
  31. package/dist/agentic/guides/modules/channel_ses/owned-contract-module-metadata.md +11 -0
  32. package/dist/agentic/guides/modules/channel_ses/setup.md +11 -0
  33. package/dist/agentic/guides/modules/channel_ses/umes-contributions.md +11 -0
  34. package/dist/agentic/guides/modules/checkout/index.md +1 -1
  35. package/dist/agentic/guides/modules/communication_channels/di-registrations-rich.md +10 -9
  36. package/dist/agentic/guides/modules/communication_channels/exact-override-targets.md +12 -11
  37. package/dist/agentic/guides/modules/communication_channels/index.md +1 -1
  38. package/dist/agentic/guides/modules/communication_channels/setup.md +1 -1
  39. package/dist/agentic/guides/modules/configs/index.md +1 -1
  40. package/dist/agentic/guides/modules/content/index.md +1 -1
  41. package/dist/agentic/guides/modules/currencies/index.md +1 -1
  42. package/dist/agentic/guides/modules/customer_accounts/index.md +1 -1
  43. package/dist/agentic/guides/modules/customers/index.md +1 -1
  44. package/dist/agentic/guides/modules/dashboards/index.md +1 -1
  45. package/dist/agentic/guides/modules/data_sync/index.md +1 -1
  46. package/dist/agentic/guides/modules/design_system/index.md +1 -1
  47. package/dist/agentic/guides/modules/devices/index.md +1 -1
  48. package/dist/agentic/guides/modules/dictionaries/index.md +1 -1
  49. package/dist/agentic/guides/modules/directory/index.md +1 -1
  50. package/dist/agentic/guides/modules/documents/index.md +1 -1
  51. package/dist/agentic/guides/modules/entities/index.md +1 -1
  52. package/dist/agentic/guides/modules/eudr/index.md +1 -1
  53. package/dist/agentic/guides/modules/events/index.md +1 -1
  54. package/dist/agentic/guides/modules/feature_toggles/index.md +1 -1
  55. package/dist/agentic/guides/modules/gateway_stripe/index.md +1 -1
  56. package/dist/agentic/guides/modules/generators/index.md +1 -1
  57. package/dist/agentic/guides/modules/inbox_ops/index.md +1 -1
  58. package/dist/agentic/guides/modules/integrations/index.md +1 -1
  59. package/dist/agentic/guides/modules/messages/index.md +1 -1
  60. package/dist/agentic/guides/modules/notifications/index.md +1 -1
  61. package/dist/agentic/guides/modules/onboarding/index.md +1 -1
  62. package/dist/agentic/guides/modules/payment_gateways/index.md +1 -1
  63. package/dist/agentic/guides/modules/perspectives/index.md +1 -1
  64. package/dist/agentic/guides/modules/planner/index.md +1 -1
  65. package/dist/agentic/guides/modules/portal/index.md +1 -1
  66. package/dist/agentic/guides/modules/progress/index.md +1 -1
  67. package/dist/agentic/guides/modules/push_notifications/index.md +1 -1
  68. package/dist/agentic/guides/modules/query_index/index.md +1 -1
  69. package/dist/agentic/guides/modules/record_locks/index.md +1 -1
  70. package/dist/agentic/guides/modules/resources/index.md +1 -1
  71. package/dist/agentic/guides/modules/sales/index.md +1 -1
  72. package/dist/agentic/guides/modules/scheduler/index.md +1 -1
  73. package/dist/agentic/guides/modules/search/index.md +1 -1
  74. package/dist/agentic/guides/modules/security/index.md +1 -1
  75. package/dist/agentic/guides/modules/shipping_carriers/index.md +1 -1
  76. package/dist/agentic/guides/modules/sso/index.md +1 -1
  77. package/dist/agentic/guides/modules/staff/index.md +1 -1
  78. package/dist/agentic/guides/modules/storage_s3/index.md +1 -1
  79. package/dist/agentic/guides/modules/sync_akeneo/index.md +1 -1
  80. package/dist/agentic/guides/modules/sync_excel/index.md +1 -1
  81. package/dist/agentic/guides/modules/system_status_overlays/index.md +1 -1
  82. package/dist/agentic/guides/modules/translations/index.md +1 -1
  83. package/dist/agentic/guides/modules/warranty_claims/index.md +1 -1
  84. package/dist/agentic/guides/modules/webhooks/index.md +1 -1
  85. package/dist/agentic/guides/modules/wms/index.md +1 -1
  86. package/dist/agentic/guides/modules/workflows/index.md +1 -1
  87. package/dist/agentic/guides/reference-module-facts.json +1 -1
  88. package/dist/agentic/guides/upstream/manifest.json +1 -1
  89. package/dist/agentic/shared/ai/harness/cases.json +4 -2
  90. package/package.json +3 -3
  91. package/template/.env.example +46 -1
  92. package/template/package.json.template +2 -0
  93. package/template/scripts/dev-runtime-actions.mjs +99 -0
  94. package/template/scripts/dev-runtime-config.mjs +89 -0
  95. package/template/scripts/dev-runtime-diagnostics.mjs +292 -0
  96. package/template/scripts/dev-runtime-gateway.mjs +370 -0
  97. package/template/scripts/dev-runtime-probe.mjs +77 -0
  98. package/template/scripts/dev-runtime-state.mjs +571 -0
  99. package/template/scripts/dev-runtime-supervisor.mjs +268 -0
  100. package/template/scripts/dev-runtime.mjs +29 -0
  101. package/template/scripts/dev-splash-state.mjs +14 -0
  102. package/template/scripts/dev-splash.html +357 -2
  103. package/template/scripts/dev.mjs +396 -14
  104. package/template/src/app/__tests__/start-page-bootstrap.test.ts +34 -0
  105. package/template/src/app/api/dev-runtime/actions/[action]/route.ts +5 -0
  106. package/template/src/app/api/dev-runtime/diagnostics/route.ts +5 -0
  107. package/template/src/app/api/dev-runtime/logs/route.ts +5 -0
  108. package/template/src/app/api/dev-runtime/status/route.ts +5 -0
  109. package/template/src/app/api/healthz/__tests__/route.test.ts +3 -1
  110. package/template/src/app/global-error.tsx +7 -0
  111. package/template/src/app/layout.tsx +11 -0
  112. package/template/src/app/start/page.tsx +11 -1
  113. package/template/src/i18n/de.json +27 -0
  114. package/template/src/i18n/en.json +27 -0
  115. package/template/src/i18n/es.json +27 -0
  116. package/template/src/i18n/ko.json +27 -0
  117. package/template/src/i18n/pl.json +27 -0
  118. package/template/src/modules/example/__integration__/TC-START-001-onboarding-gate.spec.ts +33 -0
  119. package/template/src/modules.ts +2 -0
@@ -639,6 +639,104 @@
639
639
  color: var(--warning);
640
640
  word-break: break-all;
641
641
  }
642
+ .incident-box {
643
+ display: grid;
644
+ gap: 8px;
645
+ padding: 16px 18px;
646
+ border-radius: 18px;
647
+ border: 1px solid rgba(239, 68, 68, 0.24);
648
+ background: var(--danger-surface);
649
+ min-width: 0;
650
+ max-width: 100%;
651
+ overflow: hidden;
652
+ }
653
+ .incident-box[hidden] {
654
+ display: none;
655
+ }
656
+ .incident-box[data-severity="warning"] {
657
+ border-color: rgba(234, 179, 8, 0.3);
658
+ }
659
+ .incident-header {
660
+ display: flex;
661
+ align-items: center;
662
+ gap: 8px;
663
+ flex-wrap: wrap;
664
+ }
665
+ .incident-badge {
666
+ border-radius: 999px;
667
+ padding: 2px 10px;
668
+ font-size: 11px;
669
+ font-weight: 800;
670
+ letter-spacing: 0.08em;
671
+ text-transform: uppercase;
672
+ color: var(--danger);
673
+ border: 1px solid rgba(239, 68, 68, 0.35);
674
+ }
675
+ .incident-box[data-severity="warning"] .incident-badge {
676
+ color: #b45309;
677
+ border-color: rgba(234, 179, 8, 0.45);
678
+ }
679
+ .incident-title {
680
+ color: var(--text);
681
+ font-size: 15px;
682
+ font-weight: 700;
683
+ word-break: break-word;
684
+ }
685
+ .incident-detail {
686
+ color: var(--text);
687
+ font-size: 13px;
688
+ line-height: 1.6;
689
+ word-break: break-word;
690
+ }
691
+ .incident-meta {
692
+ display: grid;
693
+ grid-template-columns: auto 1fr;
694
+ gap: 2px 12px;
695
+ margin: 0;
696
+ color: var(--muted);
697
+ font-size: 12px;
698
+ }
699
+ .incident-meta dt {
700
+ font-weight: 600;
701
+ }
702
+ .incident-meta dd {
703
+ margin: 0;
704
+ font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
705
+ word-break: break-all;
706
+ }
707
+ .incident-actions {
708
+ display: flex;
709
+ flex-wrap: wrap;
710
+ gap: 8px;
711
+ }
712
+ .incident-actions:empty {
713
+ display: none;
714
+ }
715
+ .incident-action {
716
+ min-height: 34px;
717
+ padding: 0 12px;
718
+ border-radius: 999px;
719
+ border: 1px solid var(--panel-border);
720
+ background: var(--surface);
721
+ color: var(--text);
722
+ font: inherit;
723
+ font-size: 12px;
724
+ font-weight: 600;
725
+ cursor: pointer;
726
+ }
727
+ .incident-action[disabled] {
728
+ opacity: 0.55;
729
+ cursor: default;
730
+ }
731
+ .incident-action[data-tone="danger"] {
732
+ color: var(--danger);
733
+ border-color: rgba(239, 68, 68, 0.4);
734
+ }
735
+ .incident-hint {
736
+ color: var(--muted);
737
+ font-size: 12px;
738
+ line-height: 1.5;
739
+ }
642
740
  .failure-box {
643
741
  display: grid;
644
742
  gap: 10px;
@@ -821,6 +919,17 @@
821
919
  </div>
822
920
  <div class="git-repo-secondary" id="git-repo-secondary" hidden></div>
823
921
  </section>
922
+ <section class="incident-box" id="incident-box" hidden>
923
+ <div class="incident-header">
924
+ <span class="incident-badge" id="incident-badge"></span>
925
+ <span class="incident-title" id="incident-title"></span>
926
+ </div>
927
+ <div class="incident-detail" id="incident-detail"></div>
928
+ <dl class="incident-meta" id="incident-meta"></dl>
929
+ <div class="incident-hint" id="incident-hint"></div>
930
+ <div class="incident-actions" id="incident-actions"></div>
931
+ <div class="incident-hint" id="incident-action-status" role="status" aria-live="polite"></div>
932
+ </section>
824
933
  <section class="failure-box" id="failure-box" hidden>
825
934
  <div class="failure-heading" id="failure-heading">Recent failure output</div>
826
935
  <div class="failure-command" id="failure-command"></div>
@@ -870,6 +979,14 @@
870
979
  const failureHeading = document.getElementById('failure-heading')
871
980
  const failureCommand = document.getElementById('failure-command')
872
981
  const failureLines = document.getElementById('failure-lines')
982
+ const incidentBox = document.getElementById('incident-box')
983
+ const incidentBadge = document.getElementById('incident-badge')
984
+ const incidentTitle = document.getElementById('incident-title')
985
+ const incidentDetail = document.getElementById('incident-detail')
986
+ const incidentMeta = document.getElementById('incident-meta')
987
+ const incidentHint = document.getElementById('incident-hint')
988
+ const incidentActions = document.getElementById('incident-actions')
989
+ const incidentActionStatus = document.getElementById('incident-action-status')
873
990
  const THEME_KEY = 'om-dev-theme'
874
991
  const LOCALE_KEY = 'om-dev-locale'
875
992
  const supportedLocales = Array.isArray(splashBootstrap.supportedLocales) && splashBootstrap.supportedLocales.length > 0
@@ -922,6 +1039,28 @@
922
1039
  gitRepoBusyRemote: 'Publishing to GitHub…',
923
1040
  gitRepoOpen: 'Open GitHub repository',
924
1041
  gitRepoRestartHint: 'Install GitHub CLI, then restart `yarn dev`.',
1042
+ incidentHealth_starting: 'Starting',
1043
+ incidentHealth_degraded: 'Degraded',
1044
+ incidentHealth_recovering: 'Recovering',
1045
+ incidentHealth_unavailable: 'Unavailable',
1046
+ incidentCode: 'Error code',
1047
+ incidentSource: 'Source',
1048
+ incidentOccurrences: 'Occurrences',
1049
+ incidentLastSeen: 'Last seen',
1050
+ incidentPath: 'Path',
1051
+ incidentRecovery_generate: 'Suggested fix: rerun the generators (`yarn generate`).',
1052
+ incidentRecovery_migrate: 'Suggested fix: apply database migrations (`yarn db:migrate`). This changes the database and is not automatically reversible.',
1053
+ incidentRecovery_restart: 'Suggested fix: restart the dev runtime.',
1054
+ incidentAction_generate: 'Run generators',
1055
+ incidentAction_migrate: 'Run migrations',
1056
+ incidentAction_restart: 'Restart runtime',
1057
+ incidentActionConfirm_migrate: 'Confirm: apply migrations',
1058
+ incidentActionCancel: 'Cancel',
1059
+ incidentActionMigrateWarning: 'Migrations change the database and are not automatically reversible. Click again to confirm.',
1060
+ incidentActionStarting: 'Starting the recovery action…',
1061
+ incidentActionAccepted: 'Recovery action started. Watch the startup stream for progress.',
1062
+ incidentActionBusy: 'A recovery action is already running.',
1063
+ incidentActionFailed: 'The recovery action could not be started.',
925
1064
  },
926
1065
  pl: {
927
1066
  badge: 'Open Mercato Dev',
@@ -960,6 +1099,28 @@
960
1099
  gitRepoBusyRemote: 'Publikowanie na GitHub…',
961
1100
  gitRepoOpen: 'Otwórz repozytorium GitHub',
962
1101
  gitRepoRestartHint: 'Zainstaluj GitHub CLI, a potem uruchom ponownie `yarn dev`.',
1102
+ incidentHealth_starting: 'Uruchamianie',
1103
+ incidentHealth_degraded: 'Ograniczona sprawność',
1104
+ incidentHealth_recovering: 'Odzyskiwanie',
1105
+ incidentHealth_unavailable: 'Niedostępne',
1106
+ incidentCode: 'Kod błędu',
1107
+ incidentSource: 'Źródło',
1108
+ incidentOccurrences: 'Wystąpienia',
1109
+ incidentLastSeen: 'Ostatnie wystąpienie',
1110
+ incidentPath: 'Ścieżka',
1111
+ incidentRecovery_generate: 'Sugerowana naprawa: uruchom ponownie generatory (`yarn generate`).',
1112
+ incidentRecovery_migrate: 'Sugerowana naprawa: zastosuj migracje bazy danych (`yarn db:migrate`). Zmienia to bazę i nie jest automatycznie odwracalne.',
1113
+ incidentRecovery_restart: 'Sugerowana naprawa: zrestartuj środowisko developerskie.',
1114
+ incidentAction_generate: 'Uruchom generatory',
1115
+ incidentAction_migrate: 'Uruchom migracje',
1116
+ incidentAction_restart: 'Zrestartuj środowisko',
1117
+ incidentActionConfirm_migrate: 'Potwierdź: zastosuj migracje',
1118
+ incidentActionCancel: 'Anuluj',
1119
+ incidentActionMigrateWarning: 'Migracje zmieniają bazę danych i nie są automatycznie odwracalne. Kliknij ponownie, aby potwierdzić.',
1120
+ incidentActionStarting: 'Uruchamianie akcji naprawczej…',
1121
+ incidentActionAccepted: 'Akcja naprawcza uruchomiona. Obserwuj strumień startu.',
1122
+ incidentActionBusy: 'Akcja naprawcza jest już w toku.',
1123
+ incidentActionFailed: 'Nie udało się uruchomić akcji naprawczej.',
963
1124
  },
964
1125
  es: {
965
1126
  badge: 'Open Mercato Dev',
@@ -998,6 +1159,28 @@
998
1159
  gitRepoBusyRemote: 'Publicando en GitHub…',
999
1160
  gitRepoOpen: 'Abrir repositorio de GitHub',
1000
1161
  gitRepoRestartHint: 'Instala GitHub CLI y luego reinicia `yarn dev`.',
1162
+ incidentHealth_starting: 'Iniciando',
1163
+ incidentHealth_degraded: 'Degradado',
1164
+ incidentHealth_recovering: 'Recuperando',
1165
+ incidentHealth_unavailable: 'No disponible',
1166
+ incidentCode: 'Código de error',
1167
+ incidentSource: 'Origen',
1168
+ incidentOccurrences: 'Ocurrencias',
1169
+ incidentLastSeen: 'Última vez',
1170
+ incidentPath: 'Ruta',
1171
+ incidentRecovery_generate: 'Solución sugerida: vuelve a ejecutar los generadores (`yarn generate`).',
1172
+ incidentRecovery_migrate: 'Solución sugerida: aplica las migraciones de base de datos (`yarn db:migrate`). Modifica la base de datos y no es reversible automáticamente.',
1173
+ incidentRecovery_restart: 'Solución sugerida: reinicia el entorno de desarrollo.',
1174
+ incidentAction_generate: 'Ejecutar generadores',
1175
+ incidentAction_migrate: 'Ejecutar migraciones',
1176
+ incidentAction_restart: 'Reiniciar entorno',
1177
+ incidentActionConfirm_migrate: 'Confirmar: aplicar migraciones',
1178
+ incidentActionCancel: 'Cancelar',
1179
+ incidentActionMigrateWarning: 'Las migraciones modifican la base de datos y no son reversibles automáticamente. Haz clic de nuevo para confirmar.',
1180
+ incidentActionStarting: 'Iniciando la acción de recuperación…',
1181
+ incidentActionAccepted: 'Acción de recuperación iniciada. Observa el flujo de arranque.',
1182
+ incidentActionBusy: 'Ya hay una acción de recuperación en curso.',
1183
+ incidentActionFailed: 'No se pudo iniciar la acción de recuperación.',
1001
1184
  },
1002
1185
  de: {
1003
1186
  badge: 'Open Mercato Dev',
@@ -1036,6 +1219,28 @@
1036
1219
  gitRepoBusyRemote: 'Auf GitHub wird veroeffentlicht…',
1037
1220
  gitRepoOpen: 'GitHub-Repository oeffnen',
1038
1221
  gitRepoRestartHint: 'Installiere GitHub CLI und starte dann `yarn dev` neu.',
1222
+ incidentHealth_starting: 'Startet',
1223
+ incidentHealth_degraded: 'Eingeschränkt',
1224
+ incidentHealth_recovering: 'Erholt sich',
1225
+ incidentHealth_unavailable: 'Nicht verfügbar',
1226
+ incidentCode: 'Fehlercode',
1227
+ incidentSource: 'Quelle',
1228
+ incidentOccurrences: 'Vorkommen',
1229
+ incidentLastSeen: 'Zuletzt gesehen',
1230
+ incidentPath: 'Pfad',
1231
+ incidentRecovery_generate: 'Empfohlene Behebung: Generatoren erneut ausführen (`yarn generate`).',
1232
+ incidentRecovery_migrate: 'Empfohlene Behebung: Datenbankmigrationen anwenden (`yarn db:migrate`). Das ändert die Datenbank und ist nicht automatisch umkehrbar.',
1233
+ incidentRecovery_restart: 'Empfohlene Behebung: Dev-Laufzeit neu starten.',
1234
+ incidentAction_generate: 'Generatoren ausführen',
1235
+ incidentAction_migrate: 'Migrationen ausführen',
1236
+ incidentAction_restart: 'Laufzeit neu starten',
1237
+ incidentActionConfirm_migrate: 'Bestätigen: Migrationen anwenden',
1238
+ incidentActionCancel: 'Abbrechen',
1239
+ incidentActionMigrateWarning: 'Migrationen ändern die Datenbank und sind nicht automatisch umkehrbar. Zum Bestätigen erneut klicken.',
1240
+ incidentActionStarting: 'Wiederherstellungsaktion wird gestartet…',
1241
+ incidentActionAccepted: 'Wiederherstellungsaktion gestartet. Verfolge den Startstream.',
1242
+ incidentActionBusy: 'Es läuft bereits eine Wiederherstellungsaktion.',
1243
+ incidentActionFailed: 'Die Wiederherstellungsaktion konnte nicht gestartet werden.',
1039
1244
  },
1040
1245
  }
1041
1246
  const exactTranslations = {
@@ -1281,8 +1486,158 @@
1281
1486
  scheduleActivityListLayout()
1282
1487
  }
1283
1488
 
1489
+ function resolveActiveIncident(state) {
1490
+ const runtime = state && typeof state.runtime === 'object' ? state.runtime : null
1491
+ if (!runtime) return null
1492
+ const summary = runtime.issueSummary
1493
+ if (!summary || typeof summary !== 'object') return null
1494
+ if (summary.generation !== runtime.generation) return null
1495
+ return summary
1496
+ }
1497
+
1498
+ function formatIncidentTimestamp(value) {
1499
+ const parsed = Date.parse(String(value ?? ''))
1500
+ if (!Number.isFinite(parsed)) return ''
1501
+ return new Date(parsed).toLocaleTimeString()
1502
+ }
1503
+
1504
+ function appendIncidentMetaRow(label, value) {
1505
+ if (!value) return
1506
+ const term = document.createElement('dt')
1507
+ term.textContent = label
1508
+ const definition = document.createElement('dd')
1509
+ definition.textContent = value
1510
+ incidentMeta.append(term, definition)
1511
+ }
1512
+
1513
+ // Structured, human-readable preview of the current runtime incident. It
1514
+ // stays above the raw failure output so a developer reads "what broke and
1515
+ // what to do" before the log tail.
1516
+ function renderIncident(state) {
1517
+ const incident = resolveActiveIncident(state)
1518
+ incidentBox.hidden = !incident
1519
+ incidentMeta.replaceChildren()
1520
+
1521
+ if (!incident) {
1522
+ incidentBadge.textContent = ''
1523
+ incidentTitle.textContent = ''
1524
+ incidentDetail.textContent = ''
1525
+ incidentHint.textContent = ''
1526
+ return
1527
+ }
1528
+
1529
+ const health = state?.runtime?.health
1530
+ incidentBox.dataset.severity = incident.severity === 'warning' ? 'warning' : 'error'
1531
+ incidentBadge.textContent = t('incidentHealth_' + String(health)) || String(health ?? '')
1532
+ incidentTitle.textContent = incident.title ?? ''
1533
+ incidentDetail.textContent = incident.detail ?? ''
1534
+
1535
+ appendIncidentMetaRow(t('incidentCode'), incident.code)
1536
+ appendIncidentMetaRow(t('incidentSource'), incident.source)
1537
+ appendIncidentMetaRow(t('incidentOccurrences'), String(incident.occurrences ?? 1))
1538
+ appendIncidentMetaRow(t('incidentLastSeen'), formatIncidentTimestamp(incident.lastSeenAt))
1539
+ if (incident.path) appendIncidentMetaRow(t('incidentPath'), incident.path)
1540
+
1541
+ const recoveryHint = incident.recovery ? t('incidentRecovery_' + incident.recovery) : ''
1542
+ incidentHint.textContent = recoveryHint || ''
1543
+
1544
+ renderIncidentActions(state, incident)
1545
+ }
1546
+
1547
+ // `migrate` mutates the database and is not automatically reversible, so
1548
+ // it always requires a second, explicit click rather than firing on the
1549
+ // first one. A native confirm dialog is deliberately avoided.
1550
+ let pendingConfirmAction = null
1551
+ let runtimeActionInFlight = false
1552
+
1553
+ function resolveIncidentActions(state, incident) {
1554
+ if (!splashBootstrap.runtimeToken) return []
1555
+ const actions = []
1556
+ if (incident.recovery === 'migrate') actions.push('migrate')
1557
+ if (incident.recovery === 'generate') actions.push('generate')
1558
+ if (!actions.includes('restart')) actions.push('restart')
1559
+ return actions
1560
+ }
1561
+
1562
+ function renderIncidentActions(state, incident) {
1563
+ const busy = state?.runtime?.recovery?.busy === true
1564
+ incidentActions.replaceChildren()
1565
+
1566
+ if (busy) {
1567
+ incidentActionStatus.textContent = t('incidentActionBusy')
1568
+ return
1569
+ }
1570
+ if (!runtimeActionInFlight) incidentActionStatus.textContent = incidentActionStatus.dataset.sticky ?? ''
1571
+
1572
+ for (const action of resolveIncidentActions(state, incident)) {
1573
+ const button = document.createElement('button')
1574
+ button.type = 'button'
1575
+ button.className = 'incident-action'
1576
+ button.disabled = runtimeActionInFlight
1577
+ if (action === 'migrate') button.dataset.tone = 'danger'
1578
+ button.textContent = pendingConfirmAction === action
1579
+ ? t('incidentActionConfirm_' + action)
1580
+ : t('incidentAction_' + action)
1581
+ button.addEventListener('click', () => { void handleIncidentAction(action) })
1582
+ incidentActions.append(button)
1583
+ }
1584
+
1585
+ if (pendingConfirmAction) {
1586
+ const cancel = document.createElement('button')
1587
+ cancel.type = 'button'
1588
+ cancel.className = 'incident-action'
1589
+ cancel.textContent = t('incidentActionCancel')
1590
+ cancel.addEventListener('click', () => {
1591
+ pendingConfirmAction = null
1592
+ renderIncidentActions(state, incident)
1593
+ })
1594
+ incidentActions.append(cancel)
1595
+ }
1596
+ }
1597
+
1598
+ async function handleIncidentAction(action) {
1599
+ if (runtimeActionInFlight) return
1600
+ if (action === 'migrate' && pendingConfirmAction !== 'migrate') {
1601
+ pendingConfirmAction = 'migrate'
1602
+ incidentActionStatus.textContent = t('incidentActionMigrateWarning')
1603
+ renderIncident(lastState)
1604
+ return
1605
+ }
1606
+
1607
+ pendingConfirmAction = null
1608
+ runtimeActionInFlight = true
1609
+ incidentActionStatus.textContent = t('incidentActionStarting')
1610
+ renderIncident(lastState)
1611
+
1612
+ try {
1613
+ const response = await fetch('/runtime/actions/' + encodeURIComponent(action), {
1614
+ method: 'POST',
1615
+ headers: { 'x-om-dev-runtime-token': splashBootstrap.runtimeToken },
1616
+ })
1617
+ if (!response.ok) {
1618
+ const payload = await response.json().catch(() => null)
1619
+ incidentActionStatus.dataset.sticky = payload?.error?.message || t('incidentActionFailed')
1620
+ incidentActionStatus.textContent = incidentActionStatus.dataset.sticky
1621
+ return
1622
+ }
1623
+ incidentActionStatus.dataset.sticky = ''
1624
+ incidentActionStatus.textContent = t('incidentActionAccepted')
1625
+ } catch {
1626
+ incidentActionStatus.dataset.sticky = t('incidentActionFailed')
1627
+ incidentActionStatus.textContent = incidentActionStatus.dataset.sticky
1628
+ } finally {
1629
+ runtimeActionInFlight = false
1630
+ renderIncident(lastState)
1631
+ }
1632
+ }
1633
+
1284
1634
  function renderFailure(state) {
1285
- const failed = state?.failed === true && state?.ready !== true
1635
+ const incident = resolveActiveIncident(state)
1636
+ const lines = Array.isArray(state?.failureLines) ? state.failureLines : []
1637
+ // Post-ready incidents project to `failed: false`, so the redacted log
1638
+ // tail must follow the incident rather than the legacy flag alone.
1639
+ const failed = (state?.failed === true && state?.ready !== true)
1640
+ || (incident !== null && lines.length > 0)
1286
1641
  failureBox.hidden = !failed
1287
1642
 
1288
1643
  if (!failed) {
@@ -1296,7 +1651,6 @@
1296
1651
  ? state.failureCommand.trim()
1297
1652
  : ''
1298
1653
  failureCommand.textContent = command ? t('failureCommand') + ': ' + command : ''
1299
- const lines = Array.isArray(state.failureLines) ? state.failureLines : []
1300
1654
  failureLines.textContent = lines.join('\n')
1301
1655
  }
1302
1656
 
@@ -1661,6 +2015,7 @@
1661
2015
  progressFill.style.width = percent + '%'
1662
2016
  readyUrl.textContent = state.readyUrl || t('targetPending')
1663
2017
  renderActivities(state.activities)
2018
+ renderIncident(state)
1664
2019
  renderFailure(state)
1665
2020
  lastState = state
1666
2021
  renderCodingFlow(state)