dsh-remote 0.8.76 → 0.8.78
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 +1 -0
- package/README.md +1 -0
- package/lib/client.js +169 -17
- package/lib/index.js +32 -4
- package/lib/telemetry.js +34 -0
- package/package.json +1 -1
package/README.en.md
CHANGED
|
@@ -333,6 +333,7 @@ Deploying to a product profile is a separate, explicit action (`./sync.sh`) for
|
|
|
333
333
|
| `webAttachDshHome` | string | `''` | `DSH_HOME` exported on the remote when attaching; empty reuses the remote user's own harness home |
|
|
334
334
|
| `webAttachWaitSeconds` | int | `45` | how long to wait for a freshly started remote `dsh web` to print its launch token |
|
|
335
335
|
| `localTools` | string | `bootstrap` | which `rw_*` tools a LOCAL session (cwd outside every remote mirror) sees (issue #63): `bootstrap` keeps only the configuration loop `rw_machines`/`rw_connect`/`rw_pick_workspace` (the other 19 refuse a local session with "this session is LOCAL", so exposing them just wastes schema budget); `none` hides all `rw_*` (remote setup happens via the settings page only); `all` restores the legacy full surface. REMOTE sessions (cwd inside a mirror) always see everything; an invalid value degrades to `bootstrap` |
|
|
336
|
+
| `telemetry` | bool | `true` | anonymous install heartbeat (daily-active statistics, at most once a day; the payload is a plugin-specific HMAC pseudonym + version, no machine info). `false` disables it; users also get a settings-page checkbox (persisted in `$DSH_HOME`, winning over this config) |
|
|
336
337
|
| `remoteTerminalDefault` | bool | `true` | make the shell menu's "remote ssh" launcher the terminal's DEFAULT shell when neither the host (`config.shell`) nor the user (a remembered menu choice) has picked one: a session rooted in a remote mirror opens a terminal already sshed into the remote workspace, any other session transparently falls back to a local shell (issue #55); `false` keeps it menu-only |
|
|
337
338
|
| `tui` | bool | `true` | master switch for the TUI (dsh-tui) layer; `false` registers no `/dsh-remote` page, workspace provider or status field |
|
|
338
339
|
| `tuiProviderListRecent` | bool | `true` | list each machine's recent remote projects in the TUI workspace picker |
|
package/README.md
CHANGED
|
@@ -308,6 +308,7 @@ scripts/dev-run.sh --status # 是否在运行
|
|
|
308
308
|
| `webAttachDshHome` | string | `''` | 远端启动时导出的 `DSH_HOME`;留空则复用远端用户自己的 harness home |
|
|
309
309
|
| `webAttachWaitSeconds` | int | `45` | 等待远端 `dsh web` 打印启动令牌的秒数 |
|
|
310
310
|
| `localTools` | string | `bootstrap` | 本地 session(cwd 不在远程镜像里)暴露哪些 `rw_*` 工具(issue #63):`bootstrap`=只暴露配置闭环 `rw_machines`/`rw_connect`/`rw_pick_workspace`(其余 19 个在本地 session 必然报 "this session is LOCAL",暴露只是白占 schema);`none`=完全不暴露 `rw_*`(远程配置只能走设置页);`all`=旧的 full 暴露。远程 session(cwd 在镜像里)不受影响,始终全量;非法值按 `bootstrap` 处理 |
|
|
311
|
+
| `telemetry` | bool | `true` | 匿名安装心跳(日活统计,每天至多一次;内容为插件专属 HMAC 伪名+版本号,不含机器信息)。`false` 关闭;用户也可在设置页用复选框关闭(持久化在 `$DSH_HOME`,优先于此配置) |
|
|
311
312
|
| `remoteTerminalDefault` | bool | `true` | 让 shell 菜单里的「remote ssh」启动器成为终端**默认 shell**(宿主未配置、用户未手动选择时):远程会话开终端即落到远端工作目录,本地会话自动回落本地 shell(issue #55);`false` 则只保留菜单项 |
|
|
312
313
|
| `tui` | bool | `true` | TUI 适配层(dsh-tui)总开关;`false` 时不注册 `/dsh-remote` 页面、工作区 provider 与状态行字段 |
|
|
313
314
|
| `tuiProviderListRecent` | bool | `true` | TUI 工作区选择器里是否列出每台机器最近的远程项目 |
|
package/lib/client.js
CHANGED
|
@@ -38,6 +38,23 @@ window.__ModuleLoader__.load({
|
|
|
38
38
|
// plain source.
|
|
39
39
|
const Primitives = (() => { try { return require('@deepseek-ai/dsh-client-ui-primitives') } catch { return null } })()
|
|
40
40
|
const MarkdownText = (Primitives && typeof Primitives.MarkdownText === 'function') ? Primitives.MarkdownText : null
|
|
41
|
+
// Host visual primitives adopted incrementally, always with a graceful
|
|
42
|
+
// fallback (the shared map's contents vary by host version — the bundle
|
|
43
|
+
// ships ~290 exports, older type packages fewer):
|
|
44
|
+
// Modal — always-portaled dialog with focus trap/autofocus/restore and
|
|
45
|
+
// IME-composition guards (useModalLayer underneath). Its mask dismisses
|
|
46
|
+
// on bare click, so the DIR PICKER keeps its own press-origin-guarded
|
|
47
|
+
// overlay (issue #52); simple dialogs without mid-gesture re-layouts
|
|
48
|
+
// (PromptDialog, ConfirmDialog) adopt Modal wholesale.
|
|
49
|
+
// HostMenu — anchored menu with optional body portal; replaces our
|
|
50
|
+
// imperative-DOM context menu when present.
|
|
51
|
+
// useModalLayer — the focus/escape layer on its own, applied to the picker's
|
|
52
|
+
// custom overlay (which keeps its #52 mask guard).
|
|
53
|
+
// writeClipboard — replaces the scratch-textarea copy hack.
|
|
54
|
+
const Modal = (Primitives && typeof Primitives.Modal === 'function') ? Primitives.Modal : null
|
|
55
|
+
const HostMenu = (Primitives && typeof Primitives.Menu === 'function') ? Primitives.Menu : null
|
|
56
|
+
const useModalLayerFn = (Primitives && typeof Primitives.useModalLayer === 'function') ? Primitives.useModalLayer : null
|
|
57
|
+
const writeClipboardFn = (Primitives && typeof Primitives.writeClipboard === 'function') ? Primitives.writeClipboard : null
|
|
41
58
|
|
|
42
59
|
// Issue #93: floating layers must PORTAL to document.body, exactly like the
|
|
43
60
|
// host's own Modal/Menu (and like our context menu already does with an
|
|
@@ -224,6 +241,8 @@ window.__ModuleLoader__.load({
|
|
|
224
241
|
'settings.updateNow': '立即更新',
|
|
225
242
|
'settings.updateMode': '更新模式:',
|
|
226
243
|
'settings.explorerAutoOpen': '打开远程工作区时,自动在侧边栏展开「远程文件」(需安装 better-sidebar)',
|
|
244
|
+
'settings.telemetry': '匿名使用统计(每日一次的安装心跳;不含任何机器信息,可随时关闭)',
|
|
245
|
+
'settings.telemetryHint': '上报内容只有插件专属的 HMAC 伪名与版本号;关闭后立即不再发送',
|
|
227
246
|
'settings.updateManual': '手动',
|
|
228
247
|
'settings.updateAuto': '自动',
|
|
229
248
|
'settings.updateOff': '关闭',
|
|
@@ -284,6 +303,7 @@ window.__ModuleLoader__.load({
|
|
|
284
303
|
'picker.setRemoteWs': '设为远程工作区',
|
|
285
304
|
'picker.mirroring': '镜像中…',
|
|
286
305
|
'picker.cancel': '取消',
|
|
306
|
+
'confirm.title': '请确认',
|
|
287
307
|
'picker.selectDir': '选择工作目录',
|
|
288
308
|
'picker.selected': '所选: {path}',
|
|
289
309
|
'picker.driveRoot': '(驱动器根)',
|
|
@@ -529,6 +549,8 @@ window.__ModuleLoader__.load({
|
|
|
529
549
|
'settings.updateNow': 'Update now',
|
|
530
550
|
'settings.updateMode': 'Update mode:',
|
|
531
551
|
'settings.explorerAutoOpen': 'Auto-open the Remote Files sidebar tab for remote workspaces (via better-sidebar)',
|
|
552
|
+
'settings.telemetry': 'Anonymous usage statistics (one install heartbeat per day; no machine info; can be turned off anytime)',
|
|
553
|
+
'settings.telemetryHint': 'Only a plugin-specific HMAC pseudonym and the version number are sent; takes effect immediately',
|
|
532
554
|
'settings.updateManual': 'Manual',
|
|
533
555
|
'settings.updateAuto': 'Auto',
|
|
534
556
|
'settings.updateOff': 'Off',
|
|
@@ -589,6 +611,7 @@ window.__ModuleLoader__.load({
|
|
|
589
611
|
'picker.setRemoteWs': 'Set as remote workspace',
|
|
590
612
|
'picker.mirroring': 'Mirroring…',
|
|
591
613
|
'picker.cancel': 'Cancel',
|
|
614
|
+
'confirm.title': 'Please confirm',
|
|
592
615
|
'picker.selectDir': 'Select working directory',
|
|
593
616
|
'picker.selected': 'Selected: {path}',
|
|
594
617
|
'picker.driveRoot': ' (drive root)',
|
|
@@ -909,17 +932,39 @@ window.__ModuleLoader__.load({
|
|
|
909
932
|
const { title, initial, placeholder, onSubmit, onCancel } = props
|
|
910
933
|
const backdrop = useBackdropGuard()
|
|
911
934
|
const [val, setVal] = React.useState(initial || '')
|
|
935
|
+
const submit = () => { const t = val.trim(); if (t) onSubmit(t) }
|
|
912
936
|
React.useEffect(() => {
|
|
913
937
|
try {
|
|
914
938
|
if (typeof document === 'undefined') return
|
|
915
939
|
const onKey = (e) => {
|
|
916
940
|
if (e.key === 'Escape') { e.preventDefault(); onCancel() }
|
|
917
|
-
if (e.key === 'Enter') { e.preventDefault();
|
|
941
|
+
if (e.key === 'Enter') { e.preventDefault(); submit() }
|
|
918
942
|
}
|
|
919
943
|
document.addEventListener('keydown', onKey)
|
|
920
944
|
return () => document.removeEventListener('keydown', onKey)
|
|
921
945
|
} catch { return undefined }
|
|
922
946
|
}, [val, onSubmit, onCancel])
|
|
947
|
+
// Host Modal when available: portal + focus trap + autofocus + restore +
|
|
948
|
+
// IME-composition guard come from its useModalLayer; our document-level
|
|
949
|
+
// Escape/Enter stays as the fallback path's key handling (harmless
|
|
950
|
+
// duplication: Modal's layer preventDefaults first).
|
|
951
|
+
if (Modal) {
|
|
952
|
+
return React.createElement(Modal, {
|
|
953
|
+
open: true,
|
|
954
|
+
onClose: onCancel,
|
|
955
|
+
title,
|
|
956
|
+
closeLabel: tr('picker.close'),
|
|
957
|
+
onKeyDownCapture: (e) => {
|
|
958
|
+
if (e.key === 'Enter' && !e.isComposing) { e.preventDefault(); submit() }
|
|
959
|
+
},
|
|
960
|
+
},
|
|
961
|
+
React.createElement('input', { autoFocus: true, 'data-modal-autofocus': true, value: val, onChange: (e) => setVal(e.target.value), placeholder: placeholder || '', className: 'dsh-rw-input', style: inputS }),
|
|
962
|
+
React.createElement('div', { style: { display: 'flex', gap: 8, justifyContent: 'flex-end', marginTop: 10 } },
|
|
963
|
+
React.createElement('button', { type: 'button', className: 'dsh-rw-btn', style: buttonS, onClick: onCancel }, tr('file.cancel')),
|
|
964
|
+
React.createElement('button', { type: 'button', className: 'dsh-rw-btn dsh-rw-primary', style: primaryBtnS, onClick: submit, disabled: !val.trim() }, tr('common.confirm')),
|
|
965
|
+
),
|
|
966
|
+
)
|
|
967
|
+
}
|
|
923
968
|
return React.createElement('div', {
|
|
924
969
|
style: { position: 'fixed', inset: 0, zIndex: 1000000, background: 'rgba(0,0,0,0.45)', display: 'flex', alignItems: 'center', justifyContent: 'center', padding: 16 },
|
|
925
970
|
onMouseDown: backdrop.onMouseDown,
|
|
@@ -942,6 +987,58 @@ window.__ModuleLoader__.load({
|
|
|
942
987
|
)
|
|
943
988
|
}
|
|
944
989
|
|
|
990
|
+
/**
|
|
991
|
+
* Themed confirm dialog. Uses the host Modal when the build ships one
|
|
992
|
+
* (always portaled, focus trap, autofocus, focus restore, Escape, IME
|
|
993
|
+
* guard); otherwise our own press-guarded portalized overlay. Either way it
|
|
994
|
+
* replaces `window.confirm`, which is visually alien and may be suppressed
|
|
995
|
+
* by embedders. Safe for Mask adoption here because the content never
|
|
996
|
+
* re-lays-out mid-gesture (no autocomplete list — that is why the DIRECTORY
|
|
997
|
+
* picker keeps its custom guarded overlay).
|
|
998
|
+
*/
|
|
999
|
+
function ConfirmDialog(props) {
|
|
1000
|
+
const { message, onAnswer } = props
|
|
1001
|
+
const cancelBtn = React.createElement('button', { type: 'button', className: 'dsh-rw-btn', style: buttonS, onClick: () => onAnswer(false) }, tr('file.cancel'))
|
|
1002
|
+
const okBtn = React.createElement('button', { type: 'button', className: 'dsh-rw-btn dsh-rw-primary', style: primaryBtnS, 'data-modal-autofocus': true, onClick: () => onAnswer(true) }, tr('common.confirm'))
|
|
1003
|
+
if (Modal) {
|
|
1004
|
+
return React.createElement(Modal, {
|
|
1005
|
+
open: true,
|
|
1006
|
+
onClose: () => onAnswer(false),
|
|
1007
|
+
title: tr('confirm.title'),
|
|
1008
|
+
closeLabel: tr('picker.close'),
|
|
1009
|
+
},
|
|
1010
|
+
React.createElement('div', { style: { fontSize: 13, color: T.label, whiteSpace: 'pre-wrap', wordBreak: 'break-word', maxWidth: 'min(460px, 86vw)' } }, message),
|
|
1011
|
+
React.createElement('div', { style: { display: 'flex', gap: 8, justifyContent: 'flex-end', marginTop: 14 } }, cancelBtn, okBtn),
|
|
1012
|
+
)
|
|
1013
|
+
}
|
|
1014
|
+
const backdrop = useBackdropGuard()
|
|
1015
|
+
return portalize(React.createElement('div', {
|
|
1016
|
+
style: { position: 'fixed', inset: 0, zIndex: 1000001, background: 'rgba(0,0,0,0.45)', display: 'flex', alignItems: 'center', justifyContent: 'center', padding: 16 },
|
|
1017
|
+
onMouseDown: backdrop.onMouseDown,
|
|
1018
|
+
onClick: (e) => { if (backdrop.onClick(e)) onAnswer(false) },
|
|
1019
|
+
},
|
|
1020
|
+
React.createElement('div', { style: { background: v('--dsw-alias-bg-layer-1', '#18181b'), color: T.label, border: '1px solid ' + T.borderStrong, borderRadius: 12, boxShadow: '0 12px 48px rgba(0,0,0,0.5)', padding: 16, maxWidth: 'min(460px, 86vw)' }, onClick: (e) => e.stopPropagation() },
|
|
1021
|
+
React.createElement('div', { style: { fontSize: 13, fontWeight: 600, marginBottom: 10 } }, tr('confirm.title')),
|
|
1022
|
+
React.createElement('div', { style: { fontSize: 13, whiteSpace: 'pre-wrap', wordBreak: 'break-word' } }, message),
|
|
1023
|
+
React.createElement('div', { style: { display: 'flex', gap: 8, justifyContent: 'flex-end', marginTop: 14 } }, cancelBtn, okBtn),
|
|
1024
|
+
),
|
|
1025
|
+
))
|
|
1026
|
+
}
|
|
1027
|
+
|
|
1028
|
+
/** Promise-style confirm: `if (!(await confirm.ask(msg))) return`. Render
|
|
1029
|
+
* `confirm.node` anywhere in the component's tree. */
|
|
1030
|
+
function useConfirm() {
|
|
1031
|
+
const [req, setReq] = React.useState(null)
|
|
1032
|
+
const ask = React.useCallback((message) => new Promise((resolve) => setReq({ message, resolve })), [])
|
|
1033
|
+
const node = req
|
|
1034
|
+
? React.createElement(ConfirmDialog, {
|
|
1035
|
+
message: req.message,
|
|
1036
|
+
onAnswer: (ok) => { setReq(null); req.resolve(ok) },
|
|
1037
|
+
})
|
|
1038
|
+
: null
|
|
1039
|
+
return { ask, node }
|
|
1040
|
+
}
|
|
1041
|
+
|
|
945
1042
|
function humanSize(n) {
|
|
946
1043
|
if (n == null) return ''
|
|
947
1044
|
if (n < 1024) return n + ' B'
|
|
@@ -958,10 +1055,13 @@ window.__ModuleLoader__.load({
|
|
|
958
1055
|
return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())} ${pad(d.getHours())}:${pad(d.getMinutes())}`
|
|
959
1056
|
}
|
|
960
1057
|
|
|
961
|
-
// Write text to the clipboard.
|
|
962
|
-
// http://127.0.0.1
|
|
963
|
-
// execCommand('copy') path
|
|
1058
|
+
// Write text to the clipboard. Order: the host primitive (its behavior is
|
|
1059
|
+
// the reference), then the async Clipboard API (works on http://127.0.0.1
|
|
1060
|
+
// secure contexts), then the legacy execCommand('copy') path.
|
|
964
1061
|
function copyToClipboard(text) {
|
|
1062
|
+
if (writeClipboardFn) {
|
|
1063
|
+
try { return Promise.resolve(writeClipboardFn(String(text))).then(() => true).catch(() => false) } catch { /* fall through to the manual paths */ }
|
|
1064
|
+
}
|
|
965
1065
|
if (navigator.clipboard && window.isSecureContext) {
|
|
966
1066
|
return navigator.clipboard.writeText(text).then(() => true).catch(() => false)
|
|
967
1067
|
}
|
|
@@ -1156,6 +1256,12 @@ window.__ModuleLoader__.load({
|
|
|
1156
1256
|
// Issue #78: initial value comes from localStorage, so a user's choice
|
|
1157
1257
|
// survives restarts (the bug was: the panel popped again every restart).
|
|
1158
1258
|
const [explorerAuto, setExplorerAuto] = React.useState(() => explorerAutoOpenEnabled())
|
|
1259
|
+
// Anonymous-heartbeat toggle: null = not loaded yet (checkbox disabled).
|
|
1260
|
+
// Effective value is host-side (user override > profile config).
|
|
1261
|
+
const [telemetryOn, setTelemetryOn] = React.useState(null)
|
|
1262
|
+
React.useEffect(() => {
|
|
1263
|
+
api('GET', '/dsh-remote/telemetry').then((r) => setTelemetryOn(!(r && r.enabled === false))).catch(() => {})
|
|
1264
|
+
}, [])
|
|
1159
1265
|
const checkUpdate = (quiet) => {
|
|
1160
1266
|
if (updBusy) return
|
|
1161
1267
|
setUpdBusy(true); setUpdMsg('')
|
|
@@ -1177,9 +1283,10 @@ window.__ModuleLoader__.load({
|
|
|
1177
1283
|
.catch((e) => setUpdMsg(String((e && e.message) || e)))
|
|
1178
1284
|
.finally(() => setUpdBusy(false))
|
|
1179
1285
|
}
|
|
1180
|
-
const
|
|
1286
|
+
const confirmUi = useConfirm()
|
|
1287
|
+
const applyUpdateNow = async () => {
|
|
1181
1288
|
if (!upd || !upd.latest) return
|
|
1182
|
-
if (!
|
|
1289
|
+
if (!(await confirmUi.ask(tr('settings.updateConfirm', { version: upd.latest })))) return
|
|
1183
1290
|
setUpdBusy(true); setUpdMsg('')
|
|
1184
1291
|
api('POST', '/dsh-remote/update-apply', { version: upd.latest })
|
|
1185
1292
|
.then((r) => {
|
|
@@ -1311,7 +1418,7 @@ window.__ModuleLoader__.load({
|
|
|
1311
1418
|
// Issue #13: "active remote = none" — saved machines stay, but no machine
|
|
1312
1419
|
// is current, so local sessions are never dragged into a remote context.
|
|
1313
1420
|
const clearCurrent = () => { setBusy(true); api('POST', '/dsh-remote/current', { id: '' }).then((r) => { setCurrentId(''); setMsg(tr('settings.cleared')) }).catch((e) => setErr(String((e && e.message) || e))).finally(() => setBusy(false)) }
|
|
1314
|
-
const del = (id) => { if (
|
|
1421
|
+
const del = async (id) => { if (!(await confirmUi.ask(tr('settings.deleteConfirm')))) return; api('POST', '/dsh-remote/machines', { action: 'delete', id }).then(refresh).then(() => setMsg(tr('settings.deleted'))).catch((e) => setErr(String((e && e.message) || e))) }
|
|
1315
1422
|
|
|
1316
1423
|
/**
|
|
1317
1424
|
* Issue #73: connect to one row of the host list.
|
|
@@ -1455,6 +1562,7 @@ window.__ModuleLoader__.load({
|
|
|
1455
1562
|
}
|
|
1456
1563
|
|
|
1457
1564
|
return React.createElement('div', { style: { padding: 16, display: 'flex', flexDirection: 'column', gap: 12, maxWidth: 860 } },
|
|
1565
|
+
confirmUi.node,
|
|
1458
1566
|
React.createElement('div', { style: { fontSize: 16, fontWeight: 650, letterSpacing: '-0.01em' } }, tr('settings.title')),
|
|
1459
1567
|
React.createElement('div', { style: { fontSize: 12, opacity: 0.8, lineHeight: 1.55 } },
|
|
1460
1568
|
tr('settings.intro')),
|
|
@@ -1879,6 +1987,19 @@ window.__ModuleLoader__.load({
|
|
|
1879
1987
|
}),
|
|
1880
1988
|
tr('settings.explorerAutoOpen'),
|
|
1881
1989
|
),
|
|
1990
|
+
React.createElement('label', { style: { display: 'flex', gap: 6, alignItems: 'center', cursor: telemetryOn === null ? 'default' : 'pointer', opacity: 0.85 }, title: tr('settings.telemetryHint') },
|
|
1991
|
+
React.createElement('input', {
|
|
1992
|
+
type: 'checkbox', checked: telemetryOn === true, disabled: telemetryOn === null, 'data-testid': 'telemetry-toggle',
|
|
1993
|
+
onChange: (e) => {
|
|
1994
|
+
const on = !!(e && e.target && e.target.checked)
|
|
1995
|
+
setTelemetryOn(on) // optimistic; the host answer re-syncs below
|
|
1996
|
+
api('POST', '/dsh-remote/telemetry', { enabled: on })
|
|
1997
|
+
.then((r) => setTelemetryOn(!(r && r.enabled === false)))
|
|
1998
|
+
.catch(() => setTelemetryOn(null))
|
|
1999
|
+
},
|
|
2000
|
+
}),
|
|
2001
|
+
tr('settings.telemetry'),
|
|
2002
|
+
),
|
|
1882
2003
|
),
|
|
1883
2004
|
upd && upd.pendingReload
|
|
1884
2005
|
? React.createElement('div', { style: { marginTop: 6, fontSize: 12, color: T.warn } },
|
|
@@ -3138,6 +3259,7 @@ window.__ModuleLoader__.load({
|
|
|
3138
3259
|
/** Row whose path was just copied — shows a brief「已复制」label. */
|
|
3139
3260
|
const [copiedPath, setCopiedPath] = React.useState('')
|
|
3140
3261
|
const [namePrompt, setNamePrompt] = React.useState(null) // { kind, path, name }
|
|
3262
|
+
const confirmUi = useConfirm()
|
|
3141
3263
|
React.useEffect(() => { ensureChromeCss() }, [])
|
|
3142
3264
|
const expanded = Array.isArray(props.expanded) ? props.expanded : []
|
|
3143
3265
|
const scopeCwd = props.scope && props.scope.cwd
|
|
@@ -3267,10 +3389,22 @@ window.__ModuleLoader__.load({
|
|
|
3267
3389
|
React.useEffect(() => {
|
|
3268
3390
|
if (root && typeof props.evictStray === 'function') props.evictStray(root)
|
|
3269
3391
|
}, [root, props.evictStray])
|
|
3392
|
+
/** Shared dispatch for the context menu (host Menu or the DOM fallback). */
|
|
3393
|
+
const runMenuAction = (id, m) => {
|
|
3394
|
+
if (!m) return
|
|
3395
|
+
if (id === 'open') { if (m.isDir) { if (props.onToggleDir) props.onToggleDir(m.path) } else openFile(m.path); return }
|
|
3396
|
+
if (id === 'download') { doFs('download', { path: m.path }); return }
|
|
3397
|
+
if (id === 'copy-rel') { copyPath(relPath(m.path), m.path); return }
|
|
3398
|
+
if (id === 'copy-abs') { copyPath(m.path, m.path); return }
|
|
3399
|
+
if (id === 'rename') { setNamePrompt({ kind: 'rename', path: m.path, name: m.name }); return }
|
|
3400
|
+
if (id === 'delete') { confirmUi.ask(tr('explorer.deleteConfirm', { path: m.path })).then((ok) => { if (ok) doFs('remove', { path: m.path }, true) }) }
|
|
3401
|
+
}
|
|
3270
3402
|
// ── Context-menu portal: append to document.body so the sidebar's
|
|
3271
3403
|
// overflow/transform cannot clip it. Pure DOM, no React portal needed.
|
|
3404
|
+
// Only the FALLBACK when the host ships no Menu primitive: the main
|
|
3405
|
+
// path renders HostMenu (anchored, body-portaled, keyboard-navigable).
|
|
3272
3406
|
React.useEffect(() => {
|
|
3273
|
-
if (!menu) return
|
|
3407
|
+
if (!menu || HostMenu) return
|
|
3274
3408
|
const host = document.createElement('div')
|
|
3275
3409
|
host.style.cssText = 'position:fixed;z-index:999999;pointer-events:auto'
|
|
3276
3410
|
const box = document.createElement('div')
|
|
@@ -3284,19 +3418,21 @@ window.__ModuleLoader__.load({
|
|
|
3284
3418
|
d.addEventListener('click', (e) => { e.stopPropagation(); setMenu(null); fn() })
|
|
3285
3419
|
return d
|
|
3286
3420
|
}
|
|
3287
|
-
box.appendChild(mkItem(menu.isDir ? tr('explorer.menuExpand') : tr('explorer.menuOpen'), false, () =>
|
|
3288
|
-
box.appendChild(mkItem(tr('explorer.menuDownload'), false, () =>
|
|
3289
|
-
box.appendChild(mkItem(tr('explorer.menuCopyRel'), false, () =>
|
|
3290
|
-
box.appendChild(mkItem(tr('explorer.menuCopyAbs'), false, () =>
|
|
3291
|
-
box.appendChild(mkItem(tr('explorer.menuRename'), false, () =>
|
|
3292
|
-
box.appendChild(mkItem(menu.isDir ? tr('explorer.menuDeleteDir') : tr('explorer.menuDelete'), true, () =>
|
|
3421
|
+
box.appendChild(mkItem(menu.isDir ? tr('explorer.menuExpand') : tr('explorer.menuOpen'), false, () => runMenuAction('open', menu)))
|
|
3422
|
+
box.appendChild(mkItem(tr('explorer.menuDownload'), false, () => runMenuAction('download', menu)))
|
|
3423
|
+
box.appendChild(mkItem(tr('explorer.menuCopyRel'), false, () => runMenuAction('copy-rel', menu)))
|
|
3424
|
+
box.appendChild(mkItem(tr('explorer.menuCopyAbs'), false, () => runMenuAction('copy-abs', menu)))
|
|
3425
|
+
box.appendChild(mkItem(tr('explorer.menuRename'), false, () => runMenuAction('rename', menu)))
|
|
3426
|
+
box.appendChild(mkItem(menu.isDir ? tr('explorer.menuDeleteDir') : tr('explorer.menuDelete'), true, () => runMenuAction('delete', menu)))
|
|
3293
3427
|
host.appendChild(box)
|
|
3294
3428
|
document.body.appendChild(host)
|
|
3295
3429
|
const close = (e) => { if (!box.contains(e.target)) { setMenu(null) } }
|
|
3296
3430
|
// Delay adding listener so the same mousedown that opened the menu doesn't close it
|
|
3297
3431
|
const tid = setTimeout(() => document.addEventListener('mousedown', close), 0)
|
|
3298
3432
|
return () => { clearTimeout(tid); document.removeEventListener('mousedown', close); host.remove() }
|
|
3299
|
-
|
|
3433
|
+
// confirmUi.ask is stable (useCallback); depending on the wrapper object
|
|
3434
|
+
// would rebuild the menu DOM on every render.
|
|
3435
|
+
}, [menu, confirmUi.ask])
|
|
3300
3436
|
|
|
3301
3437
|
// Open one remote file. The viewer is a RESOURCE tab type: the address
|
|
3302
3438
|
// names the file, and the HOST's tab registry picks the type that claims
|
|
@@ -3485,8 +3621,24 @@ window.__ModuleLoader__.load({
|
|
|
3485
3621
|
rootLevel && rootOpen ? renderLevel(root, 1) : null,
|
|
3486
3622
|
),
|
|
3487
3623
|
),
|
|
3488
|
-
// context menu —
|
|
3489
|
-
|
|
3624
|
+
// context menu — host Menu primitive when available (anchored at the
|
|
3625
|
+
// pointer, body-portaled), otherwise the DOM portal in the effect above
|
|
3626
|
+
menu && HostMenu ? React.createElement(HostMenu, {
|
|
3627
|
+
open: true,
|
|
3628
|
+
portal: true,
|
|
3629
|
+
getAnchorRect: () => ({ left: menu.x, top: menu.y, right: menu.x, bottom: menu.y, width: 0, height: 0 }),
|
|
3630
|
+
items: [
|
|
3631
|
+
{ id: 'open', label: menu.isDir ? tr('explorer.menuExpand') : tr('explorer.menuOpen') },
|
|
3632
|
+
{ id: 'download', label: tr('explorer.menuDownload') },
|
|
3633
|
+
{ id: 'copy-rel', label: tr('explorer.menuCopyRel') },
|
|
3634
|
+
{ id: 'copy-abs', label: tr('explorer.menuCopyAbs') },
|
|
3635
|
+
{ id: 'rename', label: tr('explorer.menuRename') },
|
|
3636
|
+
{ id: 'delete', label: menu.isDir ? tr('explorer.menuDeleteDir') : tr('explorer.menuDelete'), danger: true },
|
|
3637
|
+
],
|
|
3638
|
+
onSelect: (id) => { const m = menu; setMenu(null); runMenuAction(id, m) },
|
|
3639
|
+
onClose: () => setMenu(null),
|
|
3640
|
+
}) : null,
|
|
3641
|
+
confirmUi.node,
|
|
3490
3642
|
err ? React.createElement('div', { style: { color: T.danger, fontSize: 12, padding: '4px 8px' } }, (busy ? tr('explorer.busy') : '') + err) : null,
|
|
3491
3643
|
namePrompt ? React.createElement(PromptDialog, {
|
|
3492
3644
|
title: namePrompt.kind === 'rename' ? tr('explorer.renameTitle') : tr('explorer.mkdirTitle'),
|
package/lib/index.js
CHANGED
|
@@ -53,7 +53,7 @@ import { WebAttach } from './web-attach.js'
|
|
|
53
53
|
import { formatAuditLine, readAuditLines } from './audit.js'
|
|
54
54
|
|
|
55
55
|
import { selfDir, diskVersion, LOADED_VERSION, gtVersion, fetchLatestVersion, applyUpdate, persistUpdateMode, readUpdateMode, reloadSelf, scheduleSelfReload, lastSelfReload, isInstalledCopy } from './update.js'
|
|
56
|
-
import { sendHeartbeat, pseudonym, heartbeatUrl, hasPersistedId, installIdPath } from './telemetry.js'
|
|
56
|
+
import { sendHeartbeat, pseudonym, heartbeatUrl, hasPersistedId, installIdPath, telemetryAllowed, persistTelemetryOpt } from './telemetry.js'
|
|
57
57
|
import { loadMachines as _loadMachines, saveMachines as _saveMachines, sanitizeMachine as _sanitizeMachine, applyMachine as _applyMachine, machineId as _machineId, normalizeMachineGroup, filterMachinesByGroup, resolveProbeCredentials } from './registry.js'
|
|
58
58
|
import { registerHttpTransports } from './http-transport.js'
|
|
59
59
|
import { createHostApi } from './host-api.js'
|
|
@@ -284,6 +284,11 @@ export const Config = z.object({
|
|
|
284
284
|
* plaintext is the one outcome you did not ask for.
|
|
285
285
|
* `plain`: the pre-0.8.54 fallback (write it and warn). */
|
|
286
286
|
credentialFallback: z.string().default('refuse'),
|
|
287
|
+
/** Anonymous install heartbeat (daily-active statistics). The payload is a
|
|
288
|
+
* plugin-specific HMAC pseudonym — no machine info leaves the box. Admins
|
|
289
|
+
* can turn it off here; users get a settings-page checkbox whose persisted
|
|
290
|
+
* choice (in $DSH_HOME) wins over this config value. */
|
|
291
|
+
telemetry: z.boolean().default(true),
|
|
287
292
|
/** Make the "remote ssh" launcher the terminal's DEFAULT shell when neither
|
|
288
293
|
* the host admin (config.shell) nor the user (remembered menu choice) has
|
|
289
294
|
* picked one. The launcher is cwd-aware: a session rooted in a remote mirror
|
|
@@ -463,9 +468,10 @@ export async function apply(ctx, config) {
|
|
|
463
468
|
|
|
464
469
|
// ── 安装心跳(日活统计)─────────────────────────────────────────────────
|
|
465
470
|
// 旁路:不 await、不阻塞加载、失败静默(见 lib/telemetry.js 的隐私与失败策略)。
|
|
466
|
-
//
|
|
467
|
-
//
|
|
468
|
-
|
|
471
|
+
// 默认开启,但可以被关:profile 配置 `telemetry: false`(管理员)或设置页
|
|
472
|
+
// 复选框(用户,持久化在 $DSH_HOME,优先于配置)。上报的是本插件专属 HMAC
|
|
473
|
+
// 伪名,原始安装 id 与任何机器信息都不离开本机。
|
|
474
|
+
if (telemetryAllowed(dshBase(), config.telemetry)) void sendHeartbeat(dshBase(), LOADED_VERSION)
|
|
469
475
|
|
|
470
476
|
// The update marker means "a newer version landed on disk but is not the code
|
|
471
477
|
// running yet". Reaching apply() with a marker naming the version we just
|
|
@@ -4797,6 +4803,28 @@ export async function apply(ctx, config) {
|
|
|
4797
4803
|
}
|
|
4798
4804
|
},
|
|
4799
4805
|
},
|
|
4806
|
+
{
|
|
4807
|
+
kind: 'exact',
|
|
4808
|
+
path: '/dsh-remote/telemetry',
|
|
4809
|
+
handler: async (req, res) => {
|
|
4810
|
+
// The anonymous-heartbeat toggle (settings page). GET reads the
|
|
4811
|
+
// EFFECTIVE value (user override > profile config > default true);
|
|
4812
|
+
// POST persists the user's choice under $DSH_HOME so it survives
|
|
4813
|
+
// plugin upgrades (the install dir gets overwritten).
|
|
4814
|
+
if (req.method === 'GET') {
|
|
4815
|
+
return sendJson(res, 200, { ok: true, enabled: telemetryAllowed(dshBase(), config.telemetry), configurable: heartbeatEnabled() })
|
|
4816
|
+
}
|
|
4817
|
+
if (req.method !== 'POST') return sendJson(res, 405, { ok: false, error: 'method not allowed' })
|
|
4818
|
+
try {
|
|
4819
|
+
const body = JSON.parse((await readBody(req)) || '{}')
|
|
4820
|
+
if (typeof body.enabled !== 'boolean') return sendJson(res, 400, { ok: false, error: 'enabled must be boolean' })
|
|
4821
|
+
if (!persistTelemetryOpt(dshBase(), body.enabled)) return sendJson(res, 500, { ok: false, error: 'cannot persist the setting (read-only home?)' })
|
|
4822
|
+
return sendJson(res, 200, { ok: true, enabled: telemetryAllowed(dshBase(), config.telemetry) })
|
|
4823
|
+
} catch (err) {
|
|
4824
|
+
return sendJson(res, 500, { ok: false, error: String((err && err.message) || err) })
|
|
4825
|
+
}
|
|
4826
|
+
},
|
|
4827
|
+
},
|
|
4800
4828
|
]
|
|
4801
4829
|
|
|
4802
4830
|
registerHttpTransports(ctx, routes)
|
package/lib/telemetry.js
CHANGED
|
@@ -188,6 +188,40 @@ export function heartbeatEnabled() {
|
|
|
188
188
|
return heartbeatUrl().startsWith('https://')
|
|
189
189
|
}
|
|
190
190
|
|
|
191
|
+
// ── 用户开关(0.8.78+)────────────────────────────────────────────────────
|
|
192
|
+
// 双层:profile 配置 `telemetry: false` 是管理员路径;设置页复选框写
|
|
193
|
+
// `$DSH_HOME/.dsh-remote-telemetry`('0'/'1')是用户路径。与 updateMode 同一
|
|
194
|
+
// 约定:用户覆盖优先于配置默认。文件放 DSH_HOME 而非插件目录——升级覆写插件
|
|
195
|
+
// 目录时用户的选择不丢。
|
|
196
|
+
const OPT_FILE = '.dsh-remote-telemetry'
|
|
197
|
+
|
|
198
|
+
/** 读取用户持久化的开关:'1'/'0'/null(未设置或不可读)。 */
|
|
199
|
+
export function readTelemetryOpt(home) {
|
|
200
|
+
try {
|
|
201
|
+
const v = readFileSync(path.join(home, OPT_FILE), 'utf8').trim()
|
|
202
|
+
return v === '1' || v === '0' ? v : null
|
|
203
|
+
} catch {
|
|
204
|
+
return null
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/** 持久化用户选择;返回是否写成功(只读 HOME 时静默 false)。 */
|
|
209
|
+
export function persistTelemetryOpt(home, enabled) {
|
|
210
|
+
try {
|
|
211
|
+
writeFileSync(path.join(home, OPT_FILE), enabled ? '1' : '0')
|
|
212
|
+
return true
|
|
213
|
+
} catch {
|
|
214
|
+
return false
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/** 当前生效值:用户覆盖 > 配置值(默认 true)。 */
|
|
219
|
+
export function telemetryAllowed(home, configValue) {
|
|
220
|
+
const opt = readTelemetryOpt(home)
|
|
221
|
+
if (opt !== null) return opt === '1'
|
|
222
|
+
return configValue !== false
|
|
223
|
+
}
|
|
224
|
+
|
|
191
225
|
/** 身份文件是否已存在(自检用,不创建)。 */
|
|
192
226
|
export function hasPersistedId(home) {
|
|
193
227
|
try {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-remote",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.78",
|
|
4
4
|
"description": "Remote-work assistant for DeepSeek Harness: connect SSH (password/key/agent/keyboard-interactive, multi-hop ProxyJump), list hosts from ~/.ssh/config, pick a remote workspace, operate on it with 21 rw_* tools, conflict-aware mirror sync, an embedded PTY terminal, remote DSH web UI attach, port forwarding, host grouping, remote sandbox fencing, audit log, keychain passwords.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "flymysql <flyphp@outlook.com>",
|