dsh-vscode-mode 0.27.0 → 0.27.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-vscode-mode",
3
- "version": "0.27.0",
3
+ "version": "0.27.2",
4
4
  "description": "DSH 上的类 VSCode 编码体验:Monaco 编辑器(文件页签/QuickOpen/状态栏,可驻 DSH 0.1.5+ 官方右侧 Sidebar 与对话同屏)+ 命令栏(Ctrl+Shift+P)与可扩展指令系统 + VS Code 兼容代码片段(.code-snippets 全局/项目,IntelliSense 展开)+ Agent 编辑差异审查(整文件差异/采纳/拒绝/归档/回滚)+ SVN 集成(侧栏变更面板/日志弹窗/并排差异)+ 语言服务器(LSP)智能(跳转定义/引用/hover/大纲 + VSIX 扩展市场安装),状态持久化到工作区旁车,界面状态(页签/光标/侧栏/编辑 Tab/导航历史)镜像到 DSH home 跨重启恢复",
5
5
  "icon": "assets/icon.svg",
6
6
  "keywords": [
@@ -7,6 +7,22 @@
7
7
  * 作者 ddj 2026年10月27号
8
8
  */
9
9
  import { sessionErrorText } from './sessionError.js'
10
+ import type { ReviewDetail } from '../shared/review.js'
11
+
12
+ /**
13
+ * @public
14
+ * @author ddj 2026年11月5号
15
+ * @description 仅收敛已成功生成的空文本净差异;不把定位失败、二进制或生成异常当作已解决。
16
+ * @param detail 已加载的权威详情
17
+ * @returns 是否可以无写盘结案
18
+ */
19
+ export function emptyTextReview(detail: ReviewDetail | null): boolean {
20
+ if (!detail || detail.item.decision !== 'pending' || !detail.item.current) return false
21
+ if (detail.capability.keep !== true || detail.diff.kind !== 'text') return false
22
+
23
+ return detail.diff.hunks.length === 0 && detail.blocks.length === 0
24
+ && detail.item.added === 0 && detail.item.deleted === 0
25
+ }
10
26
 
11
27
  /** 官方差异栏输入:全部来自 EditorView dock 快照,不读取磁盘或 RPC。 */
12
28
  export interface ReviewBarInput {
@@ -26,6 +26,31 @@ export function diffPathKey(path: string): string {
26
26
  return pathKeyFor(path, false)
27
27
  }
28
28
 
29
+ /**
30
+ * @public
31
+ * @author ddj 2026年11月5号
32
+ * @description: 解析编辑器权威审查路径,累计待审优先,详情与工具栏共用同一来源。
33
+ * @param path 当前文件
34
+ * @param page 权威审查元数据
35
+ * @param sameFile 工作区路径比较器,缺省按完整路径键比较
36
+ * @returns 后端审查路径;未接管时返回 null
37
+ */
38
+ export function reviewPathOf(
39
+ path: string | null, page: ReviewPage | null,
40
+ sameFile: (left: string, right: string) => boolean = (left, right) => diffPathKey(left) === diffPathKey(right),
41
+ ): string | null {
42
+ if (!path || !page) return null
43
+
44
+ for (const item of page.items) {
45
+ if (!item.id.startsWith(PENDING_PREFIX)) continue
46
+ const currentPath = item.currentPath || item.path
47
+ const identity = item.id.slice(PENDING_PREFIX.length)
48
+ if (sameFile(currentPath, path) || sameFile(identity, path)) return currentPath
49
+ }
50
+
51
+ return page.overview?.coveredPaths.find((candidate) => sameFile(candidate, path)) ?? null
52
+ }
53
+
29
54
  /** @public @author ddj 2026年10月26号 @param path Current editor file. @param page Authoritative metadata, including decided paths. @returns Whether legacy actions must be hidden for this file. */
30
55
  export function officialPath(path: string, page: ReviewPage | null): boolean {
31
56
  const key = diffPathKey(path)
@@ -90,10 +115,11 @@ function pendingRowsOf(page: ReviewPage | null): { rows: DiffFile[]; covered: Se
90
115
  }
91
116
 
92
117
  /** @public @author ddj 2026年10月26号 @param records Tool-call history. @param page Official file navigation, never only its first 50 rows. @returns Pending first, then official; legacy paths remain explicitly labelled. */
93
- export function diffSummary(records: RecordView[], page: ReviewPage | null): DiffSummary {
118
+ export function diffSummary(records: (RecordView & { archived?: boolean })[], page: ReviewPage | null): DiffSummary {
94
119
  const pending = pendingRowsOf(page)
95
120
  // 同一路径只留一个权威:待审接管后,官方汇总行与历史留痕行都让位。
96
- const legacy = summarize(records.filter((record) => !pending.covered.has(diffPathKey(record.path)) && !officialPath(record.path, page)))
121
+ const legacy = summarize(records.filter((record) => record.archived !== true
122
+ && !pending.covered.has(diffPathKey(record.path)) && !officialPath(record.path, page)))
97
123
  const files: DiffFile[] = [...pending.rows]
98
124
  for (const file of page?.overview?.files ?? []) {
99
125
  if (pending.covered.has(diffPathKey(file.path))) continue
@@ -3,6 +3,7 @@ import React from 'react'
3
3
  import { createViewKeeper, type ViewEditor } from '../state/editorViewState.js'
4
4
  import type { Group } from '../state/editorLayout.js'
5
5
  import type { TabLike } from '../tabActions.js'
6
+ import { watchTabReveal } from './tabReveal.js'
6
7
 
7
8
  export interface PaneProps {
8
9
  group: Group
@@ -22,11 +23,39 @@ export interface PaneProps {
22
23
  tabsRef?: React.Ref<HTMLDivElement>
23
24
  /** @public @author ddj 2026年10月20号 Read-only plan preview owns this pane body, so no disk tab paints as active. */
24
25
  suppressActive?: boolean
26
+ /** @public @author ddj 2026年11月05号 Selected virtual preview address, when this strip owns preview tabs. */
27
+ previewActive?: string | null
28
+ }
29
+
30
+ /**
31
+ * Keep each group's selected tab visible while preserving the workbench wheel ref.
32
+ * @private @author ddj 2026年11月05号
33
+ * @param props Group selection and shared strip reference.
34
+ * @returns Stable callback ref for this pane's strip.
35
+ */
36
+ function useTabReveal(props: PaneProps): React.RefCallback<HTMLDivElement> {
37
+ const hostRef = React.useRef<HTMLDivElement | null>(null)
38
+ /** @private @author ddj 2026年11月05号 @param node Committed strip, or null on detach. Synchronize both owners. */
39
+ function bindStrip(node: HTMLDivElement | null): void {
40
+ hostRef.current = node
41
+ if (typeof props.tabsRef === 'function') props.tabsRef(node)
42
+ else if (props.tabsRef) (props.tabsRef as React.MutableRefObject<HTMLDivElement | null>).current = node
43
+ }
44
+ const stripRef = React.useCallback(bindStrip, [props.tabsRef])
45
+ // Include the rendered order/labels: closing, pinning or dirty marks can shift a same-path selection.
46
+ const tabShape = JSON.stringify(props.group.tabs.map(tab => [tab.path, tab.pinned, props.dirty[tab.path]]))
47
+ /** @private @author ddj 2026年11月05号 @returns Geometry observer cleanup for this committed selection. */
48
+ function observeStrip(): (() => void) | undefined {
49
+ if (hostRef.current) return watchTabReveal(hostRef.current)
50
+ }
51
+ React.useLayoutEffect(observeStrip, [props.group.active, props.focused, props.suppressActive, props.previewActive, tabShape, props.tabsRef])
52
+ return stripRef
25
53
  }
26
54
 
27
55
  /** @public @author ddj 2026年10月14号 @param props Group callbacks and file view. @returns Accessible tab strip and drop target. */
28
56
  export function EditorPane(props: PaneProps): React.ReactElement {
29
57
  const { group } = props
58
+ const stripRef = useTabReveal(props)
30
59
  // 计划预览接管本组正文时,磁盘页签只保留可点击性,不再画选中态,避免同一可见区域出现两条下划线。
31
60
  const suppressActive = props.suppressActive === true
32
61
  /** @private @author ddj 2026年10月20号 @param tab File record. @returns Draggable tab with isolated close control. */
@@ -67,7 +96,7 @@ export function EditorPane(props: PaneProps): React.ReactElement {
67
96
  }
68
97
  return React.createElement('section', { className: 'edrv-group' + (props.focused ? ' edrv-group-focused' : ''), 'data-edrv-group': group.id, onPointerDown: focusEmpty },
69
98
  React.createElement('div', { className: 'edrv-tabs-row' },
70
- React.createElement('div', { className: 'edrv-tabs', role: 'tablist', 'data-edrv-group-tabs': group.id, ref: props.tabsRef }, group.tabs.map(renderTab), props.extras),
99
+ React.createElement('div', { className: 'edrv-tabs', role: 'tablist', 'data-edrv-group-tabs': group.id, ref: stripRef }, group.tabs.map(renderTab), props.extras),
71
100
  props.tools),
72
101
  React.createElement('div', { className: 'edrv-group-body', role: 'tabpanel' }, props.children))
73
102
  }
@@ -29,7 +29,7 @@ import { toastDom } from '../externalOpen.js'
29
29
  import { ReviewAllConfirm } from './ReviewAllConfirm.js'
30
30
  import { reviewRegions } from '../../shared/reviewRegions.js'
31
31
  import { PENDING_PREFIX } from '../../shared/pendingReview.js'
32
- import { coveredPathKeys, diffPathKey, diffSummary } from '../state/diffSummary.js'
32
+ import { coveredPathKeys, diffPathKey, diffSummary, reviewPathOf } from '../state/diffSummary.js'
33
33
  import { emitFileChanged, emitRefresh } from '../events.js'
34
34
  import { langOf, loadMonaco, snippetLanguageOf } from '../monaco/loader.js'
35
35
  import { bindEditActions, runEditAction } from '../monaco/editActions.js'
@@ -136,7 +136,7 @@ import { clampToolbarPosition, loadToolbarPosition, saveToolbarPosition } from '
136
136
  import { editorModelPathOf } from '../dap/modelPath.js'
137
137
  import { dapTrace } from '../dap/trace.js'
138
138
  import { isSessionMissingError, sessionErrorText, sessionMissingDetail, sessionMissingTitle } from '../sessionError.js'
139
- import { officialDownView, SESSION_DOWN_NOTICE, SIDECAR_KEEP_DONE } from '../reviewBar.js'
139
+ import { emptyTextReview, officialDownView, SESSION_DOWN_NOTICE, SIDECAR_KEEP_DONE } from '../reviewBar.js'
140
140
 
141
141
  /** 官方差异读取失败前缀:仅用于清理同源陈旧错误,不吞并保存类错误。@author ddj 2026年10月27号 */
142
142
  const REVIEW_LOAD_ERROR = '官方差异读取失败:'
@@ -595,14 +595,9 @@ export function EditorView(props) {
595
595
  const controller = new AbortController()
596
596
  // 待审条目也走同一条行内差异通道:它由累计基线投影而来,形状与官方条目一致,
597
597
  // 因此编辑器里天然就能画行内差异与 Keep/Undo 药丸,不必另开一个窄面板。
598
- const pendingPath = (review.page?.items ?? [])
599
- .filter((item) => String(item.id).startsWith(PENDING_PREFIX))
600
- .map((item) => item.currentPath || item.path)
601
- .find((path) => sameFile(path, active))
602
- const coveredPath = review.page?.overview?.coveredPaths.find((path) => sameFile(path, active))
603
- const reviewPath = coveredPath ?? pendingPath
604
- dbg(sessionId, `[DEBUG reviewPath] active=${active ?? '(null)'} covered=${coveredPath ?? '(none)'}`
605
- + ` pending=${pendingPath ?? '(none)'} coveredCount=${review.page?.overview?.coveredPaths.length ?? -1}`
598
+ const reviewPath = reviewPathOf(active, review.page, sameFile)
599
+ dbg(sessionId, `[DEBUG reviewPath] active=${active ?? '(null)'} resolved=${reviewPath ?? '(none)'}`
600
+ + ` coveredCount=${review.page?.overview?.coveredPaths.length ?? -1}`
606
601
  + ` items=${review.page?.items?.length ?? -1} overview=${review.page?.overview ? 1 : 0}`)
607
602
  if (!active || !reviewPath) {
608
603
  setOfficialDetail(null)
@@ -696,9 +691,11 @@ export function EditorView(props) {
696
691
  const decideRegions = React.useMemo(() => [...pendingRegions, ...staleRegions], [pendingRegions, staleRegions])
697
692
  // 记录的改动已全部不在当前文件中时没有可见差异可审:自动结案,不再让「改动已失效」占用差异栏。
698
693
  React.useEffect(() => {
699
- if (!officialDetail || contentReady !== true || batchBusyRef.current) return
700
- if (pendingRegions.length > 0 || staleRegions.length === 0) return
701
- if (noBlocks || officialDetail.capability?.keep !== true) return
694
+ if (!officialDetail || batchBusyRef.current) return
695
+ // 空净差异只依赖权威快照,不依赖编辑器磁盘加载;定位失效仍须等待当前内容就绪。
696
+ const emptyText = emptyTextReview(officialDetail)
697
+ if (!emptyText && (contentReady !== true || pendingRegions.length > 0 || staleRegions.length === 0 || noBlocks)) return
698
+ if (officialDetail.capability?.keep !== true) return
702
699
  if (dirtyRef.current[active]) return
703
700
 
704
701
  void settleInvisibleRecord(officialDetail)
@@ -2137,19 +2134,6 @@ export function EditorView(props) {
2137
2134
  }
2138
2135
  }, [sessionId])
2139
2136
 
2140
- // 活动页签滚动可见(页签栏溢出时键盘切换/打开文件后把当前页签带回视野):
2141
- // 只调整页签栏自身 scrollLeft,不触发页面滚动。
2142
- React.useEffect(() => {
2143
- const host = tabsHostRef.current
2144
- if (!host) return
2145
- const el = host.querySelector?.('.edrv-tab-active')
2146
- if (!el) return
2147
- const left = el.offsetLeft
2148
- const right = left + el.offsetWidth
2149
- if (left < host.scrollLeft) host.scrollLeft = left
2150
- else if (right > host.scrollLeft + host.clientWidth) host.scrollLeft = right - host.clientWidth
2151
- }, [active, planActive, planTabs.length, tabs.length, rowOwner])
2152
-
2153
2137
  // 页签栏滚轮横向滚动(需求 3):页签栏溢出时,鼠标滚轮(含触控板纵向手势)横滚页签栏,
2154
2138
  // 不溢出时不接管(保持页面垂直滚动);Shift+滚轮交由浏览器原生横滚。详见 horizontalWheel.ts。
2155
2139
  React.useEffect(() => attachHorizontalWheel(tabsHostRef.current), [rowOwner])
@@ -3552,7 +3536,7 @@ export function EditorView(props) {
3552
3536
  const allPending = React.useMemo(() => {
3553
3537
  const out = []
3554
3538
  for (const rec of Object.values(records)) {
3555
- if (rec.superseded === true || coveredPaths.has(diffPathKey(rec.path))) continue
3539
+ if (rec.archived === true || rec.superseded === true || coveredPaths.has(diffPathKey(rec.path))) continue
3556
3540
  const perHunk = Array.isArray(rec.decisions?.perHunk) ? rec.decisions.perHunk : []
3557
3541
  const hunks = Array.isArray(rec.hunks) ? rec.hunks : []
3558
3542
  for (let i = 0; i < hunks.length; i++) {
@@ -4637,7 +4621,7 @@ export function EditorView(props) {
4637
4621
  const chrome = !floating && id === rowOwner
4638
4622
  // 计划预览占用的正文只会在焦点组里;承载页签行的组同时收起磁盘选中态,保证整屏只有计划页签一条下划线。
4639
4623
  const hideDiskActive = Boolean(planActive) && (chrome || focused)
4640
- return React.createElement(EditorPane, { key: id, group, focused, dirty: dirtyMap, suppressActive: hideDiskActive, tabsRef: chrome ? tabsHostRef : undefined, extras: chrome ? planTabExtras : undefined, tools: chrome ? rowTools : undefined, onSelect: selectGroup, onClose: closeTab, onMenu: paneMenu, onDrag: dragTab, consumeClick: consumeDrag },
4624
+ return React.createElement(EditorPane, { key: id, group, focused, dirty: dirtyMap, suppressActive: hideDiskActive, previewActive: chrome ? planActive : undefined, tabsRef: chrome ? tabsHostRef : undefined, extras: chrome ? planTabExtras : undefined, tools: chrome ? rowTools : undefined, onSelect: selectGroup, onClose: closeTab, onMenu: paneMenu, onDrag: dragTab, consumeClick: consumeDrag },
4641
4625
  focused ? React.createElement('div', { className: 'edrv-full-slot', ref: mountFull }) : React.createElement(React.Fragment, null,
4642
4626
  React.createElement(GroupPathbar, { path: group.active, onFocus: () => selectGroup(id) }),
4643
4627
  React.createElement(PassiveEditor, { key: JSON.stringify([scope, sessionId, group.active]), path: group.active, groupId: id, mount: passiveMount })))
@@ -4962,7 +4946,7 @@ export function EditorView(props) {
4962
4946
  * @author ddj 2026年09月29号
4963
4947
  * @returns 含布局及操作回调的差异快照
4964
4948
  */
4965
- const officialFile = review.page?.overview?.coveredPaths.find((path) => sameFile(path, active))
4949
+ const officialFile = reviewPathOf(active, review.page, sameFile)
4966
4950
  // 官方通道自身的失败(list 失败 / 缺 overview)只影响官方栏,不能混进保存类错误。
4967
4951
  const officialDown = officialFile ? null : officialDownView(review.error)
4968
4952
  const rawReviewError = review.error || error
@@ -0,0 +1,64 @@
1
+ /** Group-local active tab visibility. @author ddj 2026年11月05号 */
2
+
3
+ /**
4
+ * Reveal the selected tab without moving the page or keyboard focus.
5
+ * @public @author ddj 2026年11月05号
6
+ * @param host Tab strip belonging to one editor group.
7
+ * @sideEffects Updates only the strip's horizontal scroll position.
8
+ */
9
+ export function revealTab(host: HTMLDivElement): void {
10
+ const tab = host.querySelector<HTMLElement>('.edrv-tab-active')
11
+ if (!tab || host.clientWidth <= 0) return
12
+
13
+ // DOM rectangles share viewport coordinates even when offsetParent is outside the strip.
14
+ const stripRect = host.getBoundingClientRect()
15
+ const tabRect = tab.getBoundingClientRect()
16
+ const left = stripRect.left + host.clientLeft
17
+ const right = left + host.clientWidth
18
+ let delta = 0
19
+ if (tabRect.width > host.clientWidth || tabRect.left < left) delta = tabRect.left - left
20
+ else if (tabRect.right > right) delta = tabRect.right - right
21
+ if (Math.abs(delta) < 0.5) return
22
+
23
+ const maximum = Math.max(0, host.scrollWidth - host.clientWidth)
24
+ const next = Math.max(0, Math.min(maximum, host.scrollLeft + delta))
25
+ if (next !== host.scrollLeft) host.scrollLeft = next
26
+ }
27
+
28
+ /**
29
+ * Observe geometry changes, not scrolling, so manual tab browsing remains possible.
30
+ * @public @author ddj 2026年11月05号
31
+ * @param host Group tab strip after its DOM commit.
32
+ * @returns Cleanup cancelling pending work and disconnecting geometry observation.
33
+ */
34
+ export function watchTabReveal(host: HTMLDivElement): () => void {
35
+ const view = host.ownerDocument.defaultView
36
+ let frame: number | undefined
37
+ let disposed = false
38
+ /** @private @author ddj 2026年11月05号 Reveal the latest selected tab after layout. */
39
+ function measure(): void {
40
+ frame = undefined
41
+ if (!disposed) revealTab(host)
42
+ }
43
+ /** @private @author ddj 2026年11月05号 Coalesce resize notifications into one layout read. */
44
+ function schedule(): void {
45
+ if (disposed || frame !== undefined || !view) return
46
+ frame = view.requestAnimationFrame(measure)
47
+ }
48
+
49
+ revealTab(host)
50
+ schedule()
51
+ const observer = typeof ResizeObserver === 'function' ? new ResizeObserver(schedule) : undefined
52
+ observer?.observe(host)
53
+ const tab = host.querySelector<HTMLElement>('.edrv-tab-active')
54
+ if (tab) observer?.observe(tab)
55
+
56
+ /** @private @author ddj 2026年11月05号 Cancel work owned by the previous selection or pane. */
57
+ function dispose(): void {
58
+ disposed = true
59
+ observer?.disconnect()
60
+ if (frame !== undefined) view?.cancelAnimationFrame(frame)
61
+ frame = undefined
62
+ }
63
+ return dispose
64
+ }
@@ -4,6 +4,7 @@
4
4
  * @author ddj 2026年10月29号
5
5
  */
6
6
  import type { PendingEarlier, PendingLineage } from '../shared/pendingReview.js'
7
+ import { logicalLines } from '../shared/lineEndings.js'
7
8
 
8
9
  /** 内存态条目:比展示投影多保存两侧全文。 */
9
10
  export interface PendingEntry {
@@ -50,12 +51,17 @@ export function sameEntryText(left: string, right: string): boolean {
50
51
 
51
52
  /**
52
53
  * @author ddj 2026年10月29号
53
- * @description: 净零判定:基线等于当前内容即为已解决,但条目仍留在列表等待移除。
54
+ * @description: 净零判定与文本差异生成器保持逻辑行口径一致;只忽略 BOM 和换行编码,不改存储原文。
54
55
  * @param entry 待审条目
55
56
  * @returns 是否已无净差异
56
57
  */
57
58
  export function isSettled(entry: PendingEntry): boolean {
58
- return sameEntryText(entry.oldText, entry.newText)
59
+ if (sameEntryText(entry.oldText, entry.newText)) return true
60
+
61
+ const baselineLines = logicalLines(entry.oldText)
62
+ const currentLines = logicalLines(entry.newText)
63
+ return baselineLines.length === currentLines.length
64
+ && baselineLines.every((line, index) => line === currentLines[index])
59
65
  }
60
66
 
61
67
  /**