@1agh/maude 2.0.2 → 2.0.4

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 (154) hide show
  1. package/README.md +6 -5
  2. package/apps/studio/access/request.ts +0 -1
  3. package/apps/studio/acp/adapter-stderr.ts +43 -13
  4. package/apps/studio/acp/background-tasks.ts +155 -0
  5. package/apps/studio/acp/bridge.ts +44 -5
  6. package/apps/studio/acp/connected-fact.ts +15 -4
  7. package/apps/studio/acp/index.ts +14 -5
  8. package/apps/studio/actions/agents.ts +5 -0
  9. package/apps/studio/actions/defs/view.ts +12 -0
  10. package/apps/studio/actions.manifest.json +13 -1
  11. package/apps/studio/actions.parity.json +7 -1
  12. package/apps/studio/api.ts +31 -24
  13. package/apps/studio/asset-placeholder.tsx +157 -62
  14. package/apps/studio/bin/_png-playwright.mjs +10 -1
  15. package/apps/studio/bin/_pw-launch.mjs +14 -0
  16. package/apps/studio/bin/_thumbs-playwright.mjs +4 -1
  17. package/apps/studio/boot-progress.ts +31 -0
  18. package/apps/studio/bridge/dgn-protocol.ts +34 -4
  19. package/apps/studio/canvas-build-sandbox.ts +275 -42
  20. package/apps/studio/canvas-build-worker.ts +10 -0
  21. package/apps/studio/canvas-create.ts +24 -0
  22. package/apps/studio/canvas-module-cache.ts +93 -0
  23. package/apps/studio/canvas-source/errors.ts +39 -0
  24. package/apps/studio/canvas-source/waiting.ts +290 -0
  25. package/apps/studio/client/actions/shell-key-handlers.js +5 -0
  26. package/apps/studio/client/app.jsx +22 -9
  27. package/apps/studio/client/github.js +23 -3
  28. package/apps/studio/client/home/home-api.js +30 -19
  29. package/apps/studio/client/hooks/use-git-actions.jsx +2 -1
  30. package/apps/studio/client/hooks/use-shell-core.jsx +3 -0
  31. package/apps/studio/client/hooks/use-tabs.jsx +64 -35
  32. package/apps/studio/client/index-loader.ts +23 -3
  33. package/apps/studio/client/panels/ChatPanel.jsx +22 -37
  34. package/apps/studio/client/panels/DiffView.jsx +314 -248
  35. package/apps/studio/client/panels/TeamProjects.jsx +119 -69
  36. package/apps/studio/client/panels/acp-runtime.js +25 -0
  37. package/apps/studio/client/panels/chat-finish.js +66 -0
  38. package/apps/studio/client/shell/frame-cap.js +53 -0
  39. package/apps/studio/client/shell/viewport.jsx +9 -0
  40. package/apps/studio/client/styles/_index.css +2 -0
  41. package/apps/studio/client/tree/tree.jsx +48 -21
  42. package/apps/studio/client/v2/ai/BackgroundStrip.jsx +120 -0
  43. package/apps/studio/client/v2/ai/StoppedDivider.jsx +2 -1
  44. package/apps/studio/client/v2/ai/ai-run.css +87 -3
  45. package/apps/studio/client/v2/ai/background-model.js +113 -0
  46. package/apps/studio/client/v2/ai/needs-you-store.js +2 -1
  47. package/apps/studio/client/v2/ai/run-api.js +7 -3
  48. package/apps/studio/client/v2/ai/runs-store.js +2 -1
  49. package/apps/studio/client/v2/annotations/vote-store.js +11 -5
  50. package/apps/studio/client/v2/assets/asset-state-lane.js +176 -8
  51. package/apps/studio/client/v2/assets/assets-bus.js +10 -8
  52. package/apps/studio/client/v2/assets/browse-view.jsx +2 -0
  53. package/apps/studio/client/v2/assets/ds-library-view.jsx +47 -0
  54. package/apps/studio/client/v2/assets/missing-frame.jsx +8 -4
  55. package/apps/studio/client/v2/assets/spotlight-model.js +75 -0
  56. package/apps/studio/client/v2/assets/spotlight.css +153 -0
  57. package/apps/studio/client/v2/assets/spotlight.jsx +199 -0
  58. package/apps/studio/client/v2/assets/tile-menu.jsx +3 -1
  59. package/apps/studio/client/v2/assets/tile.jsx +3 -0
  60. package/apps/studio/client/v2/assets/use-assets.js +2 -1
  61. package/apps/studio/client/v2/canvases/canvases-panel.jsx +13 -2
  62. package/apps/studio/client/v2/canvases/covers.js +11 -5
  63. package/apps/studio/client/v2/canvases/folder-ask.js +139 -0
  64. package/apps/studio/client/v2/canvases/folder-dialogs.jsx +150 -0
  65. package/apps/studio/client/v2/canvases/trash-canvas.js +10 -2
  66. package/apps/studio/client/v2/canvases/trash-queue.js +152 -0
  67. package/apps/studio/client/v2/canvases/use-canvas-index.js +42 -18
  68. package/apps/studio/client/v2/canvases/use-pins.js +2 -1
  69. package/apps/studio/client/v2/code/canvas-error-card.jsx +70 -5
  70. package/apps/studio/client/v2/code/canvas-waiting-card.jsx +128 -0
  71. package/apps/studio/client/v2/code/canvas-waiting.js +164 -0
  72. package/apps/studio/client/v2/code/code.css +67 -0
  73. package/apps/studio/client/v2/code/use-canvas-source.js +19 -4
  74. package/apps/studio/client/v2/create/NameDialog.jsx +4 -2
  75. package/apps/studio/client/v2/create/name-dialog.css +10 -0
  76. package/apps/studio/client/v2/ds/advanced-host.jsx +5 -2
  77. package/apps/studio/client/v2/ds/make-host.jsx +5 -2
  78. package/apps/studio/client/v2/ds/off-system-host.jsx +5 -2
  79. package/apps/studio/client/v2/ds/truth-host.jsx +5 -2
  80. package/apps/studio/client/v2/empty/arriving.jsx +29 -12
  81. package/apps/studio/client/v2/empty/empty-host.jsx +8 -2
  82. package/apps/studio/client/v2/empty/not-local.jsx +31 -1
  83. package/apps/studio/client/v2/empty/use-empty-canvas.js +10 -1
  84. package/apps/studio/client/v2/export/last-finished.js +2 -1
  85. package/apps/studio/client/v2/export/native-save.js +44 -0
  86. package/apps/studio/client/v2/history/git-model.js +18 -4
  87. package/apps/studio/client/v2/history/git-parts.jsx +60 -42
  88. package/apps/studio/client/v2/history/history.css +6 -0
  89. package/apps/studio/client/v2/left-panel/assets-panel.jsx +87 -10
  90. package/apps/studio/client/v2/left-panel/use-trash.js +2 -1
  91. package/apps/studio/client/v2/onboarding/AdvancedSheets.jsx +100 -33
  92. package/apps/studio/client/v2/onboarding/HubSheet.jsx +51 -83
  93. package/apps/studio/client/v2/onboarding/onboarding-model.js +10 -6
  94. package/apps/studio/client/v2/present/order-notes-artboards.js +2 -1
  95. package/apps/studio/client/v2/search/search-recent.js +3 -1
  96. package/apps/studio/client/v2/search/search-remote.js +6 -4
  97. package/apps/studio/client/v2/settings/connections-model.js +1 -1
  98. package/apps/studio/client/v2/shell/menu-runner.js +1 -0
  99. package/apps/studio/client/v2/shell/occlusion-insets.js +14 -2
  100. package/apps/studio/client/v2/shell/recovery-store.js +2 -1
  101. package/apps/studio/client/v2/shell/served-routes.js +120 -0
  102. package/apps/studio/client/v2/shell/share-cluster-host.jsx +2 -1
  103. package/apps/studio/client/v2/shell/shell-activity.js +19 -0
  104. package/apps/studio/client/v2/shell/use-occluded-insets.js +3 -0
  105. package/apps/studio/client/v2/sync-states/conflict-card.jsx +7 -2
  106. package/apps/studio/client/v2/undo/use-undo-projection.jsx +3 -1
  107. package/apps/studio/cloud/endpoints.ts +23 -1
  108. package/apps/studio/dist/client.bundle.js +798 -801
  109. package/apps/studio/dist/comment-mount.js +2 -2
  110. package/apps/studio/dist/styles.css +1 -1
  111. package/apps/studio/ds-assets.ts +138 -48
  112. package/apps/studio/editing/minimap-context.tsx +3 -3
  113. package/apps/studio/editing/page-activity.ts +251 -0
  114. package/apps/studio/editing/rotate-handle.tsx +9 -5
  115. package/apps/studio/editing/sticky-name.tsx +4 -4
  116. package/apps/studio/history/restore-artboard-action.ts +40 -0
  117. package/apps/studio/home/hub.ts +77 -175
  118. package/apps/studio/home/routes.ts +47 -8
  119. package/apps/studio/http.ts +117 -66
  120. package/apps/studio/index-flight.ts +40 -0
  121. package/apps/studio/managed-projects.ts +52 -24
  122. package/apps/studio/migrate/hub.ts +7 -1
  123. package/apps/studio/routes/asset-state.ts +12 -0
  124. package/apps/studio/routes/canvas-source.ts +44 -2
  125. package/apps/studio/routes/ds-assets.ts +8 -0
  126. package/apps/studio/routes/history.ts +28 -5
  127. package/apps/studio/routes/hub-signin.ts +115 -0
  128. package/apps/studio/routes/index.ts +4 -0
  129. package/apps/studio/routes/table.ts +7 -0
  130. package/apps/studio/routes/trash.ts +3 -0
  131. package/apps/studio/server.ts +11 -0
  132. package/apps/studio/sync/accepted-cold-start.ts +26 -3
  133. package/apps/studio/sync/accepted-link.ts +9 -4
  134. package/apps/studio/sync/asset-push.ts +8 -1
  135. package/apps/studio/sync/asset-state.ts +27 -2
  136. package/apps/studio/sync/code-module-consent.ts +74 -0
  137. package/apps/studio/sync/file-ledger.ts +35 -0
  138. package/apps/studio/sync/file-plane.ts +479 -84
  139. package/apps/studio/sync/hub-browser-signin.ts +377 -0
  140. package/apps/studio/sync/hub-text-undo.ts +30 -10
  141. package/apps/studio/sync/index.ts +73 -11
  142. package/apps/studio/sync/lfs-pointer.ts +137 -0
  143. package/apps/studio/sync/projection.ts +44 -2
  144. package/apps/studio/sync/pull-pacer.ts +160 -0
  145. package/apps/studio/sync/pull-priority.ts +119 -0
  146. package/apps/studio/sync/seed-progress.ts +47 -3
  147. package/apps/studio/sync/transaction-client.ts +71 -6
  148. package/apps/studio/sync/workspace-signin.ts +6 -256
  149. package/apps/studio/sync/writer-registry.ts +5 -1
  150. package/apps/studio/video-links-overlay.tsx +3 -2
  151. package/apps/studio/whats-new.json +63 -0
  152. package/cli/lib/design-help.gen.mjs +1 -1
  153. package/cli/lib/workspace-plan.mjs +14 -0
  154. package/package.json +8 -8
@@ -11,6 +11,7 @@
11
11
  import { useEffect, useRef, useState } from 'react';
12
12
 
13
13
  import { canvasUrl } from '../canvas-url.js';
14
+ import { ConfirmAskDialog } from '../v2/canvases/folder-dialogs.jsx';
14
15
 
15
16
  const ICONS = {
16
17
  x: (
@@ -86,6 +87,18 @@ function Brand() {
86
87
  );
87
88
  }
88
89
 
90
+ const RESTORE_FAILED = 'Could not restore that version. Try again.';
91
+ const RESOLVE_FAILED = 'Could not finish the merge. Get the latest again, then retry.';
92
+
93
+ /** A refused Restore or merge, said inside the sheet (it replaces `window.alert`, which the desktop app drops). */
94
+ function DvError({ error }) {
95
+ return (
96
+ <div className="callout callout--warning dv-err" role="alert" data-testid="diff-error">
97
+ <span>{error}</span>
98
+ </div>
99
+ );
100
+ }
101
+
89
102
  function baseName(p) {
90
103
  const s = (p || '').split('/').pop() || p || '';
91
104
  return s.replace(/\.(tsx|html|meta\.json|css|svg|json)$/i, '');
@@ -235,6 +248,12 @@ export default function DiffView({ target, cfg, loadLog, onResolve, onRestore, o
235
248
  const [view, setView] = useState({ scale: 1, x: 0, y: 0 });
236
249
  const [split, setSplit] = useState(52);
237
250
  const [busy, setBusy] = useState(false);
251
+ // A failed Restore / merge is said inside the sheet, and Restore asks in the shell's own dialog:
252
+ // `window.alert` shows nothing and `window.confirm` always answers no in the desktop app.
253
+ const [error, setError] = useState('');
254
+ const [asking, setAsking] = useState(false);
255
+ const askingRef = useRef(false);
256
+ askingRef.current = asking;
238
257
  const sheetRef = useRef(null);
239
258
  const overlayRef = useRef(null);
240
259
 
@@ -280,6 +299,8 @@ export default function DiffView({ target, cfg, loadLog, onResolve, onRestore, o
280
299
  ) ?? []),
281
300
  ].filter((el) => !el.closest('[hidden]'));
282
301
  const onKey = (e) => {
302
+ // The Restore ask is its own modal: it takes Escape and Tab itself.
303
+ if (askingRef.current) return;
283
304
  if (e.key === 'Escape') {
284
305
  e.preventDefault();
285
306
  e.stopImmediatePropagation();
@@ -341,296 +362,341 @@ export default function DiffView({ target, cfg, loadLog, onResolve, onRestore, o
341
362
  window.addEventListener('pointerup', up);
342
363
  }
343
364
 
365
+ const restoreAsk = asking
366
+ ? {
367
+ title: acceptedPreview
368
+ ? `Restore version ${beforeSha.slice(1)} of “${baseName(file)}”?`
369
+ : `Restore the saved version of “${baseName(file)}”?`,
370
+ body: acceptedPreview
371
+ ? 'It becomes a new saved version. Nothing is lost.'
372
+ : "Your unsaved changes to it are discarded. This can't be undone.",
373
+ }
374
+ : null;
375
+ const doRestore = async () => {
376
+ setAsking(false);
377
+ setBusy(true);
378
+ setError('');
379
+ try {
380
+ const res = await onRestore(file, beforeSha);
381
+ if (res && res.ok === false) setError(res.error || RESTORE_FAILED);
382
+ } catch {
383
+ setError(RESTORE_FAILED);
384
+ } finally {
385
+ setBusy(false);
386
+ }
387
+ };
388
+
344
389
  return (
345
- <div
346
- className="sh-scrim dv-scrim"
347
- role="presentation"
348
- onMouseDown={(e) => {
349
- if (e.target === e.currentTarget) onClose();
350
- }}
351
- >
390
+ <>
352
391
  <div
353
- className="dv-sheet"
354
- role="dialog"
355
- aria-modal="true"
356
- aria-label={`${conflict ? 'Resolve' : 'Compare'} ${baseName(file)}`}
357
- ref={sheetRef}
358
- tabIndex={-1}
392
+ className="sh-scrim dv-scrim"
393
+ role="presentation"
394
+ onMouseDown={(e) => {
395
+ if (e.target === e.currentTarget) onClose();
396
+ }}
359
397
  >
360
- <div className="dv-hd">
361
- <Brand />
362
- <span className="dv-title">
363
- {conflict ? 'You both changed this canvas' : 'What changed'}
364
- </span>
365
- <span className="dv-file">
366
- <Icon name="file" size={13} /> {baseName(file)}
367
- </span>
368
- <span className="dv-spacer" />
369
- {showPicker && (
370
- <label className="dv-verpick">
371
- <span className="dv-verpick-lbl">Compare against</span>
372
- <select
373
- data-testid="history-preview-version"
374
- className="dv-verpick-sel"
375
- value={beforeSha}
376
- onChange={(e) => setBeforeSha(e.target.value)}
377
- aria-label={`Saved version of ${baseName(file)} to compare against`}
378
- >
379
- {!acceptedPreview && <option value="HEAD">Last saved</option>}
380
- {versions.map((v) => (
381
- <option key={v.sha} value={v.sha}>
382
- {`${v.message || 'Saved version'} · ${timeAgo(v.date)}`}
383
- </option>
384
- ))}
385
- </select>
386
- </label>
387
- )}
388
- {!conflict && renderable && (
389
- <div className="dv-seg" role="group" aria-label="Comparison mode">
390
- <button
391
- type="button"
392
- className="dv-seg-btn"
393
- aria-pressed={mode === 'side'}
394
- onClick={() => setMode('side')}
395
- >
396
- Side by side
397
- </button>
398
- <button
399
- type="button"
400
- className="dv-seg-btn"
401
- aria-pressed={mode === 'overlay'}
402
- onClick={() => setMode('overlay')}
403
- >
404
- Overlay
405
- </button>
406
- </div>
407
- )}
408
- <button type="button" className="dv-close" aria-label="Close" onClick={onClose}>
409
- <Icon name="x" size={14} />
410
- </button>
411
- </div>
412
-
413
- {conflict ? (
414
- <>
415
- <div className="dv-pick-intro">
416
- <div className="callout callout--info">
417
- <span>
418
- While you were working, someone published their own changes to{' '}
419
- <strong style={{ color: 'var(--fg-0)' }}>{baseName(file)}</strong>. Pick which to
420
- keep — <strong style={{ color: 'var(--fg-0)' }}>Keep both</strong> saves yours as
421
- a copy so nothing is lost.
422
- </span>
423
- </div>
424
- </div>
425
- <div className="dv-stage">
426
- <ZoomBar view={view} setView={setView} />
427
- <div className="dv-pair">
428
- <div className="dv-col">
429
- <div className="dv-col-hd">
430
- <span className="dv-col-tag">
431
- <Icon name="user" size={12} /> Yours
432
- </span>
433
- <span className="dv-col-who">you · just now</span>
434
- </div>
435
- <div className="dv-thumb ring-mine">
436
- <CanvasView src={afterSrc} view={view} setView={setView} label="Your version" />
437
- </div>
438
- </div>
439
- <div className="dv-col">
440
- <div className="dv-col-hd">
441
- <span className="dv-col-tag">
442
- <Icon name="users" size={12} /> Theirs
443
- </span>
444
- <span className="dv-col-who">published</span>
445
- </div>
446
- <div className="dv-thumb ring-theirs">
447
- <CanvasView
448
- src={beforeSrc}
449
- view={view}
450
- setView={setView}
451
- label="Published version"
452
- />
453
- </div>
454
- </div>
455
- </div>
456
- </div>
457
- <div className="dv-picker" role="radiogroup" aria-label="How to resolve">
458
- {CHOICES.map((c) => (
398
+ <div
399
+ className="dv-sheet"
400
+ role="dialog"
401
+ aria-modal="true"
402
+ aria-label={`${conflict ? 'Resolve' : 'Compare'} ${baseName(file)}`}
403
+ ref={sheetRef}
404
+ tabIndex={-1}
405
+ >
406
+ <div className="dv-hd">
407
+ <Brand />
408
+ <span className="dv-title">
409
+ {conflict ? 'You both changed this canvas' : 'What changed'}
410
+ </span>
411
+ <span className="dv-file">
412
+ <Icon name="file" size={13} /> {baseName(file)}
413
+ </span>
414
+ <span className="dv-spacer" />
415
+ {showPicker && (
416
+ <label className="dv-verpick">
417
+ <span className="dv-verpick-lbl">Compare against</span>
418
+ <select
419
+ data-testid="history-preview-version"
420
+ className="dv-verpick-sel"
421
+ value={beforeSha}
422
+ onChange={(e) => setBeforeSha(e.target.value)}
423
+ aria-label={`Saved version of ${baseName(file)} to compare against`}
424
+ >
425
+ {!acceptedPreview && <option value="HEAD">Last saved</option>}
426
+ {versions.map((v) => (
427
+ <option key={v.sha} value={v.sha}>
428
+ {`${v.message || 'Saved version'} · ${timeAgo(v.date)}`}
429
+ </option>
430
+ ))}
431
+ </select>
432
+ </label>
433
+ )}
434
+ {!conflict && renderable && (
435
+ <div className="dv-seg" role="group" aria-label="Comparison mode">
459
436
  <button
460
- key={c.id}
461
437
  type="button"
462
- className={'dv-pick' + (choice === c.id ? ' is-rec' : '')}
463
- role="radio"
464
- aria-checked={choice === c.id}
465
- tabIndex={choice === c.id ? 0 : -1}
466
- onClick={() => setChoice(c.id)}
467
- onKeyDown={(e) => {
468
- // Arrow-key navigation for the radiogroup (roving tabindex —
469
- // only the checked radio is a Tab stop, so arrows must move it).
470
- const dir =
471
- e.key === 'ArrowRight' || e.key === 'ArrowDown'
472
- ? 1
473
- : e.key === 'ArrowLeft' || e.key === 'ArrowUp'
474
- ? -1
475
- : 0;
476
- if (!dir) return;
477
- e.preventDefault();
478
- const i = CHOICES.findIndex((x) => x.id === choice);
479
- const ni = (i + dir + CHOICES.length) % CHOICES.length;
480
- setChoice(CHOICES[ni].id);
481
- e.currentTarget.parentElement?.children[ni]?.focus();
482
- }}
438
+ className="dv-seg-btn"
439
+ aria-pressed={mode === 'side'}
440
+ onClick={() => setMode('side')}
483
441
  >
484
- <span className="dv-pick-hd">
485
- <Icon name={c.icon} size={14} />
486
- <span className="dv-pick-title">{c.title}</span>
487
- {c.rec && <span className="dv-pick-rec">Default</span>}
488
- </span>
489
- <span className="dv-pick-desc">{c.desc}</span>
442
+ Side by side
490
443
  </button>
491
- ))}
492
- </div>
493
- <div className="dv-ft">
494
- <span className="dv-note">
495
- You can change your mind later — both versions stay in History.
496
- </span>
497
- <button
498
- type="button"
499
- className="btn btn--ghost btn--sm"
500
- onClick={onClose}
501
- disabled={busy}
502
- >
503
- Cancel
504
- </button>
505
- <button
506
- type="button"
507
- className="btn btn--primary btn--sm"
508
- disabled={busy}
509
- onClick={async () => {
510
- setBusy(true);
511
- try {
512
- await onResolve?.(choice);
513
- } finally {
514
- setBusy(false);
515
- }
516
- }}
517
- >
518
- <Icon name="check" size={14} /> {CHOICES.find((c) => c.id === choice)?.title}
519
- </button>
520
- </div>
521
- </>
522
- ) : (
523
- <>
524
- <div className="dv-stage">
525
- <ZoomBar view={view} setView={setView} />
526
- {mode === 'side' ? (
444
+ <button
445
+ type="button"
446
+ className="dv-seg-btn"
447
+ aria-pressed={mode === 'overlay'}
448
+ onClick={() => setMode('overlay')}
449
+ >
450
+ Overlay
451
+ </button>
452
+ </div>
453
+ )}
454
+ <button type="button" className="dv-close" aria-label="Close" onClick={onClose}>
455
+ <Icon name="x" size={14} />
456
+ </button>
457
+ </div>
458
+
459
+ {conflict ? (
460
+ <>
461
+ <div className="dv-pick-intro">
462
+ <div className="callout callout--info">
463
+ <span>
464
+ While you were working, someone published their own changes to{' '}
465
+ <strong style={{ color: 'var(--fg-0)' }}>{baseName(file)}</strong>. Pick which
466
+ to keep — <strong style={{ color: 'var(--fg-0)' }}>Keep both</strong> saves
467
+ yours as a copy so nothing is lost.
468
+ </span>
469
+ </div>
470
+ </div>
471
+ <div className="dv-stage">
472
+ <ZoomBar view={view} setView={setView} />
527
473
  <div className="dv-pair">
528
474
  <div className="dv-col">
529
475
  <div className="dv-col-hd">
530
- <span className="dv-col-tag is-before">Saved version</span>
531
- <span className="dv-col-who">{beforeWhen}</span>
476
+ <span className="dv-col-tag">
477
+ <Icon name="user" size={12} /> Yours
478
+ </span>
479
+ <span className="dv-col-who">you · just now</span>
532
480
  </div>
533
- <div className="dv-thumb">
481
+ <div className="dv-thumb ring-mine">
534
482
  <CanvasView
535
- src={beforeSrc}
483
+ src={afterSrc}
536
484
  view={view}
537
485
  setView={setView}
538
- label="Saved version"
486
+ label="Your version"
539
487
  />
540
488
  </div>
541
489
  </div>
542
490
  <div className="dv-col">
543
491
  <div className="dv-col-hd">
544
- <span className="dv-col-tag is-after">Your version</span>
545
- <span className="dv-col-who">
546
- {acceptedPreview ? 'now · working copy' : 'now · unsaved'}
492
+ <span className="dv-col-tag">
493
+ <Icon name="users" size={12} /> Theirs
547
494
  </span>
495
+ <span className="dv-col-who">published</span>
548
496
  </div>
549
- <div className="dv-thumb is-after">
497
+ <div className="dv-thumb ring-theirs">
550
498
  <CanvasView
551
- src={afterSrc}
499
+ src={beforeSrc}
552
500
  view={view}
553
501
  setView={setView}
554
- label="Your version (now)"
502
+ label="Published version"
555
503
  />
556
504
  </div>
557
505
  </div>
558
506
  </div>
559
- ) : (
560
- <div className="dv-overlay" ref={overlayRef} style={{ '--dv-split': `${split}%` }}>
561
- <div className="dv-overlay-layer">
562
- <CanvasView
563
- src={beforeSrc}
564
- view={view}
565
- setView={setView}
566
- label="Saved version"
567
- />
568
- </div>
569
- <div className="dv-overlay-after">
570
- <CanvasView src={afterSrc} view={view} setView={setView} label="Your version" />
571
- </div>
572
- <span className="dv-overlay-tag l">Saved</span>
573
- <span className="dv-overlay-tag r">Yours</span>
574
- <div className="dv-split">
575
- <span
576
- className="dv-split-handle"
577
- role="slider"
578
- aria-label="Drag to wipe between saved and your version"
579
- aria-valuemin={0}
580
- aria-valuemax={100}
581
- aria-valuenow={Math.round(split)}
582
- tabIndex={0}
583
- onPointerDown={onSplitDown}
584
- onKeyDown={(e) => {
585
- if (e.key === 'ArrowLeft') setSplit((s) => clamp(s - 4, 4, 96));
586
- if (e.key === 'ArrowRight') setSplit((s) => clamp(s + 4, 4, 96));
587
- }}
588
- >
589
- <Icon name="split" size={14} />
507
+ </div>
508
+ <div className="dv-picker" role="radiogroup" aria-label="How to resolve">
509
+ {CHOICES.map((c) => (
510
+ <button
511
+ key={c.id}
512
+ type="button"
513
+ className={'dv-pick' + (choice === c.id ? ' is-rec' : '')}
514
+ role="radio"
515
+ aria-checked={choice === c.id}
516
+ tabIndex={choice === c.id ? 0 : -1}
517
+ onClick={() => setChoice(c.id)}
518
+ onKeyDown={(e) => {
519
+ // Arrow-key navigation for the radiogroup (roving tabindex —
520
+ // only the checked radio is a Tab stop, so arrows must move it).
521
+ const dir =
522
+ e.key === 'ArrowRight' || e.key === 'ArrowDown'
523
+ ? 1
524
+ : e.key === 'ArrowLeft' || e.key === 'ArrowUp'
525
+ ? -1
526
+ : 0;
527
+ if (!dir) return;
528
+ e.preventDefault();
529
+ const i = CHOICES.findIndex((x) => x.id === choice);
530
+ const ni = (i + dir + CHOICES.length) % CHOICES.length;
531
+ setChoice(CHOICES[ni].id);
532
+ e.currentTarget.parentElement?.children[ni]?.focus();
533
+ }}
534
+ >
535
+ <span className="dv-pick-hd">
536
+ <Icon name={c.icon} size={14} />
537
+ <span className="dv-pick-title">{c.title}</span>
538
+ {c.rec && <span className="dv-pick-rec">Default</span>}
590
539
  </span>
591
- </div>
592
- </div>
593
- )}
594
- </div>
595
- <div className="dv-ft">
596
- <span className="dv-note">
597
- {mode === 'side'
598
- ? 'A live rendered before & after — scroll to zoom, drag to pan. Both sides stay locked together.'
599
- : 'Drag the handle to wipe between the saved version and yours.'}
600
- </span>
601
- {onRestore && (
540
+ <span className="dv-pick-desc">{c.desc}</span>
541
+ </button>
542
+ ))}
543
+ </div>
544
+ {error ? <DvError error={error} /> : null}
545
+ <div className="dv-ft">
546
+ <span className="dv-note">
547
+ You can change your mind later — both versions stay in History.
548
+ </span>
602
549
  <button
603
550
  type="button"
604
551
  className="btn btn--ghost btn--sm"
605
- data-testid="history-preview-restore"
552
+ onClick={onClose}
553
+ disabled={busy}
554
+ >
555
+ Cancel
556
+ </button>
557
+ <button
558
+ type="button"
559
+ className="btn btn--primary btn--sm"
606
560
  disabled={busy}
607
561
  onClick={async () => {
608
- if (
609
- !window.confirm(
610
- acceptedPreview
611
- ? `Restore version ${beforeSha.slice(1)} of “${baseName(file)}” as a new saved version?`
612
- : `Restore the saved version of “${baseName(file)}”? Your unsaved changes to it are discarded.`
613
- )
614
- )
615
- return;
616
562
  setBusy(true);
563
+ setError('');
617
564
  try {
618
- await onRestore(file, beforeSha);
565
+ const res = await onResolve?.(choice);
566
+ if (res && res.ok === false) setError(res.error || RESOLVE_FAILED);
567
+ } catch {
568
+ setError(RESOLVE_FAILED);
619
569
  } finally {
620
570
  setBusy(false);
621
571
  }
622
572
  }}
623
573
  >
624
- Restore saved version
574
+ <Icon name="check" size={14} /> {CHOICES.find((c) => c.id === choice)?.title}
625
575
  </button>
626
- )}
627
- <button type="button" className="btn btn--primary btn--sm" onClick={onClose}>
628
- Keep my version
629
- </button>
630
- </div>
631
- </>
632
- )}
576
+ </div>
577
+ </>
578
+ ) : (
579
+ <>
580
+ <div className="dv-stage">
581
+ <ZoomBar view={view} setView={setView} />
582
+ {mode === 'side' ? (
583
+ <div className="dv-pair">
584
+ <div className="dv-col">
585
+ <div className="dv-col-hd">
586
+ <span className="dv-col-tag is-before">Saved version</span>
587
+ <span className="dv-col-who">{beforeWhen}</span>
588
+ </div>
589
+ <div className="dv-thumb">
590
+ <CanvasView
591
+ src={beforeSrc}
592
+ view={view}
593
+ setView={setView}
594
+ label="Saved version"
595
+ />
596
+ </div>
597
+ </div>
598
+ <div className="dv-col">
599
+ <div className="dv-col-hd">
600
+ <span className="dv-col-tag is-after">Your version</span>
601
+ <span className="dv-col-who">
602
+ {acceptedPreview ? 'now · working copy' : 'now · unsaved'}
603
+ </span>
604
+ </div>
605
+ <div className="dv-thumb is-after">
606
+ <CanvasView
607
+ src={afterSrc}
608
+ view={view}
609
+ setView={setView}
610
+ label="Your version (now)"
611
+ />
612
+ </div>
613
+ </div>
614
+ </div>
615
+ ) : (
616
+ <div
617
+ className="dv-overlay"
618
+ ref={overlayRef}
619
+ style={{ '--dv-split': `${split}%` }}
620
+ >
621
+ <div className="dv-overlay-layer">
622
+ <CanvasView
623
+ src={beforeSrc}
624
+ view={view}
625
+ setView={setView}
626
+ label="Saved version"
627
+ />
628
+ </div>
629
+ <div className="dv-overlay-after">
630
+ <CanvasView
631
+ src={afterSrc}
632
+ view={view}
633
+ setView={setView}
634
+ label="Your version"
635
+ />
636
+ </div>
637
+ <span className="dv-overlay-tag l">Saved</span>
638
+ <span className="dv-overlay-tag r">Yours</span>
639
+ <div className="dv-split">
640
+ <span
641
+ className="dv-split-handle"
642
+ role="slider"
643
+ aria-label="Drag to wipe between saved and your version"
644
+ aria-valuemin={0}
645
+ aria-valuemax={100}
646
+ aria-valuenow={Math.round(split)}
647
+ tabIndex={0}
648
+ onPointerDown={onSplitDown}
649
+ onKeyDown={(e) => {
650
+ if (e.key === 'ArrowLeft') setSplit((s) => clamp(s - 4, 4, 96));
651
+ if (e.key === 'ArrowRight') setSplit((s) => clamp(s + 4, 4, 96));
652
+ }}
653
+ >
654
+ <Icon name="split" size={14} />
655
+ </span>
656
+ </div>
657
+ </div>
658
+ )}
659
+ </div>
660
+ {error ? <DvError error={error} /> : null}
661
+ <div className="dv-ft">
662
+ <span className="dv-note">
663
+ {mode === 'side'
664
+ ? 'A live rendered before & after — scroll to zoom, drag to pan. Both sides stay locked together.'
665
+ : 'Drag the handle to wipe between the saved version and yours.'}
666
+ </span>
667
+ {onRestore && (
668
+ <button
669
+ type="button"
670
+ className="btn btn--ghost btn--sm"
671
+ data-testid="history-preview-restore"
672
+ disabled={busy}
673
+ onClick={() => {
674
+ setError('');
675
+ setAsking(true);
676
+ }}
677
+ >
678
+ Restore saved version
679
+ </button>
680
+ )}
681
+ <button type="button" className="btn btn--primary btn--sm" onClick={onClose}>
682
+ Keep my version
683
+ </button>
684
+ </div>
685
+ </>
686
+ )}
687
+ </div>
633
688
  </div>
634
- </div>
689
+ {restoreAsk ? (
690
+ <ConfirmAskDialog
691
+ over
692
+ title={restoreAsk.title}
693
+ body={restoreAsk.body}
694
+ confirm="Restore"
695
+ busyLabel="Restoring…"
696
+ onConfirm={doRestore}
697
+ onCancel={() => setAsking(false)}
698
+ />
699
+ ) : null}
700
+ </>
635
701
  );
636
702
  }