dsh-remote-vs 0.24.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.
Files changed (61) hide show
  1. package/README.en.md +40 -10
  2. package/README.md +31 -9
  3. package/lib/client.js +2616 -542
  4. package/lib/index.js +186 -40
  5. package/lib/types/client/CodeEditor.d.ts +17 -0
  6. package/lib/types/client/EditorPane.d.ts +16 -5
  7. package/lib/types/client/FloatingPlaceholder.d.ts +16 -5
  8. package/lib/types/client/RemoteEditorView.d.ts +13 -10
  9. package/lib/types/client/RemoteRoot.d.ts +5 -5
  10. package/lib/types/client/TerminalSnippets.d.ts +36 -0
  11. package/lib/types/client/TerminalView.d.ts +1 -1
  12. package/lib/types/client/XTerm.d.ts +33 -0
  13. package/lib/types/client/editor-capability.d.ts +27 -0
  14. package/lib/types/client/i18n.d.ts +1 -1
  15. package/lib/types/client/store.d.ts +59 -4
  16. package/lib/types/client/terminal-input.d.ts +23 -0
  17. package/lib/types/client/terminal-snippets.d.ts +86 -0
  18. package/lib/types/client/vsc/breadcrumb.d.ts +30 -0
  19. package/lib/types/client/vsc/editor-caret.d.ts +32 -0
  20. package/lib/types/client/vsc/editor-langs.d.ts +9 -0
  21. package/lib/types/client/vsc/editor-settings.d.ts +55 -0
  22. package/lib/types/client/vsc/image-preview.d.ts +36 -0
  23. package/lib/types/client/vsc/kit.d.ts +2 -0
  24. package/lib/types/client/vsc/terminal-clipboard.d.ts +15 -0
  25. package/lib/types/client/vsc/terminal-line.d.ts +25 -0
  26. package/lib/types/client/vsc/terminal-links.d.ts +62 -0
  27. package/lib/types/client/vsc/terminal-theme.d.ts +22 -0
  28. package/lib/types/client/vsc/terminal-writer.d.ts +52 -0
  29. package/lib/types/pool.d.ts +25 -0
  30. package/lib/types/terminal.d.ts +25 -1
  31. package/package.json +1 -1
  32. package/src/client/CodeEditor.tsx +54 -2
  33. package/src/client/EditorPane.tsx +485 -107
  34. package/src/client/FloatingPlaceholder.tsx +34 -5
  35. package/src/client/RemoteEditorView.tsx +14 -11
  36. package/src/client/RemoteRoot.tsx +20 -125
  37. package/src/client/TerminalSnippets.tsx +357 -0
  38. package/src/client/TerminalView.tsx +50 -1
  39. package/src/client/XTerm.tsx +228 -58
  40. package/src/client/auto-open-remote.ts +11 -9
  41. package/src/client/editor-capability.ts +42 -0
  42. package/src/client/i18n.ts +148 -6
  43. package/src/client/index.tsx +22 -6
  44. package/src/client/store.tsx +165 -13
  45. package/src/client/terminal-input.ts +44 -0
  46. package/src/client/terminal-snippets.ts +216 -0
  47. package/src/client/vsc/breadcrumb.tsx +251 -0
  48. package/src/client/vsc/editor-caret.ts +30 -0
  49. package/src/client/vsc/editor-langs.ts +20 -0
  50. package/src/client/vsc/editor-settings.ts +146 -0
  51. package/src/client/vsc/editor-theme.ts +4 -5
  52. package/src/client/vsc/image-preview.tsx +110 -0
  53. package/src/client/vsc/kit.tsx +20 -1
  54. package/src/client/vsc/terminal-clipboard.ts +19 -0
  55. package/src/client/vsc/terminal-line.ts +101 -0
  56. package/src/client/vsc/terminal-links.ts +166 -0
  57. package/src/client/vsc/terminal-theme.ts +71 -0
  58. package/src/client/vsc/terminal-writer.ts +112 -0
  59. package/src/client/vsc/vsc.css +687 -48
  60. package/src/pool.ts +99 -27
  61. package/src/terminal.ts +160 -6
@@ -1,17 +1,46 @@
1
1
  /**
2
2
  * What the centre conversation view and the sidebar fallback show while the
3
- * editor is popped out: the editor itself is a single instance and lives in the
4
- * floating window, so these surfaces must not mount a second one (that would
5
- * be two live CodeMirror buffers for one tab — the exact defect `EditorPane`'s
6
- * header warns about). A dock button keeps the surface from looking broken.
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
- export function FloatingEditorPlaceholder(): ReactNode {
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 and diff as
3
- * the sidebar, mounted next to 对话 / 轨迹 at full width.
2
+ * The conversation-view tab: the same editor (tab strip, previews, diff, status
3
+ * bar) mounted next to 对话 / 轨迹 at full width.
4
4
  *
5
- * Registered into the `conversation.view` slot when that slot exists; the
6
- * sidebar then keeps the whole column for the explorer. Both surfaces read
7
- * the same module-level store, so a diff opened from source control appears
8
- * here, and a save here repaints the sidebar's change list.
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 owned by the client
23
- * entry (registration success decides it), NOT by this component: the view
24
- * may be unmounted while another conversation tab is selected, and flipping
25
- * the flag here would make the sidebar's rail flicker on every tab switch.
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 itself lives in the conversation view next to 轨迹 whenever that
6
- * registration succeeds (`editorSurface === 'center'`), so the tree keeps the
7
- * whole column; on a host where the conversation slot is unavailable the old
8
- * split (panel above the editor) still applies and nothing becomes
9
- * unreachable.
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 sidebar editor is the FALLBACK surface, used only when the host
458
- // has no `conversation.view` slot to mount the editor in (index.tsx
459
- // stays on 'sidebar' then). It must not render while the centre surface
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
- // Floating the editor away from the sidebar: the panel stays reachable
466
- // (so docking returns here) but shows where the editor went.
467
- return store.floatOpen ? <FloatingEditorPlaceholder /> : null
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
- // The editor slot stays MOUNTED even while the split renders the
490
- // divider copy below: removing it from this list unmounted the
491
- // panel, so leaving the split and re-entering it rebuilt the editor
492
- // and dropped its local undo/scroll state. Hidden, not removed —
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
- {editorInStack && store.tabs.length > 0
527
- && railButton('editor', store.activeTab?.rel.split('/').pop() ?? t('tab.editor'), <IconDiff size={17} />, store.tabs.length)}
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" ref={columnRef}>
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
- {/* The split must not change the TYPE of the element at this position.
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
  )