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
@@ -11,7 +11,7 @@
11
11
  * them here keeps the check meaningful in both directions: every entry must
12
12
  * exist in both dictionaries, and nothing else may be unreferenced.
13
13
  */
14
- export declare const DYNAMIC_KEYS: readonly ["common.loading", "editor.saving", "editor.unsaved", "editor.saved", "scm.hunkStaged", "scm.hunkUnstaged", "scm.hunkReverted", "history.details", "history.content", "history.diff", "downloads.running", "downloads.indeterminate", "downloads.sizeUnknown", "downloads.handedOff", "term.disconnected", "term.closed", "term.copy", "term.paste", "term.selectAll", "connection.ok", "connection.error", "connection.idle", "connection.actionFailed", "doctor.state.ok", "doctor.state.missing", "doctor.state.unknown", "doctor.item.os", "doctor.item.libc", "doctor.item.git", "doctor.item.rg", "doctor.item.tar", "doctor.item.setsid", "doctor.item.disk", "doctor.item.nproc", "doctor.item.memory", "doctor.item.helpers", "doctor.item.sshd"];
14
+ export declare const DYNAMIC_KEYS: readonly ["common.loading", "editor.saving", "editor.unsaved", "editor.saved", "scm.hunkStaged", "scm.hunkUnstaged", "scm.hunkReverted", "history.details", "history.content", "history.diff", "downloads.running", "downloads.indeterminate", "downloads.sizeUnknown", "downloads.handedOff", "term.disconnected", "term.closed", "term.copy", "term.paste", "term.selectAll", "connection.ok", "connection.error", "connection.idle", "connection.actionFailed", "doctor.state.ok", "doctor.state.missing", "doctor.state.unknown", "doctor.item.os", "doctor.item.libc", "doctor.item.git", "doctor.item.rg", "doctor.item.tar", "doctor.item.setsid", "doctor.item.disk", "doctor.item.nproc", "doctor.item.memory", "doctor.item.helpers", "doctor.item.sshd", "editor.crumbRoot", "editor.crumbLabel", "editor.crumbUp", "editor.crumbEmpty", "editor.imageHint", "editor.imageFitHint", "editor.imageFailedHint", "editor.imageTooLargeTitle", "editor.imageTooLargeHint"];
15
15
  export type Lang = 'zh' | 'en';
16
16
  export declare function detectLang(): Lang;
17
17
  export declare function makeT(lang: Lang): (key: string) => string;
@@ -274,6 +274,17 @@ export interface ExplorerValue {
274
274
  openFloatingEditor: () => void;
275
275
  /** 停靠回主界面(底层的中心视图或侧栏表面)。 */
276
276
  dockFloatingEditor: () => void;
277
+ /**
278
+ * Show the SAME editor in the conversation-view tab (full width).
279
+ *
280
+ * The docked sidebar pane is the default seat; the centre tab is an optional
281
+ * second seat for the same buffer. Flipping the surface unmounts one mount and
282
+ * mounts the other, so the live buffer is captured first (see
283
+ * `captureLiveBuffer`).
284
+ */
285
+ openEditorInCenter: () => void;
286
+ /** Dock the editor back into the sidebar (the reverse of `openEditorInCenter`). */
287
+ dockEditorSidebar: () => void;
277
288
  openDiff: (rel: string, staged: boolean, untracked?: boolean) => void;
278
289
  openCommitFile: (hash: string, rel: string, origPath?: string) => void;
279
290
  activateTab: (id: string) => void;
@@ -359,6 +370,28 @@ export declare function requestSearch(request: {
359
370
  * @param dir - absolute remote DIRECTORY (a file's parent for a file hit).
360
371
  */
361
372
  export declare function revealInExplorer(dir: string): void;
373
+ /** Outcome of one terminal path click (see `jumpToTerminalPath`). */
374
+ export type TerminalPathJump = 'revealed' | 'missing' | 'outside' | 'blocked';
375
+ /**
376
+ * Jump from a path printed in the TERMINAL to that folder in the directory tree
377
+ * (Ctrl+Click in the terminal; the wiring lives in `XTerm`/`TerminalView`).
378
+ *
379
+ * The token is only text, so the absolute path is decided by a short candidate
380
+ * chain (`vsc/terminal-links.ts`) and then CONFIRMED against the host: the first
381
+ * candidate that exists wins, and its directory (the path itself for a folder,
382
+ * its parent for a file) is revealed in the tree. A hit outside every binding on
383
+ * that host is reported instead of silently jumping somewhere unrelated — the
384
+ * tree can only show what a binding covers.
385
+ *
386
+ * @param alias - host the terminal TAB is connected to (not the panel's host
387
+ * picker: a tab can outlive a picker change).
388
+ * @param token - the path as printed in the terminal.
389
+ * @param hints - shell cwd (OSC 7) and remote home, for relative/`~` tokens.
390
+ */
391
+ export declare function jumpToTerminalPath(alias: string, token: string, hints?: {
392
+ home?: string;
393
+ cwd?: string;
394
+ }): Promise<TerminalPathJump>;
362
395
  /**
363
396
  * Open a fresh terminal tab whose shell lands in `dir` — on the CURRENT
364
397
  * workspace's host.
@@ -632,10 +665,15 @@ export declare function openRemoteFileInBinding(bindingId: string, remotePath: s
632
665
  * Whether the plugin's own rich editor is the place a remote file click should
633
666
  * land (the click interceptor's gate, see `remote-file-open.ts`).
634
667
  *
635
- * The centre conversation view is the normal case; while the editor floats it
636
- * is the floating window instead — the file still belongs in OUR editor, not in
637
- * the host's native preview. On the sidebar-fallback layout (`sidebar`) the
638
- * interceptor stays off, exactly as before this feature.
668
+ * True while at least one SEAT exists that can render our editor in this page
669
+ * (see `editor-capability.ts`): the docked sidebar pane is the default seat and
670
+ * the conversation-view tab is the optional second one. "Registered" rather than
671
+ * "currently mounted" on purpose — the panels are lazy/keep-alive, so a fresh
672
+ * page has no mounted pane until the rail visits it, and asking for a mount
673
+ * would send the first click to the host's native preview, which cannot resolve
674
+ * a remote path at all. A host where no seat registers falls back to that native
675
+ * preview, which is the only thing it can do. Unknown bindings are still
676
+ * answered by `openRemoteFileInBinding` returning false.
639
677
  */
640
678
  export declare function isEditorTakeoverActive(): boolean;
641
679
  /** Open (or focus) a working-tree diff of one repository path. */
@@ -696,6 +734,23 @@ export declare function dismissConflict(id: string): void;
696
734
  export declare function reloadTab(id: string): Promise<void>;
697
735
  /** Note where the editor pane is mounted (set by the client entry). */
698
736
  export declare function setEditorSurface(surface: 'center' | 'sidebar'): void;
737
+ /**
738
+ * Move the editor into the conversation-view tab (full width).
739
+ *
740
+ * The live buffer is captured BEFORE the surface flips: the flip unmounts the
741
+ * mount that owns it (see `captureLiveBuffer`'s header), and without that
742
+ * handoff the edits typed since the load would disappear. The host tab is then
743
+ * selected so the user actually sees where the editor went.
744
+ */
745
+ export declare function openEditorInCenter(): void;
746
+ /**
747
+ * Dock the editor back into the sidebar (the reverse of `openEditorInCenter`).
748
+ *
749
+ * The docked pane is the default seat and owns the whole sidebar column, so
750
+ * `revealEditor` switches the rail to the editor page (from whatever view was
751
+ * showing) and the tree stays one click away.
752
+ */
753
+ export declare function dockEditorSidebar(): void;
699
754
  /**
700
755
  * Record that the host's frame-wide overlay slot actually rendered the
701
756
  * floating window host (see `FloatingEditorWindow`).
@@ -0,0 +1,23 @@
1
+ /**
2
+ * One registry for "type this into that terminal's command line".
3
+ *
4
+ * The snippet panel lives in the terminal's HEADER while the xterm instance is
5
+ * owned by a child component, so the panel needs an imperative handle without
6
+ * lifting xterm state into React (a re-render per keystroke would be absurd).
7
+ * Each mounted `XTerm` registers a paste function under its tab id and removes
8
+ * it on unmount; the panel asks for the ACTIVE tab.
9
+ *
10
+ * Deliberately NOT exported as a React hook: callers are event handlers inside
11
+ * a portal, not render code.
12
+ */
13
+ /** Register one mounted terminal; returns the unregister. */
14
+ export declare function registerTerminalPaste(tabId: string, paste: (text: string) => void): () => void;
15
+ /**
16
+ * Insert one command into the given terminal without sending it.
17
+ *
18
+ * @returns false when that tab has no mounted terminal any more (a closed tab, a
19
+ * panel that is not rendered) — the caller says so instead of pretending.
20
+ */
21
+ export declare function pasteIntoTerminal(tabId: string | undefined, text: string): boolean;
22
+ /** How many terminals are registered (diagnostics; also handy for the gate). */
23
+ export declare function registeredTerminalCount(): number;
@@ -0,0 +1,86 @@
1
+ /**
2
+ * Common-command snippets: the little "常用指令" library above the terminal.
3
+ *
4
+ * A snippet is a NAME plus the COMMAND it stands for. Clicking one in the panel
5
+ * pastes the command into the active terminal's command line WITHOUT pressing
6
+ * Enter — the user reviews and runs it themselves, so a misclick cannot execute
7
+ * `rm -rf`.
8
+ *
9
+ * Storage is per browser (localStorage), like the port-forward rules and the
10
+ * editor preferences: this is a personal convenience list, not workspace state,
11
+ * and the host is told nothing about it. The pure half is exported so the gate
12
+ * can drive parsing / CRUD / ordering without a DOM, and the module-level store
13
+ * (snapshot + subscribe) is what makes the popover and the Ctrl+B shortcut share
14
+ * one list.
15
+ */
16
+ /** One saved command. */
17
+ export interface TerminalSnippet {
18
+ /** Stable identity (never reused, so drag/reorder cannot swap rows). */
19
+ id: string;
20
+ /** Short label shown in the list. */
21
+ name: string;
22
+ /** The command text pasted into the terminal (not executed). */
23
+ command: string;
24
+ }
25
+ /** localStorage key (one JSON array, so the list cannot half-update). */
26
+ export declare const SNIPPETS_KEY = "dsh-remote-vs.term.snippets";
27
+ /** Hard caps: a snippet list is a convenience, not a dataset. */
28
+ export declare const SNIPPETS_MAX = 200;
29
+ export declare const SNIPPET_NAME_MAX = 80;
30
+ export declare const SNIPPET_COMMAND_MAX = 4000;
31
+ /** A fresh identity for one snippet. */
32
+ export declare function createSnippetId(): string;
33
+ /**
34
+ * Normalize one user-entered snippet; `undefined` when it is unusable.
35
+ *
36
+ * Both fields are required (an unnamed command is unfindable, an empty command
37
+ * does nothing) and both are trimmed — a leading/trailing newline in a pasted
38
+ * command would otherwise send an empty line and RUN the command, which is
39
+ * exactly what this feature promises not to do.
40
+ */
41
+ export declare function sanitizeSnippetInput(input: {
42
+ name?: string;
43
+ command?: string;
44
+ }): {
45
+ name: string;
46
+ command: string;
47
+ } | undefined;
48
+ /** Parse the persisted JSON; anything malformed is dropped, never repaired silently. */
49
+ export declare function parseSnippets(raw: string | null | undefined): TerminalSnippet[];
50
+ /** Serialize only the known fields. */
51
+ export declare function serializeSnippets(list: readonly TerminalSnippet[]): string;
52
+ /** Append one snippet (newest last); returns the SAME array when it is invalid. */
53
+ export declare function addSnippet(list: readonly TerminalSnippet[], input: {
54
+ name?: string;
55
+ command?: string;
56
+ }, id?: string): SnippetList;
57
+ /** Replace one snippet's fields; an invalid edit leaves the list untouched. */
58
+ export declare function updateSnippet(list: readonly TerminalSnippet[], id: string, input: {
59
+ name?: string;
60
+ command?: string;
61
+ }): SnippetList;
62
+ /** Drop one snippet. */
63
+ export declare function removeSnippet(list: readonly TerminalSnippet[], id: string): SnippetList;
64
+ /**
65
+ * Move one snippet to another index (drag & drop), clamping both ends.
66
+ *
67
+ * Returning the SAME list for a no-op keeps the store's "did it change" test
68
+ * cheap and stops a drag that lands on its own row from re-rendering everything.
69
+ */
70
+ export declare function moveSnippet(list: readonly TerminalSnippet[], from: number, to: number): SnippetList;
71
+ /** A list type that is either the caller's unchanged value or a new array. */
72
+ type SnippetList = readonly TerminalSnippet[];
73
+ /** Current list (identity-stable while unchanged, safe for useSyncExternalStore). */
74
+ export declare function snippetsSnapshot(): readonly TerminalSnippet[];
75
+ /** Subscribe to snippet changes; returns the unsubscribe. */
76
+ export declare function subscribeSnippets(listener: () => void): () => void;
77
+ /**
78
+ * Apply one pure transition and persist it when it really changed.
79
+ *
80
+ * The updater must be pure and return either the same array (no change → no
81
+ * notification, no write) or a new one; every CRUD helper above already does.
82
+ */
83
+ export declare function updateSnippets(updater: (list: readonly TerminalSnippet[]) => readonly TerminalSnippet[]): void;
84
+ /** Reset the module store (the gate drives it directly; production never calls it). */
85
+ export declare function resetSnippetsForTests(list?: readonly TerminalSnippet[]): void;
86
+ export {};
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Breadcrumb above the editor in the full-width (conversation view) variant.
3
+ *
4
+ * Every path segment is clickable and opens a VS Code-style sibling picker: a
5
+ * directory segment lists itself, the file segment lists its parent directory,
6
+ * so "open the file next to this one" costs one click instead of a trip to the
7
+ * tree (whose expansion state lives in another view and cannot be expressed in
8
+ * a URL).
9
+ *
10
+ * Read-only: it only calls `fileOp.list` on the remote. The remote path is the
11
+ * Host's own business — no second validation layer here.
12
+ */
13
+ import { type ReactNode } from 'react';
14
+ /** Props of {@link Breadcrumb}. */
15
+ export interface BreadcrumbProps {
16
+ /** i18n lookup (falls back to inline copy when a key is missing). */
17
+ t: (key: string) => string;
18
+ /** SSH host alias the workspace lives on (the file route's first argument). */
19
+ alias: string;
20
+ /** Remote workspace root, absolute. */
21
+ root: string;
22
+ /** Display name of the workspace root. */
23
+ rootName: string;
24
+ /** Absolute path of the file on screen. */
25
+ path: string;
26
+ /** Open one remote file in the editor. */
27
+ onOpen: (fullPath: string) => void;
28
+ }
29
+ /** Breadcrumb: path segments + sibling dropdown. */
30
+ export declare function Breadcrumb(props: BreadcrumbProps): ReactNode;
@@ -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;
@@ -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
  *