dsh-remote-vs 0.24.0 → 0.26.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 (125) hide show
  1. package/README.en.md +50 -16
  2. package/README.md +40 -15
  3. package/THIRD-PARTY-NOTICES.md +188 -0
  4. package/lib/client.js +6512 -77887
  5. package/lib/index.js +1461 -1024
  6. package/lib/p2-router-fs.js +1 -1
  7. package/lib/types/client/CodeEditor.d.ts +25 -0
  8. package/lib/types/client/EditorPane.d.ts +16 -5
  9. package/lib/types/client/FloatingPlaceholder.d.ts +16 -5
  10. package/lib/types/client/RemoteEditorView.d.ts +13 -10
  11. package/lib/types/client/RemoteExplorer.d.ts +53 -0
  12. package/lib/types/client/RemoteRoot.d.ts +5 -5
  13. package/lib/types/client/TerminalSnippets.d.ts +36 -0
  14. package/lib/types/client/TerminalView.d.ts +1 -1
  15. package/lib/types/client/XTerm.d.ts +33 -0
  16. package/lib/types/client/api.d.ts +37 -2
  17. package/lib/types/client/changes/review-state.d.ts +19 -0
  18. package/lib/types/client/connection.d.ts +16 -0
  19. package/lib/types/client/editor-capability.d.ts +27 -0
  20. package/lib/types/client/i18n.d.ts +1 -1
  21. package/lib/types/client/request-gate.d.ts +110 -0
  22. package/lib/types/client/scm/DiffView.d.ts +45 -7
  23. package/lib/types/client/scm/actions.d.ts +31 -3
  24. package/lib/types/client/store.d.ts +112 -4
  25. package/lib/types/client/terminal-input.d.ts +23 -0
  26. package/lib/types/client/terminal-snippets.d.ts +86 -0
  27. package/lib/types/client/vsc/FindWidget.d.ts +6 -0
  28. package/lib/types/client/vsc/breadcrumb.d.ts +30 -0
  29. package/lib/types/client/vsc/change-marks.d.ts +16 -6
  30. package/lib/types/client/vsc/editor-caret.d.ts +32 -0
  31. package/lib/types/client/vsc/editor-keymap.d.ts +35 -1
  32. package/lib/types/client/vsc/editor-langs.d.ts +9 -0
  33. package/lib/types/client/vsc/editor-settings.d.ts +55 -0
  34. package/lib/types/client/vsc/image-preview.d.ts +36 -0
  35. package/lib/types/client/vsc/kit.d.ts +13 -0
  36. package/lib/types/client/vsc/save-shortcut.d.ts +21 -0
  37. package/lib/types/client/vsc/terminal-clipboard.d.ts +15 -0
  38. package/lib/types/client/vsc/terminal-line.d.ts +25 -0
  39. package/lib/types/client/vsc/terminal-links.d.ts +62 -0
  40. package/lib/types/client/vsc/terminal-theme.d.ts +48 -0
  41. package/lib/types/client/vsc/terminal-writer.d.ts +52 -0
  42. package/lib/types/forward.d.ts +12 -0
  43. package/lib/types/fs-ops.d.ts +42 -0
  44. package/lib/types/http.d.ts +2 -0
  45. package/lib/types/keygen.d.ts +9 -0
  46. package/lib/types/monitor.d.ts +8 -0
  47. package/lib/types/notices.d.ts +16 -1
  48. package/lib/types/p2/helper-rpc.d.ts +45 -0
  49. package/lib/types/pool.d.ts +25 -0
  50. package/lib/types/routes.d.ts +2 -0
  51. package/lib/types/store.d.ts +7 -0
  52. package/lib/types/terminal.d.ts +33 -1
  53. package/lib/types/view-settings.d.ts +5 -0
  54. package/lib/{worlds-B7gEDBzC.js → worlds-RG8K5eom.js} +113 -15
  55. package/package.json +2 -1
  56. package/src/client/CodeEditor.tsx +205 -10
  57. package/src/client/DirectoryFlow.tsx +16 -0
  58. package/src/client/DoctorPanel.tsx +70 -7
  59. package/src/client/EditorPane.tsx +545 -118
  60. package/src/client/FloatingPlaceholder.tsx +34 -5
  61. package/src/client/HostsView.tsx +12 -3
  62. package/src/client/RemoteDirectoryPicker.tsx +12 -0
  63. package/src/client/RemoteEditorView.tsx +14 -11
  64. package/src/client/RemoteExplorer.tsx +929 -40
  65. package/src/client/RemoteRoot.tsx +167 -147
  66. package/src/client/SearchView.tsx +8 -0
  67. package/src/client/TerminalSnippets.tsx +432 -0
  68. package/src/client/TerminalView.tsx +50 -1
  69. package/src/client/XTerm.tsx +228 -58
  70. package/src/client/api.ts +106 -13
  71. package/src/client/auto-open-remote.ts +11 -9
  72. package/src/client/changes/ChangesDock.tsx +188 -6
  73. package/src/client/changes/changes.css +10 -3
  74. package/src/client/changes/review-state.ts +34 -0
  75. package/src/client/connection.ts +29 -0
  76. package/src/client/downloads.ts +49 -4
  77. package/src/client/editor-capability.ts +42 -0
  78. package/src/client/i18n.ts +228 -12
  79. package/src/client/index.tsx +22 -6
  80. package/src/client/request-gate.ts +221 -0
  81. package/src/client/scm/CommitPane.tsx +20 -2
  82. package/src/client/scm/DiffView.tsx +343 -117
  83. package/src/client/scm/HistoryPanel.tsx +23 -2
  84. package/src/client/scm/RepoPicker.tsx +1 -1
  85. package/src/client/scm/ScmPanel.tsx +391 -87
  86. package/src/client/scm/actions.ts +95 -12
  87. package/src/client/store.tsx +537 -22
  88. package/src/client/terminal-input.ts +44 -0
  89. package/src/client/terminal-snippets.ts +216 -0
  90. package/src/client/ui.tsx +4 -0
  91. package/src/client/vsc/FindWidget.tsx +24 -9
  92. package/src/client/vsc/breadcrumb.tsx +339 -0
  93. package/src/client/vsc/change-marks.ts +93 -44
  94. package/src/client/vsc/editor-caret.ts +30 -0
  95. package/src/client/vsc/editor-keymap.ts +59 -1
  96. package/src/client/vsc/editor-langs.ts +20 -0
  97. package/src/client/vsc/editor-settings.ts +146 -0
  98. package/src/client/vsc/editor-theme.ts +4 -5
  99. package/src/client/vsc/file-icons.tsx +17 -3
  100. package/src/client/vsc/image-preview.tsx +110 -0
  101. package/src/client/vsc/kit.tsx +46 -10
  102. package/src/client/vsc/save-shortcut.ts +47 -1
  103. package/src/client/vsc/terminal-clipboard.ts +19 -0
  104. package/src/client/vsc/terminal-line.ts +101 -0
  105. package/src/client/vsc/terminal-links.ts +166 -0
  106. package/src/client/vsc/terminal-theme.ts +97 -0
  107. package/src/client/vsc/terminal-writer.ts +112 -0
  108. package/src/client/vsc/vsc.css +1078 -181
  109. package/src/forward.ts +47 -9
  110. package/src/fs-ops.ts +124 -4
  111. package/src/git-ops.ts +20 -3
  112. package/src/http.ts +35 -4
  113. package/src/keygen.ts +55 -4
  114. package/src/monitor.ts +13 -0
  115. package/src/notices.ts +23 -1
  116. package/src/p2/helper-rpc.ts +113 -7
  117. package/src/p2/worlds.ts +14 -1
  118. package/src/pool.ts +99 -27
  119. package/src/routes.ts +212 -43
  120. package/src/sftp.ts +51 -14
  121. package/src/store.ts +10 -0
  122. package/src/terminal.ts +225 -24
  123. package/src/view-settings.ts +50 -10
  124. package/lib/types/client/Dialog.d.ts +0 -14
  125. package/src/client/Dialog.tsx +0 -76
@@ -15,6 +15,25 @@ export declare class GitOpError extends Error {
15
15
  }
16
16
  /** Join a remote directory with a repo-relative path. */
17
17
  export declare function joinRemote(dir: string, rel: string): string;
18
+ /**
19
+ * Per-command options for {@link run} / {@link tryRun}.
20
+ *
21
+ * `background` puts the command on the request gate's git channel: it waits
22
+ * while a foreground request is in flight and only one such command runs at a
23
+ * time. ONLY the repository-wide READ paths use it (`probeRepoRoot`,
24
+ * `loadStatusDetail`, `loadHead`), because those are the walks a workspace
25
+ * switch starts and the ones that must never make the directory listing queue
26
+ * behind them. Every verb the user is waiting on (stage, commit, push, the
27
+ * bounded probes, the search) stays foreground and is unaffected.
28
+ *
29
+ * `signal` cancels the command: the HTTP request is aborted (and, while still
30
+ * queued, is taken out of the queue) — the store's `readGit` uses it to release
31
+ * the connections of a workspace the user just left.
32
+ */
33
+ export interface RunOptions {
34
+ background?: boolean;
35
+ signal?: AbortSignal;
36
+ }
18
37
  /** The repository that encloses a workspace directory (undefined when none). */
19
38
  export declare function resolveRepoRoot(alias: string, workspaceRoot: string): Promise<string | undefined>;
20
39
  /**
@@ -41,11 +60,11 @@ export type RepoRootProbe = {
41
60
  error: string;
42
61
  };
43
62
  /** The repository root, or WHY the probe could not answer. */
44
- export declare function probeRepoRoot(alias: string, workspaceRoot: string): Promise<RepoRootProbe>;
63
+ export declare function probeRepoRoot(alias: string, workspaceRoot: string, signal?: AbortSignal): Promise<RepoRootProbe>;
45
64
  /** Repositories under a workspace root (the workspace itself sorts first). */
46
65
  export declare function findRepos(alias: string, workspaceRoot: string): Promise<string[]>;
47
66
  /** Every changed path plus the ignored half. */
48
- export declare function loadStatusDetail(alias: string, root: string): Promise<GitStatusDetail>;
67
+ export declare function loadStatusDetail(alias: string, root: string, signal?: AbortSignal): Promise<GitStatusDetail>;
49
68
  /**
50
69
  * Pathspec-limited status probe: the raw `-z` stdout for JUST these paths.
51
70
  *
@@ -73,7 +92,7 @@ export declare function probeStatusPaths(alias: string, root: string, paths: rea
73
92
  */
74
93
  export declare function probeStatusDir(alias: string, root: string, dir: string): Promise<string>;
75
94
  /** Current branch with its ahead/behind counters (detached HEAD tolerated). */
76
- export declare function loadHead(alias: string, root: string): Promise<{
95
+ export declare function loadHead(alias: string, root: string, signal?: AbortSignal): Promise<{
77
96
  branch: string;
78
97
  detached: boolean;
79
98
  ahead: number;
@@ -143,6 +162,15 @@ export declare function loadBranches(alias: string, root: string, current: strin
143
162
  export declare function loadRemotes(alias: string, root: string): Promise<GitRemote[]>;
144
163
  /** The stash stack. */
145
164
  export declare function loadStashes(alias: string, root: string): Promise<GitStash[]>;
165
+ /**
166
+ * Initialize a repository in place (`git init`).
167
+ *
168
+ * The panel's "not a repository" state used to be a dead end (the only offer
169
+ * was "browse somewhere else") while the command builder had no caller at all.
170
+ * The caller refreshes the status afterwards — that read re-probes the
171
+ * directory, so the panel moves to the normal view without another discovery.
172
+ */
173
+ export declare function initRepo(alias: string, root: string): Promise<string>;
146
174
  /** Stage paths (additions, edits, deletions, renames). */
147
175
  export declare function stagePaths(alias: string, root: string, paths: readonly string[]): Promise<void>;
148
176
  /** Unstage paths without touching the worktree. */
@@ -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;
@@ -317,6 +328,59 @@ export interface ExplorerValue {
317
328
  }
318
329
  /** Subscribe to the explorer store. */
319
330
  export declare function useExplorer(): ExplorerValue;
331
+ /**
332
+ * Shallow equality for selector results — one level deep, `Object.is` per field.
333
+ *
334
+ * Selectors naturally build a fresh `{ repoRoot, head, … }` object out of the
335
+ * snapshot, and a plain `Object.is` would then see a new reference on every
336
+ * publish and repaint the panel anyway (defeating the whole point). Passing this
337
+ * as `equal` compares the FIELDS, so "the snapshot was rebuilt but none of the
338
+ * fields I read changed" answers `true` and the previous value (and render) is
339
+ * kept. Arrays are compared as objects, i.e. by index.
340
+ *
341
+ * Shallow is deliberate: every selected field is either a primitive or a
342
+ * REFERENCE the store already owns (`status`, `buckets`, `tabs`, `untrackedDirs`
343
+ * …). Comparing those by reference is a real value check — the store only
344
+ * replaces them when they actually change.
345
+ */
346
+ export declare function shallowEqual(a: unknown, b: unknown): boolean;
347
+ /**
348
+ * Subscribe to ONE slice of the explorer store.
349
+ *
350
+ * Why this exists: `useExplorer()` hands out the whole `ExplorerValue`, and
351
+ * every `publish()` builds a NEW snapshot object — so every subscriber repaints
352
+ * on every mutation, including mutations its panel does not read (a save bumps
353
+ * the tab array, a git refresh replaces `status`, a rail switch changes `view`).
354
+ * With the panels kept MOUNTED, one publish therefore repainted every panel,
355
+ * and the SCM panel's change list (up to 4000 rows) was rebuilt for a change in
356
+ * an unrelated field.
357
+ *
358
+ * This hook re-renders its component ONLY when the selected value changes:
359
+ * - `publish()` still notifies every listener (that is how the store stays a
360
+ * single source of truth), but React asks this hook for a fresh value and
361
+ * `Object.is`-compares it with the last rendered one; equal means no render;
362
+ * - the selector runs at most once per (snapshot, selector) pair, and its
363
+ * result is kept in a per-hook cache, so an equal result keeps the PREVIOUS
364
+ * reference (downstream `useMemo`s keyed on it stay valid).
365
+ *
366
+ * Constraints, all from `useSyncExternalStore`:
367
+ * - the value returned for an UNCHANGED snapshot must be stable. This hook
368
+ * guarantees it (cache keyed on the snapshot identity), which is also why a
369
+ * selector may safely return a fresh object — with `shallowEqual` it is
370
+ * compared and the old reference is kept, and without `equal` it is cached
371
+ * and only recomputed when the snapshot itself changes;
372
+ * - `selector` must be PURE and should read only the snapshot. It may be an
373
+ * inline arrow (the hook tracks its identity, so a selector that closes over
374
+ * props is recomputed when it changes), but a module-level selector is
375
+ * cheaper: its identity is stable, so between publishes the cache answers
376
+ * without running it at all;
377
+ * - `selector` must not mutate the snapshot.
378
+ *
379
+ * @param selector - pure read of the fields this component needs.
380
+ * @param equal - comparison used to decide whether the new selection is the
381
+ * same value; defaults to `Object.is`. Pass `shallowEqual` for object slices.
382
+ */
383
+ export declare function useExplorerSelector<T>(selector: (snapshot: ExplorerValue) => T, equal?: (a: T, b: T) => boolean): T;
320
384
  /** The repo-relative path of an absolute remote path ('' when outside). */
321
385
  export declare function repoRelative(repoRoot: string | undefined, fullPath: string): string;
322
386
  /** Install the context and load hosts/workspaces once per page. */
@@ -359,6 +423,28 @@ export declare function requestSearch(request: {
359
423
  * @param dir - absolute remote DIRECTORY (a file's parent for a file hit).
360
424
  */
361
425
  export declare function revealInExplorer(dir: string): void;
426
+ /** Outcome of one terminal path click (see `jumpToTerminalPath`). */
427
+ export type TerminalPathJump = 'revealed' | 'missing' | 'outside' | 'blocked';
428
+ /**
429
+ * Jump from a path printed in the TERMINAL to that folder in the directory tree
430
+ * (Ctrl+Click in the terminal; the wiring lives in `XTerm`/`TerminalView`).
431
+ *
432
+ * The token is only text, so the absolute path is decided by a short candidate
433
+ * chain (`vsc/terminal-links.ts`) and then CONFIRMED against the host: the first
434
+ * candidate that exists wins, and its directory (the path itself for a folder,
435
+ * its parent for a file) is revealed in the tree. A hit outside every binding on
436
+ * that host is reported instead of silently jumping somewhere unrelated — the
437
+ * tree can only show what a binding covers.
438
+ *
439
+ * @param alias - host the terminal TAB is connected to (not the panel's host
440
+ * picker: a tab can outlive a picker change).
441
+ * @param token - the path as printed in the terminal.
442
+ * @param hints - shell cwd (OSC 7) and remote home, for relative/`~` tokens.
443
+ */
444
+ export declare function jumpToTerminalPath(alias: string, token: string, hints?: {
445
+ home?: string;
446
+ cwd?: string;
447
+ }): Promise<TerminalPathJump>;
362
448
  /**
363
449
  * Open a fresh terminal tab whose shell lands in `dir` — on the CURRENT
364
450
  * workspace's host.
@@ -632,10 +718,15 @@ export declare function openRemoteFileInBinding(bindingId: string, remotePath: s
632
718
  * Whether the plugin's own rich editor is the place a remote file click should
633
719
  * land (the click interceptor's gate, see `remote-file-open.ts`).
634
720
  *
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.
721
+ * True while at least one SEAT exists that can render our editor in this page
722
+ * (see `editor-capability.ts`): the docked sidebar pane is the default seat and
723
+ * the conversation-view tab is the optional second one. "Registered" rather than
724
+ * "currently mounted" on purpose — the panels are lazy/keep-alive, so a fresh
725
+ * page has no mounted pane until the rail visits it, and asking for a mount
726
+ * would send the first click to the host's native preview, which cannot resolve
727
+ * a remote path at all. A host where no seat registers falls back to that native
728
+ * preview, which is the only thing it can do. Unknown bindings are still
729
+ * answered by `openRemoteFileInBinding` returning false.
639
730
  */
640
731
  export declare function isEditorTakeoverActive(): boolean;
641
732
  /** Open (or focus) a working-tree diff of one repository path. */
@@ -696,6 +787,23 @@ export declare function dismissConflict(id: string): void;
696
787
  export declare function reloadTab(id: string): Promise<void>;
697
788
  /** Note where the editor pane is mounted (set by the client entry). */
698
789
  export declare function setEditorSurface(surface: 'center' | 'sidebar'): void;
790
+ /**
791
+ * Move the editor into the conversation-view tab (full width).
792
+ *
793
+ * The live buffer is captured BEFORE the surface flips: the flip unmounts the
794
+ * mount that owns it (see `captureLiveBuffer`'s header), and without that
795
+ * handoff the edits typed since the load would disappear. The host tab is then
796
+ * selected so the user actually sees where the editor went.
797
+ */
798
+ export declare function openEditorInCenter(): void;
799
+ /**
800
+ * Dock the editor back into the sidebar (the reverse of `openEditorInCenter`).
801
+ *
802
+ * The docked pane is the default seat and owns the whole sidebar column, so
803
+ * `revealEditor` switches the rail to the editor page (from whatever view was
804
+ * showing) and the tree stays one click away.
805
+ */
806
+ export declare function dockEditorSidebar(): void;
699
807
  /**
700
808
  * Record that the host's frame-wide overlay slot actually rendered the
701
809
  * 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 {};
@@ -59,6 +59,12 @@ export declare function stepFind(view: EditorView, forward: boolean, state?: Fin
59
59
  export declare function FindWidget(props: {
60
60
  view: EditorView | undefined;
61
61
  open: boolean;
62
+ /**
63
+ * The page's dictionary translator. Required, not defaulted: the widget has
64
+ * no language of its own, and a silent Chinese fallback is exactly the
65
+ * hardcoded copy this prop replaced.
66
+ */
67
+ t: (key: string) => string;
62
68
  /** A selection carried in by Ctrl+F (`id` bumps to re-trigger). */
63
69
  seed: {
64
70
  text: string;
@@ -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;
@@ -22,6 +22,13 @@ import { StateField, type EditorState, type Extension } from '@codemirror/state'
22
22
  import { EditorView, ViewPlugin, type DecorationSet, type ViewUpdate } from '@codemirror/view';
23
23
  /** 改动点的三种形态。 */
24
24
  export type ChangeKind = 'add' | 'mod' | 'del';
25
+ /**
26
+ * 字典翻译函数,由调用方传入(`CodeEditor` 把页面语言解析好的那个 `t` 交下来)。
27
+ *
28
+ * 本模块自己不选语言:同样的 `t` 与同样的数据永远画出同样的 DOM,纯函数性得以
29
+ * 保持;语言变了由调用方重装扩展(`changeMarksExtension(t)`)。
30
+ */
31
+ export type Translate = (key: string) => string;
25
32
  /**
26
33
  * 新增/修改行里"真正变化的字符区间":相对所属行的列偏移,**0-based、半开区间**。
27
34
  *
@@ -145,23 +152,26 @@ export declare function changeBlockAt(state: EditorState, line: number): {
145
152
  declare class ChangeMarkHighlighter {
146
153
  decorations: DecorationSet;
147
154
  private readonly view;
148
- constructor(view: EditorView);
155
+ /** 解析标记文案的翻译函数;由 `changeMarkPlugin(t)` 装进来。 */
156
+ private readonly t;
157
+ constructor(view: EditorView, t: Translate);
149
158
  update(update: ViewUpdate): void;
150
159
  private rebuild;
151
160
  }
152
161
  /**
153
162
  * 视口内行装饰的 ViewPlugin。
154
163
  *
155
- * 导出是为了让自检脚本能直接读 `view.plugin(changeMarkPlugin).decorations.size`
156
- * —— "只装饰视口内的行"这件事在 DOM 上看不出来(CodeMirror 本来就让 DOM 只保留
157
- * 可见行),只有读这份 RangeSet 的条数才有判别力。
164
+ * 用工厂而不是模块级常量:标记与 chip 的文案由调用方的 `t` 解析。仍然导出是为了
165
+ * 让自检脚本能直接读 `view.plugin(changeMarkPlugin(t)).decorations.size` ——
166
+ * "只装饰视口内的行"这件事在 DOM 上看不出来(CodeMirror 本来就让 DOM 只保留可见
167
+ * 行),只有读这份 RangeSet 的条数才有判别力。
158
168
  */
159
- export declare const changeMarkPlugin: ViewPlugin<ChangeMarkHighlighter, undefined>;
169
+ export declare function changeMarkPlugin(t: Translate): ViewPlugin<ChangeMarkHighlighter>;
160
170
  /**
161
171
  * 编辑器侧的完整扩展:数据字段 + 作废标记 + 左侧 gutter + 行背景。
162
172
  *
163
173
  * `CodeEditor` 只在调用方真的传了 `changeSet` 时把它装进编辑器(Compartment),
164
174
  * 没传时不装 —— 这样"没有会话改动"的文件连一条 gutter 都不会多出来。
165
175
  */
166
- export declare const changeMarksExtension: Extension;
176
+ export declare function changeMarksExtension(t: Translate): Extension;
167
177
  export {};
@@ -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;
@@ -22,7 +22,15 @@
22
22
  import type { EditorView, KeyBinding } from '@codemirror/view';
23
23
  /** The editor actions the key bindings dispatch into. */
24
24
  export interface EditorKeyHandlers {
25
- /** Ctrl/Cmd+S → the pane's save path. */
25
+ /**
26
+ * Ctrl/Cmd+S → the pane's save path.
27
+ *
28
+ * MUST be a no-op while a modal layer is open: `CodeEditor` (the only caller)
29
+ * checks `isModalLayerOpen()` before saving. The binding itself stays pure —
30
+ * this module imports no DOM — but because CodeMirror handles the key first and
31
+ * prevents the default, the window listener in `save-shortcut.ts` never gets to
32
+ * apply its own gate to this path.
33
+ */
26
34
  save(): void;
27
35
  /** Ctrl/Cmd+F → seed our find widget from the selection and open it. */
28
36
  openFindForSelection(view: EditorView): void;
@@ -32,7 +40,33 @@ export interface EditorKeyHandlers {
32
40
  stepHunk(delta: 1 | -1): boolean;
33
41
  /** Escape → close the find widget; false when it was not open. */
34
42
  closeFind(): boolean;
43
+ /**
44
+ * Ctrl/Cmd+G → ask for a line number and jump there.
45
+ *
46
+ * The prompt is the caller's (`promptDialog`), so this module stays free of
47
+ * DOM/React; the binding always claims the key (browsers use Ctrl+G for
48
+ * "find next", which has nothing to do inside a code editor).
49
+ */
50
+ gotoLine(view: EditorView): void;
51
+ /**
52
+ * Ctrl/Cmd+D → select the next occurrence of the current selection.
53
+ *
54
+ * Returns the command's own answer: `false` (nothing to expand, or a mixed
55
+ * selection) must fall through to the browser instead of being swallowed —
56
+ * the same rule the hunk bindings follow.
57
+ */
58
+ selectNextOccurrence(view: EditorView): boolean;
35
59
  }
60
+ /**
61
+ * Resolve the "go to line" answer to a 1-based line number inside `total`.
62
+ *
63
+ * Accepts what VS Code's box accepts for the LINE half: `42`, ` 42 `, `42:7`
64
+ * (the column half is ignored — this editor jumps to a line, the status bar
65
+ * reports the column). Anything else (empty, `0`, text) is `undefined`, and a
66
+ * number past the end CLAMPS to the last line instead of failing: the answer
67
+ * usually comes from a file the user is reading, not from its exact length.
68
+ */
69
+ export declare function parseGotoLine(text: string, total: number): number | undefined;
36
70
  /**
37
71
  * Build the editor keymap.
38
72
  *
@@ -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;
@@ -180,6 +182,17 @@ export declare function toast(text: string, error?: boolean): void;
180
182
  * confirm dialog would paint twice.
181
183
  */
182
184
  export declare function DialogHost(): ReactNode;
185
+ /**
186
+ * Focusable elements inside one dialog, in DOM order.
187
+ *
188
+ * The modal is portaled to the END of `<body>`, so without a Tab trap a
189
+ * keyboard user tabs through the whole page to reach its buttons. Exported for
190
+ * the other portaled layers that need the same walk (the terminal snippet
191
+ * popover); `DoctorPanel` keeps its own copy because it deliberately does not
192
+ * import this module (its copy path must not use the silently-failing
193
+ * `copyText`, which `check-doctor.mjs` pins).
194
+ */
195
+ export declare function focusables(root: HTMLElement | null): HTMLElement[];
183
196
  export interface MenuEntry {
184
197
  label: string;
185
198
  onSelect: () => void;