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,5 +1,15 @@
1
1
  import type { WebSocket } from 'ws';
2
2
  import type { RemotePool } from './pool.ts';
3
+ /** Construction options (the terminal gate drives the registry directly). */
4
+ export interface TerminalRegistryOptions {
5
+ /**
6
+ * Output coalescing window in ms; `0` sends every chunk as its own frame.
7
+ *
8
+ * The existing checks use `0` so their assertions stay synchronous; one
9
+ * dedicated check drives a non-zero window to pin the coalescing itself.
10
+ */
11
+ coalesceMs?: number;
12
+ }
3
13
  /**
4
14
  * The largest client frame accepted, in bytes.
5
15
  *
@@ -13,8 +23,11 @@ import type { RemotePool } from './pool.ts';
13
23
  export declare const TERMINAL_MAX_FRAME_BYTES: number;
14
24
  export declare class TerminalSessionRegistry {
15
25
  private readonly pool;
26
+ private readonly options;
16
27
  private readonly sessions;
17
- constructor(pool: RemotePool);
28
+ constructor(pool: RemotePool, options?: TerminalRegistryOptions);
29
+ /** The window this registry coalesces within (`0` = every chunk is a frame). */
30
+ private get coalesceMs();
18
31
  /** Open a shell and attach the first socket. */
19
32
  open(ws: WebSocket, alias: string, cols: number, rows: number): Promise<string>;
20
33
  /**
@@ -45,6 +58,17 @@ export declare class TerminalSessionRegistry {
45
58
  /** Keep the shell for a while (reload can reattach), then close it for good. */
46
59
  private armReap;
47
60
  private cancelReap;
61
+ /**
62
+ * Queue one output chunk and schedule the coalesced frame.
63
+ *
64
+ * `coalesceMs === 0` broadcasts immediately (the checks rely on that
65
+ * synchrony). A chunk that arrives after an idle gap is also sent at once —
66
+ * that is the interactive echo path (a keystroke must not wait for the
67
+ * window) — while a stream that keeps producing coalesces.
68
+ */
69
+ private queueOut;
70
+ /** Send the buffered output as ONE `out` frame (no-op when empty). */
71
+ private flushOut;
48
72
  private setPaused;
49
73
  private send;
50
74
  private broadcast;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dsh-remote-vs",
3
3
  "description": "VSCode-style remote development for DSH: SSH host manager (key/password), helper deploy pipeline with version check, remote file explorer + editor + terminal in dsh-better-sidebar.",
4
- "version": "0.24.0",
4
+ "version": "0.25.0",
5
5
  "icon": "icon.svg",
6
6
  "keywords": [
7
7
  "dsh",
@@ -58,6 +58,9 @@ export interface CodeEditorViewState {
58
58
  ranges: { anchor: number; head: number }[]
59
59
  }
60
60
 
61
+ export { caretOf, type CodeEditorCaret } from './vsc/editor-caret.ts'
62
+ import { caretOf as caretOfState, type CodeEditorCaret as CodeEditorCaretType } from './vsc/editor-caret.ts'
63
+
61
64
  export interface CodeEditorHandle {
62
65
  getContent: () => string
63
66
  isDirty: () => boolean
@@ -103,6 +106,17 @@ const fallbackCompartment = new Compartment()
103
106
  */
104
107
  const readOnlyCompartment = new Compartment()
105
108
 
109
+ /**
110
+ * Compartment holding the word-wrap flag.
111
+ *
112
+ * Same reasoning as the read-only one: the preference is changed from the
113
+ * editor's own toolbar / status bar while the buffer is mounted, and remounting
114
+ * to flip it would throw away the undo history and the caret. `undefined` (a
115
+ * caller that never passed the prop, e.g. a diff pane) keeps the historical
116
+ * behaviour of wrapping.
117
+ */
118
+ const wrapCompartment = new Compartment()
119
+
106
120
  /**
107
121
  * Compartment holding the session-change marks.
108
122
  *
@@ -144,6 +158,21 @@ export const CodeEditor = forwardRef<CodeEditorHandle, {
144
158
  readOnly?: boolean
145
159
  /** Parent sub-tab visibility (views stay mounted; remeasure on show). */
146
160
  visible?: boolean
161
+ /**
162
+ * Soft wrap long lines.
163
+ *
164
+ * `undefined` = the historical behaviour (wrap on) for callers that do not
165
+ * own the preference (diff panes); `false` turns it off.
166
+ */
167
+ wrap?: boolean
168
+ /**
169
+ * Reports the 1-based caret line/column plus the selected character count.
170
+ *
171
+ * The status bar needs it and CodeMirror only exposes selection changes
172
+ * through an update listener, so the editor reports instead of the parent
173
+ * polling a ref. Called once with the initial position, then on every move.
174
+ */
175
+ onCaretChange?: (caret: CodeEditorCaretType) => void
147
176
  /** Chat-insert target: absent/disabled hides the selection popup. */
148
177
  ctx?: Context
149
178
  sessionId?: string | undefined
@@ -540,6 +569,20 @@ export const CodeEditor = forwardRef<CodeEditorHandle, {
540
569
  view.dispatch({ effects: readOnlyCompartment.reconfigure(EditorState.readOnly.of(props.readOnly === true)) })
541
570
  }, [props.readOnly])
542
571
 
572
+ /**
573
+ * Word wrap follows the shared editor preference, live.
574
+ *
575
+ * A reconfigure (not a remount) so flipping the toolbar / status-bar toggle
576
+ * keeps the undo history and the caret exactly where they were.
577
+ */
578
+ useEffect(() => {
579
+ const view = viewRef.current
580
+ if (view === undefined) return
581
+ view.dispatch({
582
+ effects: wrapCompartment.reconfigure(props.wrap === false ? [] : EditorView.lineWrapping),
583
+ })
584
+ }, [props.wrap])
585
+
543
586
  // Shown again after being hidden: remeasure layout.
544
587
  useEffect(() => {
545
588
  if (props.visible === false) return
@@ -614,7 +657,7 @@ export const CodeEditor = forwardRef<CodeEditorHandle, {
614
657
  setFindOpen(false)
615
658
  return true
616
659
  },
617
- })),
660
+ })),
618
661
  lineNumbers(),
619
662
  highlightActiveLine(),
620
663
  indentOnInput(),
@@ -639,7 +682,7 @@ export const CodeEditor = forwardRef<CodeEditorHandle, {
639
682
  // Session-change marks, off until a `changeSet` prop arrives (see
640
683
  // `changeMarksCompartment`).
641
684
  changeMarksCompartment.of([]),
642
- EditorView.lineWrapping,
685
+ wrapCompartment.of(propsRef.current.wrap === false ? [] : EditorView.lineWrapping),
643
686
  readOnlyCompartment.of(EditorState.readOnly.of(propsRef.current.readOnly === true)),
644
687
  ...langFor(propsRef.current.path),
645
688
  EditorView.updateListener.of((update) => {
@@ -730,6 +773,10 @@ export const CodeEditor = forwardRef<CodeEditorHandle, {
730
773
  // than a new extension, and gated on `findOpenRef` so the widget being
731
774
  // closed never costs a render.
732
775
  if (findOpenRef.current) setFindTick(tick => tick + 1)
776
+ // Status-bar readout: reported BEFORE the view-state handoff below,
777
+ // which returns early for callers that keep no tab state (diff panes).
778
+ const caretHandler = propsRef.current.onCaretChange
779
+ if (caretHandler !== undefined) caretHandler(caretOfState(update.state))
733
780
  const handler = propsRef.current.onViewState
734
781
  const tabId = propsRef.current.tabId
735
782
  if (handler === undefined || tabId === undefined) return
@@ -777,6 +824,11 @@ export const CodeEditor = forwardRef<CodeEditorHandle, {
777
824
  }
778
825
  }
779
826
  setView(view)
827
+ // The status bar starts at the caret's real position instead of line 1/col
828
+ // 1: a remount restores the selection further down (see the restore block
829
+ // below), and no selection event fires for a caret that never moved.
830
+ const initialCaret = propsRef.current.onCaretChange
831
+ if (initialCaret !== undefined) initialCaret(caretOfState(view.state))
780
832
  /**
781
833
  * Come back to where this file was left.
782
834
  *