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.
- package/README.en.md +455 -443
- package/README.md +408 -396
- package/lib/client.js +8062 -2651
- package/lib/index.js +1058 -288
- package/lib/p2-router-fs.js +1 -1
- package/lib/p2-router-refs.js +89 -10
- package/lib/p2-router-spill.js +73 -1
- package/lib/p2-router-subprocess.js +18 -6
- package/lib/spill-retention-BwKEWrl5.js +115 -0
- package/lib/{ssh-proc-arI5lm4W.js → ssh-proc-VKWn_LZC.js} +17 -0
- package/lib/types/archive.d.ts +1 -1
- package/lib/types/changes/recorder.d.ts +34 -2
- package/lib/types/client/CodeEditor.d.ts +12 -0
- package/lib/types/client/ConnectionStatus.d.ts +17 -0
- package/lib/types/client/DirectoryFlow.d.ts +2 -0
- package/lib/types/client/DoctorPanel.d.ts +25 -0
- package/lib/types/client/QuickOpen.d.ts +17 -0
- package/lib/types/client/RemoteExplorer.d.ts +192 -1
- package/lib/types/client/RemoteRoot.d.ts +17 -0
- package/lib/types/client/SearchView.d.ts +55 -0
- package/lib/types/client/TerminalView.d.ts +38 -0
- package/lib/types/client/WorkspaceWizard.d.ts +17 -0
- package/lib/types/client/api.d.ts +54 -4
- package/lib/types/client/changes/undo-affordance.d.ts +16 -0
- package/lib/types/client/changes/undo-context.d.ts +14 -18
- package/lib/types/client/changes/undo-target.d.ts +78 -0
- package/lib/types/client/connection.d.ts +111 -0
- package/lib/types/client/doctor.d.ts +122 -0
- package/lib/types/client/download.d.ts +35 -5
- package/lib/types/client/downloads.d.ts +18 -1
- package/lib/types/client/file-open-probe.d.ts +64 -0
- package/lib/types/client/i18n.d.ts +1 -1
- package/lib/types/client/quickopen-model.d.ts +332 -0
- package/lib/types/client/scm/DiffView.d.ts +34 -0
- package/lib/types/client/scm/actions.d.ts +18 -0
- package/lib/types/client/scm/diff-model.d.ts +17 -1
- package/lib/types/client/scm/git-cache.d.ts +10 -2
- package/lib/types/client/scm/read-queue.d.ts +2 -1
- package/lib/types/client/scm/stage-queue.d.ts +13 -0
- package/lib/types/client/scm/status-map.d.ts +3 -1
- package/lib/types/client/store.d.ts +114 -5
- package/lib/types/client/vsc/FindWidget.d.ts +7 -0
- package/lib/types/client/vsc/save-shortcut.d.ts +57 -0
- package/lib/types/deploy.d.ts +44 -2
- package/lib/types/git-format.d.ts +15 -0
- package/lib/types/http.d.ts +44 -0
- package/lib/types/p2/file-refs.d.ts +39 -2
- package/lib/types/p2/helper-rpc.d.ts +26 -0
- package/lib/types/p2/router-spill.d.ts +19 -0
- package/lib/types/p2/router-subprocess.d.ts +2 -0
- package/lib/types/p2/spill-retention.d.ts +74 -0
- package/lib/types/p2/worlds.d.ts +11 -0
- package/lib/types/pool.d.ts +73 -11
- package/lib/types/protocol.d.ts +63 -0
- package/lib/types/routes.d.ts +18 -0
- package/lib/types/sftp.d.ts +114 -8
- package/lib/types/store.d.ts +34 -0
- package/lib/types/timeouts.d.ts +14 -0
- package/lib/{worlds-C6Xha1mQ.js → worlds-Be1YE2Ot.js} +727 -78
- package/package.json +1 -1
- package/src/archive.ts +41 -9
- package/src/changes/recorder.ts +227 -31
- package/src/changes/status.ts +37 -1
- package/src/client/CodeEditor.tsx +84 -2
- package/src/client/ConnectionStatus.tsx +130 -0
- package/src/client/DirectoryFlow.tsx +40 -5
- package/src/client/DoctorPanel.tsx +202 -0
- package/src/client/DownloadDock.tsx +13 -25
- package/src/client/EditorPane.tsx +291 -7
- package/src/client/HostsView.tsx +17 -8
- package/src/client/QuickOpen.tsx +371 -0
- package/src/client/RemoteDirectoryPicker.tsx +54 -3
- package/src/client/RemoteExplorer.tsx +879 -160
- package/src/client/RemoteRoot.tsx +178 -1
- package/src/client/SearchView.tsx +180 -6
- package/src/client/SettingsHosts.tsx +1 -1
- package/src/client/TerminalView.tsx +174 -9
- package/src/client/WorkspaceWizard.tsx +110 -16
- package/src/client/WorkspacesView.tsx +22 -6
- package/src/client/api.ts +197 -11
- package/src/client/changes/ChangesDock.tsx +35 -8
- package/src/client/changes/undo-affordance.ts +33 -0
- package/src/client/changes/undo-context.ts +14 -18
- package/src/client/changes/undo-target.ts +139 -0
- package/src/client/connection.ts +264 -0
- package/src/client/doctor.ts +441 -0
- package/src/client/download.ts +148 -12
- package/src/client/downloads.ts +43 -2
- package/src/client/file-open-probe.ts +83 -0
- package/src/client/i18n.ts +244 -0
- package/src/client/index.tsx +5 -2
- package/src/client/quickopen-model.ts +778 -0
- package/src/client/remote-file-open.ts +21 -33
- package/src/client/scm/DiffView.tsx +116 -6
- package/src/client/scm/ScmPanel.tsx +19 -0
- package/src/client/scm/actions.ts +34 -2
- package/src/client/scm/diff-model.ts +33 -37
- package/src/client/scm/git-cache.ts +61 -4
- package/src/client/scm/read-queue.ts +33 -2
- package/src/client/scm/stage-queue.ts +72 -1
- package/src/client/scm/status-map.ts +22 -1
- package/src/client/store.tsx +704 -21
- package/src/client/vsc/FindWidget.tsx +20 -0
- package/src/client/vsc/kit.tsx +115 -6
- package/src/client/vsc/reveal-line.ts +33 -14
- package/src/client/vsc/save-shortcut.ts +131 -0
- package/src/client/vsc/vsc.css +419 -0
- package/src/deploy.ts +185 -33
- package/src/git-format.ts +136 -22
- package/src/git-ops.ts +14 -6
- package/src/http.ts +80 -12
- package/src/importers.ts +80 -21
- package/src/index.ts +21 -1
- package/src/p2/file-refs.ts +112 -10
- package/src/p2/helper-rpc.ts +73 -36
- package/src/p2/router-spill.ts +96 -1
- package/src/p2/router-subprocess.ts +18 -5
- package/src/p2/spill-retention.ts +134 -0
- package/src/p2/ssh-proc.ts +22 -0
- package/src/p2/worlds.ts +24 -0
- package/src/pool.ts +329 -47
- package/src/protocol.ts +66 -0
- package/src/routes.ts +251 -43
- package/src/sftp.ts +486 -26
- package/src/store.ts +207 -85
- package/src/terminal.ts +38 -2
- package/src/timeouts.ts +14 -0
- package/src/tools.ts +14 -5
|
@@ -8,15 +8,21 @@
|
|
|
8
8
|
* remote write route.
|
|
9
9
|
*/
|
|
10
10
|
import { useCallback, useEffect, useMemo, useRef, useState, type ReactNode } from 'react'
|
|
11
|
-
import { api } from './api.ts'
|
|
11
|
+
import { api, fileReadTimeoutMs } from './api.ts'
|
|
12
|
+
import { clientDeadlineFor } from '../timeouts.ts'
|
|
13
|
+
import { diffText, type TextHunk } from '../changes/text-diff.ts'
|
|
12
14
|
import { CodeEditor, type CodeEditorHandle, type CodeEditorViewState } from './CodeEditor.tsx'
|
|
15
|
+
import { ConnectionStatusChip } from './ConnectionStatus.tsx'
|
|
16
|
+
import { isConnectionFailure, useConnectionStatus } from './connection.ts'
|
|
13
17
|
import { sameLocalDir } from './composer.ts'
|
|
14
18
|
import { editorViewStateOf, pruneEditorViewStates, registerLiveEditor, rememberEditorViewState } from './live-editor.ts'
|
|
15
19
|
import { useRemoteChatTarget } from './use-remote-chat-target.ts'
|
|
16
20
|
import { useExplorer, gotoChange, markChangeStale, undoChange, type EditorTab } from './store.tsx'
|
|
17
21
|
import { DiffView } from './scm/DiffView.tsx'
|
|
22
|
+
import { Btn } from './ui.tsx'
|
|
18
23
|
import { renderMarkdown } from './vsc/markdown.tsx'
|
|
19
24
|
import { langLabel, langFromPath } from './vsc/tokenize.ts'
|
|
25
|
+
import { installSaveShortcut } from './vsc/save-shortcut.ts'
|
|
20
26
|
import {
|
|
21
27
|
IconButton,
|
|
22
28
|
IconClose,
|
|
@@ -31,6 +37,53 @@ import {
|
|
|
31
37
|
toast,
|
|
32
38
|
} from './vsc/kit.tsx'
|
|
33
39
|
|
|
40
|
+
/** How many hunks of a conflict diff are rendered before the rest is summarised. */
|
|
41
|
+
const CONFLICT_DIFF_HUNKS = 20
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Reject a remote call that never answers.
|
|
45
|
+
*
|
|
46
|
+
* The host route has its own caps, but a stuck TCP/SSH round trip would
|
|
47
|
+
* otherwise leave the conflict-difference button spinning forever with no way to
|
|
48
|
+
* tell what happened. Same rule (and same shape) the store uses for its reads.
|
|
49
|
+
*/
|
|
50
|
+
function withDeadline<T>(promise: Promise<T>, ms: number, label: string): Promise<T> {
|
|
51
|
+
return new Promise<T>((resolve, reject) => {
|
|
52
|
+
const timer = setTimeout(() => reject(new Error(`${label} (${Math.round(ms / 1000)}s)`)), ms)
|
|
53
|
+
timer.unref?.()
|
|
54
|
+
promise.then(
|
|
55
|
+
(value) => {
|
|
56
|
+
clearTimeout(timer)
|
|
57
|
+
resolve(value)
|
|
58
|
+
},
|
|
59
|
+
(error: unknown) => {
|
|
60
|
+
clearTimeout(timer)
|
|
61
|
+
reject(error instanceof Error ? error : new Error(String(error)))
|
|
62
|
+
},
|
|
63
|
+
)
|
|
64
|
+
})
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** "the remote file changed at …, N bytes" — or that it is gone entirely. */
|
|
68
|
+
function conflictVersion(t: (key: string) => string, conflict: { mtime: number | null; size: number | null }): string {
|
|
69
|
+
if (conflict.mtime === null) return t('editor.conflictDeleted')
|
|
70
|
+
const base = t('editor.conflictBody').replace('{time}', new Date(conflict.mtime).toLocaleString())
|
|
71
|
+
return conflict.size === null ? base : `${base} · ${conflict.size} B`
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* The note above a conflict diff.
|
|
76
|
+
*
|
|
77
|
+
* An EMPTY hunk list has two very different causes — the contents are identical
|
|
78
|
+
* (only the timestamp moved) or the remote read failed — and rendering neither
|
|
79
|
+
* one leaves the user staring at a blank box that reads as "no differences".
|
|
80
|
+
*/
|
|
81
|
+
function conflictDiffNote(t: (key: string) => string, payload: { error?: string; hunks: TextHunk[] }): string {
|
|
82
|
+
if (payload.error !== undefined) return payload.error
|
|
83
|
+
if (payload.hunks.length === 0) return t('editor.conflictSame')
|
|
84
|
+
return t('editor.conflictDiffHead')
|
|
85
|
+
}
|
|
86
|
+
|
|
34
87
|
/** Which i18n key describes the tab's save state. */
|
|
35
88
|
function tabStatusKey(tab: { loading: boolean; saving: boolean; dirty: boolean }): string {
|
|
36
89
|
if (tab.loading) return 'common.loading'
|
|
@@ -130,6 +183,16 @@ export function EditorPane(props: { visible: boolean }): ReactNode {
|
|
|
130
183
|
&& chat.sessionWorkspacePath !== undefined
|
|
131
184
|
&& viewedAliasPath !== undefined
|
|
132
185
|
&& sameLocalDir(chat.sessionWorkspacePath, viewedAliasPath)
|
|
186
|
+
/**
|
|
187
|
+
* The link to this workspace's host is down.
|
|
188
|
+
*
|
|
189
|
+
* Tabs keep their loaded content in memory, so the editor still has something
|
|
190
|
+
* to show — but nothing can be written, and a reload would replace the buffer
|
|
191
|
+
* with an error. The pane therefore degrades to a read-only view of what it
|
|
192
|
+
* already has, with a banner that says so (Phase 2 of the connection work).
|
|
193
|
+
*/
|
|
194
|
+
const connection = useConnectionStatus()
|
|
195
|
+
const offline = connection?.state === 'error'
|
|
133
196
|
|
|
134
197
|
// Image data URL cache, keyed by path (remote reads are not free). Bounded —
|
|
135
198
|
// see `rememberRecent` / `dropOversized`.
|
|
@@ -145,6 +208,20 @@ export function EditorPane(props: { visible: boolean }): ReactNode {
|
|
|
145
208
|
useEffect(() => {
|
|
146
209
|
setTokenCount(undefined)
|
|
147
210
|
}, [activeTab?.id])
|
|
211
|
+
/**
|
|
212
|
+
* The "see the difference" payload of a refused save.
|
|
213
|
+
*
|
|
214
|
+
* Read on DEMAND (the 409 only carries the version, not the bytes): showing
|
|
215
|
+
* the remote content requires one more read, and doing that for every save
|
|
216
|
+
* would pay for a comparison the user mostly never asks for.
|
|
217
|
+
*/
|
|
218
|
+
const [conflictDiff, setConflictDiff] = useState<{
|
|
219
|
+
tabId: string
|
|
220
|
+
remoteMtime: number | null
|
|
221
|
+
hunks: TextHunk[]
|
|
222
|
+
/** The remote read itself failed: say so instead of claiming "no changes". */
|
|
223
|
+
error?: string
|
|
224
|
+
} | undefined>(undefined)
|
|
148
225
|
useEffect(() => {
|
|
149
226
|
const tab = activeTab
|
|
150
227
|
// A hidden pane may not spend a remote read on a picture nobody can see.
|
|
@@ -196,6 +273,26 @@ export function EditorPane(props: { visible: boolean }): ReactNode {
|
|
|
196
273
|
store.closeTab(tab.id)
|
|
197
274
|
}
|
|
198
275
|
|
|
276
|
+
/**
|
|
277
|
+
* Re-read one tab, refusing to throw away unsaved edits first.
|
|
278
|
+
*
|
|
279
|
+
* `reloadTab` replaces the buffer with the remote bytes; on a dirty tab that
|
|
280
|
+
* is the same data loss as closing without the guard, but it used to happen
|
|
281
|
+
* with no prompt at all (the toolbar button sits right next to Save).
|
|
282
|
+
*/
|
|
283
|
+
const reloadWithGuard = async (tab: EditorTab): Promise<void> => {
|
|
284
|
+
if (tab.dirty) {
|
|
285
|
+
const ok = await confirmDialog({
|
|
286
|
+
title: t('editor.reloadDirty'),
|
|
287
|
+
text: tab.rel,
|
|
288
|
+
danger: true,
|
|
289
|
+
okText: t('editor.discardReload'),
|
|
290
|
+
})
|
|
291
|
+
if (!ok) return
|
|
292
|
+
}
|
|
293
|
+
await store.reloadTab(tab.id)
|
|
294
|
+
}
|
|
295
|
+
|
|
199
296
|
const htmlDoc = useMemo(() => {
|
|
200
297
|
if (activeTab === undefined || !activeTab.html) return ''
|
|
201
298
|
return activeTab.text
|
|
@@ -313,6 +410,11 @@ export function EditorPane(props: { visible: boolean }): ReactNode {
|
|
|
313
410
|
const saveActive = async (): Promise<void> => {
|
|
314
411
|
const tab = activeTab
|
|
315
412
|
if (tab === undefined) return
|
|
413
|
+
if (offline) {
|
|
414
|
+
// Writing now can only fail; say why instead of surfacing a socket error.
|
|
415
|
+
toast(t('connection.saveBlocked'), true)
|
|
416
|
+
return
|
|
417
|
+
}
|
|
316
418
|
const text = editorRef.current?.getContent()
|
|
317
419
|
if (text === undefined) {
|
|
318
420
|
// Never let the store fall back to stale text: that destroys the edit.
|
|
@@ -327,6 +429,119 @@ export function EditorPane(props: { visible: boolean }): ReactNode {
|
|
|
327
429
|
await store.saveTab(tab.id, text)
|
|
328
430
|
}
|
|
329
431
|
|
|
432
|
+
/**
|
|
433
|
+
* Overwrite a remote file this buffer was refused on.
|
|
434
|
+
*
|
|
435
|
+
* A separate, explicitly confirmed action: the whole point of the guard is
|
|
436
|
+
* that nobody loses the other writer's work WITHOUT being told. Once the user
|
|
437
|
+
* has been told and still chooses their own version, that is their call — but
|
|
438
|
+
* it is a decision made on screen, never a default.
|
|
439
|
+
*/
|
|
440
|
+
const overwriteConflict = async (tab: EditorTab): Promise<void> => {
|
|
441
|
+
/**
|
|
442
|
+
* The live buffer, from whichever surface owns this tab: the file editor's
|
|
443
|
+
* CodeMirror mount when it is up, otherwise the tab's own handoff copy —
|
|
444
|
+
* which is where a DIFF pane keeps its text (its CodeEditor reports every
|
|
445
|
+
* change through `onBuffer`). An empty tab text is refused rather than
|
|
446
|
+
* written: for a diff pane that would save an empty file over the part of
|
|
447
|
+
* the tree the diff was about.
|
|
448
|
+
*/
|
|
449
|
+
const text = editorRef.current?.getContent() ?? (tab.text === '' ? undefined : tab.text)
|
|
450
|
+
if (text === undefined) {
|
|
451
|
+
toast(t('editor.needSource'), true)
|
|
452
|
+
return
|
|
453
|
+
}
|
|
454
|
+
const ok = await confirmDialog({
|
|
455
|
+
title: t('editor.conflictOverwriteTitle'),
|
|
456
|
+
text: tab.rel,
|
|
457
|
+
danger: true,
|
|
458
|
+
okText: t('editor.conflictOverwrite'),
|
|
459
|
+
})
|
|
460
|
+
if (!ok) return
|
|
461
|
+
setConflictDiff(undefined)
|
|
462
|
+
await store.saveTab(tab.id, text, { force: true })
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
/**
|
|
466
|
+
* Compare the remote's CURRENT bytes with the live buffer, in place.
|
|
467
|
+
*
|
|
468
|
+
* The 409 carries only the version, not the content, so this costs one read —
|
|
469
|
+
* paid on demand rather than on every save, because most conflicts are
|
|
470
|
+
* resolved by "reload" or by re-typing on top of the new version without ever
|
|
471
|
+
* looking at the difference.
|
|
472
|
+
*/
|
|
473
|
+
const showConflictDiff = async (tab: EditorTab): Promise<void> => {
|
|
474
|
+
const local = editorRef.current?.getContent() ?? tab.text
|
|
475
|
+
try {
|
|
476
|
+
// Bounded like every other remote read: a Host that never answers must not
|
|
477
|
+
// leave this button spinning forever with no message.
|
|
478
|
+
const read = await withDeadline(
|
|
479
|
+
api.fileOp.read(alias, tab.fullPath),
|
|
480
|
+
clientDeadlineFor(fileReadTimeoutMs()),
|
|
481
|
+
t('editor.readTimeout'),
|
|
482
|
+
)
|
|
483
|
+
setConflictDiff({
|
|
484
|
+
tabId: tab.id,
|
|
485
|
+
remoteMtime: read.mtime,
|
|
486
|
+
// Remote is the BEFORE side: '+' lines are what this buffer would add on
|
|
487
|
+
// top of what the other writer left behind.
|
|
488
|
+
hunks: diffText(read.text ?? '', local).hunks,
|
|
489
|
+
})
|
|
490
|
+
} catch (error) {
|
|
491
|
+
// The remote could not be read (deleted, permission, link down). Say that
|
|
492
|
+
// instead of showing an empty diff, which would read as "no differences".
|
|
493
|
+
setConflictDiff({
|
|
494
|
+
tabId: tab.id,
|
|
495
|
+
remoteMtime: null,
|
|
496
|
+
hunks: [],
|
|
497
|
+
error: error instanceof Error ? error.message : String(error),
|
|
498
|
+
})
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
/**
|
|
503
|
+
* Latest `saveActive`, for the window-level shortcut.
|
|
504
|
+
*
|
|
505
|
+
* The listener is installed ONCE and must act on the current render's tab /
|
|
506
|
+
* offline state, never on the render that happened to register it.
|
|
507
|
+
*/
|
|
508
|
+
const saveActiveRef = useRef(saveActive)
|
|
509
|
+
saveActiveRef.current = saveActive
|
|
510
|
+
/** The tab the shortcut would save right now (kept fresh by the line above). */
|
|
511
|
+
const saveShortcutTabRef = useRef<EditorTab | undefined>(activeTab)
|
|
512
|
+
saveShortcutTabRef.current = activeTab
|
|
513
|
+
|
|
514
|
+
/**
|
|
515
|
+
* Keep Ctrl/Cmd+S working when the caret is NOT inside CodeMirror.
|
|
516
|
+
*
|
|
517
|
+
* The editor's own keymap only fires while its view has focus, so after
|
|
518
|
+
* clicking the tab strip / info row / a sidebar panel the keystroke did
|
|
519
|
+
* nothing — silently, while the save button's title advertises `(Ctrl+S)`.
|
|
520
|
+
* The installer runs in the bubble phase and steps aside when CodeMirror
|
|
521
|
+
* already handled the key (`defaultPrevented`), so a focused editor still
|
|
522
|
+
* saves exactly once. Everything downstream is the existing save path
|
|
523
|
+
* (`saveActive` → `store.saveTab`), so the offline / truncated guards and the
|
|
524
|
+
* per-tab save queue apply unchanged.
|
|
525
|
+
*
|
|
526
|
+
* Only the VISIBLE surface registers: several `EditorPane`s can stay mounted at
|
|
527
|
+
* once (every native session tab keeps its `RemoteRoot` alive, and the
|
|
528
|
+
* sidebar/centre/floating surfaces overlap during a swap). The module already
|
|
529
|
+
* dedupes to ONE window listener and dispatches to a single surface; gating on
|
|
530
|
+
* `visible` additionally keeps a hidden pane from being the one that answers.
|
|
531
|
+
*/
|
|
532
|
+
useEffect(() => {
|
|
533
|
+
if (!props.visible) return
|
|
534
|
+
return installSaveShortcut(() => {
|
|
535
|
+
// A themed dialog owns its input: saving the file behind it would surprise.
|
|
536
|
+
if (typeof document !== 'undefined' && document.querySelector('.rvs-modal-mask') !== null) return undefined
|
|
537
|
+
const tab = saveShortcutTabRef.current
|
|
538
|
+
// Working-tree diffs are `DiffView`'s own onSave contract; previews have no
|
|
539
|
+
// buffer at all. `saveActive` would misreport both.
|
|
540
|
+
if (tab === undefined || tab.kind !== 'file' || tab.image || tab.binary) return undefined
|
|
541
|
+
return () => { void saveActiveRef.current() }
|
|
542
|
+
})
|
|
543
|
+
}, [props.visible])
|
|
544
|
+
|
|
330
545
|
if (tabs.length === 0) {
|
|
331
546
|
return (
|
|
332
547
|
<div className="rvs-pane grow rvs-edge">
|
|
@@ -395,6 +610,9 @@ export function EditorPane(props: { visible: boolean }): ReactNode {
|
|
|
395
610
|
</span>
|
|
396
611
|
)}
|
|
397
612
|
<span style={{ color: 'var(--rvs-fg3)' }}>{langLabel(langFromPath(activeTab.rel))}</span>
|
|
613
|
+
{/* Connection health sits where the build stamp does: it is the
|
|
614
|
+
surface the user is looking at while they work. */}
|
|
615
|
+
<ConnectionStatusChip compact />
|
|
398
616
|
{/* Build stamp + token count (see tsdown `define.__RVS_BUILD__`).
|
|
399
617
|
The GUI serves plugin bundles captured when `dsh web` started,
|
|
400
618
|
so the stamp says WHICH code is running, and the token count
|
|
@@ -412,25 +630,80 @@ export function EditorPane(props: { visible: boolean }): ReactNode {
|
|
|
412
630
|
<span className={`rvs-status ${tabStatusClass(activeTab)}`}>
|
|
413
631
|
{t(tabStatusKey(activeTab))}
|
|
414
632
|
</span>
|
|
415
|
-
<IconButton title={t('
|
|
633
|
+
<IconButton title={t('editor.reloadFile')} onClick={() => { void reloadWithGuard(activeTab) }} disabled={offline || activeTab.loading}>
|
|
416
634
|
<IconRefresh size={13} />
|
|
417
635
|
</IconButton>
|
|
418
636
|
<IconButton
|
|
419
637
|
title={`${t('editor.save')} (Ctrl+S)`}
|
|
420
638
|
onClick={() => { void saveActive() }}
|
|
421
|
-
disabled={activeTab.loading || activeTab.binary || activeTab.truncated || !activeTab.dirty}
|
|
639
|
+
disabled={offline || activeTab.loading || activeTab.binary || activeTab.truncated || !activeTab.dirty}
|
|
422
640
|
>
|
|
423
641
|
<IconSave size={13} />
|
|
424
642
|
</IconButton>
|
|
425
643
|
</>
|
|
426
644
|
)}
|
|
427
645
|
{activeTab.kind === 'diff' && (
|
|
428
|
-
<IconButton title={t('scm.reloadDiff')} onClick={() => { void
|
|
646
|
+
<IconButton title={t('scm.reloadDiff')} onClick={() => { void reloadWithGuard(activeTab) }} disabled={offline}>
|
|
429
647
|
<IconRefresh size={13} />
|
|
430
648
|
</IconButton>
|
|
431
649
|
)}
|
|
432
650
|
</div>
|
|
433
651
|
<div className="rvs-body">
|
|
652
|
+
{/*
|
|
653
|
+
A REFUSED save: the remote file moved on, so nothing was written.
|
|
654
|
+
This sits above the buffer (not in a toast) because it is a
|
|
655
|
+
decision the user has to make before the next Ctrl+S can succeed,
|
|
656
|
+
and it names the three ways out instead of only the error.
|
|
657
|
+
|
|
658
|
+
File AND diff tabs: a working-tree diff's after pane is the real
|
|
659
|
+
file on the remote and saves to it, so it carries the same guard
|
|
660
|
+
(see `snapshotDiffBaseline`).
|
|
661
|
+
*/}
|
|
662
|
+
{(activeTab.kind === 'file' || activeTab.kind === 'diff') && activeTab.conflict !== undefined && (
|
|
663
|
+
<div className="rvs-banner warn rvs-conflict" role="alert">
|
|
664
|
+
<div className="rvs-conflict-text">
|
|
665
|
+
<strong>{t('editor.conflictTitle')}</strong>{' '}
|
|
666
|
+
{conflictVersion(t, activeTab.conflict)}
|
|
667
|
+
</div>
|
|
668
|
+
<div className="rvs-conflict-actions">
|
|
669
|
+
<Btn onClick={() => { void showConflictDiff(activeTab) }}>{t('editor.conflictDiff')}</Btn>
|
|
670
|
+
<Btn onClick={() => { void reloadWithGuard(activeTab) }} disabled={offline}>{t('editor.conflictReload')}</Btn>
|
|
671
|
+
<Btn kind="danger" onClick={() => { void overwriteConflict(activeTab) }} disabled={offline}>{t('editor.conflictOverwrite')}</Btn>
|
|
672
|
+
<Btn onClick={() => { store.dismissConflict(activeTab.id); setConflictDiff(undefined) }}>{t('common.close')}</Btn>
|
|
673
|
+
</div>
|
|
674
|
+
</div>
|
|
675
|
+
)}
|
|
676
|
+
{/* The panel only exists while the CONFLICT does: resolving it (reload
|
|
677
|
+
or overwrite) clears the state, and a diff against the old remote
|
|
678
|
+
bytes would otherwise keep sitting there looking current. */}
|
|
679
|
+
{conflictDiff !== undefined && activeTab.conflict !== undefined && conflictDiff.tabId === activeTab.id && (
|
|
680
|
+
<div className="rvs-conflict-diff" role="region" aria-label={t('editor.conflictDiff')}>
|
|
681
|
+
<div className="rvs-conflict-diff-head">
|
|
682
|
+
{conflictDiffNote(t, conflictDiff)}
|
|
683
|
+
{/* Which remote version the comparison is against: the panel is
|
|
684
|
+
read on demand, so the file may already have moved again. */}
|
|
685
|
+
{conflictDiff.remoteMtime !== null && ` · ${new Date(conflictDiff.remoteMtime).toLocaleString()}`}
|
|
686
|
+
</div>
|
|
687
|
+
{conflictDiff.hunks.slice(0, CONFLICT_DIFF_HUNKS).map((hunk, hunkIndex) => (
|
|
688
|
+
<div key={`hunk-${hunkIndex}`} className="rvs-conflict-hunk">
|
|
689
|
+
<div className="rvs-conflict-hunk-head">{`@@ -${hunk.oldStart},${hunk.oldLines} +${hunk.newStart},${hunk.newLines} @@`}</div>
|
|
690
|
+
{hunk.lines.map((line, lineIndex) => (
|
|
691
|
+
<div
|
|
692
|
+
key={`line-${lineIndex}`}
|
|
693
|
+
className={`rvs-conflict-row${line.startsWith('+') ? ' add' : ''}${line.startsWith('-') ? ' del' : ''}`}
|
|
694
|
+
>
|
|
695
|
+
{line}
|
|
696
|
+
</div>
|
|
697
|
+
))}
|
|
698
|
+
</div>
|
|
699
|
+
))}
|
|
700
|
+
{conflictDiff.hunks.length > CONFLICT_DIFF_HUNKS && (
|
|
701
|
+
<div className="rvs-conflict-more">
|
|
702
|
+
{t('editor.conflictMoreHunks').replace('{count}', String(conflictDiff.hunks.length - CONFLICT_DIFF_HUNKS))}
|
|
703
|
+
</div>
|
|
704
|
+
)}
|
|
705
|
+
</div>
|
|
706
|
+
)}
|
|
434
707
|
{/*
|
|
435
708
|
Change navigation lives on the editor itself (top-right, floating)
|
|
436
709
|
rather than in the panel: once a file is open, that is where the
|
|
@@ -458,9 +731,19 @@ export function EditorPane(props: { visible: boolean }): ReactNode {
|
|
|
458
731
|
</div>
|
|
459
732
|
)}
|
|
460
733
|
{activeTab.loading && <div className="rvs-empty"><MiniSpinner /> {t('common.loading')}</div>}
|
|
461
|
-
{
|
|
734
|
+
{offline && activeTab.error === undefined && activeTab.loading === false && (
|
|
735
|
+
<div className="rvs-banner warn">
|
|
736
|
+
{t('connection.editorReadOnly')}
|
|
737
|
+
{activeTab.kind === 'file' && activeTab.dirty && ` ${t('connection.editorDirty')}`}
|
|
738
|
+
</div>
|
|
739
|
+
)}
|
|
740
|
+
{!activeTab.loading && activeTab.error !== undefined && (
|
|
741
|
+
<div className="rvs-banner error">
|
|
742
|
+
{offline && isConnectionFailure(activeTab.error) ? t('connection.readFailed') : activeTab.error}
|
|
743
|
+
</div>
|
|
744
|
+
)}
|
|
462
745
|
{!activeTab.loading && activeTab.error === undefined && activeTab.kind === 'diff' && (
|
|
463
|
-
<DiffView tab={activeTab} visible={props.visible} />
|
|
746
|
+
<DiffView tab={activeTab} visible={props.visible} offline={offline === true} />
|
|
464
747
|
)}
|
|
465
748
|
{!activeTab.loading && activeTab.error === undefined && activeTab.kind === 'file' && (
|
|
466
749
|
<>
|
|
@@ -497,7 +780,7 @@ export function EditorPane(props: { visible: boolean }): ReactNode {
|
|
|
497
780
|
savedText={activeTab.baseline}
|
|
498
781
|
path={activeTab.fullPath}
|
|
499
782
|
tabId={activeTab.id}
|
|
500
|
-
readOnly={activeTab.truncated}
|
|
783
|
+
readOnly={activeTab.truncated || offline}
|
|
501
784
|
visible={props.visible}
|
|
502
785
|
ctx={store.ctx}
|
|
503
786
|
sessionId={chat.sessionId}
|
|
@@ -520,6 +803,7 @@ export function EditorPane(props: { visible: boolean }): ReactNode {
|
|
|
520
803
|
undoLabel={(mark) => undoActionLabel(t, mark.kind)}
|
|
521
804
|
onSave={() => { void saveActive() }}
|
|
522
805
|
onDirty={(dirty) => store.updateTab(activeTab.id, { dirty })}
|
|
806
|
+
onBuffer={(tabId, text) => store.updateTab(tabId, { text })}
|
|
523
807
|
/>
|
|
524
808
|
</div>
|
|
525
809
|
)}
|
package/src/client/HostsView.tsx
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import { useState, type ReactNode } from 'react'
|
|
5
5
|
import type { RemoteDeployState, RemoteHostSummary } from '../protocol.ts'
|
|
6
6
|
import { RemoteApiError, api, type HostForm } from './api.ts'
|
|
7
|
+
import { DoctorPanel } from './DoctorPanel.tsx'
|
|
7
8
|
import { Btn, Field, Notice, Row, hairline, inputStyle } from './ui.tsx'
|
|
8
9
|
|
|
9
10
|
function err(e: unknown): string {
|
|
@@ -107,7 +108,7 @@ function HostFormView(props: {
|
|
|
107
108
|
value={keyPath}
|
|
108
109
|
disabled={props.busy}
|
|
109
110
|
onChange={(e) => setKeyPath(e.target.value)}
|
|
110
|
-
placeholder={props.initial?.auth === 'key' ? '
|
|
111
|
+
placeholder={props.initial?.auth === 'key' ? t('form.unchanged') : 'C:\\Users\\me\\.ssh\\id_ed25519'}
|
|
111
112
|
style={inputStyle}
|
|
112
113
|
/>
|
|
113
114
|
</Field>
|
|
@@ -117,7 +118,7 @@ function HostFormView(props: {
|
|
|
117
118
|
value={passphrase}
|
|
118
119
|
disabled={props.busy}
|
|
119
120
|
onChange={(e) => setPassphrase(e.target.value)}
|
|
120
|
-
placeholder={props.initial !== undefined ? '
|
|
121
|
+
placeholder={props.initial !== undefined ? t('form.unchangedWhenEmpty') : ''}
|
|
121
122
|
style={inputStyle}
|
|
122
123
|
/>
|
|
123
124
|
</Field>
|
|
@@ -129,7 +130,7 @@ function HostFormView(props: {
|
|
|
129
130
|
value={password}
|
|
130
131
|
disabled={props.busy}
|
|
131
132
|
onChange={(e) => setPassword(e.target.value)}
|
|
132
|
-
placeholder={props.initial?.auth === 'password' ? '
|
|
133
|
+
placeholder={props.initial?.auth === 'password' ? t('form.unchangedWhenEmpty') : ''}
|
|
133
134
|
style={inputStyle}
|
|
134
135
|
/>
|
|
135
136
|
</Field>
|
|
@@ -155,6 +156,8 @@ export function HostsView(props: {
|
|
|
155
156
|
const [error, setError] = useState<string | undefined>(undefined)
|
|
156
157
|
const [busy, setBusy] = useState<string | undefined>(undefined)
|
|
157
158
|
const [editing, setEditing] = useState<string | 'new' | null>(null)
|
|
159
|
+
/** Alias whose environment report is open; the panel mounts and probes. */
|
|
160
|
+
const [doctor, setDoctor] = useState<string | null>(null)
|
|
158
161
|
|
|
159
162
|
const say = (message: string): void => {
|
|
160
163
|
setNotice(message)
|
|
@@ -170,8 +173,8 @@ export function HostsView(props: {
|
|
|
170
173
|
api.testHost(alias).then(
|
|
171
174
|
(r) => {
|
|
172
175
|
setBusy(undefined)
|
|
173
|
-
if (r.ok) say(
|
|
174
|
-
else fail(`${alias}: ${r.error ?? '
|
|
176
|
+
if (r.ok) say(t('hosts.testOk').replace('{alias}', alias).replace('{ms}', String(r.durationMs)))
|
|
177
|
+
else fail(`${alias}: ${r.error ?? t('hosts.unknownError')}`)
|
|
175
178
|
},
|
|
176
179
|
(e: unknown) => { setBusy(undefined); fail(e) },
|
|
177
180
|
)
|
|
@@ -205,7 +208,7 @@ export function HostsView(props: {
|
|
|
205
208
|
if (!window.confirm(t('hosts.confirmDelete'))) return
|
|
206
209
|
setBusy(`del:${alias}`)
|
|
207
210
|
api.deleteHost(alias).then(
|
|
208
|
-
() => { setBusy(undefined); say(
|
|
211
|
+
() => { setBusy(undefined); say(t('hosts.deleted').replace('{alias}', alias)); props.onChanged() },
|
|
209
212
|
(e: unknown) => { setBusy(undefined); fail(e) },
|
|
210
213
|
)
|
|
211
214
|
}
|
|
@@ -217,7 +220,7 @@ export function HostsView(props: {
|
|
|
217
220
|
(report) => {
|
|
218
221
|
setBusy(undefined)
|
|
219
222
|
const skipped = report.skipped.map(s => `${s.alias}(${s.reason})`).join('; ')
|
|
220
|
-
say(
|
|
223
|
+
say(`${t('hosts.imported').replace('{count}', String(report.imported.length))}${report.imported.length > 0 ? `: ${report.imported.join(', ')}` : ''}${skipped !== '' ? t('hosts.importedSkipped').replace('{list}', skipped) : ''}`)
|
|
221
224
|
props.onChanged()
|
|
222
225
|
},
|
|
223
226
|
(e: unknown) => { setBusy(undefined); fail(e) },
|
|
@@ -239,7 +242,7 @@ export function HostsView(props: {
|
|
|
239
242
|
(h) => {
|
|
240
243
|
setBusy(undefined)
|
|
241
244
|
setEditing(null)
|
|
242
|
-
say(
|
|
245
|
+
say(t('hosts.saved').replace('{alias}', h.alias))
|
|
243
246
|
props.onChanged()
|
|
244
247
|
},
|
|
245
248
|
(e: unknown) => { setBusy(undefined); fail(e) },
|
|
@@ -294,6 +297,9 @@ export function HostsView(props: {
|
|
|
294
297
|
<Btn onClick={() => runPush(h.alias)} disabled={disabled}>
|
|
295
298
|
{busy === `push:${h.alias}` ? t('hosts.pushing') : t('hosts.push')}
|
|
296
299
|
</Btn>
|
|
300
|
+
<Btn onClick={() => { setDoctor(h.alias); setNotice(undefined); setError(undefined) }} disabled={disabled}>
|
|
301
|
+
{t('doctor.open')}
|
|
302
|
+
</Btn>
|
|
297
303
|
<Btn onClick={() => { setEditing(editing === h.alias ? null : h.alias); setNotice(undefined); setError(undefined) }} disabled={disabled}>
|
|
298
304
|
{t('hosts.edit')}
|
|
299
305
|
</Btn>
|
|
@@ -304,6 +310,9 @@ export function HostsView(props: {
|
|
|
304
310
|
)}
|
|
305
311
|
</div>
|
|
306
312
|
))}
|
|
313
|
+
{doctor !== null && (
|
|
314
|
+
<DoctorPanel key={doctor} t={t} alias={doctor} onClose={() => setDoctor(null)} />
|
|
315
|
+
)}
|
|
307
316
|
{editing === 'new' && (
|
|
308
317
|
<HostFormView t={t} busy={disabled} onSave={saveForm} onCancel={() => setEditing(null)} />
|
|
309
318
|
)}
|