sage-mem 3.0.0 → 3.1.1

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
@@ -2001,6 +2001,67 @@ const StarmapRuntime = (function (require, _react) {
2001
2001
  },
2002
2002
  };
2003
2003
 
2004
+ // ── 3.1.0:跨设备同步(sync/devices · sync/run)──
2005
+ // devices 的两种「不行」必须分开:`ok:false` = 这次调用没走通(该看日志),
2006
+ // `available:false` = 设备发现用不了(没装 tailscale / 没登录,该提示手打别名)。
2007
+ // 所以 ok / available 都必填,devices 永远是数组(失败时是空数组,不是缺键)。
2008
+ const syncDeviceSchema = parseSchema({ "host": isStr, "dnsName": isStr, "ips": isStrArr, "os": isStr, "online": isBool });
2009
+ const syncDevicesBase = optionalFields(parseSchema({ "ok": isBool, "available": isBool }), { "reason": isStr, "code": isStr, "error": isStr });
2010
+ const syncDevicesSchema = {
2011
+ // `fields` / `elementFields` 不是装饰:`client-exec-test` 第 3.1 组拿它们与宿主
2012
+ // zod 的 shape 逐条对表 —— 少了就等于这一条 strict codec 不参与漂移检测。
2013
+ fields: syncDevicesBase.fields.concat(["devices"]),
2014
+ elementFields: syncDeviceSchema.fields,
2015
+ parse(v) {
2016
+ if (v === null || typeof v !== "object" || Array.isArray(v)) throw new Error("sage-mem: invalid sync devices");
2017
+ syncDevicesBase.parse(v);
2018
+ if (!Array.isArray(v.devices)) throw new Error("sage-mem: invalid devices list");
2019
+ v.devices.forEach((d) => syncDeviceSchema.parse(d));
2020
+ return v;
2021
+ },
2022
+ };
2023
+ // 入参:`{action, host?, remotePath?, apply?, confirm?}`。
2024
+ // **只产出声明过的键** —— 多传的键在这里就拒(宿主 strict 会剥掉它,但「界面以为
2025
+ // 自己传了」最难查)。`action` 只校字符串、**不校枚举**:合法取值是宿主 schema
2026
+ // (z.enum(PANEL_ACTIONS))与 `runSyncAction` 的事,客户端再抄一份枚举,
2027
+ // 多出来的那一种动作就会在面板上永远点不动(与 conflictApplyOptsSchema 同一条理由)。
2028
+ const SYNC_RUN_KEYS = ["action", "host", "remotePath", "apply", "confirm"];
2029
+ const syncRunArgsSchema = {
2030
+ parse(v) {
2031
+ if (v === null || typeof v !== "object" || Array.isArray(v)) throw new Error("sage-mem: expected object");
2032
+ const unknown = Object.keys(v).filter((k) => SYNC_RUN_KEYS.indexOf(k) < 0);
2033
+ if (unknown.length > 0) throw new Error("sage-mem: unexpected sync arg " + unknown.join(","));
2034
+ if (!("action" in v)) throw new Error("sage-mem: missing action");
2035
+ isStr(v.action);
2036
+ const out = { action: v.action };
2037
+ if ("host" in v) { isStr(v.host); out.host = v.host; }
2038
+ if ("remotePath" in v) { isStr(v.remotePath); out.remotePath = v.remotePath; }
2039
+ if ("apply" in v) { isBool(v.apply); out.apply = v.apply; }
2040
+ if ("confirm" in v) { isBool(v.confirm); out.confirm = v.confirm; }
2041
+ return out;
2042
+ },
2043
+ };
2044
+ // 结果:只有三种动作**都成立**的那几个字段(action / applied / report)。
2045
+ // 刻意不声明 summary / plan / results —— 三个动作的 summary 形状各不相同
2046
+ // (pull 是 import/overwrite/…,push 是 upload/overwrite/…,check 连 summary 都没有),
2047
+ // 声明一份合并形状只会被迫放宽校验或逼下游造假字段。面板渲染 report(markdown)就够。
2048
+ const syncGateSchema = parseSchema({ "allow": isBool, "reason": isStr, "needConfirm": isBool, "deviceId": isStr, "deviceLabel": isStr });
2049
+ const syncRunSchema = {
2050
+ fields: ["ok", "action", "applied", "report", "gate", "code", "error"],
2051
+ parse(v) {
2052
+ if (v === null || typeof v !== "object" || Array.isArray(v)) throw new Error("sage-mem: invalid sync result");
2053
+ isBool(v.ok);
2054
+ isStr(v.action);
2055
+ isBool(v.applied);
2056
+ isStr(v.report);
2057
+ // gate 只有 push 会给(写入门);其余动作没有这个键。
2058
+ if ("gate" in v) syncGateSchema.parse(v.gate);
2059
+ if ("code" in v) isStr(v.code);
2060
+ if ("error" in v) isStr(v.error);
2061
+ return v;
2062
+ },
2063
+ };
2064
+
2004
2065
  const TYPERT_REMOTE = {
2005
2066
  package: "sage-mem",
2006
2067
  descriptors: [
@@ -2573,6 +2634,36 @@ const StarmapRuntime = (function (require, _react) {
2573
2634
  result: { mode: "strict", typeSymbol: "sage-mem/types#ConflictApplyResult", schema: conflictApplySchema, create: () => conflictApplySchema },
2574
2635
  sourceLocation: { "file": "lib/index.js", "line": 1, "column": 1 },
2575
2636
  },
2637
+ // ── 3.1.0:跨设备同步(`sync` 面)──
2638
+ // 第五个 namespace:与 conflict 同一个坑 —— 不在这里声明就没有 `ctx.get("remote.sync")`,
2639
+ // 面板的同步页签会整块消失(宿主 remote 清单是构建期产物)。
2640
+ // 两条:设备候选(无参)与一次动作(一个 opts)。
2641
+ {
2642
+ // 无入参:超时 / 测试注入点都不走 wire(它们是后端自己的事)。
2643
+ id: "sage-mem#sync/devices",
2644
+ service: "sync",
2645
+ namespace: "sync",
2646
+ method: "devices",
2647
+ invocation: { kind: "direct" },
2648
+ parameters: [],
2649
+ result: { mode: "strict", typeSymbol: "sage-mem/types#SyncDevicesResult", schema: syncDevicesSchema, create: () => syncDevicesSchema },
2650
+ sourceLocation: { "file": "lib/index.js", "line": 1, "column": 1 },
2651
+ },
2652
+ {
2653
+ // check(看清楚)/ pull(搬回来)/ push(推上去)。
2654
+ // host / remotePath 平时不传 —— 宿主拿设置里的「跨设备」兜底;只有用户临时
2655
+ // 改了没保存时才传。所以客户端这里只做类型校验,**不填默认值**。
2656
+ id: "sage-mem#sync/run",
2657
+ service: "sync",
2658
+ namespace: "sync",
2659
+ method: "run",
2660
+ invocation: { kind: "direct" },
2661
+ parameters: [
2662
+ { name: "opts", wire: "opts", source: "json", codec: { mode: "strict", typeSymbol: "sage-mem/types#SyncRunArgs", schema: syncRunArgsSchema, create: () => syncRunArgsSchema } },
2663
+ ],
2664
+ result: { mode: "strict", typeSymbol: "sage-mem/types#SyncRunResult", schema: syncRunSchema, create: () => syncRunSchema },
2665
+ sourceLocation: { "file": "lib/index.js", "line": 1, "column": 1 },
2666
+ },
2576
2667
  ],
2577
2668
  };
2578
2669
 
@@ -4560,6 +4651,62 @@ h("span", { key: "sep", className: "smem-actions-sep", "aria-hidden": "true" }),
4560
4651
  "ext.sync.err.act": "裁决没有完成:{code} {error}",
4561
4652
  "ext.sync.err.base": "文件已经写成,但基线没更新:{error}(下次检查会把同一个冲突再造一次)",
4562
4653
  "ext.sync.err.noAct": "这个宿主没有 applyResolution(升级宿主后再试)",
4654
+ // ── 3.1.0 跨设备同步(第 5 步的「先跑一次」)─────────────────────
4655
+ // 与上面那一组分开命名是有意的:上面 `ext.sync.*` 回答「对不上时听谁的」,
4656
+ // 这一组回答「怎么让两台机器对上」。两组键逐个都有人用(client-exec-test 查死键)。
4657
+ "ext.syncPanel.title": "跨设备同步",
4658
+ "ext.syncPanel.what": "两台机器共用一份记忆:先「检查」看清楚差在哪,再决定「拉取」(把远端那份搬回来)或「推送」(把本地这份推上去)。拉取与推送都先预演、后执行,真要写盘之前还会再问你一次。",
4659
+ "ext.syncPanel.host": "远端主机",
4660
+ "ext.syncPanel.hostPlaceholder": "SSH 别名,例如 greycloud",
4661
+ "ext.syncPanel.hostHint": "填 ~/.ssh/config 里的 Host 名;改完离开输入框就存。",
4662
+ "ext.syncPanel.devices": "看看有哪些设备",
4663
+ "ext.syncPanel.devicesNone": "Tailscale 里没有别的设备",
4664
+ "ext.syncPanel.devicesUnavailable": "没检测到 Tailscale,手打 SSH 别名即可",
4665
+ "ext.syncPanel.devicesFailed": "读不到设备列表:{code} {error}",
4666
+ "ext.syncPanel.deviceOnline": "在线",
4667
+ "ext.syncPanel.deviceOffline": "离线",
4668
+ "ext.syncPanel.remotePath": "远端记忆目录",
4669
+ "ext.syncPanel.remotePathPlaceholder": "~/shengdian/memory",
4670
+ "ext.syncPanel.pathHint": "那台机器上记忆目录的位置(~ 也行);两边同名文件才算同一份记忆。",
4671
+ "ext.syncPanel.saved": "已保存",
4672
+ "ext.syncPanel.check": "检查",
4673
+ "ext.syncPanel.pull": "拉取",
4674
+ "ext.syncPanel.push": "推送",
4675
+ "ext.syncPanel.pullApply": "执行拉取",
4676
+ "ext.syncPanel.pushApply": "执行推送",
4677
+ "ext.syncPanel.actionsHint": "拉取 / 推送先预演:报告出来之后那颗按钮才变成「执行…」,点它还会再问一次。检查只跑只读的 ssh,一个字节都不写。",
4678
+ "ext.syncPanel.status.idle": "还没跑过",
4679
+ "ext.syncPanel.status.staged": "预演完成 · 待执行{action}",
4680
+ "ext.syncPanel.status.done": "上次:{action}",
4681
+ "ext.syncPanel.busy.check": "检查中…(要跑几条 ssh,慢链路十几秒很正常)",
4682
+ "ext.syncPanel.busy.pull": "正在预演拉取…",
4683
+ "ext.syncPanel.busy.push": "正在预演推送…",
4684
+ "ext.syncPanel.busy.apply": "正在写盘…",
4685
+ "ext.syncPanel.busy.devices": "正在问 Tailscale…",
4686
+ "ext.syncPanel.busy.save": "保存中…",
4687
+ "ext.syncPanel.empty": "还没有结果 —— 先点「检查」看一眼差在哪",
4688
+ "ext.syncPanel.report.title": "结果",
4689
+ "ext.syncPanel.report.preview": "预演(一个字节都没写)",
4690
+ "ext.syncPanel.report.applied": "已执行(写盘了)",
4691
+ "ext.syncPanel.report.empty": "这次没有正文报告(看下面那句结论)",
4692
+ "ext.syncPanel.confirm.pullTitle": "用远端那一版覆盖本地?",
4693
+ "ext.syncPanel.confirm.pullBody": "本地改过的文件会换成远端那份,改不回来;旧版会先进备份。预演报告就在上面。",
4694
+ "ext.syncPanel.confirm.pushTitle": "把本地这一版推到远端?",
4695
+ "ext.syncPanel.confirm.pushBody": "远端同名文件会换成本地这份,改不回来;旧版会先进备份。预演报告就在上面。",
4696
+ "ext.syncPanel.confirm.yes": "确认并执行",
4697
+ "ext.syncPanel.confirm.busy": "执行中…",
4698
+ "ext.syncPanel.gate.title": "首次向这台设备推送",
4699
+ "ext.syncPanel.gate.body": "远端库属于 {who}。确认它就是你自己的库,再继续。",
4700
+ "ext.syncPanel.gate.noDevice": "一台还没登记过的设备",
4701
+ "ext.syncPanel.gate.yes": "确认并推送",
4702
+ "ext.syncPanel.gate.cancel": "先不推",
4703
+ "ext.syncPanel.failed": "这一步没走通:{code} {error}",
4704
+ "ext.syncPanel.notice.check": "检查完了,差异在下面的报告里",
4705
+ "ext.syncPanel.notice.preview": "预演完了 —— 看着没问题,再点「执行…」",
4706
+ "ext.syncPanel.notice.pull": "拉取执行完了,报告在下面",
4707
+ "ext.syncPanel.notice.push": "推送执行完了,报告在下面",
4708
+ "ext.syncPanel.err.noRemote": "这个宿主还没有跨设备同步接口(重启 DSH 后再试)",
4709
+ "ext.syncPanel.err.noSettings": "宿主没有提供设置接口(版本偏旧)",
4563
4710
  "lab.title": "MMR 去重(实验性)",
4564
4711
  "lab.switch": "启用 MMR 去重",
4565
4712
  "lab.switch.onTitle": "现在开启:注入时优先让不同主题的记忆占名额",
@@ -5337,6 +5484,60 @@ h("span", { key: "sep", className: "smem-actions-sep", "aria-hidden": "true" }),
5337
5484
  "ext.sync.err.act": "Resolution did not complete: {code} {error}",
5338
5485
  "ext.sync.err.base": "File written, but the baseline was not updated: {error} (the next check will raise the same conflict again)",
5339
5486
  "ext.sync.err.noAct": "This host has no applyResolution (upgrade the host and retry)",
5487
+ // ── 3.1.0 cross-device sync (step 5: run one sync first) ──
5488
+ "ext.syncPanel.title": "Cross-device sync",
5489
+ "ext.syncPanel.what": "Two machines share one memory: run Check to see what differs, then Pull (bring the remote copy back) or Push (send this copy up). Pull and push always rehearse first, and both ask once more before writing.",
5490
+ "ext.syncPanel.host": "Remote host",
5491
+ "ext.syncPanel.hostPlaceholder": "SSH alias, e.g. greycloud",
5492
+ "ext.syncPanel.hostHint": "The Host name from ~/.ssh/config; saved as soon as you leave the field.",
5493
+ "ext.syncPanel.devices": "List devices",
5494
+ "ext.syncPanel.devicesNone": "No other devices in Tailscale",
5495
+ "ext.syncPanel.devicesUnavailable": "No Tailscale detected - type the SSH alias by hand",
5496
+ "ext.syncPanel.devicesFailed": "Cannot read the device list: {code} {error}",
5497
+ "ext.syncPanel.deviceOnline": "online",
5498
+ "ext.syncPanel.deviceOffline": "offline",
5499
+ "ext.syncPanel.remotePath": "Remote memory dir",
5500
+ "ext.syncPanel.remotePathPlaceholder": "~/shengdian/memory",
5501
+ "ext.syncPanel.pathHint": "Where the memory directory lives on that machine (~ works); the same file name is the same memory.",
5502
+ "ext.syncPanel.saved": "Saved",
5503
+ "ext.syncPanel.check": "Check",
5504
+ "ext.syncPanel.pull": "Pull",
5505
+ "ext.syncPanel.push": "Push",
5506
+ "ext.syncPanel.pullApply": "Run pull",
5507
+ "ext.syncPanel.pushApply": "Run push",
5508
+ "ext.syncPanel.actionsHint": "Pull and push rehearse first: the button becomes Run ... once the report is in, and it asks once more. Check only runs read-only ssh and writes nothing.",
5509
+ "ext.syncPanel.status.idle": "Not run yet",
5510
+ "ext.syncPanel.status.staged": "Rehearsed - ready to run {action}",
5511
+ "ext.syncPanel.status.done": "Last: {action}",
5512
+ "ext.syncPanel.busy.check": "Checking... (a few ssh round trips; ten seconds on a slow link is normal)",
5513
+ "ext.syncPanel.busy.pull": "Rehearsing pull...",
5514
+ "ext.syncPanel.busy.push": "Rehearsing push...",
5515
+ "ext.syncPanel.busy.apply": "Writing...",
5516
+ "ext.syncPanel.busy.devices": "Asking Tailscale...",
5517
+ "ext.syncPanel.busy.save": "Saving...",
5518
+ "ext.syncPanel.empty": "No result yet - run Check to see what differs",
5519
+ "ext.syncPanel.report.title": "Result",
5520
+ "ext.syncPanel.report.preview": "Rehearsal (nothing written)",
5521
+ "ext.syncPanel.report.applied": "Executed (written to disk)",
5522
+ "ext.syncPanel.report.empty": "No report body for this run (the line below is the verdict)",
5523
+ "ext.syncPanel.confirm.pullTitle": "Overwrite the local copy with the remote one?",
5524
+ "ext.syncPanel.confirm.pullBody": "Locally changed files will be replaced by the remote versions and cannot be restored; the old versions go to the backup first. The rehearsal report is above.",
5525
+ "ext.syncPanel.confirm.pushTitle": "Push this copy to the remote?",
5526
+ "ext.syncPanel.confirm.pushBody": "Remote files with the same name will be replaced by this copy and cannot be restored; the old versions go to the backup first. The rehearsal report is above.",
5527
+ "ext.syncPanel.confirm.yes": "Confirm and run",
5528
+ "ext.syncPanel.confirm.busy": "Running...",
5529
+ "ext.syncPanel.gate.title": "First push to this device",
5530
+ "ext.syncPanel.gate.body": "The remote library belongs to {who}. Confirm it is your own library before continuing.",
5531
+ "ext.syncPanel.gate.noDevice": "a device that has never been recorded",
5532
+ "ext.syncPanel.gate.yes": "Confirm and push",
5533
+ "ext.syncPanel.gate.cancel": "Not now",
5534
+ "ext.syncPanel.failed": "This step did not go through: {code} {error}",
5535
+ "ext.syncPanel.notice.check": "Check finished; the differences are in the report below",
5536
+ "ext.syncPanel.notice.preview": "Rehearsal finished - click Run ... once it looks right",
5537
+ "ext.syncPanel.notice.pull": "Pull finished; the report is below",
5538
+ "ext.syncPanel.notice.push": "Push finished; the report is below",
5539
+ "ext.syncPanel.err.noRemote": "This host has no cross-device sync API yet (restart DSH and retry)",
5540
+ "ext.syncPanel.err.noSettings": "This host exposes no settings API",
5340
5541
  "lab.title": "MMR de-duplication (experimental)",
5341
5542
  "lab.switch": "Enable MMR de-duplication",
5342
5543
  "lab.switch.onTitle": "On: injection prefers memories on different topics for the same slots",
@@ -8694,6 +8895,12 @@ return h("div", { className: "smem-external smem-stack" }, [
8694
8895
  // 与主卡**平级**:以前它嵌在主卡里面,三层边框(外卡 → 分区 → 内卡)挤在一起(审计 P2-3)。
8695
8896
  h(ExternalIntakeCard, { key: "intake", ctx: props.ctx }),
8696
8897
 
8898
+ // ── 3.1.0 跨设备同步:先把这次同步跑起来 ──
8899
+ // 与来件卡平级,且**排在差异卡之前**:先「触发一次同步」,再「裁决它产生的差异」。
8900
+ // 反过来摆的话,人得先滚过一列待裁决记录,才看得见「其实还没连过远端」这件事。
8901
+ // 卡本身在 `71-sync-panel.js` —— 它自带样式,且要跟 `sync.run` 的三种动作一起看。
8902
+ h(ExternalSyncPanelCard, { key: "syncPanel", ctx: props.ctx }),
8903
+
8697
8904
  // ── 3.0.0 跨设备同步:撞车的地方 ──
8698
8905
  // 与来件卡平级(同一件事的两个方向:外面的东西进不进我的库 / 我的库与别的设备
8699
8906
  // 对不上时听谁的)。卡本身在 `70-ext-sync.js` —— 它要跟 `smemLineDiff` 一起看。
@@ -9451,6 +9658,500 @@ return h("div", { className: "smem-external smem-stack" }, [
9451
9658
  notice ? h("div", { className: "smem-ok", key: "ok" }, "✓ " + notice) : null,
9452
9659
  ]);
9453
9660
  }
9661
+ // ════════════════════════════════════════════════════════════════════════
9662
+ // 3.1.0 第 5 步 · 跨设备同步卡(「外部访问」页)+ 它自己的样式
9663
+ // ════════════════════════════════════════════════════════════════════════
9664
+ //
9665
+ // 这张卡回答「怎么让两台机器对上」:填主机与远端目录 → 触发一次同步 → 再回下面那张
9666
+ // 「跨设备差异」(`70-ext-sync.js`)理它造出来的差异。**顺序是有理由的:先跑,再裁决。**
9667
+ //
9668
+ // 三条不许变的产品规则:
9669
+ // 1. **不主动起子进程**。设备候选(`sync.devices()`)背后是一条 `tailscale`,所以只在
9670
+ // 用户点「看看有哪些设备」时才调 —— 进页面就打,等于每次开设置都付一次进程开销。
9671
+ // `available:false`(没装 / 没登录 / 没别的机子)不是错误,是一句人话 + 照旧手打。
9672
+ // 2. **拉取 / 推送先预演**(`apply:false`)。报告出来之后那颗按钮才变成「执行…」,
9673
+ // 点了还要过二次确认模态 —— 它是这一屏**唯一会覆写真实文件**的路径。
9674
+ // 3. **失败不许吞**:`code` + `error` 落在卡片里。`need_confirm` 不是失败,是一句
9675
+ // 「首次向这台设备推送」+ 一颗 `[确认并推送]`(带 `confirm:true, apply:true` 重跑)。
9676
+ //
9677
+ // 数据全走已有的 remote:
9678
+ // - `memory.getSettings()` → `.sync = { host, remotePath }` 与 `.syncDiagnostics`
9679
+ // - `memory.setSettings({ sync: { host } })` → 失焦即存,**一次只带一个键**
9680
+ // - `sync.devices()` → `{ ok, available, devices, reason?, code?, error? }`
9681
+ // - `sync.run({ action, apply?, confirm? })` → `{ ok, action, applied, report, gate?, code?, error? }`
9682
+ //
9683
+ // `report` 是 markdown。这里**不自己写一个 markdown 解析器**:星图那一套
9684
+ // `renderMarkdown` 在 `StarmapRuntime` 那个 IIFE 里(`client-scope-test` 第 7 组盯着这堵墙),
9685
+ // 工厂作用域拿不到;所以照 60 / 69 的老办法原样放进等宽的 `<pre>` —— 报告是给人读的
9686
+ // 纯文本,多一层解析只会多一处会坏的地方。
9687
+
9688
+ // ── 卡片自己的样式 ─────────────────────────────────────────────────────
9689
+ //
9690
+ // 为什么不并进 `40-styles.js` 的那一份:那一份是「拼接时就固定的字符串」,本分片在它
9691
+ // 之后求值,改不动它。所以照 `11-starmap-styles.js` / 70 的老办法自带一段、幂等注入
9692
+ // (同一个 `data-plugin-css` 只挂一次)。
9693
+ // 只用宿主 token:`--dsw-alias-*`;不出现 `state-danger-*`(没有这个 token)与 `bg-l*`。
9694
+ const SYNC_PANEL_CSS = [
9695
+ // 输入框在这一行里吃掉剩余宽度:`.smem-autodream-row` 是 flex + wrap,`.smem-input`
9696
+ // 自带 `width:100%`,不收一下就会把旁边那颗按钮顶到下一行(面板 420px 起)。
9697
+ ".smem-syncp .smem-input{flex:1 1 150px;min-width:0;}",
9698
+ // 设备候选**一列**排开(单栏)。用按钮而不是 `Chip` 组件:Chip 表达「开 / 关」,
9699
+ // 这里表达「选这台」,而且一行里要装三样东西(主机名 / 系统 / 在线点)。
9700
+ ".smem-syncp-devlist{display:flex;flex-direction:column;gap:6px;}",
9701
+ ".smem-syncp-dev{display:flex;align-items:center;gap:8px;width:100%;box-sizing:border-box;text-align:left;border:1px solid var(--dsw-alias-border-l1);border-radius:8px;background:var(--dsw-alias-bg-base);color:var(--dsw-alias-label-primary);padding:5px 9px;font-size:12px;cursor:pointer;}",
9702
+ ".smem-syncp-dev:hover:not(:disabled){border-color:var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-2);}",
9703
+ ".smem-syncp-dev--on{border-color:var(--dsw-alias-brand-primary);}",
9704
+ ".smem-syncp-devhost{font-weight:600;overflow-wrap:anywhere;}",
9705
+ // 在线点:颜色靠背景,尺寸固定 7px(比文字小,不抢眼)。离线是灰的、不是红的 ——
9706
+ // 离线不是错误,别拿错误色去喊它。
9707
+ ".smem-syncp-dot{flex:none;width:7px;height:7px;border-radius:50%;margin-left:auto;background:var(--dsw-alias-label-secondary);}",
9708
+ ".smem-syncp-dot[data-on=\"1\"]{background:var(--dsw-alias-state-success-primary);}",
9709
+ // 首次推送那道门:用 warn 而不是 error —— 它不是失败,是要人点一次头。
9710
+ ".smem-syncp-gate{display:flex;flex-direction:column;gap:6px;border:1px solid var(--dsw-alias-state-warn-primary,#d97706);border-radius:10px;background:var(--dsw-alias-bg-layer-1);padding:10px 12px;}",
9711
+ ".smem-syncp-gatetitle{font-size:12.5px;font-weight:600;color:var(--dsw-alias-label-primary);}",
9712
+ ".smem-syncp-result{display:flex;flex-direction:column;gap:6px;}",
9713
+ // 报告:等宽原样。`pre-wrap` 让 markdown 的长行折在卡片里,而不是把面板撑出横向滚动。
9714
+ ".smem-syncp-report{margin:0;border:1px solid var(--dsw-alias-border-l1);border-radius:8px;background:var(--dsw-alias-bg-base);color:var(--dsw-alias-label-primary);padding:8px 10px;max-height:340px;overflow:auto;white-space:pre-wrap;overflow-wrap:anywhere;font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:11.5px;line-height:1.55;}",
9715
+ ].join("\n");
9716
+
9717
+ /** 幂等注入(同一个 id 只挂一次;`document` 不在时安静跳过,测试环境就这么用)。 */
9718
+ function injectSyncPanelStyle() {
9719
+ try {
9720
+ if (typeof document === "undefined" || !document || typeof document.createElement !== "function") return;
9721
+ const tagId = "sage-mem/sync-panel.css";
9722
+ if (typeof document.querySelector === "function"
9723
+ && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId) + "]") !== null) return;
9724
+ const tag = document.createElement("style");
9725
+ if (tag.dataset) { tag.dataset.plugin = "sage-mem"; tag.dataset.pluginCss = tagId; }
9726
+ tag.textContent = SYNC_PANEL_CSS;
9727
+ if (document.head && typeof document.head.appendChild === "function") document.head.appendChild(tag);
9728
+ } catch (e) { /* 样式注入失败不该让界面白屏 */ }
9729
+ }
9730
+ injectSyncPanelStyle();
9731
+
9732
+ // ── 卡片 ───────────────────────────────────────────────────────────────
9733
+
9734
+ /**
9735
+ * 「跨设备同步」(3.1.0)—— 挂在「外部访问」页的来件卡之后、「跨设备差异」卡**之前**。
9736
+ *
9737
+ * 为什么在差异卡之前:先「触发一次同步」,再「裁决它产生的差异」。反过来摆的话,
9738
+ * 人得先滚过一列待裁决记录才看得见「其实还没连过远端」这件事。
9739
+ *
9740
+ * 宿主没有 `sync` 面(旧宿主)时**卡还画**,只是按钮禁用并在 title 里点名缺哪个接口 ——
9741
+ * 输入框那半边是 `memory.setSettings`,它跟同步面没关系,仍然有用(配置可以先前置)。
9742
+ * 这与 `70-ext-sync.js` 那张「整块不渲染」不同:那一卡的数据**全部**来自 `conflict` 面,
9743
+ * 画一个空壳只会让人以为同步坏了;这一卡有一半是设置。
9744
+ */
9745
+ function ExternalSyncPanelCard(props) {
9746
+ const memRemote = stableRemote(props.ctx, "remote.memory");
9747
+ const syncRemote = stableRemote(props.ctx, "remote.sync");
9748
+ const canRun = !!syncRemote && typeof syncRemote.run === "function";
9749
+ const canDevices = !!syncRemote && typeof syncRemote.devices === "function";
9750
+
9751
+ const sSet = react.useState(null); const memSet = sSet[0], setMemSet = sSet[1];
9752
+ const sHost = react.useState(""); const hostDraft = sHost[0], setHostDraft = sHost[1];
9753
+ const sPath = react.useState(""); const pathDraft = sPath[0], setPathDraft = sPath[1];
9754
+ const sDevs = react.useState(null); const devs = sDevs[0], setDevs = sDevs[1];
9755
+ const sDevErr = react.useState(""); const devErr = sDevErr[0], setDevErr = sDevErr[1];
9756
+ const sBusy = react.useState(""); const busy = sBusy[0], setBusy = sBusy[1];
9757
+ const sReport = react.useState(null); const report = sReport[0], setReport = sReport[1];
9758
+ const sFail = react.useState(null); const fail = sFail[0], setFail = sFail[1];
9759
+ const sNotice = react.useState(""); const notice = sNotice[0], setNotice = sNotice[1];
9760
+ const sStaged = react.useState(""); const staged = sStaged[0], setStaged = sStaged[1];
9761
+ const sGate = react.useState(null); const gate = sGate[0], setGate = sGate[1];
9762
+ const sConfirm = react.useState(null); const confirm = sConfirm[0], setConfirm = sConfirm[1];
9763
+
9764
+ /** 服务端**已保存**的那份(失焦保存只跟它比,不与草稿比)。 */
9765
+ const saved = (memSet && memSet.sync) || null;
9766
+ const diagnostics = (memSet && Array.isArray(memSet.syncDiagnostics)) ? memSet.syncDiagnostics : [];
9767
+ const savedHost = String((saved && saved.host) || "");
9768
+ const savedPath = String((saved && saved.remotePath) || "");
9769
+ const frozen = busy !== "";
9770
+
9771
+ function load() {
9772
+ if (!memRemote || typeof memRemote.getSettings !== "function") {
9773
+ setFail({ code: "", error: t("ext.syncPanel.err.noSettings") });
9774
+ return;
9775
+ }
9776
+ Promise.resolve(memRemote.getSettings()).then(function (res) {
9777
+ const d = unwrap(res) || {};
9778
+ setMemSet(d);
9779
+ const sy = d.sync || {};
9780
+ setHostDraft(String(sy.host == null ? "" : sy.host));
9781
+ setPathDraft(String(sy.remotePath == null ? "" : sy.remotePath));
9782
+ }, function (e) { setFail({ code: "", error: detail(e) }); });
9783
+ }
9784
+
9785
+ react.useEffect(function () { load(); }, []);
9786
+
9787
+ /**
9788
+ * 存一项。**一次只带一个键**。
9789
+ *
9790
+ * 宿主按整段合并(`{...现有, ...patch}`),两个键一起发就等于替用户改了这次没碰的
9791
+ * 那一项 —— 尤其「远端目录」还在草稿里没失焦的时候。
9792
+ */
9793
+ function saveOne(key, value, okMsg) {
9794
+ if (!memRemote || typeof memRemote.setSettings !== "function") {
9795
+ setFail({ code: "", error: t("ext.syncPanel.err.noSettings") });
9796
+ return;
9797
+ }
9798
+ const patch = key === "host" ? { sync: { host: value } } : { sync: { remotePath: value } };
9799
+ if (key === "host") setHostDraft(value); else setPathDraft(value);
9800
+ setBusy("save"); setFail(null); setNotice("");
9801
+ Promise.resolve(memRemote.setSettings(patch)).then(function (out) {
9802
+ setBusy("");
9803
+ // `setSettings` 自带 `{ok, settings}`:直接读,**不要** unwrap(68 / 64 同一条)。
9804
+ if (out && out.ok === false) {
9805
+ setFail({ code: out.code ? String(out.code) : "", error: String(out.error || "") });
9806
+ return;
9807
+ }
9808
+ if (out && out.settings) setMemSet(out.settings);
9809
+ setNotice(okMsg || t("ext.syncPanel.saved"));
9810
+ }, function (e) {
9811
+ setBusy("");
9812
+ setFail({ code: "", error: detail(e) });
9813
+ });
9814
+ }
9815
+
9816
+ /** 失焦即存(仓库惯例)。只在**真的变了**才发请求,否则点进点出会白刷一次提示。 */
9817
+ function saveHostIfChanged() {
9818
+ const v = String(hostDraft == null ? "" : hostDraft).trim();
9819
+ if (v === savedHost) return;
9820
+ saveOne("host", v);
9821
+ }
9822
+
9823
+ function savePathIfChanged() {
9824
+ const v = String(pathDraft == null ? "" : pathDraft).trim();
9825
+ if (v === savedPath) return;
9826
+ saveOne("remotePath", v);
9827
+ }
9828
+
9829
+ /** 回车 = 立即保存并失焦。 */
9830
+ function onEnter(handler) {
9831
+ return function (e) {
9832
+ if (e.key !== "Enter") return;
9833
+ e.preventDefault();
9834
+ handler();
9835
+ if (e.target && typeof e.target.blur === "function") e.target.blur();
9836
+ };
9837
+ }
9838
+
9839
+ /** 设备候选 —— **只在点按钮时**调(它背后是一条 `tailscale`)。 */
9840
+ function loadDevices() {
9841
+ if (!canDevices) {
9842
+ setDevErr(t("ext.syncPanel.err.noRemote"));
9843
+ return;
9844
+ }
9845
+ setBusy("devices"); setDevErr("");
9846
+ Promise.resolve(syncRemote.devices()).then(function (res) {
9847
+ setBusy("");
9848
+ const d = unwrap(res) || {};
9849
+ if (d.ok === false) {
9850
+ setDevs(null);
9851
+ setDevErr(t("ext.syncPanel.devicesFailed", {
9852
+ code: String(d.code || "?"), error: String(d.error || ""),
9853
+ }));
9854
+ return;
9855
+ }
9856
+ setDevs({
9857
+ available: d.available !== false,
9858
+ reason: String(d.reason == null ? "" : d.reason),
9859
+ devices: Array.isArray(d.devices) ? d.devices : [],
9860
+ });
9861
+ }, function (e) {
9862
+ setBusy("");
9863
+ setDevs(null);
9864
+ setDevErr(t("ext.syncPanel.devicesFailed", { code: "", error: detail(e) }));
9865
+ });
9866
+ }
9867
+
9868
+ /**
9869
+ * 点候选 = 选这台。**点了就存**,不只是填进输入框。
9870
+ *
9871
+ * 理由:`sync.run()` 不带 `host` 时读的是**设置里**的值。只填不存的话,下一步
9872
+ * 「检查」会拿旧的别名去跑 —— 那是「按了没反应」的另一种长相,而且很难自己看出来。
9873
+ */
9874
+ function pickDevice(host) {
9875
+ const v = String(host == null ? "" : host);
9876
+ setHostDraft(v);
9877
+ if (v === savedHost) return;
9878
+ saveOne("host", v);
9879
+ }
9880
+
9881
+ function labelOf(action) {
9882
+ return action === "pull"
9883
+ ? t("ext.syncPanel.pull")
9884
+ : (action === "push" ? t("ext.syncPanel.push") : t("ext.syncPanel.check"));
9885
+ }
9886
+
9887
+ /**
9888
+ * 一次动作的唯一出口。`apply` / `confirm` **原样**交给宿主:预演与点头都是宿主的
9889
+ * 判据,这一层越权改写等于偷偷替人点了头。
9890
+ */
9891
+ function callRun(action, apply, confirmFlag) {
9892
+ if (!canRun) {
9893
+ setFail({ code: "unsupported", error: t("ext.syncPanel.err.noRemote") });
9894
+ return;
9895
+ }
9896
+ const opts = { action: action };
9897
+ // 拉取 / 推送**显式**带 `apply`(预演就是 `apply:false`):宿主只认 `=== true`,
9898
+ // 但请求里写出来这件事本身是给人看的 —— 读日志时不必再猜「没带 = 预演?」。
9899
+ // `check` 不写:它没有写盘的路,带一个恒 false 的开关只是噪音。
9900
+ if (action !== "check") opts.apply = apply === true;
9901
+ if (confirmFlag === true) opts.confirm = true;
9902
+ setBusy(apply === true ? "apply" : action);
9903
+ setFail(null); setNotice("");
9904
+ Promise.resolve(syncRemote.run(opts)).then(function (res) {
9905
+ setBusy("");
9906
+ setConfirm(null);
9907
+ const d = unwrap(res) || {};
9908
+ const g = d.gate && typeof d.gate === "object" ? d.gate : null;
9909
+ // 门的两种形状都认:结构化码(`ok:false, code:'need_confirm'`)与 `gate.needConfirm`。
9910
+ const needConfirm = (d.ok === false && d.code === "need_confirm")
9911
+ || (!!g && g.needConfirm === true);
9912
+ const text = String(d.report == null ? "" : d.report);
9913
+ if (needConfirm && action === "push") {
9914
+ // 不是失败:远端库还没被认过。报告照旧摊开,另给一句人话 + 一颗确认按钮。
9915
+ setGate({
9916
+ deviceId: String((g && g.deviceId) || ""),
9917
+ deviceLabel: String((g && g.deviceLabel) || ""),
9918
+ });
9919
+ setStaged("");
9920
+ setReport(text === "" ? null : { action: action, text: text, applied: false });
9921
+ return;
9922
+ }
9923
+ setGate(null);
9924
+ setReport(text === "" ? null : { action: action, text: text, applied: d.applied === true });
9925
+ if (d.ok === false) {
9926
+ setStaged("");
9927
+ setFail({ code: String(d.code || "?"), error: String(d.error || "") });
9928
+ return;
9929
+ }
9930
+ setFail(null);
9931
+ if (action === "check") { setStaged(""); setNotice(t("ext.syncPanel.notice.check")); return; }
9932
+ if (apply === true) {
9933
+ setStaged("");
9934
+ setNotice(action === "pull" ? t("ext.syncPanel.notice.pull") : t("ext.syncPanel.notice.push"));
9935
+ return;
9936
+ }
9937
+ // 预演:按钮换成「执行…」,等第二次点击(第二次还要过模态)。
9938
+ setStaged(action);
9939
+ setNotice(t("ext.syncPanel.notice.preview"));
9940
+ }, function (e) {
9941
+ setBusy("");
9942
+ setConfirm(null);
9943
+ setFail({ code: "", error: detail(e) });
9944
+ });
9945
+ }
9946
+
9947
+ /** 一颗动作按钮。`staged` 的那颗升成主按钮:下一步该点哪个,一眼看得出来。 */
9948
+ function actionButton(action, label, onClick) {
9949
+ return h("button", {
9950
+ type: "button",
9951
+ className: "smem-btn smem-btn-xs" + (staged === action ? " smem-btn-primary" : ""),
9952
+ key: action,
9953
+ disabled: frozen || !canRun,
9954
+ title: canRun ? undefined : t("ext.syncPanel.err.noRemote"),
9955
+ onClick: onClick,
9956
+ }, label);
9957
+ }
9958
+
9959
+ function deviceListBlock() {
9960
+ if (devErr) return h("div", { className: "smem-err", key: "deverr" }, "⚠ " + devErr);
9961
+ if (!devs) return null;
9962
+ if (devs.available === false) {
9963
+ // 降级路径:这不是错误,是一句人话;输入框照旧手打。
9964
+ return h("div", { className: "smem-muted", key: "reason" },
9965
+ devs.reason === "" ? t("ext.syncPanel.devicesUnavailable") : devs.reason);
9966
+ }
9967
+ if (devs.devices.length === 0) {
9968
+ return h("div", { className: "smem-muted", key: "none" }, t("ext.syncPanel.devicesNone"));
9969
+ }
9970
+ return h("div", { className: "smem-syncp-devlist", key: "list" }, devs.devices.map(function (d, i) {
9971
+ const host = String((d && d.host) || "");
9972
+ const online = !!d && d.online === true;
9973
+ const ips = d && Array.isArray(d.ips) ? d.ips.join(", ") : "";
9974
+ const tip = String((d && d.dnsName) || host) + (ips === "" ? "" : " · " + ips);
9975
+ return h("button", {
9976
+ type: "button",
9977
+ className: "smem-syncp-dev" + (hostDraft === host ? " smem-syncp-dev--on" : ""),
9978
+ key: "dev-" + i + "-" + host,
9979
+ disabled: frozen,
9980
+ title: tip,
9981
+ onClick: function () { pickDevice(host); },
9982
+ }, [
9983
+ h("span", { className: "smem-syncp-devhost", key: "h" }, host === "" ? "?" : host),
9984
+ d && d.os ? h("span", { className: "smem-muted", key: "o" }, String(d.os)) : null,
9985
+ h("span", {
9986
+ className: "smem-syncp-dot", key: "dot",
9987
+ "data-on": online ? "1" : "0",
9988
+ "aria-hidden": "true",
9989
+ }),
9990
+ h("span", { className: "smem-muted", key: "st" },
9991
+ online ? t("ext.syncPanel.deviceOnline") : t("ext.syncPanel.deviceOffline")),
9992
+ ]);
9993
+ }));
9994
+ }
9995
+
9996
+ function gateBlock() {
9997
+ if (!gate) return null;
9998
+ const who = gate.deviceLabel !== ""
9999
+ ? gate.deviceLabel + (gate.deviceId === "" ? "" : "(" + gate.deviceId + ")")
10000
+ : t("ext.syncPanel.gate.noDevice");
10001
+ return h("div", { className: "smem-syncp-gate", key: "gate" }, [
10002
+ h("div", { className: "smem-syncp-gatetitle", key: "t" }, t("ext.syncPanel.gate.title")),
10003
+ h("div", { className: "smem-autodream-note", key: "b" }, t("ext.syncPanel.gate.body", { who: who })),
10004
+ h("div", { className: "smem-row", key: "acts" }, [
10005
+ h("button", {
10006
+ type: "button", className: "smem-btn smem-btn-xs smem-btn-primary", key: "yes",
10007
+ disabled: frozen,
10008
+ onClick: function () { callRun("push", true, true); },
10009
+ }, t("ext.syncPanel.gate.yes")),
10010
+ h("button", {
10011
+ type: "button", className: "smem-btn smem-btn-xs", key: "no",
10012
+ disabled: frozen,
10013
+ onClick: function () { setGate(null); },
10014
+ }, t("ext.syncPanel.gate.cancel")),
10015
+ ]),
10016
+ ]);
10017
+ }
10018
+
10019
+ function confirmBlock() {
10020
+ if (!confirm) return null;
10021
+ const isPull = confirm.action === "pull";
10022
+ return h(Confirm, {
10023
+ key: "confirm",
10024
+ title: isPull ? t("ext.syncPanel.confirm.pullTitle") : t("ext.syncPanel.confirm.pushTitle"),
10025
+ confirmLabel: t("ext.syncPanel.confirm.yes"),
10026
+ busyLabel: t("ext.syncPanel.confirm.busy"),
10027
+ busy: busy === "apply",
10028
+ danger: true,
10029
+ onCancel: function () { setConfirm(null); },
10030
+ onConfirm: function () { callRun(confirm.action, true, false); },
10031
+ }, [
10032
+ h("div", { key: "body" }, isPull
10033
+ ? t("ext.syncPanel.confirm.pullBody")
10034
+ : t("ext.syncPanel.confirm.pushBody")),
10035
+ ]);
10036
+ }
10037
+
10038
+ function resultBlock() {
10039
+ if (!report) {
10040
+ return h("div", { className: "smem-autodream-note", key: "none" }, t("ext.syncPanel.empty"));
10041
+ }
10042
+ return h("div", { className: "smem-syncp-result", key: "res" }, [
10043
+ h("div", { className: "smem-autodream-row", key: "head" }, [
10044
+ h("span", { className: "smem-autodream-key", key: "k" }, t("ext.syncPanel.report.title")),
10045
+ h("span", { className: "smem-muted", key: "kind" }, report.action === "check"
10046
+ ? t("ext.syncPanel.report.preview")
10047
+ : (report.applied ? t("ext.syncPanel.report.applied") : t("ext.syncPanel.report.preview"))),
10048
+ ]),
10049
+ // markdown 原样(见文件头:不在这里再写一个解析器)。
10050
+ h("pre", { className: "smem-syncp-report", key: "pre" },
10051
+ report.text === "" ? t("ext.syncPanel.report.empty") : report.text),
10052
+ ]);
10053
+ }
10054
+
10055
+ const busyText = busy === "check" ? t("ext.syncPanel.busy.check")
10056
+ : busy === "devices" ? t("ext.syncPanel.busy.devices")
10057
+ : busy === "save" ? t("ext.syncPanel.busy.save")
10058
+ : busy === "apply" ? t("ext.syncPanel.busy.apply")
10059
+ : busy === "pull" ? t("ext.syncPanel.busy.pull")
10060
+ : busy === "push" ? t("ext.syncPanel.busy.push")
10061
+ : "";
10062
+ const statusText = busy !== ""
10063
+ ? busyText
10064
+ : (staged !== ""
10065
+ ? t("ext.syncPanel.status.staged", { action: labelOf(staged) })
10066
+ // 跑过一次之后别再说「还没跑过」——报告就在下面,两句话会互相打脸。
10067
+ : (report
10068
+ ? t("ext.syncPanel.status.done", { action: labelOf(report.action) })
10069
+ : t("ext.syncPanel.status.idle")));
10070
+
10071
+ return h("div", { className: "smem-syncp smem-module-card" }, [
10072
+ h("div", { className: "smem-modcard-head", key: "head" }, [
10073
+ h("span", { className: "smem-modcard-title", key: "t" }, t("ext.syncPanel.title")),
10074
+ h("span", { className: "smem-modcard-status", key: "s" }, statusText),
10075
+ ]),
10076
+ h("div", { className: "smem-autodream-note", key: "what" }, t("ext.syncPanel.what")),
10077
+
10078
+ // ── 主机 + 设备候选 ──
10079
+ h("div", { className: "smem-autodream-sec", key: "host" }, [
10080
+ h("div", { className: "smem-autodream-row", key: "row" }, [
10081
+ h("span", { className: "smem-autodream-key", key: "k" }, t("ext.syncPanel.host")),
10082
+ h("input", {
10083
+ className: "smem-input", key: "i", type: "text",
10084
+ value: hostDraft,
10085
+ placeholder: t("ext.syncPanel.hostPlaceholder"),
10086
+ onChange: function (e) { setHostDraft(e.target.value); },
10087
+ onBlur: saveHostIfChanged,
10088
+ onKeyDown: onEnter(saveHostIfChanged),
10089
+ }),
10090
+ h("button", {
10091
+ type: "button", className: "smem-btn smem-btn-xs", key: "dev",
10092
+ disabled: frozen || !canDevices,
10093
+ title: canDevices ? undefined : t("ext.syncPanel.err.noRemote"),
10094
+ onClick: loadDevices,
10095
+ }, t("ext.syncPanel.devices")),
10096
+ ]),
10097
+ h("div", { className: "smem-autodream-note", key: "hint" }, t("ext.syncPanel.hostHint")),
10098
+ deviceListBlock(),
10099
+ ]),
10100
+
10101
+ // ── 远端记忆目录 ──
10102
+ h("div", { className: "smem-autodream-sec", key: "path" }, [
10103
+ h("div", { className: "smem-autodream-row", key: "row" }, [
10104
+ h("span", { className: "smem-autodream-key", key: "k" }, t("ext.syncPanel.remotePath")),
10105
+ h("input", {
10106
+ className: "smem-input", key: "i", type: "text",
10107
+ value: pathDraft,
10108
+ placeholder: t("ext.syncPanel.remotePathPlaceholder"),
10109
+ onChange: function (e) { setPathDraft(e.target.value); },
10110
+ onBlur: savePathIfChanged,
10111
+ onKeyDown: onEnter(savePathIfChanged),
10112
+ }),
10113
+ ]),
10114
+ h("div", { className: "smem-autodream-note", key: "hint" }, t("ext.syncPanel.pathHint")),
10115
+ ]),
10116
+
10117
+ // ── 三个动作 ──
10118
+ h("div", { className: "smem-autodream-sec", key: "acts" }, [
10119
+ h("div", { className: "smem-row", key: "row" }, [
10120
+ actionButton("check", t("ext.syncPanel.check"), function () {
10121
+ if (busy !== "") return;
10122
+ callRun("check", false, false);
10123
+ }),
10124
+ actionButton("pull", staged === "pull" ? t("ext.syncPanel.pullApply") : t("ext.syncPanel.pull"), function () {
10125
+ if (busy !== "") return;
10126
+ // 第二次点击只开模态;**真正写盘**在模态的确认键上。
10127
+ if (staged === "pull") { setConfirm({ action: "pull" }); return; }
10128
+ callRun("pull", false, false);
10129
+ }),
10130
+ actionButton("push", staged === "push" ? t("ext.syncPanel.pushApply") : t("ext.syncPanel.push"), function () {
10131
+ if (busy !== "") return;
10132
+ if (staged === "push") { setConfirm({ action: "push" }); return; }
10133
+ callRun("push", false, false);
10134
+ }),
10135
+ ]),
10136
+ h("div", { className: "smem-autodream-note", key: "hint" }, t("ext.syncPanel.actionsHint")),
10137
+ ]),
10138
+
10139
+ // ── 结果 ──
10140
+ h("div", { className: "smem-autodream-sec", key: "result" }, [resultBlock()]),
10141
+
10142
+ gateBlock(),
10143
+ confirmBlock(),
10144
+ fail
10145
+ ? h("div", { className: "smem-err", key: "fail" }, "⚠ " + (fail.code === ""
10146
+ ? String(fail.error)
10147
+ : t("ext.syncPanel.failed", { code: String(fail.code), error: String(fail.error) })))
10148
+ : null,
10149
+ notice ? h("div", { className: "smem-ok", key: "ok" }, "✓ " + notice) : null,
10150
+ diagnostics.length > 0
10151
+ ? h("div", { className: "smem-err", key: "diag" }, "⚠ " + diagnostics.join(" · "))
10152
+ : null,
10153
+ ]);
10154
+ }
9454
10155
  // ── 文件列表这一屏(1.5.3 从 Section 里抽出;D23 计划的 72 片)──────────
9455
10156
  // 只负责「按状态/筛选把卡片摆出来 + 四种空态」;状态、筛选语义、动作回调全部由 Section 传。
9456
10157
  // 抽出的判据:它是 Section 里最大的一块纯渲染,而卡片组件(Card / ArchivedCard)本来就在 50 共享层。