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.
Files changed (67) hide show
  1. package/README.en.md +159 -23
  2. package/README.md +123 -23
  3. package/lib/client.js +6906 -6619
  4. package/lib/index.js +2014 -67
  5. package/lib/types/changes/recorder.d.ts +119 -2
  6. package/lib/types/client/CodeEditor.d.ts +15 -0
  7. package/lib/types/client/HostsView.d.ts +139 -2
  8. package/lib/types/client/api.d.ts +42 -2
  9. package/lib/types/client/changes/apply-failure.d.ts +41 -0
  10. package/lib/types/client/changes/block-confirm.d.ts +97 -0
  11. package/lib/types/client/changes/diff-outcome.d.ts +56 -0
  12. package/lib/types/client/changes/freshness.d.ts +51 -0
  13. package/lib/types/client/changes/model.d.ts +19 -1
  14. package/lib/types/client/changes/session-diff.d.ts +100 -0
  15. package/lib/types/client/changes/staleness.d.ts +98 -0
  16. package/lib/types/client/changes/turn-reverted.d.ts +82 -0
  17. package/lib/types/client/changes/turn-view.d.ts +131 -0
  18. package/lib/types/client/changes/undo-affordance.d.ts +44 -10
  19. package/lib/types/client/changes/undo-target.d.ts +12 -0
  20. package/lib/types/client/connection.d.ts +28 -1
  21. package/lib/types/client/i18n.d.ts +1 -1
  22. package/lib/types/client/store.d.ts +91 -1
  23. package/lib/types/client/vsc/change-marks.d.ts +21 -0
  24. package/lib/types/forward.d.ts +11 -1
  25. package/lib/types/pool.d.ts +95 -1
  26. package/lib/types/protocol.d.ts +221 -1
  27. package/lib/types/proxy.d.ts +136 -0
  28. package/lib/types/store.d.ts +81 -1
  29. package/lib/types/tools.d.ts +3 -0
  30. package/package.json +1 -1
  31. package/src/changes/recorder.ts +851 -8
  32. package/src/client/CodeEditor.tsx +43 -3
  33. package/src/client/ConnectionStatus.tsx +19 -5
  34. package/src/client/EditorPane.tsx +64 -7
  35. package/src/client/HostsView.tsx +552 -11
  36. package/src/client/PortsView.tsx +16 -0
  37. package/src/client/SettingsHosts.tsx +132 -6
  38. package/src/client/api.ts +60 -3
  39. package/src/client/changes/ChangesDock.tsx +539 -54
  40. package/src/client/changes/apply-failure.ts +73 -0
  41. package/src/client/changes/block-confirm.ts +180 -0
  42. package/src/client/changes/changes.css +45 -0
  43. package/src/client/changes/diff-outcome.ts +97 -0
  44. package/src/client/changes/freshness.ts +68 -0
  45. package/src/client/changes/model.ts +56 -1
  46. package/src/client/changes/session-diff.ts +187 -0
  47. package/src/client/changes/staleness.ts +148 -0
  48. package/src/client/changes/turn-reverted.ts +254 -0
  49. package/src/client/changes/turn-view.ts +195 -0
  50. package/src/client/changes/undo-affordance.ts +295 -63
  51. package/src/client/changes/undo-target.ts +12 -0
  52. package/src/client/connection.ts +76 -2
  53. package/src/client/i18n.ts +204 -4
  54. package/src/client/scm/DiffView.tsx +32 -13
  55. package/src/client/store.tsx +392 -16
  56. package/src/client/vsc/change-marks.ts +21 -0
  57. package/src/client/vsc/preview-document.tsx +4 -1
  58. package/src/client/vsc/vsc.css +6747 -6509
  59. package/src/forward.ts +38 -2
  60. package/src/importers.ts +125 -13
  61. package/src/keygen.ts +8 -1
  62. package/src/pool.ts +422 -27
  63. package/src/protocol.ts +229 -1
  64. package/src/proxy.ts +673 -0
  65. package/src/routes.ts +93 -14
  66. package/src/store.ts +335 -0
  67. package/src/tools.ts +47 -2
@@ -12,24 +12,36 @@
12
12
  * the two surfaces list the same hosts/bindings, and a workspace created here
13
13
  * used to stay invisible in the Remote tab until the whole page reloaded.
14
14
  */
15
- import { useCallback, useEffect, useState, type ReactNode } from 'react'
15
+ import { useCallback, useEffect, useId, useState, type ReactNode } from 'react'
16
16
  import type { SettingsSectionOwnerProps } from '@deepseek-ai/dsh-client-ui-settings/client'
17
17
  import {
18
18
  REMOTE_VIEW_SETTINGS_DEFAULTS,
19
19
  REMOTE_VIEW_WIDTH_MAX,
20
20
  REMOTE_VIEW_WIDTH_MIN,
21
21
  type RemoteHostSummary,
22
+ type RemoteProxySettingsPatch,
23
+ type RemoteProxySettingsView,
22
24
  type RemoteRoutingStatus,
23
25
  type RemoteViewSettings,
24
26
  type RemoteWorkspaceBinding,
25
27
  } from '../protocol.ts'
26
28
  import { RemoteApiError, api } from './api.ts'
27
- import { HostsView } from './HostsView.tsx'
29
+ import {
30
+ HostsView,
31
+ ProxyFields,
32
+ ProxySectionHeader,
33
+ defaultProxyStateOf,
34
+ proxyFormProblem,
35
+ proxySummary,
36
+ proxyTargetOf,
37
+ type ProxyChipModel,
38
+ type ProxyFormState,
39
+ } from './HostsView.tsx'
28
40
  import { refreshAll as refreshSidebarStore } from './store.tsx'
29
41
  import { loadViewSettings, saveViewSettings } from './view-settings.ts'
30
42
  import { WorkspacesView } from './WorkspacesView.tsx'
31
43
  import { detectLang, makeT } from './i18n.ts'
32
- import { Notice, Row, hairline, optionStyle, selectStyle } from './ui.tsx'
44
+ import { Btn, Notice, Row, hairline, optionStyle, selectStyle } from './ui.tsx'
33
45
 
34
46
  export function SettingsHostsSection(_props: SettingsSectionOwnerProps): ReactNode {
35
47
  const [t] = useState(() => makeT(detectLang()))
@@ -44,11 +56,23 @@ export function SettingsHostsSection(_props: SettingsSectionOwnerProps): ReactNo
44
56
  /** The width slider's live value while dragging; persisted on release. */
45
57
  const [ratio, setRatio] = useState(REMOTE_VIEW_SETTINGS_DEFAULTS.remoteWorkspaceWidthRatio)
46
58
  const [viewSaving, setViewSaving] = useState(false)
59
+ /** Profile-wide egress default (the card above the view preferences). */
60
+ const [proxySettings, setProxySettings] = useState<RemoteProxySettingsView | undefined>(undefined)
61
+ const [proxyDraft, setProxyDraft] = useState<ProxyFormState>(() => defaultProxyStateOf(undefined))
62
+ const [proxyOpen, setProxyOpen] = useState(false)
63
+ const [proxySaving, setProxySaving] = useState(false)
64
+ const [proxyError, setProxyError] = useState<string | undefined>(undefined)
65
+ const proxyPanelId = useId()
66
+ const proxyGroupName = useId()
47
67
 
48
68
  const refresh = useCallback(() => {
49
69
  setError(undefined)
50
- Promise.all([api.getHosts(), api.getWorkspaces(), loadViewSettings()]).then(
51
- ([rows, w, settings]) => {
70
+ // The proxy route is asked SEPARATELY and may fail on its own: an older Host
71
+ // answers 404 there, and that must not blank out the host list or the view
72
+ // preferences of an otherwise working page.
73
+ const loadProxy = api.getProxySettings().then(settings => settings, () => undefined)
74
+ Promise.all([api.getHosts(), api.getWorkspaces(), loadViewSettings(), loadProxy]).then(
75
+ ([rows, w, settings, proxy]) => {
52
76
  setHosts(rows)
53
77
  setMode(w.mode)
54
78
  setVersion(w.version)
@@ -56,6 +80,10 @@ export function SettingsHostsSection(_props: SettingsSectionOwnerProps): ReactNo
56
80
  setView(settings)
57
81
  setRatio(settings.remoteWorkspaceWidthRatio)
58
82
  }
83
+ if (proxy !== undefined) {
84
+ setProxySettings(proxy)
85
+ setProxyDraft(defaultProxyStateOf(proxy))
86
+ }
59
87
  },
60
88
  (e: unknown) => setError(e instanceof RemoteApiError ? e.message : String(e)),
61
89
  )
@@ -113,6 +141,47 @@ export function SettingsHostsSection(_props: SettingsSectionOwnerProps): ReactNo
113
141
  saveView({ remoteWorkspaceWidthRatio: ratio })
114
142
  }
115
143
 
144
+ /**
145
+ * Persist the profile-wide egress default.
146
+ *
147
+ * Only `target` is sent while the mode is `proxy` — switching to `direct`
148
+ * omits it so the stored endpoint (and its password) survives a flip back, and
149
+ * an empty password box omits the secret rather than clearing it.
150
+ */
151
+ const saveProxyDefault = (): void => {
152
+ const problem = proxyFormProblem(proxyDraft)
153
+ if (problem !== undefined) {
154
+ setProxyError(problem === 'target' ? t('proxy.invalidTarget') : t('proxy.invalidJump'))
155
+ return
156
+ }
157
+ setProxySaving(true)
158
+ setProxyError(undefined)
159
+ const patch: RemoteProxySettingsPatch = proxyDraft.mode === 'proxy'
160
+ ? { defaultMode: 'proxy', target: proxyTargetOf(proxyDraft) }
161
+ : { defaultMode: 'direct' }
162
+ api.patchProxySettings(patch).then(
163
+ (next) => {
164
+ setProxySettings(next)
165
+ setProxyDraft(defaultProxyStateOf(next))
166
+ },
167
+ (e: unknown) => setProxyError(
168
+ t('proxy.saveFailed').replace('{message}', e instanceof RemoteApiError ? e.message : String(e)),
169
+ ),
170
+ ).finally(() => setProxySaving(false))
171
+ }
172
+
173
+ // The collapsed chip reuses the form's own sentence, so the two surfaces can
174
+ // never disagree about how the route is WORDED — but it reads the STORED answer,
175
+ // not the draft: a chip that followed unsaved radio clicks would claim a route
176
+ // that is not in effect (the panel is where the pending edit belongs).
177
+ const proxyDefaultSummary = proxySummary(t, defaultProxyStateOf(proxySettings), undefined)
178
+ const proxyChip: ProxyChipModel = {
179
+ mode: proxyDraft.mode,
180
+ label: proxyDefaultSummary,
181
+ title: t('proxy.chipTitle').replace('{summary}', proxyDefaultSummary),
182
+ problem: false,
183
+ }
184
+
116
185
  return (
117
186
  <div style={{ padding: '4px 2px', fontSize: 13, lineHeight: 1.5 }}>
118
187
  <div style={{ ...hairline, borderTop: 'none', borderBottom: '1px solid rgba(127,127,127,.25)', marginBottom: 10, paddingBottom: 8 }}>
@@ -138,7 +207,64 @@ export function SettingsHostsSection(_props: SettingsSectionOwnerProps): ReactNo
138
207
  <div style={{ fontSize: 11, opacity: 0.6, marginTop: 4 }}>{t('route.hint')}</div>
139
208
  </div>
140
209
  {error !== undefined && <Notice kind="error">{error}</Notice>}
141
- <HostsView t={t} hosts={hosts} onChanged={reload} />
210
+ <HostsView t={t} hosts={hosts} proxyDefault={proxySettings} onChanged={reload} />
211
+ <div style={{ ...hairline, marginTop: 12, paddingTop: 10 }}>
212
+ <ProxySectionHeader
213
+ open={proxyOpen}
214
+ label={t('proxy.default.title')}
215
+ expandLabel={t('proxy.expand')}
216
+ collapseLabel={t('proxy.collapse')}
217
+ chip={proxyChip}
218
+ controls={proxyPanelId}
219
+ onToggle={() => setProxyOpen(!proxyOpen)}
220
+ />
221
+ <div id={proxyPanelId} hidden={!proxyOpen} className="rvs-proxy-panel">
222
+ <Row>
223
+ <label style={{ marginRight: 10, opacity: proxySaving ? 0.5 : 1 }}>
224
+ <input
225
+ type="radio"
226
+ name={proxyGroupName}
227
+ checked={proxyDraft.mode === 'direct'}
228
+ disabled={proxySaving}
229
+ onChange={() => { setProxyDraft({ ...proxyDraft, mode: 'direct' }); setProxyError(undefined) }}
230
+ />{' '}{t('proxy.mode.direct')}
231
+ </label>
232
+ <label style={{ opacity: proxySaving ? 0.5 : 1 }}>
233
+ <input
234
+ type="radio"
235
+ name={proxyGroupName}
236
+ checked={proxyDraft.mode === 'proxy'}
237
+ disabled={proxySaving}
238
+ onChange={() => { setProxyDraft({ ...proxyDraft, mode: 'proxy' }); setProxyError(undefined) }}
239
+ />{' '}{t('proxy.mode.proxy')}
240
+ </label>
241
+ </Row>
242
+ {proxyDraft.mode === 'proxy' && (
243
+ <ProxyFields
244
+ t={t}
245
+ state={proxyDraft}
246
+ onChange={(next) => { setProxyDraft(next); setProxyError(undefined) }}
247
+ /**
248
+ * Same rule as the host form: "leave it empty to keep it" only
249
+ * holds while the endpoint still matches the stored one.
250
+ */
251
+ storedPassword={proxySettings?.target?.hasPassword === true
252
+ && proxyDraft.kind === proxySettings.target.kind
253
+ && proxyDraft.host.trim() === proxySettings.target.host
254
+ && proxyDraft.port.trim() === String(proxySettings.target.port)
255
+ && proxyDraft.username.trim() === (proxySettings.target.username ?? '')}
256
+ disabled={proxySaving}
257
+ />
258
+ )}
259
+ <div style={{ fontSize: 11, opacity: 0.6, marginBottom: 8 }}>{t('proxy.default.hint')}</div>
260
+ <Row>
261
+ <Btn kind="primary" onClick={saveProxyDefault} disabled={proxySaving}>
262
+ {proxySaving ? t('proxy.saving') : t('proxy.save')}
263
+ </Btn>
264
+ </Row>
265
+ {proxyError !== undefined && <Notice kind="error">{proxyError}</Notice>}
266
+ </div>
267
+ </div>
142
268
  <div style={{ ...hairline, marginTop: 12, paddingTop: 10 }}>
143
269
  <div style={{ fontSize: 12, opacity: 0.75, marginBottom: 6 }}>{t('viewSettings.title')}</div>
144
270
  <Row>
package/src/client/api.ts CHANGED
@@ -11,6 +11,7 @@ import {
11
11
  type HelperAvailability,
12
12
  type ImportReport,
13
13
  type RemoteChangesDiff,
14
+ type RemoteChangesListRequest,
14
15
  type RemoteChangesSummary,
15
16
  type RemoteConnectionStatus,
16
17
  type RemoteDeployState,
@@ -18,6 +19,7 @@ import {
18
19
  type RemoteFileEntry,
19
20
  type RemoteForwardRequest,
20
21
  type RemoteForwardState,
22
+ type RemoteHostProxySetting,
21
23
  type RemoteHostSummary,
22
24
  type RemoteListenPortsResult,
23
25
  type RemoteMetricsResult,
@@ -25,6 +27,8 @@ import {
25
27
  type RemoteProcessesResult,
26
28
  type RemotePluginMeta,
27
29
  type RemoteProbe,
30
+ type RemoteProxySettingsPatch,
31
+ type RemoteProxySettingsView,
28
32
  type RemoteRead,
29
33
  type RemoteRoutingStatus,
30
34
  type RemoteTimeouts,
@@ -401,6 +405,14 @@ export interface HostForm {
401
405
  auth: { kind: 'key' | 'password'; keyPath?: string; passphrase?: string; password?: string }
402
406
  description?: string
403
407
  tags?: string[]
408
+ /**
409
+ * How this host reaches the network (see `RemoteHostProxySetting`).
410
+ *
411
+ * Absent means "no opinion": a create then keeps the profile default, and an
412
+ * update keeps whatever the host already had — which is what makes the field
413
+ * backward compatible with a Host that never heard of it.
414
+ */
415
+ proxy?: RemoteHostProxySetting
404
416
  }
405
417
 
406
418
  export interface PushReportView {
@@ -642,13 +654,23 @@ export const api = {
642
654
  * is opened for review.
643
655
  */
644
656
  changes: {
645
- list: (sessionId: string, force = false, repoSubdir = '') =>
646
- post<{ summary: RemoteChangesSummary | null }>(REMOTE_API.changes, {
657
+ /**
658
+ * @param force - `⟳` semantics: tracked scan now AND re-arm the slow new-file
659
+ * walk (expensive; a deliberate click).
660
+ * @param trackedOnly - "user came back to the page": tracked files now, but the
661
+ * slow walk keeps its cadence/write-off (see `RemoteChangesListRequest`).
662
+ */
663
+ list: (sessionId: string, force = false, repoSubdir = '', trackedOnly = false) => {
664
+ const body: RemoteChangesListRequest = {
647
665
  op: 'list',
648
666
  sessionId,
649
667
  ...(force ? { force: true } : {}),
668
+ ...(trackedOnly ? { trackedOnly: true } : {}),
650
669
  ...(repoSubdir === '' ? {} : { repoSubdir }),
651
- }).then(r => r.summary ?? null),
670
+ }
671
+ return post<{ summary: RemoteChangesSummary | null }>(REMOTE_API.changes, body)
672
+ .then(r => r.summary ?? null)
673
+ },
652
674
  diff: (sessionId: string, path: string, repoSubdir = '') =>
653
675
  post<{ diff: RemoteChangesDiff | null }>(REMOTE_API.changes, {
654
676
  op: 'diff',
@@ -656,6 +678,22 @@ export const api = {
656
678
  path,
657
679
  ...(repoSubdir === '' ? {} : { repoSubdir }),
658
680
  }).then(r => r.diff ?? null),
681
+ /**
682
+ * The same comparison, but against the previous completed turn's close
683
+ * instead of the session baseline (the panel's 「本轮」 scope).
684
+ *
685
+ * Answers `unavailable` / `stale` (with a reason) instead of hunks when the
686
+ * host has no cached per-turn contents or the file moved on after the turn —
687
+ * the client must fall back to `diff` (session view) rather than paint lines
688
+ * that no longer exist.
689
+ */
690
+ turnDiff: (sessionId: string, path: string, repoSubdir = '') =>
691
+ post<{ diff: RemoteChangesDiff | null }>(REMOTE_API.changes, {
692
+ op: 'turnDiff',
693
+ sessionId,
694
+ path,
695
+ ...(repoSubdir === '' ? {} : { repoSubdir }),
696
+ }).then(r => r.diff ?? null),
659
697
  },
660
698
  // -- routing mode (volatile, persists to the profile patch)
661
699
  setRoutingMode: (mode: 'off' | 'shadow' | 'enforce') =>
@@ -666,6 +704,25 @@ export const api = {
666
704
  /** Flat patch: unknown keys are ignored, unusable values keep the stored one. */
667
705
  setViewSettings: (patch: Partial<RemoteViewSettings>) =>
668
706
  post<{ settings: RemoteViewSettings }>(REMOTE_API.viewSettings, patch).then((r) => r.settings),
707
+ // -- profile-wide egress default (per-host overrides live on the host rows)
708
+ /**
709
+ * The default egress every `mode: 'inherit'` host follows.
710
+ *
711
+ * Answers the DEFAULTS on a fresh profile (`direct`), and a Host too old to
712
+ * know the route answers 404 — callers treat that as "direct" and keep the
713
+ * per-host form working (see `proxySummary`).
714
+ */
715
+ getProxySettings: () =>
716
+ call<{ settings: RemoteProxySettingsView }>(REMOTE_API.proxySettings).then((r) => r.settings),
717
+ /**
718
+ * Patch the default egress.
719
+ *
720
+ * `target: null` clears the stored endpoint; omitting it keeps the stored one
721
+ * (so flipping to `direct` and back does not lose the address), and an empty
722
+ * password keeps the stored secret — the browser never sees it.
723
+ */
724
+ patchProxySettings: (patch: RemoteProxySettingsPatch) =>
725
+ post<{ settings: RemoteProxySettingsView }>(REMOTE_API.proxySettings, patch).then((r) => r.settings),
669
726
  // -- deploy
670
727
  deployStatus: (alias: string) =>
671
728
  call<{ deploy: RemoteDeployState; helpers: HelperAvailability[] }>(