@delmaredigital/payload-experiments 0.4.0-rc.9 → 0.4.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 (254) hide show
  1. package/README.md +2 -8
  2. package/dist/admin/MetricSourceSelect.js +10 -3
  3. package/dist/admin/armSelect/armSelect.model.d.ts +1 -1
  4. package/dist/admin/blocks/BlockPanel.d.ts +1 -0
  5. package/dist/admin/blocks/BlockPanel.js +75 -29
  6. package/dist/admin/blocks/model.js +5 -4
  7. package/dist/admin/copy/blocks.d.ts +14 -11
  8. package/dist/admin/copy/blocks.js +33 -22
  9. package/dist/admin/copy/goals.d.ts +15 -8
  10. package/dist/admin/copy/goals.js +18 -8
  11. package/dist/admin/copy/newTest.d.ts +10 -7
  12. package/dist/admin/copy/newTest.js +14 -7
  13. package/dist/admin/copy/status.d.ts +1 -1
  14. package/dist/admin/copy/status.js +2 -1
  15. package/dist/admin/pageCollections.d.ts +1 -0
  16. package/dist/admin/pageCollections.js +3 -0
  17. package/dist/admin/placementStatus.model.js +5 -3
  18. package/dist/admin/status.model.d.ts +1 -0
  19. package/dist/admin/status.model.js +2 -1
  20. package/dist/admin/surface/ResultsRoute.js +4 -8
  21. package/dist/admin/surface/SurfaceShell.d.ts +4 -2
  22. package/dist/admin/surface/SurfaceShell.js +28 -3
  23. package/dist/admin/surface/TestRowMenu.d.ts +13 -0
  24. package/dist/admin/surface/TestRowMenu.js +163 -0
  25. package/dist/admin/surface/TestsHome.d.ts +4 -3
  26. package/dist/admin/surface/TestsHome.js +186 -47
  27. package/dist/admin/surface/TestsSurface.js +2 -1
  28. package/dist/admin/surface/goals/DeleteGoalDialog.d.ts +7 -0
  29. package/dist/admin/surface/goals/DeleteGoalDialog.js +42 -0
  30. package/dist/admin/surface/goals/GoalForm.d.ts +1 -0
  31. package/dist/admin/surface/goals/GoalForm.js +280 -198
  32. package/dist/admin/surface/goals/GoalsList.js +102 -33
  33. package/dist/admin/surface/goals/data.d.ts +2 -0
  34. package/dist/admin/surface/goals/data.js +9 -0
  35. package/dist/admin/surface/goals/goals.css +3 -2
  36. package/dist/admin/surface/goals/goals.model.d.ts +2 -2
  37. package/dist/admin/surface/goals/goals.model.js +7 -12
  38. package/dist/admin/surface/home.model.d.ts +15 -8
  39. package/dist/admin/surface/home.model.js +22 -18
  40. package/dist/admin/surface/newTest/NewTest.d.ts +3 -3
  41. package/dist/admin/surface/newTest/NewTest.js +156 -96
  42. package/dist/admin/surface/newTest/PageWizard.d.ts +4 -1
  43. package/dist/admin/surface/newTest/PageWizard.js +93 -68
  44. package/dist/admin/surface/newTest/newTest.css +28 -11
  45. package/dist/admin/surface/results/ResultsHeader.d.ts +1 -1
  46. package/dist/admin/surface/results/ResultsHeader.js +90 -63
  47. package/dist/admin/surface/surface.css +29 -0
  48. package/dist/admin/surface/test/TestPage.js +46 -38
  49. package/dist/admin/surface/useXpStepNav.d.ts +11 -0
  50. package/dist/admin/surface/useXpStepNav.js +14 -0
  51. package/dist/admin/views/TestsSurfaceClient.js +27 -3
  52. package/dist/admin/views/buildSurfaceProps.js +18 -66
  53. package/dist/arms/copy.d.ts +13 -3
  54. package/dist/arms/copy.js +5 -4
  55. package/dist/blocks/createExperimentBlock.js +1 -1
  56. package/dist/blocks/formState.js +1 -1
  57. package/dist/collections/experiments/armInvariants.js +8 -5
  58. package/dist/collections/metrics.js +12 -5
  59. package/dist/collections/serialize.js +3 -2
  60. package/dist/db/pageCopies.d.ts +5 -0
  61. package/dist/db/pageCopies.js +31 -0
  62. package/dist/db/snapshots.d.ts +1 -0
  63. package/dist/endpoints/duplicateOriginal.d.ts +38 -0
  64. package/dist/endpoints/duplicateOriginal.js +414 -0
  65. package/dist/endpoints/editorSurface.js +1 -1
  66. package/dist/endpoints/index.js +20 -0
  67. package/dist/endpoints/pages.js +245 -66
  68. package/dist/endpoints/placementStatus.js +1 -0
  69. package/dist/endpoints/results.js +3 -0
  70. package/dist/endpoints/testVersion.d.ts +2 -0
  71. package/dist/endpoints/testVersion.js +38 -0
  72. package/dist/endpoints/transitions.js +4 -5
  73. package/dist/exports/index.d.ts +1 -1
  74. package/dist/goals/picker/copy.js +1 -1
  75. package/dist/goals/sourceLabel.d.ts +2 -0
  76. package/dist/goals/sourceLabel.js +4 -0
  77. package/dist/hooks/trackPageCopies.d.ts +11 -0
  78. package/dist/hooks/trackPageCopies.js +7 -0
  79. package/dist/labels/arms.d.ts +3 -0
  80. package/dist/labels/arms.js +8 -0
  81. package/dist/options.d.ts +2 -0
  82. package/dist/options.js +18 -2
  83. package/dist/plugin.js +56 -2
  84. package/dist/puck/editor/ConfigureTestDrawer.d.ts +7 -7
  85. package/dist/puck/editor/ConfigureTestDrawer.js +36 -26
  86. package/dist/puck/editor/ExperimentSlotEditor.d.ts +2 -1
  87. package/dist/puck/editor/ExperimentSlotEditor.js +219 -106
  88. package/dist/puck/editor/LeftoverVersions.js +17 -32
  89. package/dist/puck/editor/QuickTestActions.d.ts +2 -2
  90. package/dist/puck/editor/QuickTestActions.js +44 -34
  91. package/dist/puck/editor/ResultsReadout.d.ts +3 -1
  92. package/dist/puck/editor/ResultsReadout.js +28 -16
  93. package/dist/puck/editor/VersionBuilder.d.ts +4 -2
  94. package/dist/puck/editor/VersionBuilder.js +42 -63
  95. package/dist/puck/editor/armWrites.js +1 -1
  96. package/dist/puck/editor/copy.d.ts +10 -6
  97. package/dist/puck/editor/copy.js +22 -12
  98. package/dist/puck/editor/editor.chrome.css +9 -8
  99. package/dist/puck/editor/editor.css +14 -9
  100. package/dist/puck/editor/placementsCache.d.ts +1 -1
  101. package/dist/puck/editor/placementsCache.js +9 -17
  102. package/dist/puck/editor/usePageSaveReadiness.d.ts +1 -4
  103. package/dist/puck/editor/usePageSaveReadiness.js +18 -21
  104. package/dist/puck/editor/usePlacementNotice.d.ts +2 -2
  105. package/dist/puck/editor/usePlacementNotice.js +4 -5
  106. package/dist/puck/nestedTestCopy.js +2 -2
  107. package/dist/puck/slotConfig.d.ts +1 -1
  108. package/dist/puck/slotConfig.js +1 -1
  109. package/dist/results/analyse.d.ts +2 -0
  110. package/dist/results/analyse.js +2 -2
  111. package/dist/results/verdict.d.ts +4 -4
  112. package/dist/results/verdict.js +13 -10
  113. package/dist/server/runResults.js +2 -1
  114. package/dist/testSurface/PreviewLinks.d.ts +2 -1
  115. package/dist/testSurface/PreviewLinks.js +3 -3
  116. package/dist/testSurface/actions/DecideDialog.d.ts +7 -4
  117. package/dist/testSurface/actions/DecideDialog.js +71 -59
  118. package/dist/testSurface/actions/LifecycleAction.d.ts +17 -0
  119. package/dist/testSurface/actions/LifecycleAction.js +107 -0
  120. package/dist/testSurface/actions/MakeContentResult.js +1 -1
  121. package/dist/testSurface/actions/actions.model.d.ts +13 -5
  122. package/dist/testSurface/actions/actions.model.js +75 -22
  123. package/dist/testSurface/actions/decide.model.d.ts +1 -0
  124. package/dist/testSurface/actions/decide.model.js +1 -0
  125. package/dist/testSurface/allocation.model.js +6 -3
  126. package/dist/testSurface/api.d.ts +4 -1
  127. package/dist/testSurface/api.js +22 -14
  128. package/dist/testSurface/copy/actions.d.ts +36 -14
  129. package/dist/testSurface/copy/actions.js +39 -17
  130. package/dist/testSurface/copy/advanced.d.ts +10 -0
  131. package/dist/testSurface/copy/advanced.js +10 -0
  132. package/dist/testSurface/copy/arms.d.ts +1 -1
  133. package/dist/testSurface/copy/arms.js +1 -1
  134. package/dist/testSurface/copy/audience.d.ts +4 -3
  135. package/dist/testSurface/copy/audience.js +5 -4
  136. package/dist/testSurface/copy/common.d.ts +6 -6
  137. package/dist/testSurface/copy/common.js +6 -6
  138. package/dist/testSurface/copy/metrics.d.ts +6 -0
  139. package/dist/testSurface/copy/metrics.js +8 -0
  140. package/dist/testSurface/copy/pages.d.ts +67 -7
  141. package/dist/testSurface/copy/pages.js +74 -7
  142. package/dist/testSurface/copy/readiness.d.ts +8 -6
  143. package/dist/testSurface/copy/readiness.js +19 -10
  144. package/dist/testSurface/copy/recommendation.d.ts +1 -22
  145. package/dist/testSurface/copy/recommendation.js +2 -22
  146. package/dist/testSurface/copy/results.d.ts +16 -10
  147. package/dist/testSurface/copy/results.js +19 -11
  148. package/dist/testSurface/copy/review.d.ts +13 -10
  149. package/dist/testSurface/copy/review.js +14 -10
  150. package/dist/testSurface/copy/setting.d.ts +1 -2
  151. package/dist/testSurface/copy/setting.js +1 -2
  152. package/dist/testSurface/copy/surface.d.ts +11 -2
  153. package/dist/testSurface/copy/surface.js +14 -11
  154. package/dist/testSurface/copy/testPage.d.ts +16 -10
  155. package/dist/testSurface/copy/testPage.js +24 -18
  156. package/dist/testSurface/format/date.d.ts +5 -2
  157. package/dist/testSurface/format/date.js +24 -8
  158. package/dist/testSurface/format/roundProgress.d.ts +6 -0
  159. package/dist/testSurface/format/roundProgress.js +15 -0
  160. package/dist/testSurface/format/useDateFormatter.d.ts +3 -0
  161. package/dist/testSurface/format/useDateFormatter.js +8 -0
  162. package/dist/testSurface/labels.d.ts +1 -2
  163. package/dist/testSurface/labels.js +2 -3
  164. package/dist/testSurface/lockedNotice.model.d.ts +2 -0
  165. package/dist/testSurface/lockedNotice.model.js +31 -0
  166. package/dist/testSurface/readPreflight.d.ts +0 -1
  167. package/dist/testSurface/readPreflight.js +0 -1
  168. package/dist/testSurface/results/CiChart.js +2 -1
  169. package/dist/testSurface/results/DataTable.d.ts +1 -1
  170. package/dist/testSurface/results/DataTable.js +4 -3
  171. package/dist/testSurface/results/VerdictHero.d.ts +1 -1
  172. package/dist/testSurface/results/legacy.d.ts +0 -5
  173. package/dist/testSurface/results/legacy.js +0 -14
  174. package/dist/testSurface/results/results.css +2 -2
  175. package/dist/testSurface/results/results.model.d.ts +8 -3
  176. package/dist/testSurface/results/results.model.js +25 -21
  177. package/dist/testSurface/results/snapshot.d.ts +2 -0
  178. package/dist/testSurface/results/snapshot.js +3 -0
  179. package/dist/testSurface/surface/contracts.d.ts +6 -1
  180. package/dist/testSurface/surface/editorPlacement.d.ts +1 -1
  181. package/dist/testSurface/surface/editorPlacement.js +1 -1
  182. package/dist/testSurface/surface/pageBlock/pageBlock.model.js +1 -1
  183. package/dist/testSurface/surface/pageBlock/parts.js +25 -12
  184. package/dist/testSurface/surface/pagePicker/CopyRoute.d.ts +8 -1
  185. package/dist/testSurface/surface/pagePicker/CopyRoute.js +243 -22
  186. package/dist/testSurface/surface/pagePicker/PageCombobox.d.ts +15 -4
  187. package/dist/testSurface/surface/pagePicker/PageCombobox.js +298 -209
  188. package/dist/testSurface/surface/pagePicker/pagePicker.css +73 -10
  189. package/dist/testSurface/surface/pagePicker/pagePicker.model.d.ts +5 -3
  190. package/dist/testSurface/surface/pagePicker/pagePicker.model.js +17 -2
  191. package/dist/testSurface/surface/readiness/ActionDialogs.d.ts +5 -3
  192. package/dist/testSurface/surface/readiness/ActionDialogs.js +213 -207
  193. package/dist/testSurface/surface/readiness/Banner.d.ts +5 -1
  194. package/dist/testSurface/surface/readiness/Banner.js +109 -148
  195. package/dist/testSurface/surface/readiness/SaveStatus.d.ts +5 -2
  196. package/dist/testSurface/surface/readiness/SaveStatus.js +8 -7
  197. package/dist/testSurface/surface/readiness/readiness.model.d.ts +14 -5
  198. package/dist/testSurface/surface/readiness/readiness.model.js +62 -12
  199. package/dist/testSurface/surface/readiness/useTransition.d.ts +3 -1
  200. package/dist/testSurface/surface/readiness/useTransition.js +49 -8
  201. package/dist/testSurface/surface/results/ReleasePages.d.ts +4 -3
  202. package/dist/testSurface/surface/results/ReleasePages.js +41 -41
  203. package/dist/testSurface/surface/results/ResultsBody.d.ts +7 -2
  204. package/dist/testSurface/surface/results/ResultsBody.js +170 -110
  205. package/dist/testSurface/surface/results/recommendation.model.d.ts +6 -9
  206. package/dist/testSurface/surface/results/recommendation.model.js +15 -59
  207. package/dist/testSurface/surface/results/useResults.d.ts +6 -2
  208. package/dist/testSurface/surface/setting/parts.js +31 -28
  209. package/dist/testSurface/surface/setting/setting.css +2 -1
  210. package/dist/testSurface/surface/test/AdvancedSection.js +10 -4
  211. package/dist/testSurface/surface/test/DeleteTest.d.ts +5 -1
  212. package/dist/testSurface/surface/test/DeleteTest.js +63 -55
  213. package/dist/testSurface/surface/test/GoalSection.js +11 -11
  214. package/dist/testSurface/surface/test/LengthSection.js +21 -13
  215. package/dist/testSurface/surface/test/PageHoldout.d.ts +1 -1
  216. package/dist/testSurface/surface/test/PageHoldout.js +7 -7
  217. package/dist/testSurface/surface/test/ReadinessBar.d.ts +2 -1
  218. package/dist/testSurface/surface/test/ReadinessBar.js +4 -10
  219. package/dist/testSurface/surface/test/Section.js +8 -0
  220. package/dist/testSurface/surface/test/TargetingSection.js +7 -2
  221. package/dist/testSurface/surface/test/TestSurface.js +17 -43
  222. package/dist/testSurface/surface/test/VersionsSection.js +93 -70
  223. package/dist/testSurface/surface/test/fields.d.ts +4 -3
  224. package/dist/testSurface/surface/test/fields.js +10 -16
  225. package/dist/testSurface/surface/test/pageParts.js +13 -7
  226. package/dist/testSurface/surface/test/testPage.css +9 -2
  227. package/dist/testSurface/surface/useTestDocument.d.ts +1 -3
  228. package/dist/testSurface/surface/useTestDocument.js +110 -52
  229. package/dist/testSurface/surface/watchTestDocument.d.ts +15 -0
  230. package/dist/testSurface/surface/watchTestDocument.js +181 -0
  231. package/dist/testSurface/surfaceUrls.d.ts +1 -0
  232. package/dist/testSurface/surfaceUrls.js +4 -0
  233. package/dist/testSurface/useApi.d.ts +3 -0
  234. package/dist/transitions/addMetric.d.ts +1 -1
  235. package/dist/transitions/addMetric.js +5 -1
  236. package/dist/transitions/kernel.d.ts +2 -0
  237. package/dist/transitions/kernel.js +1 -1
  238. package/dist/transitions/pageAddress.d.ts +6 -0
  239. package/dist/transitions/pageAddress.js +71 -0
  240. package/dist/transitions/pageVersions.d.ts +1 -1
  241. package/dist/transitions/preflightData.js +10 -2
  242. package/dist/transitions/start.d.ts +1 -1
  243. package/dist/transitions/start.js +8 -5
  244. package/dist/types/armKey.d.ts +2 -0
  245. package/dist/types/armKey.js +1 -0
  246. package/dist/types/contracts.d.ts +11 -1
  247. package/dist/types/endpoints.d.ts +38 -9
  248. package/dist/types/endpoints.js +1 -1
  249. package/dist/types/surface.d.ts +7 -9
  250. package/dist/ui/Dialog.d.ts +21 -2
  251. package/dist/ui/Dialog.js +101 -4
  252. package/dist/ui/Inputs.js +0 -1
  253. package/dist/ui/ui.css +5 -1
  254. package/package.json +2 -2
@@ -1,5 +1,5 @@
1
1
  import { contentLocaleURL } from '../../testSurface/contentLocaleURL.js';
2
- import { isPreflightResult, readPreflight, READINESS_REFRESH_MS } from '../../testSurface/readPreflight.js';
2
+ import { isPreflightResult, readPreflight } from '../../testSurface/readPreflight.js';
3
3
  import { classifyReadinessRead } from '../../testSurface/readinessRead.js';
4
4
  const cache = new Map();
5
5
  const latest = new Map();
@@ -180,12 +180,8 @@ export function placementReadError(api, id, contentLocale) {
180
180
  return cachedReadinessRead(api, id, contentLocale)?.message;
181
181
  }
182
182
  const notices = new WeakMap();
183
- const noticeDelay = ({ api, id, contentLocale, noticeSubscribers })=>{
184
- const read = cachedReadinessRead(api, id, contentLocale);
185
- if (read?.pollDelay && (read.failed || noticeSubscribers)) return read.pollDelay;
186
- return read?.answer?.document ? READINESS_REFRESH_MS : null;
187
- };
188
- export function watchPlacementNotice(api, id, doc, contentLocale, showingNotice = true) {
183
+ const noticeDelay = (api, id, contentLocale)=>cachedReadinessRead(api, id, contentLocale)?.pollDelay ?? null;
184
+ export function watchPlacementNotice(api, id, doc, contentLocale) {
189
185
  let session = notices.get(doc);
190
186
  if (!session) {
191
187
  const requests = new Map();
@@ -204,7 +200,7 @@ export function watchPlacementNotice(api, id, doc, contentLocale, showingNotice
204
200
  }
205
201
  const eligible = [
206
202
  ...created.requests.values()
207
- ].filter((request)=>!request.pending && noticeDelay(request) !== null);
203
+ ].filter((request)=>!request.pending && noticeDelay(request.api, request.id, request.contentLocale) !== null);
208
204
  if (doc.visibilityState !== 'visible' || !eligible.length) return;
209
205
  created.timer = setTimeout(()=>{
210
206
  created.timer = undefined;
@@ -214,7 +210,7 @@ export function watchPlacementNotice(api, id, doc, contentLocale, showingNotice
214
210
  request.pending = true;
215
211
  void refreshPlacements(request.api, request.id, request.contentLocale).then(()=>{
216
212
  request.pending = false;
217
- request.nextAt = Date.now() + (noticeDelay(request) ?? 0);
213
+ request.nextAt = Date.now() + (noticeDelay(request.api, request.id, request.contentLocale) ?? 0);
218
214
  if (notices.get(doc) === created) created.schedule();
219
215
  });
220
216
  }
@@ -222,7 +218,7 @@ export function watchPlacementNotice(api, id, doc, contentLocale, showingNotice
222
218
  }, Math.max(0, Math.min(...eligible.map((request)=>request.nextAt)) - Date.now()));
223
219
  };
224
220
  created.visibility = ()=>{
225
- for (const request of created.requests.values())request.nextAt = Date.now() + (noticeDelay(request) ?? 0);
221
+ for (const request of created.requests.values())request.nextAt = Date.now() + (noticeDelay(request.api, request.id, request.contentLocale) ?? 0);
226
222
  created.schedule();
227
223
  };
228
224
  session = created;
@@ -237,27 +233,23 @@ export function watchPlacementNotice(api, id, doc, contentLocale, showingNotice
237
233
  id,
238
234
  contentLocale,
239
235
  subscribers: 0,
240
- noticeSubscribers: 0,
241
- nextAt: 0,
236
+ nextAt: Date.now() + (noticeDelay(api, id, contentLocale) ?? 0),
242
237
  pending: false,
243
238
  release: ()=>{}
244
239
  };
245
240
  request.subscribers++;
246
- if (showingNotice) request.noticeSubscribers++;
247
- if (!existing || request.noticeSubscribers === 1 && showingNotice) request.nextAt = Date.now() + (noticeDelay(request) ?? 0);
248
241
  current.requests.set(key, request);
249
242
  if (!existing) request.release = subscribePlacements(api, id, ()=>{
250
243
  if (placementsPending(api, id, contentLocale)) return;
251
244
  // Manual/focus retries also reset the backoff after recovery.
252
- request.nextAt = Date.now() + (noticeDelay(request) ?? 0);
245
+ request.nextAt = Date.now() + (noticeDelay(api, id, contentLocale) ?? 0);
253
246
  current.schedule();
254
247
  }, contentLocale);
255
- current.schedule();
248
+ if (!existing || current.timer === undefined) current.schedule();
256
249
  let active = true;
257
250
  return ()=>{
258
251
  if (!active) return;
259
252
  active = false;
260
- if (showingNotice && --request.noticeSubscribers === 0) request.nextAt = Date.now() + (noticeDelay(request) ?? 0);
261
253
  if (--request.subscribers === 0) {
262
254
  current.removeRequest(key);
263
255
  request.release();
@@ -1,8 +1,5 @@
1
1
  import type { DocId } from '../../types/contracts.js';
2
- /** Payload Puck's built-in editor exposes no save callback through integrations.
3
- * Observe its completed same-origin page request. Custom editors and browsers
4
- * without Resource Timing still use the placement watcher.
5
- */
2
+ /** Listen for payload-puck 0.12.5+ save results through the DOM event. */
6
3
  export declare function usePageSaveReadiness(api: string, id: DocId | undefined, page: {
7
4
  collection: string;
8
5
  id: string;
@@ -1,29 +1,26 @@
1
1
  'use client';
2
2
  import { useEffect } from 'react';
3
3
  import { invalidatePlacements } from './placementsCache.js';
4
- /** Payload Puck's built-in editor exposes no save callback through integrations.
5
- * Observe its completed same-origin page request. Custom editors and browsers
6
- * without Resource Timing still use the placement watcher.
7
- */ export function usePageSaveReadiness(api, id, page, contentLocale) {
4
+ const PUCK_SAVE_EVENT = 'payload-puck:save';
5
+ /** Listen for payload-puck 0.12.5+ save results through the DOM event. */ export function usePageSaveReadiness(api, id, page, contentLocale) {
8
6
  const collection = page?.collection;
9
- const pageId = page?.id;
7
+ const pageId = page && String(page.id);
10
8
  useEffect(()=>{
11
- if (id === undefined || !collection || !pageId || !globalThis.PerformanceObserver?.supportedEntryTypes?.includes('resource')) return;
12
- const endpoint = new URL(`/api/puck/${encodeURIComponent(collection)}/${encodeURIComponent(pageId)}`, window.location.origin);
13
- const observer = new PerformanceObserver((entries)=>{
14
- const completed = entries.getEntriesByType('resource').some((entry)=>{
15
- const response = entry;
16
- const status = response.responseStatus;
17
- if (response.initiatorType !== 'fetch' || status && (status < 200 || status >= 300)) return false;
18
- const url = new URL(response.name);
19
- return url.origin === endpoint.origin && url.pathname === endpoint.pathname;
20
- });
21
- if (completed) invalidatePlacements(api, id, contentLocale);
22
- });
23
- observer.observe({
24
- type: 'resource'
25
- });
26
- return ()=>observer.disconnect();
9
+ if (id === undefined || !collection || !pageId) return;
10
+ const onSave = (event)=>{
11
+ if (!(event instanceof CustomEvent)) return;
12
+ const detail = event.detail;
13
+ if (!detail || typeof detail !== 'object') return;
14
+ const save = detail;
15
+ if (save.ok !== true || save.id !== pageId || save.collection !== undefined && save.collection !== collection) return;
16
+ if (save.operation !== 'save' && save.operation !== 'publish' && save.operation !== 'unpublish') return;
17
+ if (typeof save.apiEndpoint !== 'string' || save.locale !== undefined && typeof save.locale !== 'string') return;
18
+ if (save.status !== undefined && save.status !== 'draft' && save.status !== 'published') return;
19
+ if (save.error !== undefined) return;
20
+ invalidatePlacements(api, id, contentLocale);
21
+ };
22
+ window.addEventListener(PUCK_SAVE_EVENT, onSave);
23
+ return ()=>window.removeEventListener(PUCK_SAVE_EVENT, onSave);
27
24
  }, [
28
25
  api,
29
26
  id,
@@ -1,3 +1,3 @@
1
1
  import type { DocId } from '../../types/contracts.js';
2
- /** Visible guidance refreshes sooner than idle status. */
3
- export declare function usePlacementNotice(api: string, id: DocId | undefined, message: string | undefined, contentLocale?: string, watchStatus?: boolean): void;
2
+ /** Subscribe only while save/publish guidance or a retryable placement failure is visible. */
3
+ export declare function usePlacementNotice(api: string, id: DocId | undefined, message: string | undefined, contentLocale?: string): void;
@@ -1,16 +1,15 @@
1
1
  'use client';
2
2
  import { useEffect } from 'react';
3
3
  import { watchPlacementNotice } from './placementsCache.js';
4
- /** Visible guidance refreshes sooner than idle status. */ export function usePlacementNotice(api, id, message, contentLocale, watchStatus = false) {
4
+ /** Subscribe only while save/publish guidance or a retryable placement failure is visible. */ export function usePlacementNotice(api, id, message, contentLocale) {
5
5
  const showing = message !== undefined && id !== undefined;
6
6
  useEffect(()=>{
7
- if (id === undefined || !showing && !watchStatus) return;
8
- return watchPlacementNotice(api, id, document, contentLocale, showing);
7
+ if (id === undefined || !showing) return;
8
+ return watchPlacementNotice(api, id, document, contentLocale);
9
9
  }, [
10
10
  api,
11
11
  id,
12
12
  showing,
13
- contentLocale,
14
- watchStatus
13
+ contentLocale
15
14
  ]);
16
15
  }
@@ -1,4 +1,4 @@
1
- const innerLabel = (inner)=>inner ? `“${inner}”` : 'An Experiment block with no test chosen';
1
+ const innerLabel = (inner)=>inner ? `“${inner}”` : 'A Test block with no test chosen';
2
2
  const outerLabel = (outer)=>outer ? `“${outer}”` : 'another test';
3
3
  const moveLabel = (inner)=>inner ? `“${inner}”` : 'that block';
4
4
  const location = (outer, inner)=>`${innerLabel(inner)} is inside a version of ${outerLabel(outer)}.`;
@@ -8,7 +8,7 @@ export const nestedTestCopy = {
8
8
  start,
9
9
  readinessFallback,
10
10
  editor: (outer, inner)=>inner ? start(outer, inner) : `This test is inside a version of ${outerLabel(outer)}. A test can't go inside another test's version. Move this test out of that version before you start either test.`,
11
- publish: (outer, inner)=>`${location(outer, inner)} A test can't go inside another test's version, so this page can't be published. Move ${moveLabel(inner)} out of that version, then publish.`,
11
+ publish: (outer, inner)=>`${location(outer, inner)} A test can't go inside another test's version, so this page can't be published. Move ${moveLabel(inner)} out of that version to publish the page.`,
12
12
  hidden: (outer)=>`This test is inside a version of ${outerLabel(outer)}. It is hidden, so nothing is blocked now. If you show it again, the page can't be published until you move it out of that version.`,
13
13
  readiness: (detail)=>(Array.isArray(detail) && detail.length ? detail : [
14
14
  {}
@@ -1,5 +1,5 @@
1
1
  import type { ComponentConfig } from '@puckeditor/core';
2
2
  import { type ExperimentSlotProps } from '../types/puck.js';
3
- export declare const experimentSlotLabel = "Experiment block";
3
+ export declare const experimentSlotLabel = "Test block";
4
4
  export declare const experimentSlotFields: NonNullable<ComponentConfig<ExperimentSlotProps>['fields']>;
5
5
  export declare const experimentSlotDefaultProps: NonNullable<ComponentConfig<ExperimentSlotProps>['defaultProps']>;
@@ -1,7 +1,7 @@
1
1
  import { EXPERIMENT_SLOT_TYPE } from '../types/puck.js';
2
2
  import { createExperimentSlotField } from './experimentSlotField.js';
3
3
  import { slotLabels } from './copy.js';
4
- export const experimentSlotLabel = 'Experiment block';
4
+ export const experimentSlotLabel = 'Test block';
5
5
  export const experimentSlotFields = {
6
6
  experiment: createExperimentSlotField(),
7
7
  // Puck 0.24's defaultSlots prepends each slot, reversing declaration order in the outline.
@@ -60,6 +60,8 @@ export interface MetricUnitData {
60
60
  }
61
61
  export type AnalysePhaseInput = {
62
62
  phase: AnalysisPhase;
63
+ /** The test's control can be absent from the two rollout arms. */
64
+ controlLabel?: string;
63
65
  /** The runner logs failures; injecting this keeps analysis free of I/O imports. */
64
66
  onMetricError?: (error: unknown, metricId: DocId) => void;
65
67
  status: 'running' | 'stopped' | 'decided';
@@ -7,7 +7,7 @@ import { guardrailStatus } from './guardrails.js';
7
7
  import { remainingPower } from './power.js';
8
8
  import { assembleSnapshot, jsonInterval } from './snapshot.js';
9
9
  import { exposureSrm } from './srm.js';
10
- import { computeVerdict } from './verdict.js';
10
+ import { computeVerdict, verdictGroupLabel } from './verdict.js';
11
11
  const severity = {
12
12
  ok: 0,
13
13
  insufficient: 1,
@@ -341,7 +341,7 @@ const severity = {
341
341
  guardrails: verdictGuardrails,
342
342
  power,
343
343
  plannedDurationPassed: to - from >= analysis.plannedDurationDays * 86_400_000,
344
- originalLabel: phase.arms.find((arm)=>arm.kind === 'control')?.label ?? 'Original',
344
+ originalLabel: verdictGroupLabel('control', input.controlLabel ?? phase.arms.find((arm)=>arm.kind === 'control')?.label),
345
345
  controlArm: baselineArm.key
346
346
  };
347
347
  const verdictInput = rollout ? {
@@ -66,20 +66,20 @@ interface VerdictInputFields {
66
66
  status: 'ok' | 'warning' | 'insufficient';
67
67
  worstArmLabel?: string;
68
68
  })>;
69
- /** Additional days needed, rounded up by CORE-15a: 0 = already enough data,
70
- * null = unknown. Infeasible or >90 days uses the long-duration copy; positive
71
- * days use an estimate; 0/null with feasible=true runs to the planned end date. */
69
+ /** Additional days needed: 0 = already enough data, null = unknown.
70
+ * Infeasible or >90 days uses the long-duration copy. */
72
71
  power: {
73
72
  daysRemaining: number | null;
74
73
  feasible: boolean;
75
74
  };
76
75
  plannedDurationPassed: boolean;
77
- /** Reserved for future use; "the Original" remains literal UI vocabulary. */
76
+ /** The frozen label of the test's control version, including for rollouts. */
78
77
  originalLabel: string;
79
78
  controlArm: string;
80
79
  }
81
80
  /** Resolve a stored group label without exposing an internal key in verdict copy. */
82
81
  export declare function verdictGroupLabel(key: string, label?: string): string;
82
+ export declare function isLongDuration({ feasible, daysRemaining }: VerdictInput['power']): boolean;
83
83
  /** Apply spec §8.5 in order to already-computed results; no inference is performed here. */
84
84
  export declare function computeVerdict(input: VerdictInput): Snapshot['verdict'];
85
85
  export {};
@@ -24,8 +24,12 @@ function chance(value) {
24
24
  /** Resolve a stored group label without exposing an internal key in verdict copy. */ export function verdictGroupLabel(key, label = '') {
25
25
  return label.trim() || (Object.hasOwn(ARM_LABELS, key) ? ARM_LABELS[key] : 'This group');
26
26
  }
27
+ export function isLongDuration({ feasible, daysRemaining }) {
28
+ return !feasible || daysRemaining !== null && daysRemaining > 90;
29
+ }
27
30
  /** Apply spec §8.5 in order to already-computed results; no inference is performed here. */ export function computeVerdict(input) {
28
31
  const rollout = input.phaseKind === 'rollout';
32
+ const controlLabel = input.originalLabel;
29
33
  const make = (row, code, finding, action, detail, recommendedArm, line, worstArm)=>({
30
34
  row,
31
35
  code,
@@ -61,7 +65,7 @@ function chance(value) {
61
65
  null,
62
66
  null
63
67
  ];
64
- return make('R3', 'rollout-readout', `Since shipping ${winner}: ${percent(lift)} vs the holdout (CI ${percent(ci[0])} to ${percent(ci[1])}).`, null, 'This describes the shipped version compared with people still seeing the Original.', null, guardrailLine(input));
68
+ return make('R3', 'rollout-readout', `Since shipping ${winner}: ${percent(lift)} vs the holdout (CI ${percent(ci[0])} to ${percent(ci[1])}).`, null, `This describes the shipped version compared with people still seeing ${controlLabel}.`, null, guardrailLine(input));
65
69
  }
66
70
  const failing = input.guardrails.find((item)=>item.status === 'failing');
67
71
  if (failing) return make(3, 'guardrail-failing', `Stop: ${failing.worstArmLabel} harms ${failing.name}.`, null, 'An outcome that must stay safe has become worse.', input.controlArm, undefined, failing.worstArm);
@@ -69,7 +73,7 @@ function chance(value) {
69
73
  const smallest = compared.find((item)=>item.n === minimum);
70
74
  const fewest = converters.find((item)=>item.converters === minimumConverters);
71
75
  const groupLabel = (group)=>{
72
- if (!group || group.kind === 'control') return 'Original';
76
+ if (!group || group.kind === 'control') return controlLabel;
73
77
  const label = input.exposures.perArm.find((item)=>item.arm === group.arm)?.label ?? input.primary.comparisons.find((item)=>item.arm === group.arm)?.label;
74
78
  return verdictGroupLabel(group.arm, label);
75
79
  };
@@ -88,19 +92,18 @@ function chance(value) {
88
92
  ...better
89
93
  ].sort((a, b)=>direction * (b.lift - a.lift))[0];
90
94
  const worst = worse[0];
91
- if (variants.length > 0 && worse.length === variants.length) return make(5, 'original-better', 'The Original is better.', 'Decide for the Original.', 'Every tested alternative performed worse.', input.controlArm);
92
- if (worst && !best) return make(6, 'worse-none-better', `${labels(worse)} ${worse.length === 1 ? 'is' : 'are'} worse; no variant is better.`, `Decide for the Original or restart without ${worse.length === 1 ? 'it' : 'them'}.`, 'At least one alternative performed worse and none improved the main outcome.', input.controlArm, undefined, worst.arm);
95
+ if (variants.length > 0 && worse.length === variants.length) return make(5, 'original-better', `${controlLabel} is better.`, `Decide for ${controlLabel}.`, 'Every tested alternative performed worse.', input.controlArm);
96
+ if (worst && !best) return make(6, 'worse-none-better', `${labels(worse)} ${worse.length === 1 ? 'is' : 'are'} worse; no variant is better.`, `Decide for ${controlLabel} or restart without ${worse.length === 1 ? 'it' : 'them'}.`, 'At least one alternative performed worse and none improved the main outcome.', input.controlArm, undefined, worst.arm);
93
97
  if (best && !worst) {
94
- const finding = better.length >= 2 ? `${better.length === 2 ? 'Both' : `All ${better.length} variants`} beat the Original; not tested against each other — ${best.label} has the larger improvement.` : input.method === 'bayesian' ? `${best.label} is very likely better${chance(best.chanceToWin)}.` : `${best.label} is statistically better: ${percent(best.lift)} (CI ${percent(best.ci[0])} to ${percent(best.ci[1])}).`;
95
- return make(7, 'winner', finding, null, 'The main outcome improved compared with the Original.', best.arm, guardrailLine(input));
98
+ const finding = better.length >= 2 ? `${better.length === 2 ? 'Both' : `All ${better.length} variants`} beat ${controlLabel}; not tested against each other — ${best.label} has the larger improvement.` : input.method === 'bayesian' ? `${best.label} is very likely better${chance(best.chanceToWin)}.` : `${best.label} is statistically better: ${percent(best.lift)} (CI ${percent(best.ci[0])} to ${percent(best.ci[1])}).`;
99
+ return make(7, 'winner', finding, null, `The main outcome improved compared with ${controlLabel}.`, best.arm, guardrailLine(input));
96
100
  }
97
101
  if (best && worst) return make(8, 'mixed', `Mixed: ${labels(better)} better, ${labels(worse)} worse.`, 'Review before deciding.', 'The tested alternatives moved the main outcome in different directions.', best.arm, undefined, worst.arm);
98
102
  if (input.status === 'running' && !input.plannedDurationPassed) {
99
- if (input.power.feasible === false || input.power.daysRemaining !== null && input.power.daysRemaining > 90) {
100
- return make(9, 'keep-running', 'A clear answer would take more than 90 days at this traffic.', 'Consider a bigger change or a different metric.', 'Current traffic is too low for a timely answer.', null);
103
+ if (isLongDuration(input.power)) {
104
+ return make(9, 'keep-running', RESULTS_COPY.infeasible, 'Consider a bigger change or a different metric.', 'Current traffic is too low for a timely answer.', null);
101
105
  }
102
- const action = input.power.daysRemaining !== null && input.power.daysRemaining >= 1 ? `Keep running about ${Math.ceil(input.power.daysRemaining)} days.` : 'Keep running to the planned end date.';
103
- return make(9, 'keep-running', 'No clear winner yet.', action, 'The current results do not yet distinguish the tested versions.', null);
106
+ return make(9, 'keep-running', 'No clear winner yet.', RESULTS_COPY.plannedEnd, 'The current results do not yet distinguish the tested versions.', null);
104
107
  }
105
108
  return make(10, 'no-difference', 'No detectable difference at this size.', null, 'The data collected did not show a clear improvement or decline.', input.controlArm);
106
109
  }
@@ -315,7 +315,8 @@ async function analyseCandidate(exec, candidate, options, now, deadline, unavail
315
315
  armMismatch: await armMismatchCount(exec, query),
316
316
  identityConflictShare: userIds.length ? identityConflicts.size / userIds.length : 0,
317
317
  ...phase.phaseKind === 'rollout' ? {
318
- winnerArm: phase.arms.find((arm)=>arm.kind !== 'holdout').key
318
+ winnerArm: phase.arms.find((arm)=>arm.kind !== 'holdout').key,
319
+ controlLabel: candidate.testArms.find((arm)=>arm.kind === 'control')?.label
319
320
  } : {}
320
321
  });
321
322
  if (rapidActivity) snapshot.health = [
@@ -1,6 +1,7 @@
1
1
  import type { DocId } from '../types/contracts.js';
2
2
  import type { PreflightResult } from '../types/endpoints.js';
3
- export declare function PreviewLinks({ experimentId, placements, arms, flagPoint, apiRoute }: {
3
+ export declare function PreviewLinks({ experimentId, placements, arms, flagPoint, apiRoute, showEditLinks }: {
4
+ showEditLinks?: boolean;
4
5
  apiRoute: string;
5
6
  flagPoint?: string;
6
7
  experimentId: DocId;
@@ -9,7 +9,7 @@ import { placementLabel } from './placementLabel.js';
9
9
  import { TEST_PAGE } from './copy/testPage.js';
10
10
  import { API_MESSAGES, refusalMessage } from './copy/common.js';
11
11
  import { actionablePreviewPages } from './previewLinks.model.js';
12
- export function PreviewLinks({ experimentId, placements, arms, flagPoint, apiRoute }) {
12
+ export function PreviewLinks({ experimentId, placements, arms, flagPoint, apiRoute, showEditLinks = true }) {
13
13
  const api = useApi(apiRoute);
14
14
  const inFlight = useRef(false);
15
15
  const [busy, setBusy] = useState(false);
@@ -86,8 +86,8 @@ export function PreviewLinks({ experimentId, placements, arms, flagPoint, apiRou
86
86
  arm.label?.trim() || armLabel(arm.key)
87
87
  ]
88
88
  }, arm.key)) : null,
89
- placement.editorUrl ? /*#__PURE__*/ _jsx(Button, {
90
- variant: "link",
89
+ showEditLinks && placement.editorUrl ? /*#__PURE__*/ _jsx(Button, {
90
+ variant: "secondary",
91
91
  size: "sm",
92
92
  href: placement.editorUrl,
93
93
  "aria-label": pages.length > 1 ? `${TEST_PAGE.editOnPage}: ${placementLabel(placement)}` : undefined,
@@ -1,14 +1,17 @@
1
1
  import type { DocId } from '../../types/contracts.js';
2
- import type { PreflightResult } from '../../types/endpoints.js';
3
- import type { ActionGroup } from './actions.model.js';
4
- export declare function DecideDialog({ id, phase, arms, checks, unavailable, onClose, apiRoute, onSuccess, onRefusal }: {
2
+ import type { ResultsResponse, PreflightResult } from '../../types/endpoints.js';
3
+ import { type ActionGroup } from './actions.model.js';
4
+ export declare function DecideDialog({ id, name, phase, arms, results, checks, unavailable, pending, onClose, apiRoute, onSuccess, onRefusal }: {
5
5
  apiRoute: string;
6
+ name?: string;
6
7
  phase?: number;
7
8
  onRefusal?: () => void;
8
9
  unavailable?: boolean;
10
+ pending?: boolean;
9
11
  onSuccess?: (doc?: Record<string, unknown>) => void;
10
12
  id: DocId;
11
- arms: readonly ActionGroup[];
13
+ arms?: readonly ActionGroup[];
14
+ results?: ResultsResponse;
12
15
  checks?: PreflightResult['checks'];
13
16
  onClose: () => void;
14
17
  }): import("react").JSX.Element;
@@ -6,32 +6,43 @@ import { Select, Textarea, TextInput } from '../../ui/Inputs.js';
6
6
  import { unsupportedContentCopy } from '../copy/readiness.js';
7
7
  import { useApi } from '../useApi.js';
8
8
  import { reloadPage } from '../reload.js';
9
- import { RESULTS_COPY } from '../copy/results.js';
10
- import { ACTIONS_COPY as C, decideCopy } from '../copy/actions.js';
9
+ import { Banner } from '../../ui/Banner.js';
10
+ import { ACTIONS_COPY as C, actionTitle, decideCopy } from '../copy/actions.js';
11
+ import { READINESS_COPY } from '../copy/readiness.js';
12
+ import { actionGroupLabel, isDestructiveAction } from './actions.model.js';
11
13
  import { decideState } from './decide.model.js';
12
- import { Dialog } from '../../ui/Dialog.js';
13
- export function DecideDialog({ id, phase, arms, checks = [], unavailable, onClose, apiRoute, onSuccess, onRefusal }) {
14
+ import { ConfirmDialog } from '../../ui/Dialog.js';
15
+ import { notifyTestDocument } from '../surface/watchTestDocument.js';
16
+ export function DecideDialog({ id, name, phase, arms, results, checks = [], unavailable, pending, onClose, apiRoute, onSuccess, onRefusal }) {
14
17
  const api = useApi(apiRoute);
15
- const [snapshot, setSnapshot] = useState(null);
18
+ const [snapshot, setSnapshot] = useState(results?.snapshot ?? null);
19
+ const [roundArms, setRoundArms] = useState();
20
+ const frozenArms = roundArms ?? arms;
16
21
  const [chosen, setChosenArm] = useState();
17
22
  const chosenArm = chosen === undefined ? snapshot?.verdict.recommendedArm ?? null : chosen;
18
23
  const [note, setNote] = useState('');
19
24
  const [typed, setTyped] = useState('');
20
- const [loading, setLoading] = useState(true);
25
+ const [loading, setLoading] = useState(!results);
21
26
  const [busy, setBusy] = useState(false);
22
27
  const inFlight = useRef(false);
23
28
  const refreshing = useRef(false);
24
29
  const [error, setError] = useState(null);
25
30
  const [loadFailed, setLoadFailed] = useState(false);
26
- const statusRefused = error?.code === 'round-changed' || error?.code === 'invalid-status';
31
+ const accessRefused = !!error && [
32
+ 401,
33
+ 403,
34
+ 404
35
+ ].includes(error.status);
36
+ const statusRefused = accessRefused || error?.code === 'round-changed' || error?.code === 'invalid-status';
27
37
  const state = decideState({
28
38
  snapshot,
29
- arms,
39
+ arms: frozenArms ?? [],
30
40
  chosenArm,
31
41
  note,
32
42
  typed
33
43
  });
34
44
  useEffect(()=>{
45
+ if (results) return;
35
46
  let current = true;
36
47
  void api.results(id, {
37
48
  phase
@@ -40,6 +51,7 @@ export function DecideDialog({ id, phase, arms, checks = [], unavailable, onClos
40
51
  if (result.ok) {
41
52
  const next = result.data?.snapshot ?? null;
42
53
  setSnapshot(next);
54
+ setRoundArms(result.data?.phases?.find((round)=>round.phase === phase && round.phaseKind === 'test')?.arms);
43
55
  } else {
44
56
  setError(result);
45
57
  setLoadFailed(true);
@@ -52,7 +64,8 @@ export function DecideDialog({ id, phase, arms, checks = [], unavailable, onClos
52
64
  }, [
53
65
  api,
54
66
  id,
55
- phase
67
+ phase,
68
+ results
56
69
  ]);
57
70
  async function refresh() {
58
71
  if (refreshing.current) return;
@@ -65,6 +78,7 @@ export function DecideDialog({ id, phase, arms, checks = [], unavailable, onClos
65
78
  setLoading(false);
66
79
  if (result.ok) {
67
80
  setSnapshot(result.data?.snapshot ?? null);
81
+ setRoundArms(result.data?.phases?.find((round)=>round.phase === phase && round.phaseKind === 'test')?.arms);
68
82
  setLoadFailed(false);
69
83
  } else {
70
84
  setSnapshot(null);
@@ -73,7 +87,7 @@ export function DecideDialog({ id, phase, arms, checks = [], unavailable, onClos
73
87
  }
74
88
  }
75
89
  async function submit() {
76
- if (unavailable || statusRefused || inFlight.current || loading || busy || !state.canSubmit || loadFailed) return;
90
+ if (unavailable || pending || statusRefused || inFlight.current || loading || busy || !state.canSubmit || loadFailed) return;
77
91
  inFlight.current = true;
78
92
  setChosenArm(chosenArm);
79
93
  setBusy(true);
@@ -84,36 +98,64 @@ export function DecideDialog({ id, phase, arms, checks = [], unavailable, onClos
84
98
  });
85
99
  if (result.ok) {
86
100
  if (onSuccess) onSuccess(result.data?.doc);
87
- else reloadPage();
101
+ else {
102
+ notifyTestDocument(apiRoute, id);
103
+ reloadPage();
104
+ }
88
105
  return;
89
- } else {
90
- setError(result);
91
- if (result.code === 'confirmation-required') {
92
- await refresh();
93
- } else if (result.status === 409 || result.status === 403 || result.status === 401 || result.status === 404 || result.code === 'invalid-status') onRefusal?.();
94
106
  }
107
+ setError(result);
108
+ if (result.code === 'confirmation-required') {
109
+ await refresh();
110
+ } else if (result.status === 409 || result.code === 'invalid-status') onRefusal?.();
95
111
  inFlight.current = false;
96
112
  setBusy(false);
97
113
  }
98
- const enabled = !unavailable && !statusRefused && !busy && !loading && !loadFailed && state.canSubmit;
114
+ const enabled = !unavailable && !pending && !statusRefused && !busy && !loading && !loadFailed && state.canSubmit;
115
+ const noEvidence = !loading && !loadFailed && state.noEvidence;
116
+ const control = actionGroupLabel('control', frozenArms?.find((arm)=>arm.key === 'control')?.label);
99
117
  const label = state.options.find((option)=>option.value === chosenArm)?.label;
100
- return /*#__PURE__*/ _jsxs(Dialog, {
101
- open: true,
102
- dismissible: !busy,
103
- initialFocus: "cancel",
104
- title: C.decide,
118
+ const noteRequired = state.guarded && Boolean(label);
119
+ return /*#__PURE__*/ _jsxs(ConfirmDialog, {
120
+ title: name ? actionTitle(C.titleLead.decide, name) : C.decide,
121
+ description: C.decideBody,
105
122
  onClose: ()=>{
106
- if (!busy) onClose();
123
+ onClose();
124
+ if (accessRefused) onRefusal?.();
107
125
  },
126
+ busy: busy,
127
+ busyLabel: READINESS_COPY.changing,
128
+ cancelLabel: C.cancel,
129
+ error: error?.message ?? (unavailable ? C.decisionUnavailable : !loading && !frozenArms ? C.decideRoundMissing : null),
130
+ confirm: {
131
+ label: noEvidence ? C.decideAnyway : C.decide,
132
+ disabled: !enabled,
133
+ destructive: isDestructiveAction('decide'),
134
+ onClick: submit
135
+ },
136
+ secondaryAction: !unavailable && error?.retryable ? /*#__PURE__*/ _jsx(Button, {
137
+ disabled: busy || pending || loading || !loadFailed && !state.canSubmit,
138
+ onClick: ()=>{
139
+ if (loadFailed) {
140
+ setError(null);
141
+ void refresh();
142
+ } else void submit();
143
+ },
144
+ children: C.retry
145
+ }) : null,
108
146
  children: [
109
147
  loading ? /*#__PURE__*/ _jsx("p", {
110
148
  role: "status",
111
149
  children: C.loading
112
150
  }) : null,
151
+ noEvidence ? /*#__PURE__*/ _jsx(Banner, {
152
+ tone: "warning",
153
+ children: C.noEvidence
154
+ }) : null,
113
155
  /*#__PURE__*/ _jsxs(Select, {
114
156
  id: "xp-winner",
115
157
  name: "xp-winner",
116
- label: C.group,
158
+ label: C.winningVersion,
117
159
  value: chosenArm ?? '',
118
160
  disabled: busy || loading,
119
161
  required: true,
@@ -124,7 +166,7 @@ export function DecideDialog({ id, phase, arms, checks = [], unavailable, onClos
124
166
  children: [
125
167
  /*#__PURE__*/ _jsx("option", {
126
168
  value: "",
127
- children: RESULTS_COPY.chooseGroup
169
+ children: C.chooseVersion
128
170
  }),
129
171
  state.options.map((option)=>/*#__PURE__*/ _jsx("option", {
130
172
  value: option.value,
@@ -133,7 +175,7 @@ export function DecideDialog({ id, phase, arms, checks = [], unavailable, onClos
133
175
  ]
134
176
  }),
135
177
  label ? /*#__PURE__*/ _jsx("p", {
136
- children: decideCopy(label, arms.some((group)=>group.key === 'holdout'), chosenArm === 'control')
178
+ children: decideCopy(label, !!frozenArms?.some((group)=>group.key === 'holdout'), control, chosenArm === 'control')
137
179
  }) : null,
138
180
  checks.filter((check)=>check.code === 'make-content-unsupported' && check.warning).map((check)=>/*#__PURE__*/ _jsx("p", {
139
181
  children: unsupportedContentCopy(typeof check.detail === 'string' ? check.detail : 'This page')
@@ -143,9 +185,9 @@ export function DecideDialog({ id, phase, arms, checks = [], unavailable, onClos
143
185
  }) : null,
144
186
  /*#__PURE__*/ _jsx(Textarea, {
145
187
  id: "xp-note",
146
- label: C.note,
188
+ label: noteRequired ? C.requiredNote : C.note,
147
189
  value: note,
148
- required: state.guarded,
190
+ required: noteRequired,
149
191
  readOnly: busy,
150
192
  onChange: (event)=>{
151
193
  if (chosenArm !== null) setChosenArm(chosenArm);
@@ -174,37 +216,7 @@ export function DecideDialog({ id, phase, arms, checks = [], unavailable, onClos
174
216
  }
175
217
  })
176
218
  ]
177
- }) : null,
178
- error ? /*#__PURE__*/ _jsx("p", {
179
- role: "alert",
180
- children: error.message
181
- }) : unavailable ? /*#__PURE__*/ _jsx("p", {
182
- role: "alert",
183
- children: C.decisionUnavailable
184
- }) : null,
185
- /*#__PURE__*/ _jsx(Button, {
186
- disabled: !enabled,
187
- onClick: ()=>{
188
- void submit();
189
- },
190
- children: C.decide
191
- }),
192
- !unavailable && error?.retryable ? /*#__PURE__*/ _jsx(Button, {
193
- disabled: busy || loading || !loadFailed && !state.canSubmit,
194
- onClick: ()=>{
195
- if (loadFailed) {
196
- setError(null);
197
- void refresh();
198
- } else void submit();
199
- },
200
- children: C.retry
201
- }) : null,
202
- /*#__PURE__*/ _jsx(Button, {
203
- "data-dialog-cancel": true,
204
- disabled: busy,
205
- onClick: onClose,
206
- children: C.cancel
207
- })
219
+ }) : null
208
220
  ]
209
221
  });
210
222
  }