dsh-remote-vs 0.23.0 → 0.25.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 +49 -15
- package/README.md +40 -14
- package/lib/client.js +45978 -43338
- package/lib/index.js +388 -90
- package/lib/p2-router-fs.js +1 -1
- package/lib/types/client/CodeEditor.d.ts +17 -0
- package/lib/types/client/EditorPane.d.ts +16 -5
- package/lib/types/client/FloatingPlaceholder.d.ts +16 -5
- package/lib/types/client/RemoteEditorView.d.ts +13 -10
- package/lib/types/client/RemoteRoot.d.ts +5 -5
- package/lib/types/client/SettingsHosts.d.ts +3 -0
- package/lib/types/client/TerminalSnippets.d.ts +36 -0
- package/lib/types/client/TerminalView.d.ts +1 -1
- package/lib/types/client/XTerm.d.ts +33 -0
- package/lib/types/client/api.d.ts +4 -1
- package/lib/types/client/auto-open-remote.d.ts +41 -0
- package/lib/types/client/editor-capability.d.ts +27 -0
- package/lib/types/client/i18n.d.ts +1 -1
- package/lib/types/client/store.d.ts +59 -4
- package/lib/types/client/terminal-input.d.ts +23 -0
- package/lib/types/client/terminal-snippets.d.ts +86 -0
- package/lib/types/client/use-remote-chat-target.d.ts +2 -0
- package/lib/types/client/view-settings.d.ts +40 -0
- package/lib/types/client/vsc/breadcrumb.d.ts +30 -0
- package/lib/types/client/vsc/editor-caret.d.ts +32 -0
- package/lib/types/client/vsc/editor-langs.d.ts +9 -0
- package/lib/types/client/vsc/editor-settings.d.ts +55 -0
- package/lib/types/client/vsc/image-preview.d.ts +36 -0
- package/lib/types/client/vsc/kit.d.ts +2 -0
- package/lib/types/client/vsc/terminal-clipboard.d.ts +15 -0
- package/lib/types/client/vsc/terminal-line.d.ts +25 -0
- package/lib/types/client/vsc/terminal-links.d.ts +62 -0
- package/lib/types/client/vsc/terminal-theme.d.ts +22 -0
- package/lib/types/client/vsc/terminal-writer.d.ts +52 -0
- package/lib/types/paths.d.ts +9 -0
- package/lib/types/pool.d.ts +25 -0
- package/lib/types/protocol.d.ts +35 -0
- package/lib/types/routes.d.ts +7 -0
- package/lib/types/terminal.d.ts +25 -1
- package/lib/types/view-settings.d.ts +26 -0
- package/lib/{worlds-DXdP4SMn.js → worlds-B7gEDBzC.js} +13 -1
- package/package.json +36 -36
- package/src/client/CodeEditor.tsx +54 -2
- package/src/client/EditorPane.tsx +485 -107
- package/src/client/FloatingPlaceholder.tsx +34 -5
- package/src/client/RemoteEditorView.tsx +14 -11
- package/src/client/RemoteRoot.tsx +20 -125
- package/src/client/SettingsHosts.tsx +81 -3
- package/src/client/TerminalSnippets.tsx +357 -0
- package/src/client/TerminalView.tsx +50 -1
- package/src/client/XTerm.tsx +228 -58
- package/src/client/api.ts +7 -0
- package/src/client/auto-open-remote.ts +439 -0
- package/src/client/editor-capability.ts +42 -0
- package/src/client/i18n.ts +158 -6
- package/src/client/index.tsx +30 -6
- package/src/client/store.tsx +165 -13
- package/src/client/terminal-input.ts +44 -0
- package/src/client/terminal-snippets.ts +216 -0
- package/src/client/use-remote-chat-target.ts +1 -1
- package/src/client/view-settings.ts +99 -0
- package/src/client/vsc/breadcrumb.tsx +251 -0
- package/src/client/vsc/editor-caret.ts +30 -0
- package/src/client/vsc/editor-langs.ts +20 -0
- package/src/client/vsc/editor-settings.ts +146 -0
- package/src/client/vsc/editor-theme.ts +4 -5
- package/src/client/vsc/image-preview.tsx +110 -0
- package/src/client/vsc/kit.tsx +20 -1
- package/src/client/vsc/terminal-clipboard.ts +19 -0
- package/src/client/vsc/terminal-line.ts +101 -0
- package/src/client/vsc/terminal-links.ts +166 -0
- package/src/client/vsc/terminal-theme.ts +71 -0
- package/src/client/vsc/terminal-writer.ts +112 -0
- package/src/client/vsc/vsc.css +687 -48
- package/src/index.ts +6 -0
- package/src/paths.ts +13 -0
- package/src/pool.ts +99 -27
- package/src/protocol.ts +45 -0
- package/src/routes.ts +47 -0
- package/src/terminal.ts +160 -6
- package/src/view-settings.ts +133 -0
|
@@ -1,17 +1,46 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* What the centre conversation view and the sidebar fallback show while the
|
|
3
|
-
* editor
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
3
|
+
* editor lives somewhere else: the editor itself is a single instance, so these
|
|
4
|
+
* surfaces must not mount a second one (that would be two live CodeMirror
|
|
5
|
+
* buffers for one tab — the exact defect `EditorPane`'s header warns about).
|
|
6
|
+
*
|
|
7
|
+
* Three such places exist now that the DOCKED sidebar pane is the default seat:
|
|
8
|
+
* - `float`: the editor is popped out into the frame-wide window;
|
|
9
|
+
* - `sidebar`: the editor is docked in the sidebar column, and the
|
|
10
|
+
* conversation-view tab is only its optional full-width seat;
|
|
11
|
+
* - `center`: the reverse — the conversation tab owns the editor, and the
|
|
12
|
+
* sidebar's editor page explains how to bring it back.
|
|
13
|
+
* A button per mode keeps the surface from looking broken.
|
|
7
14
|
*/
|
|
8
15
|
import type { ReactNode } from 'react'
|
|
9
16
|
import { useExplorer } from './store.tsx'
|
|
10
17
|
import { Btn } from './ui.tsx'
|
|
11
18
|
|
|
12
|
-
|
|
19
|
+
/** Which seat currently owns the editor. */
|
|
20
|
+
export type PlaceholderMode = 'float' | 'sidebar' | 'center'
|
|
21
|
+
|
|
22
|
+
export function FloatingEditorPlaceholder(props: { mode?: PlaceholderMode }): ReactNode {
|
|
13
23
|
const store = useExplorer()
|
|
14
24
|
const t = store.t
|
|
25
|
+
const mode = props.mode ?? 'float'
|
|
26
|
+
if (mode === 'center') {
|
|
27
|
+
return (
|
|
28
|
+
<div className="rvs-float-placeholder">
|
|
29
|
+
<div className="rvs-float-placeholder-title">{t('float.centerElsewhere')}</div>
|
|
30
|
+
<div className="rvs-float-placeholder-text">{t('float.centerElsewhereHint')}</div>
|
|
31
|
+
<Btn kind="primary" onClick={() => { store.dockEditorSidebar() }}>{t('editor.dockToSidebar')}</Btn>
|
|
32
|
+
</div>
|
|
33
|
+
)
|
|
34
|
+
}
|
|
35
|
+
if (mode === 'sidebar') {
|
|
36
|
+
return (
|
|
37
|
+
<div className="rvs-float-placeholder">
|
|
38
|
+
<div className="rvs-float-placeholder-title">{t('float.dockedElsewhere')}</div>
|
|
39
|
+
<div className="rvs-float-placeholder-text">{t('float.dockedElsewhereHint')}</div>
|
|
40
|
+
<Btn kind="primary" onClick={() => { store.openEditorInCenter() }}>{t('float.openHere')}</Btn>
|
|
41
|
+
</div>
|
|
42
|
+
)
|
|
43
|
+
}
|
|
15
44
|
return (
|
|
16
45
|
<div className="rvs-float-placeholder">
|
|
17
46
|
<div className="rvs-float-placeholder-title">{t('float.placeholder')}</div>
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The conversation-view tab: the same editor tab strip, previews
|
|
3
|
-
*
|
|
2
|
+
* The conversation-view tab: the same editor (tab strip, previews, diff, status
|
|
3
|
+
* bar) mounted next to 对话 / 轨迹 at full width.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
5
|
+
* This is the OPTIONAL seat now: the docked sidebar pane is the default one, so
|
|
6
|
+
* a file click lands there and this tab shows a "docked in the sidebar"
|
|
7
|
+
* placeholder until the editor's own surface button moves it here. Both seats
|
|
8
|
+
* read the same module-level store, so a diff opened from source control
|
|
9
|
+
* appears here too and a save here repaints the sidebar's change list.
|
|
9
10
|
*
|
|
10
11
|
* While the editor floats (`editorSurface === 'float'`) this tab is NOT the
|
|
11
12
|
* editor's mount any more, so it renders a placeholder instead: mounting a
|
|
@@ -19,10 +20,12 @@ import { useBootstrap, useExplorer } from './store.tsx'
|
|
|
19
20
|
import { DialogHost } from './vsc/kit.tsx'
|
|
20
21
|
|
|
21
22
|
/**
|
|
22
|
-
* The conversation-view body. The editor surface flag is
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
* the
|
|
23
|
+
* The conversation-view body. The editor surface flag is the STORE's (the
|
|
24
|
+
* docked pane is the default; this view renders only while the user has moved
|
|
25
|
+
* the editor here), and deliberately not derived from this component's own
|
|
26
|
+
* mount: the view is unmounted while another conversation tab is selected, so
|
|
27
|
+
* inferring the surface from mount/unmount would flip the sidebar's rail — and
|
|
28
|
+
* its editor — on every host tab switch.
|
|
26
29
|
*/
|
|
27
30
|
export function RemoteEditorView(props: { ctx: Context }): ReactNode {
|
|
28
31
|
useBootstrap(props.ctx)
|
|
@@ -51,7 +54,7 @@ export function RemoteEditorView(props: { ctx: Context }): ReactNode {
|
|
|
51
54
|
</span>
|
|
52
55
|
)}
|
|
53
56
|
</div>
|
|
54
|
-
{store.editorSurface === 'center' ? <EditorPane visible /> : <FloatingEditorPlaceholder />}
|
|
57
|
+
{store.editorSurface === 'center' ? <EditorPane visible /> : <FloatingEditorPlaceholder mode={store.floatOpen ? 'float' : 'sidebar'} />}
|
|
55
58
|
</div>
|
|
56
59
|
</div>
|
|
57
60
|
</>
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
* Sidebar surface (better-sidebar tab, or the native right-Sidebar fallback):
|
|
3
3
|
* a VS Code-style activity rail plus one column that shows the active view.
|
|
4
4
|
*
|
|
5
|
-
* The editor
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
5
|
+
* The DOCKED editor is the default seat (`editorSurface === 'sidebar'`) and it
|
|
6
|
+
* is a FULL-COLUMN rail page — one view at a time, like the local sidebar
|
|
7
|
+
* plugin: opening a file switches the column to the editor, and closing its last
|
|
8
|
+
* file switches back to the directory. The conversation-view tab next to 轨迹 is
|
|
9
|
+
* the OPTIONAL full-width seat the editor's own button switches to.
|
|
10
10
|
*/
|
|
11
11
|
import type { Context } from '@deepseek-ai/cordis'
|
|
12
12
|
import { useCallback, useEffect, useRef, useState, type ReactNode } from 'react'
|
|
@@ -41,7 +41,6 @@ import {
|
|
|
41
41
|
|
|
42
42
|
type RailView = 'explorer' | 'search' | 'scm' | 'history' | 'editor' | 'terminal' | 'ports' | 'monitor' | 'workspaces'
|
|
43
43
|
|
|
44
|
-
const SPLIT_KEY = 'dsh-remote-vs.split'
|
|
45
44
|
const HIDDEN_KEY = 'dsh-remote-vs.showHidden'
|
|
46
45
|
|
|
47
46
|
/**
|
|
@@ -105,18 +104,6 @@ function Shell(props: { ctx: Context; visible: boolean }): ReactNode {
|
|
|
105
104
|
return false
|
|
106
105
|
}
|
|
107
106
|
})
|
|
108
|
-
const [split, setSplit] = useState<number>(() => {
|
|
109
|
-
try {
|
|
110
|
-
const saved = Number(localStorage.getItem(SPLIT_KEY))
|
|
111
|
-
return Number.isFinite(saved) && saved > 0.15 && saved < 0.9 ? saved : 0.45
|
|
112
|
-
} catch {
|
|
113
|
-
return 0.45
|
|
114
|
-
}
|
|
115
|
-
})
|
|
116
|
-
const splitRef = useRef(split)
|
|
117
|
-
const [dragging, setDragging] = useState(false)
|
|
118
|
-
const dragRef = useRef<{ startY: number; startRatio: number } | undefined>(undefined)
|
|
119
|
-
const columnRef = useRef<HTMLDivElement>(null)
|
|
120
107
|
|
|
121
108
|
/**
|
|
122
109
|
* Visibility is measured, not promised.
|
|
@@ -339,27 +326,6 @@ function Shell(props: { ctx: Context; visible: boolean }): ReactNode {
|
|
|
339
326
|
})
|
|
340
327
|
}, [target.sessionId, target.sessionWorkspacePath, store.ready, store.workspaces, store.aliasPaths])
|
|
341
328
|
|
|
342
|
-
/**
|
|
343
|
-
* The mount surface owns the editor, so a persisted `view === 'editor'` is
|
|
344
|
-
* only reachable where the sidebar still holds the editor.
|
|
345
|
-
*
|
|
346
|
-
* `view` is restored from localStorage (where 'editor' is an allowed value)
|
|
347
|
-
* and `editorSurface` starts as 'sidebar' before index.tsx flips it once the
|
|
348
|
-
* conversation-view slot registers. A profile that last used the fallback
|
|
349
|
-
* layout therefore came back with `view === 'editor'` while the rail button
|
|
350
|
-
* that owns it was gone AND the centre tab mounted a second EditorPane on
|
|
351
|
-
* the same store tab — two live buffers with independent undo state, the one
|
|
352
|
-
* state this file declares must never happen.
|
|
353
|
-
*
|
|
354
|
-
* Only the CENTRE pixel surface triggers this redirect. While the editor
|
|
355
|
-
* floats the sidebar keeps whatever view it had: the editor panel renders a
|
|
356
|
-
* "docked elsewhere" placeholder (see panelFor), and on docking the user
|
|
357
|
-
* lands back where they were.
|
|
358
|
-
*/
|
|
359
|
-
useEffect(() => {
|
|
360
|
-
if (store.editorSurface === 'center' && view === 'editor') go('explorer')
|
|
361
|
-
}, [store.editorSurface, view, go])
|
|
362
|
-
|
|
363
329
|
useEffect(() => {
|
|
364
330
|
try {
|
|
365
331
|
localStorage.setItem(HIDDEN_KEY, showHidden ? '1' : '0')
|
|
@@ -368,42 +334,6 @@ function Shell(props: { ctx: Context; visible: boolean }): ReactNode {
|
|
|
368
334
|
}
|
|
369
335
|
}, [showHidden])
|
|
370
336
|
|
|
371
|
-
const onDividerDown = (e: React.PointerEvent<HTMLDivElement>): void => {
|
|
372
|
-
if (e.button !== 0) return
|
|
373
|
-
e.preventDefault()
|
|
374
|
-
try {
|
|
375
|
-
e.currentTarget.setPointerCapture(e.pointerId)
|
|
376
|
-
} catch {
|
|
377
|
-
// Older engine: the buttons gate below covers it.
|
|
378
|
-
}
|
|
379
|
-
dragRef.current = { startY: e.clientY, startRatio: splitRef.current }
|
|
380
|
-
setDragging(true)
|
|
381
|
-
}
|
|
382
|
-
const onDividerMove = (e: React.PointerEvent<HTMLDivElement>): void => {
|
|
383
|
-
const drag = dragRef.current
|
|
384
|
-
if (drag === undefined) return
|
|
385
|
-
if ((e.buttons & 1) === 0) {
|
|
386
|
-
dragRef.current = undefined
|
|
387
|
-
setDragging(false)
|
|
388
|
-
return
|
|
389
|
-
}
|
|
390
|
-
const total = columnRef.current?.clientHeight ?? 0
|
|
391
|
-
if (total < 200) return
|
|
392
|
-
const next = Math.min(0.88, Math.max(0.12, drag.startRatio + (e.clientY - drag.startY) / total))
|
|
393
|
-
splitRef.current = next
|
|
394
|
-
setSplit(next)
|
|
395
|
-
}
|
|
396
|
-
const onDividerEnd = (): void => {
|
|
397
|
-
if (dragRef.current === undefined) return
|
|
398
|
-
dragRef.current = undefined
|
|
399
|
-
setDragging(false)
|
|
400
|
-
try {
|
|
401
|
-
localStorage.setItem(SPLIT_KEY, String(splitRef.current))
|
|
402
|
-
} catch {
|
|
403
|
-
// Ignore.
|
|
404
|
-
}
|
|
405
|
-
}
|
|
406
|
-
|
|
407
337
|
if (!store.ready) {
|
|
408
338
|
return (
|
|
409
339
|
<div className="rvs-root">
|
|
@@ -413,8 +343,6 @@ function Shell(props: { ctx: Context; visible: boolean }): ReactNode {
|
|
|
413
343
|
}
|
|
414
344
|
|
|
415
345
|
const editorInSidebar = store.editorSurface === 'sidebar'
|
|
416
|
-
const browsing = view === 'explorer' || view === 'search' || view === 'scm' || view === 'history'
|
|
417
|
-
const showEditorWithView = editorInSidebar && browsing && store.tabs.length > 0
|
|
418
346
|
|
|
419
347
|
/**
|
|
420
348
|
* One panel body. Every visited panel stays MOUNTED (hidden by CSS), which
|
|
@@ -454,17 +382,17 @@ function Shell(props: { ctx: Context; visible: boolean }): ReactNode {
|
|
|
454
382
|
</div>
|
|
455
383
|
)
|
|
456
384
|
case 'editor':
|
|
457
|
-
// The
|
|
458
|
-
//
|
|
459
|
-
//
|
|
385
|
+
// The docked editor is the DEFAULT seat: opening a file switches this
|
|
386
|
+
// column to this page, so the editor owns the whole sidebar instead of
|
|
387
|
+
// sharing it with the tree. It must not render while the centre surface
|
|
460
388
|
// or the floating window owns the editor: all of them read the same
|
|
461
389
|
// store, so two live editors for one tab fight over the scroll position
|
|
462
390
|
// and the hidden one — sitting at scrollTop 0 — wins, which is exactly
|
|
463
391
|
// why a tab switch kept snapping back to the top of the file.
|
|
464
392
|
if (editorInSidebar) return <EditorPane visible={panelLive('editor')} />
|
|
465
|
-
//
|
|
466
|
-
//
|
|
467
|
-
return store.floatOpen ?
|
|
393
|
+
// The editor lives elsewhere: the panel stays reachable (so docking
|
|
394
|
+
// returns here) but says where it went and how to bring it back.
|
|
395
|
+
return <FloatingEditorPlaceholder mode={store.floatOpen ? 'float' : 'center'} />
|
|
468
396
|
default:
|
|
469
397
|
return (
|
|
470
398
|
<RemoteExplorer
|
|
@@ -476,22 +404,16 @@ function Shell(props: { ctx: Context; visible: boolean }): ReactNode {
|
|
|
476
404
|
}
|
|
477
405
|
}
|
|
478
406
|
|
|
479
|
-
// Without a conversation-view slot the editor has no center tab, so it keeps
|
|
480
|
-
// its rail entry (and the split) — the older layout, still fully reachable.
|
|
481
|
-
const editorInStack = editorInSidebar && !showEditorWithView
|
|
482
|
-
|
|
483
407
|
const panel = (
|
|
484
408
|
<div className="rvs-pane grow">
|
|
485
409
|
{[...mounted].map(id => (
|
|
486
410
|
<div
|
|
487
411
|
key={id}
|
|
488
412
|
className="rvs-viewslot"
|
|
489
|
-
//
|
|
490
|
-
//
|
|
491
|
-
//
|
|
492
|
-
|
|
493
|
-
// that is also what keeps two live buffers from fighting.
|
|
494
|
-
style={{ display: view === id && !(showEditorWithView && id === 'editor') ? 'flex' : 'none' }}
|
|
413
|
+
// Kept MOUNTED and only hidden: removing a panel from this list
|
|
414
|
+
// unmounted it, so switching rail pages rebuilt the editor and
|
|
415
|
+
// dropped its local undo/scroll state (and re-listed the tree).
|
|
416
|
+
style={{ display: view === id ? 'flex' : 'none' }}
|
|
495
417
|
>
|
|
496
418
|
{panelFor(id)}
|
|
497
419
|
</div>
|
|
@@ -523,14 +445,15 @@ function Shell(props: { ctx: Context; visible: boolean }): ReactNode {
|
|
|
523
445
|
{railButton('scm', t('tab.git'), <IconBranch size={17} />, store.buckets.total)}
|
|
524
446
|
{railButton('history', t('tab.history'), <IconHistory size={17} />)}
|
|
525
447
|
<div className="rvs-rail-sep" />
|
|
526
|
-
{
|
|
527
|
-
|
|
448
|
+
{/* Always present, like the local sidebar: with no file open it is the
|
|
449
|
+
empty state, and a click from anywhere lands on the editor again. */}
|
|
450
|
+
{railButton('editor', store.activeTab?.rel.split('/').pop() ?? t('tab.editor'), <IconDiff size={17} />, store.tabs.length)}
|
|
528
451
|
{railButton('terminal', t('tab.terminal'), <IconTerminal size={17} />)}
|
|
529
452
|
{railButton('ports', t('tab.ports'), <IconPlug size={17} />)}
|
|
530
453
|
{railButton('monitor', t('tab.monitor'), <IconMonitor size={17} />)}
|
|
531
454
|
{railButton('workspaces', t('tab.workspaces'), <IconServer size={17} />, store.workspaces.length)}
|
|
532
455
|
</div>
|
|
533
|
-
<div className="rvs-column"
|
|
456
|
+
<div className="rvs-column">
|
|
534
457
|
<div className="rvs-globalbar">
|
|
535
458
|
<select
|
|
536
459
|
className="rvs-select"
|
|
@@ -553,37 +476,9 @@ function Shell(props: { ctx: Context; visible: boolean }): ReactNode {
|
|
|
553
476
|
{store.gitBusy && <MiniSpinner />}
|
|
554
477
|
</div>
|
|
555
478
|
{store.error !== undefined && <div className="rvs-banner error">{store.error}</div>}
|
|
556
|
-
|
|
557
|
-
It used to swap a Fragment for a `div` here, and React reconciles
|
|
558
|
-
by type — so every flip deleted and remounted the whole subtree,
|
|
559
|
-
which is the kept-alive panel stack (`panel` below). Consequences
|
|
560
|
-
were exactly what the keep-alive design exists to prevent: the
|
|
561
|
-
explorer re-listed over SFTP and lost its expansion, and every
|
|
562
|
-
xterm was torn down and rebuilt, closing its WebSocket and
|
|
563
|
-
orphaning a tab whose session id had not arrived yet. Same element,
|
|
564
|
-
different props, always. */}
|
|
565
|
-
<div
|
|
566
|
-
className="rvs-pane"
|
|
567
|
-
style={showEditorWithView ? { height: `${Math.round(split * 1000) / 10}%`, flex: 'none', minHeight: 0 } : { flex: 1, minHeight: 0 }}
|
|
568
|
-
>
|
|
479
|
+
<div className="rvs-pane" style={{ flex: 1, minHeight: 0 }}>
|
|
569
480
|
{panel}
|
|
570
481
|
</div>
|
|
571
|
-
{showEditorWithView && (
|
|
572
|
-
<>
|
|
573
|
-
<div
|
|
574
|
-
className="rvs-vsplit-handle"
|
|
575
|
-
data-dragging={dragging ? 'true' : 'false'}
|
|
576
|
-
onPointerDown={onDividerDown}
|
|
577
|
-
onPointerMove={onDividerMove}
|
|
578
|
-
onPointerUp={onDividerEnd}
|
|
579
|
-
onPointerCancel={onDividerEnd}
|
|
580
|
-
title={t('editor.resizeHint')}
|
|
581
|
-
/>
|
|
582
|
-
<div className="rvs-pane grow">
|
|
583
|
-
<EditorPane visible={live} />
|
|
584
|
-
</div>
|
|
585
|
-
</>
|
|
586
|
-
)}
|
|
587
482
|
</div>
|
|
588
483
|
</div>
|
|
589
484
|
)
|
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
* Settings section occupants (`settings.section`, ids `remote-hosts` and
|
|
3
3
|
* `remote-workspaces`): the full host manager plus the binding list/wizard,
|
|
4
4
|
* living in the DSH Settings dialog instead of the Remote tab.
|
|
5
|
+
* The `remote-hosts` page also carries the plugin's two view preferences at the
|
|
6
|
+
* bottom (auto-open the remote workspace, and its share of the frame width) —
|
|
7
|
+
* see `auto-open-remote.ts` for the behaviour they drive.
|
|
5
8
|
* Self-contained: each section fetches its own data so they work without any
|
|
6
9
|
* injected face or sidebar.
|
|
7
10
|
*
|
|
@@ -11,10 +14,19 @@
|
|
|
11
14
|
*/
|
|
12
15
|
import { useCallback, useEffect, useState, type ReactNode } from 'react'
|
|
13
16
|
import type { SettingsSectionOwnerProps } from '@deepseek-ai/dsh-client-ui-settings/client'
|
|
14
|
-
import
|
|
17
|
+
import {
|
|
18
|
+
REMOTE_VIEW_SETTINGS_DEFAULTS,
|
|
19
|
+
REMOTE_VIEW_WIDTH_MAX,
|
|
20
|
+
REMOTE_VIEW_WIDTH_MIN,
|
|
21
|
+
type RemoteHostSummary,
|
|
22
|
+
type RemoteRoutingStatus,
|
|
23
|
+
type RemoteViewSettings,
|
|
24
|
+
type RemoteWorkspaceBinding,
|
|
25
|
+
} from '../protocol.ts'
|
|
15
26
|
import { RemoteApiError, api } from './api.ts'
|
|
16
27
|
import { HostsView } from './HostsView.tsx'
|
|
17
28
|
import { refreshAll as refreshSidebarStore } from './store.tsx'
|
|
29
|
+
import { loadViewSettings, saveViewSettings } from './view-settings.ts'
|
|
18
30
|
import { WorkspacesView } from './WorkspacesView.tsx'
|
|
19
31
|
import { detectLang, makeT } from './i18n.ts'
|
|
20
32
|
import { Notice, Row, hairline, optionStyle, selectStyle } from './ui.tsx'
|
|
@@ -27,14 +39,23 @@ export function SettingsHostsSection(_props: SettingsSectionOwnerProps): ReactNo
|
|
|
27
39
|
const [version, setVersion] = useState('')
|
|
28
40
|
const [saving, setSaving] = useState(false)
|
|
29
41
|
const [error, setError] = useState<string | undefined>(undefined)
|
|
42
|
+
/** View preferences (the page's third block); defaults until the host answers. */
|
|
43
|
+
const [view, setView] = useState<RemoteViewSettings>(() => ({ ...REMOTE_VIEW_SETTINGS_DEFAULTS }))
|
|
44
|
+
/** The width slider's live value while dragging; persisted on release. */
|
|
45
|
+
const [ratio, setRatio] = useState(REMOTE_VIEW_SETTINGS_DEFAULTS.remoteWorkspaceWidthRatio)
|
|
46
|
+
const [viewSaving, setViewSaving] = useState(false)
|
|
30
47
|
|
|
31
48
|
const refresh = useCallback(() => {
|
|
32
49
|
setError(undefined)
|
|
33
|
-
Promise.all([api.getHosts(), api.getWorkspaces()]).then(
|
|
34
|
-
([rows, w]) => {
|
|
50
|
+
Promise.all([api.getHosts(), api.getWorkspaces(), loadViewSettings()]).then(
|
|
51
|
+
([rows, w, settings]) => {
|
|
35
52
|
setHosts(rows)
|
|
36
53
|
setMode(w.mode)
|
|
37
54
|
setVersion(w.version)
|
|
55
|
+
if (settings !== undefined) {
|
|
56
|
+
setView(settings)
|
|
57
|
+
setRatio(settings.remoteWorkspaceWidthRatio)
|
|
58
|
+
}
|
|
38
59
|
},
|
|
39
60
|
(e: unknown) => setError(e instanceof RemoteApiError ? e.message : String(e)),
|
|
40
61
|
)
|
|
@@ -69,6 +90,29 @@ export function SettingsHostsSection(_props: SettingsSectionOwnerProps): ReactNo
|
|
|
69
90
|
).finally(() => setSaving(false))
|
|
70
91
|
}
|
|
71
92
|
|
|
93
|
+
/**
|
|
94
|
+
* Persist one view preference. The module cache behind `saveViewSettings`
|
|
95
|
+
* publishes the answer, so the frame-wide auto-open behaviour sees the new
|
|
96
|
+
* value in this same page (a width save then applies to an open panel).
|
|
97
|
+
*/
|
|
98
|
+
const saveView = useCallback((patch: Partial<RemoteViewSettings>): void => {
|
|
99
|
+
setViewSaving(true)
|
|
100
|
+
setError(undefined)
|
|
101
|
+
saveViewSettings(patch).then(
|
|
102
|
+
(next) => {
|
|
103
|
+
setView(next)
|
|
104
|
+
setRatio(next.remoteWorkspaceWidthRatio)
|
|
105
|
+
},
|
|
106
|
+
(e: unknown) => setError(e instanceof RemoteApiError ? e.message : String(e)),
|
|
107
|
+
).finally(() => setViewSaving(false))
|
|
108
|
+
}, [])
|
|
109
|
+
|
|
110
|
+
/** Commit the slider on release/keyboard blur, not on every drag tick. */
|
|
111
|
+
const commitRatio = (): void => {
|
|
112
|
+
if (viewSaving || ratio === view.remoteWorkspaceWidthRatio) return
|
|
113
|
+
saveView({ remoteWorkspaceWidthRatio: ratio })
|
|
114
|
+
}
|
|
115
|
+
|
|
72
116
|
return (
|
|
73
117
|
<div style={{ padding: '4px 2px', fontSize: 13, lineHeight: 1.5 }}>
|
|
74
118
|
<div style={{ ...hairline, borderTop: 'none', borderBottom: '1px solid rgba(127,127,127,.25)', marginBottom: 10, paddingBottom: 8 }}>
|
|
@@ -95,6 +139,40 @@ export function SettingsHostsSection(_props: SettingsSectionOwnerProps): ReactNo
|
|
|
95
139
|
</div>
|
|
96
140
|
{error !== undefined && <Notice kind="error">{error}</Notice>}
|
|
97
141
|
<HostsView t={t} hosts={hosts} onChanged={reload} />
|
|
142
|
+
<div style={{ ...hairline, marginTop: 12, paddingTop: 10 }}>
|
|
143
|
+
<div style={{ fontSize: 12, opacity: 0.75, marginBottom: 6 }}>{t('viewSettings.title')}</div>
|
|
144
|
+
<Row>
|
|
145
|
+
<label style={{ display: 'flex', alignItems: 'center', gap: 6, fontSize: 12, opacity: viewSaving ? 0.5 : 1 }}>
|
|
146
|
+
<input
|
|
147
|
+
type="checkbox"
|
|
148
|
+
checked={view.autoOpenRemoteWorkspace}
|
|
149
|
+
disabled={viewSaving}
|
|
150
|
+
onChange={(e) => saveView({ autoOpenRemoteWorkspace: e.target.checked })}
|
|
151
|
+
/>
|
|
152
|
+
{t('viewSettings.autoOpen')}
|
|
153
|
+
</label>
|
|
154
|
+
{viewSaving && <span style={{ fontSize: 12, opacity: 0.6 }}>{t('route.saving')}</span>}
|
|
155
|
+
</Row>
|
|
156
|
+
<div style={{ fontSize: 11, opacity: 0.6, marginTop: 4 }}>{t('viewSettings.autoOpenHint')}</div>
|
|
157
|
+
<Row>
|
|
158
|
+
<span style={{ fontSize: 12, opacity: 0.75 }}>{t('viewSettings.width')}</span>
|
|
159
|
+
<input
|
|
160
|
+
type="range"
|
|
161
|
+
min={REMOTE_VIEW_WIDTH_MIN}
|
|
162
|
+
max={REMOTE_VIEW_WIDTH_MAX}
|
|
163
|
+
step={0.05}
|
|
164
|
+
value={ratio}
|
|
165
|
+
disabled={viewSaving}
|
|
166
|
+
onChange={(e) => setRatio(Number(e.target.value))}
|
|
167
|
+
onPointerUp={commitRatio}
|
|
168
|
+
onKeyUp={commitRatio}
|
|
169
|
+
onBlur={commitRatio}
|
|
170
|
+
style={{ width: 180, accentColor: 'inherit', opacity: viewSaving ? 0.5 : 1 }}
|
|
171
|
+
/>
|
|
172
|
+
<span style={{ fontSize: 12, opacity: 0.75 }}>{Math.round(ratio * 100)}%</span>
|
|
173
|
+
</Row>
|
|
174
|
+
<div style={{ fontSize: 11, opacity: 0.6, marginTop: 4 }}>{t('viewSettings.widthHint')}</div>
|
|
175
|
+
</div>
|
|
98
176
|
</div>
|
|
99
177
|
)
|
|
100
178
|
}
|