@artenx/dshb 0.1.43 → 0.1.45

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/client.js CHANGED
@@ -2578,18 +2578,13 @@ window.__ModuleLoader__.load({
2578
2578
  remoteDshHome: "",
2579
2579
  remoteProfile: "",
2580
2580
  remoteWebPort: "",
2581
- direction: "pull",
2582
- schedule: "manual",
2583
- mode: "full",
2584
- syncNodes: true,
2585
- syncSessions: false,
2581
+ sessionSync: "off",
2586
2582
  selection: {
2587
2583
  mode: "all",
2588
2584
  nodes: [],
2589
2585
  workspaces: [],
2590
2586
  sessions: []
2591
- },
2592
- enabled: true
2587
+ }
2593
2588
  };
2594
2589
  function validPort(value) {
2595
2590
  const port = Number(value);
@@ -2603,8 +2598,6 @@ window.__ModuleLoader__.load({
2603
2598
  if (form.authKind === "key" && !form.privateKey && !savedSecrets?.hasKey) return "请填写 SSH 私钥内容";
2604
2599
  }
2605
2600
  function toSyncPeerForm(peer) {
2606
- const syncSessions = peer.syncSessions;
2607
- const mode = syncSessions ? peer.mode ?? "full" : "full";
2608
2601
  return {
2609
2602
  name: peer.name,
2610
2603
  host: peer.host,
@@ -2617,41 +2610,32 @@ window.__ModuleLoader__.load({
2617
2610
  remoteDshHome: peer.remoteDshHome ?? "",
2618
2611
  remoteProfile: peer.remoteProfile ?? "",
2619
2612
  remoteWebPort: peer.remoteWebPort == null ? "" : String(peer.remoteWebPort),
2620
- direction: peer.direction,
2621
- schedule: peer.schedule,
2622
- mode,
2623
- syncNodes: mode === "metadata" ? peer.syncNodes ?? true : true,
2624
- syncSessions,
2613
+ sessionSync: peer.syncSessions ? peer.mode === "metadata" ? "metadata" : "full" : "off",
2625
2614
  selection: peer.selection ?? {
2626
2615
  mode: "all",
2627
2616
  nodes: [],
2628
2617
  workspaces: [],
2629
2618
  sessions: []
2630
- },
2631
- enabled: true
2619
+ }
2632
2620
  };
2633
2621
  }
2634
2622
  /**
2635
2623
  * 把表单归一化为保存请求:
2636
- * - 「启用此同步节点」已移除,enabled 恒 true(停用语义由删除节点承担)。
2637
- * - 元数据同步且不同步工作节点时没有任何调度内容,强制手动时机。
2638
- * - 全量会话同步依赖工作节点配置,强制开启节点同步。
2624
+ * - 工作节点配置恒同步;方向与时机逻辑已取消(双向交换、仅手动触发)。
2625
+ * - 「打开远端会话」(wss 实时访问)不依赖手动同步,元数据同步无需传输离线文件。
2639
2626
  */
2640
2627
  function buildSyncPeerFormRequest(form) {
2641
- const syncSessions = form.syncSessions;
2642
- const mode = syncSessions ? form.mode : "full";
2643
- const syncNodes = mode === "metadata" ? form.syncNodes : true;
2644
- const schedule = mode === "metadata" && !syncNodes ? "manual" : form.schedule;
2628
+ const syncSessions = form.sessionSync !== "off";
2645
2629
  const fields = {
2646
2630
  name: form.name.trim(),
2647
2631
  host: form.host.trim(),
2648
2632
  port: Number(form.port),
2649
2633
  username: form.username.trim(),
2650
2634
  authKind: form.authKind,
2651
- direction: form.direction,
2652
- schedule,
2653
- mode,
2654
- syncNodes,
2635
+ direction: "bidirectional",
2636
+ schedule: "manual",
2637
+ mode: form.sessionSync === "metadata" ? "metadata" : "full",
2638
+ syncNodes: true,
2655
2639
  syncSessions,
2656
2640
  selection: form.selection,
2657
2641
  enabled: true,
@@ -2840,7 +2824,6 @@ window.__ModuleLoader__.load({
2840
2824
  const runningCount = peers.filter((peer) => peer.progress?.lastRunStatus === "running").length;
2841
2825
  const statusLabel = (peer) => {
2842
2826
  const status = peer.progress?.lastRunStatus;
2843
- if (!peer.enabled) return "已停用";
2844
2827
  if (status === "running") return "同步中";
2845
2828
  if (status === "stopped") return "上次已停止(未完成批次已丢弃)";
2846
2829
  if (status === "failed") return "上次失败";
@@ -3023,7 +3006,7 @@ window.__ModuleLoader__.load({
3023
3006
  }
3024
3007
  };
3025
3008
  const runSync = async () => {
3026
- if (selectedId === "new" || !selectedPeer?.enabled) return;
3009
+ if (selectedId === "new") return;
3027
3010
  setSyncing(true);
3028
3011
  try {
3029
3012
  const response = await fetch(`/api/dshb/sync/peers/${selectedId}/run`, { method: "POST" });
@@ -3544,157 +3527,52 @@ window.__ModuleLoader__.load({
3544
3527
  },
3545
3528
  children: "同步策略"
3546
3529
  }),
3547
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
3548
- style: {
3549
- ...field,
3550
- display: "flex",
3551
- alignItems: "flex-start",
3552
- gap: 8,
3553
- cursor: "pointer"
3554
- },
3555
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
3556
- type: "checkbox",
3557
- checked: form.syncNodes,
3558
- style: { marginTop: 2 },
3559
- disabled: !(form.syncSessions && form.mode === "metadata"),
3560
- onChange: (e) => setForm((c) => ({
3561
- ...c,
3562
- syncNodes: e.target.checked,
3563
- ...e.target.checked || c.syncSessions && c.mode === "metadata" ? {} : { schedule: "manual" }
3564
- }))
3565
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3566
- style: { fontSize: 13 },
3567
- children: "同步工作节点"
3568
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3569
- style: {
3570
- display: "block",
3571
- fontSize: 11,
3572
- opacity: .5,
3573
- marginTop: 2
3574
- },
3575
- children: form.syncSessions && form.mode === "full" ? "全量会话同步依赖工作节点配置,始终开启" : "同步工作节点的 SSH 连接配置与远端目录"
3576
- })] })]
3530
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3531
+ style: field,
3532
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3533
+ style: label,
3534
+ children: "工作节点配置"
3535
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3536
+ style: hint,
3537
+ children: "始终随同步双向交换,无需配置;点击「立即同步」时执行一次。"
3538
+ })]
3577
3539
  }),
3578
- (form.syncNodes || form.syncSessions && form.mode === "full") && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3579
- className: "dshb-sync-two-col",
3580
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3581
- style: field,
3582
- children: [
3583
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3584
- style: label,
3585
- children: "同步方向"
3586
- }),
3587
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("select", {
3588
- style: inputStyle$1,
3589
- value: form.direction,
3590
- onChange: (e) => setForm((c) => ({
3591
- ...c,
3592
- direction: e.target.value
3593
- })),
3594
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
3595
- value: "pull",
3596
- children: "单向拉取到本机"
3597
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
3598
- value: "bidirectional",
3599
- children: "双向同步"
3600
- })]
3601
- }),
3602
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3603
- style: hint,
3604
- children: ["作用于工作节点配置", form.syncSessions && form.mode === "full" ? "与会话内容" : ""]
3605
- })
3606
- ]
3607
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3608
- style: field,
3609
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3540
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3541
+ style: field,
3542
+ children: [
3543
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3610
3544
  style: label,
3611
- children: "同步时机"
3612
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("select", {
3545
+ children: "工作区会话"
3546
+ }),
3547
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("select", {
3613
3548
  style: inputStyle$1,
3614
- value: form.schedule,
3549
+ value: form.sessionSync,
3615
3550
  onChange: (e) => setForm((c) => ({
3616
3551
  ...c,
3617
- schedule: e.target.value
3552
+ sessionSync: e.target.value
3618
3553
  })),
3619
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
3620
- value: "manual",
3621
- children: "手动"
3622
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
3623
- value: "every-5m",
3624
- children: "每 5 分钟"
3625
- })]
3626
- })]
3627
- })]
3628
- }),
3629
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3630
- style: {
3631
- ...field,
3632
- display: "flex",
3633
- flexDirection: "column",
3634
- gap: 10
3635
- },
3636
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
3637
- style: {
3638
- display: "flex",
3639
- alignItems: "flex-start",
3640
- gap: 8,
3641
- cursor: "pointer"
3642
- },
3643
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
3644
- type: "checkbox",
3645
- checked: form.syncSessions,
3646
- style: { marginTop: 2 },
3647
- onChange: (e) => setForm((c) => ({
3648
- ...c,
3649
- syncSessions: e.target.checked,
3650
- ...e.target.checked ? { syncNodes: true } : { mode: "full" }
3651
- }))
3652
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3653
- style: { fontSize: 13 },
3654
- children: "同步工作区会话"
3655
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3656
- style: {
3657
- display: "block",
3658
- fontSize: 11,
3659
- opacity: .5,
3660
- marginTop: 2
3661
- },
3662
- children: form.mode === "metadata" ? "同步远端工作区与会话列表,通过加密通道实时访问会话内容" : "同步会话完整内容,导入后可在本机继续;保留冲突分支供恢复"
3663
- })] })]
3664
- }), form.syncSessions && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3665
- style: {
3666
- ...field,
3667
- margin: 0
3668
- },
3669
- children: [
3670
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3671
- style: label,
3672
- children: "同步模式"
3673
- }),
3674
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("select", {
3675
- style: inputStyle$1,
3676
- value: form.mode,
3677
- onChange: (e) => setForm((c) => ({
3678
- ...c,
3679
- mode: e.target.value,
3680
- ...e.target.value === "full" ? { syncNodes: true } : {}
3681
- })),
3682
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
3554
+ children: [
3555
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
3556
+ value: "off",
3557
+ children: "不同步"
3558
+ }),
3559
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
3683
3560
  value: "full",
3684
3561
  children: "全量同步"
3685
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
3562
+ }),
3563
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
3686
3564
  value: "metadata",
3687
3565
  children: "元数据同步"
3688
- })]
3689
- }),
3690
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3691
- style: hint,
3692
- children: form.mode === "metadata" ? "仅同步工作区与会话列表,不传输会话内容;侧栏会话行的「打开远端会话」通过加密 SSH 通道实时读取远端内容并可直接继续对话与审批。" : "将工作节点配置与工作区会话内容完整传输到对端;导入后可在本机离线继续会话,数据量大时耗时较长。"
3693
- })
3694
- ]
3695
- })]
3566
+ })
3567
+ ]
3568
+ }),
3569
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3570
+ style: hint,
3571
+ children: form.sessionSync === "metadata" ? "不传输离线文件:侧栏会话行的「打开远端会话」自动经加密 SSH 通道实时显示远端会话消息,可直接继续对话与审批,不受同步时机限制。" : form.sessionSync === "full" ? "点击「立即同步」时把会话完整内容传输到本机,导入后可离线继续;数据量大时耗时较长。" : "仅同步工作节点配置;需要会话时再切换为全量或元数据同步。"
3572
+ })
3573
+ ]
3696
3574
  }),
3697
- selectedPeer && form.syncSessions && form.mode === "full" && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3575
+ selectedPeer && form.sessionSync === "full" && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3698
3576
  style: {
3699
3577
  ...field,
3700
3578
  display: "grid",
@@ -3732,7 +3610,7 @@ window.__ModuleLoader__.load({
3732
3610
  ...current,
3733
3611
  selection
3734
3612
  })),
3735
- includeSessions: form.syncSessions,
3613
+ includeSessions: form.sessionSync === "full" || form.sessionSync === "metadata",
3736
3614
  disabled: busy
3737
3615
  })
3738
3616
  ]
@@ -3823,7 +3701,7 @@ window.__ModuleLoader__.load({
3823
3701
  !isNew && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
3824
3702
  type: "button",
3825
3703
  onClick: () => void (syncInProgress ? stopSync() : runSync()),
3826
- disabled: busy || probing || stopping || !selectedPeer?.enabled && !syncInProgress,
3704
+ disabled: busy || probing || stopping,
3827
3705
  style: secondaryBtn,
3828
3706
  children: stopping ? "正在停止…" : syncInProgress ? "停止同步" : "立即同步"
3829
3707
  }),