dsh-config-sync-plugin 0.3.90 → 0.3.92

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,20 @@ 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
+ ### Remote "uncommitted" now includes local pending changes + Refresh really fetches (0.3.92)
261
+
262
+ Root cause found by measurement for "remote info still not updating": the git-level behind/ahead really is 0 (local HEAD matches the gitee cloud), while what the user means by "not updated" is the runtime-generated changes on this machine not yet captured into the repo. Two substantive fixes:
263
+
264
+ 1. **"Uncommitted" = git work-tree changes + local pending**: the status `repo` object gains `pending` (local session/config changes not yet synced) and `uncommitted` (`dirty + pending`). Both "Remote" Kv rows in the panel use `uncommitted` for the uncommitted figure and append "(N pending on this machine)" when there are pending items. New local sessions/config changes show up immediately without waiting for DSH exit + capture.
265
+ 2. **"Refresh" button actually fetches**: the summary-row "Refresh" button previously only re-read status (no git fetch, so behind/ahead stayed the same). It now runs `refreshRemoteNow`: first `/config-sync/auto {action:'check'}` to trigger `git fetch` and refresh remote refs, then refresh the snapshot. The 30-second auto-refresh while expanded shares the same chain.
266
+
267
+ ### Settings → General → Config Sync: live remote info + Pull/Push now buttons (0.3.91)
268
+
269
+ Two adjustments to the "Settings → General → Config Sync" summary row:
270
+
271
+ 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.
272
+ 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.
273
+
260
274
  ### To-do and jump-tab display cleanup (0.3.90)
261
275
 
262
276
  Four display adjustments to the panel:
@@ -690,6 +704,8 @@ The log shows which path ran: `文件比较(快筛):比对 N 个,深哈
690
704
 
691
705
  | Date | Version | Summary |
692
706
  |---|---|---|
707
+ | 2026-11-24 | 0.3.92 | Remote "uncommitted" now includes local pending data (pending); Refresh button really triggers git fetch; fixes "remote figures always 0" |
708
+ | 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
709
  | 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
710
  | 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
711
  | 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,20 @@ 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
+ ### 远端「未提交」纳入本机待同步 + 刷新按钮真正 fetch(0.3.92)
281
+
282
+ 针对「远端信息还是没更新」的实测根因:git 层的「落后/领先」确实是 0(本机 HEAD 与云端 gitee 一致),用户说的「没更新」其实是本机运行期新产生、还没 capture 进仓库的待同步数据。这次做两处实质性改动:
283
+
284
+ 1. **「未提交」= git 工作树改动 + 本机待同步**:后端 status 的 `repo` 对象新增 `pending`(本机还没同步的会话/配置改动数)与 `uncommitted`(`dirty + pending`)两个字段。面板两处「远端」Kv 的「未提交」改用 `uncommitted`,并在有待同步项时追加「(本机待同步 N)」。这样本机有新会话/配置改动时数字立刻可见,不用等退出 DSH capture。
285
+ 2. **「刷新」按钮真正 fetch**:原来摘要行的「刷新」只重读 status(不触发 git fetch,落后/领先数照旧)。现在刷新按钮走 `refreshRemoteNow`:先 `/config-sync/auto {action:'check'}` 触发 `git fetch` 更新远端引用,再刷新快照;展开时的 30 秒自动刷新统一复用这条链。
286
+
287
+ ### 设置-通用-配置同步:远端信息自动刷新 + 立即拉取/推送按钮(0.3.91)
288
+
289
+ 「设置 → 通用设置 → 配置同步」摘要行两处调整:
290
+
291
+ 1. **远端信息不再陈旧**:展开这一行时会先请求 `/config-sync/auto` 的 `check` 动作(触发 `git fetch` 更新 `@{upstream}`),再刷新状态,远端「落后 X · 领先 Y · 未提交 Z」显示的是云端最新值而非旧值;展开期间每 30 秒自动刷新一次,收起即停。根因是 `@{upstream}` 的落后/领先数只在 fetch 后才更新,单纯读 status 不会触发 fetch。
292
+ 2. **按钮换成「立即拉取 / 立即推送」**:原来四个「生成脚本 / 只生成推送 / 只生成拉取 / 只生成还原」按钮换成两个 —— **立即拉取(会关闭 DSH)** 与 **立即推送(会关闭 DSH)**,和主面板「自动同步」卡走同一条 `pull-now` / `push-now` 队列:点击即排队、退出 DSH 后执行。按钮按后端门禁(`pullAllowed` / `pushAllowed`)置灰并给出提示(空仓库先推 / 云端为空先拉),排队中与结果都有中文反馈。原「生成脚本」入口保留在主面板,摘要行不再重复。
293
+
280
294
  ### 待办与跳转按钮的显示梳理(0.3.90)
281
295
 
282
296
  面板的四处显示调整:
@@ -672,6 +686,8 @@ pwsh -File sync.ps1 push -ScanHistory
672
686
 
673
687
  | 日期 | 版本 | 要点 |
674
688
  |---|---|---|
689
+ | 2026-11-24 | 0.3.92 | 远端「未提交」纳入本机待同步数据(pending),刷新按钮真正触发 git fetch;解决「远端数字一直是 0」 |
690
+ | 2026-11-24 | 0.3.91 | 设置-通用-配置同步摘要行展开时先 fetch 再刷新远端信息(不再陈旧、每 30 秒自动刷新);四个生成脚本按钮换成「立即拉取/推送(会关闭 DSH)」两个,走自动同步同一队列 |
675
691
  | 2026-11-24 | 0.3.90 | 顶部跳转按钮跟随当前位置高亮;待办去掉「本机数据」字眼、可展开看具体会话记录名与本机 profile |
676
692
  | 2026-11-24 | 0.3.89 | 插件更新卡新增「npm 下载路径」;npm 双源(镜像+官方)兜底下载,仍按权威 sha256 校验 |
677
693
  | 2026-11-23 | 0.3.86 | 「本机数据」挪进概览-待办,按同步内容的 12 组口径分类统计,会话样本显示会话标题而非 session id |
package/client.js CHANGED
@@ -696,8 +696,8 @@ window.__ModuleLoader__.load({
696
696
  k: M('远端', 'Remote'),
697
697
  v: repo.exists
698
698
  ? M(
699
- `落后 ${repo.behind ?? '?'} · 领先 ${repo.ahead ?? '?'} · 未提交 ${repo.dirty ?? '?'}`,
700
- `behind ${repo.behind ?? '?'} · ahead ${repo.ahead ?? '?'} · dirty ${repo.dirty ?? '?'}`,
699
+ `落后 ${repo.behind ?? '?'} · 领先 ${repo.ahead ?? '?'} · 未提交 ${repo.uncommitted ?? repo.dirty ?? '?'}` + (repo.pending ? `(本机待同步 ${repo.pending})` : ''),
700
+ `behind ${repo.behind ?? '?'} · ahead ${repo.ahead ?? '?'} · uncommitted ${repo.uncommitted ?? repo.dirty ?? '?'}` + (repo.pending ? ` (${repo.pending} pending on this machine)` : ''),
701
701
  )
702
702
  : (repo.empty ? M('(拉取之后才有得比)', '(available after the first pull)') : M('(不可用)', '(unavailable)')),
703
703
  }),
@@ -3456,9 +3456,43 @@ 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
+ // 远端数字不刷新的根因有两层:
3470
+ // 1) 落后/领先来自 git tracking ref,必须 fetch 才更新 —— check 动作会 fetch;
3471
+ // 2) 用户说的「没更新」还包括本机还没 capture 进仓库的待同步数据 —— 后端已并进 repo.uncommitted/pending。
3472
+ // 「刷新」按钮与展开时的自动刷新都走这条链:先 check(fetch),再 refresh 拉新快照。
3473
+ const refreshRemoteNow = react.useCallback(async () => {
3474
+ try { await callAuto({ action: 'check' }) } catch { /* 离线就按本机缓存显示,不打扰 */ }
3475
+ refresh()
3476
+ }, [refresh])
3477
+ react.useEffect(() => {
3478
+ if (!open) return
3479
+ refreshRemoteNow()
3480
+ const timer = setInterval(refreshRemoteNow, 30000)
3481
+ return () => { clearInterval(timer) }
3482
+ }, [open, refreshRemoteNow])
3483
+
3484
+ // 立即拉取 / 立即推送:和大面板「自动同步」卡同一条 /config-sync/auto 队列,
3485
+ // 点完排队、关掉 DSH 后由 post-exit.ps1 真正执行(本进程不自己动手)。
3486
+ const actNow = async (action) => {
3487
+ setActBusy(action); setActErr(''); setActMsg('')
3488
+ try {
3489
+ const res = await callAuto({ action })
3490
+ setActMsg(res.closeRequested
3491
+ ? M('已排队:客户端马上关闭,退出后执行;拉取完成后按设置自动重开', 'Queued: the client closes now and the sync runs after exit; it relaunches per your settings when pulling finishes')
3492
+ : M('已排队:退出 DSH 后自动执行', 'Queued: runs automatically after DSH exits'))
3493
+ refresh()
3494
+ } catch (e) { setActErr(String((e && e.message) || e)) } finally { setActBusy('') }
3495
+ }
3462
3496
 
3463
3497
  const head = h('div', { style: S.head },
3464
3498
  h('div', { style: S.headText },
@@ -3469,7 +3503,7 @@ window.__ModuleLoader__.load({
3469
3503
  h('div', { style: { display: 'flex', gap: '8px', alignItems: 'center', flexShrink: 0 } },
3470
3504
  h('span', { style: chipStyle(summary.kind) }, chipLabel(summary.kind)),
3471
3505
  h('button', { type: 'button', style: S.btn, onClick: () => setOpen((v) => !v) }, open ? M('收起', 'Collapse') : M('查看', 'View')),
3472
- h('button', { type: 'button', style: S.btn, disabled: busy, onClick: refresh }, busy ? M('刷新中…', 'Refreshing…') : M('刷新', 'Refresh')),
3506
+ h('button', { type: 'button', style: S.btn, disabled: busy, onClick: refreshRemoteNow }, busy ? M('刷新中…', 'Refreshing…') : M('刷新', 'Refresh')),
3473
3507
  ),
3474
3508
  )
3475
3509
 
@@ -3493,8 +3527,8 @@ window.__ModuleLoader__.load({
3493
3527
  v: data.repo.behind === null
3494
3528
  ? M('读不到', 'Unavailable')
3495
3529
  : M(
3496
- `落后 ${data.repo.behind} · 领先 ${data.repo.ahead} · 未提交 ${data.repo.dirty}`,
3497
- `behind ${data.repo.behind} · ahead ${data.repo.ahead} · dirty ${data.repo.dirty}`,
3530
+ `落后 ${data.repo.behind} · 领先 ${data.repo.ahead} · 未提交 ${data.repo.uncommitted ?? data.repo.dirty}` + (data.repo.pending ? `(本机待同步 ${data.repo.pending})` : ''),
3531
+ `behind ${data.repo.behind} · ahead ${data.repo.ahead} · uncommitted ${data.repo.uncommitted ?? data.repo.dirty}` + (data.repo.pending ? ` (${data.repo.pending} pending on this machine)` : ''),
3498
3532
  ),
3499
3533
  }) : null,
3500
3534
  data ? h(Kv, {
@@ -3508,12 +3542,23 @@ window.__ModuleLoader__.load({
3508
3542
  data && data.remote ? h(Kv, { k: M('SSH 私钥', 'SSH key'), v: data.remote.sshKey || M('(未配置)', '(not set)') }) : null,
3509
3543
  data ? h(Advice, { items: data.advice }) : null,
3510
3544
  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')),
3545
+ h('button', {
3546
+ type: 'button',
3547
+ style: canPull ? S.btnPrimary : { ...S.btnPrimary, opacity: 0.5, cursor: 'not-allowed' },
3548
+ disabled: Boolean(actBusy) || !canPull,
3549
+ title: canPull ? '' : M('云端还是空的:没有内容可拉,先「立即推送」', 'The cloud is still empty — nothing to pull, push first'),
3550
+ onClick: () => actNow('pull-now'),
3551
+ }, actBusy === 'pull-now' ? M('排队中…', 'Queueing…') : M('立即拉取(会关闭 DSH)', 'Pull now (closes DSH)')),
3552
+ h('button', {
3553
+ type: 'button',
3554
+ style: canPush ? S.btnPrimary : { ...S.btnPrimary, opacity: 0.5, cursor: 'not-allowed' },
3555
+ disabled: Boolean(actBusy) || !canPush,
3556
+ title: canPush ? '' : M('本机还是空的、云端已有内容:先「立即拉取」', 'The local repo is empty while the cloud has content — pull first'),
3557
+ onClick: () => actNow('push-now'),
3558
+ }, actBusy === 'push-now' ? M('排队中…', 'Queueing…') : M('立即推送(会关闭 DSH)', 'Push now (closes DSH)')),
3515
3559
  ),
3516
- h(MadeNote, { made }),
3560
+ actErr ? h('div', { style: { ...S.hint, color: 'var(--dsw-alias-state-error-primary)' } }, actErr) : null,
3561
+ actMsg ? h('div', { style: { ...S.hint, color: 'var(--dsw-alias-state-success-primary)' } }, actMsg) : null,
3517
3562
  ),
3518
3563
  )
3519
3564
  }
package/index.js CHANGED
@@ -1119,6 +1119,10 @@ async function inspect(config) {
1119
1119
  dirty,
1120
1120
  ahead,
1121
1121
  behind,
1122
+ // 本机待同步(还没 capture 进仓库的会话/配置改动),与 git 工作树 dirty 是两件事。
1123
+ pending: (local && local.pending) || 0,
1124
+ // 面板上用户理解的「未提交」= git 工作树改动 + 本机还没同步的改动,反映「还没进云端的本机改动总数」。
1125
+ uncommitted: (dirty || 0) + ((local && local.pending) || 0),
1122
1126
  },
1123
1127
  version: { local: localVersion, contract: contractVersion, electron: electronVersion, match: versionMatch },
1124
1128
  // 本机数据侧:上次同步时间 + 「之后又写过多少文件」,与 repo.dirty 是两件事
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.92",
4
4
  "type": "module",
5
5
  "description": "在 DSH 设置里查看 dsh-config 仓库与本机的同步状态,并生成退出后执行的 push/pull 脚本。同步动作本身不在应用内执行。面板与文案跟随客户端语言(中文/English)。",
6
6
  "main": "./index.js",
@@ -116,6 +116,21 @@ 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 = react.useCallback(async () =>')
122
+ && source.includes("callAuto({ action: 'check' })")
123
+ && source.includes('setInterval(refreshRemoteNow, 30000)')
124
+ && source.includes('onClick: refreshRemoteNow'))
125
+ check('远端「未提交」纳入本机待同步、刷新按钮触发 fetch(0.3.92)',
126
+ source.includes('repo.uncommitted ?? repo.dirty')
127
+ && source.includes('data.repo.uncommitted ?? data.repo.dirty')
128
+ && source.includes('本机待同步 ${data.repo.pending}'))
129
+ check('设置摘要行两个立即按钮走 pull-now / push-now 队列',
130
+ source.includes("actNow('pull-now')")
131
+ && source.includes("actNow('push-now')")
132
+ && source.includes("M('立即拉取(会关闭 DSH)', 'Pull now (closes DSH)')")
133
+ && source.includes("M('立即推送(会关闭 DSH)', 'Push now (closes DSH)')"))
119
134
  check('每个 inject 回调都返回了回收函数', recycle.length === 3 && recycle.every((r) => typeof r.stop === 'function'), `实际 ${recycle.length} 个`)
120
135
 
121
136
  // 关键契约:sidebar.panellist 必须先被 inject,再往里 register(只 inject main 是无效的)