@ddtcorex/dsh-maestro-core 0.15.0 → 0.16.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 (117) hide show
  1. package/README.md +7 -7
  2. package/assets/icon.svg +4 -0
  3. package/cordis.patch.yml +0 -12
  4. package/lib/client.js +3 -1744
  5. package/lib/health-poller.js +1 -1
  6. package/lib/self-kill-guard.d.ts +25 -8
  7. package/lib/self-kill-guard.js +81 -27
  8. package/lib/types/client/config/components/BrandMark.d.ts +3 -3
  9. package/lib/types/client/index.d.ts.map +1 -1
  10. package/locale/en.json +6 -0
  11. package/package.json +9 -5
  12. package/src/client/config/components/BrandMark.tsx +3 -3
  13. package/src/client/index.tsx +0 -2
  14. package/src/host/health-poller.ts +1 -1
  15. package/src/host/self-kill-guard.ts +84 -26
  16. package/lib/sync/backup-config.d.ts +0 -55
  17. package/lib/sync/backup-config.js +0 -119
  18. package/lib/sync/backup-service.d.ts +0 -123
  19. package/lib/sync/backup-service.js +0 -486
  20. package/lib/sync/bidirectional.d.ts +0 -39
  21. package/lib/sync/bidirectional.js +0 -25
  22. package/lib/sync/cli.d.ts +0 -38
  23. package/lib/sync/cli.js +0 -528
  24. package/lib/sync/config.d.ts +0 -59
  25. package/lib/sync/config.js +0 -72
  26. package/lib/sync/fingerprint.d.ts +0 -29
  27. package/lib/sync/fingerprint.js +0 -65
  28. package/lib/sync/hashing.d.ts +0 -22
  29. package/lib/sync/hashing.js +0 -77
  30. package/lib/sync/index.d.ts +0 -6
  31. package/lib/sync/index.js +0 -619
  32. package/lib/sync/machine-id.d.ts +0 -29
  33. package/lib/sync/machine-id.js +0 -66
  34. package/lib/sync/merge.d.ts +0 -31
  35. package/lib/sync/merge.js +0 -86
  36. package/lib/sync/peer-host.d.ts +0 -22
  37. package/lib/sync/peer-host.js +0 -62
  38. package/lib/sync/process-runner.d.ts +0 -31
  39. package/lib/sync/process-runner.js +0 -161
  40. package/lib/sync/remote-agent.d.ts +0 -41
  41. package/lib/sync/remote-agent.js +0 -227
  42. package/lib/sync/remote-cache.d.ts +0 -18
  43. package/lib/sync/remote-cache.js +0 -60
  44. package/lib/sync/remote-manifest.d.ts +0 -33
  45. package/lib/sync/remote-manifest.js +0 -111
  46. package/lib/sync/s3-object-store.d.ts +0 -38
  47. package/lib/sync/s3-object-store.js +0 -126
  48. package/lib/sync/session-plan.d.ts +0 -29
  49. package/lib/sync/session-plan.js +0 -213
  50. package/lib/sync/sigv4.d.ts +0 -20
  51. package/lib/sync/sigv4.js +0 -57
  52. package/lib/sync/snapshot.d.ts +0 -16
  53. package/lib/sync/snapshot.js +0 -143
  54. package/lib/sync/ssh-mux.d.ts +0 -12
  55. package/lib/sync/ssh-mux.js +0 -48
  56. package/lib/sync/store-root.d.ts +0 -44
  57. package/lib/sync/store-root.js +0 -67
  58. package/lib/sync/sync-plan.d.ts +0 -24
  59. package/lib/sync/sync-plan.js +0 -366
  60. package/lib/sync/sync-service.d.ts +0 -181
  61. package/lib/sync/sync-service.js +0 -911
  62. package/lib/sync/sync-types.d.ts +0 -87
  63. package/lib/sync/sync-types.js +0 -1
  64. package/lib/sync/transport.d.ts +0 -75
  65. package/lib/sync/transport.js +0 -196
  66. package/lib/sync/tunnel-restore.d.ts +0 -77
  67. package/lib/sync/tunnel-restore.js +0 -142
  68. package/lib/sync/validation.d.ts +0 -12
  69. package/lib/sync/validation.js +0 -96
  70. package/lib/types/client/sync/R2SyncPanel.d.ts +0 -6
  71. package/lib/types/client/sync/R2SyncPanel.d.ts.map +0 -1
  72. package/lib/types/client/sync/SyncPanel.d.ts +0 -12
  73. package/lib/types/client/sync/SyncPanel.d.ts.map +0 -1
  74. package/lib/types/client/sync/confirm-dialog.d.ts +0 -43
  75. package/lib/types/client/sync/confirm-dialog.d.ts.map +0 -1
  76. package/lib/types/client/sync/index.d.ts +0 -10
  77. package/lib/types/client/sync/index.d.ts.map +0 -1
  78. package/lib/types/client/sync/ui.d.ts +0 -75
  79. package/lib/types/client/sync/ui.d.ts.map +0 -1
  80. package/lib/types/client/sync/use-backup.d.ts +0 -50
  81. package/lib/types/client/sync/use-backup.d.ts.map +0 -1
  82. package/lib/types/client/sync/use-sync.d.ts +0 -88
  83. package/lib/types/client/sync/use-sync.d.ts.map +0 -1
  84. package/src/client/sync/R2SyncPanel.tsx +0 -260
  85. package/src/client/sync/SyncPanel.tsx +0 -422
  86. package/src/client/sync/confirm-dialog.tsx +0 -202
  87. package/src/client/sync/index.tsx +0 -286
  88. package/src/client/sync/ui.tsx +0 -297
  89. package/src/client/sync/use-backup.ts +0 -207
  90. package/src/client/sync/use-sync.ts +0 -502
  91. package/src/host/sync/backup-config.ts +0 -158
  92. package/src/host/sync/backup-service.ts +0 -506
  93. package/src/host/sync/bidirectional.ts +0 -66
  94. package/src/host/sync/cli.ts +0 -530
  95. package/src/host/sync/config.ts +0 -96
  96. package/src/host/sync/fingerprint.ts +0 -83
  97. package/src/host/sync/hashing.ts +0 -91
  98. package/src/host/sync/index.ts +0 -697
  99. package/src/host/sync/machine-id.ts +0 -81
  100. package/src/host/sync/merge.ts +0 -99
  101. package/src/host/sync/peer-host.ts +0 -65
  102. package/src/host/sync/process-runner.ts +0 -177
  103. package/src/host/sync/remote-agent.ts +0 -223
  104. package/src/host/sync/remote-cache.ts +0 -68
  105. package/src/host/sync/remote-manifest.ts +0 -117
  106. package/src/host/sync/s3-object-store.ts +0 -144
  107. package/src/host/sync/session-plan.ts +0 -237
  108. package/src/host/sync/sigv4.ts +0 -81
  109. package/src/host/sync/snapshot.ts +0 -132
  110. package/src/host/sync/ssh-mux.ts +0 -55
  111. package/src/host/sync/store-root.ts +0 -83
  112. package/src/host/sync/sync-plan.ts +0 -366
  113. package/src/host/sync/sync-service.ts +0 -944
  114. package/src/host/sync/sync-types.ts +0 -102
  115. package/src/host/sync/transport.ts +0 -256
  116. package/src/host/sync/tunnel-restore.ts +0 -160
  117. package/src/host/sync/validation.ts +0 -104
package/lib/client.js CHANGED
@@ -5,11 +5,9 @@ window.__ModuleLoader__.load({
5
5
  var exports = module.exports;
6
6
  var React = require("react");
7
7
  "use strict";
8
- var __create = Object.create;
9
8
  var __defProp = Object.defineProperty;
10
9
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
11
10
  var __getOwnPropNames = Object.getOwnPropertyNames;
12
- var __getProtoOf = Object.getPrototypeOf;
13
11
  var __hasOwnProp = Object.prototype.hasOwnProperty;
14
12
  var __export = (target, all) => {
15
13
  for (var name in all)
@@ -23,20 +21,12 @@ var __copyProps = (to, from, except, desc) => {
23
21
  }
24
22
  return to;
25
23
  };
26
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
27
- // If the importer is in node compatibility mode or this is not an ESM
28
- // file that has been converted to a CommonJS file using a Babel-
29
- // compatible transform (i.e. "__esModule" has not been set), then set
30
- // "default" to the CommonJS "module.exports" for node compatibility.
31
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
32
- mod
33
- ));
34
24
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
35
25
 
36
26
  // src/client/index.tsx
37
27
  var index_exports = {};
38
28
  __export(index_exports, {
39
- apply: () => apply4,
29
+ apply: () => apply3,
40
30
  inject: () => inject
41
31
  });
42
32
  module.exports = __toCommonJS(index_exports);
@@ -980,1744 +970,13 @@ function apply2(ctx) {
980
970
  );
981
971
  }
982
972
 
983
- // src/client/sync/index.tsx
984
- var React5 = __toESM(require("react"), 1);
985
-
986
- // src/client/sync/SyncPanel.tsx
987
- var React4 = __toESM(require("react"), 1);
988
-
989
- // src/client/sync/use-sync.ts
990
- var React = __toESM(require("react"), 1);
991
-
992
- // src/client/sync/ui.tsx
993
- var import_jsx_runtime = require("react/jsx-runtime");
994
- var RPC_CHANNEL = "/dsh-maestro-sync";
995
- var t2 = {
996
- bgBase: "var(--dsw-alias-bg-base)",
997
- bgLayer1: "var(--dsw-alias-bg-layer-1)",
998
- bgLayer2: "var(--dsw-alias-bg-layer-2)",
999
- bgLayer3: "var(--dsw-alias-bg-layer-3)",
1000
- bgOverlay: "var(--dsw-alias-bg-overlay)",
1001
- borderL1: "var(--dsw-alias-border-l1)",
1002
- borderL2: "var(--dsw-alias-border-l2)",
1003
- labelPrimary: "var(--dsw-alias-label-primary)",
1004
- labelSecondary: "var(--dsw-alias-label-secondary)",
1005
- labelTertiary: "var(--dsw-alias-label-tertiary)",
1006
- labelFg: "var(--dsw-alias-label-primary-foreground)",
1007
- primaryFill: "var(--dsw-alias-button-primary-fill)",
1008
- primaryHover: "var(--dsw-alias-button-primary-hover)",
1009
- interactiveHover: "var(--dsw-alias-interactive-bg-hover)",
1010
- interactiveActive: "var(--dsw-alias-interactive-bg-active)",
1011
- brand: "var(--dsw-alias-brand-primary)",
1012
- stateError: "var(--dsw-alias-state-error-primary)",
1013
- stateSuccess: "var(--dsw-alias-state-success-primary)",
1014
- stateWarn: "var(--dsw-alias-state-warn-primary)",
1015
- shadowLv3: "var(--dsw-shadow-lv3)"
1016
- };
1017
- function MaestroLogo(props) {
1018
- const outer = props.outer ?? 28;
1019
- const size = props.size ?? 16;
1020
- const radius = props.radius ?? 8;
1021
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
1022
- "span",
1023
- {
1024
- "data-maestro-logo": "",
1025
- style: {
1026
- width: outer,
1027
- height: outer,
1028
- borderRadius: radius,
1029
- display: "inline-flex",
1030
- alignItems: "center",
1031
- justifyContent: "center",
1032
- background: "var(--dsw-alias-brand-primary, #0A84FF)",
1033
- backgroundColor: "#0A84FF",
1034
- color: "#fff",
1035
- flex: "none",
1036
- border: "1px solid rgba(0, 0, 0, 0.08)",
1037
- boxShadow: "0 0 0 1px var(--dsw-alias-border-l1)",
1038
- boxSizing: "border-box",
1039
- alignSelf: "flex-start",
1040
- marginTop: 2
1041
- },
1042
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MaestroMark, { size })
1043
- }
1044
- );
1045
- }
1046
- var ICON_PATHS = {
1047
- refresh: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("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" }),
1048
- download: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M8 2.5v7m0 0L5 6.5m3 3l3-3M3 12.5h10v1H3z", fill: "none", stroke: "currentColor", strokeWidth: "1.4", strokeLinecap: "round", strokeLinejoin: "round" }),
1049
- upload: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M8 11.5v-7m0 0L5 7.5m3-3l3 3M3 12.5h10v1H3z", fill: "none", stroke: "currentColor", strokeWidth: "1.4", strokeLinecap: "round", strokeLinejoin: "round" }),
1050
- swap: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("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" }),
1051
- file: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M3 13V3h6l4 4v6H3zM9 3v4h4", fill: "none", stroke: "currentColor", strokeWidth: "1.3", strokeLinejoin: "round" }),
1052
- folder: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M2 3.5h4.5l1.5 2H14v8H2v-10z", fill: "none", stroke: "currentColor", strokeWidth: "1.3", strokeLinejoin: "round" }),
1053
- star: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("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" }),
1054
- message: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M3 3h10v8H6l-3 3V3z", fill: "none", stroke: "currentColor", strokeWidth: "1.2", strokeLinejoin: "round" }),
1055
- calendar: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
1056
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("rect", { x: "2.5", y: "4", width: "11", height: "9.5", rx: "1", fill: "none", stroke: "currentColor", strokeWidth: "1.2" }),
1057
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M2.5 7.5h11M5.5 2.5v3m5-3v3", fill: "none", stroke: "currentColor", strokeWidth: "1.2", strokeLinecap: "round" })
1058
- ] }),
1059
- server: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
1060
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("rect", { x: "2.5", y: "3", width: "11", height: "4", rx: "1", fill: "none", stroke: "currentColor", strokeWidth: "1.2" }),
1061
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("rect", { x: "2.5", y: "9", width: "11", height: "4", rx: "1", fill: "none", stroke: "currentColor", strokeWidth: "1.2" }),
1062
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M5.5 5h.01M5.5 11h.01", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round" })
1063
- ] }),
1064
- clock: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
1065
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: "8", cy: "8", r: "5.5", fill: "none", stroke: "currentColor", strokeWidth: "1.3" }),
1066
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M8 5v3l2 1.5", fill: "none", stroke: "currentColor", strokeWidth: "1.3", strokeLinecap: "round" })
1067
- ] }),
1068
- alert: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
1069
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M8 2.5 14 13H2L8 2.5z", fill: "none", stroke: "currentColor", strokeWidth: "1.3", strokeLinejoin: "round" }),
1070
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M8 7v2.5M8 11.5v.01", stroke: "currentColor", strokeWidth: "1.3", strokeLinecap: "round" })
1071
- ] }),
1072
- check: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M3.5 8.2l2.8 2.8L12.5 4.8", fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }),
1073
- close: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M4 4l8 8M12 4l-8 8", fill: "none", stroke: "currentColor", strokeWidth: "1.4", strokeLinecap: "round" }),
1074
- "chevron-down": /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M3.5 5.5 7 9l3.5-3.5", fill: "none", stroke: "currentColor", strokeWidth: "1.4", strokeLinecap: "round", strokeLinejoin: "round" }),
1075
- "chevron-right": /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M5.5 3.5 9 7l-3.5 3.5", fill: "none", stroke: "currentColor", strokeWidth: "1.4", strokeLinecap: "round", strokeLinejoin: "round" }),
1076
- external: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M6 3h7v7M13 3 7 9M13 9v4H3V3h4", fill: "none", stroke: "currentColor", strokeWidth: "1.3", strokeLinecap: "round", strokeLinejoin: "round" })
1077
- };
1078
- function Icon(props) {
1079
- const size = props.size ?? 14;
1080
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", { width: size, height: size, viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", style: { flex: "none" }, children: ICON_PATHS[props.name] });
1081
- }
1082
- function Button2(props) {
1083
- const { variant = "outline", size = "md", icon, busy, children, style, ...rest } = props;
1084
- const base = {
1085
- display: "inline-flex",
1086
- alignItems: "center",
1087
- justifyContent: "center",
1088
- gap: 6,
1089
- minHeight: size === "sm" ? 32 : 36,
1090
- padding: size === "sm" ? "0 12px" : "0 14px",
1091
- borderRadius: size === "sm" ? 16 : 18,
1092
- border: "1px solid var(--dsw-alias-border-l2)",
1093
- background: variant === "primary" ? "var(--dsw-alias-button-primary-fill)" : "transparent",
1094
- color: variant === "primary" ? "var(--dsw-alias-label-primary-foreground)" : "var(--dsw-alias-label-primary)",
1095
- font: "inherit",
1096
- fontSize: 13,
1097
- lineHeight: "20px",
1098
- fontWeight: 500,
1099
- cursor: "pointer",
1100
- fontFamily: "inherit",
1101
- whiteSpace: "nowrap",
1102
- boxSizing: "border-box"
1103
- };
1104
- if (variant === "ghost") base.border = "1px solid transparent";
1105
- const disabled = rest.disabled === true;
1106
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
1107
- "button",
1108
- {
1109
- type: "button",
1110
- "data-sync-btn": "",
1111
- "data-variant": variant,
1112
- "data-size": size,
1113
- ...rest,
1114
- disabled: disabled || busy === true,
1115
- style: { ...base, ...style ?? {} },
1116
- onMouseEnter: (e) => {
1117
- if (disabled || busy) return;
1118
- if (variant === "primary") e.currentTarget.style.background = "var(--dsw-alias-button-primary-hover)";
1119
- else e.currentTarget.style.background = "var(--dsw-alias-interactive-bg-hover)";
1120
- },
1121
- onMouseLeave: (e) => {
1122
- if (variant === "primary") e.currentTarget.style.background = "var(--dsw-alias-button-primary-fill)";
1123
- else e.currentTarget.style.background = variant === "outline" ? "transparent" : "transparent";
1124
- },
1125
- children: [
1126
- busy ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "sync-spin", "aria-hidden": "true", children: "\u25CC" }) : icon ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Icon, { name: icon }) : null,
1127
- children
1128
- ]
1129
- }
1130
- );
1131
- }
1132
- function StatTile(props) {
1133
- const toneColor = props.tone === "success" ? t2.stateSuccess : props.tone === "error" ? t2.stateError : props.tone === "warn" ? t2.stateWarn : void 0;
1134
- const isBtn = props.onClick !== void 0;
1135
- const inner = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
1136
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { "data-sync-stat-icon": "", style: { color: toneColor ?? "var(--dsw-alias-label-tertiary)", display: "inline-flex" }, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Icon, { name: props.icon }) }),
1137
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { "data-sync-stat-value": "", style: { color: "var(--dsw-alias-label-primary)" }, children: props.value }),
1138
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { "data-sync-stat-label": "", style: { color: "var(--dsw-alias-label-secondary)" }, children: props.label }),
1139
- props.hint ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { "data-sync-stat-hint": "", style: { color: "var(--dsw-alias-label-tertiary)" }, children: props.hint }) : null
1140
- ] });
1141
- if (isBtn) {
1142
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", "data-sync-stat": "", role: "button", "aria-label": props.ariaLabel, onClick: props.onClick, children: inner });
1143
- }
1144
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { "data-sync-stat": "", children: inner });
1145
- }
1146
- function Badge(props) {
1147
- const tone = props.tone ?? "default";
1148
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { "data-sync-badge": "", "data-tone": tone, children: [
1149
- props.icon ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Icon, { name: props.icon, size: 11 }) : null,
1150
- props.children
1151
- ] });
1152
- }
1153
- function formatLastSync(v) {
1154
- if (!v) return "never";
1155
- try {
1156
- const d = new Date(v);
1157
- if (Number.isNaN(d.getTime())) return v;
1158
- return d.toLocaleString();
1159
- } catch {
1160
- return v;
1161
- }
1162
- }
1163
- function formatFile(path) {
1164
- if (path.startsWith("maestro-memory/daily/")) {
1165
- const date = path.replace("maestro-memory/daily/", "").replace(".md", "");
1166
- try {
1167
- const d = new Date(date);
1168
- if (!isNaN(d.getTime())) return { icon: "calendar", title: `Daily notes \u2014 ${d.toLocaleDateString("en-US", { month: "short", day: "numeric", year: "numeric" })}`, path, meta: "Daily" };
1169
- } catch {
1170
- }
1171
- return { icon: "calendar", title: `Daily notes \u2014 ${date}`, path, meta: "Daily" };
1172
- }
1173
- if (path.startsWith("maestro-memory/projects/")) {
1174
- const hash = path.split("/")[2] ?? "";
1175
- return { icon: "folder", title: "Project memory", path, meta: hash.slice(0, 7) };
1176
- }
1177
- if (path === "maestro-memory/MEMORY.md") return { icon: "star", title: "Global memory", path, meta: "Global" };
1178
- if (path.startsWith("sessions/")) {
1179
- const hash = path.split("/")[1] ?? "";
1180
- return { icon: "message", title: "Session", path, meta: hash.slice(0, 7) };
1181
- }
1182
- return { icon: "file", title: path.split("/").pop() ?? path, path, meta: path.split("/")[0] ?? "" };
1183
- }
1184
- function actionLabel(action) {
1185
- switch (action?.action) {
1186
- case "copy":
1187
- return "copy";
1188
- case "merge":
1189
- return `merge +${action.added ?? 0} ${(action.added ?? 0) === 1 ? "new entry" : "new entries"}`;
1190
- case "conflict":
1191
- return "conflict";
1192
- default:
1193
- return "skip";
1194
- }
1195
- }
1196
- function actionTone(action) {
1197
- switch (action?.action) {
1198
- case "copy":
1199
- return "brand";
1200
- case "merge":
1201
- return "success";
1202
- case "conflict":
1203
- return "error";
1204
- default:
1205
- return "default";
1206
- }
1207
- }
1208
- function humanSummary(status) {
1209
- const localOnly = status?.localOnly ?? 0;
1210
- const remoteOnly = status?.remoteOnly ?? 0;
1211
- const both = status?.both ?? 0;
1212
- if (localOnly === 0 && remoteOnly === 0 && both === 0) return "No eligible files found on either side.";
1213
- return `${localOnly} only here \xB7 ${remoteOnly} only there \xB7 ${both} on both (content compared in Preview)`;
1214
- }
1215
-
1216
- // src/client/sync/use-sync.ts
1217
- function useSync(ctx) {
1218
- const [remoteHost, setRemoteHost] = React.useState("\u2026");
1219
- const [remoteSource, setRemoteSource] = React.useState("default");
1220
- const [lastSync, setLastSync] = React.useState(() => {
1221
- try {
1222
- return typeof localStorage !== "undefined" ? localStorage.getItem("dsh-maestro-sync:lastSync") : null;
1223
- } catch {
1224
- return null;
1225
- }
1226
- });
1227
- const [status, setStatus] = React.useState(null);
1228
- const [connection, setConnection] = React.useState(null);
1229
- const [machines, setMachines] = React.useState(null);
1230
- const [checking, setChecking] = React.useState(false);
1231
- const [busy, setBusy] = React.useState(false);
1232
- const [result, setResult] = React.useState(null);
1233
- const [error, setError] = React.useState("");
1234
- const [preview, setPreview] = React.useState(null);
1235
- const [previewDirection, setPreviewDirection] = React.useState("pull");
1236
- const [confirmOpen, setConfirmOpen] = React.useState(false);
1237
- const [tunnelPreview, setTunnelPreview] = React.useState(null);
1238
- const [tunnelConfirmOpen, setTunnelConfirmOpen] = React.useState(false);
1239
- const [hostFieldError, setHostFieldError] = React.useState(null);
1240
- const [biPreview, setBiPreview] = React.useState(null);
1241
- const [biConfirmOpen, setBiConfirmOpen] = React.useState(false);
1242
- const [actionLimit, setActionLimit] = React.useState(5);
1243
- const [progress, setProgress] = React.useState(null);
1244
- const cancelledRef = React.useRef(false);
1245
- const [pages, setPages] = React.useState({
1246
- localOnly: { files: [], total: 0, next: null, loaded: false },
1247
- remoteOnly: { files: [], total: 0, next: null, loaded: false }
1248
- });
1249
- const call = React.useCallback(async (method, payload) => {
1250
- const conn = ctx.connection ?? ctx.get?.("connection");
1251
- if (!conn?.rpc?.call) throw new Error("RPC not available");
1252
- const res = await conn.rpc.call(RPC_CHANNEL, method, payload);
1253
- if (res && typeof res === "object" && "ok" in res) {
1254
- if (res.ok) return res.value;
1255
- const err = res.error;
1256
- if (typeof err === "string") return { ok: false, error: err };
1257
- return { ok: false, error: err?.message ?? "RPC failed", code: typeof err?.code === "string" ? err.code : void 0 };
1258
- }
1259
- return res;
1260
- }, [ctx]);
1261
- const loadPage = React.useCallback(
1262
- async (bucket, cursor) => {
1263
- try {
1264
- const res = await call("status", { bucket, cursor, limit: 10 });
1265
- if (!res) return;
1266
- setPages((prev) => ({
1267
- ...prev,
1268
- [bucket]: {
1269
- files: cursor === 0 ? res.files ?? [] : [...prev[bucket].files, ...res.files ?? []],
1270
- total: res.total ?? prev[bucket].total,
1271
- next: res.nextCursor ?? null,
1272
- loaded: true
1273
- }
1274
- }));
1275
- } catch {
1276
- }
1277
- },
1278
- [call]
1279
- );
1280
- const loadStatus = React.useCallback(async () => {
1281
- setError("");
1282
- setChecking(true);
1283
- setStatus(null);
1284
- try {
1285
- const res = await call("status", {});
1286
- if (res?.ok === false) {
1287
- setError(res?.error ?? "status failed");
1288
- return;
1289
- }
1290
- setStatus(res);
1291
- const conn = res?.connection ?? null;
1292
- if (conn) setConnection(conn);
1293
- else setConnection({ ok: true, host: res?.remoteHost ?? "kai@ssh.ddtcorex.com" });
1294
- if (typeof res?.remoteHost === "string" && res.remoteHost) setRemoteHost(res.remoteHost);
1295
- } catch (e) {
1296
- setError(e?.message ?? String(e));
1297
- } finally {
1298
- setChecking(false);
1299
- }
1300
- await loadPage("localOnly", 0);
1301
- await loadPage("remoteOnly", 0);
1302
- }, [call, loadPage]);
1303
- React.useEffect(() => {
1304
- void (async () => {
1305
- try {
1306
- const v = await call("getRemoteConfig", {});
1307
- if (v?.remoteHost) setRemoteHost(String(v.remoteHost));
1308
- if (typeof v?.source === "string") setRemoteSource(v.source);
1309
- } catch {
1310
- }
1311
- })();
1312
- }, [call]);
1313
- const persistLastSync = React.useCallback((ts) => {
1314
- setLastSync(ts);
1315
- try {
1316
- if (typeof localStorage !== "undefined") localStorage.setItem("dsh-maestro-sync:lastSync", ts);
1317
- } catch {
1318
- }
1319
- }, []);
1320
- const handlePreview = React.useCallback(
1321
- async (direction) => {
1322
- setBusy(true);
1323
- setError("");
1324
- setResult(null);
1325
- setActionLimit(5);
1326
- setProgress({ phase: "listing", current: 0, total: 1 });
1327
- try {
1328
- const start = await call("previewStart", { direction });
1329
- const jobId = start?.jobId;
1330
- if (!jobId) {
1331
- setError(start?.error ?? "Preview failed to start");
1332
- setProgress(null);
1333
- return;
1334
- }
1335
- let done = false;
1336
- while (!done && !cancelledRef.current) {
1337
- const st = await call("previewStatus", { jobId });
1338
- if (st?.status === "running" && st?.progress) {
1339
- setProgress({ phase: st.progress.phase, current: st.progress.current, total: st.progress.total, file: st.progress.file });
1340
- }
1341
- if (st?.status === "done") {
1342
- if (st.preview) {
1343
- setPreview(st.preview);
1344
- setPreviewDirection(direction);
1345
- setConfirmOpen(true);
1346
- } else {
1347
- setError("Preview finished without a result");
1348
- }
1349
- done = true;
1350
- } else if (st?.status === "error") {
1351
- setError(st.error ?? "Preview failed");
1352
- done = true;
1353
- } else if (st?.ok === false) {
1354
- setError(st.error ?? "Preview failed");
1355
- done = true;
1356
- } else {
1357
- await new Promise((r) => setTimeout(r, 700));
1358
- }
1359
- }
1360
- } catch (e) {
1361
- setError(e?.message ?? String(e));
1362
- } finally {
1363
- setBusy(false);
1364
- setProgress(null);
1365
- }
1366
- },
1367
- [call]
1368
- );
1369
- const handleApply = React.useCallback(async () => {
1370
- if (!preview?.previewId) return;
1371
- setBusy(true);
1372
- setError("");
1373
- const previewId = preview.previewId;
1374
- const direction = previewDirection;
1375
- try {
1376
- const res = await call("apply", { previewId, direction, confirm: true });
1377
- setConfirmOpen(false);
1378
- setPreview(null);
1379
- if (res?.ok === false) {
1380
- const label = typeof res.code === "string" ? res.code : "apply failed";
1381
- setError(`${label}: ${res?.error ?? "apply failed"}`);
1382
- setResult({ kind: "apply", ok: false, text: "Apply failed" });
1383
- return;
1384
- }
1385
- setResult({ kind: "apply", ok: true, text: `Applied preview ${previewId.slice(0, 8)} \u2014 committed ${(res?.committed ?? []).length} file(s), +${res?.summary?.added ?? 0} entries` });
1386
- persistLastSync((/* @__PURE__ */ new Date()).toISOString());
1387
- void loadStatus();
1388
- } catch (e) {
1389
- setConfirmOpen(false);
1390
- setPreview(null);
1391
- setError(e?.message ?? String(e));
1392
- } finally {
1393
- setBusy(false);
1394
- }
1395
- }, [preview, previewDirection, call, loadStatus, persistLastSync]);
1396
- const cancelDialog = React.useCallback(() => {
1397
- setConfirmOpen(false);
1398
- setPreview(null);
1399
- }, []);
1400
- const handleBidirectionalPreview = React.useCallback(async () => {
1401
- setBusy(true);
1402
- setError("");
1403
- setResult(null);
1404
- setActionLimit(5);
1405
- setProgress({ phase: "planning", current: 0, total: 1 });
1406
- try {
1407
- const combined = await call("bidirectionalPreview", {});
1408
- if (combined?.ok === false) {
1409
- setError(combined?.error ?? "Bidirectional preview failed");
1410
- return;
1411
- }
1412
- if (!combined?.previewId) {
1413
- setError("Bidirectional preview finished without a result");
1414
- return;
1415
- }
1416
- setBiPreview(combined);
1417
- setBiConfirmOpen(true);
1418
- } catch (e) {
1419
- setError(e?.message ?? String(e));
1420
- } finally {
1421
- setBusy(false);
1422
- setProgress(null);
1423
- }
1424
- }, [call]);
1425
- const handleBidirectionalApply = React.useCallback(async () => {
1426
- if (!biPreview?.previewId) return;
1427
- setBusy(true);
1428
- setError("");
1429
- const previewId = biPreview.previewId;
1430
- try {
1431
- const res = await call("bidirectionalApply", { previewId, confirm: true });
1432
- setBiConfirmOpen(false);
1433
- setBiPreview(null);
1434
- if (res?.ok === false) {
1435
- const label = typeof res.code === "string" ? res.code : "apply failed";
1436
- setError(`${label}: ${res?.error ?? "apply failed"}`);
1437
- setResult({ kind: "bidirectional", ok: false, text: "Both-ways apply failed" });
1438
- return;
1439
- }
1440
- const pushAdded = res?.push?.summary?.added ?? 0;
1441
- const pullAdded = res?.pull?.summary?.added ?? 0;
1442
- const verification = res?.verification;
1443
- const converged = verification && (verification.copied ?? 0) === 0 && (verification.merged ?? 0) === 0 && (verification.conflicts ?? 0) === 0;
1444
- setResult({
1445
- kind: "bidirectional",
1446
- ok: true,
1447
- text: `Both ways applied \u2014 push +${pushAdded}, pull +${pullAdded} entries \xB7 ${converged ? "converged" : "remaining delta, review and re-run"}`
1448
- });
1449
- persistLastSync((/* @__PURE__ */ new Date()).toISOString());
1450
- void loadStatus();
1451
- } catch (e) {
1452
- setBiConfirmOpen(false);
1453
- setBiPreview(null);
1454
- setError(e?.message ?? String(e));
1455
- } finally {
1456
- setBusy(false);
1457
- }
1458
- }, [biPreview, call, loadStatus, persistLastSync]);
1459
- const cancelBidirectionalDialog = React.useCallback(() => {
1460
- setBiConfirmOpen(false);
1461
- setBiPreview(null);
1462
- }, []);
1463
- const saveRemoteHost = React.useCallback(
1464
- async (host) => {
1465
- setError("");
1466
- setHostFieldError(null);
1467
- try {
1468
- const res = await call("saveRemoteHost", { host });
1469
- if (res?.ok === false) {
1470
- const msg = res?.error ?? "save failed";
1471
- setHostFieldError(msg);
1472
- return { ok: false, error: msg };
1473
- }
1474
- if (res?.remoteHost) {
1475
- setRemoteHost(String(res.remoteHost));
1476
- setRemoteSource("settings");
1477
- }
1478
- return { ok: true };
1479
- } catch (e) {
1480
- const msg = e?.message ?? String(e);
1481
- setHostFieldError(msg);
1482
- return { ok: false, error: msg };
1483
- }
1484
- },
1485
- [call]
1486
- );
1487
- const loadMachines = React.useCallback(async () => {
1488
- try {
1489
- const res = await call("checkMachines", {});
1490
- if (res && typeof res === "object" && (res.localId !== void 0 || res.remoteId !== void 0)) {
1491
- setMachines({ localId: res.localId ?? null, remoteId: res.remoteId ?? null, from: res.from, to: res.to, ok: res.ok, reason: res.reason ?? res.error });
1492
- } else if (res && typeof res === "object" && (res.ok === false || typeof res.reason === "string" || typeof res.error === "string")) {
1493
- setMachines({ localId: res.localId ?? null, remoteId: res.remoteId ?? null, from: res.from, to: res.to, ok: false, reason: typeof res.reason === "string" ? res.reason : String(res.error ?? "machines check failed") });
1494
- } else {
1495
- setMachines(null);
1496
- }
1497
- } catch (e) {
1498
- setMachines({ localId: null, remoteId: null, ok: false, reason: e?.message ?? String(e) });
1499
- }
1500
- }, [call]);
1501
- const checkConnection = React.useCallback(async () => {
1502
- setError("");
1503
- setResult(null);
1504
- setChecking(true);
1505
- try {
1506
- const res = await call("check", {});
1507
- const conn = res?.connection ?? null;
1508
- if (!conn || conn.ok !== true) {
1509
- setConnection(conn ?? { ok: false, host: remoteHost, error: res?.error ?? "connection failed" });
1510
- return false;
1511
- }
1512
- setConnection(conn);
1513
- if (typeof res?.remoteHost === "string" && res.remoteHost) setRemoteHost(res.remoteHost);
1514
- await loadStatus();
1515
- await loadMachines();
1516
- return true;
1517
- } catch (e) {
1518
- setConnection({ ok: false, host: remoteHost, error: e?.message ?? String(e) });
1519
- return false;
1520
- } finally {
1521
- setChecking(false);
1522
- }
1523
- }, [call, loadStatus, loadMachines, remoteHost]);
1524
- const handleTunnelRestorePreview = React.useCallback(async () => {
1525
- setError("");
1526
- setResult(null);
1527
- setBusy(true);
1528
- try {
1529
- const res = await call("tunnelRestorePreview", { side: "local" });
1530
- if (res?.ok === false) {
1531
- setError(res?.error ?? "tunnel restore preview failed");
1532
- return;
1533
- }
1534
- if (!res?.previewId) {
1535
- setError("Tunnel restore preview finished without a result");
1536
- return;
1537
- }
1538
- setTunnelPreview(res);
1539
- setTunnelConfirmOpen(true);
1540
- } catch (e) {
1541
- setError(e?.message ?? String(e));
1542
- } finally {
1543
- setBusy(false);
1544
- }
1545
- }, [call]);
1546
- const confirmTunnelRestore = React.useCallback(async () => {
1547
- const previewId = tunnelPreview?.previewId;
1548
- if (!previewId) return;
1549
- setError("");
1550
- setBusy(true);
1551
- try {
1552
- const res = await call("tunnelRestore", { side: "local", previewId, confirm: true });
1553
- setTunnelConfirmOpen(false);
1554
- setTunnelPreview(null);
1555
- if (res && res.ok) {
1556
- setResult({ kind: "tunnel-restore", ok: true, text: `Tunnel restored from profile ${res.profile ?? "auto"} (local)` });
1557
- } else {
1558
- setError(res?.error ?? "tunnel restore failed");
1559
- }
1560
- } catch (e) {
1561
- setTunnelConfirmOpen(false);
1562
- setTunnelPreview(null);
1563
- setError(e?.message ?? String(e));
1564
- } finally {
1565
- setBusy(false);
1566
- }
1567
- }, [tunnelPreview, call]);
1568
- const cancelTunnelRestore = React.useCallback(() => {
1569
- setTunnelConfirmOpen(false);
1570
- setTunnelPreview(null);
1571
- }, []);
1572
- React.useEffect(() => {
1573
- if (!confirmOpen && !biConfirmOpen && !tunnelConfirmOpen) return;
1574
- const onKey = (e) => {
1575
- if (e.key === "Escape") {
1576
- cancelDialog();
1577
- cancelBidirectionalDialog();
1578
- cancelTunnelRestore();
1579
- }
1580
- };
1581
- window.addEventListener("keydown", onKey);
1582
- return () => window.removeEventListener("keydown", onKey);
1583
- }, [confirmOpen, biConfirmOpen, tunnelConfirmOpen, cancelDialog, cancelBidirectionalDialog, cancelTunnelRestore]);
1584
- return {
1585
- remoteHost,
1586
- remoteSource,
1587
- lastSync,
1588
- status,
1589
- connection,
1590
- machines,
1591
- checking,
1592
- busy,
1593
- result,
1594
- error,
1595
- hostFieldError,
1596
- setHostFieldError,
1597
- preview,
1598
- previewDirection,
1599
- confirmOpen,
1600
- biPreview,
1601
- biConfirmOpen,
1602
- tunnelPreview,
1603
- tunnelConfirmOpen,
1604
- actionLimit,
1605
- progress,
1606
- pages,
1607
- setActionLimit,
1608
- setError,
1609
- setResult,
1610
- loadStatus,
1611
- loadPage,
1612
- saveRemoteHost,
1613
- checkConnection,
1614
- loadMachines,
1615
- handleTunnelRestorePreview,
1616
- confirmTunnelRestore,
1617
- cancelTunnelRestore,
1618
- handlePreview,
1619
- handleApply,
1620
- cancelDialog,
1621
- handleBidirectionalPreview,
1622
- handleBidirectionalApply,
1623
- cancelBidirectionalDialog
1624
- };
1625
- }
1626
-
1627
- // src/client/sync/use-backup.ts
1628
- var React2 = __toESM(require("react"), 1);
1629
- function useBackupTarget(ctx) {
1630
- const [status, setStatus] = React2.useState(null);
1631
- const [checking, setChecking] = React2.useState(true);
1632
- const [busy, setBusy] = React2.useState(false);
1633
- const [error, setError] = React2.useState("");
1634
- const [backupPreview, setBackupPreview] = React2.useState(null);
1635
- const [restorePreview, setRestorePreview] = React2.useState(null);
1636
- const [gcReport, setGcReport] = React2.useState(null);
1637
- const [confirmOpen, setConfirmOpen] = React2.useState(null);
1638
- const call = React2.useCallback(async (method, payload) => {
1639
- const conn = ctx.connection ?? ctx.get?.("connection");
1640
- const res = await conn.rpc.call(RPC_CHANNEL, method, payload);
1641
- if (res && typeof res === "object" && "ok" in res) return res;
1642
- return { ok: true, value: res };
1643
- }, [ctx]);
1644
- const loadStatus = React2.useCallback(async () => {
1645
- setChecking(true);
1646
- setError("");
1647
- try {
1648
- const res = await call("backupStatus", {});
1649
- if (res.ok) setStatus(res.value);
1650
- else setError(res.error?.message ?? "backup status failed");
1651
- } catch (e) {
1652
- setError(e?.message ?? String(e));
1653
- } finally {
1654
- setChecking(false);
1655
- }
1656
- }, [call]);
1657
- const previewBackup = React2.useCallback(async () => {
1658
- setBusy(true);
1659
- setError("");
1660
- setBackupPreview(null);
1661
- try {
1662
- const res = await call("backupPreview", {});
1663
- if (res.ok) {
1664
- setBackupPreview(res.value);
1665
- setConfirmOpen("backup");
1666
- } else setError(res.error?.message ?? "backup preview failed");
1667
- } catch (e) {
1668
- setError(e?.message ?? String(e));
1669
- } finally {
1670
- setBusy(false);
1671
- }
1672
- }, [call]);
1673
- const applyBackup = React2.useCallback(async () => {
1674
- if (!backupPreview?.previewId) return;
1675
- setBusy(true);
1676
- try {
1677
- const res = await call("backupApply", { previewId: backupPreview.previewId, confirm: true });
1678
- setConfirmOpen(null);
1679
- setBackupPreview(null);
1680
- if (!res.ok) setError(res.error?.message ?? "backup apply failed");
1681
- void loadStatus();
1682
- } catch (e) {
1683
- setError(e?.message ?? String(e));
1684
- } finally {
1685
- setBusy(false);
1686
- }
1687
- }, [backupPreview, call, loadStatus]);
1688
- const previewRestore = React2.useCallback(
1689
- async (mode) => {
1690
- setBusy(true);
1691
- setError("");
1692
- try {
1693
- const res = await call("restorePreview", { mode });
1694
- if (res.ok) {
1695
- setRestorePreview(res.value);
1696
- setConfirmOpen("restore");
1697
- } else setError(res.error?.message ?? "restore preview failed");
1698
- } catch (e) {
1699
- setError(e?.message ?? String(e));
1700
- } finally {
1701
- setBusy(false);
1702
- }
1703
- },
1704
- [call]
1705
- );
1706
- const applyRestore = React2.useCallback(
1707
- async (mode, destDir) => {
1708
- if (!restorePreview?.previewId) return;
1709
- setBusy(true);
1710
- try {
1711
- const res = await call("restoreApply", { previewId: restorePreview.previewId, mode, destDir, confirm: true });
1712
- setConfirmOpen(null);
1713
- setRestorePreview(null);
1714
- if (!res.ok) setError(res.error?.message ?? "restore apply failed");
1715
- if (mode === "in-place") void loadStatus();
1716
- } catch (e) {
1717
- setError(e?.message ?? String(e));
1718
- } finally {
1719
- setBusy(false);
1720
- }
1721
- },
1722
- [restorePreview, call, loadStatus]
1723
- );
1724
- const previewGc = React2.useCallback(async () => {
1725
- setBusy(true);
1726
- setError("");
1727
- try {
1728
- const res = await call("backupGcPreview", {});
1729
- if (res.ok) {
1730
- setGcReport(res.value);
1731
- setConfirmOpen("gc");
1732
- } else setError(res.error?.message ?? "gc preview failed");
1733
- } catch (e) {
1734
- setError(e?.message ?? String(e));
1735
- } finally {
1736
- setBusy(false);
1737
- }
1738
- }, [call]);
1739
- const applyGc = React2.useCallback(async () => {
1740
- if (!gcReport?.previewId) return;
1741
- setBusy(true);
1742
- try {
1743
- const res = await call("backupGcApply", { previewId: gcReport.previewId, confirm: true });
1744
- setConfirmOpen(null);
1745
- setGcReport(null);
1746
- if (!res.ok) setError(res.error?.message ?? "gc apply failed");
1747
- void loadStatus();
1748
- } catch (e) {
1749
- setError(e?.message ?? String(e));
1750
- } finally {
1751
- setBusy(false);
1752
- }
1753
- }, [gcReport, call, loadStatus]);
1754
- const cancelDialog = React2.useCallback(() => {
1755
- setConfirmOpen(null);
1756
- setBackupPreview(null);
1757
- setRestorePreview(null);
1758
- setGcReport(null);
1759
- }, []);
1760
- const saveR2Config = React2.useCallback(
1761
- async (fields) => {
1762
- setError("");
1763
- try {
1764
- const res = await call("saveR2Config", fields);
1765
- if (!res.ok) {
1766
- const msg = res.error?.message ?? "save failed";
1767
- setError(msg);
1768
- return { ok: false, error: msg };
1769
- }
1770
- await loadStatus();
1771
- return { ok: true };
1772
- } catch (e) {
1773
- const msg = e?.message ?? String(e);
1774
- setError(msg);
1775
- return { ok: false, error: msg };
1776
- }
1777
- },
1778
- [call, loadStatus]
1779
- );
1780
- React2.useEffect(() => {
1781
- void loadStatus();
1782
- }, [loadStatus]);
1783
- const configured = status?.configured === true;
1784
- return {
1785
- status,
1786
- checking,
1787
- busy,
1788
- error,
1789
- backupPreview,
1790
- restorePreview,
1791
- gcReport,
1792
- confirmOpen,
1793
- canBackup: configured && !checking && !busy,
1794
- loadStatus,
1795
- saveR2Config,
1796
- previewBackup,
1797
- applyBackup,
1798
- previewRestore,
1799
- applyRestore,
1800
- previewGc,
1801
- applyGc,
1802
- cancelDialog
1803
- };
1804
- }
1805
-
1806
- // src/client/sync/R2SyncPanel.tsx
1807
- var React3 = __toESM(require("react"), 1);
1808
-
1809
- // src/client/sync/confirm-dialog.tsx
1810
- var import_jsx_runtime2 = require("react/jsx-runtime");
1811
- function tunnelLine(v) {
1812
- if (v === null || v === void 0) return "not set";
1813
- if (typeof v !== "object") return String(v);
1814
- const keys = Object.keys(v).sort();
1815
- if (keys.length === 0) return "not set";
1816
- return keys.map((k) => `${k}=${String(v[k])}`).join(" \xB7 ");
1817
- }
1818
- function TunnelRestoreDialog(props) {
1819
- const { preview, busy, onCancel, onConfirm } = props;
1820
- const expiresIn = preview?.expiresAt ? Math.max(0, Math.round((new Date(preview.expiresAt).getTime() - Date.now()) / 1e3)) : 0;
1821
- const changed = preview?.changed === true;
1822
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { "data-sync-dialog-overlay": "", "data-testid": "sync-tunnel-dialog-overlay", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { role: "dialog", "aria-modal": "true", "aria-labelledby": "sync-tunnel-dialog-title", "data-sync-dialog": "", "data-testid": "sync-tunnel-dialog", children: [
1823
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { "data-sync-dialog-top": "", children: [
1824
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { "data-sync-dialog-heading": "", children: [
1825
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { id: "sync-tunnel-dialog-title", "data-sync-dialog-title": "", children: [
1826
- "Restore tunnel \u2014 profile ",
1827
- preview?.profile ?? "?"
1828
- ] }),
1829
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { "data-sync-dialog-desc": "", children: [
1830
- "Rewrites ",
1831
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("code", { children: "domains.tunnel" }),
1832
- " in the shared settings store on this machine \xB7 preview expires in ",
1833
- expiresIn,
1834
- "s"
1835
- ] })
1836
- ] }),
1837
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", "data-sync-dialog-close": "", "aria-label": "Cancel", onClick: onCancel, disabled: busy, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Icon, { name: "close" }) })
1838
- ] }),
1839
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { "data-sync-planlist": "", "data-testid": "sync-tunnel-plan", children: [
1840
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { "data-action-row": "", "data-sync-planrow": "", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { "data-sync-planfile": "", children: [
1841
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { "data-sync-planfile-title": "", children: "Current value" }),
1842
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { "data-sync-planfile-path": "", "data-testid": "sync-tunnel-current", children: tunnelLine(preview?.current) })
1843
- ] }) }),
1844
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { "data-action-row": "", "data-sync-planrow": "", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { "data-sync-planfile": "", children: [
1845
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { "data-sync-planfile-title": "", children: "Restored from profile" }),
1846
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { "data-sync-planfile-path": "", "data-testid": "sync-tunnel-desired", children: tunnelLine(preview?.desired) })
1847
- ] }) }),
1848
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { "data-sync-planlist-note": "", children: changed ? "Only domains.tunnel changes \u2014 every other domain (jobs, notifier, guard, \u2026) is left untouched." : "The stored value already matches this profile \u2014 confirming is a no-op." })
1849
- ] }),
1850
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { "data-sync-dialog-actions": "", children: [
1851
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Button2, { variant: "outline", onClick: onCancel, disabled: busy, "aria-label": "Cancel", children: "Cancel" }),
1852
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Button2, { variant: "primary", "data-testid": "sync-tunnel-confirm", onClick: onConfirm, disabled: busy, busy, "aria-label": "Restore tunnel", children: busy ? "Restoring\u2026" : "Restore tunnel" })
1853
- ] })
1854
- ] }) });
1855
- }
1856
- function ConfirmDialog(props) {
1857
- const { preview, previewDirection, remoteHost, busy, actionLimit, planAgeSecs, onShowMore, onCancel, onApply, title, targetLabel, projectedTitle, projectedPreview, projectedNote, applyLabel } = props;
1858
- const actions = (preview?.actions ?? []).slice(0, actionLimit);
1859
- const hasMore = (preview?.actions?.length ?? 0) > actionLimit;
1860
- const summary = preview?.summary ?? {};
1861
- const sessionCounts = preview?.sessionCounts;
1862
- const previewId = String(preview?.previewId ?? "").slice(0, 8);
1863
- const sessionLine = sessionCounts ? `${sessionCounts.added ?? 0} added \xB7 ${sessionCounts.updated ?? 0} updated \xB7 ${sessionCounts.deleted ?? 0} deleted \xB7 ${sessionCounts.identical ?? 0} identical` : null;
1864
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { "data-sync-dialog-overlay": "", "data-testid": "sync-dialog-overlay", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { role: "dialog", "aria-modal": "true", "aria-labelledby": "sync-dialog-title", "data-sync-dialog": "", "data-testid": "sync-dialog", children: [
1865
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { "data-sync-dialog-top": "", children: [
1866
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { "data-sync-dialog-heading": "", children: [
1867
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { id: "sync-dialog-title", "data-sync-dialog-title": "", children: title ?? `Apply ${previewDirection} \u2014 preview ${previewId}` }),
1868
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { "data-sync-dialog-desc": "", children: [
1869
- targetLabel ?? remoteHost,
1870
- " \xB7 plan ",
1871
- planAgeSecs,
1872
- "s before expiry \xB7 ",
1873
- summary.copied ?? 0,
1874
- " copy \xB7 ",
1875
- summary.merged ?? 0,
1876
- " merge (+",
1877
- summary.added ?? 0,
1878
- " added) \xB7 ",
1879
- summary.skipped ?? 0,
1880
- " skip \xB7 ",
1881
- summary.conflicts ?? 0,
1882
- " conflict"
1883
- ] })
1884
- ] }),
1885
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", "data-sync-dialog-close": "", "aria-label": "Cancel", onClick: onCancel, disabled: busy, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Icon, { name: "close" }) })
1886
- ] }),
1887
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { "data-sync-planlist": "", children: [
1888
- sessionLine ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { "data-sync-sessioncounts": "", "data-testid": "sync-session-counts", children: [
1889
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { "data-sync-sessioncounts-lbl": "", children: [
1890
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Icon, { name: "swap" }),
1891
- "Sessions (counted by checksum)"
1892
- ] }),
1893
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { "data-sync-sessioncounts-line": "", children: sessionLine })
1894
- ] }) : null,
1895
- actions.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { "data-sync-empty": "", children: "Nothing to do \u2014 every file is already in sync." }) : actions.map((a) => {
1896
- const f = formatFile(a.path);
1897
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { "data-action-row": "", title: a.path, "data-sync-planrow": "", children: [
1898
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { "data-sync-planfile-icon": "", style: { color: "var(--dsw-alias-label-tertiary)" }, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Icon, { name: f.icon }) }),
1899
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { "data-sync-planfile": "", children: [
1900
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { "data-sync-planfile-title": "", children: [
1901
- f.title,
1902
- " \u2014 ",
1903
- actionLabel(a)
1904
- ] }),
1905
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { "data-sync-planfile-path": "", children: a.path })
1906
- ] }),
1907
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { "data-sync-planrow-meta": "", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { "data-sync-badge": "", "data-tone": actionTone(a), children: a.reason ?? a.action }) })
1908
- ] }, a.path);
1909
- }),
1910
- hasMore ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { "data-sync-planmore": "", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Button2, { size: "sm", variant: "ghost", onClick: onShowMore, "aria-label": "Show more actions", children: "Show more" }) }) : null
1911
- ] }),
1912
- projectedPreview ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { "data-sync-planlist": "", "data-testid": "sync-projected-plan", children: [
1913
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { "data-sync-planlist-title": "", children: projectedTitle ?? "Pull plan (projected)" }),
1914
- projectedNote ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { "data-sync-planlist-note": "", children: projectedNote }) : null,
1915
- (projectedPreview?.actions ?? []).slice(0, actionLimit).map((a) => {
1916
- const f = formatFile(a.path);
1917
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { "data-action-row": "", title: a.path, "data-sync-planrow": "", children: [
1918
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { "data-sync-planfile-icon": "", style: { color: "var(--dsw-alias-label-tertiary)" }, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Icon, { name: f.icon }) }),
1919
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { "data-sync-planfile": "", children: [
1920
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { "data-sync-planfile-title": "", children: [
1921
- f.title,
1922
- " \u2014 ",
1923
- actionLabel(a)
1924
- ] }),
1925
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { "data-sync-planfile-path": "", children: a.path })
1926
- ] }),
1927
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { "data-sync-planrow-meta": "", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { "data-sync-badge": "", "data-tone": actionTone(a), children: a.reason ?? a.action }) })
1928
- ] }, a.path);
1929
- })
1930
- ] }) : null,
1931
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { "data-sync-dialog-actions": "", children: [
1932
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Button2, { variant: "outline", onClick: onCancel, disabled: busy, "aria-label": "Cancel", children: "Cancel" }),
1933
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Button2, { variant: "primary", onClick: onApply, disabled: busy, busy, "aria-label": applyLabel ?? `Apply ${previewDirection}`, children: busy ? "Applying\u2026" : applyLabel ?? `Apply ${previewDirection} \u2014 ${summary.copied ?? 0} copy, ${summary.merged ?? 0} merge` })
1934
- ] })
1935
- ] }) });
1936
- }
1937
-
1938
- // src/client/sync/R2SyncPanel.tsx
1939
- var import_jsx_runtime3 = require("react/jsx-runtime");
1940
- var sourceLabel = (s) => s === "env" ? "Env" : s === "file" ? "Private file" : "Not configured";
1941
- function field(input) {
1942
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { "data-r2-field": "", children: [
1943
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("label", { "data-r2-field-label": "", htmlFor: input.id, children: input.label }),
1944
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1945
- "input",
1946
- {
1947
- id: input.id,
1948
- "data-r2-field-input": "",
1949
- "data-testid": input.id,
1950
- value: input.value,
1951
- onChange: (e) => input.onChange(e.target.value),
1952
- placeholder: input.placeholder,
1953
- autoComplete: "off",
1954
- autoCapitalize: "off",
1955
- spellCheck: false,
1956
- disabled: input.disabled,
1957
- "aria-invalid": input.error ? "true" : void 0,
1958
- "aria-describedby": input.error ? `${input.id}-error` : void 0
1959
- }
1960
- ),
1961
- input.error ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { id: `${input.id}-error`, "data-r2-field-error": "", role: "alert", "data-testid": `${input.id}-error`, children: input.error }) : null,
1962
- input.hint ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { "data-r2-field-hint": "", children: input.hint }) : null
1963
- ] });
1964
- }
1965
- function routeR2FieldError(msg) {
1966
- const m = /^\s*(?:invalid\s+)?(accountId|endpoint|region|bucket|prefix|provider)\b/i.exec(msg);
1967
- if (!m || m[1] === void 0) return null;
1968
- return { field: m[1], message: msg };
1969
- }
1970
- function ConfigForm(props) {
1971
- const b = props.b;
1972
- const st = b.status;
1973
- const [provider, setProvider] = React3.useState("r2");
1974
- const [accountId, setAccountId] = React3.useState("");
1975
- const [endpoint, setEndpoint] = React3.useState("");
1976
- const [region, setRegion] = React3.useState("");
1977
- const [bucket, setBucket] = React3.useState("");
1978
- const [prefix, setPrefix] = React3.useState("");
1979
- const [fieldErrors, setFieldErrors] = React3.useState({});
1980
- const [primed, setPrimed] = React3.useState(false);
1981
- React3.useEffect(() => {
1982
- if (primed || !st) return;
1983
- const r = st.r2;
1984
- setProvider(r?.provider === "aws" ? "aws" : "r2");
1985
- setAccountId("");
1986
- setEndpoint(r?.endpoint ?? "");
1987
- setRegion(r?.region ?? "");
1988
- setBucket(r?.bucket ?? "");
1989
- setPrefix(st.prefix ?? "");
1990
- setPrimed(true);
1991
- }, [st, primed]);
1992
- const busy = b.busy || b.checking;
1993
- const bind = (key, set) => (v) => {
1994
- set(v);
1995
- setFieldErrors((prev) => {
1996
- if (!(key in prev)) return prev;
1997
- const next = { ...prev };
1998
- delete next[key];
1999
- return next;
2000
- });
2001
- };
2002
- const save = async () => {
2003
- setFieldErrors({});
2004
- const res = await b.saveR2Config({ provider, accountId, endpoint, region, bucket, prefix });
2005
- if (!res.ok) {
2006
- const routed = routeR2FieldError(res.error ?? "");
2007
- if (routed) setFieldErrors({ [routed.field]: routed.message });
2008
- }
2009
- };
2010
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { "data-r2-config": "", children: [
2011
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { "data-r2-config-label": "", children: "Backup target" }),
2012
- /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { "data-r2-field": "", children: [
2013
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("label", { "data-r2-field-label": "", htmlFor: "r2-cfg-provider", children: "Provider" }),
2014
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { "data-r2-provider-row": "", role: "radiogroup", "aria-label": "Provider", children: ["r2", "aws"].map((p) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
2015
- "button",
2016
- {
2017
- type: "button",
2018
- "data-testid": `r2-cfg-provider-${p}`,
2019
- "data-r2-provider-opt": "",
2020
- "aria-pressed": provider === p,
2021
- disabled: busy,
2022
- onClick: () => setProvider(p),
2023
- children: p === "r2" ? "Cloudflare R2" : "AWS S3"
2024
- },
2025
- p
2026
- )) })
2027
- ] }),
2028
- provider === "r2" ? field({ id: "r2-cfg-account", label: "Account ID", value: accountId, placeholder: "32 hex chars \u2014 leave empty to keep the default endpoint", onChange: bind("accountId", setAccountId), disabled: busy, error: fieldErrors.accountId }) : null,
2029
- field({ id: "r2-cfg-endpoint", label: "Endpoint", value: endpoint, placeholder: "https://<account>.r2.cloudflarestorage.com", onChange: bind("endpoint", setEndpoint), disabled: busy, error: fieldErrors.endpoint }),
2030
- field({ id: "r2-cfg-region", label: "Region", value: region, placeholder: "auto", onChange: bind("region", setRegion), disabled: busy, error: fieldErrors.region }),
2031
- field({ id: "r2-cfg-bucket", label: "Bucket", value: bucket, placeholder: "your-bucket-name", onChange: bind("bucket", setBucket), disabled: busy, error: fieldErrors.bucket }),
2032
- field({ id: "r2-cfg-prefix", label: "Prefix", value: prefix, placeholder: "your-prefix/", onChange: bind("prefix", setPrefix), disabled: busy, error: fieldErrors.prefix }),
2033
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { "data-r2-config-row": "", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Button2, { "data-testid": "r2-save-config", variant: "primary", disabled: busy, busy: b.busy, onClick: () => void save(), children: b.busy ? "Saving\u2026" : "Save target" }) }),
2034
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { "data-r2-config-hint": "", children: "Access keys are never entered here \u2014 set R2_ACCESS_KEY_ID / R2_SECRET_ACCESS_KEY env or the 0600 sidecar file." })
2035
- ] });
2036
- }
2037
- function R2SyncPanel(props) {
2038
- const b = props.b;
2039
- const st = b.status;
2040
- const [moreOpen, setMoreOpen] = React3.useState(false);
2041
- const closeMore = () => setMoreOpen(false);
2042
- const banner = () => {
2043
- if (!st) return null;
2044
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { "data-r2-summary": "", children: [
2045
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Badge, { tone: st.configured ? "success" : "error", children: st.configured ? sourceLabel(st.source) : sourceLabel("none") }),
2046
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { "data-r2-muted": "", children: st.configured ? `${st.bucket} \xB7 ${st.prefix}` : "Set domains.sync.r2 + secret material to enable backup" })
2047
- ] });
2048
- };
2049
- const dialog = () => {
2050
- if (b.confirmOpen === "backup" && b.backupPreview) {
2051
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
2052
- ConfirmDialog,
2053
- {
2054
- kind: "backup",
2055
- title: "Apply backup",
2056
- targetLabel: `${st?.bucket ?? ""} / ${st?.prefix ?? ""}`,
2057
- preview: b.backupPreview,
2058
- previewDirection: "push",
2059
- remoteHost: st?.bucket ?? "R2",
2060
- busy: b.busy,
2061
- actionLimit: 5,
2062
- planAgeSecs: 0,
2063
- onShowMore: () => {
2064
- },
2065
- onCancel: b.cancelDialog,
2066
- onApply: () => void b.applyBackup()
2067
- }
2068
- );
2069
- }
2070
- if (b.confirmOpen === "restore" && b.restorePreview) {
2071
- const r = b.restorePreview;
2072
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
2073
- ConfirmDialog,
2074
- {
2075
- kind: "restore",
2076
- title: `Apply restore (${r.mode === "new-dir" ? "new dir" : "in place"})`,
2077
- targetLabel: "from backup HEAD",
2078
- preview: { ...r, summary: r.summary, actions: [] },
2079
- previewDirection: "pull",
2080
- remoteHost: "R2 backup",
2081
- busy: b.busy,
2082
- actionLimit: 5,
2083
- planAgeSecs: 0,
2084
- onShowMore: () => {
2085
- },
2086
- onCancel: b.cancelDialog,
2087
- onApply: () => void b.applyRestore(r.mode)
2088
- }
2089
- );
2090
- }
2091
- if (b.confirmOpen === "gc" && b.gcReport) {
2092
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
2093
- ConfirmDialog,
2094
- {
2095
- kind: "gc",
2096
- title: "Apply GC",
2097
- targetLabel: `${b.gcReport.deletableBlobs?.length ?? 0} blobs \xB7 ${b.gcReport.freedBytes ?? 0} bytes`,
2098
- preview: { ...b.gcReport, summary: {}, actions: [] },
2099
- previewDirection: "push",
2100
- remoteHost: st?.bucket ?? "R2",
2101
- busy: b.busy,
2102
- actionLimit: 5,
2103
- planAgeSecs: 0,
2104
- onShowMore: () => {
2105
- },
2106
- onCancel: b.cancelDialog,
2107
- onApply: () => void b.applyGc()
2108
- }
2109
- );
2110
- }
2111
- return null;
2112
- };
2113
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { "data-sync-root": "", "data-r2-root": "", "aria-busy": b.busy, children: [
2114
- banner(),
2115
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ConfigForm, { b }),
2116
- /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { "data-r2-stats": "", children: [
2117
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(StatTile, { icon: "server", value: String(st?.eligible?.md ?? 0), label: "memory" }),
2118
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(StatTile, { icon: "refresh", value: String(st?.eligible?.sessions ?? 0), label: "sessions" }),
2119
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(StatTile, { icon: "check", value: st?.lastManifest ? "yes" : "no", label: "last backup" })
2120
- ] }),
2121
- /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { "data-r2-actions": "", "data-sync-actions-bar": "", children: [
2122
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Button2, { "data-testid": "r2-preview-backup", kind: "primary", disabled: !b.canBackup, onClick: () => void b.previewBackup(), children: "Preview Backup" }),
2123
- /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { "data-r2-more": "", children: [
2124
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
2125
- Button2,
2126
- {
2127
- "data-testid": "r2-more",
2128
- variant: "outline",
2129
- disabled: !b.canBackup,
2130
- "aria-haspopup": "menu",
2131
- "aria-expanded": moreOpen,
2132
- onClick: () => setMoreOpen((v) => !v),
2133
- children: "More"
2134
- }
2135
- ),
2136
- moreOpen ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { "data-r2-more-menu": "", role: "menu", "aria-label": "More backup actions", children: [
2137
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Button2, { "data-testid": "r2-restore-newdir", role: "menuitem", variant: "ghost", disabled: !b.canBackup, onClick: () => {
2138
- closeMore();
2139
- void b.previewRestore("new-dir");
2140
- }, children: "Restore to new folder\u2026" }),
2141
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Button2, { "data-testid": "r2-restore-inplace", role: "menuitem", variant: "ghost", disabled: !b.canBackup, onClick: () => {
2142
- closeMore();
2143
- void b.previewRestore("in-place");
2144
- }, children: "Restore in place\u2026" }),
2145
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Button2, { "data-testid": "r2-preview-gc", role: "menuitem", variant: "ghost", disabled: !b.canBackup, onClick: () => {
2146
- closeMore();
2147
- void b.previewGc();
2148
- }, children: "Preview GC" })
2149
- ] }) : null
2150
- ] })
2151
- ] }),
2152
- b.error ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { role: "alert", "data-sync-error": "", children: b.error }) : null,
2153
- dialog()
2154
- ] });
2155
- }
2156
-
2157
- // src/client/sync/SyncPanel.tsx
2158
- var import_jsx_runtime4 = require("react/jsx-runtime");
2159
- function SyncPanel(props) {
2160
- const s = useSync(props.ctx);
2161
- const b = useBackupTarget(props.ctx);
2162
- const [tab, setTab] = React4.useState("remote");
2163
- const { connection, checking, busy, error, result, status, remoteHost, remoteSource, lastSync, confirmOpen, preview, previewDirection, biPreview, biConfirmOpen, tunnelPreview, tunnelConfirmOpen, hostFieldError, actionLimit, pages } = s;
2164
- const st = b.status;
2165
- const isConnected = connection?.ok === true;
2166
- const isDisconnected = connection?.ok === false;
2167
- const machinesBlocked = s.machines?.ok === false;
2168
- const canSync = isConnected && !checking && !busy && !machinesBlocked;
2169
- const planAgeSecs = preview?.expiresAt ? Math.max(0, Math.round((new Date(preview.expiresAt).getTime() - Date.now()) / 1e3)) : 0;
2170
- const [hostInput, setHostInput] = React4.useState("");
2171
- React4.useEffect(() => {
2172
- if (hostInput === "" && remoteHost !== "\u2026") setHostInput(remoteHost);
2173
- }, [remoteHost, hostInput]);
2174
- const handleCheck = React4.useCallback(async () => {
2175
- const host = hostInput.trim();
2176
- if (!host) return;
2177
- const saved = await s.saveRemoteHost(host);
2178
- if (!saved.ok) return;
2179
- await s.checkConnection();
2180
- }, [hostInput, s]);
2181
- const sourceLabel2 = remoteSource === "machine" ? "Saved for this machine" : remoteSource === "settings" ? "Saved in settings" : remoteSource === "env" ? "From REMOTE_HOST env" : "Built-in default";
2182
- const [collapsed, setCollapsed] = React4.useState(() => {
2183
- const narrow = typeof window !== "undefined" && typeof window.innerWidth === "number" && window.innerWidth < 640;
2184
- return { localOnly: narrow, remoteOnly: narrow };
2185
- });
2186
- const renderBucket = (bucket, heading, empty) => {
2187
- const page = pages[bucket];
2188
- const icon = bucket === "localOnly" ? "upload" : "download";
2189
- const open = !collapsed[bucket];
2190
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("section", { "data-sync-dcol": "", "data-bucket": bucket, "data-collapsed": String(!open), "aria-label": heading, children: [
2191
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("header", { "data-sync-dcol-head": "", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
2192
- "button",
2193
- {
2194
- type: "button",
2195
- "data-sync-dcol-toggle": "",
2196
- "aria-expanded": open,
2197
- "aria-label": `${open ? "Collapse" : "Expand"} ${heading}`,
2198
- onClick: () => setCollapsed((prev) => ({ ...prev, [bucket]: !prev[bucket] })),
2199
- children: [
2200
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { "data-sync-dcol-title": "", children: [
2201
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Icon, { name: open ? "chevron-down" : "chevron-right" }),
2202
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Icon, { name: icon }),
2203
- heading
2204
- ] }),
2205
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { "data-sync-dcol-count": "", children: [
2206
- page.files.length,
2207
- "/",
2208
- page.total
2209
- ] })
2210
- ]
2211
- }
2212
- ) }),
2213
- open ? isDisconnected ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { "data-sync-empty": "", children: [
2214
- "Cannot check remote \u2014 SSH to ",
2215
- connection.host,
2216
- " is not connected."
2217
- ] }) : page.files.length === 0 && !page.loaded ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { "data-sync-loading": "", children: [
2218
- "Checking ",
2219
- heading.toLowerCase(),
2220
- "\u2026"
2221
- ] }) : page.files.length === 0 && !checking ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { "data-sync-empty": "", children: empty }) : page.files.map((p) => {
2222
- const f = formatFile(p);
2223
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { "data-sync-file": "", title: p, children: [
2224
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { "data-sync-file-icon": "", style: { color: "var(--dsw-alias-label-tertiary)" }, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Icon, { name: f.icon }) }),
2225
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { "data-sync-file-main": "", children: [
2226
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { "data-sync-file-title": "", children: f.title }),
2227
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { "data-sync-file-path": "", children: f.path })
2228
- ] }),
2229
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { "data-sync-file-meta": "", children: f.meta })
2230
- ] }, p);
2231
- }) : null,
2232
- open && page.next != null ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("footer", { "data-sync-dcol-foot": "", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Button2, { size: "sm", variant: "ghost", onClick: () => void s.loadPage(bucket, page.next), "aria-label": `Show more ${heading}`, children: "Show more" }) }) : null
2233
- ] });
2234
- };
2235
- const headerStatus = tab === "remote" ? checking ? "Checking connection\u2026" : isConnected ? `${connection.host} \xB7 ${humanSummary(status)}` : isDisconnected ? `Cannot reach ${connection.host}` : connection === null ? "Not checked yet \u2014 configure SSH and check" : humanSummary(status) : b.checking ? "Checking backup configuration\u2026" : st?.configured ? `Backup ${st.prefix}` : "Not configured";
2236
- const renderRemote = () => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { "data-sync-root": "", "aria-busy": busy || checking, children: [
2237
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { "data-sync-ssh": "", children: [
2238
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("label", { "data-sync-ssh-label": "", htmlFor: "sync-ssh-host", children: "SSH target" }),
2239
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
2240
- "input",
2241
- {
2242
- id: "sync-ssh-host",
2243
- "data-sync-ssh-input": "",
2244
- "data-testid": "sync-ssh-host",
2245
- value: hostInput,
2246
- onChange: (e) => {
2247
- setHostInput(e.target.value);
2248
- void s.setHostFieldError?.(null);
2249
- },
2250
- placeholder: "user@host",
2251
- autoComplete: "off",
2252
- autoCapitalize: "off",
2253
- spellCheck: false,
2254
- disabled: checking || busy,
2255
- "aria-describedby": "sync-ssh-src",
2256
- "aria-invalid": hostFieldError ? "true" : void 0
2257
- }
2258
- ),
2259
- hostFieldError ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { "data-sync-field-error": "", role: "alert", "data-testid": "sync-ssh-host-error", style: { fontSize: 12, lineHeight: "16px", color: "var(--dsw-alias-state-error-primary)", overflowWrap: "anywhere" }, children: hostFieldError }) : null,
2260
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { "data-sync-ssh-row": "", children: [
2261
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Button2, { variant: "outline", "data-testid": "sync-save-host", disabled: checking || busy || hostInput.trim().length === 0, onClick: () => void s.saveRemoteHost(hostInput.trim()), children: "Save" }),
2262
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Button2, { variant: "primary", "data-testid": "sync-check-connection", disabled: checking || busy || hostInput.trim().length === 0, busy: checking, onClick: () => void handleCheck(), children: checking ? "Checking\u2026" : "Check connection" })
2263
- ] }),
2264
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { id: "sync-ssh-src", "data-sync-ssh-src": "", children: sourceLabel2 })
2265
- ] }),
2266
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { "data-sync-conn": "", "data-state": isDisconnected ? "bad" : checking ? "checking" : "ok", "data-testid": "sync-connection", children: [
2267
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { "data-sync-conn-dot": "" }),
2268
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { "data-sync-conn-main": "", children: checking ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { "data-sync-conn-title": "", children: [
2269
- "Checking SSH to ",
2270
- remoteHost,
2271
- "\u2026"
2272
- ] }) : isConnected ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
2273
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { "data-sync-conn-title": "", children: [
2274
- "Connected to ",
2275
- connection.host,
2276
- connection.latencyMs != null ? ` \xB7 ${connection.latencyMs}ms` : "",
2277
- " \xB7 SSH ready"
2278
- ] }),
2279
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { "data-sync-conn-desc": "", children: "Use Preview to see the exact plan \u2014 Apply always requires confirmation." })
2280
- ] }) : isDisconnected ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
2281
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { "data-sync-conn-title": "", children: [
2282
- "Cannot reach ",
2283
- connection.host,
2284
- " \u2014 sync is paused"
2285
- ] }),
2286
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { "data-sync-conn-desc": "", children: connection.error ? String(connection.error).slice(0, 220) : "SSH failed. Check that the host is reachable and your key is loaded." })
2287
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { "data-sync-conn-title": "", children: "Not checked yet \u2014 configure SSH above, then Check connection." }) }),
2288
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Button2, { 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" }, children: checking ? "Checking" : "Refresh" })
2289
- ] }),
2290
- isConnected ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
2291
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { "data-sync-fields": "", children: [
2292
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { "data-sync-field": "", children: [
2293
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { "data-sync-field-label": "", children: "Remote host" }),
2294
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { "data-sync-field-value": "", "data-testid": "sync-remote-host", children: remoteHost })
2295
- ] }),
2296
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { "data-sync-field": "", children: [
2297
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { "data-sync-field-label": "", children: "Last sync (this browser)" }),
2298
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { "data-sync-field-value": "", "data-testid": "sync-last-sync", children: formatLastSync(lastSync) })
2299
- ] }),
2300
- s.machines ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { "data-sync-field": "", children: [
2301
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { "data-sync-field-label": "", children: "Machines" }),
2302
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { "data-sync-field-value": "", "data-testid": "sync-machines", children: [
2303
- s.machines.localId ?? "?",
2304
- " \u2194 ",
2305
- s.machines.remoteId ?? "?"
2306
- ] }),
2307
- s.machines.reason ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { "data-sync-field-note": "", "data-testid": "sync-machines-error", style: { fontSize: 12, lineHeight: "16px", color: "var(--dsw-alias-label-secondary)", overflowWrap: "anywhere" }, children: s.machines.reason }) : null,
2308
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Button2, { variant: "outline", size: "sm", "data-testid": "sync-tunnel-restore", disabled: checking || busy, onClick: () => void s.handleTunnelRestorePreview(), children: "Restore tunnel" })
2309
- ] }) : null
2310
- ] }),
2311
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { "data-sync-stats": "", children: [
2312
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
2313
- StatTile,
2314
- {
2315
- icon: "upload",
2316
- value: status ? String(status.localOnly ?? 0) : "\u2014",
2317
- label: "Only here",
2318
- hint: status?.localOnly ? "Pushed on Preview Push" : "Nothing here",
2319
- ariaLabel: "Files only on this machine"
2320
- }
2321
- ),
2322
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
2323
- StatTile,
2324
- {
2325
- icon: "swap",
2326
- value: status ? String(status.both ?? 0) : "\u2014",
2327
- label: "On both",
2328
- hint: "Content compared in Preview",
2329
- ariaLabel: "Files on both machines"
2330
- }
2331
- ),
2332
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
2333
- StatTile,
2334
- {
2335
- icon: "download",
2336
- value: status ? String(status.remoteOnly ?? 0) : "\u2014",
2337
- label: "Only there",
2338
- hint: status?.remoteOnly ? "Pulled on Preview Pull" : "Nothing there",
2339
- ariaLabel: "Files only on the other machine"
2340
- }
2341
- )
2342
- ] }),
2343
- machinesBlocked ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { "data-sync-notice": "", "data-tone": "bad", role: "status", "data-testid": "sync-machines-gate", children: [
2344
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { "data-sync-notice-icon": "", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Icon, { name: "alert" }) }),
2345
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { "data-sync-notice-main": "", children: [
2346
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { "data-sync-notice-title": "", children: "Sync is locked \u2014 machine identity check failed" }),
2347
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { "data-sync-notice-desc": "", children: [
2348
- s.machines?.reason ?? "The two sides do not look like two distinct machines.",
2349
- " Fix the SSH target so it points at the OTHER machine, then Check connection again."
2350
- ] })
2351
- ] })
2352
- ] }) : null,
2353
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { "data-sync-actions": "", "data-sync-actions-bar": "", children: [
2354
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Button2, { variant: "primary", icon: "swap", disabled: !canSync, "data-testid": "sync-both-ways", onClick: () => void s.handleBidirectionalPreview(), children: busy ? "Working\u2026" : "Sync both ways" }),
2355
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Button2, { variant: "outline", icon: "download", disabled: !canSync, "data-testid": "sync-preview-pull", onClick: () => void s.handlePreview("pull"), children: busy ? "Working\u2026" : "Preview Pull" }),
2356
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Button2, { variant: "outline", icon: "upload", disabled: !canSync, "data-testid": "sync-preview-push", onClick: () => void s.handlePreview("push"), children: busy ? "Working\u2026" : "Preview Push" })
2357
- ] }),
2358
- busy && s.progress ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { "data-sync-progress": "", role: "status", "aria-live": "polite", "data-testid": "sync-progress", children: [
2359
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { "data-sync-progress-meta": "", children: s.progress.phase === "hashing" ? `Reviewing sessions ${s.progress.current}/${s.progress.total}${s.progress.file ? ` \u2014 ${formatFile(s.progress.file).path}` : ""}` : s.progress.phase === "staging" ? `Staging files ${s.progress.current}/${s.progress.total}` : s.progress.phase === "planning" ? "Building the exact plan\u2026" : "Listing both machines\u2026" }),
2360
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { "data-sync-progress-track": "", role: "progressbar", "aria-valuemin": 0, "aria-valuemax": s.progress.total, "aria-valuenow": s.progress.current, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { "data-sync-progress-fill": "", style: { width: `${s.progress.total > 0 ? Math.min(100, Math.round(s.progress.current / s.progress.total * 100)) : 0}%` } }) })
2361
- ] }) : null,
2362
- result ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { "data-sync-notice": "", "data-tone": result.ok ? "ok" : "bad", role: "status", "aria-live": "polite", children: [
2363
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { "data-sync-notice-icon": "", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Icon, { name: result.ok ? "check" : "alert" }) }),
2364
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { "data-sync-notice-main": "", children: [
2365
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { "data-sync-notice-title": "", children: result.ok ? "Apply complete" : "Apply failed" }),
2366
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { "data-sync-notice-desc": "", children: result.text })
2367
- ] })
2368
- ] }) : null,
2369
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { "data-sync-filetables": "", children: [
2370
- renderBucket("remoteOnly", "Coming from the other machine", "Nothing to pull \u2014 the other machine has no eligible files here."),
2371
- renderBucket("localOnly", "Ready to send", "Nothing to push \u2014 this machine has no eligible files here.")
2372
- ] })
2373
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { "data-sync-notice": "", "data-tone": "ok", role: "status", children: [
2374
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { "data-sync-notice-icon": "", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Icon, { name: isDisconnected ? "alert" : "clock" }) }),
2375
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { "data-sync-notice-main": "", children: [
2376
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { "data-sync-notice-title": "", children: isDisconnected ? "Connection failed" : "Preview and file lists are locked" }),
2377
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { "data-sync-notice-desc": "", children: isDisconnected ? "Fix the SSH target above and check again." : "Configure the SSH target above, then Check connection \u2014 everything below unlocks after a successful check." })
2378
- ] })
2379
- ] }),
2380
- error ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { "data-sync-notice": "", "data-tone": "bad", role: "alert", children: [
2381
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { "data-sync-notice-icon": "", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Icon, { name: "alert" }) }),
2382
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { "data-sync-notice-main": "", children: [
2383
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { "data-sync-notice-title": "", children: "Something went wrong" }),
2384
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { "data-sync-notice-desc": "", children: error })
2385
- ] })
2386
- ] }) : null,
2387
- confirmOpen && preview ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
2388
- ConfirmDialog,
2389
- {
2390
- preview,
2391
- previewDirection,
2392
- remoteHost,
2393
- busy,
2394
- actionLimit,
2395
- planAgeSecs,
2396
- onShowMore: () => s.setActionLimit((n) => n + 5),
2397
- onCancel: s.cancelDialog,
2398
- onApply: () => void s.handleApply()
2399
- }
2400
- ) : null,
2401
- biConfirmOpen && biPreview ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
2402
- ConfirmDialog,
2403
- {
2404
- preview: biPreview.push,
2405
- previewDirection: "push",
2406
- remoteHost,
2407
- busy,
2408
- actionLimit,
2409
- planAgeSecs: Math.max(0, Math.round((new Date(biPreview.expiresAt).getTime() - Date.now()) / 1e3)),
2410
- onShowMore: () => s.setActionLimit((n) => n + 5),
2411
- onCancel: s.cancelBidirectionalDialog,
2412
- onApply: () => void s.handleBidirectionalApply(),
2413
- title: `Apply both ways \u2014 preview ${String(biPreview.previewId ?? "").slice(0, 8)}`,
2414
- projectedTitle: "Pull plan (projected)",
2415
- projectedPreview: biPreview.pullProjected,
2416
- projectedNote: "Projected \u2014 recomputed exact after the push lands.",
2417
- applyLabel: "Apply both ways"
2418
- }
2419
- ) : null,
2420
- tunnelConfirmOpen && tunnelPreview ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
2421
- TunnelRestoreDialog,
2422
- {
2423
- preview: tunnelPreview,
2424
- busy,
2425
- onCancel: s.cancelTunnelRestore,
2426
- onConfirm: () => void s.confirmTunnelRestore()
2427
- }
2428
- ) : null,
2429
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { "data-sync-muted": "", style: { textAlign: "center" }, children: "Notes and sessions are merged \u2014 never overwritten. Apply always requires confirmation." })
2430
- ] });
2431
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { "data-sync-shell": "", children: [
2432
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { display: "flex", gap: 10, alignItems: "flex-start", padding: "2px 2px 4px" }, children: [
2433
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(MaestroLogo, {}),
2434
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { display: "flex", flexDirection: "column", minWidth: 0, gap: 2 }, children: [
2435
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: { fontSize: 15, fontWeight: 600, lineHeight: "22px", color: "var(--dsw-alias-label-primary)" }, children: "Maestro Sync" }),
2436
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { style: { fontSize: 12, lineHeight: "16px", color: "var(--dsw-alias-label-secondary)", overflowWrap: "anywhere" }, children: headerStatus })
2437
- ] })
2438
- ] }),
2439
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { "data-sync-tabs": "", role: "tablist", "aria-label": "Maestro Sync modes", children: [
2440
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { "data-testid": "sync-tab-remote", role: "tab", "aria-selected": tab === "remote", "data-sync-tab": "", onClick: () => setTab("remote"), children: "Remote Sync" }),
2441
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { "data-testid": "sync-tab-r2", role: "tab", "aria-selected": tab === "r2", "data-sync-tab": "", onClick: () => setTab("r2"), children: "R2 Sync" })
2442
- ] }),
2443
- tab === "remote" ? renderRemote() : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(R2SyncPanel, { b })
2444
- ] });
2445
- }
2446
-
2447
- // src/client/sync/index.tsx
2448
- function installStyleTag(css, pluginCss) {
2449
- if (typeof document === "undefined") return () => {
2450
- };
2451
- const tag = document.createElement("style");
2452
- tag.dataset.plugin = "@ddtcorex/dsh-maestro-sync";
2453
- tag.dataset.pluginCss = pluginCss;
2454
- tag.textContent = css;
2455
- document.head.appendChild(tag);
2456
- return () => {
2457
- document.querySelector(`style[data-plugin-css="${pluginCss}"]`)?.remove();
2458
- };
2459
- }
2460
- var SYNC_CSS = `
2461
- [data-sync-root], [data-sync-root] * { box-sizing: border-box; }
2462
- [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; }
2463
-
2464
- /* connection banner */
2465
- [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); }
2466
- [data-sync-conn][data-state="bad"] { border-color: var(--dsw-alias-state-error-primary, #DC2626); }
2467
- [data-sync-conn-dot] { flex: none; width: 8px; height: 8px; border-radius: 50%; margin-top: 5px; }
2468
- [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); }
2469
- [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); }
2470
- [data-sync-conn][data-state="checking"] [data-sync-conn-dot] { background: var(--dsw-alias-label-secondary); opacity: 0.6; }
2471
- [data-sync-conn-main] { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
2472
- [data-sync-conn-title] { font-size: 12px; font-weight: 600; line-height: 16px; }
2473
- [data-sync-conn-desc] { font-size: 11px; line-height: 14px; color: var(--dsw-alias-label-secondary); word-break: break-word; }
2474
-
2475
- /* identity fields */
2476
- [data-sync-fields] { display: flex; gap: 10px; flex-wrap: wrap; }
2477
- [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; }
2478
- [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; }
2479
- [data-sync-field-value] { font-size: 13px; font-weight: 600; word-break: break-all; margin-top: 2px; display: block; }
2480
-
2481
- /* stat tiles */
2482
- [data-sync-stats] { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
2483
- [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; }
2484
- button[data-sync-stat] { cursor: pointer; }
2485
- button[data-sync-stat]:hover { border-color: var(--dsw-alias-border-l2); background: var(--dsw-alias-bg-layer-3); }
2486
- button[data-sync-stat]:focus-visible { outline: 2px solid var(--dsw-alias-border-l2); outline-offset: 2px; }
2487
- [data-sync-stat-icon] { display: inline-flex; color: var(--dsw-alias-label-tertiary); }
2488
- [data-sync-stat-value] { font-size: 22px; font-weight: 700; line-height: 1; letter-spacing: -0.02em; }
2489
- [data-sync-stat-label] { font-size: 12px; font-weight: 600; line-height: 16px; }
2490
- [data-sync-stat-hint] { font-size: 10px; line-height: 13px; color: var(--dsw-alias-label-tertiary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
2491
-
2492
- /* actions */
2493
- [data-sync-actions] { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
2494
-
2495
- /* preview progress \u2014 live per-file ticks while sessions are counted */
2496
- [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); }
2497
- [data-sync-progress-meta] { font-size: 11px; line-height: 14px; color: var(--dsw-alias-label-secondary); word-break: break-word; }
2498
- [data-sync-progress-track] { display: block; height: 4px; border-radius: 999px; background: var(--dsw-alias-bg-layer-3); overflow: hidden; }
2499
- [data-sync-progress-fill] { display: block; height: 100%; border-radius: 999px; background: var(--dsw-alias-state-info-primary, #0A84FF); transition: width 0.3s ease; }
2500
- @media (prefers-reduced-motion: reduce) { [data-sync-progress-fill] { transition: none; } }
2501
-
2502
- /* dialog session counts \u2014 counted by checksum, no per-file rows */
2503
- [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; }
2504
- [data-sync-sessioncounts-lbl] { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--dsw-alias-label-primary); }
2505
- [data-sync-sessioncounts-line] { font-size: 11px; line-height: 14px; color: var(--dsw-alias-label-secondary); }
2506
-
2507
- /* notice / error */
2508
- [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); }
2509
- [data-sync-notice][data-tone="bad"] { border-color: var(--dsw-alias-state-error-primary, #DC2626); }
2510
- [data-sync-notice-icon] { display: inline-flex; color: var(--dsw-alias-label-tertiary); margin-top: 1px; }
2511
- [data-sync-notice][data-tone="bad"] [data-sync-notice-icon] { color: var(--dsw-alias-state-error-primary, #DC2626); }
2512
- [data-sync-notice][data-tone="ok"] [data-sync-notice-icon] { color: var(--dsw-alias-state-success-primary, #16A34A); }
2513
- [data-sync-notice-main] { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
2514
- [data-sync-notice-title] { font-size: 12px; font-weight: 600; }
2515
- [data-sync-notice-desc] { font-size: 11px; line-height: 14px; color: var(--dsw-alias-label-secondary); word-break: break-word; }
2516
-
2517
- /* badges */
2518
- [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; }
2519
- [data-sync-badge][data-tone="brand"] { color: var(--dsw-alias-label-primary); border-color: var(--dsw-alias-border-l2); }
2520
- [data-sync-badge][data-tone="success"] { color: var(--dsw-alias-state-success-primary); }
2521
- [data-sync-badge][data-tone="error"] { color: var(--dsw-alias-state-error-primary); border-color: var(--dsw-alias-state-error-primary); }
2522
- [data-sync-badge][data-tone="warn"] { color: var(--dsw-alias-state-warn-primary); }
2523
-
2524
- [data-sync-muted] { color: var(--dsw-alias-label-secondary); font-size: 11px; line-height: 14px; }
2525
-
2526
- /* ---- confirmation dialog: bottom sheet on mobile, centered card \u2265640 ---- */
2527
- [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; }
2528
- [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; }
2529
- [data-sync-dialog-top] { display: flex; align-items: flex-start; gap: 8px; }
2530
- [data-sync-dialog-heading] { flex: 1; min-width: 0; }
2531
- [data-sync-dialog-title] { font-size: 14px; font-weight: 700; letter-spacing: -0.01em; line-height: 20px; }
2532
- [data-sync-dialog-desc] { font-size: 12px; line-height: 16px; color: var(--dsw-alias-label-secondary); margin-top: 2px; }
2533
- [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; }
2534
- [data-sync-dialog-close]:hover { color: var(--dsw-alias-label-primary); border-color: var(--dsw-alias-border-l2); }
2535
- [data-sync-dialog-close]:focus-visible { outline: 2px solid var(--dsw-alias-border-l2); outline-offset: 2px; }
2536
- [data-sync-planlist] { display: flex; flex-direction: column; border: 1px solid var(--dsw-alias-border-l1); border-radius: 10px; overflow: hidden; }
2537
- [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); }
2538
- [data-sync-planrow]:last-child { border-bottom: none; }
2539
- [data-sync-planfile-icon] { display: inline-flex; flex: none; }
2540
- [data-sync-planfile] { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
2541
- [data-sync-planfile-title] { font-size: 12px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
2542
- [data-sync-planfile-path] { font-size: 11px; color: var(--dsw-alias-label-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
2543
- [data-sync-planrow-meta] { flex: none; }
2544
- [data-sync-planmore] { display: flex; justify-content: center; padding: 8px; }
2545
- [data-sync-empty] { padding: 16px 12px; text-align: center; color: var(--dsw-alias-label-secondary); font-size: 12px; line-height: 16px; }
2546
- [data-sync-loading] { padding: 16px 12px; text-align: center; color: var(--dsw-alias-label-tertiary); font-size: 12px; line-height: 16px; }
2547
- [data-sync-dialog-actions] { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
2548
-
2549
- /* ---- file list sections (in-card) ---- */
2550
- [data-sync-filetables] { display: grid; grid-template-columns: 1fr; gap: 12px; }
2551
- @media (min-width: 1024px) {
2552
- [data-sync-filetables] { grid-template-columns: 1fr 1fr; }
2553
- }
2554
- [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; }
2555
- [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); }
2556
- [data-sync-dcol-title] { font-size: 12px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
2557
- [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; }
2558
- [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; }
2559
- [data-sync-file]:last-child { border-bottom: none; }
2560
- [data-sync-file-icon] { display: inline-flex; flex: none; color: var(--dsw-alias-label-tertiary); }
2561
- [data-sync-file-main] { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
2562
- [data-sync-file-title] { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 12px; }
2563
- [data-sync-file-path] { font-size: 11px; color: var(--dsw-alias-label-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
2564
- [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; }
2565
- [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); }
2566
-
2567
- /* spinner */
2568
- @keyframes sync-spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
2569
- .sync-spin { display: inline-block; animation: sync-spin 0.8s linear infinite; font-size: 14px; line-height: 1; }
2570
-
2571
- /* ---- breakpoints ---- */
2572
- @media (max-width: 640px) {
2573
- [data-sync-fields] { gap: 8px; }
2574
- [data-sync-field] { flex: 1 1 0; min-width: 0; padding: 7px 8px; border-radius: 8px; }
2575
- [data-sync-field-label] { font-size: 10px; line-height: 12px; }
2576
- [data-sync-field-value] { font-size: 12px; line-height: 14px; }
2577
- }
2578
- @media (max-width: 480px) {
2579
- [data-sync-actions] > [data-sync-btn] { flex: 1 1 auto; }
2580
- [data-sync-fields] { flex-direction: row; gap: 6px; }
2581
- [data-sync-field] { flex: 1 1 0; min-width: 0; padding: 6px 8px; border-radius: 8px; }
2582
- [data-sync-field-label] { font-size: 10px; line-height: 11px; }
2583
- [data-sync-field-value] { font-size: 11px; line-height: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; word-break: normal; }
2584
- }
2585
- @media (min-width: 640px) {
2586
- [data-sync-dialog-overlay] { align-items: center; padding: 24px; }
2587
- [data-sync-dialog] { border-radius: 14px; box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35); }
2588
- }
2589
- @media (min-width: 1024px) {
2590
- [data-sync-dash-content] { padding: 20px; }
2591
- }
2592
- @media (max-width: 390px) {
2593
- [data-sync-card] { padding: 12px; }
2594
- }
2595
- @media (prefers-reduced-motion: reduce) {
2596
- [data-sync-root] *, [data-sync-dialog] * { transition: none !important; animation: none !important; }
2597
- .sync-spin { animation: none; }
2598
- }
2599
-
2600
- /* ---- mobile-first (2026-09-03): thumb reach, disclosure, touch targets ---- */
2601
- [data-sync-shell] { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
2602
- /* mode tabs \u2014 pill bar, 44px touch height on every viewport */
2603
- [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); }
2604
- [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; }
2605
- [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); }
2606
- [data-sync-tab]:focus-visible { outline: 2px solid var(--dsw-alias-border-l2); outline-offset: 2px; }
2607
- /* collapsible bucket header toggle (header padding moves onto the button) */
2608
- [data-sync-dcol-head] { padding: 0; }
2609
- [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; }
2610
- [data-sync-dcol-toggle]:focus-visible { outline: 2px solid var(--dsw-alias-border-l2); outline-offset: -2px; }
2611
- /* R2 actions: primary + More menu (menu never overflows 360px) */
2612
- [data-r2-actions] { display: flex; gap: 8px; flex-wrap: wrap; align-items: stretch; }
2613
- [data-r2-actions] > [data-sync-btn] { flex: 2 1 0; }
2614
- [data-r2-more] { position: relative; flex: 1 1 0; display: flex; }
2615
- [data-r2-more] > [data-sync-btn] { flex: 1 1 auto; width: 100%; }
2616
- [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); }
2617
- [data-r2-more-menu] > [data-sync-btn] { justify-content: flex-start; width: 100%; }
2618
- /* sticky thumb-reach bars + condensed stats on narrow screens */
2619
- @media (max-width: 640px) {
2620
- [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); }
2621
- [data-sync-actions-bar] > [data-sync-btn] { flex: 1 1 0; min-height: 48px !important; font-size: 14px; }
2622
- [data-sync-actions-bar] [data-r2-more] > [data-sync-btn] { min-height: 48px !important; }
2623
- [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); }
2624
- [data-sync-dialog-actions] > [data-sync-btn]:last-child { flex: 1 1 100%; min-height: 48px !important; }
2625
- [data-sync-stats] { gap: 6px; }
2626
- [data-sync-stat] { padding: 8px 10px; }
2627
- }
2628
- /* coarse pointers: 40\u201344px targets (inline min-heights need !important) */
2629
- @media (pointer: coarse) {
2630
- [data-sync-btn][data-size="sm"] { min-height: 40px !important; }
2631
- [data-sync-btn][data-size="md"], [data-sync-btn]:not([data-size]) { min-height: 44px !important; }
2632
- [data-sync-dialog-close] { width: 40px; height: 40px; }
2633
- }
2634
- @media (max-width: 390px) {
2635
- [data-sync-stat-value] { font-size: 18px; }
2636
- [data-sync-stat-hint] { display: none; }
2637
- }
2638
- /* SSH configuration \u2014 user-filled target, explicit check, nothing auto-probes */
2639
- [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); }
2640
- [data-sync-ssh-label] { font-size: 11px; line-height: 16px; color: var(--dsw-alias-label-secondary); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
2641
- [data-sync-ssh-input] { min-height: 44px; padding: 6px 12px; border: 0.5px solid var(--dsw-alias-border-l4); border-radius: var(--dsw-radius-md); background: var(--dsw-alias-bg-layer-3); color: var(--dsw-alias-label-primary); font: inherit; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; width: 100%; box-sizing: border-box; }
2642
- [data-sync-ssh-input]:focus-visible { outline: 2px solid var(--dsw-alias-border-l2); outline-offset: 2px; }
2643
- [data-sync-ssh-input]:disabled { opacity: 0.6; }
2644
- [data-sync-ssh-row] { display: flex; gap: 8px; flex-wrap: wrap; }
2645
- [data-sync-ssh-row] > [data-sync-btn] { flex: 1 1 0; }
2646
- [data-sync-ssh-src] { font-size: 11px; line-height: 14px; color: var(--dsw-alias-label-secondary); }
2647
- /* R2 status banner \u2014 badge + hint need a real gap (was running together) */
2648
- [data-r2-summary] { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
2649
- /* R2 backup-target form \u2014 same language as the SSH section */
2650
- [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); }
2651
- [data-r2-config-label] { font-size: 11px; color: var(--dsw-alias-label-secondary); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
2652
- [data-r2-field] { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
2653
- [data-r2-field-label] { font-size: 12px; font-weight: 600; color: var(--dsw-alias-label-primary); }
2654
- [data-r2-field-input] { min-height: 44px; padding: 6px 12px; border: 0.5px solid var(--dsw-alias-border-l4); border-radius: var(--dsw-radius-md); background: var(--dsw-alias-bg-layer-3); color: var(--dsw-alias-label-primary); font: inherit; width: 100%; box-sizing: border-box; }
2655
- [data-r2-field-input]:focus-visible { outline: 2px solid var(--dsw-alias-border-l2); outline-offset: 2px; }
2656
- [data-r2-field-input]:disabled { opacity: 0.6; }
2657
- [data-r2-field-hint] { font-size: 11px; line-height: 14px; color: var(--dsw-alias-label-tertiary); }
2658
- /* Field-level validation feedback: the message must sit under the input it
2659
- names, not only in the panel-wide banner. */
2660
- [data-r2-field-error] { font-size: 11px; line-height: 15px; color: var(--dsw-alias-state-error-primary); overflow-wrap: anywhere; }
2661
- [data-r2-field-input][aria-invalid="true"] { border-color: var(--dsw-alias-state-error-primary); }
2662
- [data-sync-field-error] { font-size: 12px; line-height: 16px; color: var(--dsw-alias-state-error-primary); overflow-wrap: anywhere; }
2663
- [data-sync-ssh-input][aria-invalid="true"] { border-color: var(--dsw-alias-state-error-primary); }
2664
- [data-r2-provider-row] { display: flex; gap: 8px; }
2665
- [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; }
2666
- [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); }
2667
- [data-r2-provider-opt]:focus-visible { outline: 2px solid var(--dsw-alias-border-l2); outline-offset: 2px; }
2668
- [data-r2-config-row] { display: flex; gap: 8px; }
2669
- [data-r2-config-row] > [data-sync-btn] { flex: 1 1 0; }
2670
- [data-r2-config-hint] { font-size: 11px; line-height: 14px; color: var(--dsw-alias-label-secondary); }
2671
- @media (max-width: 640px) {
2672
- [data-sync-ssh-row] > [data-sync-btn] { min-height: 44px !important; }
2673
- }
2674
-
2675
- /* iOS 16px field floor hold (dsh-maestro-mobile zoom guard).
2676
- Every text field on the page is held at 16px under html[data-mobile-nav-ios]
2677
- inside this same predicate, because iOS WebKit magnifies the visual viewport
2678
- for a focused field below 16px. An earlier revision of this panel opted its
2679
- own fields back out to inherit for a compact 13px scale \u2014 and every tap on
2680
- those fields zoomed the page on iPhone, with modal sheets never blurring
2681
- back. Function beats pixels: hold the same 16px here (the :not(#...) clause
2682
- matches every element \u2014 no node carries that id \u2014 and exists purely for
2683
- id-level specificity, so this declaration keeps winning over competing
2684
- field rules). Android and desktop never carry the marker, so the compact
2685
- scale they were designed with is untouched. */
2686
- @media (max-width: 1023px) and (pointer: coarse) {
2687
- html[data-mobile-nav-ios] [data-sync-root] input:not(#dsh-field-floor-opt-out),
2688
- html[data-mobile-nav-ios] [data-sync-root] textarea:not(#dsh-field-floor-opt-out),
2689
- html[data-mobile-nav-ios] [data-sync-root] select:not(#dsh-field-floor-opt-out) { font-size:16px !important; }
2690
- }
2691
- `;
2692
- function apply3(ctx) {
2693
- const slots = ctx.slots ?? ctx.get?.("slots");
2694
- if (!slots?.inject || !slots?.register) return;
2695
- ctx.effect(() => installStyleTag(SYNC_CSS, "maestro-sync/settings.css"), "maestro-sync: settings css");
2696
- ctx.effect(() => {
2697
- const dispose = slots.inject(
2698
- "settings.section",
2699
- () => slots.register(
2700
- { name: "settings.section", id: "maestro-sync", order: 28, label: () => "Maestro Sync" },
2701
- () => React5.createElement(SyncPanel, { ctx })
2702
- )
2703
- );
2704
- return () => {
2705
- try {
2706
- dispose?.();
2707
- } catch {
2708
- }
2709
- };
2710
- }, "maestro-sync: settings");
2711
- }
2712
-
2713
973
  // src/client/index.tsx
2714
974
  var inject = ["slots", "connection"];
2715
975
  var MODULES = [
2716
976
  ["auto-reload", apply],
2717
- ["config", apply2],
2718
- ["sync", apply3]
977
+ ["config", apply2]
2719
978
  ];
2720
- function apply4(ctx) {
979
+ function apply3(ctx) {
2721
980
  for (const [name, register] of MODULES) {
2722
981
  try {
2723
982
  register(ctx);