@1agh/maude 2.0.3 → 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.
- package/README.md +6 -5
- package/apps/studio/access/request.ts +0 -1
- package/apps/studio/acp/adapter-stderr.ts +43 -13
- package/apps/studio/acp/background-tasks.ts +155 -0
- package/apps/studio/acp/bridge.ts +44 -5
- package/apps/studio/acp/connected-fact.ts +15 -4
- package/apps/studio/acp/index.ts +14 -5
- package/apps/studio/actions/agents.ts +5 -0
- package/apps/studio/actions/defs/view.ts +12 -0
- package/apps/studio/actions.manifest.json +13 -1
- package/apps/studio/actions.parity.json +7 -1
- package/apps/studio/api.ts +31 -24
- package/apps/studio/bin/_png-playwright.mjs +10 -1
- package/apps/studio/bin/_pw-launch.mjs +14 -0
- package/apps/studio/bin/_thumbs-playwright.mjs +4 -1
- package/apps/studio/boot-progress.ts +31 -0
- package/apps/studio/canvas-build-sandbox.ts +275 -42
- package/apps/studio/canvas-build-worker.ts +10 -0
- package/apps/studio/canvas-create.ts +24 -0
- package/apps/studio/canvas-module-cache.ts +93 -0
- package/apps/studio/canvas-source/errors.ts +39 -0
- package/apps/studio/canvas-source/waiting.ts +290 -0
- package/apps/studio/client/actions/shell-key-handlers.js +5 -0
- package/apps/studio/client/app.jsx +19 -9
- package/apps/studio/client/github.js +23 -3
- package/apps/studio/client/home/home-api.js +30 -19
- package/apps/studio/client/hooks/use-git-actions.jsx +2 -1
- package/apps/studio/client/hooks/use-shell-core.jsx +3 -0
- package/apps/studio/client/hooks/use-tabs.jsx +64 -35
- package/apps/studio/client/index-loader.ts +23 -3
- package/apps/studio/client/panels/ChatPanel.jsx +22 -37
- package/apps/studio/client/panels/DiffView.jsx +314 -248
- package/apps/studio/client/panels/TeamProjects.jsx +119 -69
- package/apps/studio/client/panels/acp-runtime.js +25 -0
- package/apps/studio/client/panels/chat-finish.js +66 -0
- package/apps/studio/client/shell/frame-cap.js +53 -0
- package/apps/studio/client/shell/viewport.jsx +9 -0
- package/apps/studio/client/styles/_index.css +2 -0
- package/apps/studio/client/tree/tree.jsx +48 -21
- package/apps/studio/client/v2/ai/BackgroundStrip.jsx +120 -0
- package/apps/studio/client/v2/ai/StoppedDivider.jsx +2 -1
- package/apps/studio/client/v2/ai/ai-run.css +87 -3
- package/apps/studio/client/v2/ai/background-model.js +113 -0
- package/apps/studio/client/v2/ai/needs-you-store.js +2 -1
- package/apps/studio/client/v2/ai/run-api.js +7 -3
- package/apps/studio/client/v2/ai/runs-store.js +2 -1
- package/apps/studio/client/v2/annotations/vote-store.js +11 -5
- package/apps/studio/client/v2/assets/asset-state-lane.js +6 -3
- package/apps/studio/client/v2/assets/assets-bus.js +10 -8
- package/apps/studio/client/v2/assets/browse-view.jsx +2 -0
- package/apps/studio/client/v2/assets/ds-library-view.jsx +47 -0
- package/apps/studio/client/v2/assets/spotlight-model.js +75 -0
- package/apps/studio/client/v2/assets/spotlight.css +153 -0
- package/apps/studio/client/v2/assets/spotlight.jsx +199 -0
- package/apps/studio/client/v2/assets/tile-menu.jsx +3 -1
- package/apps/studio/client/v2/assets/tile.jsx +3 -0
- package/apps/studio/client/v2/assets/use-assets.js +2 -1
- package/apps/studio/client/v2/canvases/canvases-panel.jsx +13 -2
- package/apps/studio/client/v2/canvases/covers.js +11 -5
- package/apps/studio/client/v2/canvases/folder-ask.js +139 -0
- package/apps/studio/client/v2/canvases/folder-dialogs.jsx +150 -0
- package/apps/studio/client/v2/canvases/trash-canvas.js +10 -2
- package/apps/studio/client/v2/canvases/trash-queue.js +152 -0
- package/apps/studio/client/v2/canvases/use-canvas-index.js +42 -18
- package/apps/studio/client/v2/canvases/use-pins.js +2 -1
- package/apps/studio/client/v2/code/canvas-error-card.jsx +70 -5
- package/apps/studio/client/v2/code/canvas-waiting-card.jsx +128 -0
- package/apps/studio/client/v2/code/canvas-waiting.js +164 -0
- package/apps/studio/client/v2/code/code.css +67 -0
- package/apps/studio/client/v2/code/use-canvas-source.js +19 -4
- package/apps/studio/client/v2/create/NameDialog.jsx +4 -2
- package/apps/studio/client/v2/create/name-dialog.css +10 -0
- package/apps/studio/client/v2/ds/advanced-host.jsx +5 -2
- package/apps/studio/client/v2/ds/make-host.jsx +5 -2
- package/apps/studio/client/v2/ds/off-system-host.jsx +5 -2
- package/apps/studio/client/v2/ds/truth-host.jsx +5 -2
- package/apps/studio/client/v2/empty/arriving.jsx +29 -12
- package/apps/studio/client/v2/empty/empty-host.jsx +8 -2
- package/apps/studio/client/v2/empty/not-local.jsx +31 -1
- package/apps/studio/client/v2/empty/use-empty-canvas.js +10 -1
- package/apps/studio/client/v2/export/last-finished.js +2 -1
- package/apps/studio/client/v2/history/git-model.js +18 -4
- package/apps/studio/client/v2/history/git-parts.jsx +60 -42
- package/apps/studio/client/v2/history/history.css +6 -0
- package/apps/studio/client/v2/left-panel/assets-panel.jsx +87 -10
- package/apps/studio/client/v2/left-panel/use-trash.js +2 -1
- package/apps/studio/client/v2/onboarding/AdvancedSheets.jsx +100 -33
- package/apps/studio/client/v2/onboarding/HubSheet.jsx +51 -83
- package/apps/studio/client/v2/onboarding/onboarding-model.js +10 -6
- package/apps/studio/client/v2/present/order-notes-artboards.js +2 -1
- package/apps/studio/client/v2/search/search-recent.js +3 -1
- package/apps/studio/client/v2/search/search-remote.js +6 -4
- package/apps/studio/client/v2/settings/connections-model.js +1 -1
- package/apps/studio/client/v2/shell/menu-runner.js +1 -0
- package/apps/studio/client/v2/shell/occlusion-insets.js +14 -2
- package/apps/studio/client/v2/shell/recovery-store.js +2 -1
- package/apps/studio/client/v2/shell/served-routes.js +120 -0
- package/apps/studio/client/v2/shell/share-cluster-host.jsx +2 -1
- package/apps/studio/client/v2/shell/shell-activity.js +19 -0
- package/apps/studio/client/v2/shell/use-occluded-insets.js +3 -0
- package/apps/studio/client/v2/sync-states/conflict-card.jsx +7 -2
- package/apps/studio/client/v2/undo/use-undo-projection.jsx +3 -1
- package/apps/studio/cloud/endpoints.ts +23 -1
- package/apps/studio/dist/client.bundle.js +977 -981
- package/apps/studio/dist/styles.css +1 -1
- package/apps/studio/editing/minimap-context.tsx +3 -3
- package/apps/studio/editing/page-activity.ts +251 -0
- package/apps/studio/editing/rotate-handle.tsx +9 -5
- package/apps/studio/editing/sticky-name.tsx +4 -4
- package/apps/studio/history/restore-artboard-action.ts +40 -0
- package/apps/studio/home/hub.ts +77 -175
- package/apps/studio/home/routes.ts +47 -8
- package/apps/studio/http.ts +117 -66
- package/apps/studio/index-flight.ts +40 -0
- package/apps/studio/managed-projects.ts +52 -24
- package/apps/studio/migrate/hub.ts +7 -1
- package/apps/studio/routes/canvas-source.ts +44 -2
- package/apps/studio/routes/history.ts +28 -5
- package/apps/studio/routes/hub-signin.ts +115 -0
- package/apps/studio/routes/index.ts +4 -0
- package/apps/studio/routes/table.ts +7 -0
- package/apps/studio/routes/trash.ts +3 -0
- package/apps/studio/server.ts +11 -0
- package/apps/studio/sync/accepted-cold-start.ts +26 -3
- package/apps/studio/sync/accepted-link.ts +9 -4
- package/apps/studio/sync/code-module-consent.ts +74 -0
- package/apps/studio/sync/file-ledger.ts +35 -0
- package/apps/studio/sync/file-plane.ts +443 -77
- package/apps/studio/sync/hub-browser-signin.ts +377 -0
- package/apps/studio/sync/hub-text-undo.ts +30 -10
- package/apps/studio/sync/index.ts +73 -11
- package/apps/studio/sync/projection.ts +44 -2
- package/apps/studio/sync/pull-pacer.ts +160 -0
- package/apps/studio/sync/pull-priority.ts +119 -0
- package/apps/studio/sync/seed-progress.ts +47 -3
- package/apps/studio/sync/transaction-client.ts +71 -6
- package/apps/studio/sync/workspace-signin.ts +6 -256
- package/apps/studio/sync/writer-registry.ts +5 -1
- package/apps/studio/video-links-overlay.tsx +3 -2
- package/apps/studio/whats-new.json +54 -0
- package/cli/lib/design-help.gen.mjs +1 -1
- package/cli/lib/workspace-plan.mjs +14 -0
- 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
|
-
|
|
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-
|
|
354
|
-
role="
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
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
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
<
|
|
369
|
-
|
|
370
|
-
<
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
>
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
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=
|
|
463
|
-
|
|
464
|
-
|
|
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
|
-
|
|
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
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
>
|
|
518
|
-
|
|
519
|
-
|
|
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
|
|
531
|
-
|
|
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={
|
|
483
|
+
src={afterSrc}
|
|
536
484
|
view={view}
|
|
537
485
|
setView={setView}
|
|
538
|
-
label="
|
|
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
|
|
545
|
-
|
|
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
|
|
497
|
+
<div className="dv-thumb ring-theirs">
|
|
550
498
|
<CanvasView
|
|
551
|
-
src={
|
|
499
|
+
src={beforeSrc}
|
|
552
500
|
view={view}
|
|
553
501
|
setView={setView}
|
|
554
|
-
label="
|
|
502
|
+
label="Published version"
|
|
555
503
|
/>
|
|
556
504
|
</div>
|
|
557
505
|
</div>
|
|
558
506
|
</div>
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
<
|
|
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
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
<
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
574
|
+
<Icon name="check" size={14} /> {CHOICES.find((c) => c.id === choice)?.title}
|
|
625
575
|
</button>
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
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
|
-
|
|
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
|
}
|