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.
Files changed (81) hide show
  1. package/README.en.md +49 -15
  2. package/README.md +40 -14
  3. package/lib/client.js +45978 -43338
  4. package/lib/index.js +388 -90
  5. package/lib/p2-router-fs.js +1 -1
  6. package/lib/types/client/CodeEditor.d.ts +17 -0
  7. package/lib/types/client/EditorPane.d.ts +16 -5
  8. package/lib/types/client/FloatingPlaceholder.d.ts +16 -5
  9. package/lib/types/client/RemoteEditorView.d.ts +13 -10
  10. package/lib/types/client/RemoteRoot.d.ts +5 -5
  11. package/lib/types/client/SettingsHosts.d.ts +3 -0
  12. package/lib/types/client/TerminalSnippets.d.ts +36 -0
  13. package/lib/types/client/TerminalView.d.ts +1 -1
  14. package/lib/types/client/XTerm.d.ts +33 -0
  15. package/lib/types/client/api.d.ts +4 -1
  16. package/lib/types/client/auto-open-remote.d.ts +41 -0
  17. package/lib/types/client/editor-capability.d.ts +27 -0
  18. package/lib/types/client/i18n.d.ts +1 -1
  19. package/lib/types/client/store.d.ts +59 -4
  20. package/lib/types/client/terminal-input.d.ts +23 -0
  21. package/lib/types/client/terminal-snippets.d.ts +86 -0
  22. package/lib/types/client/use-remote-chat-target.d.ts +2 -0
  23. package/lib/types/client/view-settings.d.ts +40 -0
  24. package/lib/types/client/vsc/breadcrumb.d.ts +30 -0
  25. package/lib/types/client/vsc/editor-caret.d.ts +32 -0
  26. package/lib/types/client/vsc/editor-langs.d.ts +9 -0
  27. package/lib/types/client/vsc/editor-settings.d.ts +55 -0
  28. package/lib/types/client/vsc/image-preview.d.ts +36 -0
  29. package/lib/types/client/vsc/kit.d.ts +2 -0
  30. package/lib/types/client/vsc/terminal-clipboard.d.ts +15 -0
  31. package/lib/types/client/vsc/terminal-line.d.ts +25 -0
  32. package/lib/types/client/vsc/terminal-links.d.ts +62 -0
  33. package/lib/types/client/vsc/terminal-theme.d.ts +22 -0
  34. package/lib/types/client/vsc/terminal-writer.d.ts +52 -0
  35. package/lib/types/paths.d.ts +9 -0
  36. package/lib/types/pool.d.ts +25 -0
  37. package/lib/types/protocol.d.ts +35 -0
  38. package/lib/types/routes.d.ts +7 -0
  39. package/lib/types/terminal.d.ts +25 -1
  40. package/lib/types/view-settings.d.ts +26 -0
  41. package/lib/{worlds-DXdP4SMn.js → worlds-B7gEDBzC.js} +13 -1
  42. package/package.json +36 -36
  43. package/src/client/CodeEditor.tsx +54 -2
  44. package/src/client/EditorPane.tsx +485 -107
  45. package/src/client/FloatingPlaceholder.tsx +34 -5
  46. package/src/client/RemoteEditorView.tsx +14 -11
  47. package/src/client/RemoteRoot.tsx +20 -125
  48. package/src/client/SettingsHosts.tsx +81 -3
  49. package/src/client/TerminalSnippets.tsx +357 -0
  50. package/src/client/TerminalView.tsx +50 -1
  51. package/src/client/XTerm.tsx +228 -58
  52. package/src/client/api.ts +7 -0
  53. package/src/client/auto-open-remote.ts +439 -0
  54. package/src/client/editor-capability.ts +42 -0
  55. package/src/client/i18n.ts +158 -6
  56. package/src/client/index.tsx +30 -6
  57. package/src/client/store.tsx +165 -13
  58. package/src/client/terminal-input.ts +44 -0
  59. package/src/client/terminal-snippets.ts +216 -0
  60. package/src/client/use-remote-chat-target.ts +1 -1
  61. package/src/client/view-settings.ts +99 -0
  62. package/src/client/vsc/breadcrumb.tsx +251 -0
  63. package/src/client/vsc/editor-caret.ts +30 -0
  64. package/src/client/vsc/editor-langs.ts +20 -0
  65. package/src/client/vsc/editor-settings.ts +146 -0
  66. package/src/client/vsc/editor-theme.ts +4 -5
  67. package/src/client/vsc/image-preview.tsx +110 -0
  68. package/src/client/vsc/kit.tsx +20 -1
  69. package/src/client/vsc/terminal-clipboard.ts +19 -0
  70. package/src/client/vsc/terminal-line.ts +101 -0
  71. package/src/client/vsc/terminal-links.ts +166 -0
  72. package/src/client/vsc/terminal-theme.ts +71 -0
  73. package/src/client/vsc/terminal-writer.ts +112 -0
  74. package/src/client/vsc/vsc.css +687 -48
  75. package/src/index.ts +6 -0
  76. package/src/paths.ts +13 -0
  77. package/src/pool.ts +99 -27
  78. package/src/protocol.ts +45 -0
  79. package/src/routes.ts +47 -0
  80. package/src/terminal.ts +160 -6
  81. package/src/view-settings.ts +133 -0
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Caret readout maths for the editor status bar (pure, no CodeMirror/DOM).
3
+ *
4
+ * Kept out of `CodeEditor.tsx` so the gate can assert the 1-based conversion and
5
+ * the "selected characters" count without mounting an editor.
6
+ */
7
+ /** Caret readout for the status bar (1-based, matching what the user sees). */
8
+ export interface CodeEditorCaret {
9
+ /** 1-based line of the caret (the selection's head). */
10
+ line: number;
11
+ /** 1-based column of the caret. */
12
+ column: number;
13
+ /** Number of selected characters (0 = empty selection). */
14
+ selected: number;
15
+ }
16
+ /** The caret reading of one editor state. */
17
+ export declare function caretOf(state: {
18
+ doc: {
19
+ lineAt(offset: number): {
20
+ number: number;
21
+ from: number;
22
+ to: number;
23
+ };
24
+ };
25
+ selection: {
26
+ main: {
27
+ head: number;
28
+ from: number;
29
+ to: number;
30
+ };
31
+ };
32
+ }): CodeEditorCaret;
@@ -3,3 +3,12 @@ import type { Extension } from '@codemirror/state';
3
3
  export declare function extensionOf(path: string): string;
4
4
  /** The grammar extension list for a file path (empty = plain text). */
5
5
  export declare function langFor(path: string): Extension[];
6
+ /**
7
+ * Guess the indentation style from the file body (status-bar hint only).
8
+ *
9
+ * Only the first stretch of lines that really starts with whitespace is
10
+ * inspected: the goal is a quick hint, not a formatter. `undefined` means "no
11
+ * indented line in the head", and the status bar then omits the item instead of
12
+ * inventing a default.
13
+ */
14
+ export declare function detectIndentLabel(text: string): string | undefined;
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Editor view preferences (word wrap + font size), shared by every surface that
3
+ * shows the editor (the sidebar pane, the conversation-view tab, the floating
4
+ * window).
5
+ *
6
+ * Module-level, React/DOM-free on purpose: those three surfaces are three
7
+ * different React trees, so React state cannot carry "I made the font bigger in
8
+ * the floating window, dock it and the sidebar must show the same size" — which
9
+ * is the whole point (it is ONE editor, only its mount changes).
10
+ *
11
+ * The pure parse/serialize half is exported because the self-check harness
12
+ * imports this module in Node: it must not read localStorage at module load
13
+ * (private mode throws on `getItem`).
14
+ */
15
+ /** One shared view preference set. */
16
+ export interface EditorSettings {
17
+ /** Soft wrap the long lines. */
18
+ wrap: boolean;
19
+ /** Editor type size in px (0.5 px steps are legal). */
20
+ fontSize: number;
21
+ }
22
+ /** localStorage key: ONE JSON object, so the two fields cannot drift apart. */
23
+ export declare const EDITOR_SETTINGS_KEY = "dsh-remote-vs.editor.settings";
24
+ /** Legal font-size range, shared with the floating window's Ctrl+wheel zoom. */
25
+ export declare const FONT_MIN = 9;
26
+ export declare const FONT_MAX = 28;
27
+ export declare const FONT_STEP = 1;
28
+ /** Defaults used before anything was stored (matches the theme's 13px fallback). */
29
+ export declare const DEFAULT_EDITOR_SETTINGS: EditorSettings;
30
+ /** Clamp any input to a legal font size; non-numbers answer undefined. */
31
+ export declare function parseFontSize(value: unknown): number | undefined;
32
+ /** One zoom step (-1 = smaller, +1 = bigger), already clamped. */
33
+ export declare function stepFontSize(size: number, direction: -1 | 1): number;
34
+ /**
35
+ * Parse the persisted JSON.
36
+ *
37
+ * Anything damaged (not JSON, not an object, wrong field types) falls back to
38
+ * the defaults: this data only affects presentation, and a dirty localStorage
39
+ * entry must never keep the page from starting.
40
+ */
41
+ export declare function parseEditorSettings(raw: string | null | undefined): EditorSettings;
42
+ /** Serialize only the known fields (never whatever else the caller passed). */
43
+ export declare function serializeEditorSettings(settings: EditorSettings): string;
44
+ /** Current snapshot (identity-stable while unchanged, safe for useSyncExternalStore). */
45
+ export declare function editorSettingsSnapshot(): EditorSettings;
46
+ /** Subscribe to preference changes; returns the unsubscribe. */
47
+ export declare function subscribeEditorSettings(listener: () => void): () => void;
48
+ /**
49
+ * Change one preference and persist it.
50
+ *
51
+ * Illegal values (out-of-range size) are clamped BEFORE the "did it change"
52
+ * comparison: without that, every click on a "+" already at the cap would
53
+ * re-render all three surfaces for nothing.
54
+ */
55
+ export declare function updateEditorSettings(patch: Partial<EditorSettings>): void;
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Inline image preview for the editor body.
3
+ *
4
+ * A remote image has no text to edit, so the editor shows the picture instead
5
+ * of the "binary file" notice. Presentation only: the base64 payload comes from
6
+ * the tab's read (the same SFTP read every other preview uses), and this
7
+ * component owns nothing but the fit / actual-size toggle and the load-failure
8
+ * state.
9
+ *
10
+ * Why an `<img>` with a `data:` URL and not an object URL: the payload already
11
+ * arrived base64 from the file route, so there is nothing extra to fetch — and
12
+ * nothing to revoke when the tab closes.
13
+ */
14
+ import { type ReactNode } from 'react';
15
+ /** Props of {@link ImagePreview}. */
16
+ export interface ImagePreviewProps {
17
+ /** `data:` URL built from the tab's base64 payload. */
18
+ src: string;
19
+ /** Absolute remote path (tooltip / aria label). */
20
+ path: string;
21
+ /** File size in bytes (shown next to the dimensions). */
22
+ size: number;
23
+ /** Set when the read was capped: a partial image cannot decode. */
24
+ truncated?: boolean;
25
+ /** i18n lookup (falls back to the inline English when the key is missing). */
26
+ t?: (key: string) => string;
27
+ }
28
+ /** Human size for the meta line. */
29
+ export declare function imageSizeText(bytes: number): string;
30
+ /**
31
+ * The preview body: the image, a click-to-toggle zoom, and a meta line.
32
+ *
33
+ * `fit` scales the picture down to the pane (the common case: look at it);
34
+ * `actual` shows it at natural size inside a scrollable pane (inspect pixels).
35
+ */
36
+ export declare function ImagePreview(props: ImagePreviewProps): ReactNode;
@@ -83,6 +83,8 @@ export declare function IconCode(props: IconProps): ReactNode;
83
83
  export declare function IconCheck(props: IconProps): ReactNode;
84
84
  export declare function IconUndo(props: IconProps): ReactNode;
85
85
  export declare function IconDiff(props: IconProps): ReactNode;
86
+ /** Float / pop-out: a small frame with an arrow leaving its top-right corner. */
87
+ export declare function IconFloat(props: IconProps): ReactNode;
86
88
  export declare function IconImage(props: IconProps): ReactNode;
87
89
  export declare function IconSync(props: IconProps): ReactNode;
88
90
  export declare function IconSave(props: IconProps): ReactNode;
@@ -49,6 +49,21 @@ export interface TerminalChordInput {
49
49
  export declare function clipboardChordFor(input: TerminalChordInput): TerminalClipboardChord | undefined;
50
50
  /** Copy and paste chords take the key over; the native-paste chord must not. */
51
51
  export declare function chordTakesKey(chord: TerminalClipboardChord): boolean;
52
+ /**
53
+ * Map ONE keyboard event to a terminal clipboard command.
54
+ *
55
+ * xterm calls its custom key handler for keydown, keyup AND keypress. Only the
56
+ * keydown PRESS is a command: handling keyup too ran every chord twice, which is
57
+ * what made Shift+Insert paste the clipboard twice (reported 2026-11-23) — two
58
+ * Clipboard-API reads and two input frames for one gesture, with no native paste
59
+ * event involved.
60
+ *
61
+ * Pure, so the gate can pin the "keyup is not a command" rule directly instead
62
+ * of matching source text.
63
+ */
64
+ export declare function terminalKeyCommand(input: TerminalChordInput & {
65
+ type: string;
66
+ }): TerminalClipboardChord | undefined;
52
67
  /** Dependencies of {@link createPasteFallback}. */
53
68
  export interface PasteFallbackDeps {
54
69
  /** Clipboard read; `undefined` when the browser denies it. */
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Track what the user has typed on the CURRENT terminal line (pure).
3
+ *
4
+ * Why this exists: `Ctrl+B` should save the command the user is about to run as
5
+ * a snippet, pre-filled. The PTY protocol has no "current line" query, and asking
6
+ * the shell would mean typing into it — so the client reconstructs the line from
7
+ * the same `onData` stream it forwards: printable characters append, backspace
8
+ * removes, Enter/Ctrl+C/Ctrl+U clear, escape sequences (arrows, F-keys, history
9
+ * recall) are ignored.
10
+ *
11
+ * The result is a BEST-EFFORT draft, not a shell parser: after cursor movement or
12
+ * history recall it can differ from the real line. That is acceptable because it
13
+ * only pre-fills an editable form — nothing is executed, and the user can fix it.
14
+ */
15
+ /** Longest line worth remembering (a snippet's command is capped separately). */
16
+ export declare const TERMINAL_LINE_MAX = 4000;
17
+ /**
18
+ * Apply one chunk of terminal INPUT to the current line.
19
+ *
20
+ * @param line - the line reconstructed so far.
21
+ * @param data - the chunk as handed to the PTY (bracketed-paste markers already
22
+ * stripped by the caller).
23
+ * @returns the new line.
24
+ */
25
+ export declare function applyTerminalInput(line: string, data: string): string;
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Terminal path links: find path-like tokens in a terminal line and turn them
3
+ * into absolute remote paths (pure, no xterm/DOM).
4
+ *
5
+ * The terminal prints paths constantly (compiler errors, `ls`, `grep`, logs) and
6
+ * the tree already knows how to reveal a folder over SFTP, so the missing piece
7
+ * is only "which text is a path, and what absolute path does it mean". Both
8
+ * questions are decided here; the xterm link provider and the store action are
9
+ * thin wiring on top.
10
+ *
11
+ * Scope decisions (kept deliberately conservative — a wrong jump is worse than a
12
+ * missing one):
13
+ * - absolute (`/opt/src/a.c`), home-relative (`~/build.log`) and relative
14
+ * tokens that contain a `/` (`v_sys/system/core.c`) are offered;
15
+ * - a `:line` / `:line:col` suffix is stripped (`src/a.ts:12:5` → `src/a.ts`);
16
+ * - URLs, flags (`--opt/x`) and pure numbers are not links;
17
+ * - resolution never guesses silently: it returns a CANDIDATE list, and the
18
+ * caller validates each candidate against the host before acting.
19
+ */
20
+ /** One path-looking range inside a terminal line. */
21
+ export interface TerminalPathToken {
22
+ /** 0-based index of the first character. */
23
+ start: number;
24
+ /** 0-based index of the LAST character (inclusive). */
25
+ end: number;
26
+ /** The path itself, with any `:line(:col)` suffix removed. */
27
+ path: string;
28
+ }
29
+ /** Everything {@link resolutionCandidates} may use to anchor a relative token. */
30
+ export interface PathResolutionContext {
31
+ /** Remote home directory, when knowable (derived from the SSH user). */
32
+ home?: string;
33
+ /** Shell working directory, when the shell reports it (OSC 7). */
34
+ cwd?: string;
35
+ /** Remote workspace roots on this host, most specific first. */
36
+ roots?: readonly string[];
37
+ }
38
+ /** Collapse `//`, resolve `.`/`..` and drop a trailing slash (POSIX semantics). */
39
+ export declare function normalizeRemotePath(path: string): string;
40
+ /** Join a base directory and a relative token (POSIX, no trailing slash). */
41
+ export declare function joinRemotePath(base: string, token: string): string;
42
+ /** The parent directory of an absolute path (`/a/b/c` → `/a/b`; `/a` → `/`). */
43
+ export declare function parentDirectoryOf(path: string): string;
44
+ /** Whether `path` is `root` itself or lives under it. */
45
+ export declare function isWithinRoot(path: string, root: string): boolean;
46
+ /**
47
+ * Every path-looking token of one terminal line, in order.
48
+ *
49
+ * Trailing sentence punctuation is trimmed rather than excluded beforehand, so
50
+ * `see /opt/src/a.c.` links `a.c`; a location suffix is removed before that trim
51
+ * so `a.c:12` links `a.c` (not `a.c:12`).
52
+ */
53
+ export declare function findTerminalPathTokens(text: string): TerminalPathToken[];
54
+ /**
55
+ * Absolute candidates for one token, in the order they should be validated.
56
+ *
57
+ * The caller stats each in turn (bounded) and acts on the first hit, which is
58
+ * why the order matters: the shell's reported cwd beats a workspace-root guess,
59
+ * and the home directory is the last resort (most relative paths a shell prints
60
+ * are relative to where the user is).
61
+ */
62
+ export declare function resolutionCandidates(token: string, ctx?: PathResolutionContext): string[];
@@ -0,0 +1,22 @@
1
+ /**
2
+ * xterm colour theme, kept free of React/DOM so a gate can assert it.
3
+ *
4
+ * The palette is OPAQUE on purpose: xterm's contrast engine cannot reason about
5
+ * translucent colours, and a terminal over a wallpaper needs a definite surface.
6
+ *
7
+ * Selection colours are explicit per scheme. xterm's defaults assume a dark
8
+ * background, so in the light theme a selected block rendered white-on-white —
9
+ * copy worked while "selecting" looked like it did nothing (reported
10
+ * 2026-11-23). These are the VS Code selection colours, with a dimmer variant
11
+ * for an unfocused window.
12
+ *
13
+ * Only a TYPE import from xterm here: the module must stay loadable in Node for
14
+ * the gate (`@xterm/xterm`'s entry pulls CSS/UMD code).
15
+ */
16
+ import type { ITheme } from '@xterm/xterm';
17
+ /** The dark scheme palette. */
18
+ export declare const DARK_TERMINAL_THEME: ITheme;
19
+ /** The light scheme palette. */
20
+ export declare const LIGHT_TERMINAL_THEME: ITheme;
21
+ /** The palette for one scheme. */
22
+ export declare function terminalTheme(dark: boolean): ITheme;
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Terminal OUTPUT writer: an ordered, coalescing buffer between the WebSocket
3
+ * frames and `term.write`.
4
+ *
5
+ * Why this is not just `term.write(frame.d)` per frame, and NOT a chain of
6
+ * `write(..., callback)`:
7
+ *
8
+ * - xterm parses writes in slices of a few milliseconds; handing it one string
9
+ * per frame costs per-call overhead on a busy stream (`cat`, `dmesg`).
10
+ * - chaining on the write CALLBACK couples our queue to xterm's parse/render
11
+ * completion. A callback is delivered after the data is parsed AND rendered,
12
+ * and rendering is driven by the browser's frames — a throttled window, an
13
+ * occluded tab or a very large previous chunk delays it, and while it is
14
+ * delayed this queue refuses to hand xterm anything new. That is exactly the
15
+ * "typing sometimes has no echo for a while, then it catches up" symptom:
16
+ * the echo was sitting in our queue behind a callback that had not fired yet.
17
+ *
18
+ * So: order is preserved by APPENDING to one buffer and flushing it on a timer
19
+ * (or immediately when the buffer is large). Nothing here waits for a write to
20
+ * finish — xterm's own queue already serialises the chunks we hand it.
21
+ *
22
+ * Pure for the gate (`scripts/check-terminal-writer.mjs`): the scheduler and the
23
+ * write sink are injected, no DOM, no timers at import time.
24
+ */
25
+ /** Dependencies of {@link createTerminalWriter}. */
26
+ export interface TerminalWriterDeps {
27
+ /** Hand one chunk to the terminal (xterm's `write`). Must not throw. */
28
+ write: (text: string) => void;
29
+ /** Schedule one flush; the default is `setTimeout(run, 0)`. */
30
+ schedule?: (run: () => void) => unknown;
31
+ /**
32
+ * Largest string handed to `write` in one call.
33
+ *
34
+ * Joining a multi-megabyte backlog into ONE string would itself block the main
35
+ * thread (and the join is O(total) on every flush), so a big queue is written
36
+ * in pieces and the rest is scheduled immediately.
37
+ */
38
+ maxChunkChars?: number;
39
+ }
40
+ /** Handle returned by {@link createTerminalWriter}. */
41
+ export interface TerminalWriter {
42
+ /** Append output; the returned value is ignored (kept for symmetry/tests). */
43
+ push: (text: string) => void;
44
+ /** Flush everything right now (tab closing, exit frame). */
45
+ flush: () => void;
46
+ /** Characters still waiting (diagnostics/tests). */
47
+ pendingChars: () => number;
48
+ }
49
+ /** Default cap for one `write` call (256 Ki UTF-16 units). */
50
+ export declare const WRITER_MAX_CHUNK_CHARS: number;
51
+ /** Create one ordered, coalescing writer. */
52
+ export declare function createTerminalWriter(deps: TerminalWriterDeps): TerminalWriter;
@@ -2,6 +2,15 @@
2
2
  export declare function dshHome(): string;
3
3
  /** Absolute path of the remote store file. */
4
4
  export declare function storePath(home?: string): string;
5
+ /**
6
+ * Absolute path of the client view-preferences file.
7
+ *
8
+ * Its own file, not a section of `dsh-remote.json`: hosts and bindings are
9
+ * routing data read by the routers on every operation, while these two fields
10
+ * are GUI behaviour. Keeping them apart means a hand-edited preference can never
11
+ * cost the routing store (see `RemoteViewSettingsStore` for the defaults).
12
+ */
13
+ export declare function viewSettingsPath(home?: string): string;
5
14
  /** Absolute path of the managed-keys directory (created 0700 on demand). */
6
15
  export declare function keysDir(home?: string): string;
7
16
  /** Absolute path of the helper tarball cache directory. */
@@ -45,6 +45,24 @@ export interface SftpOptions {
45
45
  export declare class RemotePool {
46
46
  private readonly store;
47
47
  private readonly conns;
48
+ /**
49
+ * Dedicated connections for PTY shells (one per alias).
50
+ *
51
+ * Why a SECOND connection instead of a channel on the shared one: ssh2
52
+ * multiplexes channels over ONE TCP connection, and SSH has no per-channel
53
+ * priority or flow control. A large SFTP transfer / git output on that
54
+ * connection therefore delays everything else on it — including the echo of a
55
+ * keystroke — which is exactly the "typing stutters when something else is
56
+ * moving data" report. A terminal gets its own connection, so its bytes never
57
+ * queue behind browse/exec traffic, and shells stop consuming the shared
58
+ * connection's channel budget as well.
59
+ *
60
+ * Cost: one extra SSH handshake per alias the first time a terminal opens,
61
+ * plus one held TCP connection per host with a terminal. `shell()` falls back
62
+ * to the shared connection if this one cannot be established at all, so a host
63
+ * that refuses extra connections still gets a working terminal.
64
+ */
65
+ private readonly shellConns;
48
66
  /** TOFU fingerprints observed this process (alias -> sha256). */
49
67
  private readonly hostKeys;
50
68
  /** Per-alias `setsid --wait` capability, probed once (see supportsSetsid). */
@@ -285,8 +303,15 @@ export declare class RemotePool {
285
303
  private supportsSetsid;
286
304
  /** Hold the connection against idle eviction (balanced by release). */
287
305
  private hold;
306
+ private holdIn;
288
307
  private release;
308
+ private releaseIn;
289
309
  private acquire;
310
+ /** `acquire` for the dedicated PTY connection map. */
311
+ private acquireShell;
312
+ private acquireIn;
313
+ /** Evict ONE alias from ONE map (host removal drops both maps explicitly). */
314
+ private evictFrom;
290
315
  /**
291
316
  * The ssh2 client factory.
292
317
  *
@@ -29,6 +29,8 @@ export declare const REMOTE_API: {
29
29
  readonly terminal: "/api/dsh-remote/terminal";
30
30
  readonly terminalClose: "/api/dsh-remote/terminal-close";
31
31
  readonly routing: "/api/dsh-remote/routing";
32
+ /** Client view preferences (auto-open the remote page + its width share). */
33
+ readonly viewSettings: "/api/dsh-remote/view-settings";
32
34
  /** Current working directory of one live session (click resolution helper). */
33
35
  readonly sessionCwd: "/api/dsh-remote/session-cwd";
34
36
  /** What one live session changed on its remote host (the review panel). */
@@ -117,6 +119,39 @@ export interface RemoteRoutingStatus {
117
119
  /** Removed alias dirs that fail closed (history kept). */
118
120
  tombstones: string[];
119
121
  }
122
+ /**
123
+ * Client view preferences: what the RIGHT PANEL does when this plugin opens it.
124
+ *
125
+ * Host-persisted rather than browser-local on purpose: the same user drives the
126
+ * Web GUI and the Desktop shell, and these describe how the plugin behaves on
127
+ * both. They are per PROFILE, not per workspace.
128
+ */
129
+ export interface RemoteViewSettings {
130
+ /**
131
+ * Open this plugin's right-panel page when a session that the plugin considers
132
+ * REMOTE first appears on screen (once per session per page load). Default off:
133
+ * the panel is the user's space unless they asked for this.
134
+ */
135
+ autoOpenRemoteWorkspace: boolean;
136
+ /**
137
+ * Share of the frame width the right panel takes when this plugin opens it.
138
+ * Bounded by {@link REMOTE_VIEW_WIDTH_MIN} … {@link REMOTE_VIEW_WIDTH_MAX}.
139
+ */
140
+ remoteWorkspaceWidthRatio: number;
141
+ }
142
+ /** The answers a fresh profile gets before anything is saved. */
143
+ export declare const REMOTE_VIEW_SETTINGS_DEFAULTS: RemoteViewSettings;
144
+ /** Narrowest useful share of the frame width (a smaller panel hides its tools). */
145
+ export declare const REMOTE_VIEW_WIDTH_MIN = 0.2;
146
+ /** Widest share the column itself allows (DSH caps the column at 70 %). */
147
+ export declare const REMOTE_VIEW_WIDTH_MAX = 0.7;
148
+ /**
149
+ * Clamp one width share into the allowed band.
150
+ *
151
+ * Pure and shared by both halves: the Host validates what it stores, and the
152
+ * browser clamps what it applies (an older Host may omit or round the field).
153
+ */
154
+ export declare function clampViewWidthRatio(value: number): number;
120
155
  /** Plugin identity (workspaces GET extension for the Settings display). */
121
156
  export interface RemotePluginMeta {
122
157
  /** Version from the shipped package.json ('unknown' when unreadable). */
@@ -7,6 +7,7 @@ import type { RemoteWorlds } from './p2/worlds.ts';
7
7
  import { TerminalSessionRegistry } from './terminal.ts';
8
8
  import { ForwardManager } from './forward.ts';
9
9
  import type { SessionChanges } from './changes/recorder.ts';
10
+ import { RemoteViewSettingsStore } from './view-settings.ts';
10
11
  /**
11
12
  * Wrap one archive command in a remote-side deadline.
12
13
  *
@@ -44,6 +45,12 @@ export interface RemoteRoutesDeps {
44
45
  * instead of pretending the feature exists.
45
46
  */
46
47
  forwards?: ForwardManager;
48
+ /**
49
+ * Client view preferences. Absent in route-only probes, which then get a
50
+ * store on the real path — its first touch is a read, so constructing one
51
+ * costs nothing until a request actually asks.
52
+ */
53
+ viewSettings?: RemoteViewSettingsStore;
47
54
  }
48
55
  export declare function makeRoutes(deps: RemoteRoutesDeps): {
49
56
  routes: WebRoute[];
@@ -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;
@@ -0,0 +1,26 @@
1
+ import { type RemoteViewSettings } from './protocol.ts';
2
+ export declare class RemoteViewSettingsStore {
3
+ private readonly file;
4
+ constructor(file?: string);
5
+ /**
6
+ * The current preferences (a missing file answers the defaults).
7
+ *
8
+ * Read from disk on every call: the file is tiny, GET hands it to a page load,
9
+ * and two processes sharing `$DSH_HOME` (desktop + `dsh web`) must see each
10
+ * other's edit without a restart.
11
+ */
12
+ get(): RemoteViewSettings;
13
+ /**
14
+ * Merge one flat patch into the stored preferences and persist the result.
15
+ *
16
+ * Unknown keys are ignored and an unusable value of a known field keeps the
17
+ * stored one: the browser's controls only ever send valid values, so a bad
18
+ * field means a stale client, not something the user should be told about.
19
+ *
20
+ * @param patch - a partial document straight from the POST body.
21
+ * @returns the settings as stored.
22
+ */
23
+ patch(patch: Record<string, unknown>): RemoteViewSettings;
24
+ /** Write one document atomically: a crash never leaves a half-written file. */
25
+ private save;
26
+ }
@@ -28,6 +28,7 @@ var __require = /* #__PURE__ */ (() => createRequire(import.meta.url))();
28
28
  * (default ~/.dsh), next to — but independent from — dsh-ssh.json:
29
29
  *
30
30
  * - dsh-remote.json host + workspace store (0600)
31
+ * - dsh-remote-view.json client view preferences (auto-open + panel width)
31
32
  * - dsh-remote-keys/ plugin-managed keypairs (0700 dir, 0600 keys)
32
33
  * - dsh-remote-helpers/ cached helper tarballs + .sha256 + .helper.json
33
34
  * - remote-ssh/aliases/ local alias dirs, one per remote workspace binding
@@ -42,6 +43,17 @@ function dshHome() {
42
43
  function storePath(home = dshHome()) {
43
44
  return join(home, "dsh-remote.json");
44
45
  }
46
+ /**
47
+ * Absolute path of the client view-preferences file.
48
+ *
49
+ * Its own file, not a section of `dsh-remote.json`: hosts and bindings are
50
+ * routing data read by the routers on every operation, while these two fields
51
+ * are GUI behaviour. Keeping them apart means a hand-edited preference can never
52
+ * cost the routing store (see `RemoteViewSettingsStore` for the defaults).
53
+ */
54
+ function viewSettingsPath(home = dshHome()) {
55
+ return join(home, "dsh-remote-view.json");
56
+ }
45
57
  /** Absolute path of the managed-keys directory (created 0700 on demand). */
46
58
  function keysDir(home = dshHome()) {
47
59
  return join(home, "dsh-remote-keys");
@@ -20039,4 +20051,4 @@ var RemoteWorlds = class {
20039
20051
  }
20040
20052
  };
20041
20053
  //#endregion
20042
- export { ensurePrivateDir as C, dshHome as S, storePath as T, MIN_TIMEOUT_MS as _, helperAvailability as a, require_lib as b, seedHelperCache as c, attachmentHeader as d, DEFAULT_GIT_TIMEOUT_MS as f, MAX_TIMEOUT_MS as g, DeadlineError as h, drainHostNotices as i, RemoteFiles as l, DEFAULT_TIMEOUTS as m, TombstonedError as n, probe as o, DEFAULT_READ_TIMEOUT_MS as p, isWindowsAbsolute as r, pushPipeline as s, RemoteWorlds as t, WriteConflictError as u, clampExecTimeout as v, keysDir as w, aliasRoot as x, resolveTimeouts as y };
20054
+ export { ensurePrivateDir as C, viewSettingsPath as E, dshHome as S, storePath as T, MIN_TIMEOUT_MS as _, helperAvailability as a, require_lib as b, seedHelperCache as c, attachmentHeader as d, DEFAULT_GIT_TIMEOUT_MS as f, MAX_TIMEOUT_MS as g, DeadlineError as h, drainHostNotices as i, RemoteFiles as l, DEFAULT_TIMEOUTS as m, TombstonedError as n, probe as o, DEFAULT_READ_TIMEOUT_MS as p, isWindowsAbsolute as r, pushPipeline as s, RemoteWorlds as t, WriteConflictError as u, clampExecTimeout as v, keysDir as w, aliasRoot as x, resolveTimeouts as y };