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.
- package/README.en.md +50 -16
- package/README.md +40 -15
- package/THIRD-PARTY-NOTICES.md +188 -0
- package/lib/client.js +6512 -77887
- package/lib/index.js +1461 -1024
- package/lib/p2-router-fs.js +1 -1
- package/lib/types/client/CodeEditor.d.ts +25 -0
- package/lib/types/client/EditorPane.d.ts +16 -5
- package/lib/types/client/FloatingPlaceholder.d.ts +16 -5
- package/lib/types/client/RemoteEditorView.d.ts +13 -10
- package/lib/types/client/RemoteExplorer.d.ts +53 -0
- package/lib/types/client/RemoteRoot.d.ts +5 -5
- package/lib/types/client/TerminalSnippets.d.ts +36 -0
- package/lib/types/client/TerminalView.d.ts +1 -1
- package/lib/types/client/XTerm.d.ts +33 -0
- package/lib/types/client/api.d.ts +37 -2
- package/lib/types/client/changes/review-state.d.ts +19 -0
- package/lib/types/client/connection.d.ts +16 -0
- package/lib/types/client/editor-capability.d.ts +27 -0
- package/lib/types/client/i18n.d.ts +1 -1
- package/lib/types/client/request-gate.d.ts +110 -0
- package/lib/types/client/scm/DiffView.d.ts +45 -7
- package/lib/types/client/scm/actions.d.ts +31 -3
- package/lib/types/client/store.d.ts +112 -4
- package/lib/types/client/terminal-input.d.ts +23 -0
- package/lib/types/client/terminal-snippets.d.ts +86 -0
- package/lib/types/client/vsc/FindWidget.d.ts +6 -0
- package/lib/types/client/vsc/breadcrumb.d.ts +30 -0
- package/lib/types/client/vsc/change-marks.d.ts +16 -6
- package/lib/types/client/vsc/editor-caret.d.ts +32 -0
- package/lib/types/client/vsc/editor-keymap.d.ts +35 -1
- package/lib/types/client/vsc/editor-langs.d.ts +9 -0
- package/lib/types/client/vsc/editor-settings.d.ts +55 -0
- package/lib/types/client/vsc/image-preview.d.ts +36 -0
- package/lib/types/client/vsc/kit.d.ts +13 -0
- package/lib/types/client/vsc/save-shortcut.d.ts +21 -0
- package/lib/types/client/vsc/terminal-clipboard.d.ts +15 -0
- package/lib/types/client/vsc/terminal-line.d.ts +25 -0
- package/lib/types/client/vsc/terminal-links.d.ts +62 -0
- package/lib/types/client/vsc/terminal-theme.d.ts +48 -0
- package/lib/types/client/vsc/terminal-writer.d.ts +52 -0
- package/lib/types/forward.d.ts +12 -0
- package/lib/types/fs-ops.d.ts +42 -0
- package/lib/types/http.d.ts +2 -0
- package/lib/types/keygen.d.ts +9 -0
- package/lib/types/monitor.d.ts +8 -0
- package/lib/types/notices.d.ts +16 -1
- package/lib/types/p2/helper-rpc.d.ts +45 -0
- package/lib/types/pool.d.ts +25 -0
- package/lib/types/routes.d.ts +2 -0
- package/lib/types/store.d.ts +7 -0
- package/lib/types/terminal.d.ts +33 -1
- package/lib/types/view-settings.d.ts +5 -0
- package/lib/{worlds-B7gEDBzC.js → worlds-RG8K5eom.js} +113 -15
- package/package.json +2 -1
- package/src/client/CodeEditor.tsx +205 -10
- package/src/client/DirectoryFlow.tsx +16 -0
- package/src/client/DoctorPanel.tsx +70 -7
- package/src/client/EditorPane.tsx +545 -118
- package/src/client/FloatingPlaceholder.tsx +34 -5
- package/src/client/HostsView.tsx +12 -3
- package/src/client/RemoteDirectoryPicker.tsx +12 -0
- package/src/client/RemoteEditorView.tsx +14 -11
- package/src/client/RemoteExplorer.tsx +929 -40
- package/src/client/RemoteRoot.tsx +167 -147
- package/src/client/SearchView.tsx +8 -0
- package/src/client/TerminalSnippets.tsx +432 -0
- package/src/client/TerminalView.tsx +50 -1
- package/src/client/XTerm.tsx +228 -58
- package/src/client/api.ts +106 -13
- package/src/client/auto-open-remote.ts +11 -9
- package/src/client/changes/ChangesDock.tsx +188 -6
- package/src/client/changes/changes.css +10 -3
- package/src/client/changes/review-state.ts +34 -0
- package/src/client/connection.ts +29 -0
- package/src/client/downloads.ts +49 -4
- package/src/client/editor-capability.ts +42 -0
- package/src/client/i18n.ts +228 -12
- package/src/client/index.tsx +22 -6
- package/src/client/request-gate.ts +221 -0
- package/src/client/scm/CommitPane.tsx +20 -2
- package/src/client/scm/DiffView.tsx +343 -117
- package/src/client/scm/HistoryPanel.tsx +23 -2
- package/src/client/scm/RepoPicker.tsx +1 -1
- package/src/client/scm/ScmPanel.tsx +391 -87
- package/src/client/scm/actions.ts +95 -12
- package/src/client/store.tsx +537 -22
- package/src/client/terminal-input.ts +44 -0
- package/src/client/terminal-snippets.ts +216 -0
- package/src/client/ui.tsx +4 -0
- package/src/client/vsc/FindWidget.tsx +24 -9
- package/src/client/vsc/breadcrumb.tsx +339 -0
- package/src/client/vsc/change-marks.ts +93 -44
- package/src/client/vsc/editor-caret.ts +30 -0
- package/src/client/vsc/editor-keymap.ts +59 -1
- package/src/client/vsc/editor-langs.ts +20 -0
- package/src/client/vsc/editor-settings.ts +146 -0
- package/src/client/vsc/editor-theme.ts +4 -5
- package/src/client/vsc/file-icons.tsx +17 -3
- package/src/client/vsc/image-preview.tsx +110 -0
- package/src/client/vsc/kit.tsx +46 -10
- package/src/client/vsc/save-shortcut.ts +47 -1
- package/src/client/vsc/terminal-clipboard.ts +19 -0
- package/src/client/vsc/terminal-line.ts +101 -0
- package/src/client/vsc/terminal-links.ts +166 -0
- package/src/client/vsc/terminal-theme.ts +97 -0
- package/src/client/vsc/terminal-writer.ts +112 -0
- package/src/client/vsc/vsc.css +1078 -181
- package/src/forward.ts +47 -9
- package/src/fs-ops.ts +124 -4
- package/src/git-ops.ts +20 -3
- package/src/http.ts +35 -4
- package/src/keygen.ts +55 -4
- package/src/monitor.ts +13 -0
- package/src/notices.ts +23 -1
- package/src/p2/helper-rpc.ts +113 -7
- package/src/p2/worlds.ts +14 -1
- package/src/pool.ts +99 -27
- package/src/routes.ts +212 -43
- package/src/sftp.ts +51 -14
- package/src/store.ts +10 -0
- package/src/terminal.ts +225 -24
- package/src/view-settings.ts +50 -10
- package/lib/types/client/Dialog.d.ts +0 -14
- package/src/client/Dialog.tsx +0 -76
package/lib/p2-router-fs.js
CHANGED
|
@@ -20,6 +20,8 @@ export interface CodeEditorViewState {
|
|
|
20
20
|
head: number;
|
|
21
21
|
}[];
|
|
22
22
|
}
|
|
23
|
+
export { caretOf, type CodeEditorCaret } from './vsc/editor-caret.ts';
|
|
24
|
+
import { type CodeEditorCaret as CodeEditorCaretType } from './vsc/editor-caret.ts';
|
|
23
25
|
export interface CodeEditorHandle {
|
|
24
26
|
getContent: () => string;
|
|
25
27
|
isDirty: () => boolean;
|
|
@@ -61,6 +63,29 @@ export declare const CodeEditor: import("react").ForwardRefExoticComponent<{
|
|
|
61
63
|
readOnly?: boolean;
|
|
62
64
|
/** Parent sub-tab visibility (views stay mounted; remeasure on show). */
|
|
63
65
|
visible?: boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Translator for the editor's own chrome (find widget + change marks).
|
|
68
|
+
*
|
|
69
|
+
* Optional so callers that do not own the dictionary (diff panes) keep
|
|
70
|
+
* working: the fallback makes the same `detectLang()` choice the store does,
|
|
71
|
+
* so the copy matches the language of the rest of the pane.
|
|
72
|
+
*/
|
|
73
|
+
t?: (key: string) => string;
|
|
74
|
+
/**
|
|
75
|
+
* Soft wrap long lines.
|
|
76
|
+
*
|
|
77
|
+
* `undefined` = the historical behaviour (wrap on) for callers that do not
|
|
78
|
+
* own the preference (diff panes); `false` turns it off.
|
|
79
|
+
*/
|
|
80
|
+
wrap?: boolean;
|
|
81
|
+
/**
|
|
82
|
+
* Reports the 1-based caret line/column plus the selected character count.
|
|
83
|
+
*
|
|
84
|
+
* The status bar needs it and CodeMirror only exposes selection changes
|
|
85
|
+
* through an update listener, so the editor reports instead of the parent
|
|
86
|
+
* polling a ref. Called once with the initial position, then on every move.
|
|
87
|
+
*/
|
|
88
|
+
onCaretChange?: (caret: CodeEditorCaretType) => void;
|
|
64
89
|
/** Chat-insert target: absent/disabled hides the selection popup. */
|
|
65
90
|
ctx?: Context;
|
|
66
91
|
sessionId?: string | undefined;
|
|
@@ -1,11 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The editor area: one tab strip for code files, previews and diffs, an info
|
|
3
|
-
* row, and the
|
|
3
|
+
* row, the body, and (in the full-width conversation-view variant) a status bar.
|
|
4
4
|
*
|
|
5
|
-
* The
|
|
6
|
-
*
|
|
7
|
-
* every
|
|
8
|
-
*
|
|
5
|
+
* The chrome follows the local sidebar plugin's editor (same tab strip, info
|
|
6
|
+
* row, empty states, status bar, image preview and editor background tokens),
|
|
7
|
+
* while every remote-only capability stays exactly where it was: the remote
|
|
8
|
+
* read/write routes, the save-conflict banner and its on-demand difference, the
|
|
9
|
+
* diff tabs, markdown/HTML previews, session change marks and the offline
|
|
10
|
+
* read-only degradation.
|
|
11
|
+
*
|
|
12
|
+
* Three variants share this component, chosen from the store's effective
|
|
13
|
+
* surface — never from a prop, so a surface can never mount two live buffers:
|
|
14
|
+
* - `sidebar`: the docked pane — a FULL-COLUMN rail page and the default seat
|
|
15
|
+
* (opening a file switches the rail to it; closing the last file switches
|
|
16
|
+
* back to the directory);
|
|
17
|
+
* - `center`: the conversation-view tab next to 对话 / 轨迹 (optional, full
|
|
18
|
+
* width, breadcrumb + status bar);
|
|
19
|
+
* - `float`: the frame-wide floating window (its own font zoom applies).
|
|
9
20
|
*/
|
|
10
21
|
import { type ReactNode } from 'react';
|
|
11
22
|
/**
|
|
@@ -1,9 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* What the centre conversation view and the sidebar fallback show while the
|
|
3
|
-
* editor
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
3
|
+
* editor lives somewhere else: the editor itself is a single instance, so these
|
|
4
|
+
* surfaces must not mount a second one (that would be two live CodeMirror
|
|
5
|
+
* buffers for one tab — the exact defect `EditorPane`'s header warns about).
|
|
6
|
+
*
|
|
7
|
+
* Three such places exist now that the DOCKED sidebar pane is the default seat:
|
|
8
|
+
* - `float`: the editor is popped out into the frame-wide window;
|
|
9
|
+
* - `sidebar`: the editor is docked in the sidebar column, and the
|
|
10
|
+
* conversation-view tab is only its optional full-width seat;
|
|
11
|
+
* - `center`: the reverse — the conversation tab owns the editor, and the
|
|
12
|
+
* sidebar's editor page explains how to bring it back.
|
|
13
|
+
* A button per mode keeps the surface from looking broken.
|
|
7
14
|
*/
|
|
8
15
|
import type { ReactNode } from 'react';
|
|
9
|
-
|
|
16
|
+
/** Which seat currently owns the editor. */
|
|
17
|
+
export type PlaceholderMode = 'float' | 'sidebar' | 'center';
|
|
18
|
+
export declare function FloatingEditorPlaceholder(props: {
|
|
19
|
+
mode?: PlaceholderMode;
|
|
20
|
+
}): ReactNode;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The conversation-view tab: the same editor tab strip, previews
|
|
3
|
-
*
|
|
2
|
+
* The conversation-view tab: the same editor (tab strip, previews, diff, status
|
|
3
|
+
* bar) mounted next to 对话 / 轨迹 at full width.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
5
|
+
* This is the OPTIONAL seat now: the docked sidebar pane is the default one, so
|
|
6
|
+
* a file click lands there and this tab shows a "docked in the sidebar"
|
|
7
|
+
* placeholder until the editor's own surface button moves it here. Both seats
|
|
8
|
+
* read the same module-level store, so a diff opened from source control
|
|
9
|
+
* appears here too and a save here repaints the sidebar's change list.
|
|
9
10
|
*
|
|
10
11
|
* While the editor floats (`editorSurface === 'float'`) this tab is NOT the
|
|
11
12
|
* editor's mount any more, so it renders a placeholder instead: mounting a
|
|
@@ -14,10 +15,12 @@
|
|
|
14
15
|
import type { Context } from '@deepseek-ai/cordis';
|
|
15
16
|
import type { ReactNode } from 'react';
|
|
16
17
|
/**
|
|
17
|
-
* The conversation-view body. The editor surface flag is
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* the
|
|
18
|
+
* The conversation-view body. The editor surface flag is the STORE's (the
|
|
19
|
+
* docked pane is the default; this view renders only while the user has moved
|
|
20
|
+
* the editor here), and deliberately not derived from this component's own
|
|
21
|
+
* mount: the view is unmounted while another conversation tab is selected, so
|
|
22
|
+
* inferring the surface from mount/unmount would flip the sidebar's rail — and
|
|
23
|
+
* its editor — on every host tab switch.
|
|
21
24
|
*/
|
|
22
25
|
export declare function RemoteEditorView(props: {
|
|
23
26
|
ctx: Context;
|
|
@@ -78,6 +78,52 @@ export declare function rekeyPaths(set: Set<string>, from: string, to: string):
|
|
|
78
78
|
export declare function withoutListingPaths(listings: Record<string, RemoteFileEntry[]>, alias: string, removed: readonly string[]): Record<string, RemoteFileEntry[]>;
|
|
79
79
|
/** Re-key cached listings after a rename/move (memo keys are `alias:path`). */
|
|
80
80
|
export declare function rekeyListings(listings: Record<string, RemoteFileEntry[]>, alias: string, from: string, to: string): Record<string, RemoteFileEntry[]>;
|
|
81
|
+
/**
|
|
82
|
+
* Feed one streamed stdout chunk through a line buffer and hand out every
|
|
83
|
+
* COMPLETE marker line.
|
|
84
|
+
*
|
|
85
|
+
* The stream splits wherever the transport felt like it: a marker can arrive as
|
|
86
|
+
* `RV_DEL_`, then `OK 3\n` in the next chunk. Only complete lines are parsed,
|
|
87
|
+
* and the unfinished tail is returned so the next chunk can continue it; the
|
|
88
|
+
* caller flushes it with a final `'\n'` when the command ends.
|
|
89
|
+
*
|
|
90
|
+
* Exported because it is the one place where a cross-chunk parse bug would
|
|
91
|
+
* silently mis-count deletions; the local probe drives it directly.
|
|
92
|
+
*/
|
|
93
|
+
export declare function drainDeleteMarkers(buffer: string, text: string, onMarker: (marker: {
|
|
94
|
+
kind: 'item' | 'ok' | 'fail';
|
|
95
|
+
index: number;
|
|
96
|
+
}) => void): string;
|
|
97
|
+
/** The half-open range of flat rows the tree paints, plus the spacers around it. */
|
|
98
|
+
export interface TreeWindow {
|
|
99
|
+
/** First painted row index into the flat row list. */
|
|
100
|
+
from: number;
|
|
101
|
+
/** One past the last painted row index. */
|
|
102
|
+
to: number;
|
|
103
|
+
/** Height of the rows above `from`, in px. */
|
|
104
|
+
before: number;
|
|
105
|
+
/** Height of the rows below `to`, in px. */
|
|
106
|
+
after: number;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Which flat rows to paint for one scroll position.
|
|
110
|
+
*
|
|
111
|
+
* Pure, so a gate or probe can pin the arithmetic without a layout engine: the
|
|
112
|
+
* tree is one flat pre-order list with a fixed row height, so the first visible
|
|
113
|
+
* row is `offset / height` and the painted count is
|
|
114
|
+
* `ceil(visible height / height) + overscan`. `scrollTop` is the scroller's
|
|
115
|
+
* offset; `headerHeight` is the block ABOVE the rows inside it (the workspace
|
|
116
|
+
* root label, the drop hint, `.rvs-tree`'s top padding), because the offset only
|
|
117
|
+
* starts indexing rows below that block.
|
|
118
|
+
*
|
|
119
|
+
* `viewportHeight <= headerHeight` means there is no room for rows at all
|
|
120
|
+
* (jsdom or a hidden panel): the fallback paints the whole tree while it is
|
|
121
|
+
* small and `TREE_WINDOW_FALLBACK` rows otherwise. The invariant
|
|
122
|
+
* `before + (to - from) * TREE_ROW_HEIGHT + after === total * TREE_ROW_HEIGHT`
|
|
123
|
+
* holds on every branch, which is what keeps the scroll range identical to the
|
|
124
|
+
* fully-mounted tree the window replaced.
|
|
125
|
+
*/
|
|
126
|
+
export declare function computeTreeWindow(total: number, scrollTop: number, viewportHeight: number, headerHeight: number, overscan?: number): TreeWindow;
|
|
81
127
|
/**
|
|
82
128
|
* One rendered line of the flattened tree.
|
|
83
129
|
*
|
|
@@ -179,6 +225,13 @@ export interface ExplorerRowActions {
|
|
|
179
225
|
interface ExplorerRowProps {
|
|
180
226
|
entry: RemoteFileEntry;
|
|
181
227
|
depth: number;
|
|
228
|
+
/**
|
|
229
|
+
* ARIA position among the flattened visible rows. The tree is now WINDOWED, so
|
|
230
|
+
* the DOM sibling count is only the slice; without these two attributes a
|
|
231
|
+
* screen reader announces "5 of 26" for a row that is really "5005 of 20003".
|
|
232
|
+
*/
|
|
233
|
+
posinset: number;
|
|
234
|
+
setsize: number;
|
|
182
235
|
status: string | undefined;
|
|
183
236
|
ignored: boolean;
|
|
184
237
|
isSelected: boolean;
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
* Sidebar surface (better-sidebar tab, or the native right-Sidebar fallback):
|
|
3
3
|
* a VS Code-style activity rail plus one column that shows the active view.
|
|
4
4
|
*
|
|
5
|
-
* The editor
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
5
|
+
* The DOCKED editor is the default seat (`editorSurface === 'sidebar'`) and it
|
|
6
|
+
* is a FULL-COLUMN rail page — one view at a time, like the local sidebar
|
|
7
|
+
* plugin: opening a file switches the column to the editor, and closing its last
|
|
8
|
+
* file switches back to the directory. The conversation-view tab next to 轨迹 is
|
|
9
|
+
* the OPTIONAL full-width seat the editor's own button switches to.
|
|
10
10
|
*/
|
|
11
11
|
import type { Context } from '@deepseek-ai/cordis';
|
|
12
12
|
import { type ReactNode } from 'react';
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The "常用指令" panel above the terminal: a personal library of NAME + COMMAND
|
|
3
|
+
* pairs that paste into the active terminal's command line WITHOUT pressing
|
|
4
|
+
* Enter (misclick safety: the user still reviews and runs it).
|
|
5
|
+
*
|
|
6
|
+
* Why it is a popover rather than a dock: the terminal needs the whole column
|
|
7
|
+
* for output; the list is opened deliberately, used once, and dismissed. The
|
|
8
|
+
* panel is portaled with fixed coordinates so the terminal's own scroller and
|
|
9
|
+
* the sidebar's `overflow: hidden` cannot clip it.
|
|
10
|
+
*
|
|
11
|
+
* Snapshot + subscribe come from `terminal-snippets.ts` (one list shared with the
|
|
12
|
+
* Ctrl+B quick-add shortcut, which `XTerm` reports as a counter prop).
|
|
13
|
+
*/
|
|
14
|
+
import { type ReactNode } from 'react';
|
|
15
|
+
/** Props of the panel (plus the button that opens it). */
|
|
16
|
+
export interface TerminalSnippetsProps {
|
|
17
|
+
/** Translator. */
|
|
18
|
+
t: (key: string) => string;
|
|
19
|
+
/** Insert one command into the active terminal; false when none is mounted. */
|
|
20
|
+
onInsert: (command: string) => boolean;
|
|
21
|
+
/** Bumped by the Ctrl+B shortcut; each change opens the ADD dialog. */
|
|
22
|
+
addRequest: number;
|
|
23
|
+
/**
|
|
24
|
+
* Draft the Ctrl+B form starts with (the terminal selection, else the line
|
|
25
|
+
* reconstructed from keystrokes). Empty for the panel's own "+" button.
|
|
26
|
+
*/
|
|
27
|
+
addContent: string;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* The panel.
|
|
31
|
+
*
|
|
32
|
+
* Kept in one component on purpose: the button, the popover, the form and their
|
|
33
|
+
* shared focus/dismissal rules are one interaction, and splitting them would
|
|
34
|
+
* need a context for four pieces of state.
|
|
35
|
+
*/
|
|
36
|
+
export declare function TerminalSnippets(props: TerminalSnippetsProps): ReactNode;
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
*/
|
|
10
10
|
import { type ReactNode } from 'react';
|
|
11
11
|
import type { RemoteHostSummary } from '../protocol.ts';
|
|
12
|
-
import type
|
|
12
|
+
import { type TerminalRequest } from './store.tsx';
|
|
13
13
|
/** First mount claims the panel, so a single-surface profile renders at once. */
|
|
14
14
|
export declare function claimTerminalOwnerIfNone(id: symbol): void;
|
|
15
15
|
/** Whether `id` is the surface that currently owns the terminal panel. */
|
|
@@ -20,4 +20,37 @@ export declare function XTerm(props: {
|
|
|
20
20
|
initialInput?: string;
|
|
21
21
|
/** Translator for the right-click menu (copy / paste / select all). */
|
|
22
22
|
t: (key: string) => string;
|
|
23
|
+
/** Tab identity, used by the snippet panel to target THIS terminal. */
|
|
24
|
+
tabId: string;
|
|
25
|
+
/**
|
|
26
|
+
* Ctrl/Cmd+B inside the terminal: open the "add snippet" form.
|
|
27
|
+
*
|
|
28
|
+
* Receives a best-effort draft so the form can pre-fill its command: the
|
|
29
|
+
* current terminal SELECTION when there is one (the user picked exactly what
|
|
30
|
+
* they want), else the line reconstructed from this session's keystrokes.
|
|
31
|
+
*
|
|
32
|
+
* Absent → the keystroke stays the shell's (readline's backward-char), which
|
|
33
|
+
* is what a host that did not wire the panel should keep.
|
|
34
|
+
*/
|
|
35
|
+
onQuickAddSnippet?: (draft: {
|
|
36
|
+
selection?: string;
|
|
37
|
+
line?: string;
|
|
38
|
+
}) => void;
|
|
39
|
+
/**
|
|
40
|
+
* Remote home directory of this tab's host, when known.
|
|
41
|
+
*
|
|
42
|
+
* Used to resolve a `~/x` token printed by the shell. The SSH user's home is
|
|
43
|
+
* the only honest source — the terminal protocol carries no home directory.
|
|
44
|
+
*/
|
|
45
|
+
home?: string;
|
|
46
|
+
/**
|
|
47
|
+
* Ctrl/Cmd + click on a path printed in the terminal.
|
|
48
|
+
*
|
|
49
|
+
* Receives the path AS PRINTED plus the hints that make sense of a relative
|
|
50
|
+
* one: the shell's cwd when it reports it (OSC 7) and the remote home.
|
|
51
|
+
*/
|
|
52
|
+
onPathClick?: (token: string, context: {
|
|
53
|
+
cwd?: string;
|
|
54
|
+
home?: string;
|
|
55
|
+
}) => void;
|
|
23
56
|
}): ReactNode;
|
|
@@ -31,8 +31,38 @@ export declare class RemoteApiError extends Error {
|
|
|
31
31
|
* happened (the Host successfully protected the file).
|
|
32
32
|
*/
|
|
33
33
|
conflict?: RemoteWriteConflict;
|
|
34
|
+
/**
|
|
35
|
+
* The Host's own words, kept when the message was rewritten for the user.
|
|
36
|
+
*
|
|
37
|
+
* Today only the loopback fence's `403 forbidden: loopback-only` takes this
|
|
38
|
+
* path (see `loopbackFenceMessage`): the readable sentence explains what to do,
|
|
39
|
+
* while this keeps the exact server string for diagnostics and logs.
|
|
40
|
+
*/
|
|
41
|
+
detail?: string;
|
|
34
42
|
constructor(status: number, message: string);
|
|
35
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* Per-request scheduling options (the channel lives in `request-gate.ts`).
|
|
46
|
+
*
|
|
47
|
+
* Every call site that does NOT pass them keeps the pre-gate behaviour: a
|
|
48
|
+
* foreground request that starts immediately and never waits.
|
|
49
|
+
*/
|
|
50
|
+
export interface RequestOptions {
|
|
51
|
+
/**
|
|
52
|
+
* Run this request on the BACKGROUND channel.
|
|
53
|
+
*
|
|
54
|
+
* Only repository-wide git walks use it (see `scm/actions.ts`): they can take
|
|
55
|
+
* minutes on a large tree, and a workspace switch must not make the directory
|
|
56
|
+
* listing queue behind them for a connection. Background requests start only
|
|
57
|
+
* while no foreground request is in flight, one at a time.
|
|
58
|
+
*/
|
|
59
|
+
background?: boolean;
|
|
60
|
+
/**
|
|
61
|
+
* Cancels the request: a queued background entry leaves the queue, and a
|
|
62
|
+
* request that already started is aborted at the fetch.
|
|
63
|
+
*/
|
|
64
|
+
signal?: AbortSignal;
|
|
65
|
+
}
|
|
36
66
|
/** Query for one remote terminal socket. */
|
|
37
67
|
export interface TerminalSocketQuery {
|
|
38
68
|
alias?: string;
|
|
@@ -130,7 +160,7 @@ export declare const api: {
|
|
|
130
160
|
deleteHost: (alias: string) => Promise<{
|
|
131
161
|
ok: boolean;
|
|
132
162
|
}>;
|
|
133
|
-
testHost: (alias: string) => Promise<{
|
|
163
|
+
testHost: (alias: string, opts?: RequestOptions) => Promise<{
|
|
134
164
|
ok: boolean;
|
|
135
165
|
error?: string;
|
|
136
166
|
durationMs: number;
|
|
@@ -169,7 +199,12 @@ export declare const api: {
|
|
|
169
199
|
ok: boolean;
|
|
170
200
|
}>;
|
|
171
201
|
};
|
|
172
|
-
|
|
202
|
+
/**
|
|
203
|
+
* One remote command (`/exec`), foreground unless `opts.background` asks for
|
|
204
|
+
* the git channel. Reads the SCM panel builds stay foreground; the
|
|
205
|
+
* repository-wide walks pass `{ background: true }` (see `scm/actions.ts`).
|
|
206
|
+
*/
|
|
207
|
+
exec: (alias: string, command: string, timeoutMs?: number, opts?: RequestOptions) => Promise<RemoteExecResult>;
|
|
173
208
|
/**
|
|
174
209
|
* Streaming exec: the network verbs' live log.
|
|
175
210
|
*
|
|
@@ -42,6 +42,25 @@ export declare function reviewKeyOf(file: ReviewSubject): string;
|
|
|
42
42
|
export declare function isReviewed(file: ReviewSubject, reviewed: ReviewedMap): boolean;
|
|
43
43
|
/** 已审阅的行数(只数当前列表里的,所以它永远 ≤ 列表长度)。 */
|
|
44
44
|
export declare function reviewedCount(files: readonly ReviewSubject[], reviewed: ReviewedMap): number;
|
|
45
|
+
/**
|
|
46
|
+
* 从 `fromKey` 之后找第一个未审阅的行 —— 面板头部「跳到下一个未审阅」的取数。
|
|
47
|
+
*
|
|
48
|
+
* 顺序就是列表本身的顺序:从游标位置往**后**线性找,走到末尾回绕到开头,最多看
|
|
49
|
+
* 一圈,因此不会重复、也不会越界。跳过已审阅的行是它的职责;它本身不改任何状态,
|
|
50
|
+
* 也不负责打开文件(那是面板的事)。
|
|
51
|
+
*
|
|
52
|
+
* `fromKey` 缺失、或已经不在列表里(行被删了、文件又改了一次导致计数进键变化)时
|
|
53
|
+
* 从第一行开始:起点未知只会让这一跳从头枚举,绝不会漏掉任何一行。
|
|
54
|
+
*
|
|
55
|
+
* 返回值与入参同一行类型(`T extends ReviewSubject`),所以面板拿回的是它自己的
|
|
56
|
+
* `RemoteChangedFile`,不需要在调用处断言一次。
|
|
57
|
+
*
|
|
58
|
+
* @param files - 面板当前的行,数组顺序即导航顺序。
|
|
59
|
+
* @param reviewed - 已审阅集合(键见 {@link reviewKeyOf})。
|
|
60
|
+
* @param fromKey - 当前游标(`reviewKeyOf` 给出的键);空/未知表示从头开始。
|
|
61
|
+
* @returns 第一个未审阅的行;空列表或全部已审阅时 `undefined`。
|
|
62
|
+
*/
|
|
63
|
+
export declare function nextUnreviewed<T extends ReviewSubject>(files: readonly T[], reviewed: ReviewedMap, fromKey?: string): T | undefined;
|
|
45
64
|
/** 切换一行的标记,返回新表(输入不被修改)。 */
|
|
46
65
|
export declare function toggleReviewed(files: readonly ReviewSubject[], reviewed: ReviewedMap, file: ReviewSubject): Record<string, 1>;
|
|
47
66
|
/** 全标或全清。 */
|
|
@@ -77,6 +77,22 @@ export declare function noteConnectionFailure(alias: string, error: unknown): vo
|
|
|
77
77
|
export declare function resetConnectionViews(): void;
|
|
78
78
|
/** Record that an explicit retry just succeeded for `alias`. */
|
|
79
79
|
export declare function markConnectionProbeOk(alias: string): void;
|
|
80
|
+
/**
|
|
81
|
+
* Forget the cached record of every alias the hosts table no longer holds.
|
|
82
|
+
*
|
|
83
|
+
* `views`/`probes` are module-level maps keyed by alias and nothing ever removed
|
|
84
|
+
* an entry: deleting or renaming a host in Settings left its view (and its
|
|
85
|
+
* explicit-retry probe) in page memory for the life of the tab. Callers pass the
|
|
86
|
+
* aliases the hosts table currently holds; everything else is stale.
|
|
87
|
+
*
|
|
88
|
+
* Only cache entries are removed — no connection state is transitioned. When the
|
|
89
|
+
* ACTIVE alias is pruned its snapshot becomes `undefined` ("no evidence yet",
|
|
90
|
+
* which every reader already treats as "not proven down") and subscribers are
|
|
91
|
+
* woken. `activeAlias` itself is deliberately KEPT: `setActiveConnectionAlias`
|
|
92
|
+
* early-returns on an unchanged alias, so clearing it here would leave a
|
|
93
|
+
* re-added host's chip blank until the user switched workspaces.
|
|
94
|
+
*/
|
|
95
|
+
export declare function pruneConnections(aliases: Iterable<string>): void;
|
|
80
96
|
/** Where the last observed state came from (see `isConnectionRecovery`). */
|
|
81
97
|
export interface ConnectionTrace {
|
|
82
98
|
alias: string;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether this page has ANY seat that can render the plugin's editor.
|
|
3
|
+
*
|
|
4
|
+
* Why not "is an `EditorPane` mounted right now": the editor panels are
|
|
5
|
+
* lazy/keep-alive (the sidebar's editor page is only rendered after the rail has
|
|
6
|
+
* visited it, and the conversation-view seat only exists while its host tab is
|
|
7
|
+
* selected). That made the first file click after a page load fall back to the
|
|
8
|
+
* host's native preview — which cannot resolve remote paths at all — even though
|
|
9
|
+
* our editor was one click away. The question the interceptor must answer is
|
|
10
|
+
* "could this file be shown in our editor in this page", i.e. a seat exists.
|
|
11
|
+
*
|
|
12
|
+
* Seats are registered exactly where a surface is registered:
|
|
13
|
+
* - the better-sidebar tab (`index.tsx` `goBetter`),
|
|
14
|
+
* - the native right-sidebar page (`registerNativeExplorer` returning a
|
|
15
|
+
* disposer),
|
|
16
|
+
* - the conversation-view tab (`conversation.view` registration).
|
|
17
|
+
*
|
|
18
|
+
* Pure module (no React/DOM) so the gate can drive register/unregister.
|
|
19
|
+
*/
|
|
20
|
+
/** One seat became available (a tab/view registration succeeded). */
|
|
21
|
+
export declare function noteEditorSeatAvailable(): void;
|
|
22
|
+
/** One seat went away (a registration was disposed); never negative. */
|
|
23
|
+
export declare function noteEditorSeatGone(): void;
|
|
24
|
+
/** How many seats exist right now. */
|
|
25
|
+
export declare function editorSeatCount(): number;
|
|
26
|
+
/** Test-only reset (the gate drives the counter directly). */
|
|
27
|
+
export declare function resetEditorSeatsForTests(): void;
|
|
@@ -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;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Request priority gate: a foreground request never waits, background ones yield.
|
|
3
|
+
*
|
|
4
|
+
* The symptom this exists for: switching the remote workspace made the tree
|
|
5
|
+
* crawl. The switch starts a full `git status` walk of the new repository
|
|
6
|
+
* (minutes on an AOSP monorepo) while the tree itself needs a handful of small
|
|
7
|
+
* foreground reads. A browser gives ONE origin six connections, so the walk —
|
|
8
|
+
* probe + status + branch header, three at once — filled the pool and the
|
|
9
|
+
* directory listing queued behind it. Measured on the reported trees: the git
|
|
10
|
+
* walk took 8–9 s (1.6–1.9 s with `-uno`), and during that window a purely
|
|
11
|
+
* in-memory Host route (`/status`, normally < 1 ms) answered in 2.7–4.6 s. The
|
|
12
|
+
* directory list itself was 175–180 ms; the rest was queueing.
|
|
13
|
+
*
|
|
14
|
+
* The contract is one sentence per direction:
|
|
15
|
+
*
|
|
16
|
+
* - FOREGROUND — every request somebody is waiting on (directory list, file
|
|
17
|
+
* read/write, session cwd, connection status, terminal exec): it never waits
|
|
18
|
+
* for a background slot. It only bumps a counter, so a background request that
|
|
19
|
+
* is already running cannot hold it up (that one still owns a TCP connection,
|
|
20
|
+
* which is what `maxBackground` and the abort in `store.readGit` are for).
|
|
21
|
+
* - BACKGROUND — repository-wide git walks: started only while NO foreground
|
|
22
|
+
* request is in flight and fewer than `maxBackground` background requests run.
|
|
23
|
+
* Otherwise queued (FIFO). `maxBackground: 1` is deliberate: the walk's own
|
|
24
|
+
* steps (probe, status, branch header) are work on ONE repository, and letting
|
|
25
|
+
* three of them hold three connections is exactly the pool exhaustion this
|
|
26
|
+
* gate exists to prevent.
|
|
27
|
+
*
|
|
28
|
+
* Aborting: a queued entry leaves the queue and rejects with `AbortError`. A
|
|
29
|
+
* request that already STARTED cannot be un-sent — its slot is released the
|
|
30
|
+
* moment its signal aborts (a cancelled fetch frees its connection right away,
|
|
31
|
+
* and the channel must not depend on the transport noticing), while the outcome
|
|
32
|
+
* of the underlying promise stays the transport's business: a real `fetch`
|
|
33
|
+
* rejects with `AbortError`, which is what the store sees. A signal that is
|
|
34
|
+
* ALREADY aborted when the request is handed over is passed to the transport
|
|
35
|
+
* unchanged — `fetch` refuses it at once, and deciding that here would swallow
|
|
36
|
+
* a step of a read that chose to keep going.
|
|
37
|
+
*
|
|
38
|
+
* Kept dependency-free (no store, no React, no fetch) on purpose: a node gate
|
|
39
|
+
* imports this class and proves the ordering with its own deferreds, and the
|
|
40
|
+
* store/api wiring is a one-liner at each call site.
|
|
41
|
+
*/
|
|
42
|
+
/** What `pending()` reports: counts only, never the queued closures. */
|
|
43
|
+
export interface RequestGatePending {
|
|
44
|
+
/** Foreground requests in flight. */
|
|
45
|
+
foreground: number;
|
|
46
|
+
/** Background requests in flight. */
|
|
47
|
+
background: number;
|
|
48
|
+
/** Background requests waiting for a slot. */
|
|
49
|
+
queued: number;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* The cancellation error a queued background request rejects with when its
|
|
53
|
+
* signal aborts (`AbortError`, the same name `fetch` uses for its own aborts).
|
|
54
|
+
*/
|
|
55
|
+
export declare function requestAbortError(): Error;
|
|
56
|
+
/**
|
|
57
|
+
* True when `error` is an abort, not a failure.
|
|
58
|
+
*
|
|
59
|
+
* Callers that cancelled a request on purpose (a workspace switch) must not
|
|
60
|
+
* report it: "the read you superseded was cancelled" is not an error the user
|
|
61
|
+
* can act on.
|
|
62
|
+
*/
|
|
63
|
+
export declare function isRequestAbort(error: unknown): boolean;
|
|
64
|
+
/**
|
|
65
|
+
* The gate itself.
|
|
66
|
+
*
|
|
67
|
+
* One instance per page is enough and is what `api.ts` uses; the class is
|
|
68
|
+
* exported so a gate can drive several independent instances with its own
|
|
69
|
+
* timings instead of sharing module state.
|
|
70
|
+
*/
|
|
71
|
+
export declare class RequestGate {
|
|
72
|
+
private readonly maxBackground;
|
|
73
|
+
/** Foreground requests in flight. */
|
|
74
|
+
private foregroundCount;
|
|
75
|
+
/** Background requests in flight (a slot is held until it settles or aborts). */
|
|
76
|
+
private backgroundCount;
|
|
77
|
+
/** Background requests waiting for a slot, in arrival order (FIFO). */
|
|
78
|
+
private readonly queued;
|
|
79
|
+
/**
|
|
80
|
+
* @param maxBackground - how many background requests may run at once.
|
|
81
|
+
* `1` is the client's choice; see the module comment.
|
|
82
|
+
*/
|
|
83
|
+
constructor(maxBackground?: number);
|
|
84
|
+
/** Run one foreground request. It never waits for a background slot. */
|
|
85
|
+
runForeground<T>(fn: () => Promise<T>): Promise<T>;
|
|
86
|
+
/**
|
|
87
|
+
* Run one background request, waiting for a slot.
|
|
88
|
+
*
|
|
89
|
+
* @param signal - a QUEUED request leaves the queue and rejects with
|
|
90
|
+
* `AbortError`; a request that already started releases its slot at once
|
|
91
|
+
* (its own `fetch` gets the same signal, so the transport is cancelled too).
|
|
92
|
+
* An already-aborted signal is handed to the transport, which refuses it.
|
|
93
|
+
*/
|
|
94
|
+
runBackground<T>(fn: () => Promise<T>, signal?: AbortSignal): Promise<T>;
|
|
95
|
+
/** Snapshot of the counts (gates assert ordering with this). */
|
|
96
|
+
pending(): RequestGatePending;
|
|
97
|
+
/**
|
|
98
|
+
* Start as many queued background requests as the rule allows.
|
|
99
|
+
*
|
|
100
|
+
* Called when a foreground request finishes, when a background one settles and
|
|
101
|
+
* when a running one's signal aborts. A background request that is RUNNING is
|
|
102
|
+
* never recalled (a fetch cannot be un-sent), so a foreground request arriving
|
|
103
|
+
* mid-walk simply runs alongside it until it settles.
|
|
104
|
+
*/
|
|
105
|
+
private pump;
|
|
106
|
+
}
|
|
107
|
+
/** The one gate the client uses (see `api.call`). */
|
|
108
|
+
export declare const requestGate: RequestGate;
|
|
109
|
+
/** Snapshot of {@link requestGate} — for gates that assert the wiring. */
|
|
110
|
+
export declare function pending(): RequestGatePending;
|
|
@@ -8,16 +8,54 @@
|
|
|
8
8
|
* already-staged diff can only be un-staged. 变更后 switches to a real
|
|
9
9
|
* CodeMirror buffer so the file can be edited in place.
|
|
10
10
|
*
|
|
11
|
-
* The row count is the WHOLE file, so
|
|
12
|
-
* `
|
|
13
|
-
* ~2N tokenized lines in the DOM at once, and every store publish rebuilt all
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
11
|
+
* The row count is the WHOLE file, so every pane is windowed (see
|
|
12
|
+
* `useScrollWindow`): before that, a 3000-line file put 9000 line containers and
|
|
13
|
+
* ~2N tokenized lines in the DOM at once, and every store publish rebuilt all of
|
|
14
|
+
* them — the "变更前 / 变更后" panes mounted every line of one side as well. In
|
|
15
|
+
* the split mode note which element scrolls: the two panes only own their
|
|
16
|
+
* HORIZONTAL scroll (`.rvs-diff-col`), while vertical scrolling belongs to
|
|
17
|
+
* `.rvs-diff-grid` outside them — so ONE window serves all three columns and no
|
|
18
|
+
* column can drift out of lockstep with another. The whole-file panes scroll
|
|
19
|
+
* their own `.rvs-code` box and take the same window from the same hook.
|
|
18
20
|
*/
|
|
19
21
|
import { type ReactNode } from 'react';
|
|
20
22
|
import type { EditorTab } from '../store.tsx';
|
|
23
|
+
/** The half-open line range a windowed pane paints, plus what it leaves blank. */
|
|
24
|
+
export interface LineWindow {
|
|
25
|
+
/** First rendered line index. */
|
|
26
|
+
from: number;
|
|
27
|
+
/** One past the last rendered line index. */
|
|
28
|
+
to: number;
|
|
29
|
+
/** Height of the lines above `from`, in px. */
|
|
30
|
+
before: number;
|
|
31
|
+
/** Height of the lines below `to`, in px. */
|
|
32
|
+
after: number;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* The lines to paint for one scroll offset — arithmetic, not measurement,
|
|
36
|
+
* because every windowed row is a hard `ROW_HEIGHT`.
|
|
37
|
+
*
|
|
38
|
+
* `total` is the number of lines the FULL pane would have rendered, which is
|
|
39
|
+
* what the scroll range has to cover: `before + painted + after` is exactly
|
|
40
|
+
* `total * ROW_HEIGHT`, so the scrollbar behaves as it did when every line was
|
|
41
|
+
* mounted.
|
|
42
|
+
*
|
|
43
|
+
* `offset` is the scroller's own top padding (`CODE_PAD_TOP` on `.rvs-code`, 0
|
|
44
|
+
* on `.rvs-diff-grid`).
|
|
45
|
+
*
|
|
46
|
+
* The offset is clamped to the LAST line, not merely guarded against negatives:
|
|
47
|
+
* a reload can replace a 3000-line side with a 40-line one while the browser
|
|
48
|
+
* still holds the old offset (it re-clamps the scroller only once the new
|
|
49
|
+
* spacer height is in the DOM). An unclamped slice would ask for lines that no
|
|
50
|
+
* longer exist, `from` would exceed the text, and the two spacers would then add
|
|
51
|
+
* up to less than the file — the bottom of the new text would be unreachable.
|
|
52
|
+
* Clamping keeps `before + painted + after` exactly equal to
|
|
53
|
+
* `total * ROW_HEIGHT`, which is what the scroller's range was before this
|
|
54
|
+
* window existed.
|
|
55
|
+
*
|
|
56
|
+
* Pure and exported so a probe can pin the boundaries without a browser.
|
|
57
|
+
*/
|
|
58
|
+
export declare function computeLineWindow(total: number, scrollTop: number, height: number, offset?: number, overscan?: number): LineWindow;
|
|
21
59
|
/** Why one hunk action (stage / unstage / revert) cannot run for this tab. */
|
|
22
60
|
export type HunkBlockReason = 'offline' | 'truncated';
|
|
23
61
|
/**
|