dsh-remote-vs 0.13.0 → 0.15.1
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 +455 -443
- package/README.md +408 -396
- package/lib/client.js +8062 -2651
- package/lib/index.js +1058 -288
- package/lib/p2-router-fs.js +1 -1
- package/lib/p2-router-refs.js +89 -10
- package/lib/p2-router-spill.js +73 -1
- package/lib/p2-router-subprocess.js +18 -6
- package/lib/spill-retention-BwKEWrl5.js +115 -0
- package/lib/{ssh-proc-arI5lm4W.js → ssh-proc-VKWn_LZC.js} +17 -0
- package/lib/types/archive.d.ts +1 -1
- package/lib/types/changes/recorder.d.ts +34 -2
- package/lib/types/client/CodeEditor.d.ts +12 -0
- package/lib/types/client/ConnectionStatus.d.ts +17 -0
- package/lib/types/client/DirectoryFlow.d.ts +2 -0
- package/lib/types/client/DoctorPanel.d.ts +25 -0
- package/lib/types/client/QuickOpen.d.ts +17 -0
- package/lib/types/client/RemoteExplorer.d.ts +192 -1
- package/lib/types/client/RemoteRoot.d.ts +17 -0
- package/lib/types/client/SearchView.d.ts +55 -0
- package/lib/types/client/TerminalView.d.ts +38 -0
- package/lib/types/client/WorkspaceWizard.d.ts +17 -0
- package/lib/types/client/api.d.ts +54 -4
- package/lib/types/client/changes/undo-affordance.d.ts +16 -0
- package/lib/types/client/changes/undo-context.d.ts +14 -18
- package/lib/types/client/changes/undo-target.d.ts +78 -0
- package/lib/types/client/connection.d.ts +111 -0
- package/lib/types/client/doctor.d.ts +122 -0
- package/lib/types/client/download.d.ts +35 -5
- package/lib/types/client/downloads.d.ts +18 -1
- package/lib/types/client/file-open-probe.d.ts +64 -0
- package/lib/types/client/i18n.d.ts +1 -1
- package/lib/types/client/quickopen-model.d.ts +332 -0
- package/lib/types/client/scm/DiffView.d.ts +34 -0
- package/lib/types/client/scm/actions.d.ts +18 -0
- package/lib/types/client/scm/diff-model.d.ts +17 -1
- package/lib/types/client/scm/git-cache.d.ts +10 -2
- package/lib/types/client/scm/read-queue.d.ts +2 -1
- package/lib/types/client/scm/stage-queue.d.ts +13 -0
- package/lib/types/client/scm/status-map.d.ts +3 -1
- package/lib/types/client/store.d.ts +114 -5
- package/lib/types/client/vsc/FindWidget.d.ts +7 -0
- package/lib/types/client/vsc/save-shortcut.d.ts +57 -0
- package/lib/types/deploy.d.ts +44 -2
- package/lib/types/git-format.d.ts +15 -0
- package/lib/types/http.d.ts +44 -0
- package/lib/types/p2/file-refs.d.ts +39 -2
- package/lib/types/p2/helper-rpc.d.ts +26 -0
- package/lib/types/p2/router-spill.d.ts +19 -0
- package/lib/types/p2/router-subprocess.d.ts +2 -0
- package/lib/types/p2/spill-retention.d.ts +74 -0
- package/lib/types/p2/worlds.d.ts +11 -0
- package/lib/types/pool.d.ts +73 -11
- package/lib/types/protocol.d.ts +63 -0
- package/lib/types/routes.d.ts +18 -0
- package/lib/types/sftp.d.ts +114 -8
- package/lib/types/store.d.ts +34 -0
- package/lib/types/timeouts.d.ts +14 -0
- package/lib/{worlds-C6Xha1mQ.js → worlds-Be1YE2Ot.js} +727 -78
- package/package.json +1 -1
- package/src/archive.ts +41 -9
- package/src/changes/recorder.ts +227 -31
- package/src/changes/status.ts +37 -1
- package/src/client/CodeEditor.tsx +84 -2
- package/src/client/ConnectionStatus.tsx +130 -0
- package/src/client/DirectoryFlow.tsx +40 -5
- package/src/client/DoctorPanel.tsx +202 -0
- package/src/client/DownloadDock.tsx +13 -25
- package/src/client/EditorPane.tsx +291 -7
- package/src/client/HostsView.tsx +17 -8
- package/src/client/QuickOpen.tsx +371 -0
- package/src/client/RemoteDirectoryPicker.tsx +54 -3
- package/src/client/RemoteExplorer.tsx +879 -160
- package/src/client/RemoteRoot.tsx +178 -1
- package/src/client/SearchView.tsx +180 -6
- package/src/client/SettingsHosts.tsx +1 -1
- package/src/client/TerminalView.tsx +174 -9
- package/src/client/WorkspaceWizard.tsx +110 -16
- package/src/client/WorkspacesView.tsx +22 -6
- package/src/client/api.ts +197 -11
- package/src/client/changes/ChangesDock.tsx +35 -8
- package/src/client/changes/undo-affordance.ts +33 -0
- package/src/client/changes/undo-context.ts +14 -18
- package/src/client/changes/undo-target.ts +139 -0
- package/src/client/connection.ts +264 -0
- package/src/client/doctor.ts +441 -0
- package/src/client/download.ts +148 -12
- package/src/client/downloads.ts +43 -2
- package/src/client/file-open-probe.ts +83 -0
- package/src/client/i18n.ts +244 -0
- package/src/client/index.tsx +5 -2
- package/src/client/quickopen-model.ts +778 -0
- package/src/client/remote-file-open.ts +21 -33
- package/src/client/scm/DiffView.tsx +116 -6
- package/src/client/scm/ScmPanel.tsx +19 -0
- package/src/client/scm/actions.ts +34 -2
- package/src/client/scm/diff-model.ts +33 -37
- package/src/client/scm/git-cache.ts +61 -4
- package/src/client/scm/read-queue.ts +33 -2
- package/src/client/scm/stage-queue.ts +72 -1
- package/src/client/scm/status-map.ts +22 -1
- package/src/client/store.tsx +704 -21
- package/src/client/vsc/FindWidget.tsx +20 -0
- package/src/client/vsc/kit.tsx +115 -6
- package/src/client/vsc/reveal-line.ts +33 -14
- package/src/client/vsc/save-shortcut.ts +131 -0
- package/src/client/vsc/vsc.css +419 -0
- package/src/deploy.ts +185 -33
- package/src/git-format.ts +136 -22
- package/src/git-ops.ts +14 -6
- package/src/http.ts +80 -12
- package/src/importers.ts +80 -21
- package/src/index.ts +21 -1
- package/src/p2/file-refs.ts +112 -10
- package/src/p2/helper-rpc.ts +73 -36
- package/src/p2/router-spill.ts +96 -1
- package/src/p2/router-subprocess.ts +18 -5
- package/src/p2/spill-retention.ts +134 -0
- package/src/p2/ssh-proc.ts +22 -0
- package/src/p2/worlds.ts +24 -0
- package/src/pool.ts +329 -47
- package/src/protocol.ts +66 -0
- package/src/routes.ts +251 -43
- package/src/sftp.ts +486 -26
- package/src/store.ts +207 -85
- package/src/terminal.ts +38 -2
- package/src/timeouts.ts +14 -0
- package/src/tools.ts +14 -5
|
@@ -10,9 +10,200 @@
|
|
|
10
10
|
* previous explorer, and `insertRemoteReference` still writes into the
|
|
11
11
|
* on-screen session's composer draft.
|
|
12
12
|
*/
|
|
13
|
-
import { type ReactNode } from 'react';
|
|
13
|
+
import { type MutableRefObject, type ReactNode } from 'react';
|
|
14
|
+
import { type RemoteFileEntry } from '../protocol.ts';
|
|
15
|
+
/**
|
|
16
|
+
* Whether a "show this folder" request still needs to be processed.
|
|
17
|
+
*
|
|
18
|
+
* The store keeps the request object after it has been handled, and this effect
|
|
19
|
+
* re-runs whenever `root`/`loadDir` change (workspace switch, offline flip). No
|
|
20
|
+
* consumed marker meant switching back to a workspace replayed the OLD reveal:
|
|
21
|
+
* it re-expanded the ancestor chain and scrolled away from wherever the user was.
|
|
22
|
+
*/
|
|
23
|
+
export declare function shouldConsumeReveal(lastId: number, id: number): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Whether a remote WRITE may start.
|
|
26
|
+
*
|
|
27
|
+
* Uploads hold one `AbortController` slot and a batch can run for minutes; a
|
|
28
|
+
* second upload used to overwrite that slot (the first became uncancellable and
|
|
29
|
+
* the two progress bars overwrote each other), and paste/delete could interleave
|
|
30
|
+
* with the transfer. Serializing writes through one flag is the smallest fix;
|
|
31
|
+
* read-only browsing stays allowed.
|
|
32
|
+
*/
|
|
33
|
+
export declare function writeAllowed(transferActive: boolean): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Whether the write ENTRIES (new file/folder, upload, paste, delete) are
|
|
36
|
+
* disabled right now.
|
|
37
|
+
*
|
|
38
|
+
* @param transferActive - is a write batch currently holding the slot?
|
|
39
|
+
*
|
|
40
|
+
* This is a named function, not an inline expression, because the expression it
|
|
41
|
+
* replaces was a double negative that inverted itself:
|
|
42
|
+
* `!writeAllowed(upload === undefined)` passes `true` ("busy") exactly when
|
|
43
|
+
* nothing is uploading, so the whole write menu was greyed out while idle and
|
|
44
|
+
* came alive during an upload — while the toolbar's own buttons, which test
|
|
45
|
+
* `upload !== undefined` directly, disagreed with it on the same screen. Two
|
|
46
|
+
* surfaces, one state, opposite answers.
|
|
47
|
+
*/
|
|
48
|
+
export declare function writeEntriesDisabled(transferActive: boolean): boolean;
|
|
49
|
+
/** True when `path` is `prefix` itself or a descendant of it. */
|
|
50
|
+
export declare function pathUnder(path: string, prefix: string): boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Where a copy/cut/move of `sourcePath` into `intoDir` lands.
|
|
53
|
+
*
|
|
54
|
+
* `fs-ops`' commands copy/move the entry KEEPING its basename, so the new path
|
|
55
|
+
* is `intoDir/<basename>`; the explorer needs it to re-key its path indexes.
|
|
56
|
+
*/
|
|
57
|
+
export declare function destinationOfMove(intoDir: string, sourcePath: string): string;
|
|
58
|
+
/**
|
|
59
|
+
* Drop every path that is (or lives under) a removed path from a path-keyed set.
|
|
60
|
+
*
|
|
61
|
+
* `expanded` / `selected` / `anchor` are absolute-path indexes. Renaming re-keys
|
|
62
|
+
* them (see `rekeyPaths`), but deleting or moving a subtree used to leave the
|
|
63
|
+
* old paths behind: the root refresh effect then re-listed directories that no
|
|
64
|
+
* longer exist on every revision bump (one failed SFTP request and one error
|
|
65
|
+
* toast each), and `trimListings` protected those dead keys from eviction.
|
|
66
|
+
*/
|
|
67
|
+
export declare function withoutPaths(set: Set<string>, removed: readonly string[]): Set<string>;
|
|
68
|
+
/** Re-key a path-keyed set after a rename/move of `from` to `to`. */
|
|
69
|
+
export declare function rekeyPaths(set: Set<string>, from: string, to: string): Set<string>;
|
|
70
|
+
/**
|
|
71
|
+
* Drop cached listings for removed paths.
|
|
72
|
+
*
|
|
73
|
+
* Same reason as `withoutPaths`, for the listing cache: a dead key would keep a
|
|
74
|
+
* whole directory's rows in memory forever (plus a requested-but-failing list
|
|
75
|
+
* on every refresh), while `trimListings` still counts it against the 50-entry
|
|
76
|
+
* budget of LIVE directories.
|
|
77
|
+
*/
|
|
78
|
+
export declare function withoutListingPaths(listings: Record<string, RemoteFileEntry[]>, alias: string, removed: readonly string[]): Record<string, RemoteFileEntry[]>;
|
|
79
|
+
/** Re-key cached listings after a rename/move (memo keys are `alias:path`). */
|
|
80
|
+
export declare function rekeyListings(listings: Record<string, RemoteFileEntry[]>, alias: string, from: string, to: string): Record<string, RemoteFileEntry[]>;
|
|
81
|
+
/**
|
|
82
|
+
* One rendered line of the flattened tree.
|
|
83
|
+
*
|
|
84
|
+
* The tree is rendered as a FLAT pre-order list (not nested components): the
|
|
85
|
+
* rows of a large directory then each own one memoized component whose props are
|
|
86
|
+
* primitives, so a selection change, an upload progress tick or an unrelated
|
|
87
|
+
* store publish only re-renders the rows that actually changed. Nesting the
|
|
88
|
+
* recursion in JSX made every row a child of its parent row, which defeated
|
|
89
|
+
* `memo` (the children element was new on every render).
|
|
90
|
+
*/
|
|
91
|
+
export type ExplorerRow = {
|
|
92
|
+
kind: 'entry';
|
|
93
|
+
entry: RemoteFileEntry;
|
|
94
|
+
depth: number;
|
|
95
|
+
} | {
|
|
96
|
+
kind: 'create';
|
|
97
|
+
dir: string;
|
|
98
|
+
createKind: 'file' | 'folder';
|
|
99
|
+
depth: number;
|
|
100
|
+
}
|
|
101
|
+
/** An expanded directory whose listing is not available yet (loading/offline). */
|
|
102
|
+
| {
|
|
103
|
+
kind: 'pending';
|
|
104
|
+
dir: string;
|
|
105
|
+
depth: number;
|
|
106
|
+
reason: 'loading' | 'offline';
|
|
107
|
+
};
|
|
108
|
+
/**
|
|
109
|
+
* What double-clicking a row should open.
|
|
110
|
+
*
|
|
111
|
+
* `undefined` for a directory: `store.openFile()` has no type guard of its own,
|
|
112
|
+
* so handing it a directory path produced an editor tab whose Host read answers
|
|
113
|
+
* `not a file: … is a directory` — and the click also switched the surface to
|
|
114
|
+
* the editor. The guard lives here (and is applied in the row action) so every
|
|
115
|
+
* caller inherits it; the pre-refactor renderer had the same check inline.
|
|
116
|
+
*/
|
|
117
|
+
export declare function rowOpenTarget(entry: RemoteFileEntry): string | undefined;
|
|
118
|
+
/**
|
|
119
|
+
* Flatten the loaded part of the tree into pre-order rows.
|
|
120
|
+
*
|
|
121
|
+
* Pure: the gate drives it with a synthetic `rowsOf`/`isExpanded` pair. The
|
|
122
|
+
* depth of a directory's entries is its own depth + 1 (same indentation the
|
|
123
|
+
* recursive renderer used), and the inline "new file/folder" row is emitted
|
|
124
|
+
* before that directory's children.
|
|
125
|
+
*
|
|
126
|
+
* `placeholderOf` makes an expanded directory with no listing yet emit a
|
|
127
|
+
* `pending` row. Before the flat rewrite the recursive renderer did this for
|
|
128
|
+
* EVERY directory; after it only the root had a placeholder, so expanding a
|
|
129
|
+
* cold (or offline) directory showed nothing until the listing landed.
|
|
130
|
+
*/
|
|
131
|
+
export declare function buildVisibleRows(input: {
|
|
132
|
+
root: string;
|
|
133
|
+
rowsOf: (dir: string) => RemoteFileEntry[] | undefined;
|
|
134
|
+
isExpanded: (path: string) => boolean;
|
|
135
|
+
creating?: {
|
|
136
|
+
dir: string;
|
|
137
|
+
kind: 'file' | 'folder';
|
|
138
|
+
};
|
|
139
|
+
placeholderOf?: (dir: string) => 'loading' | 'offline' | undefined;
|
|
140
|
+
}): ExplorerRow[];
|
|
141
|
+
/**
|
|
142
|
+
* Where a keyboard move from `currentPath` lands.
|
|
143
|
+
*
|
|
144
|
+
* Pure so the a11y gate can pin the tree navigation without mounting React:
|
|
145
|
+
* `up`/`down` walk the flat visible rows, `parent` finds the enclosing directory
|
|
146
|
+
* row (if it is still visible), `child` the first row under a directory.
|
|
147
|
+
*/
|
|
148
|
+
export declare function rowKeyboardTarget(rows: readonly ExplorerRow[], currentPath: string, intent: 'up' | 'down' | 'parent' | 'child'): string | undefined;
|
|
149
|
+
/**
|
|
150
|
+
* Which row should own the tree's Tab stop.
|
|
151
|
+
*
|
|
152
|
+
* The roving tabindex puts `tabIndex={0}` on exactly ONE row (the focused one),
|
|
153
|
+
* so a focused path that stops existing — the row was deleted, renamed, or its
|
|
154
|
+
* directory collapsed — leaves every row at -1 and the whole tree unreachable by
|
|
155
|
+
* keyboard. This keeps a stop alive: an existing focused row wins, otherwise the
|
|
156
|
+
* first row does, otherwise none (empty tree).
|
|
157
|
+
*
|
|
158
|
+
* Pure, so the gate can pin the fallback without mounting React.
|
|
159
|
+
*/
|
|
160
|
+
export declare function nextFocusPath(rows: readonly ExplorerRow[], focusedPath: string | undefined): string | undefined;
|
|
161
|
+
/** Handlers one row needs, held in a ref so a memoized row never re-renders for them. */
|
|
162
|
+
export interface ExplorerRowActions {
|
|
163
|
+
select: (entry: RemoteFileEntry, event: React.MouseEvent) => void;
|
|
164
|
+
openFile: (entry: RemoteFileEntry) => void;
|
|
165
|
+
hoverDir: (path: string | undefined) => void;
|
|
166
|
+
openMenu: (event: React.MouseEvent, entry: RemoteFileEntry) => void;
|
|
167
|
+
contextMenu: (event: React.MouseEvent, entry: RemoteFileEntry) => void;
|
|
168
|
+
startDrag: (entry: RemoteFileEntry) => void;
|
|
169
|
+
dragOver: (entry: RemoteFileEntry, event: React.DragEvent) => void;
|
|
170
|
+
dragLeave: (entry: RemoteFileEntry) => void;
|
|
171
|
+
dropOn: (entry: RemoteFileEntry, event: React.DragEvent) => void;
|
|
172
|
+
commitRename: (entry: RemoteFileEntry, name: string) => void;
|
|
173
|
+
cancelRename: () => void;
|
|
174
|
+
reference: (entry: RemoteFileEntry) => void;
|
|
175
|
+
/** Keyboard navigation: ↑↓←→/Home/End/Enter/Space/Shift+F10 live in the parent. */
|
|
176
|
+
keyDown: (entry: RemoteFileEntry, event: React.KeyboardEvent) => void;
|
|
177
|
+
focusPath: (path: string) => void;
|
|
178
|
+
}
|
|
179
|
+
interface ExplorerRowProps {
|
|
180
|
+
entry: RemoteFileEntry;
|
|
181
|
+
depth: number;
|
|
182
|
+
status: string | undefined;
|
|
183
|
+
ignored: boolean;
|
|
184
|
+
isSelected: boolean;
|
|
185
|
+
isOpen: boolean;
|
|
186
|
+
isCut: boolean;
|
|
187
|
+
isDropTarget: boolean;
|
|
188
|
+
isRenaming: boolean;
|
|
189
|
+
isFocused: boolean;
|
|
190
|
+
chatEnabled: boolean;
|
|
191
|
+
/** Precomputed so `t` (whose identity may change with a store publish) is not a prop. */
|
|
192
|
+
referenceTitle: string;
|
|
193
|
+
symlinkTitle: string;
|
|
194
|
+
actions: MutableRefObject<ExplorerRowActions>;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* One tree row.
|
|
198
|
+
*
|
|
199
|
+
* Memoized on primitive props: the parent re-renders on every store publish and
|
|
200
|
+
* on each upload-progress tick, and without this every one of those re-rendered
|
|
201
|
+
* the whole expanded tree (a 20 000-entry directory means 20 000 rows).
|
|
202
|
+
*/
|
|
203
|
+
export declare const ExplorerRowView: import("react").NamedExoticComponent<ExplorerRowProps>;
|
|
14
204
|
export declare function RemoteExplorer(props: {
|
|
15
205
|
showHidden: boolean;
|
|
16
206
|
onToggleHidden: () => void;
|
|
17
207
|
visible: boolean;
|
|
18
208
|
}): ReactNode;
|
|
209
|
+
export {};
|
|
@@ -10,6 +10,23 @@
|
|
|
10
10
|
*/
|
|
11
11
|
import type { Context } from '@deepseek-ai/cordis';
|
|
12
12
|
import { type ReactNode } from 'react';
|
|
13
|
+
/**
|
|
14
|
+
* Which tabs a recovered link must reload, and how many dirty tabs to warn about.
|
|
15
|
+
*
|
|
16
|
+
* Pure so the gate can drive it with a synthetic list: the recovery timer used
|
|
17
|
+
* to close over the tab array of the render that STARTED it (10 s earlier), so a
|
|
18
|
+
* tab opened or closed in that window was missed. Only clean file/diff tabs are
|
|
19
|
+
* reloaded; a dirty tab is the user's unsaved work and must never be replaced.
|
|
20
|
+
*/
|
|
21
|
+
export declare function planRecoveryReload(tabs: readonly {
|
|
22
|
+
id: string;
|
|
23
|
+
dirty: boolean;
|
|
24
|
+
loading: boolean;
|
|
25
|
+
kind: string;
|
|
26
|
+
}[]): {
|
|
27
|
+
dirty: number;
|
|
28
|
+
reload: string[];
|
|
29
|
+
};
|
|
13
30
|
export declare function RemoteRoot(props: {
|
|
14
31
|
ctx: Context;
|
|
15
32
|
visible?: boolean;
|
|
@@ -11,4 +11,59 @@
|
|
|
11
11
|
* tree without the two views knowing about each other.
|
|
12
12
|
*/
|
|
13
13
|
import { type ReactNode } from 'react';
|
|
14
|
+
import type { RemoteExecResult } from '../protocol.ts';
|
|
15
|
+
/**
|
|
16
|
+
* Whether a scope still belongs to the workspace root it was entered under.
|
|
17
|
+
*
|
|
18
|
+
* The scope is an ABSOLUTE remote directory, so a workspace switch leaves it
|
|
19
|
+
* pointing at a tree the new host may not have: the next search would run
|
|
20
|
+
* `find`/`grep` in the OLD workspace's path against the NEW alias (wrong or
|
|
21
|
+
* empty results, and an error that names no cause). Callers reset the scope when
|
|
22
|
+
* this answers false.
|
|
23
|
+
*/
|
|
24
|
+
export declare function scopeBelongsToRoot(scope: string, root: string): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Which "truncated"/"lines clipped" banners may be shown RIGHT NOW.
|
|
27
|
+
*
|
|
28
|
+
* Both flags describe one answered search, so a banner left over from a cleared
|
|
29
|
+
* query, from the other mode, or from the previous workspace is a claim about a
|
|
30
|
+
* result the panel is no longer showing. Pure so the gate can pin the rules.
|
|
31
|
+
*/
|
|
32
|
+
export declare function visibleSearchBanners(input: {
|
|
33
|
+
mode: 'name' | 'content';
|
|
34
|
+
ran: boolean;
|
|
35
|
+
nameTruncated: boolean;
|
|
36
|
+
contentTruncated: boolean;
|
|
37
|
+
linesClipped: boolean;
|
|
38
|
+
}): {
|
|
39
|
+
nameTruncated: boolean;
|
|
40
|
+
contentTruncated: boolean;
|
|
41
|
+
linesClipped: boolean;
|
|
42
|
+
};
|
|
43
|
+
/** First non-empty warning line from a finished search, or undefined. */
|
|
44
|
+
export declare function stderrWarning(stderr: string, maxChars?: number): string | undefined;
|
|
45
|
+
/**
|
|
46
|
+
* What clicking one NAME result should do.
|
|
47
|
+
*
|
|
48
|
+
* `find` can report a DIRECTORY, and `store.openFile()` has no type guard: a
|
|
49
|
+
* click used to hand the directory path to the editor (the Host answered
|
|
50
|
+
* "not a file: … is a directory" and the surface was switched for nothing).
|
|
51
|
+
*/
|
|
52
|
+
export declare function nameHitAction(hit: {
|
|
53
|
+
isDir: boolean;
|
|
54
|
+
}): 'reveal' | 'open';
|
|
55
|
+
/** True when a rejection is a user cancel (not a failure to report). */
|
|
56
|
+
export declare function isSearchCancellation(error: unknown, signal: AbortSignal | undefined): boolean;
|
|
57
|
+
/**
|
|
58
|
+
* One content search over the STREAMING exec route.
|
|
59
|
+
*
|
|
60
|
+
* `api.exec` cannot be cancelled: a replaced query left the remote `grep`
|
|
61
|
+
* running for its whole 120 s budget while the client ignored the answer.
|
|
62
|
+
* `execStream` carries an AbortSignal and the Host kills the remote process
|
|
63
|
+
* group when the response closes, so a cancelled search really stops. The
|
|
64
|
+
* route forwards output as SSE frames instead of `stdout`/`stderr`, so they are
|
|
65
|
+
* accumulated here and handed to the same parser as before. A Host without the
|
|
66
|
+
* route (404/405) is remembered and served by `api.exec` from then on.
|
|
67
|
+
*/
|
|
68
|
+
export declare function runContentSearch(alias: string, command: string, signal: AbortSignal): Promise<RemoteExecResult>;
|
|
14
69
|
export declare function SearchView(): ReactNode;
|
|
@@ -10,6 +10,44 @@
|
|
|
10
10
|
import { type ReactNode } from 'react';
|
|
11
11
|
import type { RemoteHostSummary } from '../protocol.ts';
|
|
12
12
|
import type { TerminalRequest } from './store.tsx';
|
|
13
|
+
/** First mount claims the panel, so a single-surface profile renders at once. */
|
|
14
|
+
export declare function claimTerminalOwnerIfNone(id: symbol): void;
|
|
15
|
+
/** Whether `id` is the surface that currently owns the terminal panel. */
|
|
16
|
+
export declare function terminalSurfaceOwnedBy(owner: symbol | undefined, id: symbol): boolean;
|
|
17
|
+
/** Why a terminal connection ended — and therefore whether the shell may live on. */
|
|
18
|
+
export type TerminalExitKind =
|
|
19
|
+
/** The socket went away; the Host keeps the PTY for 10 minutes and can reattach. */
|
|
20
|
+
'reattach'
|
|
21
|
+
/** The remote shell really exited (or refused the connection at the shell level). */
|
|
22
|
+
| 'exited'
|
|
23
|
+
/** The Host no longer knows this session id: drop it and open a fresh shell. */
|
|
24
|
+
| 'expired';
|
|
25
|
+
/**
|
|
26
|
+
* Classify one terminal exit report.
|
|
27
|
+
*
|
|
28
|
+
* `XTerm` reports the ssh channel's exit code and, for socket-level problems, a
|
|
29
|
+
* message with `code === null`. A socket that closes with neither (page reload,
|
|
30
|
+
* network blip, laptop sleep) must NOT destroy the tab's `session` id: the Host
|
|
31
|
+
* keeps the PTY for `EMPTY_SOCKET_TTL_MS`, so the right answer is "keep the id,
|
|
32
|
+
* offer a reattach". Only a real exit (a code, or a shell-level error message)
|
|
33
|
+
* ends the session.
|
|
34
|
+
*/
|
|
35
|
+
export declare function classifyTerminalExit(code: number | null, message: string | undefined): TerminalExitKind;
|
|
36
|
+
/** What one tab should look like after an exit report. */
|
|
37
|
+
export interface TerminalExitState {
|
|
38
|
+
connected: boolean;
|
|
39
|
+
/** Kept for `reattach`, cleared for `exited`/`expired`. */
|
|
40
|
+
session: string | undefined;
|
|
41
|
+
kind: TerminalExitKind;
|
|
42
|
+
/** i18n key for the note, when the note is a fixed sentence. */
|
|
43
|
+
noteKey?: 'term.disconnected' | 'term.closed';
|
|
44
|
+
/** Literal note (exit code or a host message), when it is not a fixed sentence. */
|
|
45
|
+
noteText?: string;
|
|
46
|
+
}
|
|
47
|
+
/** Apply {@link classifyTerminalExit} to one tab. Pure, so the gate can pin it. */
|
|
48
|
+
export declare function terminalExitState(tab: {
|
|
49
|
+
session?: string;
|
|
50
|
+
}, code: number | null, message: string | undefined): TerminalExitState;
|
|
13
51
|
export declare function TerminalView(props: {
|
|
14
52
|
t: (key: string) => string;
|
|
15
53
|
hosts: RemoteHostSummary[];
|
|
@@ -6,6 +6,23 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { type ReactNode } from 'react';
|
|
8
8
|
import type { RemoteHostSummary, RemoteWorkspaceBinding } from '../protocol.ts';
|
|
9
|
+
/**
|
|
10
|
+
* Whether an async result belongs to a host/attempt the wizard has left.
|
|
11
|
+
*
|
|
12
|
+
* Every step is host-scoped (`testHost`, `deployPush`, `stat` all take the alias
|
|
13
|
+
* captured when the request started), so a result that arrives after the user
|
|
14
|
+
* switched hosts — or after a newer attempt in the same step — must be dropped:
|
|
15
|
+
* otherwise host B inherits "tested"/"pushed"/"path verified" from host A, and
|
|
16
|
+
* the bind step can save a path nobody checked on B. Pure so the gate can pin it.
|
|
17
|
+
*/
|
|
18
|
+
export declare function isStaleWizardResult(requestSequence: number, currentSequence: number, requestAlias: string, currentAlias: string): boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Whether the path may be considered verified for the host ON SCREEN.
|
|
21
|
+
*
|
|
22
|
+
* `pathOk` alone is not enough: it is set by whichever `stat` answered last, and
|
|
23
|
+
* a host switch (or a slower, older verify) can leave it true for another host.
|
|
24
|
+
*/
|
|
25
|
+
export declare function wizardPathVerified(pathOk: boolean, verifiedAlias: string | undefined, currentAlias: string): boolean;
|
|
9
26
|
export declare function WorkspaceWizard(props: {
|
|
10
27
|
t: (k: string) => string;
|
|
11
28
|
hosts: RemoteHostSummary[];
|
|
@@ -1,9 +1,36 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Typed fetch wrapper over the /api/dsh-remote JSON API (full P0 surface).
|
|
3
3
|
*/
|
|
4
|
-
import { type GitBranch, type GitCommit, type GitShow, type GitStatus, type HelperAvailability, type ImportReport, type RemoteChangesDiff, type RemoteChangesSummary, type RemoteDeployState, type RemoteExecResult, type RemoteFileEntry, type RemoteHostSummary, type RemotePluginMeta, type RemoteProbe, type RemoteRead, type RemoteRoutingStatus, type RemoteTimeouts, type RemoteWorkspaceBinding } from '../protocol.ts';
|
|
4
|
+
import { type GitBranch, type GitCommit, type GitShow, type GitStatus, type HelperAvailability, type ImportReport, type RemoteChangesDiff, type RemoteChangesSummary, type RemoteConnectionStatus, type RemoteDeployState, type RemoteExecResult, type RemoteFileEntry, type RemoteHostSummary, type RemotePluginMeta, type RemoteProbe, type RemoteRead, type RemoteRoutingStatus, type RemoteTimeouts, type RemoteWorkspaceBinding, type RemoteWriteConflict, type RemoteWriteResult } from '../protocol.ts';
|
|
5
5
|
export declare class RemoteApiError extends Error {
|
|
6
6
|
readonly status: number;
|
|
7
|
+
/**
|
|
8
|
+
* The request failed because the SSH link did, not because the remote said no.
|
|
9
|
+
*
|
|
10
|
+
* Carried as a flag because the message can be REWRITTEN to a localized
|
|
11
|
+
* sentence for repeat failures; classification must survive that rewrite so
|
|
12
|
+
* callers (toast quieting, offline banners) keep treating it as transport.
|
|
13
|
+
*/
|
|
14
|
+
transport?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* The operation ran out of its budget; the link itself was not proven bad.
|
|
17
|
+
*
|
|
18
|
+
* Set from the Host's `code: 'deadline'`. It keeps classification honest: one
|
|
19
|
+
* slow request (a huge directory, an 8 MiB read on a thin link) must not flip
|
|
20
|
+
* the chip to "connection error" or downgrade the editor to read-only, while
|
|
21
|
+
* the operation still fails for the user with its readable reason.
|
|
22
|
+
*/
|
|
23
|
+
deadline?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* The remote file moved on since the version this buffer was based on.
|
|
26
|
+
*
|
|
27
|
+
* Carried as DATA, not prose: the editor has to offer overwrite / reload /
|
|
28
|
+
* see-the-difference, and that needs what is there now (`mtime`, `size`)
|
|
29
|
+
* without another round trip. The status is 409 for exactly this case — a
|
|
30
|
+
* plain 502 would read as "the host failed", which is the opposite of what
|
|
31
|
+
* happened (the Host successfully protected the file).
|
|
32
|
+
*/
|
|
33
|
+
conflict?: RemoteWriteConflict;
|
|
7
34
|
constructor(status: number, message: string);
|
|
8
35
|
}
|
|
9
36
|
/** Query for one remote terminal socket. */
|
|
@@ -84,6 +111,18 @@ export interface PushReportView {
|
|
|
84
111
|
action: 'pushed' | 'skipped-same' | 'failed';
|
|
85
112
|
detail: string;
|
|
86
113
|
}
|
|
114
|
+
/** Record one landed remote write (see {@link remoteWriteSequence}). */
|
|
115
|
+
export declare function noteRemoteWrite(): void;
|
|
116
|
+
/** The counter a cached listing must match to still be considered fresh. */
|
|
117
|
+
export declare function remoteWriteSequence(): number;
|
|
118
|
+
/**
|
|
119
|
+
* Does this remote command change the working tree?
|
|
120
|
+
*
|
|
121
|
+
* Exported so the gate can drive it directly: the SCM verbs do not pass through
|
|
122
|
+
* `api.fileOp`, so this predicate is the only thing that makes discard/checkout/
|
|
123
|
+
* stash invalidate the quick-open index at all.
|
|
124
|
+
*/
|
|
125
|
+
export declare function execChangesWorktree(command: string): boolean;
|
|
87
126
|
export declare const api: {
|
|
88
127
|
getHosts: () => Promise<RemoteHostSummary[]>;
|
|
89
128
|
createHost: (payload: HostForm) => Promise<RemoteHostSummary>;
|
|
@@ -96,6 +135,8 @@ export declare const api: {
|
|
|
96
135
|
error?: string;
|
|
97
136
|
durationMs: number;
|
|
98
137
|
}>;
|
|
138
|
+
/** Per-alias SSH connection health (Host pool's view; this is a local poll). */
|
|
139
|
+
connectionStatus: () => Promise<RemoteConnectionStatus[]>;
|
|
99
140
|
bootstrap: (alias: string) => Promise<{
|
|
100
141
|
alias: string;
|
|
101
142
|
keyPath: string;
|
|
@@ -106,9 +147,18 @@ export declare const api: {
|
|
|
106
147
|
list: (alias: string, path: string) => Promise<RemoteFileEntry[]>;
|
|
107
148
|
stat: (alias: string, path: string) => Promise<RemoteFileEntry>;
|
|
108
149
|
read: (alias: string, path: string) => Promise<RemoteRead>;
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
150
|
+
/**
|
|
151
|
+
* Write one file, optionally guarded by the version it was based on.
|
|
152
|
+
*
|
|
153
|
+
* `guard` is the save-conflict lock: the Host refuses (409, `code:
|
|
154
|
+
* 'conflict'`) when the remote file no longer matches, and the caller gets a
|
|
155
|
+
* `RemoteApiError` carrying `conflict`. Omitting it keeps the old
|
|
156
|
+
* unconditional write, which is what every programmatic caller wants.
|
|
157
|
+
*/
|
|
158
|
+
write: (alias: string, path: string, content: string, guard?: {
|
|
159
|
+
expectMtime?: number;
|
|
160
|
+
expectSize?: number;
|
|
161
|
+
}) => Promise<RemoteWriteResult>;
|
|
112
162
|
mkdir: (alias: string, path: string) => Promise<{
|
|
113
163
|
ok: boolean;
|
|
114
164
|
}>;
|
|
@@ -39,6 +39,22 @@ export interface UndoAffordanceOptions {
|
|
|
39
39
|
/** 悬停延迟,缺省 300ms。 */
|
|
40
40
|
hoverTime?: number;
|
|
41
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* 只读编辑器里不提供撤销(断线降级 / 超上限截断)。
|
|
44
|
+
*
|
|
45
|
+
* 撤销按钮点下去是一次远端写(`git apply -R`),所以只读时它必须消失:否则屏幕上
|
|
46
|
+
* 「只读(不能保存)」与「可写的撤销」并存,且请求只会在远端失败。判据读编辑器自己的
|
|
47
|
+
* `readOnly` facet —— 与 `CodeEditor` 的 readOnly Compartment 是同一个事实,不需要再传
|
|
48
|
+
* 一个 prop(第二个真相源迟早会漂)。
|
|
49
|
+
*
|
|
50
|
+
* 导出是为了让门禁能钉住这个判定(渲染 CodeMirror 的 DOM 级证明成本高,而这里的
|
|
51
|
+
* 语义只有"只读 ⇒ 不提供"一句话)。
|
|
52
|
+
*/
|
|
53
|
+
export declare function undoBlockedByReadOnly(view: {
|
|
54
|
+
state: {
|
|
55
|
+
readOnly: boolean;
|
|
56
|
+
};
|
|
57
|
+
}): boolean;
|
|
42
58
|
/**
|
|
43
59
|
* 装上「悬浮撤销」。
|
|
44
60
|
*
|
|
@@ -1,25 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* The coordinates the editor's "revert this change" action uses.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
4
|
+
* This module is the SLOT the store reads (`undoContext()`); it no longer decides
|
|
5
|
+
* anything. The value is written by the change panel from the provenance of the
|
|
6
|
+
* marks on screen — see `undo-target.ts`, which validates that the marks' session,
|
|
7
|
+
* binding and root still describe the tab the user is looking at. When validation
|
|
8
|
+
* fails the slot holds `undefined`, and the store's undo path refuses
|
|
9
|
+
* (`changes.undoNoContext`) instead of guessing a repository.
|
|
9
10
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* a time is enough because the panel only ever lists changes of the session on
|
|
14
|
-
* screen.
|
|
11
|
+
* Historically the slot was "the last summary this panel saw", which could point
|
|
12
|
+
* a revert at another conversation's — or a sibling binding's — repository. The
|
|
13
|
+
* revert writes to the remote, so the coordinates now travel with the marks.
|
|
15
14
|
*/
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
root: string;
|
|
21
|
-
}
|
|
22
|
-
/** Point the affordance at one session's remote workspace. */
|
|
15
|
+
import type { ChangeOrigin } from './undo-target.ts';
|
|
16
|
+
/** Coordinates one revert needs. Kept as the store's contract name. */
|
|
17
|
+
export type UndoContext = ChangeOrigin;
|
|
18
|
+
/** Publish the validated provenance for the tab currently on screen (or nothing). */
|
|
23
19
|
export declare function setUndoContext(context: UndoContext | undefined): void;
|
|
24
20
|
/** The coordinates a revert should use right now, if any. */
|
|
25
21
|
export declare function undoContext(): UndoContext | undefined;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Undo provenance: which repository a set of change marks belongs to.
|
|
3
|
+
*
|
|
4
|
+
* The revert (`git apply -R`, see `client/scm/actions.ts`) is the only user
|
|
5
|
+
* action in this plugin that WRITES to the remote, so its coordinates must come
|
|
6
|
+
* from the marks themselves — not from "whichever change panel updated last".
|
|
7
|
+
* The panel therefore records one {@link ChangeOrigin} per tab when it attaches
|
|
8
|
+
* the marks, and publishes it (validated) only while that tab is the one on
|
|
9
|
+
* screen. The store's undo path keeps calling `undoContext()` unchanged; it now
|
|
10
|
+
* receives proven provenance or nothing.
|
|
11
|
+
*
|
|
12
|
+
* Three failure modes this closes:
|
|
13
|
+
* - **cross-session**: the panel's session and the marks' session must agree, so
|
|
14
|
+
* switching conversations cannot leave session A's patch aimed at session B's
|
|
15
|
+
* coordinates;
|
|
16
|
+
* - **cross-binding (same alias)**: two bindings can share one host alias — one
|
|
17
|
+
* machine may hold two checkouts of the same tree. The alias is not an
|
|
18
|
+
* identity; the `bindingId` is, and the file path must sit under the recorded
|
|
19
|
+
* ledger root — otherwise a revert computed for one checkout can land in an
|
|
20
|
+
* identical sibling one, where git's context check would happily accept it;
|
|
21
|
+
* - **stale binding**: a binding edited or moved keeps its id but changes its
|
|
22
|
+
* alias/root; the recorded snapshot no longer matches, so the revert refuses
|
|
23
|
+
* instead of guessing.
|
|
24
|
+
*
|
|
25
|
+
* Pure functions + a bounded registry here (no React, no cordis), so
|
|
26
|
+
* `scripts/check-undo-target.mjs` drives the real decisions.
|
|
27
|
+
*/
|
|
28
|
+
import type { RemoteOpenBinding } from '../remote-file-open-target.ts';
|
|
29
|
+
/** Where one tab's change marks came from. */
|
|
30
|
+
export interface ChangeOrigin {
|
|
31
|
+
/** Session whose ledger produced the hunks. */
|
|
32
|
+
sessionId: string;
|
|
33
|
+
/** Binding identity at attach time (the ONE unique key; alias is not). */
|
|
34
|
+
bindingId: string;
|
|
35
|
+
/** Host alias snapshot, for the binding-changed check. */
|
|
36
|
+
alias: string;
|
|
37
|
+
/** Ledger root the patch paths are relative to (`git apply -R` runs here). */
|
|
38
|
+
root: string;
|
|
39
|
+
}
|
|
40
|
+
/** Why a revert must be refused. */
|
|
41
|
+
export type UndoRefusal = 'no-origin' | 'session-mismatch' | 'binding-gone' | 'binding-changed' | 'path-outside';
|
|
42
|
+
export type UndoTargetResult = {
|
|
43
|
+
ok: true;
|
|
44
|
+
origin: ChangeOrigin;
|
|
45
|
+
} | {
|
|
46
|
+
ok: false;
|
|
47
|
+
reason: UndoRefusal;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Decide whether a revert may run, and with which coordinates.
|
|
51
|
+
*
|
|
52
|
+
* @param input.origin - provenance recorded when the marks were attached.
|
|
53
|
+
* @param input.tabPath - the tab's absolute remote path (the file the patch names).
|
|
54
|
+
* @param input.panelSessionId - the session whose panel is on screen right now.
|
|
55
|
+
* @param input.bindings - the live binding table (`remoteOpenBindings()`).
|
|
56
|
+
*/
|
|
57
|
+
export declare function resolveUndoTarget(input: {
|
|
58
|
+
origin: ChangeOrigin | undefined;
|
|
59
|
+
tabPath: string;
|
|
60
|
+
panelSessionId: string | undefined;
|
|
61
|
+
bindings: readonly RemoteOpenBinding[];
|
|
62
|
+
}): UndoTargetResult;
|
|
63
|
+
/** Record where one tab's marks came from (called by the change panel). */
|
|
64
|
+
export declare function rememberChangeOrigin(tabId: string, origin: ChangeOrigin): void;
|
|
65
|
+
/** Drop one tab's provenance (marks cleared, file closed, diff failed). */
|
|
66
|
+
export declare function forgetChangeOrigin(tabId: string): void;
|
|
67
|
+
/** Provenance recorded for one tab, if any. */
|
|
68
|
+
export declare function changeOriginForTab(tabId: string | undefined): ChangeOrigin | undefined;
|
|
69
|
+
/**
|
|
70
|
+
* The value the undo slot should hold for the tab currently on screen: the tab's
|
|
71
|
+
* own validated provenance, or `undefined` (which makes undo refuse, never guess).
|
|
72
|
+
*/
|
|
73
|
+
export declare function publishableUndoOrigin(input: {
|
|
74
|
+
tabId: string | undefined;
|
|
75
|
+
tabPath: string | undefined;
|
|
76
|
+
panelSessionId: string | undefined;
|
|
77
|
+
bindings: readonly RemoteOpenBinding[];
|
|
78
|
+
}): ChangeOrigin | undefined;
|