dsh-remote-vs 0.29.0 → 0.31.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 +53 -20
- package/README.md +41 -19
- package/THIRD-PARTY-NOTICES.md +6 -6
- package/cordis.patch.yml +31 -76
- package/lib/client.js +319 -91
- package/lib/index.js +845 -129
- package/lib/p2-router-fs.js +15 -1
- package/lib/types/changes/recorder.d.ts +65 -10
- package/lib/types/changes/status.d.ts +48 -3
- package/lib/types/client/ConnectionsSection.d.ts +73 -0
- package/lib/types/client/WorkspacesView.d.ts +2 -0
- package/lib/types/client/api.d.ts +41 -2
- package/lib/types/client/composer.d.ts +8 -1
- package/lib/types/client/scm/actions.d.ts +25 -1
- package/lib/types/client/selection-popup.d.ts +1 -1
- package/lib/types/client/ui.d.ts +7 -4
- package/lib/types/p2/helper-rpc.d.ts +48 -0
- package/lib/types/p2/router-fs.d.ts +9 -1
- package/lib/types/p2/worlds.d.ts +51 -0
- package/lib/types/pool.d.ts +245 -10
- package/lib/types/protocol.d.ts +96 -0
- package/lib/{worlds-RG8K5eom.js → worlds-BdxLeKul.js} +134 -7
- package/package.json +46 -46
- package/src/changes/recorder.ts +151 -15
- package/src/changes/status.ts +59 -4
- package/src/client/ConnectionsSection.tsx +359 -0
- package/src/client/DirectoryFlow.tsx +8 -0
- package/src/client/EditorPane.tsx +5 -1
- package/src/client/HostsView.tsx +2 -0
- package/src/client/MonitorView.tsx +14 -0
- package/src/client/RemoteExplorer.tsx +11 -2
- package/src/client/RemoteRoot.tsx +1 -0
- package/src/client/SettingsHosts.tsx +1 -0
- package/src/client/WorkspaceWizard.tsx +1 -0
- package/src/client/WorkspacesView.tsx +21 -1
- package/src/client/api.ts +72 -4
- package/src/client/composer.ts +8 -1
- package/src/client/i18n.ts +50 -2
- package/src/client/scm/DiffView.tsx +5 -2
- package/src/client/scm/actions.ts +63 -12
- package/src/client/selection-popup.ts +1 -1
- package/src/client/ui.tsx +9 -7
- package/src/client/vsc/vsc.css +231 -3
- package/src/index.ts +31 -0
- package/src/p2/helper-rpc.ts +73 -5
- package/src/p2/router-fs.ts +29 -1
- package/src/p2/worlds.ts +116 -1
- package/src/pool.ts +736 -111
- package/src/protocol.ts +100 -0
- package/src/routes.ts +85 -13
- package/vendor/dsh-remote-helpers/dsh-ssh-helper-0.2.3-alpha.3-linux-x64.helper.json +20 -0
- package/vendor/dsh-remote-helpers/dsh-ssh-helper-0.2.3-alpha.3-linux-x64.tar.gz +4 -0
- package/vendor/dsh-remote-helpers/dsh-ssh-helper-0.2.3-alpha.3-linux-x64.tar.gz.sha256 +1 -0
- package/vendor/dsh-remote-helpers/pkg-sea-bare-import.patch +30 -0
- package/vendor/dsh-remote-helpers/ssh-helper-runtime-deps.patch +4 -3
- package/vendor/dsh-remote-helpers/dsh-ssh-helper-0.2.2-rc.4-linux-x64.helper.json +0 -19
- package/vendor/dsh-remote-helpers/dsh-ssh-helper-0.2.2-rc.4-linux-x64.tar.gz +0 -4
- package/vendor/dsh-remote-helpers/dsh-ssh-helper-0.2.2-rc.4-linux-x64.tar.gz.sha256 +0 -1
package/src/changes/status.ts
CHANGED
|
@@ -229,13 +229,24 @@ export function excludeDirNames(dirs: readonly string[] | undefined): string[] {
|
|
|
229
229
|
/**
|
|
230
230
|
* New files git is not tracking yet (the ones a session usually creates).
|
|
231
231
|
*
|
|
232
|
+
* `--directory` is the load-bearing flag. Without it git descends into every
|
|
233
|
+
* untracked directory and prints one path per FILE: measured on the reference
|
|
234
|
+
* monorepo that is 11.25s warm, and on a cold AOSP checkout past a minute. With
|
|
235
|
+
* it, an untracked directory is reported ONCE as `dir/` (trailing slash) and git
|
|
236
|
+
* stops descending — a build tree or an un-ignored dependency tree costs one
|
|
237
|
+
* record instead of thousands of `stat`s. The scan still has to walk the tracked
|
|
238
|
+
* part of the tree, but the expensive half is exactly the part that is skipped.
|
|
239
|
+
*
|
|
240
|
+
* The semantic cost is that the answer now names directories; the caller expands
|
|
241
|
+
* the ones it still wants files for with {@link untrackedExpandCommand}, within
|
|
242
|
+
* bounds of its own (see `UNTRACKED_EXPAND_DIRS` in `recorder.ts`). A file that
|
|
243
|
+
* git reports directly is already the final answer.
|
|
244
|
+
*
|
|
232
245
|
* The exclusions are pushed down as pathspecs (`:(exclude)out`) rather than
|
|
233
246
|
* filtered after the fact, so those paths never cross the wire and never enter
|
|
234
247
|
* the 500-row cap. Measured on a tree with 3000 build outputs + 300 sources:
|
|
235
248
|
* 3300 records / 61.5 KB unfiltered versus 300 records / 6.8 KB with two
|
|
236
|
-
* exclusions
|
|
237
|
-
* those directories), so the win is wire bytes, parse time and the read budget,
|
|
238
|
-
* not scan latency.
|
|
249
|
+
* exclusions.
|
|
239
250
|
*
|
|
240
251
|
* @param root - remote absolute POSIX directory (the session cwd).
|
|
241
252
|
* @param excludeDirs - directory names to leave out (see {@link excludeDirNames}).
|
|
@@ -244,7 +255,51 @@ export function excludeDirNames(dirs: readonly string[] | undefined): string[] {
|
|
|
244
255
|
export function untrackedCommand(root: string, excludeDirs: readonly string[] = []): string {
|
|
245
256
|
const excludes = excludeDirNames(excludeDirs).map(name => shq(`:(exclude)${name}`))
|
|
246
257
|
const pathspec = ['--', '.', ...excludes].join(' ')
|
|
247
|
-
return [cdLine(root), `git ls-files --others --exclude-standard -z ${pathspec}`].join('\n')
|
|
258
|
+
return [cdLine(root), `git ls-files --others --exclude-standard -z --directory ${pathspec}`].join('\n')
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Whether a `--directory` record names a collapsed DIRECTORY.
|
|
263
|
+
*
|
|
264
|
+
* git marks one with a trailing slash; a record without it is a file, which is
|
|
265
|
+
* already the final answer and must not be expanded again.
|
|
266
|
+
*/
|
|
267
|
+
export function isUntrackedDirectoryPath(path: string): boolean {
|
|
268
|
+
return path.endsWith('/')
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* List the files inside EVERY directory a {@link untrackedCommand} walk
|
|
273
|
+
* collapsed, in ONE command.
|
|
274
|
+
*
|
|
275
|
+
* Same walk, same exclusions, minus `--directory`: the caller gets file paths
|
|
276
|
+
* again. One command for all of them on purpose — git also collapses directories
|
|
277
|
+
* that hold nothing but IGNORED files (`build/` full of gitignored output) and
|
|
278
|
+
* empty ones, so a per-directory loop would spend a whole round trip (and one of
|
|
279
|
+
* the expansion slots) proving that such a directory has no visible file inside.
|
|
280
|
+
* Batched, an empty directory costs nothing and cannot push a real one out of
|
|
281
|
+
* the slot budget.
|
|
282
|
+
*
|
|
283
|
+
* Every directory comes from git's own output, but each still crosses a shell, so
|
|
284
|
+
* each goes through {@link shq} — a directory named `it's a 目录` is one quoted
|
|
285
|
+
* argument, never a second command or a flag.
|
|
286
|
+
*
|
|
287
|
+
* The trailing slash the fast walk adds is dropped: the pathspec names the
|
|
288
|
+
* directory either way, and a bare path keeps this builder from ever emitting
|
|
289
|
+
* `-- ''` (which would mean "the whole repository").
|
|
290
|
+
*
|
|
291
|
+
* @param root - remote absolute POSIX directory (the session cwd).
|
|
292
|
+
* @param dirs - collapsed directories from {@link untrackedCommand}, with or
|
|
293
|
+
* without their trailing slashes.
|
|
294
|
+
* @param excludeDirs - the same exclusions the fast walk used (nested build
|
|
295
|
+
* output inside a collapsed directory must stay out too).
|
|
296
|
+
*/
|
|
297
|
+
export function untrackedExpandCommand(root: string, dirs: readonly string[], excludeDirs: readonly string[] = []): string {
|
|
298
|
+
const targets = dirs.map(dir => dir.replace(/\/+$/, '')).filter(dir => dir !== '')
|
|
299
|
+
if (targets.length === 0) throw new Error('untracked expand needs at least one directory path')
|
|
300
|
+
const excludes = excludeDirNames(excludeDirs).map(name => shq(`:(exclude)${name}`))
|
|
301
|
+
const pathspec = [...targets.map(dir => shq(dir)), ...excludes].join(' ')
|
|
302
|
+
return [cdLine(root), `git ls-files --others --exclude-standard -z -- ${pathspec}`].join('\n')
|
|
248
303
|
}
|
|
249
304
|
|
|
250
305
|
/**
|
|
@@ -0,0 +1,359 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SSH connection-pool section shown on the monitor page, right under the
|
|
3
|
+
* process table.
|
|
4
|
+
*
|
|
5
|
+
* The pool is where "why is this slow" has an actual answer: one shared TCP
|
|
6
|
+
* connection per host carries exec/git/monitor traffic, terminals and port
|
|
7
|
+
* forwards dial their own, file operations ride a third, and each lane has a
|
|
8
|
+
* channel budget. When a budget is full the work QUEUES — and that is invisible
|
|
9
|
+
* from the file tree, where a slow listing just looks like a slow remote. So
|
|
10
|
+
* the page prints the four lanes, their channel counts, the slot occupancy and
|
|
11
|
+
* the route the shared connection took.
|
|
12
|
+
*
|
|
13
|
+
* Cost rules, the same ones the process section above follows:
|
|
14
|
+
* - collapsed by default; a collapsed section issues ZERO requests, because a
|
|
15
|
+
* closed diagnostic panel must not become the plugin's traffic source;
|
|
16
|
+
* - sampling happens only while the section is EXPANDED, the monitor panel is
|
|
17
|
+
* the visible view AND the page is in the foreground. There is no second
|
|
18
|
+
* throttle: the panel's own interval (and its pause control) is the cadence.
|
|
19
|
+
*
|
|
20
|
+
* Degradation: a Host that predates the route answers 404. That is not an error
|
|
21
|
+
* — the section keeps its header and prints ONE muted line saying so, instead of
|
|
22
|
+
* an error banner or an empty pool that would read as "nothing is connected".
|
|
23
|
+
* After it has said that it stops asking: the answer cannot change without an
|
|
24
|
+
* upgrade and a page reload.
|
|
25
|
+
*/
|
|
26
|
+
import { useCallback, useEffect, useMemo, useRef, useState, type ReactNode } from 'react'
|
|
27
|
+
import type {
|
|
28
|
+
RemoteHostPoolStats,
|
|
29
|
+
RemoteHostSummary,
|
|
30
|
+
RemotePoolLane,
|
|
31
|
+
RemotePoolStatsResult,
|
|
32
|
+
} from '../protocol.ts'
|
|
33
|
+
import { api, RemoteApiError } from './api.ts'
|
|
34
|
+
import { egressTitleLine } from './connection.ts'
|
|
35
|
+
import { MiniSpinner } from './vsc/kit.tsx'
|
|
36
|
+
|
|
37
|
+
/** Fallback cadence when the panel has no interval of its own. */
|
|
38
|
+
export const POOL_POLL_MS = 5_000
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Rounds waiting for a channel on ANY budget of one host.
|
|
42
|
+
*
|
|
43
|
+
* All three budgets are queues the user can be stuck behind, so the badge, the
|
|
44
|
+
* summary and the "a queue sorts first" rank count them together; which budget
|
|
45
|
+
* is full is the per-line detail below the lanes.
|
|
46
|
+
*/
|
|
47
|
+
export function queuedOf(host: RemoteHostPoolStats): number {
|
|
48
|
+
return host.slots.queued + (host.sftpSlots?.queued ?? 0) + (host.netSlots?.queued ?? 0) + (host.gitSlots?.queued ?? 0)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Channels riding that host's lanes (the header summary's "N connections").
|
|
53
|
+
*
|
|
54
|
+
* The helper counts too: it is its own SSH connection with one channel, and a
|
|
55
|
+
* summary that said "0 connections" while a helper session was up would be the
|
|
56
|
+
* one number on the page that lies. Its lane is absent when the Host cannot
|
|
57
|
+
* report it, and then it contributes nothing.
|
|
58
|
+
*/
|
|
59
|
+
export function channelsOf(host: RemoteHostPoolStats): number {
|
|
60
|
+
const lanes = host.connections
|
|
61
|
+
return lanes.shared.channels + lanes.pty.channels + lanes.forward.channels + lanes.sftp.channels
|
|
62
|
+
+ (lanes.helper?.channels ?? 0)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Host order: the CURRENT host first, then a queue, then alias.
|
|
67
|
+
*
|
|
68
|
+
* The current host is the one the workspace is bound to, so its numbers are the
|
|
69
|
+
* answer to "why is what I am doing slow" — it belongs at the top even when it
|
|
70
|
+
* has nothing queued. Everything below keeps the rules this list was built on:
|
|
71
|
+
* a queued host outranks an idle one, and the rest is alias order.
|
|
72
|
+
*
|
|
73
|
+
* The host with work waiting behind a full budget is the one the user is
|
|
74
|
+
* looking for, so "has a queue" is the only promotion. The rank is a BOOLEAN on
|
|
75
|
+
* purpose: ranking by the queue DEPTH made rows swap places between polls (a
|
|
76
|
+
* host draining from 3 queued to 1 slid under a host at 2 — the same two hosts,
|
|
77
|
+
* a different order, nothing the user could have come to read). Everything else
|
|
78
|
+
* keeps a fixed order; the number itself is on the row's badge and in the
|
|
79
|
+
* summary. Aliases compare by code unit, not `localeCompare`: the order must
|
|
80
|
+
* not depend on the browser's locale.
|
|
81
|
+
*/
|
|
82
|
+
export function sortPoolHosts(
|
|
83
|
+
hosts: readonly RemoteHostPoolStats[],
|
|
84
|
+
currentAlias = '',
|
|
85
|
+
): RemoteHostPoolStats[] {
|
|
86
|
+
return [...hosts].sort((left, right) => {
|
|
87
|
+
// `currentAlias` is '' when no workspace is bound: nothing matches, so no
|
|
88
|
+
// host is promoted by identity (an alias is never the empty string).
|
|
89
|
+
const current = Number(right.alias === currentAlias) - Number(left.alias === currentAlias)
|
|
90
|
+
if (current !== 0) return current
|
|
91
|
+
const rank = Number(queuedOf(right) > 0) - Number(queuedOf(left) > 0)
|
|
92
|
+
if (rank !== 0) return rank
|
|
93
|
+
return left.alias < right.alias ? -1 : left.alias > right.alias ? 1 : 0
|
|
94
|
+
})
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* One connection kind: its name, dialled-or-not, and how many channels ride it.
|
|
99
|
+
* `egress` is passed for the shared lane only — it is the route that connection
|
|
100
|
+
* took, already worded by `connection.ts` — `fallback` for the file-transfer
|
|
101
|
+
* lane, which says the files are riding the shared connection instead of their
|
|
102
|
+
* own, and `inFlight` for the helper lane, whose `held` counts RPC calls inside
|
|
103
|
+
* the connection rather than a queue (so it is a clause, not a budget line).
|
|
104
|
+
*/
|
|
105
|
+
function PoolLane(props: {
|
|
106
|
+
t: (key: string) => string
|
|
107
|
+
label: string
|
|
108
|
+
lane: RemotePoolLane
|
|
109
|
+
egress?: string | undefined
|
|
110
|
+
fallback?: string | undefined
|
|
111
|
+
inFlight?: string | undefined
|
|
112
|
+
}): ReactNode {
|
|
113
|
+
const t = props.t
|
|
114
|
+
return (
|
|
115
|
+
<div className="rvs-pool-lane">
|
|
116
|
+
<span className="rvs-pool-lane-name">{props.label}</span>
|
|
117
|
+
<span className={props.lane.open ? 'rvs-pool-lane-state open' : 'rvs-pool-lane-state'}>
|
|
118
|
+
{props.lane.open ? t('pool.laneOpen') : t('pool.laneClosed')}
|
|
119
|
+
{' · '}
|
|
120
|
+
{t('pool.channels').replace('{channels}', String(props.lane.channels))}
|
|
121
|
+
{props.inFlight !== undefined && (<>{' · '}{props.inFlight}</>)}
|
|
122
|
+
</span>
|
|
123
|
+
{props.egress !== undefined && (
|
|
124
|
+
<span className="rvs-pool-egress" title={props.egress}>{props.egress}</span>
|
|
125
|
+
)}
|
|
126
|
+
{props.fallback !== undefined && (
|
|
127
|
+
<span className="rvs-pool-fallback" title={props.fallback}>{props.fallback}</span>
|
|
128
|
+
)}
|
|
129
|
+
</div>
|
|
130
|
+
)
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/** One host's pool: the four lanes, then its channel budget(s). */
|
|
134
|
+
function PoolHost(props: { t: (key: string) => string; host: RemoteHostPoolStats }): ReactNode {
|
|
135
|
+
const t = props.t
|
|
136
|
+
const host = props.host
|
|
137
|
+
const queued = queuedOf(host)
|
|
138
|
+
// The live route of the held shared connection, worded once by `connection.ts`
|
|
139
|
+
// (an absent egress means the shared connection is not dialled — say nothing
|
|
140
|
+
// rather than guess a route).
|
|
141
|
+
const egress = host.egress === undefined ? undefined : egressTitleLine({ egress: host.egress }, t)
|
|
142
|
+
// A host that refused its own SFTP connection still serves files, over the
|
|
143
|
+
// shared connection. Without this line the "file transfer: closed, 0 channels"
|
|
144
|
+
// row would read as "files are down", which is the opposite of the truth.
|
|
145
|
+
const fallback = host.sftpFallback === true ? t('pool.sftpFallback') : undefined
|
|
146
|
+
/**
|
|
147
|
+
* The SSH helper (the p2 transport: the file/Git fast path).
|
|
148
|
+
*
|
|
149
|
+
* It dials from `p2/worlds.ts`, not from the pool, so the key is OPTIONAL — a
|
|
150
|
+
* Host that cannot report it omits it rather than claiming "closed" — and its
|
|
151
|
+
* `held` counts RPC calls IN FLIGHT, not work waiting for a channel. That
|
|
152
|
+
* difference is load-bearing in two places:
|
|
153
|
+
* - it is a clause on the row (`3 calls in flight`), never a budget line: the
|
|
154
|
+
* helper has no channel limit to compare `active/limit` against;
|
|
155
|
+
* - it is NOT part of `queuedOf`, so a busy helper never paints a queue badge,
|
|
156
|
+
* never promotes its host in the ordering and never inflates the summary's
|
|
157
|
+
* queue count. A saturated helper is busy, not blocked.
|
|
158
|
+
*/
|
|
159
|
+
const helper = host.connections.helper
|
|
160
|
+
const helperInFlight = helper === undefined || helper.held <= 0
|
|
161
|
+
? undefined
|
|
162
|
+
: t('pool.helperInFlight').replace('{count}', String(helper.held))
|
|
163
|
+
return (
|
|
164
|
+
<div className="rvs-pool-host" role="group" aria-label={host.alias}>
|
|
165
|
+
<div className="rvs-pool-host-head">
|
|
166
|
+
<span className="rvs-pool-host-alias" title={host.alias}>{host.alias}</span>
|
|
167
|
+
{queued > 0 && (
|
|
168
|
+
<span className="rvs-pool-queue">{t('pool.queued').replace('{queued}', String(queued))}</span>
|
|
169
|
+
)}
|
|
170
|
+
</div>
|
|
171
|
+
<PoolLane t={t} label={t('pool.shared')} lane={host.connections.shared} egress={egress} />
|
|
172
|
+
<PoolLane t={t} label={t('pool.pty')} lane={host.connections.pty} />
|
|
173
|
+
<PoolLane t={t} label={t('pool.forward')} lane={host.connections.forward} />
|
|
174
|
+
<PoolLane t={t} label={t('pool.sftp')} lane={host.connections.sftp} fallback={fallback} />
|
|
175
|
+
{/* Fifth, and after the four pool lanes on purpose: the pool owns those,
|
|
176
|
+
the p2 layer owns this one, and an absent key means "no helper to
|
|
177
|
+
report" rather than "closed". */}
|
|
178
|
+
{helper !== undefined && (
|
|
179
|
+
<PoolLane t={t} label={t('pool.helper')} lane={helper} inFlight={helperInFlight} />
|
|
180
|
+
)}
|
|
181
|
+
<div className="rvs-pool-slots">
|
|
182
|
+
{t('pool.slots')
|
|
183
|
+
.replace('{active}', String(host.slots.active))
|
|
184
|
+
.replace('{limit}', String(host.slots.limit))
|
|
185
|
+
.replace('{queued}', String(host.slots.queued))}
|
|
186
|
+
</div>
|
|
187
|
+
{host.sftpSlots !== undefined && (
|
|
188
|
+
<div className="rvs-pool-slots">
|
|
189
|
+
{t('pool.sftpSlots')
|
|
190
|
+
.replace('{active}', String(host.sftpSlots.active))
|
|
191
|
+
.replace('{limit}', String(host.sftpSlots.limit))
|
|
192
|
+
.replace('{queued}', String(host.sftpSlots.queued))}
|
|
193
|
+
</div>
|
|
194
|
+
)}
|
|
195
|
+
{/* Network verbs (git fetch/pull/push) hold a channel for the whole network
|
|
196
|
+
timeout, so they have their own small budget; the line only appears while
|
|
197
|
+
one is running, which is also when the shared budget is NOT the thing
|
|
198
|
+
holding them up. */}
|
|
199
|
+
{host.netSlots !== undefined && (
|
|
200
|
+
<div className="rvs-pool-slots">
|
|
201
|
+
{t('pool.netSlots')
|
|
202
|
+
.replace('{active}', String(host.netSlots.active))
|
|
203
|
+
.replace('{limit}', String(host.netSlots.limit))
|
|
204
|
+
.replace('{queued}', String(host.netSlots.queued))}
|
|
205
|
+
</div>
|
|
206
|
+
)}
|
|
207
|
+
{/* Git commands (the `git status`/`diff`/`log` reads, the ledger's own
|
|
208
|
+
scans, and the SCM panel's local writes) take seconds on a big tree, so
|
|
209
|
+
they have a budget of their own rather than eating the exec slots the
|
|
210
|
+
monitor and agent tools need. Printed only while one is running or
|
|
211
|
+
waiting, like the two budgets above. */}
|
|
212
|
+
{host.gitSlots !== undefined && (
|
|
213
|
+
<div className="rvs-pool-slots">
|
|
214
|
+
{t('pool.gitSlots')
|
|
215
|
+
.replace('{active}', String(host.gitSlots.active))
|
|
216
|
+
.replace('{limit}', String(host.gitSlots.limit))
|
|
217
|
+
.replace('{queued}', String(host.gitSlots.queued))}
|
|
218
|
+
</div>
|
|
219
|
+
)}
|
|
220
|
+
</div>
|
|
221
|
+
)
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
export function ConnectionsSection(props: {
|
|
225
|
+
t: (key: string) => string
|
|
226
|
+
hosts: RemoteHostSummary[]
|
|
227
|
+
visible: boolean
|
|
228
|
+
paused: boolean
|
|
229
|
+
intervalMs: number
|
|
230
|
+
/** Alias of the host this workspace is bound to (sorted first). */
|
|
231
|
+
currentAlias?: string
|
|
232
|
+
}): ReactNode {
|
|
233
|
+
const t = props.t
|
|
234
|
+
const [expanded, setExpanded] = useState(false)
|
|
235
|
+
const [result, setResult] = useState<RemotePoolStatsResult | undefined>(undefined)
|
|
236
|
+
/** The Host answered 404: the route does not exist in this version. */
|
|
237
|
+
const [unsupported, setUnsupported] = useState(false)
|
|
238
|
+
const [error, setError] = useState<string | undefined>(undefined)
|
|
239
|
+
/** One request at a time: an interval tick cannot open a second channel. */
|
|
240
|
+
const inFlight = useRef(false)
|
|
241
|
+
const alive = useRef(true)
|
|
242
|
+
|
|
243
|
+
useEffect(() => {
|
|
244
|
+
alive.current = true
|
|
245
|
+
return () => { alive.current = false }
|
|
246
|
+
}, [])
|
|
247
|
+
|
|
248
|
+
const load = useCallback(async (): Promise<void> => {
|
|
249
|
+
if (inFlight.current) return
|
|
250
|
+
inFlight.current = true
|
|
251
|
+
try {
|
|
252
|
+
const next = await api.getPoolStats()
|
|
253
|
+
if (!alive.current) return
|
|
254
|
+
// `undefined` is the Host saying "I do not know this route" (404). Keep
|
|
255
|
+
// the header, say it once, and stop sampling (see the module docstring).
|
|
256
|
+
if (next === undefined) {
|
|
257
|
+
setUnsupported(true)
|
|
258
|
+
return
|
|
259
|
+
}
|
|
260
|
+
setResult(next)
|
|
261
|
+
setError(undefined)
|
|
262
|
+
} catch (caught) {
|
|
263
|
+
if (!alive.current) return
|
|
264
|
+
setError(caught instanceof RemoteApiError ? caught.message : String(caught))
|
|
265
|
+
} finally {
|
|
266
|
+
inFlight.current = false
|
|
267
|
+
}
|
|
268
|
+
}, [])
|
|
269
|
+
|
|
270
|
+
// The ONLY sampling sites: the immediate first sample plus the interval. Same
|
|
271
|
+
// guards as the process section above — expanded, panel visible, page not
|
|
272
|
+
// paused — and the tick itself re-checks `document.hidden`, so a background
|
|
273
|
+
// tab stops asking immediately instead of after the next interval.
|
|
274
|
+
useEffect(() => {
|
|
275
|
+
if (!expanded || !props.visible || props.paused || unsupported) return
|
|
276
|
+
const tick = (): void => {
|
|
277
|
+
if (document.hidden) return
|
|
278
|
+
void load()
|
|
279
|
+
}
|
|
280
|
+
tick()
|
|
281
|
+
const timer = window.setInterval(tick, Math.max(2_000, props.intervalMs || POOL_POLL_MS))
|
|
282
|
+
return () => window.clearInterval(timer)
|
|
283
|
+
}, [expanded, props.visible, props.paused, unsupported, load, props.intervalMs])
|
|
284
|
+
|
|
285
|
+
useEffect(() => {
|
|
286
|
+
if (!expanded || !props.visible || props.paused || unsupported) return
|
|
287
|
+
const onVisible = (): void => {
|
|
288
|
+
if (!document.hidden) void load()
|
|
289
|
+
}
|
|
290
|
+
document.addEventListener('visibilitychange', onVisible)
|
|
291
|
+
return () => document.removeEventListener('visibilitychange', onVisible)
|
|
292
|
+
}, [expanded, props.visible, props.paused, unsupported, load])
|
|
293
|
+
|
|
294
|
+
const currentAlias = props.currentAlias ?? ''
|
|
295
|
+
const hosts = useMemo(
|
|
296
|
+
() => sortPoolHosts(result?.hosts ?? [], currentAlias),
|
|
297
|
+
[result, currentAlias],
|
|
298
|
+
)
|
|
299
|
+
const summary = useMemo(() => {
|
|
300
|
+
if (result === undefined) return undefined
|
|
301
|
+
return {
|
|
302
|
+
hosts: hosts.length,
|
|
303
|
+
connections: hosts.reduce((total, host) => total + channelsOf(host), 0),
|
|
304
|
+
queued: hosts.reduce((total, host) => total + queuedOf(host), 0),
|
|
305
|
+
}
|
|
306
|
+
}, [result, hosts])
|
|
307
|
+
|
|
308
|
+
// Nothing to diagnose before the first host exists; the panel's own "no hosts"
|
|
309
|
+
// banner already explains the empty page.
|
|
310
|
+
if (props.hosts.length === 0) return null
|
|
311
|
+
|
|
312
|
+
const loading = expanded && !unsupported && error === undefined && result === undefined
|
|
313
|
+
|
|
314
|
+
return (
|
|
315
|
+
<section className={expanded ? 'rvs-pool expanded' : 'rvs-pool'} aria-label={t('pool.title')}>
|
|
316
|
+
<div className="rvs-pool-head">
|
|
317
|
+
<button
|
|
318
|
+
type="button"
|
|
319
|
+
className="rvs-pool-toggle"
|
|
320
|
+
aria-expanded={expanded}
|
|
321
|
+
onClick={() => { setExpanded(value => !value) }}
|
|
322
|
+
title={expanded ? t('pool.collapse') : t('pool.expand')}
|
|
323
|
+
>
|
|
324
|
+
<span aria-hidden="true">{expanded ? '▾' : '▸'}</span>
|
|
325
|
+
</button>
|
|
326
|
+
<span className="rvs-pool-title">{t('pool.title')}</span>
|
|
327
|
+
{summary !== undefined && (
|
|
328
|
+
// `aria-live` lives HERE, not on the list: the numbers above are one
|
|
329
|
+
// short sentence whose change is worth announcing (a queue appeared,
|
|
330
|
+
// a channel was freed), while the table below re-renders every 5 s —
|
|
331
|
+
// a live region around it makes a screen reader re-read every lane on
|
|
332
|
+
// each poll.
|
|
333
|
+
<span className="rvs-pool-summary" aria-live="polite">
|
|
334
|
+
{t('pool.summary')
|
|
335
|
+
.replace('{hosts}', String(summary.hosts))
|
|
336
|
+
.replace('{connections}', String(summary.connections))
|
|
337
|
+
.replace('{queued}', String(summary.queued))}
|
|
338
|
+
</span>
|
|
339
|
+
)}
|
|
340
|
+
</div>
|
|
341
|
+
{!expanded && <div className="rvs-pool-collapsed">{t('pool.collapsedHint')}</div>}
|
|
342
|
+
{expanded && unsupported && <div className="rvs-pool-note">{t('pool.unsupported')}</div>}
|
|
343
|
+
{expanded && !unsupported && error !== undefined && <div className="rvs-pool-note error">{error}</div>}
|
|
344
|
+
{loading && (
|
|
345
|
+
<div className="rvs-pool-note">
|
|
346
|
+
<MiniSpinner /> {t('pool.loading')}
|
|
347
|
+
</div>
|
|
348
|
+
)}
|
|
349
|
+
{expanded && !unsupported && result !== undefined && hosts.length === 0 && (
|
|
350
|
+
<div className="rvs-pool-note">{t('pool.empty')}</div>
|
|
351
|
+
)}
|
|
352
|
+
{expanded && hosts.length > 0 && (
|
|
353
|
+
<div className="rvs-pool-list rvs-scroll">
|
|
354
|
+
{hosts.map(host => <PoolHost key={host.alias} t={t} host={host} />)}
|
|
355
|
+
</div>
|
|
356
|
+
)}
|
|
357
|
+
</section>
|
|
358
|
+
)
|
|
359
|
+
}
|
|
@@ -25,6 +25,7 @@ import type { RemoteHostSummary } from '../protocol.ts'
|
|
|
25
25
|
import { RemoteApiError, api } from './api.ts'
|
|
26
26
|
import { WorkspaceWizard } from './WorkspaceWizard.tsx'
|
|
27
27
|
import { detectLang, makeT } from './i18n.ts'
|
|
28
|
+
import { refreshAll } from './store.tsx'
|
|
28
29
|
import { Btn, Notice } from './ui.tsx'
|
|
29
30
|
|
|
30
31
|
/**
|
|
@@ -378,6 +379,13 @@ function RemoteLeg(props: {
|
|
|
378
379
|
onSaved={(_workspace, aliasPath) => {
|
|
379
380
|
setDone(true)
|
|
380
381
|
traceFlow('remote wizard saved', aliasPath)
|
|
382
|
+
// The workbench store (hosts + bindings + routing) is module state
|
|
383
|
+
// bootstrapped once per page; adopting a NEW binding through this
|
|
384
|
+
// stock-owner dialog used to leave it stale, so the Remote panel's
|
|
385
|
+
// 「工作区」 list did not show the workspace the user just created
|
|
386
|
+
// until a page reload. The panel's own wizard refreshes through
|
|
387
|
+
// `onDone`; this path has no such hook, so it refreshes here.
|
|
388
|
+
refreshAll()
|
|
381
389
|
props.onPicked(aliasPath)
|
|
382
390
|
}}
|
|
383
391
|
/>
|
|
@@ -1727,7 +1727,11 @@ export function EditorPane(props: { visible: boolean }): ReactNode {
|
|
|
1727
1727
|
wrap={settings.wrap}
|
|
1728
1728
|
ctx={store.ctx}
|
|
1729
1729
|
sessionId={chat.sessionId}
|
|
1730
|
-
|
|
1730
|
+
// The mention geometry is workspace-rooted. `repoRoot` is
|
|
1731
|
+
// the SCM panel's selected repository and may be a
|
|
1732
|
+
// subdirectory of the workspace (or an enclosing one), so
|
|
1733
|
+
// rooting selections there silently drops or shifts paths.
|
|
1734
|
+
remoteRoot={store.root}
|
|
1731
1735
|
chatEnabled={chatEnabled}
|
|
1732
1736
|
addLabel={t('files.addToConversation')}
|
|
1733
1737
|
{...(activeTab.line === undefined ? {} : { revealLine: activeTab.line })}
|
package/src/client/HostsView.tsx
CHANGED
|
@@ -287,6 +287,7 @@ export function ProxyFields(props: {
|
|
|
287
287
|
<div style={{ flex: 1.1 }}>
|
|
288
288
|
<Field label={t('proxy.kind')}>
|
|
289
289
|
<select
|
|
290
|
+
className="rvs-dropdown"
|
|
290
291
|
value={state.kind}
|
|
291
292
|
disabled={disabled}
|
|
292
293
|
onChange={(e) => set({ kind: e.target.value === 'socks5' ? 'socks5' : 'http' })}
|
|
@@ -445,6 +446,7 @@ function HostProxySection(props: {
|
|
|
445
446
|
<>
|
|
446
447
|
<Field label={t('proxy.jumpVia')}>
|
|
447
448
|
<select
|
|
449
|
+
className="rvs-dropdown"
|
|
448
450
|
value={state.viaAlias}
|
|
449
451
|
disabled={props.busy}
|
|
450
452
|
onChange={(e) => set({ viaAlias: e.target.value })}
|
|
@@ -31,6 +31,7 @@ import { useExplorer } from './store.tsx'
|
|
|
31
31
|
import { optionStyle } from './ui.tsx'
|
|
32
32
|
import { IconButton, IconRefresh, MiniSpinner, Segmented } from './vsc/kit.tsx'
|
|
33
33
|
import { ProcessesSection } from './ProcessesSection.tsx'
|
|
34
|
+
import { ConnectionsSection } from './ConnectionsSection.tsx'
|
|
34
35
|
|
|
35
36
|
/** Visible-panel poll cadence. The Host's own reuse window is shorter (3 s). */
|
|
36
37
|
export const MONITOR_POLL_MS = 5_000
|
|
@@ -641,6 +642,19 @@ export function MonitorView(props: {
|
|
|
641
642
|
paused={paused}
|
|
642
643
|
intervalMs={intervalMs}
|
|
643
644
|
/>
|
|
645
|
+
{/* Last, and for a reason: the metrics and processes above are what the
|
|
646
|
+
page was opened for; the pool shape explains WHY they are slow, so it
|
|
647
|
+
reads as the footnote to both. Two collapsed sections stack at the
|
|
648
|
+
bottom of the pane; whichever one is expanded takes the leftover
|
|
649
|
+
height (see `.rvs-monitor-body:has(.rvs-proc.expanded)`). */}
|
|
650
|
+
<ConnectionsSection
|
|
651
|
+
t={t}
|
|
652
|
+
hosts={props.hosts}
|
|
653
|
+
visible={props.visible}
|
|
654
|
+
paused={paused}
|
|
655
|
+
intervalMs={intervalMs}
|
|
656
|
+
currentAlias={currentAlias}
|
|
657
|
+
/>
|
|
644
658
|
</div>
|
|
645
659
|
</div>
|
|
646
660
|
)
|
|
@@ -2641,7 +2641,14 @@ export function RemoteExplorer(props: { showHidden: boolean; onToggleHidden: ()
|
|
|
2641
2641
|
onSelect: () => {
|
|
2642
2642
|
if (chatTarget.sessionId === undefined) return
|
|
2643
2643
|
for (const item of targets) {
|
|
2644
|
-
|
|
2644
|
+
// The mention is WORKSPACE-relative: the model resolves it against
|
|
2645
|
+
// the session workspace root. `repoRoot` is the SCM panel's selected
|
|
2646
|
+
// repository, which may be a SUBDIRECTORY of the workspace (or an
|
|
2647
|
+
// enclosing repository above it) — rooting mentions there made every
|
|
2648
|
+
// file outside that repository unrepresentable and every file inside
|
|
2649
|
+
// it off by the repository prefix. See the reference-root rule in
|
|
2650
|
+
// composer.ts's `remoteRelativePath`.
|
|
2651
|
+
insertRemoteReference(ctx, chatTarget.sessionId, root, item.path, item.isDir)
|
|
2645
2652
|
}
|
|
2646
2653
|
},
|
|
2647
2654
|
disabled: !chatEnabled,
|
|
@@ -2887,7 +2894,9 @@ export function RemoteExplorer(props: { showHidden: boolean; onToggleHidden: ()
|
|
|
2887
2894
|
cancelRename: () => setRenaming(undefined),
|
|
2888
2895
|
reference: (entry) => {
|
|
2889
2896
|
if (chatTarget.sessionId === undefined) return
|
|
2890
|
-
|
|
2897
|
+
// Workspace-rooted, never `repoRoot`: see the rule at the context-menu
|
|
2898
|
+
// call site above (the selected repository may be a workspace subdir).
|
|
2899
|
+
insertRemoteReference(ctx, chatTarget.sessionId, root, entry.path, entry.isDir)
|
|
2891
2900
|
},
|
|
2892
2901
|
keyDown: onRowKeyDown,
|
|
2893
2902
|
focusPath: (path) => { setFocusedPath(path) },
|
|
@@ -502,6 +502,7 @@ function Shell(props: { ctx: Context; visible: boolean }): ReactNode {
|
|
|
502
502
|
workspaces={store.workspaces}
|
|
503
503
|
routing={store.routing}
|
|
504
504
|
onChanged={store.refreshAll}
|
|
505
|
+
visible={panelLive('workspaces')}
|
|
505
506
|
onOpenFiles={openWorkspaceFiles}
|
|
506
507
|
/>
|
|
507
508
|
</div>
|
|
@@ -188,6 +188,7 @@ export function SettingsHostsSection(_props: SettingsSectionOwnerProps): ReactNo
|
|
|
188
188
|
<Row>
|
|
189
189
|
<span style={{ fontSize: 12, opacity: 0.75 }}>{t('route.mode')}</span>
|
|
190
190
|
<select
|
|
191
|
+
className="rvs-dropdown"
|
|
191
192
|
value={mode}
|
|
192
193
|
disabled={saving}
|
|
193
194
|
onChange={(e) => changeMode(e.target.value as 'off' | 'shadow' | 'enforce')}
|
|
@@ -222,6 +222,7 @@ export function WorkspaceWizard(props: {
|
|
|
222
222
|
<div style={{ marginTop: 8, fontWeight: 600 }}>{t('ws.step1')}</div>
|
|
223
223
|
<Row>
|
|
224
224
|
<select
|
|
225
|
+
className="rvs-dropdown"
|
|
225
226
|
value={alias}
|
|
226
227
|
disabled={disabled || props.hosts.length === 0}
|
|
227
228
|
onChange={(e) => pick(e.target.value)}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Workspaces view: bindings list + the shared new-remote-workspace wizard.
|
|
3
3
|
*/
|
|
4
|
-
import { useState, type ReactNode } from 'react'
|
|
4
|
+
import { useEffect, useRef, useState, type ReactNode } from 'react'
|
|
5
5
|
import type { RemoteHostSummary, RemoteRoutingStatus, RemoteWorkspaceBinding } from '../protocol.ts'
|
|
6
6
|
import { RemoteApiError, api } from './api.ts'
|
|
7
7
|
import { WorkspaceWizard } from './WorkspaceWizard.tsx'
|
|
@@ -18,6 +18,8 @@ export function WorkspacesView(props: {
|
|
|
18
18
|
workspaces: RemoteWorkspaceBinding[]
|
|
19
19
|
routing: RemoteRoutingStatus
|
|
20
20
|
onChanged: () => void
|
|
21
|
+
/** False while the panel is off screen: the live poll below only runs on screen. */
|
|
22
|
+
visible?: boolean
|
|
21
23
|
/** Open the files view for a binding; omitted where no files view exists (settings section hides the button). */
|
|
22
24
|
onOpenFiles?: (workspaceId: string) => void
|
|
23
25
|
}): ReactNode {
|
|
@@ -26,6 +28,24 @@ export function WorkspacesView(props: {
|
|
|
26
28
|
const [notice, setNotice] = useState<string | undefined>(undefined)
|
|
27
29
|
const [error, setError] = useState<string | undefined>(undefined)
|
|
28
30
|
const [busy, setBusy] = useState<string | undefined>(undefined)
|
|
31
|
+
/**
|
|
32
|
+
* Keep the list live without asking the user to close and reopen the panel.
|
|
33
|
+
*
|
|
34
|
+
* Two changes happen OUTSIDE this panel and used to stay invisible until a
|
|
35
|
+
* page reload: another window creating a binding, and the user deleting a
|
|
36
|
+
* workspace in DSH's own sidebar (which the Host turns into an unbind). The
|
|
37
|
+
* store is module state bootstrapped once, so a light poll while this panel is
|
|
38
|
+
* actually on screen is the cheap, reliable way to follow both.
|
|
39
|
+
*/
|
|
40
|
+
const changedRef = useRef(props.onChanged)
|
|
41
|
+
changedRef.current = props.onChanged
|
|
42
|
+
const visible = props.visible !== false
|
|
43
|
+
useEffect(() => {
|
|
44
|
+
if (!visible) return
|
|
45
|
+
changedRef.current()
|
|
46
|
+
const timer = window.setInterval(() => { changedRef.current() }, 2500)
|
|
47
|
+
return () => { window.clearInterval(timer) }
|
|
48
|
+
}, [visible])
|
|
29
49
|
|
|
30
50
|
/**
|
|
31
51
|
* Unbind one workspace, after a confirmation.
|