dsh-remote-vs 0.13.0 → 0.15.1

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 (128) hide show
  1. package/README.en.md +455 -443
  2. package/README.md +408 -396
  3. package/lib/client.js +8062 -2651
  4. package/lib/index.js +1058 -288
  5. package/lib/p2-router-fs.js +1 -1
  6. package/lib/p2-router-refs.js +89 -10
  7. package/lib/p2-router-spill.js +73 -1
  8. package/lib/p2-router-subprocess.js +18 -6
  9. package/lib/spill-retention-BwKEWrl5.js +115 -0
  10. package/lib/{ssh-proc-arI5lm4W.js → ssh-proc-VKWn_LZC.js} +17 -0
  11. package/lib/types/archive.d.ts +1 -1
  12. package/lib/types/changes/recorder.d.ts +34 -2
  13. package/lib/types/client/CodeEditor.d.ts +12 -0
  14. package/lib/types/client/ConnectionStatus.d.ts +17 -0
  15. package/lib/types/client/DirectoryFlow.d.ts +2 -0
  16. package/lib/types/client/DoctorPanel.d.ts +25 -0
  17. package/lib/types/client/QuickOpen.d.ts +17 -0
  18. package/lib/types/client/RemoteExplorer.d.ts +192 -1
  19. package/lib/types/client/RemoteRoot.d.ts +17 -0
  20. package/lib/types/client/SearchView.d.ts +55 -0
  21. package/lib/types/client/TerminalView.d.ts +38 -0
  22. package/lib/types/client/WorkspaceWizard.d.ts +17 -0
  23. package/lib/types/client/api.d.ts +54 -4
  24. package/lib/types/client/changes/undo-affordance.d.ts +16 -0
  25. package/lib/types/client/changes/undo-context.d.ts +14 -18
  26. package/lib/types/client/changes/undo-target.d.ts +78 -0
  27. package/lib/types/client/connection.d.ts +111 -0
  28. package/lib/types/client/doctor.d.ts +122 -0
  29. package/lib/types/client/download.d.ts +35 -5
  30. package/lib/types/client/downloads.d.ts +18 -1
  31. package/lib/types/client/file-open-probe.d.ts +64 -0
  32. package/lib/types/client/i18n.d.ts +1 -1
  33. package/lib/types/client/quickopen-model.d.ts +332 -0
  34. package/lib/types/client/scm/DiffView.d.ts +34 -0
  35. package/lib/types/client/scm/actions.d.ts +18 -0
  36. package/lib/types/client/scm/diff-model.d.ts +17 -1
  37. package/lib/types/client/scm/git-cache.d.ts +10 -2
  38. package/lib/types/client/scm/read-queue.d.ts +2 -1
  39. package/lib/types/client/scm/stage-queue.d.ts +13 -0
  40. package/lib/types/client/scm/status-map.d.ts +3 -1
  41. package/lib/types/client/store.d.ts +114 -5
  42. package/lib/types/client/vsc/FindWidget.d.ts +7 -0
  43. package/lib/types/client/vsc/save-shortcut.d.ts +57 -0
  44. package/lib/types/deploy.d.ts +44 -2
  45. package/lib/types/git-format.d.ts +15 -0
  46. package/lib/types/http.d.ts +44 -0
  47. package/lib/types/p2/file-refs.d.ts +39 -2
  48. package/lib/types/p2/helper-rpc.d.ts +26 -0
  49. package/lib/types/p2/router-spill.d.ts +19 -0
  50. package/lib/types/p2/router-subprocess.d.ts +2 -0
  51. package/lib/types/p2/spill-retention.d.ts +74 -0
  52. package/lib/types/p2/worlds.d.ts +11 -0
  53. package/lib/types/pool.d.ts +73 -11
  54. package/lib/types/protocol.d.ts +63 -0
  55. package/lib/types/routes.d.ts +18 -0
  56. package/lib/types/sftp.d.ts +114 -8
  57. package/lib/types/store.d.ts +34 -0
  58. package/lib/types/timeouts.d.ts +14 -0
  59. package/lib/{worlds-C6Xha1mQ.js → worlds-Be1YE2Ot.js} +727 -78
  60. package/package.json +1 -1
  61. package/src/archive.ts +41 -9
  62. package/src/changes/recorder.ts +227 -31
  63. package/src/changes/status.ts +37 -1
  64. package/src/client/CodeEditor.tsx +84 -2
  65. package/src/client/ConnectionStatus.tsx +130 -0
  66. package/src/client/DirectoryFlow.tsx +40 -5
  67. package/src/client/DoctorPanel.tsx +202 -0
  68. package/src/client/DownloadDock.tsx +13 -25
  69. package/src/client/EditorPane.tsx +291 -7
  70. package/src/client/HostsView.tsx +17 -8
  71. package/src/client/QuickOpen.tsx +371 -0
  72. package/src/client/RemoteDirectoryPicker.tsx +54 -3
  73. package/src/client/RemoteExplorer.tsx +879 -160
  74. package/src/client/RemoteRoot.tsx +178 -1
  75. package/src/client/SearchView.tsx +180 -6
  76. package/src/client/SettingsHosts.tsx +1 -1
  77. package/src/client/TerminalView.tsx +174 -9
  78. package/src/client/WorkspaceWizard.tsx +110 -16
  79. package/src/client/WorkspacesView.tsx +22 -6
  80. package/src/client/api.ts +197 -11
  81. package/src/client/changes/ChangesDock.tsx +35 -8
  82. package/src/client/changes/undo-affordance.ts +33 -0
  83. package/src/client/changes/undo-context.ts +14 -18
  84. package/src/client/changes/undo-target.ts +139 -0
  85. package/src/client/connection.ts +264 -0
  86. package/src/client/doctor.ts +441 -0
  87. package/src/client/download.ts +148 -12
  88. package/src/client/downloads.ts +43 -2
  89. package/src/client/file-open-probe.ts +83 -0
  90. package/src/client/i18n.ts +244 -0
  91. package/src/client/index.tsx +5 -2
  92. package/src/client/quickopen-model.ts +778 -0
  93. package/src/client/remote-file-open.ts +21 -33
  94. package/src/client/scm/DiffView.tsx +116 -6
  95. package/src/client/scm/ScmPanel.tsx +19 -0
  96. package/src/client/scm/actions.ts +34 -2
  97. package/src/client/scm/diff-model.ts +33 -37
  98. package/src/client/scm/git-cache.ts +61 -4
  99. package/src/client/scm/read-queue.ts +33 -2
  100. package/src/client/scm/stage-queue.ts +72 -1
  101. package/src/client/scm/status-map.ts +22 -1
  102. package/src/client/store.tsx +704 -21
  103. package/src/client/vsc/FindWidget.tsx +20 -0
  104. package/src/client/vsc/kit.tsx +115 -6
  105. package/src/client/vsc/reveal-line.ts +33 -14
  106. package/src/client/vsc/save-shortcut.ts +131 -0
  107. package/src/client/vsc/vsc.css +419 -0
  108. package/src/deploy.ts +185 -33
  109. package/src/git-format.ts +136 -22
  110. package/src/git-ops.ts +14 -6
  111. package/src/http.ts +80 -12
  112. package/src/importers.ts +80 -21
  113. package/src/index.ts +21 -1
  114. package/src/p2/file-refs.ts +112 -10
  115. package/src/p2/helper-rpc.ts +73 -36
  116. package/src/p2/router-spill.ts +96 -1
  117. package/src/p2/router-subprocess.ts +18 -5
  118. package/src/p2/spill-retention.ts +134 -0
  119. package/src/p2/ssh-proc.ts +22 -0
  120. package/src/p2/worlds.ts +24 -0
  121. package/src/pool.ts +329 -47
  122. package/src/protocol.ts +66 -0
  123. package/src/routes.ts +251 -43
  124. package/src/sftp.ts +486 -26
  125. package/src/store.ts +207 -85
  126. package/src/terminal.ts +38 -2
  127. package/src/timeouts.ts +14 -0
  128. package/src/tools.ts +14 -5
@@ -97,6 +97,53 @@ function targetKey(target: ScmTarget): string {
97
97
  return `${target.alias}\n${target.root}`
98
98
  }
99
99
 
100
+ /**
101
+ * The repository the PANEL is currently pointed at.
102
+ *
103
+ * Why this is module state instead of per-coordinator: one page shows one
104
+ * source-control panel, and the coordinator is created by the store while the
105
+ * panel that owns the visible repository is a component — the panel reports its
106
+ * repository here, the coordinator reads it when it writes a result back.
107
+ *
108
+ * The problem it answers: a stage click is applied to the local status model
109
+ * IMMEDIATELY and verified ~250 ms later (plus the write's own round trip, which
110
+ * on a large repository can be seconds). If the user switches workspace or picks
111
+ * another repository directory inside that window, the verification's rollback
112
+ * or mismatch correction used to run against whatever repository was on screen
113
+ * NOW — with paths that are relative to the OLD repository root. Two repositories
114
+ * that happen to share a relative path then had the row moved on the WRONG list,
115
+ * and the store's stage-override ledger (keyed by repository) was reset as a
116
+ * side effect. Paths only mean something inside their own repository, so a
117
+ * result whose repository is no longer the visible one is dropped.
118
+ *
119
+ * `undefined` means "no panel has reported yet" and keeps the historic
120
+ * behaviour (every result is applied): that is the state a headless caller or a
121
+ * local check starts in, and a stage click cannot happen before the panel that
122
+ * hosts it exists.
123
+ *
124
+ * `alias + root` IS the repository identity (the binding id is not needed: two
125
+ * bindings pointing at one repository must share these corrections, and two
126
+ * hosts with an identical root are told apart by the alias). The binding id is
127
+ * deliberately not part of the token because it is not available at issue time
128
+ * without a store change.
129
+ */
130
+ let visibleRepository: ScmTarget | undefined
131
+
132
+ /** Two targets name the same repository. */
133
+ function sameRepository(left: ScmTarget, right: ScmTarget): boolean {
134
+ return left.alias === right.alias && left.root === right.root
135
+ }
136
+
137
+ /** Called by the source-control panel whenever its repository changes. */
138
+ export function setVisibleStageRepository(target: ScmTarget | undefined): void {
139
+ visibleRepository = target === undefined ? undefined : { alias: target.alias, root: target.root }
140
+ }
141
+
142
+ /** The repository the coordinator may write local results back into. */
143
+ export function visibleStageRepository(): ScmTarget | undefined {
144
+ return visibleRepository
145
+ }
146
+
100
147
  /**
101
148
  * Coordinates optimistic stage/unstage with a debounced, path-limited check.
102
149
  *
@@ -178,7 +225,9 @@ export class StageCoordinator {
178
225
  const error = outcomes[index]
179
226
  if (error === undefined) return
180
227
  // The verb never landed: put the row back and let the caller report it.
181
- this.sink.apply(job.paths, !job.staged)
228
+ // Only inside the repository the panel still shows — the rollback names
229
+ // OLD-repository paths, and applying it elsewhere moved an unrelated row.
230
+ if (this.stillVisible(job.target)) this.sink.apply(job.paths, !job.staged)
182
231
  job.reject(error)
183
232
  })
184
233
  const landed = batch.filter((_, index) => outcomes[index] === undefined)
@@ -194,6 +243,19 @@ export class StageCoordinator {
194
243
  }
195
244
  }
196
245
 
246
+ /**
247
+ * May a result about `target` be written into the panel's local model?
248
+ *
249
+ * `true` while no panel has reported a repository (headless callers, local
250
+ * checks) and while the reported repository IS `target`. `false` once the
251
+ * panel has moved to another repository: the paths in the result are relative
252
+ * to `target`'s root and would land on the wrong rows (see `visibleRepository`).
253
+ */
254
+ private stillVisible(target: ScmTarget): boolean {
255
+ const visible = visibleRepository
256
+ return visible === undefined || sameRepository(visible, target)
257
+ }
258
+
197
259
  /** Queue one write behind the previous one for the same repository. */
198
260
  private enqueue(target: ScmTarget, run: () => Promise<void>): Promise<void> {
199
261
  const key = targetKey(target)
@@ -239,6 +301,13 @@ export class StageCoordinator {
239
301
  }
240
302
 
241
303
  for (const group of groups.values()) {
304
+ // The user may have switched repository while this window's writes were in
305
+ // flight. The probe would still be answered (it is path-limited), but its
306
+ // answer describes a repository that is no longer on screen: correcting the
307
+ // visible model with those paths is the cross-repository corruption this
308
+ // guard exists for. Nothing is reported either — a toast naming the old
309
+ // repository's paths, under another repository's list, is noise.
310
+ if (!this.stillVisible(group.target)) continue
242
311
  let stdout = ''
243
312
  try {
244
313
  stdout = await this.port.probe(group.target, group.paths)
@@ -248,6 +317,8 @@ export class StageCoordinator {
248
317
  this.sink.report({ kind: 'unverified', paths: group.paths })
249
318
  continue
250
319
  }
320
+ // The probe itself can outlast a repository switch.
321
+ if (!this.stillVisible(group.target)) continue
251
322
  const detail = parseStatusDetail(stdout)
252
323
  const wrong: string[] = []
253
324
  for (const path of group.paths) {
@@ -181,7 +181,9 @@ export function stagedStateOf(detail: GitStatusDetail, path: string): boolean {
181
181
  * under "changes", so the record stays in the model);
182
182
  * - unstaging a staged RENAME leaves HEAD's path deleted in the INDEX — the
183
183
  * old path becomes `D ` and the new one untracked (measured, not assumed);
184
- * - staging a conflict resolves it into the index.
184
+ * - staging a conflict resolves it into the index (`D `/`A `/`M ` by conflict
185
+ * pair, never a `U` half — see `localStageEntry`, it used to keep `U` and
186
+ * the row then never left the conflict section);
185
187
  *
186
188
  * Pure, so the panel's instant feedback is assertable without a host: the
187
189
  * caller decides WHEN to apply it (and when to apply the inverse).
@@ -216,6 +218,25 @@ function localStageEntry(entry: GitPathStatus, staged: boolean): GitPathStatus[]
216
218
  const { path, x, y, origPath } = entry
217
219
  const keep = origPath === undefined ? {} : { origPath }
218
220
  if (staged) {
221
+ /**
222
+ * A MERGE CONFLICT: `git add` RESOLVES it into the index, so the record
223
+ * must leave the conflict section. Keeping the `U` half here (the old
224
+ * projection did: it read `x` and reused the letter) meant the row the user
225
+ * had just staged stayed under 冲突, `bucketStatus().staged` stayed EMPTY and
226
+ * the commit button — disabled while `staged.length === 0` — never came
227
+ * back, with no toast and no error. Only an unrelated full status read
228
+ * repaired it, and staging a conflict does not trigger one by design.
229
+ *
230
+ * What git reports afterwards is an ordinary index half: `D ` for a pair
231
+ * that is deleted on both sides, `A ` when HEAD has no such path (both-added
232
+ * / added-by-us), `M ` otherwise. The probe that follows the click
233
+ * (`stagedStateOf` → `isStagedStatus`) agrees with all three, so this is a
234
+ * projection the verification can confirm rather than contradict.
235
+ */
236
+ if (isConflict(x, y)) {
237
+ const letter = x === 'D' && y === 'D' ? 'D' : (x === 'A' || y === 'A' ? 'A' : 'M')
238
+ return [{ path, x: letter, y: ' ', ...keep }]
239
+ }
219
240
  // The index half takes the most descriptive letter it can keep: what is
220
241
  // already staged, else what the worktree showed, else a plain add.
221
242
  const letter = x !== ' ' && x !== '?' ? x : (y !== ' ' && y !== '?' ? y : 'M')