@ddtcorex/dsh-maestro-core 0.10.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.
- package/LICENSE +21 -0
- package/README.md +209 -0
- package/cordis.patch.yml +43 -0
- package/lib/bin.d.ts +2 -0
- package/lib/bin.js +3 -0
- package/lib/boot-guard.d.ts +33 -0
- package/lib/boot-guard.js +68 -0
- package/lib/boot-lock.d.ts +56 -0
- package/lib/boot-lock.js +155 -0
- package/lib/cli.d.ts +31 -0
- package/lib/cli.js +336 -0
- package/lib/client.js +2901 -0
- package/lib/config/index.d.ts +34 -0
- package/lib/config/index.js +62 -0
- package/lib/config/service.d.ts +18 -0
- package/lib/config/service.js +28 -0
- package/lib/config.d.ts +1 -0
- package/lib/config.js +19 -0
- package/lib/daemon-freshness.d.ts +48 -0
- package/lib/daemon-freshness.js +122 -0
- package/lib/debug-agent.d.ts +17 -0
- package/lib/debug-agent.js +144 -0
- package/lib/dsh-session.d.ts +26 -0
- package/lib/dsh-session.js +45 -0
- package/lib/guard/config.d.ts +82 -0
- package/lib/guard/config.js +211 -0
- package/lib/guard/decide.d.ts +30 -0
- package/lib/guard/decide.js +38 -0
- package/lib/guard/full-scan-tool.d.ts +6 -0
- package/lib/guard/full-scan-tool.js +65 -0
- package/lib/guard/index.d.ts +85 -0
- package/lib/guard/index.js +254 -0
- package/lib/guard/journal.d.ts +146 -0
- package/lib/guard/journal.js +398 -0
- package/lib/guard/migrate.d.ts +15 -0
- package/lib/guard/migrate.js +42 -0
- package/lib/guard/parse.d.ts +193 -0
- package/lib/guard/parse.js +1103 -0
- package/lib/guard/paths.d.ts +104 -0
- package/lib/guard/paths.js +254 -0
- package/lib/guard/permission-policy.d.ts +10 -0
- package/lib/guard/permission-policy.js +21 -0
- package/lib/guard/redact.d.ts +25 -0
- package/lib/guard/redact.js +52 -0
- package/lib/guard/rules.d.ts +65 -0
- package/lib/guard/rules.js +832 -0
- package/lib/guard/status-tool.d.ts +54 -0
- package/lib/guard/status-tool.js +195 -0
- package/lib/guard/tiers.d.ts +2 -0
- package/lib/guard/tiers.js +1 -0
- package/lib/guard/validators.d.ts +4 -0
- package/lib/guard/validators.js +45 -0
- package/lib/health-poller.d.ts +90 -0
- package/lib/health-poller.js +430 -0
- package/lib/index.d.ts +7 -0
- package/lib/index.js +7 -0
- package/lib/intents.d.ts +32 -0
- package/lib/intents.js +49 -0
- package/lib/notifier.d.ts +12 -0
- package/lib/notifier.js +62 -0
- package/lib/paths.d.ts +13 -0
- package/lib/paths.js +70 -0
- package/lib/plugin.d.ts +250 -0
- package/lib/plugin.js +1126 -0
- package/lib/preset.d.ts +73 -0
- package/lib/preset.js +158 -0
- package/lib/report.d.ts +11 -0
- package/lib/report.js +58 -0
- package/lib/restart-exec.d.ts +35 -0
- package/lib/restart-exec.js +60 -0
- package/lib/restart-guards.d.ts +39 -0
- package/lib/restart-guards.js +150 -0
- package/lib/restart-tool.d.ts +124 -0
- package/lib/restart-tool.js +539 -0
- package/lib/restart-web.d.ts +26 -0
- package/lib/restart-web.js +58 -0
- package/lib/resume-log.d.ts +24 -0
- package/lib/resume-log.js +18 -0
- package/lib/resume-tools.d.ts +131 -0
- package/lib/resume-tools.js +337 -0
- package/lib/resume.d.ts +33 -0
- package/lib/resume.js +221 -0
- package/lib/scan.d.ts +20 -0
- package/lib/scan.js +71 -0
- package/lib/self-kill-guard.d.ts +81 -0
- package/lib/self-kill-guard.js +208 -0
- package/lib/session-health.d.ts +89 -0
- package/lib/session-health.js +274 -0
- package/lib/session-log-file.d.ts +22 -0
- package/lib/session-log-file.js +74 -0
- package/lib/skill-provider.d.ts +6 -0
- package/lib/skill-provider.js +73 -0
- package/lib/snapshot.d.ts +59 -0
- package/lib/snapshot.js +358 -0
- package/lib/source.d.ts +19 -0
- package/lib/source.js +19 -0
- package/lib/store/index.d.ts +42 -0
- package/lib/store/index.js +340 -0
- package/lib/store/legacy.d.ts +17 -0
- package/lib/store/legacy.js +85 -0
- package/lib/supervisor.d.ts +119 -0
- package/lib/supervisor.js +741 -0
- package/lib/sync/backup-config.d.ts +55 -0
- package/lib/sync/backup-config.js +119 -0
- package/lib/sync/backup-service.d.ts +110 -0
- package/lib/sync/backup-service.js +440 -0
- package/lib/sync/bidirectional.d.ts +39 -0
- package/lib/sync/bidirectional.js +25 -0
- package/lib/sync/cli.d.ts +38 -0
- package/lib/sync/cli.js +536 -0
- package/lib/sync/config.d.ts +77 -0
- package/lib/sync/config.js +90 -0
- package/lib/sync/fingerprint.d.ts +29 -0
- package/lib/sync/fingerprint.js +65 -0
- package/lib/sync/hashing.d.ts +9 -0
- package/lib/sync/hashing.js +47 -0
- package/lib/sync/index.d.ts +6 -0
- package/lib/sync/index.js +634 -0
- package/lib/sync/machine-id.d.ts +29 -0
- package/lib/sync/machine-id.js +66 -0
- package/lib/sync/merge.d.ts +33 -0
- package/lib/sync/merge.js +88 -0
- package/lib/sync/peer-host.d.ts +22 -0
- package/lib/sync/peer-host.js +62 -0
- package/lib/sync/process-runner.d.ts +31 -0
- package/lib/sync/process-runner.js +161 -0
- package/lib/sync/remote-agent.d.ts +42 -0
- package/lib/sync/remote-agent.js +217 -0
- package/lib/sync/remote-cache.d.ts +18 -0
- package/lib/sync/remote-cache.js +60 -0
- package/lib/sync/remote-manifest.d.ts +8 -0
- package/lib/sync/remote-manifest.js +64 -0
- package/lib/sync/s3-object-store.d.ts +38 -0
- package/lib/sync/s3-object-store.js +126 -0
- package/lib/sync/session-merge.d.ts +18 -0
- package/lib/sync/session-merge.js +191 -0
- package/lib/sync/session-plan.d.ts +29 -0
- package/lib/sync/session-plan.js +213 -0
- package/lib/sync/sigv4.d.ts +20 -0
- package/lib/sync/sigv4.js +57 -0
- package/lib/sync/snapshot.d.ts +21 -0
- package/lib/sync/snapshot.js +176 -0
- package/lib/sync/ssh-mux.d.ts +12 -0
- package/lib/sync/ssh-mux.js +48 -0
- package/lib/sync/sync-plan.d.ts +24 -0
- package/lib/sync/sync-plan.js +366 -0
- package/lib/sync/sync-service.d.ts +177 -0
- package/lib/sync/sync-service.js +819 -0
- package/lib/sync/sync-types.d.ts +87 -0
- package/lib/sync/sync-types.js +1 -0
- package/lib/sync/transport.d.ts +75 -0
- package/lib/sync/transport.js +200 -0
- package/lib/sync/tunnel-restore.d.ts +77 -0
- package/lib/sync/tunnel-restore.js +142 -0
- package/lib/sync/validation.d.ts +10 -0
- package/lib/sync/validation.js +83 -0
- package/lib/tool-view.d.ts +62 -0
- package/lib/tool-view.js +70 -0
- package/lib/types/client/auto-reload.d.ts +8 -0
- package/lib/types/client/auto-reload.d.ts.map +1 -0
- package/lib/types/client/config/MaestroSettings.d.ts +25 -0
- package/lib/types/client/config/MaestroSettings.d.ts.map +1 -0
- package/lib/types/client/config/components/BrandMark.d.ts +50 -0
- package/lib/types/client/config/components/BrandMark.d.ts.map +1 -0
- package/lib/types/client/config/guard-view.d.ts +83 -0
- package/lib/types/client/config/guard-view.d.ts.map +1 -0
- package/lib/types/client/config/index.d.ts +20 -0
- package/lib/types/client/config/index.d.ts.map +1 -0
- package/lib/types/client/config/maestro-mark.d.ts +29 -0
- package/lib/types/client/config/maestro-mark.d.ts.map +1 -0
- package/lib/types/client/config/settings-nav-icon.d.ts +21 -0
- package/lib/types/client/config/settings-nav-icon.d.ts.map +1 -0
- package/lib/types/client/index.d.ts +16 -0
- package/lib/types/client/index.d.ts.map +1 -0
- package/lib/types/client/sync/R2SyncPanel.d.ts +6 -0
- package/lib/types/client/sync/R2SyncPanel.d.ts.map +1 -0
- package/lib/types/client/sync/SyncPanel.d.ts +12 -0
- package/lib/types/client/sync/SyncPanel.d.ts.map +1 -0
- package/lib/types/client/sync/confirm-dialog.d.ts +43 -0
- package/lib/types/client/sync/confirm-dialog.d.ts.map +1 -0
- package/lib/types/client/sync/index.d.ts +10 -0
- package/lib/types/client/sync/index.d.ts.map +1 -0
- package/lib/types/client/sync/ui.d.ts +79 -0
- package/lib/types/client/sync/ui.d.ts.map +1 -0
- package/lib/types/client/sync/use-backup.d.ts +50 -0
- package/lib/types/client/sync/use-backup.d.ts.map +1 -0
- package/lib/types/client/sync/use-sync.d.ts +88 -0
- package/lib/types/client/sync/use-sync.d.ts.map +1 -0
- package/package.json +89 -0
- package/skills/dsh-safe-restart/SKILL.md +206 -0
- package/skills/dsh-safe-restart/scripts/restart-dsh-web.sh +468 -0
- package/src/client/auto-reload.ts +104 -0
- package/src/client/config/MaestroSettings.tsx +892 -0
- package/src/client/config/components/BrandMark.tsx +94 -0
- package/src/client/config/guard-view.ts +187 -0
- package/src/client/config/index.tsx +109 -0
- package/src/client/config/maestro-mark.ts +37 -0
- package/src/client/config/settings-nav-icon.ts +68 -0
- package/src/client/index.tsx +33 -0
- package/src/client/sync/R2SyncPanel.tsx +260 -0
- package/src/client/sync/SyncPanel.tsx +422 -0
- package/src/client/sync/confirm-dialog.tsx +202 -0
- package/src/client/sync/index.tsx +336 -0
- package/src/client/sync/ui.tsx +313 -0
- package/src/client/sync/use-backup.ts +207 -0
- package/src/client/sync/use-sync.ts +502 -0
- package/src/host/bin.ts +3 -0
- package/src/host/boot-guard.ts +76 -0
- package/src/host/boot-lock.ts +155 -0
- package/src/host/cli.ts +288 -0
- package/src/host/config/index.ts +78 -0
- package/src/host/config/service.ts +40 -0
- package/src/host/config.ts +18 -0
- package/src/host/daemon-freshness.ts +143 -0
- package/src/host/debug-agent.ts +145 -0
- package/src/host/dsh-session.ts +56 -0
- package/src/host/dsh-skill.d.ts +44 -0
- package/src/host/guard/augment.d.ts +33 -0
- package/src/host/guard/config.ts +244 -0
- package/src/host/guard/decide.ts +40 -0
- package/src/host/guard/full-scan-tool.ts +61 -0
- package/src/host/guard/index.ts +281 -0
- package/src/host/guard/journal.ts +440 -0
- package/src/host/guard/migrate.ts +41 -0
- package/src/host/guard/parse.ts +1150 -0
- package/src/host/guard/paths.ts +239 -0
- package/src/host/guard/permission-policy.ts +15 -0
- package/src/host/guard/redact.ts +64 -0
- package/src/host/guard/rules.ts +891 -0
- package/src/host/guard/status-tool.ts +229 -0
- package/src/host/guard/tiers.ts +2 -0
- package/src/host/guard/validators.ts +29 -0
- package/src/host/health-poller.ts +446 -0
- package/src/host/index.ts +7 -0
- package/src/host/intents.ts +67 -0
- package/src/host/notifier.ts +71 -0
- package/src/host/paths.ts +70 -0
- package/src/host/plugin.ts +1097 -0
- package/src/host/preset.ts +170 -0
- package/src/host/report.ts +71 -0
- package/src/host/restart-exec.ts +81 -0
- package/src/host/restart-guards.ts +150 -0
- package/src/host/restart-tool.ts +483 -0
- package/src/host/restart-web.ts +72 -0
- package/src/host/resume-log.ts +39 -0
- package/src/host/resume-tools.ts +385 -0
- package/src/host/resume.ts +204 -0
- package/src/host/scan.ts +61 -0
- package/src/host/self-kill-guard.ts +216 -0
- package/src/host/session-health.ts +236 -0
- package/src/host/session-log-file.ts +77 -0
- package/src/host/skill-provider.ts +69 -0
- package/src/host/snapshot.ts +337 -0
- package/src/host/source.ts +19 -0
- package/src/host/store/index.ts +348 -0
- package/src/host/store/legacy.ts +96 -0
- package/src/host/supervisor.ts +720 -0
- package/src/host/sync/backup-config.ts +159 -0
- package/src/host/sync/backup-service.ts +453 -0
- package/src/host/sync/bidirectional.ts +66 -0
- package/src/host/sync/cli.ts +539 -0
- package/src/host/sync/config.ts +119 -0
- package/src/host/sync/fingerprint.ts +83 -0
- package/src/host/sync/hashing.ts +58 -0
- package/src/host/sync/index.ts +737 -0
- package/src/host/sync/machine-id.ts +81 -0
- package/src/host/sync/merge.ts +102 -0
- package/src/host/sync/peer-host.ts +65 -0
- package/src/host/sync/process-runner.ts +177 -0
- package/src/host/sync/remote-agent.ts +213 -0
- package/src/host/sync/remote-cache.ts +68 -0
- package/src/host/sync/remote-manifest.ts +70 -0
- package/src/host/sync/s3-object-store.ts +144 -0
- package/src/host/sync/session-merge.ts +220 -0
- package/src/host/sync/session-plan.ts +237 -0
- package/src/host/sync/sigv4.ts +81 -0
- package/src/host/sync/snapshot.ts +162 -0
- package/src/host/sync/ssh-mux.ts +56 -0
- package/src/host/sync/sync-plan.ts +366 -0
- package/src/host/sync/sync-service.ts +855 -0
- package/src/host/sync/sync-types.ts +102 -0
- package/src/host/sync/transport.ts +261 -0
- package/src/host/sync/tunnel-restore.ts +160 -0
- package/src/host/sync/validation.ts +91 -0
- package/src/host/tool-view.ts +98 -0
|
@@ -0,0 +1,422 @@
|
|
|
1
|
+
import * as React from 'react'
|
|
2
|
+
import { useSync, type Bucket } from './use-sync.js'
|
|
3
|
+
import { useBackupTarget } from './use-backup.js'
|
|
4
|
+
import { R2SyncPanel } from './R2SyncPanel.js'
|
|
5
|
+
import { ConfirmDialog, TunnelRestoreDialog } from './confirm-dialog.js'
|
|
6
|
+
import { Button, Icon, MaestroLogo, StatTile, formatFile, formatLastSync, humanSummary } from './ui.js'
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Maestro Sync — the complete settings card (settings.section, id maestro-sync).
|
|
10
|
+
* Mobile-first summary + the two paged file lists (Only here / Only there);
|
|
11
|
+
* everything lives in Settings. Keeps the confirmation-first contract: Preview
|
|
12
|
+
* is read-only; apply exists only inside the dialog bound to the live preview
|
|
13
|
+
* id (confirm:true).
|
|
14
|
+
*/
|
|
15
|
+
export function SyncPanel(props: { ctx: any }): React.ReactElement {
|
|
16
|
+
const s = useSync(props.ctx)
|
|
17
|
+
const b = useBackupTarget(props.ctx)
|
|
18
|
+
const [tab, setTab] = React.useState<'remote' | 'r2'>('remote')
|
|
19
|
+
const { connection, checking, busy, error, result, status, remoteHost, remoteSource, lastSync, confirmOpen, preview, previewDirection, biPreview, biConfirmOpen, tunnelPreview, tunnelConfirmOpen, hostFieldError, actionLimit, pages } = s
|
|
20
|
+
const st = b.status
|
|
21
|
+
|
|
22
|
+
const isConnected = connection?.ok === true
|
|
23
|
+
const isDisconnected = connection?.ok === false
|
|
24
|
+
// Machine identity is a real precondition, not decoration: a failed verdict
|
|
25
|
+
// (same machine on both sides, or the peer reporting our own id) means every
|
|
26
|
+
// plan below would be computed against the wrong peer, so it gates the
|
|
27
|
+
// actions instead of only rendering a line. `machines === null` = not checked
|
|
28
|
+
// yet, which the SSH gate already covers.
|
|
29
|
+
const machinesBlocked = s.machines?.ok === false
|
|
30
|
+
const canSync = isConnected && !checking && !busy && !machinesBlocked
|
|
31
|
+
const planAgeSecs = preview?.expiresAt ? Math.max(0, Math.round((new Date(preview.expiresAt).getTime() - Date.now()) / 1000)) : 0
|
|
32
|
+
|
|
33
|
+
// SSH target form state — prefilled from the saved/env/default target once
|
|
34
|
+
// it loads; the user edits, Saves, then explicitly Checks. Nothing probes
|
|
35
|
+
// SSH until Check is pressed and nothing unlocks until it passes.
|
|
36
|
+
const [hostInput, setHostInput] = React.useState('')
|
|
37
|
+
React.useEffect(() => {
|
|
38
|
+
if (hostInput === '' && remoteHost !== '…') setHostInput(remoteHost)
|
|
39
|
+
}, [remoteHost, hostInput])
|
|
40
|
+
const handleCheck = React.useCallback(async () => {
|
|
41
|
+
const host = hostInput.trim()
|
|
42
|
+
if (!host) return
|
|
43
|
+
const saved = await s.saveRemoteHost(host)
|
|
44
|
+
if (!saved.ok) return
|
|
45
|
+
await s.checkConnection()
|
|
46
|
+
}, [hostInput, s])
|
|
47
|
+
// `machine` is the machine-local peer file, which outranks the shared store
|
|
48
|
+
// because the store travels between the two machines.
|
|
49
|
+
const sourceLabel = remoteSource === 'machine' ? 'Saved for this machine' : remoteSource === 'settings' ? 'Saved in settings' : remoteSource === 'env' ? 'From REMOTE_HOST env' : 'Built-in default'
|
|
50
|
+
|
|
51
|
+
// Mobile-first progressive disclosure: buckets start collapsed on narrow
|
|
52
|
+
// screens (<640px) so the summary + actions fit one viewport; desktop and
|
|
53
|
+
// wider start expanded. jsdom (tests) reports 1024px → expanded.
|
|
54
|
+
const [collapsed, setCollapsed] = React.useState<Record<Bucket, boolean>>(() => {
|
|
55
|
+
const narrow = typeof window !== 'undefined' && typeof window.innerWidth === 'number' && window.innerWidth < 640
|
|
56
|
+
return { localOnly: narrow, remoteOnly: narrow }
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
const renderBucket = (bucket: Bucket, heading: string, empty: string) => {
|
|
60
|
+
const page = pages[bucket]
|
|
61
|
+
const icon = bucket === 'localOnly' ? 'upload' : 'download'
|
|
62
|
+
const open = !collapsed[bucket]
|
|
63
|
+
return (
|
|
64
|
+
<section data-sync-dcol="" data-bucket={bucket} data-collapsed={String(!open)} aria-label={heading}>
|
|
65
|
+
<header data-sync-dcol-head="">
|
|
66
|
+
<button
|
|
67
|
+
type="button"
|
|
68
|
+
data-sync-dcol-toggle=""
|
|
69
|
+
aria-expanded={open}
|
|
70
|
+
aria-label={`${open ? 'Collapse' : 'Expand'} ${heading}`}
|
|
71
|
+
onClick={() => setCollapsed((prev) => ({ ...prev, [bucket]: !prev[bucket] }))}
|
|
72
|
+
>
|
|
73
|
+
<span data-sync-dcol-title="">
|
|
74
|
+
<Icon name={open ? 'chevron-down' : 'chevron-right'} />
|
|
75
|
+
<Icon name={icon} />
|
|
76
|
+
{heading}
|
|
77
|
+
</span>
|
|
78
|
+
<span data-sync-dcol-count="">
|
|
79
|
+
{page.files.length}/{page.total}
|
|
80
|
+
</span>
|
|
81
|
+
</button>
|
|
82
|
+
</header>
|
|
83
|
+
{open ? (
|
|
84
|
+
isDisconnected ? (
|
|
85
|
+
<div data-sync-empty="">Cannot check remote — SSH to {connection!.host} is not connected.</div>
|
|
86
|
+
) : page.files.length === 0 && !page.loaded ? (
|
|
87
|
+
<div data-sync-loading="">Checking {heading.toLowerCase()}…</div>
|
|
88
|
+
) : page.files.length === 0 && !checking ? (
|
|
89
|
+
<div data-sync-empty="">{empty}</div>
|
|
90
|
+
) : (
|
|
91
|
+
page.files.map((p: string) => {
|
|
92
|
+
const f = formatFile(p)
|
|
93
|
+
return (
|
|
94
|
+
<div key={p} data-sync-file="" title={p}>
|
|
95
|
+
<span data-sync-file-icon="" style={{ color: 'var(--dsw-alias-label-tertiary)' }}>
|
|
96
|
+
<Icon name={f.icon} />
|
|
97
|
+
</span>
|
|
98
|
+
<span data-sync-file-main="">
|
|
99
|
+
<span data-sync-file-title="">{f.title}</span>
|
|
100
|
+
<span data-sync-file-path="">{f.path}</span>
|
|
101
|
+
</span>
|
|
102
|
+
<span data-sync-file-meta="">{f.meta}</span>
|
|
103
|
+
</div>
|
|
104
|
+
)
|
|
105
|
+
})
|
|
106
|
+
)
|
|
107
|
+
) : null}
|
|
108
|
+
{open && page.next != null ? (
|
|
109
|
+
<footer data-sync-dcol-foot="">
|
|
110
|
+
<Button size="sm" variant="ghost" onClick={() => void s.loadPage(bucket, page.next!)} aria-label={`Show more ${heading}`}>
|
|
111
|
+
Show more
|
|
112
|
+
</Button>
|
|
113
|
+
</footer>
|
|
114
|
+
) : null}
|
|
115
|
+
</section>
|
|
116
|
+
)
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// House pattern: ONE header (badge + title + live status) above the tabs.
|
|
120
|
+
// The status line follows the active tab; per-tab headers were removed.
|
|
121
|
+
const headerStatus =
|
|
122
|
+
tab === 'remote'
|
|
123
|
+
? checking
|
|
124
|
+
? 'Checking connection…'
|
|
125
|
+
: isConnected
|
|
126
|
+
? `${connection!.host} · ${humanSummary(status)}`
|
|
127
|
+
: isDisconnected
|
|
128
|
+
? `Cannot reach ${connection!.host}`
|
|
129
|
+
: connection === null
|
|
130
|
+
? 'Not checked yet — configure SSH and check'
|
|
131
|
+
: humanSummary(status)
|
|
132
|
+
: b.checking
|
|
133
|
+
? 'Checking backup configuration…'
|
|
134
|
+
: st?.configured
|
|
135
|
+
? `Backup ${st.prefix}`
|
|
136
|
+
: 'Not configured'
|
|
137
|
+
|
|
138
|
+
const renderRemote = () => (
|
|
139
|
+
<div data-sync-root="" aria-busy={busy || checking}>
|
|
140
|
+
{/* SSH configuration — the user fills the target, Saves, then explicitly
|
|
141
|
+
Checks. Nothing below unlocks until the check passes. */}
|
|
142
|
+
<div data-sync-ssh="">
|
|
143
|
+
<label data-sync-ssh-label="" htmlFor="sync-ssh-host">SSH target</label>
|
|
144
|
+
<input
|
|
145
|
+
id="sync-ssh-host"
|
|
146
|
+
data-sync-ssh-input=""
|
|
147
|
+
data-testid="sync-ssh-host"
|
|
148
|
+
value={hostInput}
|
|
149
|
+
onChange={(e) => { setHostInput(e.target.value); void s.setHostFieldError?.(null) }}
|
|
150
|
+
placeholder="user@host"
|
|
151
|
+
autoComplete="off"
|
|
152
|
+
autoCapitalize="off"
|
|
153
|
+
spellCheck={false}
|
|
154
|
+
disabled={checking || busy}
|
|
155
|
+
aria-describedby="sync-ssh-src"
|
|
156
|
+
aria-invalid={hostFieldError ? 'true' : undefined}
|
|
157
|
+
/>
|
|
158
|
+
{hostFieldError ? (
|
|
159
|
+
<span data-sync-field-error="" role="alert" data-testid="sync-ssh-host-error" style={{ gridColumn: '1 / -1', fontSize: 12, lineHeight: '16px', color: 'var(--dsw-alias-state-error-primary)', overflowWrap: 'anywhere' }}>
|
|
160
|
+
{hostFieldError}
|
|
161
|
+
</span>
|
|
162
|
+
) : null}
|
|
163
|
+
<div data-sync-ssh-row="">
|
|
164
|
+
<Button variant="outline" data-testid="sync-save-host" disabled={checking || busy || hostInput.trim().length === 0} onClick={() => void s.saveRemoteHost(hostInput.trim())}>
|
|
165
|
+
Save
|
|
166
|
+
</Button>
|
|
167
|
+
<Button variant="primary" data-testid="sync-check-connection" disabled={checking || busy || hostInput.trim().length === 0} busy={checking} onClick={() => void handleCheck()}>
|
|
168
|
+
{checking ? 'Checking…' : 'Check connection'}
|
|
169
|
+
</Button>
|
|
170
|
+
</div>
|
|
171
|
+
<span id="sync-ssh-src" data-sync-ssh-src="">{sourceLabel}</span>
|
|
172
|
+
</div>
|
|
173
|
+
|
|
174
|
+
{/* Connection banner (Refresh lives here so the header stays badge+title+status) */}
|
|
175
|
+
<div data-sync-conn="" data-state={isDisconnected ? 'bad' : checking ? 'checking' : 'ok'} data-testid="sync-connection">
|
|
176
|
+
<span data-sync-conn-dot="" />
|
|
177
|
+
<span data-sync-conn-main="">
|
|
178
|
+
{checking ? (
|
|
179
|
+
<span data-sync-conn-title="">Checking SSH to {remoteHost}…</span>
|
|
180
|
+
) : isConnected ? (
|
|
181
|
+
<>
|
|
182
|
+
<span data-sync-conn-title="">
|
|
183
|
+
Connected to {connection!.host}
|
|
184
|
+
{connection!.latencyMs != null ? ` · ${connection!.latencyMs}ms` : ''} · SSH ready
|
|
185
|
+
</span>
|
|
186
|
+
<span data-sync-conn-desc="">Use Preview to see the exact plan — Apply always requires confirmation.</span>
|
|
187
|
+
</>
|
|
188
|
+
) : isDisconnected ? (
|
|
189
|
+
<>
|
|
190
|
+
<span data-sync-conn-title="">Cannot reach {connection!.host} — sync is paused</span>
|
|
191
|
+
<span data-sync-conn-desc="">{connection!.error ? String(connection!.error).slice(0, 220) : 'SSH failed. Check that the host is reachable and your key is loaded.'}</span>
|
|
192
|
+
</>
|
|
193
|
+
) : (
|
|
194
|
+
<span data-sync-conn-title="">Not checked yet — configure SSH above, then Check connection.</span>
|
|
195
|
+
)}
|
|
196
|
+
</span>
|
|
197
|
+
<Button variant="ghost" size="sm" icon="refresh" busy={checking} disabled={!isConnected} onClick={() => void s.loadStatus()} aria-label="Refresh connection status" style={{ marginLeft: 'auto', flex: 'none', alignSelf: 'center' }}>
|
|
198
|
+
{checking ? 'Checking' : 'Refresh'}
|
|
199
|
+
</Button>
|
|
200
|
+
</div>
|
|
201
|
+
|
|
202
|
+
{isConnected ? (
|
|
203
|
+
<>
|
|
204
|
+
{/* Identity fields — host + last sync */}
|
|
205
|
+
<div data-sync-fields="">
|
|
206
|
+
<div data-sync-field="">
|
|
207
|
+
<span data-sync-field-label="">Remote host</span>
|
|
208
|
+
<span data-sync-field-value="" data-testid="sync-remote-host">{remoteHost}</span>
|
|
209
|
+
</div>
|
|
210
|
+
<div data-sync-field="">
|
|
211
|
+
{/* Browser-local, client-only (localStorage). A CLI apply on this
|
|
212
|
+
machine never updates it, so the label says whose history this is
|
|
213
|
+
instead of implying it is the canonical sync state. */}
|
|
214
|
+
<span data-sync-field-label="">Last sync (this browser)</span>
|
|
215
|
+
<span data-sync-field-value="" data-testid="sync-last-sync">{formatLastSync(lastSync)}</span>
|
|
216
|
+
</div>
|
|
217
|
+
{s.machines ? (
|
|
218
|
+
<div data-sync-field="">
|
|
219
|
+
<span data-sync-field-label="">Machines</span>
|
|
220
|
+
<span data-sync-field-value="" data-testid="sync-machines">{s.machines.localId ?? '?'} ↔ {s.machines.remoteId ?? '?'}</span>
|
|
221
|
+
{s.machines.reason ? (
|
|
222
|
+
<span data-sync-field-note="" data-testid="sync-machines-error" style={{ fontSize: 12, lineHeight: '16px', color: 'var(--dsw-alias-label-secondary)', overflowWrap: 'anywhere' }}>{s.machines.reason}</span>
|
|
223
|
+
) : null}
|
|
224
|
+
<Button variant="outline" size="sm" data-testid="sync-tunnel-restore" disabled={checking || busy} onClick={() => void s.handleTunnelRestorePreview()}>
|
|
225
|
+
Restore tunnel
|
|
226
|
+
</Button>
|
|
227
|
+
</div>
|
|
228
|
+
) : null}
|
|
229
|
+
</div>
|
|
230
|
+
|
|
231
|
+
{/* Stats */}
|
|
232
|
+
<div data-sync-stats="">
|
|
233
|
+
<StatTile
|
|
234
|
+
icon="upload"
|
|
235
|
+
value={status ? String(status.localOnly ?? 0) : '—'}
|
|
236
|
+
label="Only here"
|
|
237
|
+
hint={status?.localOnly ? 'Pushed on Preview Push' : 'Nothing here'}
|
|
238
|
+
ariaLabel="Files only on this machine"
|
|
239
|
+
/>
|
|
240
|
+
<StatTile
|
|
241
|
+
icon="swap"
|
|
242
|
+
value={status ? String(status.both ?? 0) : '—'}
|
|
243
|
+
label="On both"
|
|
244
|
+
hint="Content compared in Preview"
|
|
245
|
+
ariaLabel="Files on both machines"
|
|
246
|
+
/>
|
|
247
|
+
<StatTile
|
|
248
|
+
icon="download"
|
|
249
|
+
value={status ? String(status.remoteOnly ?? 0) : '—'}
|
|
250
|
+
label="Only there"
|
|
251
|
+
hint={status?.remoteOnly ? 'Pulled on Preview Pull' : 'Nothing there'}
|
|
252
|
+
ariaLabel="Files only on the other machine"
|
|
253
|
+
/>
|
|
254
|
+
</div>
|
|
255
|
+
|
|
256
|
+
{/* Primary actions — sticky bottom bar on mobile (thumb reach) */}
|
|
257
|
+
{machinesBlocked ? (
|
|
258
|
+
<div data-sync-notice="" data-tone="bad" role="status" data-testid="sync-machines-gate">
|
|
259
|
+
<span data-sync-notice-icon="">
|
|
260
|
+
<Icon name="alert" />
|
|
261
|
+
</span>
|
|
262
|
+
<span data-sync-notice-main="">
|
|
263
|
+
<span data-sync-notice-title="">Sync is locked — machine identity check failed</span>
|
|
264
|
+
<span data-sync-notice-desc="">
|
|
265
|
+
{s.machines?.reason ?? 'The two sides do not look like two distinct machines.'} Fix the SSH target so it points at the OTHER machine, then Check connection again.
|
|
266
|
+
</span>
|
|
267
|
+
</span>
|
|
268
|
+
</div>
|
|
269
|
+
) : null}
|
|
270
|
+
<div data-sync-actions="" data-sync-actions-bar="">
|
|
271
|
+
<Button variant="primary" icon="swap" disabled={!canSync} data-testid="sync-both-ways" onClick={() => void s.handleBidirectionalPreview()}>
|
|
272
|
+
{busy ? 'Working…' : 'Sync both ways'}
|
|
273
|
+
</Button>
|
|
274
|
+
<Button variant="outline" icon="download" disabled={!canSync} data-testid="sync-preview-pull" onClick={() => void s.handlePreview('pull')}>
|
|
275
|
+
{busy ? 'Working…' : 'Preview Pull'}
|
|
276
|
+
</Button>
|
|
277
|
+
<Button variant="outline" icon="upload" disabled={!canSync} data-testid="sync-preview-push" onClick={() => void s.handlePreview('push')}>
|
|
278
|
+
{busy ? 'Working…' : 'Preview Push'}
|
|
279
|
+
</Button>
|
|
280
|
+
</div>
|
|
281
|
+
|
|
282
|
+
{/* Preview progress — shows the session file currently being counted */}
|
|
283
|
+
{busy && s.progress ? (
|
|
284
|
+
<div data-sync-progress="" role="status" aria-live="polite" data-testid="sync-progress">
|
|
285
|
+
<span data-sync-progress-meta="">
|
|
286
|
+
{s.progress.phase === 'hashing'
|
|
287
|
+
? `Reviewing sessions ${s.progress.current}/${s.progress.total}${s.progress.file ? ` — ${formatFile(s.progress.file).path}` : ''}`
|
|
288
|
+
: s.progress.phase === 'staging'
|
|
289
|
+
? `Staging files ${s.progress.current}/${s.progress.total}`
|
|
290
|
+
: s.progress.phase === 'planning'
|
|
291
|
+
? 'Building the exact plan…'
|
|
292
|
+
: 'Listing both machines…'}
|
|
293
|
+
</span>
|
|
294
|
+
<span data-sync-progress-track="" role="progressbar" aria-valuemin={0} aria-valuemax={s.progress.total} aria-valuenow={s.progress.current}>
|
|
295
|
+
<span data-sync-progress-fill="" style={{ width: `${s.progress.total > 0 ? Math.min(100, Math.round((s.progress.current / s.progress.total) * 100)) : 0}%` }} />
|
|
296
|
+
</span>
|
|
297
|
+
</div>
|
|
298
|
+
) : null}
|
|
299
|
+
|
|
300
|
+
{/* Results + errors (announced) */}
|
|
301
|
+
{result ? (
|
|
302
|
+
<div data-sync-notice="" data-tone={result.ok ? 'ok' : 'bad'} role="status" aria-live="polite">
|
|
303
|
+
<span data-sync-notice-icon="">
|
|
304
|
+
<Icon name={result.ok ? 'check' : 'alert'} />
|
|
305
|
+
</span>
|
|
306
|
+
<span data-sync-notice-main="">
|
|
307
|
+
<span data-sync-notice-title="">{result.ok ? 'Apply complete' : 'Apply failed'}</span>
|
|
308
|
+
<span data-sync-notice-desc="">{result.text}</span>
|
|
309
|
+
</span>
|
|
310
|
+
</div>
|
|
311
|
+
) : null}
|
|
312
|
+
{/* Results (announced) — inside the gate: only a passed check produces one */}
|
|
313
|
+
|
|
314
|
+
{/* File list sections — everything stays inside Settings */}
|
|
315
|
+
<div data-sync-filetables="">
|
|
316
|
+
{renderBucket('remoteOnly', 'Coming from the other machine', 'Nothing to pull — the other machine has no eligible files here.')}
|
|
317
|
+
{renderBucket('localOnly', 'Ready to send', 'Nothing to push — this machine has no eligible files here.')}
|
|
318
|
+
</div>
|
|
319
|
+
</>
|
|
320
|
+
) : (
|
|
321
|
+
<div data-sync-notice="" data-tone="ok" role="status">
|
|
322
|
+
<span data-sync-notice-icon="">
|
|
323
|
+
<Icon name={isDisconnected ? 'alert' : 'clock'} />
|
|
324
|
+
</span>
|
|
325
|
+
<span data-sync-notice-main="">
|
|
326
|
+
<span data-sync-notice-title="">{isDisconnected ? 'Connection failed' : 'Preview and file lists are locked'}</span>
|
|
327
|
+
<span data-sync-notice-desc="">
|
|
328
|
+
{isDisconnected
|
|
329
|
+
? 'Fix the SSH target above and check again.'
|
|
330
|
+
: 'Configure the SSH target above, then Check connection — everything below unlocks after a successful check.'}
|
|
331
|
+
</span>
|
|
332
|
+
</span>
|
|
333
|
+
</div>
|
|
334
|
+
)}
|
|
335
|
+
|
|
336
|
+
{error ? (
|
|
337
|
+
<div data-sync-notice="" data-tone="bad" role="alert">
|
|
338
|
+
<span data-sync-notice-icon="">
|
|
339
|
+
<Icon name="alert" />
|
|
340
|
+
</span>
|
|
341
|
+
<span data-sync-notice-main="">
|
|
342
|
+
<span data-sync-notice-title="">Something went wrong</span>
|
|
343
|
+
<span data-sync-notice-desc="">{error}</span>
|
|
344
|
+
</span>
|
|
345
|
+
</div>
|
|
346
|
+
) : null}
|
|
347
|
+
|
|
348
|
+
{/* Confirmation dialog — the only place apply exists */}
|
|
349
|
+
{confirmOpen && preview ? (
|
|
350
|
+
<ConfirmDialog
|
|
351
|
+
preview={preview}
|
|
352
|
+
previewDirection={previewDirection}
|
|
353
|
+
remoteHost={remoteHost}
|
|
354
|
+
busy={busy}
|
|
355
|
+
actionLimit={actionLimit}
|
|
356
|
+
planAgeSecs={planAgeSecs}
|
|
357
|
+
onShowMore={() => s.setActionLimit((n: number) => n + 5)}
|
|
358
|
+
onCancel={s.cancelDialog}
|
|
359
|
+
onApply={() => void s.handleApply()}
|
|
360
|
+
/>
|
|
361
|
+
) : null}
|
|
362
|
+
|
|
363
|
+
{/* Bidirectional dialog — exact push plan plus the projected pull plan */}
|
|
364
|
+
{biConfirmOpen && biPreview ? (
|
|
365
|
+
<ConfirmDialog
|
|
366
|
+
preview={biPreview.push}
|
|
367
|
+
previewDirection="push"
|
|
368
|
+
remoteHost={remoteHost}
|
|
369
|
+
busy={busy}
|
|
370
|
+
actionLimit={actionLimit}
|
|
371
|
+
planAgeSecs={Math.max(0, Math.round((new Date(biPreview.expiresAt).getTime() - Date.now()) / 1000))}
|
|
372
|
+
onShowMore={() => s.setActionLimit((n: number) => n + 5)}
|
|
373
|
+
onCancel={s.cancelBidirectionalDialog}
|
|
374
|
+
onApply={() => void s.handleBidirectionalApply()}
|
|
375
|
+
title={`Apply both ways — preview ${String(biPreview.previewId ?? '').slice(0, 8)}`}
|
|
376
|
+
projectedTitle="Pull plan (projected)"
|
|
377
|
+
projectedPreview={biPreview.pullProjected}
|
|
378
|
+
projectedNote="Projected — recomputed exact after the push lands."
|
|
379
|
+
applyLabel="Apply both ways"
|
|
380
|
+
/>
|
|
381
|
+
) : null}
|
|
382
|
+
|
|
383
|
+
{/* Tunnel-restore dialog — the only place the domains.tunnel write exists */}
|
|
384
|
+
{tunnelConfirmOpen && tunnelPreview ? (
|
|
385
|
+
<TunnelRestoreDialog
|
|
386
|
+
preview={tunnelPreview}
|
|
387
|
+
busy={busy}
|
|
388
|
+
onCancel={s.cancelTunnelRestore}
|
|
389
|
+
onConfirm={() => void s.confirmTunnelRestore()}
|
|
390
|
+
/>
|
|
391
|
+
) : null}
|
|
392
|
+
|
|
393
|
+
<div data-sync-muted="" style={{ textAlign: 'center' }}>
|
|
394
|
+
Notes and sessions are merged — never overwritten. Apply always requires confirmation.
|
|
395
|
+
</div>
|
|
396
|
+
</div>
|
|
397
|
+
)
|
|
398
|
+
|
|
399
|
+
return (
|
|
400
|
+
<div data-sync-shell="">
|
|
401
|
+
{/* Header — shared Maestro badge + title + live status line (same as Maestro Jobs) */}
|
|
402
|
+
<div style={{ display: 'flex', gap: 10, alignItems: 'flex-start', padding: '2px 2px 4px' }}>
|
|
403
|
+
<MaestroLogo />
|
|
404
|
+
<div style={{ display: 'flex', flexDirection: 'column', minWidth: 0, gap: 2 }}>
|
|
405
|
+
<div style={{ fontSize: 15, fontWeight: 600, lineHeight: '22px', color: 'var(--dsw-alias-label-primary)' }}>Maestro Sync</div>
|
|
406
|
+
<span style={{ fontSize: 12, lineHeight: '16px', color: 'var(--dsw-alias-label-secondary)', overflowWrap: 'anywhere' }}>
|
|
407
|
+
{headerStatus}
|
|
408
|
+
</span>
|
|
409
|
+
</div>
|
|
410
|
+
</div>
|
|
411
|
+
<div data-sync-tabs="" role="tablist" aria-label="Maestro Sync modes">
|
|
412
|
+
<button data-testid="sync-tab-remote" role="tab" aria-selected={tab === 'remote'} data-sync-tab="" onClick={() => setTab('remote')}>
|
|
413
|
+
Remote Sync
|
|
414
|
+
</button>
|
|
415
|
+
<button data-testid="sync-tab-r2" role="tab" aria-selected={tab === 'r2'} data-sync-tab="" onClick={() => setTab('r2')}>
|
|
416
|
+
R2 Sync
|
|
417
|
+
</button>
|
|
418
|
+
</div>
|
|
419
|
+
{tab === 'remote' ? renderRemote() : <R2SyncPanel b={b} />}
|
|
420
|
+
</div>
|
|
421
|
+
)
|
|
422
|
+
}
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import * as React from 'react'
|
|
2
|
+
import { Button, Icon, actionLabel, actionTone, formatFile } from './ui.js'
|
|
3
|
+
|
|
4
|
+
/** Renders a tunnel domain object as a stable, comparable one-liner. */
|
|
5
|
+
function tunnelLine(v: any): string {
|
|
6
|
+
if (v === null || v === undefined) return 'not set'
|
|
7
|
+
if (typeof v !== 'object') return String(v)
|
|
8
|
+
const keys = Object.keys(v).sort()
|
|
9
|
+
if (keys.length === 0) return 'not set'
|
|
10
|
+
return keys.map((k) => `${k}=${String((v as any)[k])}`).join(' · ')
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Tunnel-restore confirmation — the only place a restore can be issued.
|
|
15
|
+
*
|
|
16
|
+
* The restore rewrites `domains.tunnel` in the shared store, the same data
|
|
17
|
+
* class whose uncoordinated write took a machine's tunnel down (HTTP 530) on
|
|
18
|
+
* 2026-08-26/2026-09-09, so it follows the preview → single-use id → dialog
|
|
19
|
+
* contract every other mutation in this panel already uses. The preview body is
|
|
20
|
+
* read-only and shows exactly which fields change.
|
|
21
|
+
*/
|
|
22
|
+
export function TunnelRestoreDialog(props: {
|
|
23
|
+
preview: any
|
|
24
|
+
busy: boolean
|
|
25
|
+
onCancel: () => void
|
|
26
|
+
onConfirm: () => void
|
|
27
|
+
}): React.ReactElement {
|
|
28
|
+
const { preview, busy, onCancel, onConfirm } = props
|
|
29
|
+
const expiresIn = preview?.expiresAt ? Math.max(0, Math.round((new Date(preview.expiresAt).getTime() - Date.now()) / 1000)) : 0
|
|
30
|
+
const changed = preview?.changed === true
|
|
31
|
+
return (
|
|
32
|
+
<div data-sync-dialog-overlay="" data-testid="sync-tunnel-dialog-overlay">
|
|
33
|
+
<div role="dialog" aria-modal="true" aria-labelledby="sync-tunnel-dialog-title" data-sync-dialog="" data-testid="sync-tunnel-dialog">
|
|
34
|
+
<div data-sync-dialog-top="">
|
|
35
|
+
<div data-sync-dialog-heading="">
|
|
36
|
+
<div id="sync-tunnel-dialog-title" data-sync-dialog-title="">Restore tunnel — profile {preview?.profile ?? '?'}</div>
|
|
37
|
+
<div data-sync-dialog-desc="">
|
|
38
|
+
Rewrites <code>domains.tunnel</code> in the shared settings store on this machine · preview expires in {expiresIn}s
|
|
39
|
+
</div>
|
|
40
|
+
</div>
|
|
41
|
+
<button type="button" data-sync-dialog-close="" aria-label="Cancel" onClick={onCancel} disabled={busy}>
|
|
42
|
+
<Icon name="close" />
|
|
43
|
+
</button>
|
|
44
|
+
</div>
|
|
45
|
+
|
|
46
|
+
<div data-sync-planlist="" data-testid="sync-tunnel-plan">
|
|
47
|
+
<div data-action-row="" data-sync-planrow="">
|
|
48
|
+
<span data-sync-planfile="">
|
|
49
|
+
<span data-sync-planfile-title="">Current value</span>
|
|
50
|
+
<span data-sync-planfile-path="" data-testid="sync-tunnel-current">{tunnelLine(preview?.current)}</span>
|
|
51
|
+
</span>
|
|
52
|
+
</div>
|
|
53
|
+
<div data-action-row="" data-sync-planrow="">
|
|
54
|
+
<span data-sync-planfile="">
|
|
55
|
+
<span data-sync-planfile-title="">Restored from profile</span>
|
|
56
|
+
<span data-sync-planfile-path="" data-testid="sync-tunnel-desired">{tunnelLine(preview?.desired)}</span>
|
|
57
|
+
</span>
|
|
58
|
+
</div>
|
|
59
|
+
<div data-sync-planlist-note="">
|
|
60
|
+
{changed
|
|
61
|
+
? 'Only domains.tunnel changes — every other domain (jobs, notifier, guard, …) is left untouched.'
|
|
62
|
+
: 'The stored value already matches this profile — confirming is a no-op.'}
|
|
63
|
+
</div>
|
|
64
|
+
</div>
|
|
65
|
+
|
|
66
|
+
<div data-sync-dialog-actions="">
|
|
67
|
+
<Button variant="outline" onClick={onCancel} disabled={busy} aria-label="Cancel">Cancel</Button>
|
|
68
|
+
<Button variant="primary" data-testid="sync-tunnel-confirm" onClick={onConfirm} disabled={busy} busy={busy} aria-label="Restore tunnel">
|
|
69
|
+
{busy ? 'Restoring…' : 'Restore tunnel'}
|
|
70
|
+
</Button>
|
|
71
|
+
</div>
|
|
72
|
+
</div>
|
|
73
|
+
</div>
|
|
74
|
+
)
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Confirmation-first apply dialog — the ONLY place an apply can be issued.
|
|
79
|
+
* Bound to a live preview id; Escape cancels; actions list paginates.
|
|
80
|
+
* Bottom-sheet on mobile, centered card on ≥640px.
|
|
81
|
+
*/
|
|
82
|
+
export function ConfirmDialog(props: {
|
|
83
|
+
preview: any
|
|
84
|
+
previewDirection: 'pull' | 'push'
|
|
85
|
+
remoteHost: string
|
|
86
|
+
busy: boolean
|
|
87
|
+
actionLimit: number
|
|
88
|
+
planAgeSecs: number
|
|
89
|
+
onShowMore: () => void
|
|
90
|
+
onCancel: () => void
|
|
91
|
+
onApply: () => void
|
|
92
|
+
/** R2 flows: title + target label override; defaults keep the remote-sync wording. */
|
|
93
|
+
kind?: 'sync' | 'backup' | 'restore' | 'gc'
|
|
94
|
+
title?: string
|
|
95
|
+
targetLabel?: string
|
|
96
|
+
/** Bidirectional flow: second plan section rendered below the primary one. */
|
|
97
|
+
projectedTitle?: string
|
|
98
|
+
projectedPreview?: any
|
|
99
|
+
projectedNote?: string
|
|
100
|
+
/** Bidirectional flow: apply button label override. */
|
|
101
|
+
applyLabel?: string
|
|
102
|
+
}): React.ReactElement {
|
|
103
|
+
const { preview, previewDirection, remoteHost, busy, actionLimit, planAgeSecs, onShowMore, onCancel, onApply, title, targetLabel, projectedTitle, projectedPreview, projectedNote, applyLabel } = props
|
|
104
|
+
const actions = (preview?.actions ?? []).slice(0, actionLimit)
|
|
105
|
+
const hasMore = (preview?.actions?.length ?? 0) > actionLimit
|
|
106
|
+
const summary = preview?.summary ?? {}
|
|
107
|
+
const sessionCounts = preview?.sessionCounts
|
|
108
|
+
const previewId = String(preview?.previewId ?? '').slice(0, 8)
|
|
109
|
+
|
|
110
|
+
const sessionLine = sessionCounts
|
|
111
|
+
? `${sessionCounts.added ?? 0} added · ${sessionCounts.updated ?? 0} updated · ${sessionCounts.deleted ?? 0} deleted · ${sessionCounts.identical ?? 0} identical`
|
|
112
|
+
: null
|
|
113
|
+
|
|
114
|
+
return (
|
|
115
|
+
<div data-sync-dialog-overlay="" data-testid="sync-dialog-overlay">
|
|
116
|
+
<div role="dialog" aria-modal="true" aria-labelledby="sync-dialog-title" data-sync-dialog="" data-testid="sync-dialog">
|
|
117
|
+
<div data-sync-dialog-top="">
|
|
118
|
+
<div data-sync-dialog-heading="">
|
|
119
|
+
<div id="sync-dialog-title" data-sync-dialog-title="">
|
|
120
|
+
{title ?? `Apply ${previewDirection} — preview ${previewId}`}
|
|
121
|
+
</div>
|
|
122
|
+
<div data-sync-dialog-desc="">
|
|
123
|
+
{targetLabel ?? remoteHost} · plan {planAgeSecs}s before expiry · {summary.copied ?? 0} copy · {summary.merged ?? 0} merge (+{summary.added ?? 0} added) · {summary.skipped ?? 0} skip · {summary.conflicts ?? 0} conflict
|
|
124
|
+
</div>
|
|
125
|
+
</div>
|
|
126
|
+
<button type="button" data-sync-dialog-close="" aria-label="Cancel" onClick={onCancel} disabled={busy}>
|
|
127
|
+
<Icon name="close" />
|
|
128
|
+
</button>
|
|
129
|
+
</div>
|
|
130
|
+
|
|
131
|
+
<div data-sync-planlist="">
|
|
132
|
+
{sessionLine ? (
|
|
133
|
+
<div data-sync-sessioncounts="" data-testid="sync-session-counts">
|
|
134
|
+
<span data-sync-sessioncounts-lbl="">
|
|
135
|
+
<Icon name="swap" />
|
|
136
|
+
Sessions (counted by checksum)
|
|
137
|
+
</span>
|
|
138
|
+
<span data-sync-sessioncounts-line="">{sessionLine}</span>
|
|
139
|
+
</div>
|
|
140
|
+
) : null}
|
|
141
|
+
{actions.length === 0 ? (
|
|
142
|
+
<div data-sync-empty="">Nothing to do — every file is already in sync.</div>
|
|
143
|
+
) : (
|
|
144
|
+
actions.map((a: any) => {
|
|
145
|
+
const f = formatFile(a.path)
|
|
146
|
+
return (
|
|
147
|
+
<div key={a.path} data-action-row="" title={a.path} data-sync-planrow="">
|
|
148
|
+
<span data-sync-planfile-icon="" style={{ color: 'var(--dsw-alias-label-tertiary)' }}>
|
|
149
|
+
<Icon name={f.icon} />
|
|
150
|
+
</span>
|
|
151
|
+
<span data-sync-planfile="">
|
|
152
|
+
<span data-sync-planfile-title="">{f.title} — {actionLabel(a)}</span>
|
|
153
|
+
<span data-sync-planfile-path="">{a.path}</span>
|
|
154
|
+
</span>
|
|
155
|
+
<span data-sync-planrow-meta="">
|
|
156
|
+
<span data-sync-badge="" data-tone={actionTone(a)}>{a.reason ?? a.action}</span>
|
|
157
|
+
</span>
|
|
158
|
+
</div>
|
|
159
|
+
)
|
|
160
|
+
})
|
|
161
|
+
)}
|
|
162
|
+
{hasMore ? (
|
|
163
|
+
<div data-sync-planmore="">
|
|
164
|
+
<Button size="sm" variant="ghost" onClick={onShowMore} aria-label="Show more actions">Show more</Button>
|
|
165
|
+
</div>
|
|
166
|
+
) : null}
|
|
167
|
+
</div>
|
|
168
|
+
|
|
169
|
+
{projectedPreview ? (
|
|
170
|
+
<div data-sync-planlist="" data-testid="sync-projected-plan">
|
|
171
|
+
<div data-sync-planlist-title="">{projectedTitle ?? 'Pull plan (projected)'}</div>
|
|
172
|
+
{projectedNote ? <div data-sync-planlist-note="">{projectedNote}</div> : null}
|
|
173
|
+
{((projectedPreview?.actions ?? []) as any[]).slice(0, actionLimit).map((a: any) => {
|
|
174
|
+
const f = formatFile(a.path)
|
|
175
|
+
return (
|
|
176
|
+
<div key={a.path} data-action-row="" title={a.path} data-sync-planrow="">
|
|
177
|
+
<span data-sync-planfile-icon="" style={{ color: 'var(--dsw-alias-label-tertiary)' }}>
|
|
178
|
+
<Icon name={f.icon} />
|
|
179
|
+
</span>
|
|
180
|
+
<span data-sync-planfile="">
|
|
181
|
+
<span data-sync-planfile-title="">{f.title} — {actionLabel(a)}</span>
|
|
182
|
+
<span data-sync-planfile-path="">{a.path}</span>
|
|
183
|
+
</span>
|
|
184
|
+
<span data-sync-planrow-meta="">
|
|
185
|
+
<span data-sync-badge="" data-tone={actionTone(a)}>{a.reason ?? a.action}</span>
|
|
186
|
+
</span>
|
|
187
|
+
</div>
|
|
188
|
+
)
|
|
189
|
+
})}
|
|
190
|
+
</div>
|
|
191
|
+
) : null}
|
|
192
|
+
|
|
193
|
+
<div data-sync-dialog-actions="">
|
|
194
|
+
<Button variant="outline" onClick={onCancel} disabled={busy} aria-label="Cancel">Cancel</Button>
|
|
195
|
+
<Button variant="primary" onClick={onApply} disabled={busy} busy={busy} aria-label={applyLabel ?? `Apply ${previewDirection}`}>
|
|
196
|
+
{busy ? 'Applying…' : (applyLabel ?? `Apply ${previewDirection} — ${summary.copied ?? 0} copy, ${summary.merged ?? 0} merge`)}
|
|
197
|
+
</Button>
|
|
198
|
+
</div>
|
|
199
|
+
</div>
|
|
200
|
+
</div>
|
|
201
|
+
)
|
|
202
|
+
}
|