dsh-linked-workspace 0.16.1 → 0.18.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/CHANGELOG.md +17 -0
- package/README.en.md +19 -1
- package/README.md +20 -1
- package/docs/API.md +25 -4
- package/docs/VERIFY.md +24 -0
- package/lib/client.js +326 -3
- package/lib/index.js +585 -33
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -2267,6 +2267,13 @@ function attributeViolation(name, value, tagName) {
|
|
|
2267
2267
|
searchRegex: '正则表达式',
|
|
2268
2268
|
searchScopeAll: '整个工作区',
|
|
2269
2269
|
searchScopeHere: '只搜当前目录',
|
|
2270
|
+
searchIncludeIgnored: '连通常忽略的目录一起搜(.git 仍然排除)',
|
|
2271
|
+
searchFilesOnly: '只列文件名(不显示命中行)',
|
|
2272
|
+
searchStop: '停止',
|
|
2273
|
+
searchStats: '扫描 {{files}} 个文件 · {{size}}',
|
|
2274
|
+
searchStatsSkipped: '跳过 {{count}} 个',
|
|
2275
|
+
ctxCopyReference: '复制为 @ 引用',
|
|
2276
|
+
referenceCopied: '已复制 {{reference}}',
|
|
2270
2277
|
searchScopeLabel: '范围:{{scope}}',
|
|
2271
2278
|
findPlaceholder: '查找…',
|
|
2272
2279
|
replacePlaceholder: '替换为…',
|
|
@@ -2494,6 +2501,18 @@ function attributeViolation(name, value, tagName) {
|
|
|
2494
2501
|
autoSaveHint: '编辑停顿约 1 秒后自动保存;关闭后请按 Ctrl+S 手动保存。',
|
|
2495
2502
|
autoSaveLabel: '开启自动保存',
|
|
2496
2503
|
autoSaveSaved: '自动保存设置已保存',
|
|
2504
|
+
execTitle: '远端命令执行',
|
|
2505
|
+
execHint: '默认关闭。开启后,会话里的模型可以通过 linked_workspace 的 exec 动作在远端跑命令;只对下面勾选的主机/工作区生效,每次尝试(含被拒)都记进审计日志。',
|
|
2506
|
+
execEnabledLabel: '允许在远端执行命令',
|
|
2507
|
+
execWarn: '命令会以你的 SSH 账号身份在远端运行,请只对可信主机开启。',
|
|
2508
|
+
execHostsTitle: '允许的主机',
|
|
2509
|
+
execHostsEmpty: '没有可用的 SSH 主机',
|
|
2510
|
+
execWorkspacesTitle: '允许的工作区(第二层)',
|
|
2511
|
+
execWorkspacesHint: '留空表示上一步勾选的主机全部放行;勾选后只允许这些工作区。',
|
|
2512
|
+
execTimeoutLabel: '默认超时(秒)',
|
|
2513
|
+
execOutputLabel: '输出上限(字符)',
|
|
2514
|
+
execAuditOpen: '打开审计日志',
|
|
2515
|
+
execSaved: '远端命令执行设置已保存',
|
|
2497
2516
|
shortcutTitle: '常用快捷键',
|
|
2498
2517
|
shortcutHint: '与 VS Code 类似的默认快捷键;macOS 上把 Ctrl 换成 ⌘。',
|
|
2499
2518
|
shortcutSave: '保存当前文件',
|
|
@@ -2746,6 +2765,13 @@ function attributeViolation(name, value, tagName) {
|
|
|
2746
2765
|
searchRegex: 'Regular expression',
|
|
2747
2766
|
searchScopeAll: 'Whole workspace',
|
|
2748
2767
|
searchScopeHere: 'Current folder only',
|
|
2768
|
+
searchIncludeIgnored: 'Also search usually ignored folders (.git stays out)',
|
|
2769
|
+
searchFilesOnly: 'List file names only (no matching lines)',
|
|
2770
|
+
searchStop: 'Stop',
|
|
2771
|
+
searchStats: 'Scanned {{files}} files · {{size}}',
|
|
2772
|
+
searchStatsSkipped: '{{count}} skipped',
|
|
2773
|
+
ctxCopyReference: 'Copy as @ reference',
|
|
2774
|
+
referenceCopied: 'Copied {{reference}}',
|
|
2749
2775
|
searchScopeLabel: 'Scope: {{scope}}',
|
|
2750
2776
|
findPlaceholder: 'Find…',
|
|
2751
2777
|
replacePlaceholder: 'Replace with…',
|
|
@@ -2973,6 +2999,18 @@ function attributeViolation(name, value, tagName) {
|
|
|
2973
2999
|
autoSaveHint: 'Saves about one second after you stop typing. When off, press Ctrl+S to save.',
|
|
2974
3000
|
autoSaveLabel: 'Enable auto save',
|
|
2975
3001
|
autoSaveSaved: 'Auto-save setting saved',
|
|
3002
|
+
execTitle: 'Remote command execution',
|
|
3003
|
+
execHint: 'Off by default. When on, the model can run commands on the remote host through the linked_workspace "exec" action — only for the hosts and workspaces ticked below, and every attempt (refusals included) is audited.',
|
|
3004
|
+
execEnabledLabel: 'Allow running commands remotely',
|
|
3005
|
+
execWarn: 'Commands run on the remote host with your SSH account. Enable this only for hosts you trust.',
|
|
3006
|
+
execHostsTitle: 'Allowed hosts',
|
|
3007
|
+
execHostsEmpty: 'No SSH hosts available',
|
|
3008
|
+
execWorkspacesTitle: 'Allowed workspaces (second layer)',
|
|
3009
|
+
execWorkspacesHint: 'Leave empty to allow every workspace on the hosts ticked above; tick some to restrict execution to them.',
|
|
3010
|
+
execTimeoutLabel: 'Default timeout (seconds)',
|
|
3011
|
+
execOutputLabel: 'Output limit (characters)',
|
|
3012
|
+
execAuditOpen: 'Open the audit log',
|
|
3013
|
+
execSaved: 'Remote-execution settings saved',
|
|
2976
3014
|
shortcutTitle: 'Keyboard shortcuts',
|
|
2977
3015
|
shortcutHint: 'VS Code-like defaults; use ⌘ instead of Ctrl on macOS.',
|
|
2978
3016
|
shortcutSave: 'Save the current file',
|
|
@@ -3165,7 +3203,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
3165
3203
|
* Host methods the running DSH process does not have yet, the directory
|
|
3166
3204
|
* pane says so instead of surfacing an unrelated error.
|
|
3167
3205
|
*/
|
|
3168
|
-
var HOST_API_REVISION =
|
|
3206
|
+
var HOST_API_REVISION = 4;
|
|
3169
3207
|
var hostInfoProbe = null;
|
|
3170
3208
|
|
|
3171
3209
|
function probeHostInfo() {
|
|
@@ -3643,6 +3681,11 @@ function attributeViolation(name, value, tagName) {
|
|
|
3643
3681
|
'.rw-option-desc{font-size:11.5px;line-height:17px;color:var(--dsw-alias-label-tertiary)}',
|
|
3644
3682
|
'.rw-warn-box{padding:8px 10px;border-radius:8px;border:1px solid color-mix(in srgb,var(--dsw-alias-state-warn-primary) 45%,transparent);background:color-mix(in srgb,var(--dsw-alias-state-warn-primary) 8%,var(--dsw-alias-bg-layer-1));font-size:12px;line-height:18px}',
|
|
3645
3683
|
'.rw-setting-row{display:flex;align-items:center;gap:10px;padding:10px 12px;border:1px solid var(--dsw-alias-border-l1);border-radius:9px;background:var(--dsw-alias-bg-layer-1)}',
|
|
3684
|
+
'.rw-exec-list{display:flex;flex-direction:column;gap:4px;margin-top:8px}',
|
|
3685
|
+
'.rw-exec-item{display:flex;align-items:center;gap:8px;padding:7px 10px;border:1px solid var(--dsw-alias-border-l1);border-radius:8px;background:var(--dsw-alias-bg-layer-1);cursor:pointer;font-size:13px}',
|
|
3686
|
+
'.rw-exec-item input[type=checkbox]{margin:0;flex:none}',
|
|
3687
|
+
'.rw-exec-name{flex:1 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}',
|
|
3688
|
+
'.rw-exec-meta{flex:none;color:var(--dsw-alias-text-3);font-size:12px;font-variant-numeric:tabular-nums}',
|
|
3646
3689
|
'.rw-shortcut-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(220px,1fr));gap:4px 16px}',
|
|
3647
3690
|
'.rw-shortcut-row{display:flex;align-items:center;gap:10px;min-height:28px;font-size:12px;color:var(--dsw-alias-label-secondary)}',
|
|
3648
3691
|
'.rw-kbd{display:inline-flex;align-items:center;justify-content:center;min-width:64px;padding:2px 7px;border:1px solid var(--dsw-alias-border-l2);border-bottom-width:2px;border-radius:5px;background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-label-primary);font:11px/16px ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;white-space:nowrap}',
|
|
@@ -3689,6 +3732,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
3689
3732
|
'.rw-disk{flex:none;font-size:11px;color:var(--dsw-alias-label-secondary,#8b949e);font-variant-numeric:tabular-nums}',
|
|
3690
3733
|
'.rw-search-history{display:flex;align-items:center;gap:6px;flex-wrap:wrap;padding:4px 8px 6px}',
|
|
3691
3734
|
'.rw-search-history-label{font-size:11px;color:var(--dsw-alias-label-secondary,#8b949e);flex:none}',
|
|
3735
|
+
'.rw-search-stats{padding:2px 8px 4px;font-size:11px;color:var(--dsw-alias-label-secondary,#8b949e);font-variant-numeric:tabular-nums}',
|
|
3692
3736
|
'.rw-queue-history{margin-top:12px;border-top:1px solid var(--dsw-alias-border-l1,rgba(127,127,127,.28));padding-top:8px}',
|
|
3693
3737
|
'.rw-queue-history-title{font-size:11px;color:var(--dsw-alias-label-secondary,#8b949e);margin-bottom:4px}',
|
|
3694
3738
|
'.rw-queue-row.is-history .rw-queue-state{opacity:.75}',
|
|
@@ -7171,6 +7215,16 @@ function rememberShowHidden(value) {
|
|
|
7171
7215
|
var searchHereState = useState(false);
|
|
7172
7216
|
var searchHere = searchHereState[0];
|
|
7173
7217
|
var setSearchHere = searchHereState[1];
|
|
7218
|
+
var searchIncludeIgnoredState = useState(false);
|
|
7219
|
+
var searchIncludeIgnored = searchIncludeIgnoredState[0];
|
|
7220
|
+
var setSearchIncludeIgnored = searchIncludeIgnoredState[1];
|
|
7221
|
+
var searchFilesOnlyState = useState(false);
|
|
7222
|
+
var searchFilesOnly = searchFilesOnlyState[0];
|
|
7223
|
+
var setSearchFilesOnly = searchFilesOnlyState[1];
|
|
7224
|
+
var searchStatsState = useState(null);
|
|
7225
|
+
var searchStats = searchStatsState[0];
|
|
7226
|
+
var setSearchStats = searchStatsState[1];
|
|
7227
|
+
var searchJobRef = useRef('');
|
|
7174
7228
|
var searchState = useState({ loading: false, remote: [], local: [], truncated: false, truncatedReason: '', error: null });
|
|
7175
7229
|
var search = searchState[0];
|
|
7176
7230
|
var setSearch = searchState[1];
|
|
@@ -7722,6 +7776,27 @@ function rememberShowHidden(value) {
|
|
|
7722
7776
|
} catch (error) { /* clipboard unavailable */ }
|
|
7723
7777
|
}
|
|
7724
7778
|
|
|
7779
|
+
/** Copy the `@relative/path` form the model understands for a workspace path. */
|
|
7780
|
+
function copyReference(filePath) {
|
|
7781
|
+
var scope = sourceScopeOf(selected);
|
|
7782
|
+
var root = selected && selected.kind === 'remote' ? selected.remotePath : (selected && selected.remotePath) || '';
|
|
7783
|
+
var relative = String(filePath || '');
|
|
7784
|
+
if (root && relative.indexOf(root) === 0) {
|
|
7785
|
+
relative = relative.slice(root.length);
|
|
7786
|
+
if (relative.charAt(0) !== '/') relative = '/' + relative;
|
|
7787
|
+
}
|
|
7788
|
+
var reference = '@' + relative.replace(/^\/+/, '');
|
|
7789
|
+
try {
|
|
7790
|
+
if (navigator.clipboard && navigator.clipboard.writeText) {
|
|
7791
|
+
navigator.clipboard.writeText(reference).then(function () {
|
|
7792
|
+
showNotice('success', t('referenceCopied', { reference: reference }));
|
|
7793
|
+
}).catch(function () {});
|
|
7794
|
+
return;
|
|
7795
|
+
}
|
|
7796
|
+
} catch (error) { /* clipboard unavailable */ }
|
|
7797
|
+
void scope
|
|
7798
|
+
}
|
|
7799
|
+
|
|
7725
7800
|
/** Copy a ready-made ssh command that lands in the given remote directory. */
|
|
7726
7801
|
function copySshCommand(dirPath) {
|
|
7727
7802
|
var source = selected || {};
|
|
@@ -8287,6 +8362,7 @@ function rememberShowHidden(value) {
|
|
|
8287
8362
|
items.push({ label: t('ctxPaste'), disabled: !canPaste, onSelect: function () { pasteEntry(menu); } });
|
|
8288
8363
|
items.push({ separator: true });
|
|
8289
8364
|
items.push({ label: t('ctxCopyPath'), onSelect: function () { copyPathToClipboard(menu.path); } });
|
|
8365
|
+
items.push({ label: t('ctxCopyReference'), onSelect: function () { copyReference(menu.path); } });
|
|
8290
8366
|
if (menu.side === 'remote' && menu.isDir) {
|
|
8291
8367
|
items.push({ label: t('ctxCopySsh'), onSelect: function () { copySshCommand(menu.path); } });
|
|
8292
8368
|
}
|
|
@@ -8521,11 +8597,18 @@ function rememberShowHidden(value) {
|
|
|
8521
8597
|
var contentMode = searchMode === 'content';
|
|
8522
8598
|
var method = contentMode ? 'fs.grep' : 'fs.search';
|
|
8523
8599
|
var extra = { side: 'remote', query: query, maxResults: 200 };
|
|
8600
|
+
var jobId = '';
|
|
8524
8601
|
if (contentMode) {
|
|
8525
8602
|
// F3: narrow the sweep to the folder the user is standing in.
|
|
8526
8603
|
if (searchHere && searchRootPath !== '') extra.path = searchRootPath;
|
|
8527
8604
|
extra.ignoreCase = !searchCase;
|
|
8528
8605
|
extra.regex = searchRegex;
|
|
8606
|
+
extra.includeIgnored = searchIncludeIgnored;
|
|
8607
|
+
extra.resultMode = searchFilesOnly ? 'files' : 'lines';
|
|
8608
|
+
// One job id per sweep so 「停止」 can cancel it on the Host.
|
|
8609
|
+
jobId = 'grep-' + Date.now() + '-' + Math.random().toString(36).slice(2, 8);
|
|
8610
|
+
extra.jobId = jobId;
|
|
8611
|
+
searchJobRef.current = jobId;
|
|
8529
8612
|
}
|
|
8530
8613
|
var jobs = [apiCall(method, Object.assign(extra, scopeParams(scopeNow))).catch(function (error) {
|
|
8531
8614
|
return { ok: false, entries: [], error: messageOf(error, t, locale) };
|
|
@@ -8541,6 +8624,16 @@ function rememberShowHidden(value) {
|
|
|
8541
8624
|
}
|
|
8542
8625
|
Promise.all(jobs).then(function (results) {
|
|
8543
8626
|
if (!alive) return;
|
|
8627
|
+
if (contentMode && jobId !== '' && searchJobRef.current === jobId) searchJobRef.current = '';
|
|
8628
|
+
var stats = null;
|
|
8629
|
+
if (contentMode && results[0] && typeof results[0].scannedFiles === 'number') {
|
|
8630
|
+
stats = {
|
|
8631
|
+
files: (results[0].scannedFiles || 0) + ((results[1] && results[1].scannedFiles) || 0),
|
|
8632
|
+
bytes: (results[0].scannedBytes || 0) + ((results[1] && results[1].scannedBytes) || 0),
|
|
8633
|
+
skipped: (results[0].skippedFiles || 0) + ((results[1] && results[1].skippedFiles) || 0),
|
|
8634
|
+
};
|
|
8635
|
+
}
|
|
8636
|
+
if (contentMode) setSearchStats(stats);
|
|
8544
8637
|
setSearch({
|
|
8545
8638
|
loading: false,
|
|
8546
8639
|
remote: results[0] && results[0].entries ? results[0].entries : [],
|
|
@@ -8552,7 +8645,7 @@ function rememberShowHidden(value) {
|
|
|
8552
8645
|
});
|
|
8553
8646
|
}, 320);
|
|
8554
8647
|
return function () { alive = false; clearTimeout(timer); };
|
|
8555
|
-
}, [searchOpen, searchQuery, selectedKey, version, searchMode, searchCase, searchRegex, searchHere]);
|
|
8648
|
+
}, [searchOpen, searchQuery, selectedKey, version, searchMode, searchCase, searchRegex, searchHere, searchIncludeIgnored, searchFilesOnly]);
|
|
8556
8649
|
|
|
8557
8650
|
if (!selected) {
|
|
8558
8651
|
return h('div', { className: 'rw-workbench rw-workspace', ref: workbenchRef },
|
|
@@ -8809,7 +8902,33 @@ function rememberShowHidden(value) {
|
|
|
8809
8902
|
'aria-pressed': searchHere ? 'true' : 'false',
|
|
8810
8903
|
disabled: searchRootPath === '',
|
|
8811
8904
|
onClick: function () { setSearchHere(!searchHere); },
|
|
8812
|
-
}, IconFolderTree(11))
|
|
8905
|
+
}, IconFolderTree(11)),
|
|
8906
|
+
h('button', {
|
|
8907
|
+
type: 'button',
|
|
8908
|
+
className: 'rw-chip-btn' + (searchIncludeIgnored ? ' is-on' : ''),
|
|
8909
|
+
title: t('searchIncludeIgnored'),
|
|
8910
|
+
'aria-pressed': searchIncludeIgnored ? 'true' : 'false',
|
|
8911
|
+
onClick: function () { setSearchIncludeIgnored(!searchIncludeIgnored); },
|
|
8912
|
+
}, '.*/'),
|
|
8913
|
+
h('button', {
|
|
8914
|
+
type: 'button',
|
|
8915
|
+
className: 'rw-chip-btn' + (searchFilesOnly ? ' is-on' : ''),
|
|
8916
|
+
title: t('searchFilesOnly'),
|
|
8917
|
+
'aria-pressed': searchFilesOnly ? 'true' : 'false',
|
|
8918
|
+
onClick: function () { setSearchFilesOnly(!searchFilesOnly); },
|
|
8919
|
+
}, IconFile(11)),
|
|
8920
|
+
search.loading && searchJobRef.current !== ''
|
|
8921
|
+
? h('button', {
|
|
8922
|
+
type: 'button',
|
|
8923
|
+
className: 'rw-chip-btn',
|
|
8924
|
+
title: t('searchStop'),
|
|
8925
|
+
onClick: function () {
|
|
8926
|
+
var jobId = searchJobRef.current;
|
|
8927
|
+
searchJobRef.current = '';
|
|
8928
|
+
if (jobId) apiCall('fs.grepCancel', { jobId }).catch(function () {});
|
|
8929
|
+
},
|
|
8930
|
+
}, t('searchStop'))
|
|
8931
|
+
: null)
|
|
8813
8932
|
: null,
|
|
8814
8933
|
h('button', {
|
|
8815
8934
|
type: 'button', className: 'rw-icon-btn', title: t('cancel'),
|
|
@@ -8829,6 +8948,11 @@ function rememberShowHidden(value) {
|
|
|
8829
8948
|
}, h('span', { style: { overflow: 'hidden', textOverflow: 'ellipsis', maxWidth: '160px' } }, term));
|
|
8830
8949
|
}))
|
|
8831
8950
|
: null,
|
|
8951
|
+
searchOpen && searchMode === 'content' && !search.loading && searchStats && searchStats.files > 0
|
|
8952
|
+
? h('div', { className: 'rw-search-stats' },
|
|
8953
|
+
t('searchStats', { files: searchStats.files, size: formatBytes(searchStats.bytes) }),
|
|
8954
|
+
searchStats.skipped > 0 ? ' · ' + t('searchStatsSkipped', { count: searchStats.skipped }) : '')
|
|
8955
|
+
: null,
|
|
8832
8956
|
sources.length > 1
|
|
8833
8957
|
? h('div', { className: 'rw-chips' },
|
|
8834
8958
|
sources.map(function (source) {
|
|
@@ -10455,6 +10579,199 @@ function rememberShowHidden(value) {
|
|
|
10455
10579
|
: null);
|
|
10456
10580
|
}
|
|
10457
10581
|
|
|
10582
|
+
function ExecSettingsGroup(props) {
|
|
10583
|
+
var t = props.t;
|
|
10584
|
+
var locale = props.locale;
|
|
10585
|
+
var hosts = props.hosts || [];
|
|
10586
|
+
var workspaces = props.workspaces || [];
|
|
10587
|
+
var state = useState({
|
|
10588
|
+
loading: true,
|
|
10589
|
+
saving: false,
|
|
10590
|
+
message: null,
|
|
10591
|
+
execEnabled: false,
|
|
10592
|
+
execHostIds: [],
|
|
10593
|
+
execWorkspaceIds: [],
|
|
10594
|
+
execTimeoutSec: 60,
|
|
10595
|
+
execMaxOutputChars: 200000,
|
|
10596
|
+
});
|
|
10597
|
+
var local = state[0];
|
|
10598
|
+
var setLocal = state[1];
|
|
10599
|
+
|
|
10600
|
+
var adopt = function (settings, extra) {
|
|
10601
|
+
var value = settings || {};
|
|
10602
|
+
setLocal(function (previous) {
|
|
10603
|
+
return Object.assign({}, previous, {
|
|
10604
|
+
loading: false,
|
|
10605
|
+
execEnabled: typeof value.execEnabled === 'boolean' ? value.execEnabled : previous.execEnabled,
|
|
10606
|
+
execHostIds: Array.isArray(value.execHostIds) ? value.execHostIds : previous.execHostIds,
|
|
10607
|
+
execWorkspaceIds: Array.isArray(value.execWorkspaceIds) ? value.execWorkspaceIds : previous.execWorkspaceIds,
|
|
10608
|
+
execTimeoutSec: Math.round((Number(value.execTimeoutMs) || previous.execTimeoutSec * 1000) / 1000),
|
|
10609
|
+
execMaxOutputChars: Number(value.execMaxOutputChars) || previous.execMaxOutputChars,
|
|
10610
|
+
}, extra || {});
|
|
10611
|
+
});
|
|
10612
|
+
};
|
|
10613
|
+
|
|
10614
|
+
useEffect(function () {
|
|
10615
|
+
var alive = true;
|
|
10616
|
+
apiCall('settings.get', {}).then(function (settings) {
|
|
10617
|
+
if (alive) adopt(settings);
|
|
10618
|
+
}).catch(function (error) {
|
|
10619
|
+
if (!alive) return;
|
|
10620
|
+
setLocal(function (previous) {
|
|
10621
|
+
return Object.assign({}, previous, {
|
|
10622
|
+
loading: false,
|
|
10623
|
+
message: { kind: 'error', text: messageOf(error, t, locale) },
|
|
10624
|
+
});
|
|
10625
|
+
});
|
|
10626
|
+
});
|
|
10627
|
+
return function () { alive = false; };
|
|
10628
|
+
}, []);
|
|
10629
|
+
|
|
10630
|
+
function save(patch, okText) {
|
|
10631
|
+
if (local.saving) return;
|
|
10632
|
+
setLocal(function (previous) { return Object.assign({}, previous, { saving: true, message: null }); });
|
|
10633
|
+
apiCall('settings.update', patch).then(function (settings) {
|
|
10634
|
+
adopt(settings, {
|
|
10635
|
+
saving: false,
|
|
10636
|
+
message: okText ? { kind: 'success', text: okText } : null,
|
|
10637
|
+
});
|
|
10638
|
+
}).catch(function (error) {
|
|
10639
|
+
setLocal(function (previous) {
|
|
10640
|
+
return Object.assign({}, previous, {
|
|
10641
|
+
saving: false,
|
|
10642
|
+
message: { kind: 'error', text: messageOf(error, t, locale) },
|
|
10643
|
+
});
|
|
10644
|
+
});
|
|
10645
|
+
});
|
|
10646
|
+
}
|
|
10647
|
+
|
|
10648
|
+
function withId(list, id, checked) {
|
|
10649
|
+
var next = (list || []).filter(function (item) { return item !== id; });
|
|
10650
|
+
if (checked) next.push(id);
|
|
10651
|
+
return next;
|
|
10652
|
+
}
|
|
10653
|
+
|
|
10654
|
+
function openAudit() {
|
|
10655
|
+
apiCall('meta.info', {}).then(function (info) {
|
|
10656
|
+
if (!info || !info.execAuditFile) return null;
|
|
10657
|
+
return apiCall('local.openExternal', { path: info.execAuditFile });
|
|
10658
|
+
}).catch(function (error) {
|
|
10659
|
+
setLocal(function (previous) {
|
|
10660
|
+
return Object.assign({}, previous, {
|
|
10661
|
+
message: { kind: 'error', text: messageOf(error, t, locale) },
|
|
10662
|
+
});
|
|
10663
|
+
});
|
|
10664
|
+
});
|
|
10665
|
+
}
|
|
10666
|
+
|
|
10667
|
+
function numberRow(label, value, min, max, step, onCommit) {
|
|
10668
|
+
return h('label', { className: 'rw-inline', style: { gap: 6 } },
|
|
10669
|
+
h('span', { className: 'rw-group-hint' }, label),
|
|
10670
|
+
h('input', {
|
|
10671
|
+
className: 'rw-input',
|
|
10672
|
+
style: { width: 92 },
|
|
10673
|
+
type: 'number',
|
|
10674
|
+
min: min,
|
|
10675
|
+
max: max,
|
|
10676
|
+
step: step,
|
|
10677
|
+
value: String(value),
|
|
10678
|
+
onChange: function (event) {
|
|
10679
|
+
var next = Number(event.currentTarget.value);
|
|
10680
|
+
setLocal(function (previous) {
|
|
10681
|
+
var patch = {};
|
|
10682
|
+
patch[onCommit.field] = Number.isFinite(next) ? next : previous[onCommit.field];
|
|
10683
|
+
return Object.assign({}, previous, patch);
|
|
10684
|
+
});
|
|
10685
|
+
},
|
|
10686
|
+
onBlur: function () { onCommit.commit(local[onCommit.field]); },
|
|
10687
|
+
}));
|
|
10688
|
+
}
|
|
10689
|
+
|
|
10690
|
+
var children = [
|
|
10691
|
+
h('div', { className: 'rw-group-head' },
|
|
10692
|
+
h('span', { className: 'rw-group-title' }, t('execTitle')),
|
|
10693
|
+
h('span', { className: 'rw-group-hint' }, t('execHint'))),
|
|
10694
|
+
h('div', { className: 'rw-setting-row' },
|
|
10695
|
+
h(Switch, {
|
|
10696
|
+
checked: local.execEnabled,
|
|
10697
|
+
onChange: function (next) { save({ execEnabled: Boolean(next) }, t('execSaved')); },
|
|
10698
|
+
label: t('execEnabledLabel'),
|
|
10699
|
+
text: t('execEnabledLabel'),
|
|
10700
|
+
}),
|
|
10701
|
+
local.saving ? Spinner(12) : null),
|
|
10702
|
+
];
|
|
10703
|
+
|
|
10704
|
+
if (local.execEnabled) {
|
|
10705
|
+
children.push(h('div', { className: 'rw-group-hint', style: { marginTop: 8, color: 'rgb(210,153,34)' } }, t('execWarn')));
|
|
10706
|
+
children.push(h('div', { className: 'rw-group-head', style: { marginTop: 12 } },
|
|
10707
|
+
h('span', { className: 'rw-group-title' }, t('execHostsTitle'))));
|
|
10708
|
+
children.push(hosts.length === 0
|
|
10709
|
+
? h('div', { className: 'rw-hint' }, t('execHostsEmpty'))
|
|
10710
|
+
: h('div', { className: 'rw-exec-list' }, hosts.map(function (host) {
|
|
10711
|
+
var checked = local.execHostIds.indexOf(host.id) >= 0;
|
|
10712
|
+
return h('label', { key: host.id, className: 'rw-exec-item' },
|
|
10713
|
+
h('input', {
|
|
10714
|
+
type: 'checkbox',
|
|
10715
|
+
checked: checked,
|
|
10716
|
+
onChange: function (event) {
|
|
10717
|
+
var on = event.currentTarget.checked;
|
|
10718
|
+
save({ execHostIds: withId(local.execHostIds, host.id, on) }, t('execSaved'));
|
|
10719
|
+
},
|
|
10720
|
+
}),
|
|
10721
|
+
h('span', { className: 'rw-exec-name' }, host.name || host.host || host.id),
|
|
10722
|
+
h('span', { className: 'rw-exec-meta' }, (host.username ? host.username + '@' : '') + (host.host || '') + (host.port ? ':' + host.port : '')));
|
|
10723
|
+
})));
|
|
10724
|
+
children.push(h('div', { className: 'rw-group-head', style: { marginTop: 12 } },
|
|
10725
|
+
h('span', { className: 'rw-group-title' }, t('execWorkspacesTitle')),
|
|
10726
|
+
h('span', { className: 'rw-group-hint' }, t('execWorkspacesHint'))));
|
|
10727
|
+
children.push(workspaces.length === 0
|
|
10728
|
+
? h('div', { className: 'rw-hint' }, t('execHostsEmpty'))
|
|
10729
|
+
: h('div', { className: 'rw-exec-list' }, workspaces.map(function (item) {
|
|
10730
|
+
var checked = local.execWorkspaceIds.indexOf(item.id) >= 0;
|
|
10731
|
+
return h('label', { key: item.id, className: 'rw-exec-item' },
|
|
10732
|
+
h('input', {
|
|
10733
|
+
type: 'checkbox',
|
|
10734
|
+
checked: checked,
|
|
10735
|
+
onChange: function (event) {
|
|
10736
|
+
var on = event.currentTarget.checked;
|
|
10737
|
+
save({ execWorkspaceIds: withId(local.execWorkspaceIds, item.id, on) }, t('execSaved'));
|
|
10738
|
+
},
|
|
10739
|
+
}),
|
|
10740
|
+
h('span', { className: 'rw-exec-name' }, item.name || item.id),
|
|
10741
|
+
h('span', { className: 'rw-exec-meta' }, item.remotePath || ''));
|
|
10742
|
+
})));
|
|
10743
|
+
children.push(h('div', { className: 'rw-inline', style: { marginTop: 12, flexWrap: 'wrap', gap: 12 } },
|
|
10744
|
+
numberRow(t('execTimeoutLabel'), local.execTimeoutSec, 1, 600, 1, {
|
|
10745
|
+
field: 'execTimeoutSec',
|
|
10746
|
+
commit: function (value) {
|
|
10747
|
+
save({ execTimeoutMs: Math.round((Number(value) || 60) * 1000) }, t('execSaved'));
|
|
10748
|
+
},
|
|
10749
|
+
}),
|
|
10750
|
+
numberRow(t('execOutputLabel'), local.execMaxOutputChars, 1000, 400000, 1000, {
|
|
10751
|
+
field: 'execMaxOutputChars',
|
|
10752
|
+
commit: function (value) {
|
|
10753
|
+
save({ execMaxOutputChars: Math.round(Number(value) || 200000) }, t('execSaved'));
|
|
10754
|
+
},
|
|
10755
|
+
}),
|
|
10756
|
+
h('button', {
|
|
10757
|
+
type: 'button',
|
|
10758
|
+
className: 'rw-btn rw-btn-ghost rw-btn-sm',
|
|
10759
|
+
onClick: openAudit,
|
|
10760
|
+
}, IconTerminal(13), t('execAuditOpen'))));
|
|
10761
|
+
}
|
|
10762
|
+
|
|
10763
|
+
if (local.message) {
|
|
10764
|
+
children.push(h(Banner, {
|
|
10765
|
+
kind: local.message.kind === 'success' ? 'success' : 'error',
|
|
10766
|
+
onClose: function () {
|
|
10767
|
+
setLocal(function (previous) { return Object.assign({}, previous, { message: null }); });
|
|
10768
|
+
},
|
|
10769
|
+
}, local.message.text));
|
|
10770
|
+
}
|
|
10771
|
+
|
|
10772
|
+
return h('div', { className: 'rw-group' }, children);
|
|
10773
|
+
}
|
|
10774
|
+
|
|
10458
10775
|
function ConnectionsPage(props) {
|
|
10459
10776
|
var ctx = props.ctx;
|
|
10460
10777
|
var locale = useLocale(ctx);
|
|
@@ -10515,6 +10832,12 @@ function rememberShowHidden(value) {
|
|
|
10515
10832
|
!sidebarAvailable ? h(Banner, { kind: 'warn' }, t('needsSidebar')) : null,
|
|
10516
10833
|
h(ThemeGroup, { t: t, locale: locale }),
|
|
10517
10834
|
h(EditorSettingsGroup, { t: t, locale: locale }),
|
|
10835
|
+
h(ExecSettingsGroup, {
|
|
10836
|
+
t: t,
|
|
10837
|
+
locale: locale,
|
|
10838
|
+
hosts: remote.data.hosts || [],
|
|
10839
|
+
workspaces: links.concat(remotes),
|
|
10840
|
+
}),
|
|
10518
10841
|
adding === 'linked'
|
|
10519
10842
|
? h(AddWorkspaceFlow, {
|
|
10520
10843
|
ctx: ctx, t: t, locale: locale,
|