dsh-vscode-mode 0.37.0 → 0.39.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 (59) hide show
  1. package/README.md +54 -33
  2. package/lib/client.js +69 -66
  3. package/lib/client.js.map +1 -1
  4. package/lib/index.js +6774 -1925
  5. package/lib/index.js.map +1 -1
  6. package/package.json +3 -2
  7. package/skills/dsh-vscodemode-html-plan/SKILL.md +44 -42
  8. package/src/archiveDb.ts +24 -0
  9. package/src/archivePurge.ts +120 -28
  10. package/src/client/htmlPlan/HtmlPlanModeChip.ts +181 -0
  11. package/src/client/htmlPlan/HtmlPlanPanel.ts +230 -61
  12. package/src/client/htmlPlan/planActions.ts +38 -8
  13. package/src/client/htmlPlan/planPage.ts +111 -9
  14. package/src/client/index.ts +3 -0
  15. package/src/client/planBridge.ts +27 -2
  16. package/src/client/planState.ts +51 -4
  17. package/src/client/reviewBatch.ts +48 -1
  18. package/src/client/state/diffSummary.ts +5 -1
  19. package/src/client/styles/editor.css +16 -1
  20. package/src/client/ui/EditorView.ts +16 -10
  21. package/src/client/ui/McpSettings.ts +2 -2
  22. package/src/client/ui/OfficialReview.ts +6 -4
  23. package/src/client/ui/SvnCommitDialog.ts +256 -31
  24. package/src/client/ui/svnCommitModel.ts +63 -0
  25. package/src/htmlPlanCommand.ts +87 -177
  26. package/src/htmlPlanGuidance.ts +67 -0
  27. package/src/htmlPlanMode.ts +547 -0
  28. package/src/index.ts +32 -54
  29. package/src/officialCapture.ts +58 -9
  30. package/src/pending/capture.ts +201 -34
  31. package/src/pending/decide.ts +33 -1
  32. package/src/pending/externalCapture.ts +194 -333
  33. package/src/pending/kernel.ts +36 -2
  34. package/src/pending/noteTool.ts +96 -0
  35. package/src/pending/notes.ts +83 -0
  36. package/src/pending/persist.ts +312 -62
  37. package/src/pending/provenance.ts +50 -39
  38. package/src/pending/receipt.ts +177 -0
  39. package/src/pending/store.ts +230 -164
  40. package/src/pending/tracking.ts +81 -0
  41. package/src/pending/verdict.ts +170 -0
  42. package/src/pendingCompat.ts +40 -2
  43. package/src/pendingRpc.ts +8 -56
  44. package/src/planAutoPage.ts +306 -0
  45. package/src/planPagePack.ts +148 -0
  46. package/src/registry.ts +7 -2
  47. package/src/reviewDb.ts +64 -3
  48. package/src/reviewRpc.ts +61 -7
  49. package/src/rpc.ts +47 -7
  50. package/src/shared/htmlPlanMode.ts +26 -0
  51. package/src/shared/pendingReview.ts +35 -9
  52. package/src/shared/review.ts +22 -0
  53. package/src/shared/reviewRegions.ts +48 -3
  54. package/src/shared/rpc.ts +13 -9
  55. package/src/slowLog.ts +74 -0
  56. package/src/store.ts +17 -1
  57. package/src/textEncoding.probe.ts +1 -0
  58. package/src/pending/externalAlign.ts +0 -297
  59. package/src/pending/vcs.ts +0 -584
@@ -17,12 +17,13 @@ import { AI_COMMIT_STYLE_LABEL, AI_COMMIT_IDLE, runAiCommit } from '../aiCommit.
17
17
  import { svnCommitNow, svnCommitPlan } from '../svnCommit.js'
18
18
  import { SVN_ACTION_BY_ID } from '../../shared/svnActions.js'
19
19
  import type { SvnChangeEntry } from '../../shared/svn.js'
20
- import { SVN_STATUS_LABEL, SVN_STATUS_LETTER, SVN_STATUS_TONE } from '../../shared/svn.js'
20
+ import { SVN_STATUS_LABEL, SVN_STATUS_LETTER, SVN_STATUS_TONE, isSvnDiffable } from '../../shared/svn.js'
21
21
  import { updateParent } from './svnUpdateModel.js'
22
22
  import { entryIconEl } from './icons.js'
23
23
  import { isDirOf } from './svnIcons.js'
24
24
  import { useSvnEntryKinds } from './useSvnEntryKinds.js'
25
25
  import {
26
+ batchCheckValueOf,
26
27
  commitActs,
27
28
  commitHintOf,
28
29
  commitMessageErrorOf,
@@ -31,7 +32,10 @@ import {
31
32
  commitStatsOf,
32
33
  defaultCheckedOf,
33
34
  groupTriStateOf,
35
+ moveRowPick,
34
36
  nextRowPick,
37
+ pruneRowPick,
38
+ rangeCheckValueOf,
35
39
  } from './svnCommitModel.js'
36
40
 
37
41
  /** 状态分级的展示顺序(页脚计数同序,避免数字跳动)。 */
@@ -146,22 +150,22 @@ function useCommitMenu() {
146
150
  }
147
151
 
148
152
  /**
149
- * 行选中(Ctrl 切换 / Shift 范围):与更新窗口同一套手势,纯逻辑在 nextRowPick 里可单测。
150
- * @author ddj 2026年11月21号
153
+ * 行选中(Ctrl 切换 / Shift 范围 / 方向键移动):纯逻辑在 nextRowPick 与 moveRowPick 里可单测。
154
+ * @author ddj 2026年11月21号 / 2026年11月24号
151
155
  * @param order 当前显示顺序(路径)
152
- * @returns 选中路径与选择动作
156
+ * @returns 选中状态、写入器与手势
153
157
  */
154
158
  function useRowPick(order) {
155
159
  const [pick, setPick] = React.useState({ selected: [], anchor: null })
156
160
  const orderRef = React.useRef(order)
157
161
  orderRef.current = order
162
+ // 手势与键盘都要基于「最新一次渲染的选中」算下一态,闭包里读到的是旧值
163
+ const pickRef = React.useRef(pick)
164
+ pickRef.current = pick
158
165
 
159
166
  // 清单重载后丢弃已不存在的路径,避免批量动作打到过期目标
160
167
  React.useEffect(() => {
161
- setPick((current) => {
162
- const selected = current.selected.filter((path) => order.includes(path))
163
- return selected.length === current.selected.length ? current : { selected, anchor: null }
164
- })
168
+ setPick((current) => pruneRowPick(current, order))
165
169
  }, [order])
166
170
 
167
171
  /** @private @author ddj 2026年11月21号 @param event 点击事件 @param path 目标路径 @returns void */
@@ -170,20 +174,43 @@ function useRowPick(order) {
170
174
  setPick((current) => nextRowPick(current, orderRef.current, path, mode))
171
175
  }
172
176
 
173
- return { selected: pick.selected, choose }
177
+ /** @private @author ddj 2026年11月24号 @param step 方向(-1 上 / 1 下)@param extend 是否扩选 @returns 移动后的选中 */
178
+ const move = (step, extend) => {
179
+ const next = moveRowPick(pickRef.current, orderRef.current, step, extend)
180
+ setPick(next)
181
+ return next
182
+ }
183
+
184
+ /** @private @author ddj 2026年11月24号 @returns void */
185
+ const selectAll = () => {
186
+ const all = [...orderRef.current]
187
+ setPick({ selected: all, anchor: all[0] ?? null })
188
+ }
189
+
190
+ return { pick, setPick, choose, move, selectAll }
191
+ }
192
+
193
+ /**
194
+ * 事件目标是否落在勾选框列:那里的 Space 与状态切换交给原生控件,行不再重复处理。
195
+ * @author ddj 2026年11月24号
196
+ * @param target 事件目标
197
+ * @returns 是否在勾选框列
198
+ */
199
+ function isPickBox(target) {
200
+ return Boolean(target && typeof target.closest === 'function' && target.closest('.edrv-svncommit-pick'))
174
201
  }
175
202
 
176
203
  /**
177
204
  * 右键瞬间的生效选中:目标已在选中集合里就批量,否则先把选中改成该行。
178
- * @author ddj 2026年11月21号
179
- * @param rowPick 行选中状态 @param entry 右键目标
205
+ * @author ddj 2026年11月21号 / 2026年11月24号
206
+ * @param selected 当前选中路径 @param choose 选中手势 @param entry 右键目标
180
207
  * @returns 生效选中路径
181
208
  */
182
- function pickPathsOf(rowPick, entry) {
209
+ function pickPathsOf(selected, choose, entry) {
183
210
  if (!entry) return []
184
- if (rowPick.selected.includes(entry.path)) return rowPick.selected
211
+ if (selected.includes(entry.path)) return selected
185
212
 
186
- rowPick.choose({}, entry.path)
213
+ choose({}, entry.path)
187
214
  return [entry.path]
188
215
  }
189
216
 
@@ -247,15 +274,17 @@ async function pasteInto(s, menu) {
247
274
  }
248
275
 
249
276
  /**
250
- * 多选菜单:只做勾选与复制;破坏性动作仍限单行,避免一次误点还原多份本地改动。
251
- * @author ddj 2026年11月21号
252
- * @param s 视图状态 @param paths 选中路径
277
+ * 多选菜单:比较(只对右键那一行)+ 批量勾选与复制;破坏性动作仍限单行,
278
+ * 避免一次误点还原多份本地改动。
279
+ * @author ddj 2026年11月21号 / 2026年11月25号
280
+ * @param s 视图状态 @param entry 右键目标 @param paths 选中路径
253
281
  * @returns 菜单条目
254
282
  */
255
- function multiRowMenuOf(s, paths) {
283
+ function multiRowMenuOf(s, entry, paths) {
256
284
  const busy = Boolean(s.busy || s.aiBusy)
257
285
  return [
258
- { id: 'pick-on', label: '勾选选中 ' + paths.length + ' 项', disabled: busy, onClick: () => s.setPickChecked(paths, true) },
286
+ { id: 'compare', label: '与基线比较(这一行)', onClick: () => s.openCompare?.(entry.path) },
287
+ { id: 'pick-on', label: '勾选选中 ' + paths.length + ' 项', separator: true, disabled: busy, onClick: () => s.setPickChecked(paths, true) },
259
288
  { id: 'pick-off', label: '取消勾选选中 ' + paths.length + ' 项', disabled: busy, onClick: () => s.setPickChecked(paths, false) },
260
289
  { id: 'copy', label: '复制 ' + paths.length + ' 条路径', separator: true, disabled: busy,
261
290
  onClick: () => { void copyText(paths.join('\n'), '已复制路径', s.notify) } },
@@ -263,8 +292,28 @@ function multiRowMenuOf(s, paths) {
263
292
  }
264
293
 
265
294
  /**
266
- * 单选菜单:核对 / 打开 / 勾选 / 写动作 / 复制;可用性全部来自 commitActs。
267
- * @author ddj 2026年11月21号
295
+ * 行比较不可用的原因(空串 = 可以打开差异)。
296
+ *
297
+ * 菜单项不再靠 disabled 表达「不能比较」:禁用项点下去毫无反应,
298
+ * 用户只会以为功能坏了。改为始终可点,点了就用一句话说明为什么打不开。
299
+ * @author ddj 2026年11月25号
300
+ * @param entry 待提交条目
301
+ * @param busy 提交或 AI 生成进行中
302
+ * @param isDir 该行是否为目录
303
+ * @returns 不可用原因;空串表示可比较
304
+ */
305
+ function compareBlockOf(entry, busy, isDir) {
306
+ if (!entry) return '没有可比较的目标'
307
+ if (busy) return '提交或 AI 生成进行中,先等结果'
308
+ if (isDir) return '目录不能逐文件比较,请比较其中的文件'
309
+
310
+ return isSvnDiffable(entry.path, entry.status) ? '' : '二进制文件或未纳入版本控制,没有文本基线'
311
+ }
312
+
313
+ /**
314
+ * 单行菜单:核对 / 打开 / 勾选 / 写动作 / 复制;可用性全部来自 commitActs。
315
+ * 「与基线比较」保留可点:不可比较时用提示说明原因(见 compareBlockOf)。
316
+ * @author ddj 2026年11月21号 / 2026年11月25号
268
317
  * @param s 视图状态 @param entry 目标条目
269
318
  * @returns 菜单条目
270
319
  */
@@ -272,7 +321,7 @@ function oneRowMenuOf(s, entry) {
272
321
  const acts = commitActs(entry, Boolean(s.busy || s.aiBusy))
273
322
  const picked = s.checked.has(entry.path)
274
323
  return [
275
- { id: 'compare', label: '与基线比较', disabled: !acts.compare, onClick: () => s.onCompare?.(entry.path) },
324
+ { id: 'compare', label: '与基线比较', onClick: () => s.openCompare?.(entry.path) },
276
325
  { id: 'log', label: '查看日志', disabled: !acts.log, onClick: () => s.onShowLog?.(entry.path) },
277
326
  { id: 'open', label: '打开文件', separator: true, disabled: !acts.open, onClick: () => s.onOpenFile?.(entry.path) },
278
327
  { id: 'parent', label: '打开父目录', disabled: !acts.openParent, onClick: () => s.onOpenParent?.(updateParent(entry.path)) },
@@ -294,7 +343,7 @@ function rowMenuEntriesOf(s, menu) {
294
343
  if (!entry) return []
295
344
 
296
345
  const paths = menu.paths && menu.paths.length ? menu.paths : [entry.path]
297
- if (paths.length > 1) return multiRowMenuOf(s, paths)
346
+ if (paths.length > 1) return multiRowMenuOf(s, entry, paths)
298
347
  return oneRowMenuOf(s, entry)
299
348
  }
300
349
 
@@ -336,8 +385,8 @@ function msgMenuEntriesOf(s, menu) {
336
385
  }
337
386
 
338
387
  /**
339
- * 单条待提交文件(勾选 / 状态字母 / 图标 / 路径),支持右键与键盘唤起菜单。
340
- * @author ddj 2026年11月15号 / 2026年11月21号 / 2026年11月23号
388
+ * 单条待提交文件(勾选 / 状态字母 / 图标 / 路径),支持双击看差异、右键与键盘唤起菜单。
389
+ * @author ddj 2026年11月15号 / 2026年11月21号 / 2026年11月23号 / 2026年11月24号
341
390
  * @param entry 变更条目 @param checked 是否勾选 @param onToggle 切换 @param s 视图状态(菜单与动作)
342
391
  * @returns 行元素
343
392
  */
@@ -345,15 +394,20 @@ function rowEl(entry, checked, onToggle, s) {
345
394
  const tone = SVN_STATUS_TONE[entry.status] ?? 'plain'
346
395
  const opened = Boolean(s.menu && s.menu.kind === 'row' && s.menu.entry && s.menu.entry.path === entry.path)
347
396
  const selected = Boolean(s.selection && s.selection.includes(entry.path))
397
+ const diffable = commitActs(entry, Boolean(s.busy || s.aiBusy)).compare
348
398
  return React.createElement('div', {
349
399
  className: 'edrv-svncommit-row' + (opened ? ' is-menu' : '') + (selected ? ' is-selected' : ''),
350
400
  role: 'row',
351
401
  'aria-selected': selected,
352
402
  tabIndex: 0,
353
403
  key: entry.path,
404
+ 'data-path': entry.path,
405
+ ref: (node) => s.registerRow?.(entry.path, node),
406
+ title: diffable ? entry.path + '\n双击或回车:与基线比较' : entry.path,
354
407
  onClick: (event) => s.pickRow(event, entry.path),
408
+ onDoubleClick: (event) => s.diffRow(event, entry),
355
409
  onContextMenu: (event) => s.menuOpen(event, 'row', entry),
356
- onKeyDown: (event) => openMenuByKey(event, entry, s.menuOpen),
410
+ onKeyDown: (event) => s.rowKeyDown(event, entry),
357
411
  },
358
412
  React.createElement('span', { className: 'edrv-svncommit-pick', role: 'cell' }, checkBoxEl(checked, onToggle, entry.path)),
359
413
  React.createElement('span', {
@@ -401,8 +455,33 @@ function tableEl(s) {
401
455
  }
402
456
 
403
457
  /**
404
- * 工具带:最近信息 / AI 风格 / AI 生成 / 保持锁定 / 已选计数。
405
- * @author ddj 2026年11月15号
458
+ * 工具带上的批量勾选按钮:只在选中 2 行及以上时出现(选中是批量动作的作用域)。
459
+ * @author ddj 2026年11月24号
460
+ * @param s 视图状态
461
+ * @returns 按钮组元素;选中不足两行返回 null
462
+ */
463
+ function batchEl(s) {
464
+ const selected = s.selection ?? []
465
+ if (selected.length < 2) return null
466
+
467
+ const busy = Boolean(s.busy || s.aiBusy)
468
+ /** @private @author ddj 2026年11月24号 @param on 勾选还是取消 @param label 按钮文案 @returns 按钮 */
469
+ const cell = (on, label) => React.createElement('button', {
470
+ type: 'button',
471
+ className: 'edrv-svn-act edrv-svncommit-ctl',
472
+ disabled: busy,
473
+ title: on ? '把选中的 ' + selected.length + ' 项一起勾选(加入提交范围)' : '把选中的 ' + selected.length + ' 项一起取消勾选',
474
+ onClick: () => s.setPickChecked(selected, on),
475
+ }, label)
476
+
477
+ return React.createElement('span', { className: 'edrv-svncommit-sels' },
478
+ cell(true, '勾选选中 ' + selected.length + ' 项'),
479
+ cell(false, '取消勾选 ' + selected.length + ' 项'))
480
+ }
481
+
482
+ /**
483
+ * 工具带:最近信息 / AI 风格 / AI 生成 / 批量勾选 / 保持锁定 / 已选计数。
484
+ * @author ddj 2026年11月15号 / 2026年11月24号
406
485
  * @param s 视图状态
407
486
  * @returns 工具带元素
408
487
  */
@@ -442,6 +521,7 @@ function barEl(s) {
442
521
  disabled: s.aiBusy || s.busy || !s.paths.length,
443
522
  onClick: s.generate,
444
523
  }, '✨ AI 生成提交信息'),
524
+ batchEl(s),
445
525
  React.createElement('label', { className: 'edrv-svn-check', title: '提交后保留锁定(--no-unlock)' },
446
526
  React.createElement('input', {
447
527
  className: 'edrv-svncommit-cb',
@@ -738,12 +818,157 @@ export function SvnCommitDialog(props) {
738
818
  const s = useCommitState(sessionId, seed, notify, onCommitted, props.onChanged)
739
819
  const context = useCommitMenu()
740
820
  const rowPick = useRowPick(s.rowOrder)
821
+ // 方向键移动后要把焦点与滚动带到新行:按路径登记行节点,渲染期不查 DOM
822
+ const rowNodes = React.useRef(new Map())
741
823
  const entryKind = useSvnEntryKinds(s.rowOrder, sessionId)
824
+
825
+ /**
826
+ * 登记行节点(行卸载时清掉,避免焦点追到已消失的条目)。
827
+ * @author ddj 2026年11月24号
828
+ * @param path 行路径
829
+ * @param node 行节点
830
+ * @returns void
831
+ */
832
+ const registerRow = (path, node) => {
833
+ if (node) rowNodes.current.set(path, node)
834
+ else rowNodes.current.delete(path)
835
+ }
836
+
837
+ /**
838
+ * 把焦点与滚动带到指定行。
839
+ * @author ddj 2026年11月24号
840
+ * @param path 目标行路径
841
+ * @returns void
842
+ */
843
+ const focusRow = (path) => {
844
+ const node = path ? rowNodes.current.get(path) : null
845
+ if (!node) return
846
+
847
+ node.focus?.()
848
+ node.scrollIntoView?.({ block: 'nearest' })
849
+ }
850
+
851
+ /**
852
+ * 判断某行能否比较(不可比较时返回原因,供菜单与双击共用)。
853
+ * @author ddj 2026年11月25号
854
+ * @param entry 目标条目
855
+ * @returns 不可用原因;空串表示可比较
856
+ */
857
+ const compareBlock = (entry) => compareBlockOf(
858
+ entry,
859
+ Boolean(s.busy || s.aiBusy),
860
+ Boolean(entry && isDirOf(entry.path, entryKind.dirs, entryKind.kinds)),
861
+ )
862
+
863
+ /**
864
+ * 打开基线差异:任何打不开的情况都给一句可读提示,不做静默失败。
865
+ *
866
+ * 回调本身不带回执,所以这里补一次「窗口有没有出现」的兜底检查:
867
+ * 接了 onCompare 但差异窗口没渲染出来时,用户至少能看到原因,而不是「点了没反应」。
868
+ * @author ddj 2026年11月25号
869
+ * @param path 目标路径
870
+ * @returns void
871
+ */
872
+ const openCompare = (path) => {
873
+ const entry = s.sections.flatMap((section) => section.entries).find((item) => item.path === path) ?? null
874
+ const block = compareBlock(entry)
875
+ if (block) { notify?.(block); return }
876
+ if (!props.onCompare) { notify?.('差异视图未接入,无法打开比较'); return }
877
+
878
+ props.onCompare(path)
879
+ verifyCompareWindow()
880
+ }
881
+
882
+ /**
883
+ * 兜底核对差异窗口是否真的出现(只在本机浏览器里跑,测试环境直接跳过)。
884
+ * @author ddj 2026年11月25号
885
+ * @returns void
886
+ */
887
+ const verifyCompareWindow = () => {
888
+ if (typeof document === 'undefined' || typeof window === 'undefined' || !window.setTimeout) return
889
+
890
+ window.setTimeout(() => {
891
+ if (document.querySelector('.edrv-svndiff')) return
892
+ notify?.('差异窗口没有出现:文件可能没有文本基线,或差异视图被遮挡')
893
+ }, 2500)
894
+ }
895
+
896
+ /**
897
+ * 双击或回车:可比较才打开基线差异,其余情况说明原因(不弹空窗口)。
898
+ * @author ddj 2026年11月24号 / 2026年11月25号
899
+ * @param event 双击/键盘事件
900
+ * @param entry 目标条目
901
+ * @returns void
902
+ */
903
+ const diffRow = (event, entry) => {
904
+ if (isPickBox(event && event.target)) return
905
+
906
+ openCompare(entry.path)
907
+ }
908
+
909
+ /**
910
+ * 行点击:Shift 把整段勾选翻面,Ctrl 只切换选中。
911
+ * @author ddj 2026年11月24号
912
+ * @param event 点击事件
913
+ * @param path 目标路径
914
+ * @returns void
915
+ */
916
+ const pickRow = (event, path) => {
917
+ if (!event.shiftKey) { rowPick.choose(event, path); return }
918
+
919
+ // 勾选框自己在 click 之后会切状态:先掐掉原生切换,整段值统一由翻面决定
920
+ event.preventDefault()
921
+ const next = nextRowPick(rowPick.pick, s.rowOrder, path, 'range')
922
+ rowPick.setPick(next)
923
+ s.setPickChecked(next.selected, rangeCheckValueOf(s.checked, path))
924
+ }
925
+
926
+ /**
927
+ * 行键盘:Space 批量勾选、Ctrl+A 全选、↑↓ 移动、Enter 看差异;菜单键仍走右键菜单。
928
+ * @author ddj 2026年11月24号
929
+ * @param event 键盘事件
930
+ * @param entry 目标条目
931
+ * @returns void
932
+ */
933
+ const rowKeyDown = (event, entry) => {
934
+ openMenuByKey(event, entry, menuOpen)
935
+ if (event.defaultPrevented) return
936
+
937
+ // 焦点在勾选框上时 Space 由原生控件处理(切这一行),方向键仍要照常移动
938
+ if (event.key === ' ' && isPickBox(event.target)) return
939
+
940
+ const picked = rowPick.pick.selected.length ? rowPick.pick.selected : [entry.path]
941
+ if (event.key === ' ') {
942
+ event.preventDefault()
943
+ s.setPickChecked(picked, batchCheckValueOf(s.checked, picked))
944
+ return
945
+ }
946
+ if (event.key === 'a' && (event.ctrlKey || event.metaKey)) { event.preventDefault(); rowPick.selectAll(); return }
947
+ if (event.key === 'Enter') { diffRow(event, entry); return }
948
+ if (event.key !== 'ArrowDown' && event.key !== 'ArrowUp') return
949
+
950
+ event.preventDefault()
951
+ const next = rowPick.move(event.key === 'ArrowDown' ? 1 : -1, event.shiftKey)
952
+ focusRow(next.selected[next.selected.length - 1])
953
+ }
954
+
955
+ /**
956
+ * 打开行菜单:批量动作的作用域是右键瞬间的选中。
957
+ * @author ddj 2026年11月21号 / 2026年11月24号
958
+ * @param event 右键事件
959
+ * @param kind 目标种类
960
+ * @param entry 行条目
961
+ * @param node 文本框
962
+ * @returns void
963
+ */
964
+ const menuOpen = (event, kind, entry, node) => {
965
+ context.open(event, kind, entry, node, pickPathsOf(rowPick.pick.selected, rowPick.choose, entry))
966
+ }
967
+
742
968
  const view = {
743
- ...s, onClose, notify, selection: rowPick.selected, pickRow: rowPick.choose,
969
+ ...s, onClose, notify, selection: rowPick.pick.selected, pickRow, diffRow, openCompare, rowKeyDown, registerRow,
744
970
  dirs: entryKind.dirs, kinds: entryKind.kinds,
745
- menu: context.menu,
746
- menuOpen: (event, kind, entry, node) => context.open(event, kind, entry, node, pickPathsOf(rowPick, entry)),
971
+ menu: context.menu, menuOpen,
747
972
  onCompare: props.onCompare, onShowLog: props.onShowLog,
748
973
  onOpenFile: props.onOpenFile, onOpenParent: props.onOpenParent,
749
974
  }
@@ -264,6 +264,69 @@ export interface RowPick {
264
264
  anchor: string | null
265
265
  }
266
266
 
267
+ /**
268
+ * Shift 点击时整段要写入的勾选值:只看目标行当前状态,取反。
269
+ * 锚点不参与取值,否则「整段翻面」会退化成逐行取反。
270
+ * @author ddj 2026年11月24号
271
+ * @param checked 勾选路径集合
272
+ * @param path 目标行路径
273
+ * @returns true = 整段勾上;false = 整段取消
274
+ */
275
+ export function rangeCheckValueOf(checked: ReadonlySet<string>, path: string): boolean {
276
+ return !checked.has(path)
277
+ }
278
+
279
+ /**
280
+ * 批量勾选要写入的值:全已勾则整批取消,否则整批勾上。
281
+ * @author ddj 2026年11月24号
282
+ * @param checked 勾选路径集合
283
+ * @param paths 作用范围(空范围返回 true,调用方按无操作处理)
284
+ * @returns true = 勾上;false = 取消
285
+ */
286
+ export function batchCheckValueOf(checked: ReadonlySet<string>, paths: readonly string[]): boolean {
287
+ if (!paths.length) return true
288
+
289
+ return !paths.every((path) => checked.has(path))
290
+ }
291
+
292
+ /**
293
+ * 方向键移动选中:单步移动,或从锚点扩选。
294
+ * @author ddj 2026年11月24号
295
+ * @param pick 当前选中
296
+ * @param order 显示顺序
297
+ * @param step -1 向上 / 1 向下
298
+ * @param extend 是否扩选(Shift + 方向键)
299
+ * @returns 新的选中状态(顺序恒按显示顺序)
300
+ */
301
+ export function moveRowPick(pick: RowPick, order: readonly string[], step: number, extend: boolean): RowPick {
302
+ if (!order.length) return pick
303
+
304
+ const last = pick.selected[pick.selected.length - 1]
305
+ const from = last ? order.indexOf(last) : -1
306
+ const base = from >= 0 ? from : (step > 0 ? -1 : order.length)
307
+ const path = order[Math.min(order.length - 1, Math.max(0, base + step))]
308
+ if (!path) return pick
309
+
310
+ if (extend) return nextRowPick({ selected: pick.selected, anchor: pick.anchor ?? last ?? path }, order, path, 'range')
311
+
312
+ return { selected: [path], anchor: path }
313
+ }
314
+
315
+ /**
316
+ * 清单重载后清理选中:丢掉已消失的路径,锚点不在清单里时一并清空。
317
+ * @author ddj 2026年11月24号
318
+ * @param pick 当前选中
319
+ * @param order 显示顺序
320
+ * @returns 新的选中状态;无需变更时返回原对象(避免多余渲染)
321
+ */
322
+ export function pruneRowPick(pick: RowPick, order: readonly string[]): RowPick {
323
+ const selected = pick.selected.filter((path) => order.includes(path))
324
+ const anchor = pick.anchor && order.includes(pick.anchor) ? pick.anchor : null
325
+ if (selected.length === pick.selected.length && anchor === pick.anchor) return pick
326
+
327
+ return { selected, anchor }
328
+ }
329
+
267
330
  /**
268
331
  * 行选中变更:单击选中、Ctrl 切换、Shift 从锚点取范围。
269
332
  * @author ddj 2026年11月21号