@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.
Files changed (285) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +209 -0
  3. package/cordis.patch.yml +43 -0
  4. package/lib/bin.d.ts +2 -0
  5. package/lib/bin.js +3 -0
  6. package/lib/boot-guard.d.ts +33 -0
  7. package/lib/boot-guard.js +68 -0
  8. package/lib/boot-lock.d.ts +56 -0
  9. package/lib/boot-lock.js +155 -0
  10. package/lib/cli.d.ts +31 -0
  11. package/lib/cli.js +336 -0
  12. package/lib/client.js +2901 -0
  13. package/lib/config/index.d.ts +34 -0
  14. package/lib/config/index.js +62 -0
  15. package/lib/config/service.d.ts +18 -0
  16. package/lib/config/service.js +28 -0
  17. package/lib/config.d.ts +1 -0
  18. package/lib/config.js +19 -0
  19. package/lib/daemon-freshness.d.ts +48 -0
  20. package/lib/daemon-freshness.js +122 -0
  21. package/lib/debug-agent.d.ts +17 -0
  22. package/lib/debug-agent.js +144 -0
  23. package/lib/dsh-session.d.ts +26 -0
  24. package/lib/dsh-session.js +45 -0
  25. package/lib/guard/config.d.ts +82 -0
  26. package/lib/guard/config.js +211 -0
  27. package/lib/guard/decide.d.ts +30 -0
  28. package/lib/guard/decide.js +38 -0
  29. package/lib/guard/full-scan-tool.d.ts +6 -0
  30. package/lib/guard/full-scan-tool.js +65 -0
  31. package/lib/guard/index.d.ts +85 -0
  32. package/lib/guard/index.js +254 -0
  33. package/lib/guard/journal.d.ts +146 -0
  34. package/lib/guard/journal.js +398 -0
  35. package/lib/guard/migrate.d.ts +15 -0
  36. package/lib/guard/migrate.js +42 -0
  37. package/lib/guard/parse.d.ts +193 -0
  38. package/lib/guard/parse.js +1103 -0
  39. package/lib/guard/paths.d.ts +104 -0
  40. package/lib/guard/paths.js +254 -0
  41. package/lib/guard/permission-policy.d.ts +10 -0
  42. package/lib/guard/permission-policy.js +21 -0
  43. package/lib/guard/redact.d.ts +25 -0
  44. package/lib/guard/redact.js +52 -0
  45. package/lib/guard/rules.d.ts +65 -0
  46. package/lib/guard/rules.js +832 -0
  47. package/lib/guard/status-tool.d.ts +54 -0
  48. package/lib/guard/status-tool.js +195 -0
  49. package/lib/guard/tiers.d.ts +2 -0
  50. package/lib/guard/tiers.js +1 -0
  51. package/lib/guard/validators.d.ts +4 -0
  52. package/lib/guard/validators.js +45 -0
  53. package/lib/health-poller.d.ts +90 -0
  54. package/lib/health-poller.js +430 -0
  55. package/lib/index.d.ts +7 -0
  56. package/lib/index.js +7 -0
  57. package/lib/intents.d.ts +32 -0
  58. package/lib/intents.js +49 -0
  59. package/lib/notifier.d.ts +12 -0
  60. package/lib/notifier.js +62 -0
  61. package/lib/paths.d.ts +13 -0
  62. package/lib/paths.js +70 -0
  63. package/lib/plugin.d.ts +250 -0
  64. package/lib/plugin.js +1126 -0
  65. package/lib/preset.d.ts +73 -0
  66. package/lib/preset.js +158 -0
  67. package/lib/report.d.ts +11 -0
  68. package/lib/report.js +58 -0
  69. package/lib/restart-exec.d.ts +35 -0
  70. package/lib/restart-exec.js +60 -0
  71. package/lib/restart-guards.d.ts +39 -0
  72. package/lib/restart-guards.js +150 -0
  73. package/lib/restart-tool.d.ts +124 -0
  74. package/lib/restart-tool.js +539 -0
  75. package/lib/restart-web.d.ts +26 -0
  76. package/lib/restart-web.js +58 -0
  77. package/lib/resume-log.d.ts +24 -0
  78. package/lib/resume-log.js +18 -0
  79. package/lib/resume-tools.d.ts +131 -0
  80. package/lib/resume-tools.js +337 -0
  81. package/lib/resume.d.ts +33 -0
  82. package/lib/resume.js +221 -0
  83. package/lib/scan.d.ts +20 -0
  84. package/lib/scan.js +71 -0
  85. package/lib/self-kill-guard.d.ts +81 -0
  86. package/lib/self-kill-guard.js +208 -0
  87. package/lib/session-health.d.ts +89 -0
  88. package/lib/session-health.js +274 -0
  89. package/lib/session-log-file.d.ts +22 -0
  90. package/lib/session-log-file.js +74 -0
  91. package/lib/skill-provider.d.ts +6 -0
  92. package/lib/skill-provider.js +73 -0
  93. package/lib/snapshot.d.ts +59 -0
  94. package/lib/snapshot.js +358 -0
  95. package/lib/source.d.ts +19 -0
  96. package/lib/source.js +19 -0
  97. package/lib/store/index.d.ts +42 -0
  98. package/lib/store/index.js +340 -0
  99. package/lib/store/legacy.d.ts +17 -0
  100. package/lib/store/legacy.js +85 -0
  101. package/lib/supervisor.d.ts +119 -0
  102. package/lib/supervisor.js +741 -0
  103. package/lib/sync/backup-config.d.ts +55 -0
  104. package/lib/sync/backup-config.js +119 -0
  105. package/lib/sync/backup-service.d.ts +110 -0
  106. package/lib/sync/backup-service.js +440 -0
  107. package/lib/sync/bidirectional.d.ts +39 -0
  108. package/lib/sync/bidirectional.js +25 -0
  109. package/lib/sync/cli.d.ts +38 -0
  110. package/lib/sync/cli.js +536 -0
  111. package/lib/sync/config.d.ts +77 -0
  112. package/lib/sync/config.js +90 -0
  113. package/lib/sync/fingerprint.d.ts +29 -0
  114. package/lib/sync/fingerprint.js +65 -0
  115. package/lib/sync/hashing.d.ts +9 -0
  116. package/lib/sync/hashing.js +47 -0
  117. package/lib/sync/index.d.ts +6 -0
  118. package/lib/sync/index.js +634 -0
  119. package/lib/sync/machine-id.d.ts +29 -0
  120. package/lib/sync/machine-id.js +66 -0
  121. package/lib/sync/merge.d.ts +33 -0
  122. package/lib/sync/merge.js +88 -0
  123. package/lib/sync/peer-host.d.ts +22 -0
  124. package/lib/sync/peer-host.js +62 -0
  125. package/lib/sync/process-runner.d.ts +31 -0
  126. package/lib/sync/process-runner.js +161 -0
  127. package/lib/sync/remote-agent.d.ts +42 -0
  128. package/lib/sync/remote-agent.js +217 -0
  129. package/lib/sync/remote-cache.d.ts +18 -0
  130. package/lib/sync/remote-cache.js +60 -0
  131. package/lib/sync/remote-manifest.d.ts +8 -0
  132. package/lib/sync/remote-manifest.js +64 -0
  133. package/lib/sync/s3-object-store.d.ts +38 -0
  134. package/lib/sync/s3-object-store.js +126 -0
  135. package/lib/sync/session-merge.d.ts +18 -0
  136. package/lib/sync/session-merge.js +191 -0
  137. package/lib/sync/session-plan.d.ts +29 -0
  138. package/lib/sync/session-plan.js +213 -0
  139. package/lib/sync/sigv4.d.ts +20 -0
  140. package/lib/sync/sigv4.js +57 -0
  141. package/lib/sync/snapshot.d.ts +21 -0
  142. package/lib/sync/snapshot.js +176 -0
  143. package/lib/sync/ssh-mux.d.ts +12 -0
  144. package/lib/sync/ssh-mux.js +48 -0
  145. package/lib/sync/sync-plan.d.ts +24 -0
  146. package/lib/sync/sync-plan.js +366 -0
  147. package/lib/sync/sync-service.d.ts +177 -0
  148. package/lib/sync/sync-service.js +819 -0
  149. package/lib/sync/sync-types.d.ts +87 -0
  150. package/lib/sync/sync-types.js +1 -0
  151. package/lib/sync/transport.d.ts +75 -0
  152. package/lib/sync/transport.js +200 -0
  153. package/lib/sync/tunnel-restore.d.ts +77 -0
  154. package/lib/sync/tunnel-restore.js +142 -0
  155. package/lib/sync/validation.d.ts +10 -0
  156. package/lib/sync/validation.js +83 -0
  157. package/lib/tool-view.d.ts +62 -0
  158. package/lib/tool-view.js +70 -0
  159. package/lib/types/client/auto-reload.d.ts +8 -0
  160. package/lib/types/client/auto-reload.d.ts.map +1 -0
  161. package/lib/types/client/config/MaestroSettings.d.ts +25 -0
  162. package/lib/types/client/config/MaestroSettings.d.ts.map +1 -0
  163. package/lib/types/client/config/components/BrandMark.d.ts +50 -0
  164. package/lib/types/client/config/components/BrandMark.d.ts.map +1 -0
  165. package/lib/types/client/config/guard-view.d.ts +83 -0
  166. package/lib/types/client/config/guard-view.d.ts.map +1 -0
  167. package/lib/types/client/config/index.d.ts +20 -0
  168. package/lib/types/client/config/index.d.ts.map +1 -0
  169. package/lib/types/client/config/maestro-mark.d.ts +29 -0
  170. package/lib/types/client/config/maestro-mark.d.ts.map +1 -0
  171. package/lib/types/client/config/settings-nav-icon.d.ts +21 -0
  172. package/lib/types/client/config/settings-nav-icon.d.ts.map +1 -0
  173. package/lib/types/client/index.d.ts +16 -0
  174. package/lib/types/client/index.d.ts.map +1 -0
  175. package/lib/types/client/sync/R2SyncPanel.d.ts +6 -0
  176. package/lib/types/client/sync/R2SyncPanel.d.ts.map +1 -0
  177. package/lib/types/client/sync/SyncPanel.d.ts +12 -0
  178. package/lib/types/client/sync/SyncPanel.d.ts.map +1 -0
  179. package/lib/types/client/sync/confirm-dialog.d.ts +43 -0
  180. package/lib/types/client/sync/confirm-dialog.d.ts.map +1 -0
  181. package/lib/types/client/sync/index.d.ts +10 -0
  182. package/lib/types/client/sync/index.d.ts.map +1 -0
  183. package/lib/types/client/sync/ui.d.ts +79 -0
  184. package/lib/types/client/sync/ui.d.ts.map +1 -0
  185. package/lib/types/client/sync/use-backup.d.ts +50 -0
  186. package/lib/types/client/sync/use-backup.d.ts.map +1 -0
  187. package/lib/types/client/sync/use-sync.d.ts +88 -0
  188. package/lib/types/client/sync/use-sync.d.ts.map +1 -0
  189. package/package.json +89 -0
  190. package/skills/dsh-safe-restart/SKILL.md +206 -0
  191. package/skills/dsh-safe-restart/scripts/restart-dsh-web.sh +468 -0
  192. package/src/client/auto-reload.ts +104 -0
  193. package/src/client/config/MaestroSettings.tsx +892 -0
  194. package/src/client/config/components/BrandMark.tsx +94 -0
  195. package/src/client/config/guard-view.ts +187 -0
  196. package/src/client/config/index.tsx +109 -0
  197. package/src/client/config/maestro-mark.ts +37 -0
  198. package/src/client/config/settings-nav-icon.ts +68 -0
  199. package/src/client/index.tsx +33 -0
  200. package/src/client/sync/R2SyncPanel.tsx +260 -0
  201. package/src/client/sync/SyncPanel.tsx +422 -0
  202. package/src/client/sync/confirm-dialog.tsx +202 -0
  203. package/src/client/sync/index.tsx +336 -0
  204. package/src/client/sync/ui.tsx +313 -0
  205. package/src/client/sync/use-backup.ts +207 -0
  206. package/src/client/sync/use-sync.ts +502 -0
  207. package/src/host/bin.ts +3 -0
  208. package/src/host/boot-guard.ts +76 -0
  209. package/src/host/boot-lock.ts +155 -0
  210. package/src/host/cli.ts +288 -0
  211. package/src/host/config/index.ts +78 -0
  212. package/src/host/config/service.ts +40 -0
  213. package/src/host/config.ts +18 -0
  214. package/src/host/daemon-freshness.ts +143 -0
  215. package/src/host/debug-agent.ts +145 -0
  216. package/src/host/dsh-session.ts +56 -0
  217. package/src/host/dsh-skill.d.ts +44 -0
  218. package/src/host/guard/augment.d.ts +33 -0
  219. package/src/host/guard/config.ts +244 -0
  220. package/src/host/guard/decide.ts +40 -0
  221. package/src/host/guard/full-scan-tool.ts +61 -0
  222. package/src/host/guard/index.ts +281 -0
  223. package/src/host/guard/journal.ts +440 -0
  224. package/src/host/guard/migrate.ts +41 -0
  225. package/src/host/guard/parse.ts +1150 -0
  226. package/src/host/guard/paths.ts +239 -0
  227. package/src/host/guard/permission-policy.ts +15 -0
  228. package/src/host/guard/redact.ts +64 -0
  229. package/src/host/guard/rules.ts +891 -0
  230. package/src/host/guard/status-tool.ts +229 -0
  231. package/src/host/guard/tiers.ts +2 -0
  232. package/src/host/guard/validators.ts +29 -0
  233. package/src/host/health-poller.ts +446 -0
  234. package/src/host/index.ts +7 -0
  235. package/src/host/intents.ts +67 -0
  236. package/src/host/notifier.ts +71 -0
  237. package/src/host/paths.ts +70 -0
  238. package/src/host/plugin.ts +1097 -0
  239. package/src/host/preset.ts +170 -0
  240. package/src/host/report.ts +71 -0
  241. package/src/host/restart-exec.ts +81 -0
  242. package/src/host/restart-guards.ts +150 -0
  243. package/src/host/restart-tool.ts +483 -0
  244. package/src/host/restart-web.ts +72 -0
  245. package/src/host/resume-log.ts +39 -0
  246. package/src/host/resume-tools.ts +385 -0
  247. package/src/host/resume.ts +204 -0
  248. package/src/host/scan.ts +61 -0
  249. package/src/host/self-kill-guard.ts +216 -0
  250. package/src/host/session-health.ts +236 -0
  251. package/src/host/session-log-file.ts +77 -0
  252. package/src/host/skill-provider.ts +69 -0
  253. package/src/host/snapshot.ts +337 -0
  254. package/src/host/source.ts +19 -0
  255. package/src/host/store/index.ts +348 -0
  256. package/src/host/store/legacy.ts +96 -0
  257. package/src/host/supervisor.ts +720 -0
  258. package/src/host/sync/backup-config.ts +159 -0
  259. package/src/host/sync/backup-service.ts +453 -0
  260. package/src/host/sync/bidirectional.ts +66 -0
  261. package/src/host/sync/cli.ts +539 -0
  262. package/src/host/sync/config.ts +119 -0
  263. package/src/host/sync/fingerprint.ts +83 -0
  264. package/src/host/sync/hashing.ts +58 -0
  265. package/src/host/sync/index.ts +737 -0
  266. package/src/host/sync/machine-id.ts +81 -0
  267. package/src/host/sync/merge.ts +102 -0
  268. package/src/host/sync/peer-host.ts +65 -0
  269. package/src/host/sync/process-runner.ts +177 -0
  270. package/src/host/sync/remote-agent.ts +213 -0
  271. package/src/host/sync/remote-cache.ts +68 -0
  272. package/src/host/sync/remote-manifest.ts +70 -0
  273. package/src/host/sync/s3-object-store.ts +144 -0
  274. package/src/host/sync/session-merge.ts +220 -0
  275. package/src/host/sync/session-plan.ts +237 -0
  276. package/src/host/sync/sigv4.ts +81 -0
  277. package/src/host/sync/snapshot.ts +162 -0
  278. package/src/host/sync/ssh-mux.ts +56 -0
  279. package/src/host/sync/sync-plan.ts +366 -0
  280. package/src/host/sync/sync-service.ts +855 -0
  281. package/src/host/sync/sync-types.ts +102 -0
  282. package/src/host/sync/transport.ts +261 -0
  283. package/src/host/sync/tunnel-restore.ts +160 -0
  284. package/src/host/sync/validation.ts +91 -0
  285. package/src/host/tool-view.ts +98 -0
@@ -0,0 +1,336 @@
1
+ /**
2
+ * dsh-maestro-sync — client bundle entry.
3
+ * Single registration: settings.section id maestro-sync (Minimalism & Swiss,
4
+ * mobile-first). The settings card is the complete Sync UI — connection,
5
+ * stats, paged file lists, and the confirmation-first Preview/Apply flow:
6
+ * preview is read-only; apply exists only inside a dialog bound to the live
7
+ * preview id (confirm:true). All colors/geometry via --dsw-alias-* tokens;
8
+ * the only fixed hex is the shared Maestro logo tile #0A84FF (branding rule).
9
+ */
10
+ import * as React from 'react'
11
+ import { SyncPanel } from './SyncPanel.js'
12
+
13
+ export const inject = ['slots', 'connection'] as const
14
+
15
+ const SETTINGS_NAV_MARKER = 'data-maestro-sync-settings-nav'
16
+ const SETTINGS_NAV_CSS = `
17
+ [${SETTINGS_NAV_MARKER}] > svg:first-child,
18
+ [${SETTINGS_NAV_MARKER}] > svg.zWKi1a_navIcon {
19
+ display: none !important;
20
+ }
21
+ [${SETTINGS_NAV_MARKER}]::before {
22
+ content: '';
23
+ flex: none;
24
+ width: 16px;
25
+ height: 16px;
26
+ display: inline-block;
27
+ background: currentColor;
28
+ -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2 11 L5 4 L8 9 L11 4 L14 11'/%3E%3C/svg%3E") center / contain no-repeat;
29
+ mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2 11 L5 4 L8 9 L11 4 L14 11'/%3E%3C/svg%3E") center / contain no-repeat;
30
+ }
31
+ `
32
+
33
+ function registerSyncNavIcon(label: () => string, root?: any): () => void {
34
+ if (typeof document === 'undefined' && root === undefined) return () => {}
35
+ const scope: any = root ?? document
36
+ let disposed = false
37
+ const sync = () => {
38
+ if (disposed) return
39
+ const currentLabel = label().trim()
40
+ const buttons = scope.querySelectorAll('[role="dialog"] nav button')
41
+ for (const button of Array.from(buttons as any) as Element[]) {
42
+ const el = button as any
43
+ const matches = currentLabel.length > 0 && (button as Element).textContent != null && (button as Element).textContent!.trim() === currentLabel
44
+ if (matches) el.setAttribute(SETTINGS_NAV_MARKER, '')
45
+ else el.removeAttribute(SETTINGS_NAV_MARKER)
46
+ }
47
+ }
48
+ sync()
49
+ let observer: MutationObserver | null = null
50
+ if (typeof MutationObserver !== 'undefined') {
51
+ observer = new MutationObserver(sync)
52
+ observer.observe(document.body, { childList: true, subtree: true, characterData: true })
53
+ }
54
+ return () => {
55
+ disposed = true
56
+ if (observer !== null) observer.disconnect()
57
+ for (const element of Array.from(scope.querySelectorAll(`[${SETTINGS_NAV_MARKER}]`) as any)) {
58
+ ;(element as any).removeAttribute(SETTINGS_NAV_MARKER)
59
+ }
60
+ }
61
+ }
62
+
63
+ function installStyleTag(css: string, pluginCss: string): () => void {
64
+ if (typeof document === 'undefined') return () => {}
65
+ const tag = document.createElement('style')
66
+ tag.dataset.plugin = '@ddtcorex/dsh-maestro-sync'
67
+ tag.dataset.pluginCss = pluginCss
68
+ tag.textContent = css
69
+ document.head.appendChild(tag)
70
+ return () => {
71
+ document.querySelector(`style[data-plugin-css="${pluginCss}"]`)?.remove()
72
+ }
73
+ }
74
+
75
+ // ---------------------------------------------------------------------------
76
+ // Sync UI CSS — token-native, mobile-first (375 → 480 → 640 → 1024 → 1440)
77
+ // ---------------------------------------------------------------------------
78
+ const SYNC_CSS = `
79
+ [data-sync-root], [data-sync-root] * { box-sizing: border-box; }
80
+ [data-sync-root] { display: flex; flex-direction: column; gap: 12px; color: var(--dsw-alias-label-primary); font-size: 13px; line-height: 1.5; min-width: 0; width: 100%; max-width: 640px; }
81
+
82
+ /* connection banner */
83
+ [data-sync-conn] { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--dsw-alias-border-l1); background: var(--dsw-alias-bg-layer-2); }
84
+ [data-sync-conn][data-state="bad"] { border-color: var(--dsw-alias-state-error-primary, #DC2626); }
85
+ [data-sync-conn-dot] { flex: none; width: 8px; height: 8px; border-radius: 50%; margin-top: 5px; }
86
+ [data-sync-conn][data-state="ok"] [data-sync-conn-dot] { background: var(--dsw-alias-state-success-primary, #16A34A); box-shadow: 0 0 0 4px color-mix(in srgb, var(--dsw-alias-state-success-primary, #16A34A) 16%, transparent); }
87
+ [data-sync-conn][data-state="bad"] [data-sync-conn-dot] { background: var(--dsw-alias-state-error-primary, #DC2626); box-shadow: 0 0 0 4px color-mix(in srgb, var(--dsw-alias-state-error-primary, #DC2626) 12%, transparent); }
88
+ [data-sync-conn][data-state="checking"] [data-sync-conn-dot] { background: var(--dsw-alias-label-secondary); opacity: 0.6; }
89
+ [data-sync-conn-main] { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
90
+ [data-sync-conn-title] { font-size: 12px; font-weight: 600; line-height: 16px; }
91
+ [data-sync-conn-desc] { font-size: 11px; line-height: 14px; color: var(--dsw-alias-label-secondary); word-break: break-word; }
92
+
93
+ /* identity fields */
94
+ [data-sync-fields] { display: flex; gap: 10px; flex-wrap: wrap; }
95
+ [data-sync-field] { flex: 1 1 160px; min-width: 0; border: 1px solid var(--dsw-alias-border-l1); border-radius: 8px; background: var(--dsw-alias-bg-layer-2); padding: 8px 10px; }
96
+ [data-sync-field-label] { font-size: 11px; color: var(--dsw-alias-label-secondary); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; display: block; }
97
+ [data-sync-field-value] { font-size: 13px; font-weight: 600; word-break: break-all; margin-top: 2px; display: block; }
98
+
99
+ /* stat tiles */
100
+ [data-sync-stats] { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
101
+ [data-sync-stat] { display: flex; flex-direction: column; gap: 4px; min-width: 0; border: 1px solid var(--dsw-alias-border-l1); border-radius: 10px; background: var(--dsw-alias-bg-layer-2); padding: 10px 12px; text-align: left; font: inherit; cursor: default; color: inherit; }
102
+ button[data-sync-stat] { cursor: pointer; }
103
+ button[data-sync-stat]:hover { border-color: var(--dsw-alias-border-l2); background: var(--dsw-alias-bg-layer-3); }
104
+ button[data-sync-stat]:focus-visible { outline: 2px solid var(--dsw-alias-border-l2); outline-offset: 2px; }
105
+ [data-sync-stat-icon] { display: inline-flex; color: var(--dsw-alias-label-tertiary); }
106
+ [data-sync-stat-value] { font-size: 22px; font-weight: 700; line-height: 1; letter-spacing: -0.02em; }
107
+ [data-sync-stat-label] { font-size: 12px; font-weight: 600; line-height: 16px; }
108
+ [data-sync-stat-hint] { font-size: 10px; line-height: 13px; color: var(--dsw-alias-label-tertiary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
109
+
110
+ /* actions */
111
+ [data-sync-actions] { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
112
+
113
+ /* preview progress — live per-file ticks while sessions are counted */
114
+ [data-sync-progress] { display: flex; flex-direction: column; gap: 6px; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--dsw-alias-border-l1); background: var(--dsw-alias-bg-layer-2); }
115
+ [data-sync-progress-meta] { font-size: 11px; line-height: 14px; color: var(--dsw-alias-label-secondary); word-break: break-word; }
116
+ [data-sync-progress-track] { display: block; height: 4px; border-radius: 999px; background: var(--dsw-alias-bg-layer-3); overflow: hidden; }
117
+ [data-sync-progress-fill] { display: block; height: 100%; border-radius: 999px; background: var(--dsw-alias-state-info-primary, #0A84FF); transition: width 0.3s ease; }
118
+ @media (prefers-reduced-motion: reduce) { [data-sync-progress-fill] { transition: none; } }
119
+
120
+ /* dialog session counts — counted by checksum, no per-file rows */
121
+ [data-sync-sessioncounts] { display: flex; flex-direction: column; gap: 2px; padding: 8px 12px; border-radius: 8px; border: 1px dashed var(--dsw-alias-border-l2); background: var(--dsw-alias-bg-layer-2); margin-bottom: 6px; }
122
+ [data-sync-sessioncounts-lbl] { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--dsw-alias-label-primary); }
123
+ [data-sync-sessioncounts-line] { font-size: 11px; line-height: 14px; color: var(--dsw-alias-label-secondary); }
124
+
125
+ /* notice / error */
126
+ [data-sync-notice] { display: flex; align-items: flex-start; gap: 8px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--dsw-alias-border-l1); background: var(--dsw-alias-bg-layer-2); }
127
+ [data-sync-notice][data-tone="bad"] { border-color: var(--dsw-alias-state-error-primary, #DC2626); }
128
+ [data-sync-notice-icon] { display: inline-flex; color: var(--dsw-alias-label-tertiary); margin-top: 1px; }
129
+ [data-sync-notice][data-tone="bad"] [data-sync-notice-icon] { color: var(--dsw-alias-state-error-primary, #DC2626); }
130
+ [data-sync-notice][data-tone="ok"] [data-sync-notice-icon] { color: var(--dsw-alias-state-success-primary, #16A34A); }
131
+ [data-sync-notice-main] { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
132
+ [data-sync-notice-title] { font-size: 12px; font-weight: 600; }
133
+ [data-sync-notice-desc] { font-size: 11px; line-height: 14px; color: var(--dsw-alias-label-secondary); word-break: break-word; }
134
+
135
+ /* badges */
136
+ [data-sync-badge] { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 600; color: var(--dsw-alias-label-secondary); background: var(--dsw-alias-bg-layer-2); border: 1px solid var(--dsw-alias-border-l1); border-radius: 999px; padding: 2px 8px; white-space: nowrap; }
137
+ [data-sync-badge][data-tone="brand"] { color: var(--dsw-alias-label-primary); border-color: var(--dsw-alias-border-l2); }
138
+ [data-sync-badge][data-tone="success"] { color: var(--dsw-alias-state-success-primary); }
139
+ [data-sync-badge][data-tone="error"] { color: var(--dsw-alias-state-error-primary); border-color: var(--dsw-alias-state-error-primary); }
140
+ [data-sync-badge][data-tone="warn"] { color: var(--dsw-alias-state-warn-primary); }
141
+
142
+ [data-sync-muted] { color: var(--dsw-alias-label-secondary); font-size: 11px; line-height: 14px; }
143
+
144
+ /* ---- confirmation dialog: bottom sheet on mobile, centered card ≥640 ---- */
145
+ [data-sync-dialog-overlay] { position: fixed; inset: 0; z-index: 1000; background: color-mix(in srgb, var(--dsw-alias-bg-base, #000) 55%, transparent); display: flex; align-items: flex-end; justify-content: center; }
146
+ [data-sync-dialog] { width: 100%; max-width: 560px; max-height: 88dvh; overflow: auto; border: 1px solid var(--dsw-alias-border-l2); border-radius: 16px 16px 0 0; background: var(--dsw-alias-bg-layer-1); box-shadow: 0 -16px 50px rgba(0, 0, 0, 0.3); padding: 16px; display: flex; flex-direction: column; gap: 12px; }
147
+ [data-sync-dialog-top] { display: flex; align-items: flex-start; gap: 8px; }
148
+ [data-sync-dialog-heading] { flex: 1; min-width: 0; }
149
+ [data-sync-dialog-title] { font-size: 14px; font-weight: 700; letter-spacing: -0.01em; line-height: 20px; }
150
+ [data-sync-dialog-desc] { font-size: 12px; line-height: 16px; color: var(--dsw-alias-label-secondary); margin-top: 2px; }
151
+ [data-sync-dialog-close] { flex: none; width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--dsw-alias-border-l1); border-radius: 8px; background: var(--dsw-alias-bg-layer-2); color: var(--dsw-alias-label-secondary); cursor: pointer; padding: 0; }
152
+ [data-sync-dialog-close]:hover { color: var(--dsw-alias-label-primary); border-color: var(--dsw-alias-border-l2); }
153
+ [data-sync-dialog-close]:focus-visible { outline: 2px solid var(--dsw-alias-border-l2); outline-offset: 2px; }
154
+ [data-sync-planlist] { display: flex; flex-direction: column; border: 1px solid var(--dsw-alias-border-l1); border-radius: 10px; overflow: hidden; }
155
+ [data-sync-planrow] { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--dsw-alias-border-l1); background: var(--dsw-alias-bg-layer-1); }
156
+ [data-sync-planrow]:last-child { border-bottom: none; }
157
+ [data-sync-planfile-icon] { display: inline-flex; flex: none; }
158
+ [data-sync-planfile] { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
159
+ [data-sync-planfile-title] { font-size: 12px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
160
+ [data-sync-planfile-path] { font-size: 11px; color: var(--dsw-alias-label-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
161
+ [data-sync-planrow-meta] { flex: none; }
162
+ [data-sync-planmore] { display: flex; justify-content: center; padding: 8px; }
163
+ [data-sync-empty] { padding: 16px 12px; text-align: center; color: var(--dsw-alias-label-secondary); font-size: 12px; line-height: 16px; }
164
+ [data-sync-loading] { padding: 16px 12px; text-align: center; color: var(--dsw-alias-label-tertiary); font-size: 12px; line-height: 16px; }
165
+ [data-sync-dialog-actions] { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
166
+
167
+ /* ---- file list sections (in-card) ---- */
168
+ [data-sync-filetables] { display: grid; grid-template-columns: 1fr; gap: 12px; }
169
+ @media (min-width: 1024px) {
170
+ [data-sync-filetables] { grid-template-columns: 1fr 1fr; }
171
+ }
172
+ [data-sync-dcol] { display: flex; flex-direction: column; border: 1px solid var(--dsw-alias-border-l1); border-radius: 12px; background: var(--dsw-alias-bg-layer-1); overflow: hidden; min-width: 0; }
173
+ [data-sync-dcol-head] { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--dsw-alias-border-l1); background: var(--dsw-alias-bg-layer-2); }
174
+ [data-sync-dcol-title] { font-size: 12px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
175
+ [data-sync-dcol-count] { font-size: 11px; font-weight: 600; color: var(--dsw-alias-label-secondary); background: var(--dsw-alias-bg-layer-1); border: 1px solid var(--dsw-alias-border-l1); border-radius: 999px; padding: 2px 8px; }
176
+ [data-sync-file] { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--dsw-alias-border-l1); font-size: 12px; min-width: 0; }
177
+ [data-sync-file]:last-child { border-bottom: none; }
178
+ [data-sync-file-icon] { display: inline-flex; flex: none; color: var(--dsw-alias-label-tertiary); }
179
+ [data-sync-file-main] { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
180
+ [data-sync-file-title] { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 12px; }
181
+ [data-sync-file-path] { font-size: 11px; color: var(--dsw-alias-label-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
182
+ [data-sync-file-meta] { flex: none; font-size: 11px; color: var(--dsw-alias-label-secondary); background: var(--dsw-alias-bg-layer-2); border: 1px solid var(--dsw-alias-border-l1); border-radius: 6px; padding: 1px 6px; white-space: nowrap; }
183
+ [data-sync-dcol-foot] { display: flex; justify-content: center; padding: 8px; border-top: 1px solid var(--dsw-alias-border-l1); background: var(--dsw-alias-bg-layer-2); }
184
+
185
+ /* spinner */
186
+ @keyframes sync-spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
187
+ .sync-spin { display: inline-block; animation: sync-spin 0.8s linear infinite; font-size: 14px; line-height: 1; }
188
+
189
+ /* ---- breakpoints ---- */
190
+ @media (max-width: 640px) {
191
+ [data-sync-fields] { gap: 8px; }
192
+ [data-sync-field] { flex: 1 1 0; min-width: 0; padding: 7px 8px; border-radius: 8px; }
193
+ [data-sync-field-label] { font-size: 10px; line-height: 12px; }
194
+ [data-sync-field-value] { font-size: 12px; line-height: 14px; }
195
+ }
196
+ @media (max-width: 480px) {
197
+ [data-sync-actions] > [data-sync-btn] { flex: 1 1 auto; }
198
+ [data-sync-fields] { flex-direction: row; gap: 6px; }
199
+ [data-sync-field] { flex: 1 1 0; min-width: 0; padding: 6px 8px; border-radius: 8px; }
200
+ [data-sync-field-label] { font-size: 10px; line-height: 11px; }
201
+ [data-sync-field-value] { font-size: 11px; line-height: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; word-break: normal; }
202
+ }
203
+ @media (min-width: 640px) {
204
+ [data-sync-dialog-overlay] { align-items: center; padding: 24px; }
205
+ [data-sync-dialog] { border-radius: 14px; box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35); }
206
+ }
207
+ @media (min-width: 1024px) {
208
+ [data-sync-dash-content] { padding: 20px; }
209
+ }
210
+ @media (max-width: 390px) {
211
+ [data-sync-card] { padding: 12px; }
212
+ }
213
+ @media (prefers-reduced-motion: reduce) {
214
+ [data-sync-root] *, [data-sync-dialog] * { transition: none !important; animation: none !important; }
215
+ .sync-spin { animation: none; }
216
+ }
217
+
218
+ /* ---- mobile-first (2026-09-03): thumb reach, disclosure, touch targets ---- */
219
+ [data-sync-shell] { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
220
+ /* mode tabs — pill bar, 44px touch height on every viewport */
221
+ [data-sync-tabs] { display: flex; gap: 4px; padding: 3px; border-radius: 999px; border: 1px solid var(--dsw-alias-border-l1); background: var(--dsw-alias-bg-layer-2); }
222
+ [data-sync-tab] { flex: 1 1 0; min-height: 44px; padding: 0 14px; border: 0; border-radius: 999px; background: transparent; color: var(--dsw-alias-label-secondary); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
223
+ [data-sync-tab][aria-selected="true"] { background: var(--dsw-alias-bg-layer-1); color: var(--dsw-alias-label-primary); box-shadow: inset 0 0 0 1px var(--dsw-alias-border-l1); }
224
+ [data-sync-tab]:focus-visible { outline: 2px solid var(--dsw-alias-border-l2); outline-offset: 2px; }
225
+ /* collapsible bucket header toggle (header padding moves onto the button) */
226
+ [data-sync-dcol-head] { padding: 0; }
227
+ [data-sync-dcol-toggle] { all: unset; display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; min-height: 44px; padding: 10px 12px; cursor: pointer; box-sizing: border-box; font: inherit; color: inherit; }
228
+ [data-sync-dcol-toggle]:focus-visible { outline: 2px solid var(--dsw-alias-border-l2); outline-offset: -2px; }
229
+ /* R2 actions: primary + More menu (menu never overflows 360px) */
230
+ [data-r2-actions] { display: flex; gap: 8px; flex-wrap: wrap; align-items: stretch; }
231
+ [data-r2-actions] > [data-sync-btn] { flex: 2 1 0; }
232
+ [data-r2-more] { position: relative; flex: 1 1 0; display: flex; }
233
+ [data-r2-more] > [data-sync-btn] { flex: 1 1 auto; width: 100%; }
234
+ [data-r2-more-menu] { position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; min-width: 220px; max-width: calc(100vw - 48px); display: flex; flex-direction: column; gap: 2px; padding: 6px; border: 1px solid var(--dsw-alias-border-l2); border-radius: 12px; background: var(--dsw-alias-bg-layer-1); box-shadow: var(--dsw-shadow-lv3); }
235
+ [data-r2-more-menu] > [data-sync-btn] { justify-content: flex-start; width: 100%; }
236
+ /* sticky thumb-reach bars + condensed stats on narrow screens */
237
+ @media (max-width: 640px) {
238
+ [data-sync-actions-bar] { position: sticky; bottom: 0; z-index: 10; padding: 10px 2px calc(10px + env(safe-area-inset-bottom, 0px)); background: color-mix(in srgb, var(--dsw-alias-bg-base, #fff) 92%, transparent); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
239
+ [data-sync-actions-bar] > [data-sync-btn] { flex: 1 1 0; min-height: 48px !important; font-size: 14px; }
240
+ [data-sync-actions-bar] [data-r2-more] > [data-sync-btn] { min-height: 48px !important; }
241
+ [data-sync-dialog-actions] { position: sticky; bottom: 0; padding: 10px 0 calc(4px + env(safe-area-inset-bottom, 0px)); background: var(--dsw-alias-bg-layer-1); }
242
+ [data-sync-dialog-actions] > [data-sync-btn]:last-child { flex: 1 1 100%; min-height: 48px !important; }
243
+ [data-sync-stats] { gap: 6px; }
244
+ [data-sync-stat] { padding: 8px 10px; }
245
+ }
246
+ /* coarse pointers: 40–44px targets (inline min-heights need !important) */
247
+ @media (pointer: coarse) {
248
+ [data-sync-btn][data-size="sm"] { min-height: 40px !important; }
249
+ [data-sync-btn][data-size="md"], [data-sync-btn]:not([data-size]) { min-height: 44px !important; }
250
+ [data-sync-dialog-close] { width: 40px; height: 40px; }
251
+ }
252
+ @media (max-width: 390px) {
253
+ [data-sync-stat-value] { font-size: 18px; }
254
+ [data-sync-stat-hint] { display: none; }
255
+ }
256
+ /* SSH configuration — user-filled target, explicit check, nothing auto-probes */
257
+ [data-sync-ssh] { display: flex; flex-direction: column; gap: 8px; padding: 10px 12px; border: 1px solid var(--dsw-alias-border-l1); border-radius: 10px; background: var(--dsw-alias-bg-layer-2); }
258
+ [data-sync-ssh-label] { font-size: 11px; color: var(--dsw-alias-label-secondary); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
259
+ [data-sync-ssh-input] { min-height: 44px; padding: 0 12px; border: 1px solid var(--dsw-alias-border-l2); border-radius: 10px; background: var(--dsw-alias-bg-layer-1); color: var(--dsw-alias-label-primary); font: inherit; font-size: 13px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; width: 100%; box-sizing: border-box; }
260
+ [data-sync-ssh-input]:focus-visible { outline: 2px solid var(--dsw-alias-border-l2); outline-offset: 2px; }
261
+ [data-sync-ssh-input]:disabled { opacity: 0.6; }
262
+ [data-sync-ssh-row] { display: flex; gap: 8px; flex-wrap: wrap; }
263
+ [data-sync-ssh-row] > [data-sync-btn] { flex: 1 1 0; }
264
+ [data-sync-ssh-src] { font-size: 11px; line-height: 14px; color: var(--dsw-alias-label-secondary); }
265
+ /* R2 status banner — badge + hint need a real gap (was running together) */
266
+ [data-r2-summary] { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
267
+ /* R2 backup-target form — same language as the SSH section */
268
+ [data-r2-config] { display: flex; flex-direction: column; gap: 8px; padding: 10px 12px; border: 1px solid var(--dsw-alias-border-l1); border-radius: 10px; background: var(--dsw-alias-bg-layer-2); }
269
+ [data-r2-config-label] { font-size: 11px; color: var(--dsw-alias-label-secondary); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
270
+ [data-r2-field] { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
271
+ [data-r2-field-label] { font-size: 12px; font-weight: 600; color: var(--dsw-alias-label-primary); }
272
+ [data-r2-field-input] { min-height: 44px; padding: 0 12px; border: 1px solid var(--dsw-alias-border-l2); border-radius: 10px; background: var(--dsw-alias-bg-layer-1); color: var(--dsw-alias-label-primary); font: inherit; font-size: 13px; width: 100%; box-sizing: border-box; }
273
+ [data-r2-field-input]:focus-visible { outline: 2px solid var(--dsw-alias-border-l2); outline-offset: 2px; }
274
+ [data-r2-field-input]:disabled { opacity: 0.6; }
275
+ [data-r2-field-hint] { font-size: 11px; line-height: 14px; color: var(--dsw-alias-label-tertiary); }
276
+ /* Field-level validation feedback: the message must sit under the input it
277
+ names, not only in the panel-wide banner. */
278
+ [data-r2-field-error] { font-size: 11px; line-height: 15px; color: var(--dsw-alias-state-error-primary); overflow-wrap: anywhere; }
279
+ [data-r2-field-input][aria-invalid="true"] { border-color: var(--dsw-alias-state-error-primary); }
280
+ [data-sync-field-error] { font-size: 12px; line-height: 16px; color: var(--dsw-alias-state-error-primary); overflow-wrap: anywhere; }
281
+ [data-sync-ssh-input][aria-invalid="true"] { border-color: var(--dsw-alias-state-error-primary); }
282
+ [data-r2-provider-row] { display: flex; gap: 8px; }
283
+ [data-r2-provider-opt] { flex: 1 1 0; min-height: 44px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--dsw-alias-border-l2); background: transparent; color: var(--dsw-alias-label-secondary); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
284
+ [data-r2-provider-opt][aria-pressed="true"] { background: var(--dsw-alias-bg-layer-1); color: var(--dsw-alias-label-primary); box-shadow: inset 0 0 0 1px var(--dsw-alias-border-l1); }
285
+ [data-r2-provider-opt]:focus-visible { outline: 2px solid var(--dsw-alias-border-l2); outline-offset: 2px; }
286
+ [data-r2-config-row] { display: flex; gap: 8px; }
287
+ [data-r2-config-row] > [data-sync-btn] { flex: 1 1 0; }
288
+ [data-r2-config-hint] { font-size: 11px; line-height: 14px; color: var(--dsw-alias-label-secondary); }
289
+ @media (max-width: 640px) {
290
+ [data-sync-ssh-row] > [data-sync-btn] { min-height: 48px !important; }
291
+ }
292
+
293
+ /* iOS 16px field floor hold (dsh-maestro-mobile zoom guard).
294
+ Every text field on the page is held at 16px under html[data-mobile-nav-ios]
295
+ inside this same predicate, because iOS WebKit magnifies the visual viewport
296
+ for a focused field below 16px. An earlier revision of this panel opted its
297
+ own fields back out to inherit for a compact 13px scale — and every tap on
298
+ those fields zoomed the page on iPhone, with modal sheets never blurring
299
+ back. Function beats pixels: hold the same 16px here (the :not(#...) clause
300
+ matches every element — no node carries that id — and exists purely for
301
+ id-level specificity, so this declaration keeps winning over competing
302
+ field rules). Android and desktop never carry the marker, so the compact
303
+ scale they were designed with is untouched. */
304
+ @media (max-width: 1023px) and (pointer: coarse) {
305
+ html[data-mobile-nav-ios] [data-sync-root] input:not(#dsh-field-floor-opt-out),
306
+ html[data-mobile-nav-ios] [data-sync-root] textarea:not(#dsh-field-floor-opt-out),
307
+ html[data-mobile-nav-ios] [data-sync-root] select:not(#dsh-field-floor-opt-out) { font-size:16px !important; }
308
+ }
309
+ `
310
+
311
+ function apply(ctx: any): void {
312
+ const slots = (ctx as any).slots ?? (ctx as any).get?.('slots')
313
+ if (!slots?.inject || !slots?.register) return
314
+
315
+ ctx.effect(() => registerSyncNavIcon(() => 'Maestro Sync'), 'maestro-sync: settings nav icon')
316
+ ctx.effect(() => installStyleTag(SETTINGS_NAV_CSS, 'maestro-sync/settings-nav.css'), 'maestro-sync: settings nav css')
317
+ ctx.effect(() => installStyleTag(SYNC_CSS, 'maestro-sync/settings.css'), 'maestro-sync: settings css')
318
+
319
+ ctx.effect(() => {
320
+ const dispose = slots.inject('settings.section', () =>
321
+ slots.register(
322
+ { name: 'settings.section', id: 'maestro-sync', order: 28, label: () => 'Maestro Sync' },
323
+ () => React.createElement(SyncPanel, { ctx }),
324
+ ),
325
+ )
326
+ return () => {
327
+ try {
328
+ (dispose as any)?.()
329
+ } catch {}
330
+ }
331
+ }, 'maestro-sync: settings')
332
+ }
333
+
334
+ export { SyncPanel, apply }
335
+
336
+ export default { inject, apply }
@@ -0,0 +1,313 @@
1
+ import * as React from 'react'
2
+
3
+ /**
4
+ * Sync UI kit — DSH-native primitives, Minimalism & Swiss (design-system/MASTER.md).
5
+ * Every color/geometry value maps to a --dsw-alias-* / --dsw-* token; the only
6
+ * fixed hex is the shared Maestro logo tile #0A84FF (branding rule).
7
+ * Components style themselves via [data-sync-*] attributes + tokens (mirrors
8
+ * the dsh-maestro-jobs ui kit so mobile media queries live in one CSS layer).
9
+ */
10
+
11
+ export const RPC_CHANNEL = '/dsh-maestro-sync' as const
12
+
13
+ // --- DSH tokens — single source, no custom hex ---------------------------------
14
+ export const t = {
15
+ bgBase: 'var(--dsw-alias-bg-base)',
16
+ bgLayer1: 'var(--dsw-alias-bg-layer-1)',
17
+ bgLayer2: 'var(--dsw-alias-bg-layer-2)',
18
+ bgLayer3: 'var(--dsw-alias-bg-layer-3)',
19
+ bgOverlay: 'var(--dsw-alias-bg-overlay)',
20
+ borderL1: 'var(--dsw-alias-border-l1)',
21
+ borderL2: 'var(--dsw-alias-border-l2)',
22
+ labelPrimary: 'var(--dsw-alias-label-primary)',
23
+ labelSecondary: 'var(--dsw-alias-label-secondary)',
24
+ labelTertiary: 'var(--dsw-alias-label-tertiary)',
25
+ labelFg: 'var(--dsw-alias-label-primary-foreground)',
26
+ primaryFill: 'var(--dsw-alias-button-primary-fill)',
27
+ primaryHover: 'var(--dsw-alias-button-primary-hover)',
28
+ interactiveHover: 'var(--dsw-alias-interactive-bg-hover)',
29
+ interactiveActive: 'var(--dsw-alias-interactive-bg-active)',
30
+ brand: 'var(--dsw-alias-brand-primary)',
31
+ stateError: 'var(--dsw-alias-state-error-primary)',
32
+ stateSuccess: 'var(--dsw-alias-state-success-primary)',
33
+ stateWarn: 'var(--dsw-alias-state-warn-primary)',
34
+ shadowLv3: 'var(--dsw-shadow-lv3)',
35
+ } as const
36
+
37
+ // --- Shared Maestro logo (branding rule: same mark/path everywhere) -------------
38
+ export function MaestroMark(props: { size?: number }) {
39
+ const s = props.size ?? 16
40
+ return (
41
+ <svg width={s} height={s} viewBox="0 0 16 16" fill="none" aria-hidden="true">
42
+ <path d="M2 11 L5 4 L8 9 L11 4 L14 11" stroke="currentColor" strokeWidth={1.6} strokeLinecap="round" strokeLinejoin="round" />
43
+ </svg>
44
+ )
45
+ }
46
+
47
+ export function MaestroLogo(props: { outer?: number; size?: number; radius?: number }) {
48
+ const outer = props.outer ?? 28
49
+ const size = props.size ?? 16
50
+ const radius = props.radius ?? 8
51
+ return (
52
+ <span
53
+ data-maestro-logo=""
54
+ style={{
55
+ width: outer,
56
+ height: outer,
57
+ borderRadius: radius,
58
+ display: 'inline-flex',
59
+ alignItems: 'center',
60
+ justifyContent: 'center',
61
+ background: 'var(--dsw-alias-brand-primary, #0A84FF)',
62
+ backgroundColor: '#0A84FF',
63
+ color: '#fff',
64
+ flex: 'none',
65
+ border: '1px solid rgba(0, 0, 0, 0.08)',
66
+ boxShadow: '0 0 0 1px var(--dsw-alias-border-l1)',
67
+ boxSizing: 'border-box',
68
+ alignSelf: 'flex-start',
69
+ marginTop: 2,
70
+ }}
71
+ >
72
+ <MaestroMark size={size} />
73
+ </span>
74
+ )
75
+ }
76
+
77
+ // --- Inline SVG icon set (no emoji-as-icon) -------------------------------------
78
+ export type IconName =
79
+ | 'refresh'
80
+ | 'download'
81
+ | 'upload'
82
+ | 'swap'
83
+ | 'file'
84
+ | 'folder'
85
+ | 'star'
86
+ | 'message'
87
+ | 'calendar'
88
+ | 'server'
89
+ | 'clock'
90
+ | 'alert'
91
+ | 'check'
92
+ | 'close'
93
+ | 'chevron-down'
94
+ | 'chevron-right'
95
+ | 'external'
96
+
97
+ const ICON_PATHS: Record<IconName, React.ReactNode> = {
98
+ refresh: <path d="M13.5 8a5.5 5.5 0 1 1-1.6-3.9M13.5 2.5v3h-3" fill="none" stroke="currentColor" strokeWidth="1.4" strokeLinecap="round" strokeLinejoin="round" />,
99
+ download: <path d="M8 2.5v7m0 0L5 6.5m3 3l3-3M3 12.5h10v1H3z" fill="none" stroke="currentColor" strokeWidth="1.4" strokeLinecap="round" strokeLinejoin="round" />,
100
+ upload: <path d="M8 11.5v-7m0 0L5 7.5m3-3l3 3M3 12.5h10v1H3z" fill="none" stroke="currentColor" strokeWidth="1.4" strokeLinecap="round" strokeLinejoin="round" />,
101
+ swap: <path d="M4.5 3.5 2 6l2.5 2.5M2 6h7m2.5 5.5L14 9l-2.5-2.5M14 9H7" fill="none" stroke="currentColor" strokeWidth="1.3" strokeLinecap="round" strokeLinejoin="round" />,
102
+ file: <path d="M3 13V3h6l4 4v6H3zM9 3v4h4" fill="none" stroke="currentColor" strokeWidth="1.3" strokeLinejoin="round" />,
103
+ folder: <path d="M2 3.5h4.5l1.5 2H14v8H2v-10z" fill="none" stroke="currentColor" strokeWidth="1.3" strokeLinejoin="round" />,
104
+ star: <path d="M8 2l1.8 3.7 4.2.6-3 3 .7 4.2L8 11.9 4.3 13.5l.7-4.2-3-3 4.2-.6z" fill="none" stroke="currentColor" strokeWidth="1.2" strokeLinejoin="round" />,
105
+ message: <path d="M3 3h10v8H6l-3 3V3z" fill="none" stroke="currentColor" strokeWidth="1.2" strokeLinejoin="round" />,
106
+ calendar: (
107
+ <>
108
+ <rect x="2.5" y="4" width="11" height="9.5" rx="1" fill="none" stroke="currentColor" strokeWidth="1.2" />
109
+ <path d="M2.5 7.5h11M5.5 2.5v3m5-3v3" fill="none" stroke="currentColor" strokeWidth="1.2" strokeLinecap="round" />
110
+ </>
111
+ ),
112
+ server: (
113
+ <>
114
+ <rect x="2.5" y="3" width="11" height="4" rx="1" fill="none" stroke="currentColor" strokeWidth="1.2" />
115
+ <rect x="2.5" y="9" width="11" height="4" rx="1" fill="none" stroke="currentColor" strokeWidth="1.2" />
116
+ <path d="M5.5 5h.01M5.5 11h.01" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" />
117
+ </>
118
+ ),
119
+ clock: (
120
+ <>
121
+ <circle cx="8" cy="8" r="5.5" fill="none" stroke="currentColor" strokeWidth="1.3" />
122
+ <path d="M8 5v3l2 1.5" fill="none" stroke="currentColor" strokeWidth="1.3" strokeLinecap="round" />
123
+ </>
124
+ ),
125
+ alert: (
126
+ <>
127
+ <path d="M8 2.5 14 13H2L8 2.5z" fill="none" stroke="currentColor" strokeWidth="1.3" strokeLinejoin="round" />
128
+ <path d="M8 7v2.5M8 11.5v.01" stroke="currentColor" strokeWidth="1.3" strokeLinecap="round" />
129
+ </>
130
+ ),
131
+ check: <path d="M3.5 8.2l2.8 2.8L12.5 4.8" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" />,
132
+ close: <path d="M4 4l8 8M12 4l-8 8" fill="none" stroke="currentColor" strokeWidth="1.4" strokeLinecap="round" />,
133
+ 'chevron-down': <path d="M3.5 5.5 7 9l3.5-3.5" fill="none" stroke="currentColor" strokeWidth="1.4" strokeLinecap="round" strokeLinejoin="round" />,
134
+ 'chevron-right': <path d="M5.5 3.5 9 7l-3.5 3.5" fill="none" stroke="currentColor" strokeWidth="1.4" strokeLinecap="round" strokeLinejoin="round" />,
135
+ external: <path d="M6 3h7v7M13 3 7 9M13 9v4H3V3h4" fill="none" stroke="currentColor" strokeWidth="1.3" strokeLinecap="round" strokeLinejoin="round" />,
136
+ }
137
+
138
+ export function Icon(props: { name: IconName; size?: number }) {
139
+ const size = props.size ?? 14
140
+ return (
141
+ <svg width={size} height={size} viewBox="0 0 16 16" fill="none" aria-hidden="true" style={{ flex: 'none' }}>
142
+ {ICON_PATHS[props.name]}
143
+ </svg>
144
+ )
145
+ }
146
+
147
+ // --- Buttons (primary / outline / ghost, sm / md) — token-native ---------------
148
+ export function Button(props: {
149
+ variant?: 'primary' | 'outline' | 'ghost'
150
+ size?: 'sm' | 'md'
151
+ icon?: IconName
152
+ busy?: boolean
153
+ children?: React.ReactNode
154
+ style?: React.CSSProperties
155
+ } & Record<string, unknown>) {
156
+ const { variant = 'outline', size = 'md', icon, busy, children, style, ...rest } = props as any
157
+ const base: React.CSSProperties = {
158
+ display: 'inline-flex',
159
+ alignItems: 'center',
160
+ justifyContent: 'center',
161
+ gap: 6,
162
+ minHeight: size === 'sm' ? 32 : 36,
163
+ padding: size === 'sm' ? '0 12px' : '0 14px',
164
+ borderRadius: size === 'sm' ? 16 : 18,
165
+ border: '1px solid var(--dsw-alias-border-l2)',
166
+ background: variant === 'primary' ? 'var(--dsw-alias-button-primary-fill)' : 'transparent',
167
+ color: variant === 'primary' ? 'var(--dsw-alias-label-primary-foreground)' : 'var(--dsw-alias-label-primary)',
168
+ font: 'inherit',
169
+ fontSize: 13,
170
+ lineHeight: '20px',
171
+ fontWeight: 500,
172
+ cursor: 'pointer',
173
+ fontFamily: 'inherit',
174
+ whiteSpace: 'nowrap',
175
+ boxSizing: 'border-box',
176
+ }
177
+ if (variant === 'ghost') base.border = '1px solid transparent'
178
+ const disabled = rest.disabled === true
179
+ return (
180
+ <button
181
+ type="button"
182
+ data-sync-btn=""
183
+ data-variant={variant}
184
+ data-size={size}
185
+ {...rest}
186
+ disabled={disabled || busy === true}
187
+ style={{ ...base, ...(style ?? {}) }}
188
+ onMouseEnter={(e) => {
189
+ if (disabled || busy) return
190
+ if (variant === 'primary') (e.currentTarget as HTMLButtonElement).style.background = 'var(--dsw-alias-button-primary-hover)'
191
+ else (e.currentTarget as HTMLButtonElement).style.background = 'var(--dsw-alias-interactive-bg-hover)'
192
+ }}
193
+ onMouseLeave={(e) => {
194
+ if (variant === 'primary') (e.currentTarget as HTMLButtonElement).style.background = 'var(--dsw-alias-button-primary-fill)'
195
+ else (e.currentTarget as HTMLButtonElement).style.background = variant === 'outline' ? 'transparent' : 'transparent'
196
+ }}
197
+ >
198
+ {busy ? <span className="sync-spin" aria-hidden="true">◌</span> : icon ? <Icon name={icon} /> : null}
199
+ {children}
200
+ </button>
201
+ )
202
+ }
203
+
204
+ // --- Stat tile — tappable summary card ------------------------------------------
205
+ export function StatTile(props: { icon: IconName; value: React.ReactNode; label: string; hint?: string; tone?: 'default' | 'success' | 'error' | 'warn'; onClick?: () => void; ariaLabel?: string }) {
206
+ const toneColor = props.tone === 'success' ? t.stateSuccess : props.tone === 'error' ? t.stateError : props.tone === 'warn' ? t.stateWarn : undefined
207
+ const isBtn = props.onClick !== undefined
208
+ const inner = (
209
+ <>
210
+ <span data-sync-stat-icon="" style={{ color: toneColor ?? 'var(--dsw-alias-label-tertiary)', display: 'inline-flex' }}>
211
+ <Icon name={props.icon} />
212
+ </span>
213
+ <span data-sync-stat-value="" style={{ color: 'var(--dsw-alias-label-primary)' }}>{props.value}</span>
214
+ <span data-sync-stat-label="" style={{ color: 'var(--dsw-alias-label-secondary)' }}>{props.label}</span>
215
+ {props.hint ? <span data-sync-stat-hint="" style={{ color: 'var(--dsw-alias-label-tertiary)' }}>{props.hint}</span> : null}
216
+ </>
217
+ )
218
+ if (isBtn) {
219
+ return (
220
+ <button type="button" data-sync-stat="" role="button" aria-label={props.ariaLabel} onClick={props.onClick}>
221
+ {inner}
222
+ </button>
223
+ )
224
+ }
225
+ return <div data-sync-stat="">{inner}</div>
226
+ }
227
+
228
+ // --- Small status badge -----------------------------------------------------------
229
+ export function Badge(props: { children: React.ReactNode; tone?: 'default' | 'success' | 'error' | 'warn' | 'brand'; icon?: IconName }) {
230
+ const tone = props.tone ?? 'default'
231
+ return (
232
+ <span data-sync-badge="" data-tone={tone}>
233
+ {props.icon ? <Icon name={props.icon} size={11} /> : null}
234
+ {props.children}
235
+ </span>
236
+ )
237
+ }
238
+
239
+ // --- File + action helpers ---------------------------------------------------------
240
+ export function formatLastSync(v: string | null): string {
241
+ if (!v) return 'never'
242
+ try {
243
+ const d = new Date(v)
244
+ if (Number.isNaN(d.getTime())) return v
245
+ return d.toLocaleString()
246
+ } catch {
247
+ return v
248
+ }
249
+ }
250
+
251
+ export function fileIcon(path: string): IconName {
252
+ if (path.startsWith('dsh-maestro-memory/daily/')) return 'calendar'
253
+ if (path.startsWith('dsh-maestro-memory/projects/')) return 'folder'
254
+ if (path === 'dsh-maestro-memory/MEMORY.md') return 'star'
255
+ if (path.startsWith('sessions/')) return 'message'
256
+ return 'file'
257
+ }
258
+
259
+ export function formatFile(path: string): { icon: IconName; title: string; path: string; meta: string } {
260
+ if (path.startsWith('dsh-maestro-memory/daily/')) {
261
+ const date = path.replace('dsh-maestro-memory/daily/', '').replace('.md', '')
262
+ try {
263
+ const d = new Date(date)
264
+ if (!isNaN(d.getTime())) return { icon: 'calendar', title: `Daily notes — ${d.toLocaleDateString('en-US', { month: 'short', day: 'numeric', year: 'numeric' })}`, path, meta: 'Daily' }
265
+ } catch {}
266
+ return { icon: 'calendar', title: `Daily notes — ${date}`, path, meta: 'Daily' }
267
+ }
268
+ if (path.startsWith('dsh-maestro-memory/projects/')) {
269
+ const hash = path.split('/')[2] ?? ''
270
+ return { icon: 'folder', title: 'Project memory', path, meta: hash.slice(0, 7) }
271
+ }
272
+ if (path === 'dsh-maestro-memory/MEMORY.md') return { icon: 'star', title: 'Global memory', path, meta: 'Global' }
273
+ if (path.startsWith('sessions/')) {
274
+ const hash = path.split('/')[1] ?? ''
275
+ return { icon: 'message', title: 'Session', path, meta: hash.slice(0, 7) }
276
+ }
277
+ return { icon: 'file', title: path.split('/').pop() ?? path, path, meta: path.split('/')[0] ?? '' }
278
+ }
279
+
280
+ /** Exact action label — same-name files are never called "in sync" here. */
281
+ export function actionLabel(action: any): string {
282
+ switch (action?.action) {
283
+ case 'copy':
284
+ return 'copy'
285
+ case 'merge':
286
+ return `merge +${action.added ?? 0} ${(action.added ?? 0) === 1 ? 'new entry' : 'new entries'}`
287
+ case 'conflict':
288
+ return 'conflict'
289
+ default:
290
+ return 'skip'
291
+ }
292
+ }
293
+
294
+ export function actionTone(action: any): 'default' | 'success' | 'error' | 'warn' | 'brand' {
295
+ switch (action?.action) {
296
+ case 'copy':
297
+ return 'brand'
298
+ case 'merge':
299
+ return 'success'
300
+ case 'conflict':
301
+ return 'error'
302
+ default:
303
+ return 'default'
304
+ }
305
+ }
306
+
307
+ export function humanSummary(status: any): string {
308
+ const localOnly = status?.localOnly ?? 0
309
+ const remoteOnly = status?.remoteOnly ?? 0
310
+ const both = status?.both ?? 0
311
+ if (localOnly === 0 && remoteOnly === 0 && both === 0) return 'No eligible files found on either side.'
312
+ return `${localOnly} only here · ${remoteOnly} only there · ${both} on both (content compared in Preview)`
313
+ }