dsh-remote-vs 0.27.0 → 0.29.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.
- package/README.en.md +159 -23
- package/README.md +123 -23
- package/lib/client.js +6906 -6619
- package/lib/index.js +2014 -67
- package/lib/types/changes/recorder.d.ts +119 -2
- package/lib/types/client/CodeEditor.d.ts +15 -0
- package/lib/types/client/HostsView.d.ts +139 -2
- package/lib/types/client/api.d.ts +42 -2
- package/lib/types/client/changes/apply-failure.d.ts +41 -0
- package/lib/types/client/changes/block-confirm.d.ts +97 -0
- package/lib/types/client/changes/diff-outcome.d.ts +56 -0
- package/lib/types/client/changes/freshness.d.ts +51 -0
- package/lib/types/client/changes/model.d.ts +19 -1
- package/lib/types/client/changes/session-diff.d.ts +100 -0
- package/lib/types/client/changes/staleness.d.ts +98 -0
- package/lib/types/client/changes/turn-reverted.d.ts +82 -0
- package/lib/types/client/changes/turn-view.d.ts +131 -0
- package/lib/types/client/changes/undo-affordance.d.ts +44 -10
- package/lib/types/client/changes/undo-target.d.ts +12 -0
- package/lib/types/client/connection.d.ts +28 -1
- package/lib/types/client/i18n.d.ts +1 -1
- package/lib/types/client/store.d.ts +91 -1
- package/lib/types/client/vsc/change-marks.d.ts +21 -0
- package/lib/types/forward.d.ts +11 -1
- package/lib/types/pool.d.ts +95 -1
- package/lib/types/protocol.d.ts +221 -1
- package/lib/types/proxy.d.ts +136 -0
- package/lib/types/store.d.ts +81 -1
- package/lib/types/tools.d.ts +3 -0
- package/package.json +1 -1
- package/src/changes/recorder.ts +851 -8
- package/src/client/CodeEditor.tsx +43 -3
- package/src/client/ConnectionStatus.tsx +19 -5
- package/src/client/EditorPane.tsx +64 -7
- package/src/client/HostsView.tsx +552 -11
- package/src/client/PortsView.tsx +16 -0
- package/src/client/SettingsHosts.tsx +132 -6
- package/src/client/api.ts +60 -3
- package/src/client/changes/ChangesDock.tsx +539 -54
- package/src/client/changes/apply-failure.ts +73 -0
- package/src/client/changes/block-confirm.ts +180 -0
- package/src/client/changes/changes.css +45 -0
- package/src/client/changes/diff-outcome.ts +97 -0
- package/src/client/changes/freshness.ts +68 -0
- package/src/client/changes/model.ts +56 -1
- package/src/client/changes/session-diff.ts +187 -0
- package/src/client/changes/staleness.ts +148 -0
- package/src/client/changes/turn-reverted.ts +254 -0
- package/src/client/changes/turn-view.ts +195 -0
- package/src/client/changes/undo-affordance.ts +295 -63
- package/src/client/changes/undo-target.ts +12 -0
- package/src/client/connection.ts +76 -2
- package/src/client/i18n.ts +204 -4
- package/src/client/scm/DiffView.tsx +32 -13
- package/src/client/store.tsx +392 -16
- package/src/client/vsc/change-marks.ts +21 -0
- package/src/client/vsc/preview-document.tsx +4 -1
- package/src/client/vsc/vsc.css +6747 -6509
- package/src/forward.ts +38 -2
- package/src/importers.ts +125 -13
- package/src/keygen.ts +8 -1
- package/src/pool.ts +422 -27
- package/src/protocol.ts +229 -1
- package/src/proxy.ts +673 -0
- package/src/routes.ts +93 -14
- package/src/store.ts +335 -0
- package/src/tools.ts +47 -2
|
@@ -153,7 +153,13 @@ import {
|
|
|
153
153
|
} from './vsc/change-marks.ts'
|
|
154
154
|
import { blameExtension, blameViewportReporter } from './vsc/blame.ts'
|
|
155
155
|
import type { BlameLine } from './blame-model.ts'
|
|
156
|
-
import {
|
|
156
|
+
import {
|
|
157
|
+
DEFAULT_CONFIRM_LABEL,
|
|
158
|
+
DEFAULT_CONFIRMED_LABEL,
|
|
159
|
+
DEFAULT_TRIGGER_LABEL,
|
|
160
|
+
DEFAULT_UNDO_LABEL,
|
|
161
|
+
undoAffordance,
|
|
162
|
+
} from './changes/undo-affordance.ts'
|
|
157
163
|
|
|
158
164
|
/**
|
|
159
165
|
* The editor surface is OPAQUE and scrolls in the editor's own palette
|
|
@@ -228,6 +234,21 @@ export const CodeEditor = forwardRef<CodeEditorHandle, {
|
|
|
228
234
|
onUndoChange?: (mark: ChangeMark) => void
|
|
229
235
|
/** 悬浮按钮的文案(由调用方按 `kind` 给出它的 i18n 说法)。 */
|
|
230
236
|
undoLabel?: (mark: ChangeMark) => string
|
|
237
|
+
/** 行尾那枚 `⋯` 的说明(title / aria-label,调用方传 i18n)。 */
|
|
238
|
+
undoTriggerLabel?: () => string
|
|
239
|
+
/**
|
|
240
|
+
* 悬浮栏的第二个动作:「确认保留」(块级本地笔记,见 `changes/block-confirm.ts`)。
|
|
241
|
+
*
|
|
242
|
+
* 不传 = 悬浮栏只有撤销一个动作(与没有这个功能时完全一致)。传了也只是把
|
|
243
|
+
* 读/切换交回去:存储、会话归属都在调用方那一侧,编辑器组件不持有这份状态,更
|
|
244
|
+
* 不会因为它写任何远端。
|
|
245
|
+
*/
|
|
246
|
+
blockConfirm?: {
|
|
247
|
+
isConfirmed: (mark: ChangeMark) => boolean
|
|
248
|
+
onToggle: (mark: ChangeMark) => void
|
|
249
|
+
label: (mark: ChangeMark) => string
|
|
250
|
+
pressedLabel?: (mark: ChangeMark) => string
|
|
251
|
+
}
|
|
231
252
|
/** 改动点跳转的目标行(1-based),配合 `revealHunkNonce` 重跳同一行。 */
|
|
232
253
|
revealHunkLine?: number
|
|
233
254
|
/** 改动点跳转的 nonce(同 `revealNonce` 的道理)。 */
|
|
@@ -412,6 +433,12 @@ export const CodeEditor = forwardRef<CodeEditorHandle, {
|
|
|
412
433
|
*/
|
|
413
434
|
const labelsRef = useRef(t)
|
|
414
435
|
const undoArmed = props.onUndoChange !== undefined
|
|
436
|
+
/**
|
|
437
|
+
* 「确认保留」是否可用也是**能力**的一部分:它随"这批标记有没有块标识"一起到达,
|
|
438
|
+
* 所以要进 `armed` 键 —— 否则先挂载、后拿到标记的编辑器永远不会重装扩展,第二个
|
|
439
|
+
* 按钮就再也不会出现。
|
|
440
|
+
*/
|
|
441
|
+
const confirmArmed = props.blockConfirm !== undefined
|
|
415
442
|
useEffect(() => {
|
|
416
443
|
const current = viewRef.current
|
|
417
444
|
if (current === undefined) return
|
|
@@ -421,7 +448,7 @@ export const CodeEditor = forwardRef<CodeEditorHandle, {
|
|
|
421
448
|
}
|
|
422
449
|
const set = props.changeSet
|
|
423
450
|
const marks = set !== undefined
|
|
424
|
-
const armed = `${marks ? 'm' : ''}${undoArmed ? 'u' : ''}`
|
|
451
|
+
const armed = `${marks ? 'm' : ''}${undoArmed ? 'u' : ''}${confirmArmed ? 'c' : ''}`
|
|
425
452
|
if (armed !== armedRef.current) {
|
|
426
453
|
armedRef.current = armed
|
|
427
454
|
// 重装扩展会重建字段,之前下发过的数据随之消失,必须再喂一次。
|
|
@@ -432,6 +459,19 @@ export const CodeEditor = forwardRef<CodeEditorHandle, {
|
|
|
432
459
|
? [undoAffordance({
|
|
433
460
|
onUndo: (mark) => { propsRef.current.onUndoChange?.(mark) },
|
|
434
461
|
label: (mark) => propsRef.current.undoLabel?.(mark) ?? DEFAULT_UNDO_LABEL,
|
|
462
|
+
triggerLabel: () => propsRef.current.undoTriggerLabel?.() ?? DEFAULT_TRIGGER_LABEL,
|
|
463
|
+
...(confirmArmed
|
|
464
|
+
? {
|
|
465
|
+
confirm: {
|
|
466
|
+
isConfirmed: (mark) => propsRef.current.blockConfirm?.isConfirmed(mark) === true,
|
|
467
|
+
onToggle: (mark) => { propsRef.current.blockConfirm?.onToggle(mark) },
|
|
468
|
+
label: (mark) => propsRef.current.blockConfirm?.label(mark) ?? DEFAULT_CONFIRM_LABEL,
|
|
469
|
+
pressedLabel: (mark) => propsRef.current.blockConfirm?.pressedLabel?.(mark)
|
|
470
|
+
?? propsRef.current.blockConfirm?.label(mark)
|
|
471
|
+
?? DEFAULT_CONFIRMED_LABEL,
|
|
472
|
+
},
|
|
473
|
+
}
|
|
474
|
+
: {}),
|
|
435
475
|
})]
|
|
436
476
|
: []),
|
|
437
477
|
]
|
|
@@ -449,7 +489,7 @@ export const CodeEditor = forwardRef<CodeEditorHandle, {
|
|
|
449
489
|
} catch {
|
|
450
490
|
// Disposed.
|
|
451
491
|
}
|
|
452
|
-
}, [props.changeSet, undoArmed, view, t])
|
|
492
|
+
}, [props.changeSet, undoArmed, confirmArmed, view, t])
|
|
453
493
|
|
|
454
494
|
/**
|
|
455
495
|
* Blame gutter: install/replace it when the pane hands over a new window.
|
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
AUTO_RETRY_MS,
|
|
20
20
|
connectionLabelKey,
|
|
21
21
|
consumeAutoRetry,
|
|
22
|
+
egressTitleLine,
|
|
22
23
|
markConnectionProbeOk,
|
|
23
24
|
useConnectionStatus,
|
|
24
25
|
type ConnectionView,
|
|
@@ -26,9 +27,18 @@ import {
|
|
|
26
27
|
import { useExplorer } from './store.tsx'
|
|
27
28
|
import { MiniSpinner } from './vsc/kit.tsx'
|
|
28
29
|
|
|
29
|
-
/**
|
|
30
|
-
|
|
30
|
+
/**
|
|
31
|
+
* Tooltip: alias, state, where the connection ACTUALLY goes (or would go), and
|
|
32
|
+
* the last failure (with its time) or last success.
|
|
33
|
+
*
|
|
34
|
+
* The egress line is the answer to "is this really going through the jump host?",
|
|
35
|
+
* which the settings panel cannot answer: it shows the SAVED decision, while a
|
|
36
|
+
* connection established before an edit keeps running on the old route until it
|
|
37
|
+
* is dropped.
|
|
38
|
+
*/
|
|
39
|
+
function titleOf(connection: ConnectionView, t: (key: string) => string, egress: string | undefined): string {
|
|
31
40
|
const parts = [`${connection.alias} · ${t(connectionLabelKey(connection.state))}`]
|
|
41
|
+
if (egress !== undefined) parts.push(egress)
|
|
32
42
|
if (connection.state === 'error') {
|
|
33
43
|
if (connection.errorAt !== undefined) {
|
|
34
44
|
parts.push(`${t('connection.errorAt')} ${new Date(connection.errorAt).toLocaleTimeString()}`)
|
|
@@ -107,11 +117,15 @@ export function ConnectionStatusChip(props: { compact?: boolean }): ReactNode {
|
|
|
107
117
|
if (alias === '' || connection === undefined) return null
|
|
108
118
|
const label = retrying ? t('connection.retrying') : t(connectionLabelKey(connection.state))
|
|
109
119
|
const className = `rvs-conn rvs-conn-${connection.state}${props.compact === true ? ' compact' : ''}${errored ? ' clickable' : ''}`
|
|
110
|
-
const
|
|
120
|
+
const egress = egressTitleLine(connection, t)
|
|
121
|
+
const title = titleOf(connection, t, egress)
|
|
122
|
+
// The tooltip is mouse-only, so the same line goes into the accessible name:
|
|
123
|
+
// a screen-reader user asks the same question the mouse user does.
|
|
124
|
+
const ariaLabel = egress === undefined ? label : `${label} · ${egress}`
|
|
111
125
|
if (!errored) {
|
|
112
126
|
// A healthy/idle read-out must not be a button whose click does nothing.
|
|
113
127
|
return (
|
|
114
|
-
<span className={className} title={title} role="status" aria-label={
|
|
128
|
+
<span className={className} title={title} role="status" aria-label={ariaLabel}>
|
|
115
129
|
<span className="rvs-conn-dot" aria-hidden="true" />
|
|
116
130
|
{props.compact !== true && <span className="rvs-conn-label">{label}</span>}
|
|
117
131
|
</span>
|
|
@@ -121,7 +135,7 @@ export function ConnectionStatusChip(props: { compact?: boolean }): ReactNode {
|
|
|
121
135
|
// dial can take the whole ready-timeout, and hiding the manual affordance for
|
|
122
136
|
// its duration is exactly when the user reaches for it.
|
|
123
137
|
return (
|
|
124
|
-
<button type="button" className={className} title={title} aria-label={
|
|
138
|
+
<button type="button" className={className} title={title} aria-label={ariaLabel} aria-busy={retrying} onClick={() => { void attempt() }}>
|
|
125
139
|
<span className="rvs-conn-dot" aria-hidden="true" />
|
|
126
140
|
{retrying && <MiniSpinner />}
|
|
127
141
|
{props.compact !== true && <span className="rvs-conn-label">{label}</span>}
|
|
@@ -29,6 +29,9 @@ import { sameLocalDir } from './composer.ts'
|
|
|
29
29
|
import { editorViewStateOf, pruneEditorViewStates, registerLiveEditor, rememberEditorViewState } from './live-editor.ts'
|
|
30
30
|
import { useRemoteChatTarget } from './use-remote-chat-target.ts'
|
|
31
31
|
import { useExplorer, gotoChange, markChangeStale, repoRelative, undoChange, type EditorTab } from './store.tsx'
|
|
32
|
+
import { blockIdForMark, isStoredBlockConfirmed, toggleStoredBlock, type ConfirmStorage } from './changes/block-confirm.ts'
|
|
33
|
+
import { changeOriginForTab } from './changes/undo-target.ts'
|
|
34
|
+
import type { ChangeMark } from './vsc/change-marks.ts'
|
|
32
35
|
import { DiffView } from './scm/DiffView.tsx'
|
|
33
36
|
import { loadBlame, loadFileHistory } from './scm/actions.ts'
|
|
34
37
|
import { isCommittedBlame, planBlameWindow, type BlameLine, type FileHistoryCommit } from './blame-model.ts'
|
|
@@ -88,12 +91,12 @@ function outlineAvailable(tab: EditorTab | undefined): tab is EditorTab {
|
|
|
88
91
|
const BLAME_PREF_KEY = 'dsh-remote-vs.editor.blame'
|
|
89
92
|
const EMPTY_BLAME: ReadonlyMap<number, BlameLine> = new Map()
|
|
90
93
|
|
|
91
|
-
/** Inline blame is
|
|
94
|
+
/** Inline blame is OFF by default; the user opts in and the choice survives a reload. */
|
|
92
95
|
function readBlamePreference(): boolean {
|
|
93
96
|
try {
|
|
94
|
-
return localStorage.getItem(BLAME_PREF_KEY)
|
|
97
|
+
return localStorage.getItem(BLAME_PREF_KEY) === '1'
|
|
95
98
|
} catch {
|
|
96
|
-
return
|
|
99
|
+
return false
|
|
97
100
|
}
|
|
98
101
|
}
|
|
99
102
|
|
|
@@ -1157,11 +1160,66 @@ export function EditorPane(props: { visible: boolean }): ReactNode {
|
|
|
1157
1160
|
*/
|
|
1158
1161
|
const canSwitchToEdit = activeTab !== undefined
|
|
1159
1162
|
&& activeTab.kind === 'diff'
|
|
1163
|
+
// 会话只读 diff 不开「切换为内容编辑」:它属于会话账本,编辑入口是面板左键
|
|
1164
|
+
// (会带着标记打开);这里再开一次只会打开一个没有标记的普通标签页。
|
|
1165
|
+
&& activeTab.sessionDiff === undefined
|
|
1160
1166
|
&& activeTab.ref === undefined
|
|
1161
1167
|
&& activeTab.diff !== undefined
|
|
1162
1168
|
&& !activeTab.diff.unsupported
|
|
1163
1169
|
&& !(activeTab.diff.newText === '' && activeTab.diff.oldText !== '')
|
|
1164
1170
|
const displayPath = activeTab?.fullPath ?? ''
|
|
1171
|
+
/**
|
|
1172
|
+
* 信息栏里那句"这一页是什么 diff"。
|
|
1173
|
+
*
|
|
1174
|
+
* 三种来源必须分得清:会话账本的只读比较、暂存区(只读)、某个提交(历史)。
|
|
1175
|
+
* 写成一串 if 而不是嵌套三元:三种情况各说各的,读起来不会串行。
|
|
1176
|
+
*/
|
|
1177
|
+
let diffScopeLabel = ''
|
|
1178
|
+
if (activeTab?.kind === 'diff') {
|
|
1179
|
+
if (activeTab.sessionDiff !== undefined) diffScopeLabel = t('changes.diffTabLabel')
|
|
1180
|
+
else if (activeTab.ref !== undefined) diffScopeLabel = `${t('scm.commitDiff')} ${activeTab.ref.slice(0, 7)}`
|
|
1181
|
+
else if (activeTab.staged) diffScopeLabel = t('scm.stagedReadonly')
|
|
1182
|
+
}
|
|
1183
|
+
/**
|
|
1184
|
+
* 编辑器悬浮栏的「确认保留」(块级本地笔记,见 `changes/block-confirm.ts`)。
|
|
1185
|
+
*
|
|
1186
|
+
* 三个前提缺一不可:这一页有改动标记、标记带着块标识(建标记时带了远端绝对路径)、
|
|
1187
|
+
* 以及这批标记有 provenance(会话归属 —— 笔记按会话存)。任何一个缺失就不提供这个
|
|
1188
|
+
* 动作,悬浮栏回到"只有撤销"。
|
|
1189
|
+
*
|
|
1190
|
+
* 读写都走 `localStorage`,**不发任何请求**:这是"我看到哪儿了"的记号,不是远端
|
|
1191
|
+
* 事实;状态变化不经过 React(编辑器在 React 之外点它),所以每次现读。
|
|
1192
|
+
*/
|
|
1193
|
+
const blockConfirm = (() => {
|
|
1194
|
+
const set = activeTab?.changeSet
|
|
1195
|
+
if (activeTab === undefined || set === undefined || set === null) return undefined
|
|
1196
|
+
const blocks = set.blocks
|
|
1197
|
+
const sessionId = changeOriginForTab(activeTab.id)?.sessionId
|
|
1198
|
+
if (blocks === undefined || sessionId === undefined || sessionId === '') return undefined
|
|
1199
|
+
const storage = (): ConfirmStorage | undefined => {
|
|
1200
|
+
try {
|
|
1201
|
+
return window.localStorage
|
|
1202
|
+
} catch {
|
|
1203
|
+
// 隐私模式 / 禁用存储:不提供这一级(而不是给一个点了不生效的按钮)。
|
|
1204
|
+
return undefined
|
|
1205
|
+
}
|
|
1206
|
+
}
|
|
1207
|
+
return {
|
|
1208
|
+
isConfirmed: (mark: ChangeMark): boolean => {
|
|
1209
|
+
const id = blockIdForMark(blocks, mark)
|
|
1210
|
+
const store = storage()
|
|
1211
|
+
return id === undefined || store === undefined ? false : isStoredBlockConfirmed(store, sessionId, id)
|
|
1212
|
+
},
|
|
1213
|
+
onToggle: (mark: ChangeMark): void => {
|
|
1214
|
+
const id = blockIdForMark(blocks, mark)
|
|
1215
|
+
const store = storage()
|
|
1216
|
+
if (id === undefined || store === undefined) return
|
|
1217
|
+
toggleStoredBlock(store, sessionId, id)
|
|
1218
|
+
},
|
|
1219
|
+
label: (): string => t('changes.confirmBlock'),
|
|
1220
|
+
pressedLabel: (): string => t('changes.confirmedBlock'),
|
|
1221
|
+
}
|
|
1222
|
+
})()
|
|
1165
1223
|
const language = isDiff
|
|
1166
1224
|
? 'Diff'
|
|
1167
1225
|
: activeTab?.image === true
|
|
@@ -1281,10 +1339,7 @@ export function EditorPane(props: { visible: boolean }): ReactNode {
|
|
|
1281
1339
|
/>
|
|
1282
1340
|
)}
|
|
1283
1341
|
{activeTab.kind === 'diff' && (
|
|
1284
|
-
<span style={{ color: 'var(--rvs-fg3)' }}>
|
|
1285
|
-
{activeTab.staged && activeTab.ref === undefined ? t('scm.stagedReadonly') : ''}
|
|
1286
|
-
{activeTab.ref !== undefined ? `${t('scm.commitDiff')} ${activeTab.ref.slice(0, 7)}` : ''}
|
|
1287
|
-
</span>
|
|
1342
|
+
<span style={{ color: 'var(--rvs-fg3)' }}>{diffScopeLabel}</span>
|
|
1288
1343
|
)}
|
|
1289
1344
|
<span style={{ color: 'var(--rvs-fg3)' }}>{language}</span>
|
|
1290
1345
|
{/* Connection health sits where the build stamp does: it is the
|
|
@@ -1693,6 +1748,8 @@ export function EditorPane(props: { visible: boolean }): ReactNode {
|
|
|
1693
1748
|
onChangeStale={() => { markChangeStale(activeTab.id) }}
|
|
1694
1749
|
onUndoChange={(mark) => { void undoChange(activeTab.id, mark) }}
|
|
1695
1750
|
undoLabel={(mark) => undoActionLabel(t, mark.kind)}
|
|
1751
|
+
undoTriggerLabel={() => t('changes.actions')}
|
|
1752
|
+
{...(blockConfirm === undefined ? {} : { blockConfirm })}
|
|
1696
1753
|
onSave={() => { void saveActive() }}
|
|
1697
1754
|
onDirty={(dirty) => store.updateTab(activeTab.id, { dirty })}
|
|
1698
1755
|
onBuffer={(tabId, text) => store.updateTab(tabId, { text })}
|