dsh-remote-vs 0.24.0 → 0.26.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 (125) hide show
  1. package/README.en.md +50 -16
  2. package/README.md +40 -15
  3. package/THIRD-PARTY-NOTICES.md +188 -0
  4. package/lib/client.js +6512 -77887
  5. package/lib/index.js +1461 -1024
  6. package/lib/p2-router-fs.js +1 -1
  7. package/lib/types/client/CodeEditor.d.ts +25 -0
  8. package/lib/types/client/EditorPane.d.ts +16 -5
  9. package/lib/types/client/FloatingPlaceholder.d.ts +16 -5
  10. package/lib/types/client/RemoteEditorView.d.ts +13 -10
  11. package/lib/types/client/RemoteExplorer.d.ts +53 -0
  12. package/lib/types/client/RemoteRoot.d.ts +5 -5
  13. package/lib/types/client/TerminalSnippets.d.ts +36 -0
  14. package/lib/types/client/TerminalView.d.ts +1 -1
  15. package/lib/types/client/XTerm.d.ts +33 -0
  16. package/lib/types/client/api.d.ts +37 -2
  17. package/lib/types/client/changes/review-state.d.ts +19 -0
  18. package/lib/types/client/connection.d.ts +16 -0
  19. package/lib/types/client/editor-capability.d.ts +27 -0
  20. package/lib/types/client/i18n.d.ts +1 -1
  21. package/lib/types/client/request-gate.d.ts +110 -0
  22. package/lib/types/client/scm/DiffView.d.ts +45 -7
  23. package/lib/types/client/scm/actions.d.ts +31 -3
  24. package/lib/types/client/store.d.ts +112 -4
  25. package/lib/types/client/terminal-input.d.ts +23 -0
  26. package/lib/types/client/terminal-snippets.d.ts +86 -0
  27. package/lib/types/client/vsc/FindWidget.d.ts +6 -0
  28. package/lib/types/client/vsc/breadcrumb.d.ts +30 -0
  29. package/lib/types/client/vsc/change-marks.d.ts +16 -6
  30. package/lib/types/client/vsc/editor-caret.d.ts +32 -0
  31. package/lib/types/client/vsc/editor-keymap.d.ts +35 -1
  32. package/lib/types/client/vsc/editor-langs.d.ts +9 -0
  33. package/lib/types/client/vsc/editor-settings.d.ts +55 -0
  34. package/lib/types/client/vsc/image-preview.d.ts +36 -0
  35. package/lib/types/client/vsc/kit.d.ts +13 -0
  36. package/lib/types/client/vsc/save-shortcut.d.ts +21 -0
  37. package/lib/types/client/vsc/terminal-clipboard.d.ts +15 -0
  38. package/lib/types/client/vsc/terminal-line.d.ts +25 -0
  39. package/lib/types/client/vsc/terminal-links.d.ts +62 -0
  40. package/lib/types/client/vsc/terminal-theme.d.ts +48 -0
  41. package/lib/types/client/vsc/terminal-writer.d.ts +52 -0
  42. package/lib/types/forward.d.ts +12 -0
  43. package/lib/types/fs-ops.d.ts +42 -0
  44. package/lib/types/http.d.ts +2 -0
  45. package/lib/types/keygen.d.ts +9 -0
  46. package/lib/types/monitor.d.ts +8 -0
  47. package/lib/types/notices.d.ts +16 -1
  48. package/lib/types/p2/helper-rpc.d.ts +45 -0
  49. package/lib/types/pool.d.ts +25 -0
  50. package/lib/types/routes.d.ts +2 -0
  51. package/lib/types/store.d.ts +7 -0
  52. package/lib/types/terminal.d.ts +33 -1
  53. package/lib/types/view-settings.d.ts +5 -0
  54. package/lib/{worlds-B7gEDBzC.js → worlds-RG8K5eom.js} +113 -15
  55. package/package.json +2 -1
  56. package/src/client/CodeEditor.tsx +205 -10
  57. package/src/client/DirectoryFlow.tsx +16 -0
  58. package/src/client/DoctorPanel.tsx +70 -7
  59. package/src/client/EditorPane.tsx +545 -118
  60. package/src/client/FloatingPlaceholder.tsx +34 -5
  61. package/src/client/HostsView.tsx +12 -3
  62. package/src/client/RemoteDirectoryPicker.tsx +12 -0
  63. package/src/client/RemoteEditorView.tsx +14 -11
  64. package/src/client/RemoteExplorer.tsx +929 -40
  65. package/src/client/RemoteRoot.tsx +167 -147
  66. package/src/client/SearchView.tsx +8 -0
  67. package/src/client/TerminalSnippets.tsx +432 -0
  68. package/src/client/TerminalView.tsx +50 -1
  69. package/src/client/XTerm.tsx +228 -58
  70. package/src/client/api.ts +106 -13
  71. package/src/client/auto-open-remote.ts +11 -9
  72. package/src/client/changes/ChangesDock.tsx +188 -6
  73. package/src/client/changes/changes.css +10 -3
  74. package/src/client/changes/review-state.ts +34 -0
  75. package/src/client/connection.ts +29 -0
  76. package/src/client/downloads.ts +49 -4
  77. package/src/client/editor-capability.ts +42 -0
  78. package/src/client/i18n.ts +228 -12
  79. package/src/client/index.tsx +22 -6
  80. package/src/client/request-gate.ts +221 -0
  81. package/src/client/scm/CommitPane.tsx +20 -2
  82. package/src/client/scm/DiffView.tsx +343 -117
  83. package/src/client/scm/HistoryPanel.tsx +23 -2
  84. package/src/client/scm/RepoPicker.tsx +1 -1
  85. package/src/client/scm/ScmPanel.tsx +391 -87
  86. package/src/client/scm/actions.ts +95 -12
  87. package/src/client/store.tsx +537 -22
  88. package/src/client/terminal-input.ts +44 -0
  89. package/src/client/terminal-snippets.ts +216 -0
  90. package/src/client/ui.tsx +4 -0
  91. package/src/client/vsc/FindWidget.tsx +24 -9
  92. package/src/client/vsc/breadcrumb.tsx +339 -0
  93. package/src/client/vsc/change-marks.ts +93 -44
  94. package/src/client/vsc/editor-caret.ts +30 -0
  95. package/src/client/vsc/editor-keymap.ts +59 -1
  96. package/src/client/vsc/editor-langs.ts +20 -0
  97. package/src/client/vsc/editor-settings.ts +146 -0
  98. package/src/client/vsc/editor-theme.ts +4 -5
  99. package/src/client/vsc/file-icons.tsx +17 -3
  100. package/src/client/vsc/image-preview.tsx +110 -0
  101. package/src/client/vsc/kit.tsx +46 -10
  102. package/src/client/vsc/save-shortcut.ts +47 -1
  103. package/src/client/vsc/terminal-clipboard.ts +19 -0
  104. package/src/client/vsc/terminal-line.ts +101 -0
  105. package/src/client/vsc/terminal-links.ts +166 -0
  106. package/src/client/vsc/terminal-theme.ts +97 -0
  107. package/src/client/vsc/terminal-writer.ts +112 -0
  108. package/src/client/vsc/vsc.css +1078 -181
  109. package/src/forward.ts +47 -9
  110. package/src/fs-ops.ts +124 -4
  111. package/src/git-ops.ts +20 -3
  112. package/src/http.ts +35 -4
  113. package/src/keygen.ts +55 -4
  114. package/src/monitor.ts +13 -0
  115. package/src/notices.ts +23 -1
  116. package/src/p2/helper-rpc.ts +113 -7
  117. package/src/p2/worlds.ts +14 -1
  118. package/src/pool.ts +99 -27
  119. package/src/routes.ts +212 -43
  120. package/src/sftp.ts +51 -14
  121. package/src/store.ts +10 -0
  122. package/src/terminal.ts +225 -24
  123. package/src/view-settings.ts +50 -10
  124. package/lib/types/client/Dialog.d.ts +0 -14
  125. package/src/client/Dialog.tsx +0 -76
@@ -29,6 +29,7 @@ import {
29
29
  gitErrorHint,
30
30
  GIT_CAP,
31
31
  headMessageCommand,
32
+ initCommand,
32
33
  mergeCommand,
33
34
  parseAllBranches,
34
35
  parseCommitFiles,
@@ -61,7 +62,8 @@ import {
61
62
  statusPathsCommand,
62
63
  unstageCommand,
63
64
  } from '../../git-ops.ts'
64
- import { api, gitTimeoutMs } from '../api.ts'
65
+ import { api, gitTimeoutMs, type RequestOptions } from '../api.ts'
66
+ import { isRequestAbort } from '../request-gate.ts'
65
67
  import { appendExecOutput, networkBudgetMs, networkCommands, type PushTarget } from '../exec-output.ts'
66
68
  import { timeoutSeconds } from '../../timeouts.ts'
67
69
 
@@ -101,19 +103,61 @@ function failureOf(result: RemoteExecResult, timeoutMs: number): GitOpError {
101
103
  return new GitOpError(hint ?? detail ?? result.error ?? `git failed [exit code: ${result.exitCode ?? '?'}]`)
102
104
  }
103
105
 
106
+ /**
107
+ * Per-command options for {@link run} / {@link tryRun}.
108
+ *
109
+ * `background` puts the command on the request gate's git channel: it waits
110
+ * while a foreground request is in flight and only one such command runs at a
111
+ * time. ONLY the repository-wide READ paths use it (`probeRepoRoot`,
112
+ * `loadStatusDetail`, `loadHead`), because those are the walks a workspace
113
+ * switch starts and the ones that must never make the directory listing queue
114
+ * behind them. Every verb the user is waiting on (stage, commit, push, the
115
+ * bounded probes, the search) stays foreground and is unaffected.
116
+ *
117
+ * `signal` cancels the command: the HTTP request is aborted (and, while still
118
+ * queued, is taken out of the queue) — the store's `readGit` uses it to release
119
+ * the connections of a workspace the user just left.
120
+ */
121
+ export interface RunOptions {
122
+ background?: boolean
123
+ signal?: AbortSignal
124
+ }
125
+
126
+ /** Map {@link RunOptions} onto the HTTP layer's {@link RequestOptions}. */
127
+ function requestOptionsOf(options: RunOptions): RequestOptions {
128
+ return {
129
+ ...(options.background === true ? { background: true } : {}),
130
+ ...(options.signal === undefined ? {} : { signal: options.signal }),
131
+ }
132
+ }
133
+
104
134
  /** Run one command, raising a readable error on a non-zero exit. */
105
- async function run(alias: string, command: string, timeoutMs = normalTimeoutMs()): Promise<RemoteExecResult> {
106
- const result = await api.exec(alias, command, timeoutMs)
135
+ async function run(
136
+ alias: string,
137
+ command: string,
138
+ timeoutMs = normalTimeoutMs(),
139
+ options: RunOptions = {},
140
+ ): Promise<RemoteExecResult> {
141
+ const result = await api.exec(alias, command, timeoutMs, requestOptionsOf(options))
107
142
  if (result.success) return result
108
143
  throw failureOf(result, timeoutMs)
109
144
  }
110
145
 
111
146
  /** Run one command tolerating failure (returns '' instead). */
112
- async function tryRun(alias: string, command: string, timeoutMs = normalTimeoutMs()): Promise<string> {
147
+ async function tryRun(
148
+ alias: string,
149
+ command: string,
150
+ timeoutMs = normalTimeoutMs(),
151
+ options: RunOptions = {},
152
+ ): Promise<string> {
113
153
  try {
114
- const result = await api.exec(alias, command, timeoutMs)
154
+ const result = await api.exec(alias, command, timeoutMs, requestOptionsOf(options))
115
155
  return result.success ? result.stdout : ''
116
- } catch {
156
+ } catch (error) {
157
+ // A cancelled command is not "no answer": swallowing it would let the
158
+ // sibling half of a `Promise.all` land with a placeholder value (an aborted
159
+ // HEAD write once cached `detached: true`).
160
+ if (isRequestAbort(error)) throw error
117
161
  return ''
118
162
  }
119
163
  }
@@ -146,11 +190,22 @@ export type RepoRootProbe =
146
190
  | { kind: 'failed'; error: string }
147
191
 
148
192
  /** The repository root, or WHY the probe could not answer. */
149
- export async function probeRepoRoot(alias: string, workspaceRoot: string): Promise<RepoRootProbe> {
193
+ export async function probeRepoRoot(
194
+ alias: string,
195
+ workspaceRoot: string,
196
+ signal?: AbortSignal,
197
+ ): Promise<RepoRootProbe> {
150
198
  let result: RemoteExecResult
151
199
  try {
152
- result = await api.exec(alias, repoProbeDetailCommand(workspaceRoot), normalTimeoutMs())
200
+ result = await api.exec(alias, repoProbeDetailCommand(workspaceRoot), normalTimeoutMs(), {
201
+ // The probe is the FIRST step of a workspace switch's background walk: on
202
+ // a large tree it is a full `rev-parse` + `cd` over SSH, and it must yield
203
+ // to the listing the user is waiting on.
204
+ background: true,
205
+ ...(signal === undefined ? {} : { signal }),
206
+ })
153
207
  } catch (error) {
208
+ if (isRequestAbort(error)) throw error
154
209
  // The transport/route failed before any git exit code existed.
155
210
  return { kind: 'failed', error: error instanceof Error ? error.message : String(error) }
156
211
  }
@@ -171,8 +226,13 @@ export async function findRepos(alias: string, workspaceRoot: string): Promise<s
171
226
  }
172
227
 
173
228
  /** Every changed path plus the ignored half. */
174
- export async function loadStatusDetail(alias: string, root: string): Promise<GitStatusDetail> {
175
- const out = await run(alias, statusDetailCommand(root))
229
+ export async function loadStatusDetail(alias: string, root: string, signal?: AbortSignal): Promise<GitStatusDetail> {
230
+ // The walk itself: the expensive half of a switch (8–9 s on the reported AOSP
231
+ // trees), so it runs on the git channel and yields to every foreground read.
232
+ const out = await run(alias, statusDetailCommand(root), normalTimeoutMs(), {
233
+ background: true,
234
+ ...(signal === undefined ? {} : { signal }),
235
+ })
176
236
  return parseStatusDetail(out.stdout)
177
237
  }
178
238
 
@@ -212,9 +272,20 @@ export async function probeStatusDir(alias: string, root: string, dir: string):
212
272
  }
213
273
 
214
274
  /** Current branch with its ahead/behind counters (detached HEAD tolerated). */
215
- export async function loadHead(alias: string, root: string): Promise<{ branch: string; detached: boolean; ahead: number; behind: number }> {
216
- const out = await tryRun(alias, branchHeaderCommand(root), 60_000)
275
+ export async function loadHead(
276
+ alias: string,
277
+ root: string,
278
+ signal?: AbortSignal,
279
+ ): Promise<{ branch: string; detached: boolean; ahead: number; behind: number }> {
280
+ const out = await tryRun(alias, branchHeaderCommand(root), 60_000, {
281
+ background: true,
282
+ ...(signal === undefined ? {} : { signal }),
283
+ })
217
284
  const first = (out.split('\0')[0] ?? out.split('\n')[0] ?? '').replace(/^## /, '').trim()
285
+ // An empty repository reports `## No commits yet on <branch>`: the branch name
286
+ // lives AFTER the words, and the generic pattern below would read "No".
287
+ const unborn = /^No commits yet on (\S+)$/.exec(first)
288
+ if (unborn !== null) return { branch: unborn[1] as string, detached: false, ahead: 0, behind: 0 }
218
289
  if (first === '' || first.startsWith('HEAD (no branch')) return { branch: 'HEAD', detached: true, ahead: 0, behind: 0 }
219
290
  const match = /^([^\s.]+(?:\.\.\.[^\s[]+)?)(?: \[(?:ahead (\d+))?(?:, )?(?:behind (\d+))?\])?/.exec(first)
220
291
  if (match === null) return { branch: first, detached: false, ahead: 0, behind: 0 }
@@ -374,6 +445,18 @@ export async function loadStashes(alias: string, root: string): Promise<GitStash
374
445
 
375
446
  // ------------------------------------------------------------ write paths
376
447
 
448
+ /**
449
+ * Initialize a repository in place (`git init`).
450
+ *
451
+ * The panel's "not a repository" state used to be a dead end (the only offer
452
+ * was "browse somewhere else") while the command builder had no caller at all.
453
+ * The caller refreshes the status afterwards — that read re-probes the
454
+ * directory, so the panel moves to the normal view without another discovery.
455
+ */
456
+ export async function initRepo(alias: string, root: string): Promise<string> {
457
+ return (await run(alias, initCommand(root), 60_000)).stdout
458
+ }
459
+
377
460
  /** Stage paths (additions, edits, deletions, renames). */
378
461
  export async function stagePaths(alias: string, root: string, paths: readonly string[]): Promise<void> {
379
462
  if (paths.length === 0) return