dsh-config-sync-plugin 0.3.90 → 0.3.91

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/README.en.md CHANGED
@@ -257,6 +257,13 @@ Two display fixes on top of 0.3.77:
257
257
 
258
258
  The "Plugin update" card now shows an **npm download URL** line with the actual fallback addresses (domestic mirror `registry.npmmirror.com` + official `registry.npmjs.org`). When the GitHub release download is unreachable (common in mainland China), the update package automatically falls back to npm. It is still verified against the authoritative sha256 in `version.json` — switching source never relaxes verification. The two sources back each other up: the mirror can briefly 404 during its first-sync window, and the official source takes over. The npm tarball is byte-identical to the GitHub release tgz (same sha256).
259
259
 
260
+ ### Settings → General → Config Sync: live remote info + Pull/Push now buttons (0.3.91)
261
+
262
+ Two adjustments to the "Settings → General → Config Sync" summary row:
263
+
264
+ 1. **Remote info no longer stale**: expanding the row first requests the `check` action on `/config-sync/auto` (triggering `git fetch` to refresh `@{upstream}`) and then refreshes status, so "behind X · ahead Y · uncommitted Z" shows the latest cloud figures instead of stale ones; it refreshes every 30 seconds while expanded and stops when collapsed. Root cause: the behind/ahead counts from `@{upstream}` only update after a fetch — a plain status read never triggers one.
265
+ 2. **Buttons replaced with Pull/Push now**: the four "Generate scripts / push only / pull only / restore only" buttons are replaced by two — **Pull now (closes DSH)** and **Push now (closes DSH)** — sharing the same `pull-now` / `push-now` queue as the main panel's Automation card: clicking queues the action, which runs after DSH exits. Buttons are gated by backend permissions (`pullAllowed` / `pushAllowed`) with hints (empty repo → push first; empty cloud → pull first), and queued/result states give Chinese feedback. The script-generation entry remains on the main panel and is no longer duplicated in the summary row.
266
+
260
267
  ### To-do and jump-tab display cleanup (0.3.90)
261
268
 
262
269
  Four display adjustments to the panel:
@@ -690,6 +697,7 @@ The log shows which path ran: `文件比较(快筛):比对 N 个,深哈
690
697
 
691
698
  | Date | Version | Summary |
692
699
  |---|---|---|
700
+ | 2026-11-24 | 0.3.91 | Settings summary row fetches before refreshing remote info (no longer stale, auto-refresh every 30s); four generate-script buttons replaced with Pull/Push now (closes DSH) sharing the automation queue |
693
701
  | 2026-11-24 | 0.3.90 | Jump tabs highlight the current section; "Local data" label removed from To-do; To-do expands to concrete session names and local profile files |
694
702
  | 2026-11-24 | 0.3.89 | Plugin update card shows an "npm download URL"; falls back to two npm sources (mirror + official) when GitHub release is unreachable, still verified against the authoritative sha256 |
695
703
  | 2026-11-23 | 0.3.86 | Moved "Local data" into Overview / To-do, grouped pending files by the twelve sync-content groups, and show session names instead of session ids in the sample |
package/README.md CHANGED
@@ -277,6 +277,13 @@ pwsh -File runtime\sync.ps1 pull `
277
277
 
278
278
  「插件更新」卡新增一行 **npm 下载路径**,直接显示实际兜底地址(国内镜像 `registry.npmmirror.com` + 官方 `registry.npmjs.org` 两个源)。GitHub release 整段不通时(国内常见),更新包会自动兜底从 npm 下载;仍按 `version.json` 里的权威 sha256 校验,换源不放宽校验。两个源互为备份:镜像首发同步窗口期会短暂 404,官方源随即兜上。实测 npm tarball 与 GitHub release tgz 是同一份产物、sha256 完全一致。
279
279
 
280
+ ### 设置-通用-配置同步:远端信息自动刷新 + 立即拉取/推送按钮(0.3.91)
281
+
282
+ 「设置 → 通用设置 → 配置同步」摘要行两处调整:
283
+
284
+ 1. **远端信息不再陈旧**:展开这一行时会先请求 `/config-sync/auto` 的 `check` 动作(触发 `git fetch` 更新 `@{upstream}`),再刷新状态,远端「落后 X · 领先 Y · 未提交 Z」显示的是云端最新值而非旧值;展开期间每 30 秒自动刷新一次,收起即停。根因是 `@{upstream}` 的落后/领先数只在 fetch 后才更新,单纯读 status 不会触发 fetch。
285
+ 2. **按钮换成「立即拉取 / 立即推送」**:原来四个「生成脚本 / 只生成推送 / 只生成拉取 / 只生成还原」按钮换成两个 —— **立即拉取(会关闭 DSH)** 与 **立即推送(会关闭 DSH)**,和主面板「自动同步」卡走同一条 `pull-now` / `push-now` 队列:点击即排队、退出 DSH 后执行。按钮按后端门禁(`pullAllowed` / `pushAllowed`)置灰并给出提示(空仓库先推 / 云端为空先拉),排队中与结果都有中文反馈。原「生成脚本」入口保留在主面板,摘要行不再重复。
286
+
280
287
  ### 待办与跳转按钮的显示梳理(0.3.90)
281
288
 
282
289
  面板的四处显示调整:
@@ -672,6 +679,7 @@ pwsh -File sync.ps1 push -ScanHistory
672
679
 
673
680
  | 日期 | 版本 | 要点 |
674
681
  |---|---|---|
682
+ | 2026-11-24 | 0.3.91 | 设置-通用-配置同步摘要行展开时先 fetch 再刷新远端信息(不再陈旧、每 30 秒自动刷新);四个生成脚本按钮换成「立即拉取/推送(会关闭 DSH)」两个,走自动同步同一队列 |
675
683
  | 2026-11-24 | 0.3.90 | 顶部跳转按钮跟随当前位置高亮;待办去掉「本机数据」字眼、可展开看具体会话记录名与本机 profile |
676
684
  | 2026-11-24 | 0.3.89 | 插件更新卡新增「npm 下载路径」;npm 双源(镜像+官方)兜底下载,仍按权威 sha256 校验 |
677
685
  | 2026-11-23 | 0.3.86 | 「本机数据」挪进概览-待办,按同步内容的 12 组口径分类统计,会话样本显示会话标题而非 session id |
package/client.js CHANGED
@@ -3456,9 +3456,44 @@ window.__ModuleLoader__.load({
3456
3456
 
3457
3457
  /** 设置 → 通用 里的一行摘要(保留入口,不重复大面板)。 */
3458
3458
  function ConfigSyncRow() {
3459
- const { data, err, busy, made, refresh, prepare } = useSync()
3459
+ const { data, err, busy, refresh } = useSync()
3460
3460
  const [open, setOpen] = react.useState(false)
3461
+ const [actBusy, setActBusy] = react.useState('')
3462
+ const [actMsg, setActMsg] = react.useState('')
3463
+ const [actErr, setActErr] = react.useState('')
3461
3464
  const summary = summarize(data)
3465
+ const repo = (data && data.repo) || {}
3466
+ const canPull = repo.pullAllowed === true
3467
+ const canPush = repo.pushAllowed === true
3468
+
3469
+ // 远端信息不更新的根因:inspect() 的落后/领先数来自 git rev-list HEAD...@{upstream},
3470
+ // 而 @{upstream} 只有 git fetch 之后才反映云端最新,光 refresh() 拿到的还是旧引用。
3471
+ // 所以展开这里先打一次 /config-sync/auto {action:'check'}(它会 fetch 云端更新远端引用),
3472
+ // 再 refresh() 拉新快照;展开期间每 30 秒重复一次。
3473
+ react.useEffect(() => {
3474
+ if (!open) return
3475
+ let alive = true
3476
+ const refreshRemoteNow = async () => {
3477
+ try { await callAuto({ action: 'check' }) } catch { /* 离线就按本机缓存显示,不打扰 */ }
3478
+ if (alive) refresh()
3479
+ }
3480
+ refreshRemoteNow()
3481
+ const timer = setInterval(refreshRemoteNow, 30000)
3482
+ return () => { alive = false; clearInterval(timer) }
3483
+ }, [open, refresh])
3484
+
3485
+ // 立即拉取 / 立即推送:和大面板「自动同步」卡同一条 /config-sync/auto 队列,
3486
+ // 点完排队、关掉 DSH 后由 post-exit.ps1 真正执行(本进程不自己动手)。
3487
+ const actNow = async (action) => {
3488
+ setActBusy(action); setActErr(''); setActMsg('')
3489
+ try {
3490
+ const res = await callAuto({ action })
3491
+ setActMsg(res.closeRequested
3492
+ ? M('已排队:客户端马上关闭,退出后执行;拉取完成后按设置自动重开', 'Queued: the client closes now and the sync runs after exit; it relaunches per your settings when pulling finishes')
3493
+ : M('已排队:退出 DSH 后自动执行', 'Queued: runs automatically after DSH exits'))
3494
+ refresh()
3495
+ } catch (e) { setActErr(String((e && e.message) || e)) } finally { setActBusy('') }
3496
+ }
3462
3497
 
3463
3498
  const head = h('div', { style: S.head },
3464
3499
  h('div', { style: S.headText },
@@ -3508,12 +3543,23 @@ window.__ModuleLoader__.load({
3508
3543
  data && data.remote ? h(Kv, { k: M('SSH 私钥', 'SSH key'), v: data.remote.sshKey || M('(未配置)', '(not set)') }) : null,
3509
3544
  data ? h(Advice, { items: data.advice }) : null,
3510
3545
  h('div', { style: S.actions },
3511
- h('button', { type: 'button', style: S.btnPrimary, disabled: busy || !data || !data.repo.exists, onClick: () => prepare('all') }, M('一键生成 推送 / 拉取 / 还原', 'Generate push / pull / restore')),
3512
- h('button', { type: 'button', style: S.btn, disabled: busy || !data || !data.repo.exists, onClick: () => prepare('push') }, M('只生成推送', 'Push only')),
3513
- h('button', { type: 'button', style: S.btn, disabled: busy || !data || !data.repo.exists, onClick: () => prepare('pull') }, M('只生成拉取', 'Pull only')),
3514
- h('button', { type: 'button', style: S.btn, disabled: busy || !data || !data.repo.exists, onClick: () => prepare('restore') }, M('只生成还原', 'Restore only')),
3546
+ h('button', {
3547
+ type: 'button',
3548
+ style: canPull ? S.btnPrimary : { ...S.btnPrimary, opacity: 0.5, cursor: 'not-allowed' },
3549
+ disabled: Boolean(actBusy) || !canPull,
3550
+ title: canPull ? '' : M('云端还是空的:没有内容可拉,先「立即推送」', 'The cloud is still empty — nothing to pull, push first'),
3551
+ onClick: () => actNow('pull-now'),
3552
+ }, actBusy === 'pull-now' ? M('排队中…', 'Queueing…') : M('立即拉取(会关闭 DSH)', 'Pull now (closes DSH)')),
3553
+ h('button', {
3554
+ type: 'button',
3555
+ style: canPush ? S.btnPrimary : { ...S.btnPrimary, opacity: 0.5, cursor: 'not-allowed' },
3556
+ disabled: Boolean(actBusy) || !canPush,
3557
+ title: canPush ? '' : M('本机还是空的、云端已有内容:先「立即拉取」', 'The local repo is empty while the cloud has content — pull first'),
3558
+ onClick: () => actNow('push-now'),
3559
+ }, actBusy === 'push-now' ? M('排队中…', 'Queueing…') : M('立即推送(会关闭 DSH)', 'Push now (closes DSH)')),
3515
3560
  ),
3516
- h(MadeNote, { made }),
3561
+ actErr ? h('div', { style: { ...S.hint, color: 'var(--dsw-alias-state-error-primary)' } }, actErr) : null,
3562
+ actMsg ? h('div', { style: { ...S.hint, color: 'var(--dsw-alias-state-success-primary)' } }, actMsg) : null,
3517
3563
  ),
3518
3564
  )
3519
3565
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-config-sync-plugin",
3
- "version": "0.3.90",
3
+ "version": "0.3.91",
4
4
  "type": "module",
5
5
  "description": "在 DSH 设置里查看 dsh-config 仓库与本机的同步状态,并生成退出后执行的 push/pull 脚本。同步动作本身不在应用内执行。面板与文案跟随客户端语言(中文/English)。",
6
6
  "main": "./index.js",
@@ -116,6 +116,16 @@ check('云端仓库没配时推送/拉取禁用、还原仍可用',
116
116
  && source.includes("disabled: busy || !hasRepoPath, onClick: () => prepare('restore')"))
117
117
  check('面板有「提交说明」输入(生成推送脚本时带上)', source.includes('提交说明') && source.includes('prepare(\'push\', note)'))
118
118
  check('按钮文案用中文(推送 / 拉取)', source.includes("'只生成推送'") && source.includes("'只生成拉取'"))
119
+ // 0.3.91:设置 → 通用 摘要行的远端信息会刷新,按钮换成「立即拉取/推送(会关闭 DSH)」
120
+ check('设置摘要行展开时 fetch 远端再刷新(远端信息不陈旧)',
121
+ source.includes('const refreshRemoteNow = async () =>')
122
+ && source.includes("callAuto({ action: 'check' })")
123
+ && source.includes('setInterval(refreshRemoteNow, 30000)'))
124
+ check('设置摘要行两个立即按钮走 pull-now / push-now 队列',
125
+ source.includes("actNow('pull-now')")
126
+ && source.includes("actNow('push-now')")
127
+ && source.includes("M('立即拉取(会关闭 DSH)', 'Pull now (closes DSH)')")
128
+ && source.includes("M('立即推送(会关闭 DSH)', 'Push now (closes DSH)')"))
119
129
  check('每个 inject 回调都返回了回收函数', recycle.length === 3 && recycle.every((r) => typeof r.stop === 'function'), `实际 ${recycle.length} 个`)
120
130
 
121
131
  // 关键契约:sidebar.panellist 必须先被 inject,再往里 register(只 inject main 是无效的)