dsh-linked-workspace 0.18.0 → 0.20.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 +16 -0
- package/README.en.md +6 -0
- package/README.md +6 -0
- package/docs/API.md +14 -6
- package/docs/VERIFY.md +16 -0
- package/lib/client.js +490 -1
- package/lib/index.js +613 -16
- package/lib/ssh.js +108 -15
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -2501,6 +2501,45 @@ function attributeViolation(name, value, tagName) {
|
|
|
2501
2501
|
autoSaveHint: '编辑停顿约 1 秒后自动保存;关闭后请按 Ctrl+S 手动保存。',
|
|
2502
2502
|
autoSaveLabel: '开启自动保存',
|
|
2503
2503
|
autoSaveSaved: '自动保存设置已保存',
|
|
2504
|
+
syncTitle: '把本地改动推回远端',
|
|
2505
|
+
syncNeedsLinked: '只有联动工作区有本地目录可以推送',
|
|
2506
|
+
syncSummary: '新增 {{added}} · 修改 {{changed}} · 冲突 {{conflict}} · 远端已删 {{removed}}',
|
|
2507
|
+
syncNothing: '本地与远端一致,没有需要推送的文件。',
|
|
2508
|
+
syncTruncated: '文件太多,只比较了前 {{max}} 个;请先清理或分批推送。',
|
|
2509
|
+
syncSkipped: '跳过了 {{count}} 个(过大或无法读取)。',
|
|
2510
|
+
syncAdded: '新增',
|
|
2511
|
+
syncChanged: '修改',
|
|
2512
|
+
syncConflict: '冲突',
|
|
2513
|
+
syncRemoved: '远端已删',
|
|
2514
|
+
syncMore: '还有 {{count}} 个未列出…',
|
|
2515
|
+
syncPushSkip: '推送(跳过冲突)',
|
|
2516
|
+
syncPushOverwrite: '推送并覆盖冲突',
|
|
2517
|
+
syncPushing: '正在推送…',
|
|
2518
|
+
syncPushed: '已推送 {{pushed}} 个文件',
|
|
2519
|
+
syncConflictLeft: '{{count}} 个冲突未处理',
|
|
2520
|
+
ctxPushThis: '把这个推送到远端',
|
|
2521
|
+
autoPushTitle: '自动推回远端',
|
|
2522
|
+
autoPushLabel: '开启自动推送',
|
|
2523
|
+
autoPushWarn: '开启后,本地目录里保存的文件会在停止编辑约 1.5 秒后自动写回远端;如果同一文件在远端也被改过,会保留远端版本(不覆盖)。',
|
|
2524
|
+
autoPushConfirm: '我明白,开启自动推送',
|
|
2525
|
+
autoPushCancel: '先不开',
|
|
2526
|
+
autoPushIncludeLabel: '只推送这些路径(每行一个,支持 *)',
|
|
2527
|
+
autoPushExcludeLabel: '不要推送这些路径(每行一个,支持 *)',
|
|
2528
|
+
autoPushDebounceLabel: '停止编辑后等待(毫秒)',
|
|
2529
|
+
autoPushSaved: '自动推送设置已保存',
|
|
2530
|
+
sshTrustTitle: 'SSH 信任与编码',
|
|
2531
|
+
sshTrustHint: '默认信任第一次连接看到的主机密钥(TOFU);选「严格」后,没见过的主机一律拒绝。远端命令输出按下面的编码解码,中文 Windows 服务器常需要 GBK。',
|
|
2532
|
+
hostKeyPolicyLabel: '主机密钥策略',
|
|
2533
|
+
hostKeyPolicyTofu: '信任首次连接(TOFU)',
|
|
2534
|
+
hostKeyPolicyStrict: '只连接见过的主机(严格)',
|
|
2535
|
+
outputEncodingLabel: '远端命令输出编码',
|
|
2536
|
+
outputEncodingUtf8: 'UTF-8(大多数 Linux)',
|
|
2537
|
+
outputEncodingGbk: 'GBK(中文 Windows)',
|
|
2538
|
+
knownKeysTitle: '已知主机密钥',
|
|
2539
|
+
knownKeysEmpty: '还没有记录任何主机密钥。',
|
|
2540
|
+
forgetHostKey: '忘记',
|
|
2541
|
+
forgotHostKey: '已忘记 {{authority}} 的主机密钥',
|
|
2542
|
+
sshTrustSaved: 'SSH 设置已保存',
|
|
2504
2543
|
execTitle: '远端命令执行',
|
|
2505
2544
|
execHint: '默认关闭。开启后,会话里的模型可以通过 linked_workspace 的 exec 动作在远端跑命令;只对下面勾选的主机/工作区生效,每次尝试(含被拒)都记进审计日志。',
|
|
2506
2545
|
execEnabledLabel: '允许在远端执行命令',
|
|
@@ -2999,6 +3038,45 @@ function attributeViolation(name, value, tagName) {
|
|
|
2999
3038
|
autoSaveHint: 'Saves about one second after you stop typing. When off, press Ctrl+S to save.',
|
|
3000
3039
|
autoSaveLabel: 'Enable auto save',
|
|
3001
3040
|
autoSaveSaved: 'Auto-save setting saved',
|
|
3041
|
+
syncTitle: 'Push local changes back to the remote side',
|
|
3042
|
+
syncNeedsLinked: 'Only a linked workspace has a local directory to push',
|
|
3043
|
+
syncSummary: 'added {{added}} · changed {{changed}} · conflict {{conflict}} · gone upstream {{removed}}',
|
|
3044
|
+
syncNothing: 'Local and remote agree; nothing to push.',
|
|
3045
|
+
syncTruncated: 'Too many files; only the first {{max}} were compared. Tidy up or push in batches.',
|
|
3046
|
+
syncSkipped: '{{count}} skipped (too large or unreadable).',
|
|
3047
|
+
syncAdded: 'added',
|
|
3048
|
+
syncChanged: 'changed',
|
|
3049
|
+
syncConflict: 'conflict',
|
|
3050
|
+
syncRemoved: 'gone upstream',
|
|
3051
|
+
syncMore: '{{count}} more not listed…',
|
|
3052
|
+
syncPushSkip: 'Push (skip conflicts)',
|
|
3053
|
+
syncPushOverwrite: 'Push and overwrite conflicts',
|
|
3054
|
+
syncPushing: 'Pushing…',
|
|
3055
|
+
syncPushed: 'Pushed {{pushed}} file(s)',
|
|
3056
|
+
syncConflictLeft: '{{count}} conflict(s) left',
|
|
3057
|
+
ctxPushThis: 'Push this to the remote side',
|
|
3058
|
+
autoPushTitle: 'Push back automatically',
|
|
3059
|
+
autoPushLabel: 'Enable automatic push',
|
|
3060
|
+
autoPushWarn: 'Once enabled, files saved locally are written back about 1.5 s after you stop editing. If the same file also changed on the remote side, the remote version is kept (never overwritten).',
|
|
3061
|
+
autoPushConfirm: 'I understand, enable it',
|
|
3062
|
+
autoPushCancel: 'Not now',
|
|
3063
|
+
autoPushIncludeLabel: 'Only push these paths (one per line, * allowed)',
|
|
3064
|
+
autoPushExcludeLabel: 'Never push these paths (one per line, * allowed)',
|
|
3065
|
+
autoPushDebounceLabel: 'Wait after editing stops (ms)',
|
|
3066
|
+
autoPushSaved: 'Automatic push settings saved',
|
|
3067
|
+
sshTrustTitle: 'SSH trust and encodings',
|
|
3068
|
+
sshTrustHint: 'The first host key seen is trusted by default (TOFU); "strict" refuses a host we have never seen. Command output is decoded with the encoding below — Chinese Windows servers usually need GBK.',
|
|
3069
|
+
hostKeyPolicyLabel: 'Host key policy',
|
|
3070
|
+
hostKeyPolicyTofu: 'Trust the first key (TOFU)',
|
|
3071
|
+
hostKeyPolicyStrict: 'Only connect to known hosts (strict)',
|
|
3072
|
+
outputEncodingLabel: 'Remote command output encoding',
|
|
3073
|
+
outputEncodingUtf8: 'UTF-8 (most Linux hosts)',
|
|
3074
|
+
outputEncodingGbk: 'GBK (Chinese Windows)',
|
|
3075
|
+
knownKeysTitle: 'Known host keys',
|
|
3076
|
+
knownKeysEmpty: 'No host key recorded yet.',
|
|
3077
|
+
forgetHostKey: 'Forget',
|
|
3078
|
+
forgotHostKey: 'Forgot the host key for {{authority}}',
|
|
3079
|
+
sshTrustSaved: 'SSH settings saved',
|
|
3002
3080
|
execTitle: 'Remote command execution',
|
|
3003
3081
|
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
3082
|
execEnabledLabel: 'Allow running commands remotely',
|
|
@@ -3203,7 +3281,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
3203
3281
|
* Host methods the running DSH process does not have yet, the directory
|
|
3204
3282
|
* pane says so instead of surfacing an unrelated error.
|
|
3205
3283
|
*/
|
|
3206
|
-
var HOST_API_REVISION =
|
|
3284
|
+
var HOST_API_REVISION = 6;
|
|
3207
3285
|
var hostInfoProbe = null;
|
|
3208
3286
|
|
|
3209
3287
|
function probeHostInfo() {
|
|
@@ -3682,6 +3760,16 @@ function attributeViolation(name, value, tagName) {
|
|
|
3682
3760
|
'.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}',
|
|
3683
3761
|
'.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
3762
|
'.rw-exec-list{display:flex;flex-direction:column;gap:4px;margin-top:8px}',
|
|
3763
|
+
'.rw-sync-list{display:flex;flex-direction:column;gap:2px;max-height:260px;overflow:auto;margin:8px 0;padding:6px 8px;border-radius:10px;background:var(--dsw-alias-bg-base)}',
|
|
3764
|
+
'.rw-sync-row{display:flex;align-items:center;gap:8px;font-size:12px;line-height:20px}',
|
|
3765
|
+
'.rw-sync-tag{flex:none;min-width:52px;color:rgb(150,150,152)}',
|
|
3766
|
+
'.rw-sync-path{flex:1 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-family:var(--dsw-font-mono,monospace)}',
|
|
3767
|
+
'.rw-autopush-list{width:100%;resize:vertical;font-family:var(--dsw-font-mono,monospace);font-size:12px}',
|
|
3768
|
+
'.rw-known-keys{display:flex;flex-direction:column;gap:6px;margin-top:8px}',
|
|
3769
|
+
'.rw-known-key{display:flex;align-items:center;gap:10px}',
|
|
3770
|
+
'.rw-known-key-main{flex:1 1 auto;min-width:0;display:flex;flex-direction:column;gap:2px}',
|
|
3771
|
+
'.rw-known-key-host{font-size:12px;color:var(--dsw-alias-text-2)}',
|
|
3772
|
+
'.rw-known-key-fp{font-size:11px;font-family:var(--dsw-font-mono,monospace);color:var(--dsw-alias-text-3);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}',
|
|
3685
3773
|
'.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
3774
|
'.rw-exec-item input[type=checkbox]{margin:0;flex:none}',
|
|
3687
3775
|
'.rw-exec-name{flex:1 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}',
|
|
@@ -6080,6 +6168,14 @@ function attributeViolation(name, value, tagName) {
|
|
|
6080
6168
|
style: props.transferEnabled ? undefined : { opacity: 0.42, cursor: 'default' },
|
|
6081
6169
|
onClick: props.transferSelected,
|
|
6082
6170
|
}, IconDownload(14)),
|
|
6171
|
+
h('button', {
|
|
6172
|
+
type: 'button',
|
|
6173
|
+
className: 'rw-icon-btn' + (props.syncBusy ? ' is-on' : ''),
|
|
6174
|
+
title: props.syncTitle || t('syncTitle'),
|
|
6175
|
+
disabled: !props.syncEnabled,
|
|
6176
|
+
style: props.syncEnabled ? undefined : { opacity: 0.42, cursor: 'default' },
|
|
6177
|
+
onClick: props.onSync,
|
|
6178
|
+
}, IconSync(14)),
|
|
6083
6179
|
h('button', {
|
|
6084
6180
|
type: 'button',
|
|
6085
6181
|
className: 'rw-icon-btn',
|
|
@@ -6763,6 +6859,50 @@ function rememberShowHidden(value) {
|
|
|
6763
6859
|
h('button', { type: 'button', className: 'rw-btn rw-btn-sm', onClick: props.onClose }, props.t('cancel'))));
|
|
6764
6860
|
}
|
|
6765
6861
|
|
|
6862
|
+
function SyncPlanDialog(props) {
|
|
6863
|
+
var t = props.t;
|
|
6864
|
+
var plan = props.plan;
|
|
6865
|
+
var rows = []
|
|
6866
|
+
.concat((plan.added || []).map(function (item) { return { tag: t('syncAdded'), item: item }; }))
|
|
6867
|
+
.concat((plan.changed || []).map(function (item) { return { tag: t('syncChanged'), item: item }; }))
|
|
6868
|
+
.concat((plan.conflict || []).map(function (item) { return { tag: t('syncConflict'), item: item }; }))
|
|
6869
|
+
.concat((plan.removed || []).map(function (item) { return { tag: t('syncRemoved'), item: item }; }));
|
|
6870
|
+
var busy = Boolean(props.busy);
|
|
6871
|
+
return h(DialogShell, { title: t('syncTitle'), onClose: busy ? function () {} : props.onClose },
|
|
6872
|
+
h('div', { className: 'rw-dialog-message' },
|
|
6873
|
+
t('syncSummary', {
|
|
6874
|
+
added: (plan.added || []).length,
|
|
6875
|
+
changed: (plan.changed || []).length,
|
|
6876
|
+
conflict: (plan.conflict || []).length,
|
|
6877
|
+
removed: (plan.removed || []).length,
|
|
6878
|
+
})),
|
|
6879
|
+
plan.truncated ? h('div', { className: 'rw-dialog-message rw-warn-text' }, t('syncTruncated', { max: plan.maxFiles })) : null,
|
|
6880
|
+
plan.skipped ? h('div', { className: 'rw-dialog-message' }, t('syncSkipped', { count: plan.skipped })) : null,
|
|
6881
|
+
rows.length === 0
|
|
6882
|
+
? h('div', { className: 'rw-dialog-message' }, t('syncNothing'))
|
|
6883
|
+
: h('div', { className: 'rw-sync-list' }, rows.slice(0, 40).map(function (row) {
|
|
6884
|
+
return h('div', { key: row.tag + row.item.relative, className: 'rw-sync-row' },
|
|
6885
|
+
h('span', { className: 'rw-sync-tag' }, row.tag),
|
|
6886
|
+
h('span', { className: 'rw-sync-path', title: row.item.relative }, row.item.relative));
|
|
6887
|
+
})),
|
|
6888
|
+
rows.length > 40 ? h('div', { className: 'rw-dialog-message' }, t('syncMore', { count: rows.length - 40 })) : null,
|
|
6889
|
+
props.message ? h('div', { className: 'rw-dialog-message' }, props.message) : null,
|
|
6890
|
+
h('div', { className: 'rw-dialog-actions' },
|
|
6891
|
+
h('button', { type: 'button', className: 'rw-btn rw-btn-sm', disabled: busy, onClick: props.onClose }, t('cancel')),
|
|
6892
|
+
h('button', {
|
|
6893
|
+
type: 'button',
|
|
6894
|
+
className: 'rw-btn rw-btn-sm',
|
|
6895
|
+
disabled: busy || plan.pending === 0,
|
|
6896
|
+
onClick: function () { props.onPush('skip'); },
|
|
6897
|
+
}, t('syncPushSkip')),
|
|
6898
|
+
h('button', {
|
|
6899
|
+
type: 'button',
|
|
6900
|
+
className: 'rw-btn rw-btn-sm rw-btn-primary',
|
|
6901
|
+
disabled: busy,
|
|
6902
|
+
onClick: function () { props.onPush('overwrite'); },
|
|
6903
|
+
}, t('syncPushOverwrite'))));
|
|
6904
|
+
}
|
|
6905
|
+
|
|
6766
6906
|
function QueueDialog(props) {
|
|
6767
6907
|
var history = props.history && props.history.length > 0 ? props.history : null;
|
|
6768
6908
|
return h(DialogShell, { title: props.title, onClose: props.onClose },
|
|
@@ -7931,6 +8071,40 @@ function rememberShowHidden(value) {
|
|
|
7931
8071
|
});
|
|
7932
8072
|
}
|
|
7933
8073
|
|
|
8074
|
+
/** Open the diff preview for the whole workspace (or the given paths). */
|
|
8075
|
+
function openSyncPlan(paths) {
|
|
8076
|
+
var scope = sourceScopeOf(selected);
|
|
8077
|
+
if (!scope || scope.kind !== 'linked') return;
|
|
8078
|
+
apiCall('linked.plan', { id: scope.id, maxFiles: 2000 }).then(function (plan) {
|
|
8079
|
+
setDialog({
|
|
8080
|
+
kind: 'syncPlan',
|
|
8081
|
+
plan: plan,
|
|
8082
|
+
paths: Array.isArray(paths) && paths.length > 0 ? paths : null,
|
|
8083
|
+
busy: false,
|
|
8084
|
+
message: '',
|
|
8085
|
+
});
|
|
8086
|
+
}).catch(noticeError);
|
|
8087
|
+
}
|
|
8088
|
+
|
|
8089
|
+
/** Push the planned files back to the remote directory. */
|
|
8090
|
+
function pushPlan(plan, conflict, paths) {
|
|
8091
|
+
var scope = sourceScopeOf(selected);
|
|
8092
|
+
if (!scope || scope.kind !== 'linked') return;
|
|
8093
|
+
setDialog({ kind: 'syncPlan', plan: plan, paths: paths || null, busy: true, message: t('syncPushing') });
|
|
8094
|
+
var jobId = 'push-' + Date.now() + '-' + Math.random().toString(36).slice(2, 8);
|
|
8095
|
+
var params = { id: scope.id, conflict: conflict, jobId: jobId };
|
|
8096
|
+
if (Array.isArray(paths) && paths.length > 0) params.paths = paths;
|
|
8097
|
+
apiCall('linked.push', params).then(function (result) {
|
|
8098
|
+
setDialog(null);
|
|
8099
|
+
var text = t('syncPushed', { pushed: result.pushed, skipped: result.skipped });
|
|
8100
|
+
if (result.conflictsLeft > 0) text += ' · ' + t('syncConflictLeft', { count: result.conflictsLeft });
|
|
8101
|
+
showNotice(result.pushed > 0 ? 'success' : 'warn', text);
|
|
8102
|
+
refreshTree();
|
|
8103
|
+
}).catch(function (error) {
|
|
8104
|
+
setDialog({ kind: 'syncPlan', plan: plan, paths: paths || null, busy: false, message: messageOf(error, t, locale) });
|
|
8105
|
+
});
|
|
8106
|
+
}
|
|
8107
|
+
|
|
7934
8108
|
function editNotepad(side, filePath) {
|
|
7935
8109
|
var method = side === 'remote' ? 'fs.edit' : 'local.edit';
|
|
7936
8110
|
var params = side === 'remote'
|
|
@@ -8366,6 +8540,15 @@ function rememberShowHidden(value) {
|
|
|
8366
8540
|
if (menu.side === 'remote' && menu.isDir) {
|
|
8367
8541
|
items.push({ label: t('ctxCopySsh'), onSelect: function () { copySshCommand(menu.path); } });
|
|
8368
8542
|
}
|
|
8543
|
+
if (selected.kind === 'linked' && menu.side === 'remote') {
|
|
8544
|
+
var remoteRoot = selected.remotePath;
|
|
8545
|
+
var relativePath = menu.path.indexOf(remoteRoot) === 0
|
|
8546
|
+
? menu.path.slice(remoteRoot.length).replace(/^\/+/, '')
|
|
8547
|
+
: '';
|
|
8548
|
+
if (relativePath !== '') {
|
|
8549
|
+
items.push({ label: t('ctxPushThis'), onSelect: function () { openSyncPlan([relativePath]); } });
|
|
8550
|
+
}
|
|
8551
|
+
}
|
|
8369
8552
|
items.push({ separator: true });
|
|
8370
8553
|
var rootPath = menu.side === 'remote' ? selected.remotePath : selected.localPath;
|
|
8371
8554
|
if (menu.path !== rootPath) {
|
|
@@ -8511,6 +8694,16 @@ function rememberShowHidden(value) {
|
|
|
8511
8694
|
onPick: function (targetDir) { moveEntries(dialog.side, moveTargets, targetDir); },
|
|
8512
8695
|
});
|
|
8513
8696
|
}
|
|
8697
|
+
if (dialog.kind === 'syncPlan') {
|
|
8698
|
+
return h(SyncPlanDialog, {
|
|
8699
|
+
t: t,
|
|
8700
|
+
plan: dialog.plan,
|
|
8701
|
+
busy: Boolean(dialog.busy),
|
|
8702
|
+
message: dialog.message,
|
|
8703
|
+
onClose: function () { if (!dialog.busy) setDialog(null); },
|
|
8704
|
+
onPush: function (conflict) { return pushPlan(dialog.plan, conflict, dialog.paths); },
|
|
8705
|
+
});
|
|
8706
|
+
}
|
|
8514
8707
|
if (dialog.kind === 'renameMany') {
|
|
8515
8708
|
return h(BatchRenameDialog, {
|
|
8516
8709
|
t: t,
|
|
@@ -8840,6 +9033,9 @@ function rememberShowHidden(value) {
|
|
|
8840
9033
|
onToggleSearch: function () { setSearchOpen(!searchOpen); },
|
|
8841
9034
|
onOpenMode: updateOpenMode,
|
|
8842
9035
|
onRefresh: refreshAll,
|
|
9036
|
+
syncEnabled: selected.kind === 'linked',
|
|
9037
|
+
syncTitle: selected.kind === 'linked' ? t('syncTitle') : t('syncNeedsLinked'),
|
|
9038
|
+
onSync: function () { openSyncPlan(null); },
|
|
8843
9039
|
}),
|
|
8844
9040
|
searchOpen
|
|
8845
9041
|
? h('div', { className: 'rw-searchbar' },
|
|
@@ -10772,6 +10968,297 @@ function rememberShowHidden(value) {
|
|
|
10772
10968
|
return h('div', { className: 'rw-group' }, children);
|
|
10773
10969
|
}
|
|
10774
10970
|
|
|
10971
|
+
function AutoPushSettingsGroup(props) {
|
|
10972
|
+
var t = props.t;
|
|
10973
|
+
var locale = props.locale;
|
|
10974
|
+
var localState = useState({ loading: true, saving: false, message: null, asking: false });
|
|
10975
|
+
var local = localState[0];
|
|
10976
|
+
var setLocal = localState[1];
|
|
10977
|
+
var valuesState = useState({
|
|
10978
|
+
autoPushEnabled: false,
|
|
10979
|
+
autoPushDebounceMs: 1500,
|
|
10980
|
+
autoPushInclude: '',
|
|
10981
|
+
autoPushExclude: '',
|
|
10982
|
+
});
|
|
10983
|
+
var values = valuesState[0];
|
|
10984
|
+
var setValues = valuesState[1];
|
|
10985
|
+
|
|
10986
|
+
useEffect(function () {
|
|
10987
|
+
var alive = true;
|
|
10988
|
+
apiCall('settings.get', {}).then(function (settings) {
|
|
10989
|
+
if (!alive) return;
|
|
10990
|
+
setValues({
|
|
10991
|
+
autoPushEnabled: settings.autoPushEnabled === true,
|
|
10992
|
+
autoPushDebounceMs: Number(settings.autoPushDebounceMs) || 1500,
|
|
10993
|
+
autoPushInclude: (settings.autoPushInclude || []).join('\n'),
|
|
10994
|
+
autoPushExclude: (settings.autoPushExclude || []).join('\n'),
|
|
10995
|
+
});
|
|
10996
|
+
setLocal(function (previous) { return Object.assign({}, previous, { loading: false }); });
|
|
10997
|
+
}).catch(function () {
|
|
10998
|
+
if (alive) setLocal(function (previous) { return Object.assign({}, previous, { loading: false }); });
|
|
10999
|
+
});
|
|
11000
|
+
return function () { alive = false; };
|
|
11001
|
+
}, []);
|
|
11002
|
+
|
|
11003
|
+
function save(patch, okText) {
|
|
11004
|
+
setLocal(function (previous) { return Object.assign({}, previous, { saving: true, message: null }); });
|
|
11005
|
+
apiCall('settings.update', patch).then(function (settings) {
|
|
11006
|
+
setValues({
|
|
11007
|
+
autoPushEnabled: settings.autoPushEnabled === true,
|
|
11008
|
+
autoPushDebounceMs: Number(settings.autoPushDebounceMs) || 1500,
|
|
11009
|
+
autoPushInclude: (settings.autoPushInclude || []).join('\n'),
|
|
11010
|
+
autoPushExclude: (settings.autoPushExclude || []).join('\n'),
|
|
11011
|
+
});
|
|
11012
|
+
setLocal({ loading: false, saving: false, asking: false, message: { kind: 'success', text: okText } });
|
|
11013
|
+
}).catch(function (error) {
|
|
11014
|
+
setLocal({
|
|
11015
|
+
loading: false,
|
|
11016
|
+
saving: false,
|
|
11017
|
+
asking: false,
|
|
11018
|
+
message: { kind: 'error', text: messageOf(error, t, locale) },
|
|
11019
|
+
});
|
|
11020
|
+
});
|
|
11021
|
+
}
|
|
11022
|
+
|
|
11023
|
+
function toggle(next) {
|
|
11024
|
+
if (next === true && values.autoPushEnabled === false) {
|
|
11025
|
+
// Turning it on writes files behind the user's back: ask once, in
|
|
11026
|
+
// place, before the switch actually flips.
|
|
11027
|
+
setLocal(function (previous) { return Object.assign({}, previous, { asking: true, message: null }); });
|
|
11028
|
+
return;
|
|
11029
|
+
}
|
|
11030
|
+
save({ autoPushEnabled: Boolean(next) }, t('autoPushSaved'));
|
|
11031
|
+
}
|
|
11032
|
+
|
|
11033
|
+
function commitList(field, key) {
|
|
11034
|
+
var lines = String(values[field] || '').split('\n').map(function (line) { return line.trim(); }).filter(function (line) { return line !== ''; });
|
|
11035
|
+
var patch = {};
|
|
11036
|
+
patch[key] = lines;
|
|
11037
|
+
save(patch, t('autoPushSaved'));
|
|
11038
|
+
}
|
|
11039
|
+
|
|
11040
|
+
var children = [
|
|
11041
|
+
h('div', { className: 'rw-group-head' },
|
|
11042
|
+
h('span', { className: 'rw-group-title' }, t('autoPushTitle'))),
|
|
11043
|
+
h('div', { className: 'rw-setting-row' },
|
|
11044
|
+
h(Switch, {
|
|
11045
|
+
checked: values.autoPushEnabled,
|
|
11046
|
+
onChange: toggle,
|
|
11047
|
+
label: t('autoPushLabel'),
|
|
11048
|
+
text: t('autoPushLabel'),
|
|
11049
|
+
}),
|
|
11050
|
+
local.saving ? Spinner(12) : null),
|
|
11051
|
+
];
|
|
11052
|
+
|
|
11053
|
+
if (local.asking && !values.autoPushEnabled) {
|
|
11054
|
+
children.push(h('div', { className: 'rw-group-hint', style: { marginTop: 8, color: 'rgb(210,153,34)' } }, t('autoPushWarn')));
|
|
11055
|
+
children.push(h('div', { className: 'rw-dialog-actions', style: { marginTop: 10 } },
|
|
11056
|
+
h('button', {
|
|
11057
|
+
type: 'button',
|
|
11058
|
+
className: 'rw-btn rw-btn-sm',
|
|
11059
|
+
onClick: function () { setLocal(function (previous) { return Object.assign({}, previous, { asking: false }); }); },
|
|
11060
|
+
}, t('autoPushCancel')),
|
|
11061
|
+
h('button', {
|
|
11062
|
+
type: 'button',
|
|
11063
|
+
className: 'rw-btn rw-btn-sm rw-btn-primary',
|
|
11064
|
+
onClick: function () { save({ autoPushEnabled: true }, t('autoPushSaved')); },
|
|
11065
|
+
}, t('autoPushConfirm'))));
|
|
11066
|
+
}
|
|
11067
|
+
|
|
11068
|
+
if (values.autoPushEnabled) {
|
|
11069
|
+
children.push(h('div', { className: 'rw-group-hint', style: { marginTop: 8 } }, t('autoPushWarn')));
|
|
11070
|
+
children.push(h('div', { className: 'rw-group-head', style: { marginTop: 12 } },
|
|
11071
|
+
h('span', { className: 'rw-group-title' }, t('autoPushIncludeLabel'))));
|
|
11072
|
+
children.push(h('textarea', {
|
|
11073
|
+
className: 'rw-input rw-input-mono rw-autopush-list',
|
|
11074
|
+
rows: 3,
|
|
11075
|
+
value: values.autoPushInclude,
|
|
11076
|
+
placeholder: 'src/**\ndocs/*.md',
|
|
11077
|
+
onChange: function (event) {
|
|
11078
|
+
var value = event.currentTarget.value;
|
|
11079
|
+
setValues(function (previous) { return Object.assign({}, previous, { autoPushInclude: value }); });
|
|
11080
|
+
},
|
|
11081
|
+
onBlur: function () { commitList('autoPushInclude', 'autoPushInclude'); },
|
|
11082
|
+
}));
|
|
11083
|
+
children.push(h('div', { className: 'rw-group-head', style: { marginTop: 12 } },
|
|
11084
|
+
h('span', { className: 'rw-group-title' }, t('autoPushExcludeLabel'))));
|
|
11085
|
+
children.push(h('textarea', {
|
|
11086
|
+
className: 'rw-input rw-input-mono rw-autopush-list',
|
|
11087
|
+
rows: 3,
|
|
11088
|
+
value: values.autoPushExclude,
|
|
11089
|
+
placeholder: '*.log\n.remote/**',
|
|
11090
|
+
onChange: function (event) {
|
|
11091
|
+
var value = event.currentTarget.value;
|
|
11092
|
+
setValues(function (previous) { return Object.assign({}, previous, { autoPushExclude: value }); });
|
|
11093
|
+
},
|
|
11094
|
+
onBlur: function () { commitList('autoPushExclude', 'autoPushExclude'); },
|
|
11095
|
+
}));
|
|
11096
|
+
children.push(h('div', { className: 'rw-inline', style: { marginTop: 12, flexWrap: 'wrap', gap: 12 } },
|
|
11097
|
+
h('span', { className: 'rw-setting-label' }, t('autoPushDebounceLabel')),
|
|
11098
|
+
h('input', {
|
|
11099
|
+
className: 'rw-input rw-input-num',
|
|
11100
|
+
type: 'number',
|
|
11101
|
+
min: 300,
|
|
11102
|
+
max: 60000,
|
|
11103
|
+
step: 100,
|
|
11104
|
+
value: values.autoPushDebounceMs,
|
|
11105
|
+
onChange: function (event) {
|
|
11106
|
+
var value = event.currentTarget.value;
|
|
11107
|
+
setValues(function (previous) { return Object.assign({}, previous, { autoPushDebounceMs: value }); });
|
|
11108
|
+
},
|
|
11109
|
+
onBlur: function () {
|
|
11110
|
+
var ms = Math.round(Number(values.autoPushDebounceMs) || 1500);
|
|
11111
|
+
save({ autoPushDebounceMs: ms }, t('autoPushSaved'));
|
|
11112
|
+
},
|
|
11113
|
+
})));
|
|
11114
|
+
}
|
|
11115
|
+
|
|
11116
|
+
if (local.message) {
|
|
11117
|
+
children.push(h(Banner, {
|
|
11118
|
+
kind: local.message.kind === 'success' ? 'success' : 'error',
|
|
11119
|
+
onClose: function () {
|
|
11120
|
+
setLocal(function (previous) { return Object.assign({}, previous, { message: null }); });
|
|
11121
|
+
},
|
|
11122
|
+
}, local.message.text));
|
|
11123
|
+
}
|
|
11124
|
+
|
|
11125
|
+
return h('div', { className: 'rw-group' }, children);
|
|
11126
|
+
}
|
|
11127
|
+
|
|
11128
|
+
/**
|
|
11129
|
+
* Host key trust and command-output encoding (0.20.0).
|
|
11130
|
+
*
|
|
11131
|
+
* Before this, a changed host key could only be cleared by hand-editing
|
|
11132
|
+
* `known_hosts.json`, and a Windows shell's GBK output arrived as mojibake.
|
|
11133
|
+
*/
|
|
11134
|
+
function SshTrustSettingsGroup(props) {
|
|
11135
|
+
var t = props.t;
|
|
11136
|
+
var locale = props.locale;
|
|
11137
|
+
var localState = useState({ loading: true, saving: false, message: null });
|
|
11138
|
+
var local = localState[0];
|
|
11139
|
+
var setLocal = localState[1];
|
|
11140
|
+
var valuesState = useState({ hostKeyPolicy: 'tofu', outputEncoding: 'utf8' });
|
|
11141
|
+
var values = valuesState[0];
|
|
11142
|
+
var setValues = valuesState[1];
|
|
11143
|
+
var keysState = useState([]);
|
|
11144
|
+
var keys = keysState[0];
|
|
11145
|
+
var setKeys = keysState[1];
|
|
11146
|
+
|
|
11147
|
+
function refreshKeys() {
|
|
11148
|
+
apiCall('hosts.hostKeys', {}).then(function (result) {
|
|
11149
|
+
setKeys(Array.isArray(result.entries) ? result.entries : []);
|
|
11150
|
+
}).catch(function () {
|
|
11151
|
+
setKeys([]);
|
|
11152
|
+
});
|
|
11153
|
+
}
|
|
11154
|
+
|
|
11155
|
+
useEffect(function () {
|
|
11156
|
+
var alive = true;
|
|
11157
|
+
apiCall('settings.get', {}).then(function (settings) {
|
|
11158
|
+
if (!alive) return;
|
|
11159
|
+
setValues({
|
|
11160
|
+
hostKeyPolicy: settings.hostKeyPolicy === 'strict' ? 'strict' : 'tofu',
|
|
11161
|
+
outputEncoding: settings.outputEncoding === 'gbk' ? 'gbk' : 'utf8',
|
|
11162
|
+
});
|
|
11163
|
+
setLocal(function (previous) { return Object.assign({}, previous, { loading: false }); });
|
|
11164
|
+
}).catch(function () {
|
|
11165
|
+
if (alive) setLocal(function (previous) { return Object.assign({}, previous, { loading: false }); });
|
|
11166
|
+
});
|
|
11167
|
+
refreshKeys();
|
|
11168
|
+
return function () { alive = false; };
|
|
11169
|
+
}, []);
|
|
11170
|
+
|
|
11171
|
+
function save(patch, okText) {
|
|
11172
|
+
setLocal(function (previous) { return Object.assign({}, previous, { saving: true, message: null }); });
|
|
11173
|
+
apiCall('settings.update', patch).then(function (settings) {
|
|
11174
|
+
setValues({
|
|
11175
|
+
hostKeyPolicy: settings.hostKeyPolicy === 'strict' ? 'strict' : 'tofu',
|
|
11176
|
+
outputEncoding: settings.outputEncoding === 'gbk' ? 'gbk' : 'utf8',
|
|
11177
|
+
});
|
|
11178
|
+
setLocal({ loading: false, saving: false, message: { kind: 'success', text: okText } });
|
|
11179
|
+
}).catch(function (error) {
|
|
11180
|
+
setLocal({ loading: false, saving: false, message: { kind: 'error', text: messageOf(error, t, locale) } });
|
|
11181
|
+
});
|
|
11182
|
+
}
|
|
11183
|
+
|
|
11184
|
+
function forget(entry) {
|
|
11185
|
+
var params = entry.hostId ? { hostId: entry.hostId } : { authority: entry.authority };
|
|
11186
|
+
setLocal(function (previous) { return Object.assign({}, previous, { saving: true, message: null }); });
|
|
11187
|
+
apiCall('hosts.forgetHostKey', params).then(function () {
|
|
11188
|
+
setLocal({
|
|
11189
|
+
loading: false,
|
|
11190
|
+
saving: false,
|
|
11191
|
+
message: { kind: 'success', text: t('forgotHostKey', { authority: entry.authority }) },
|
|
11192
|
+
});
|
|
11193
|
+
refreshKeys();
|
|
11194
|
+
}).catch(function (error) {
|
|
11195
|
+
setLocal({ loading: false, saving: false, message: { kind: 'error', text: messageOf(error, t, locale) } });
|
|
11196
|
+
});
|
|
11197
|
+
}
|
|
11198
|
+
|
|
11199
|
+
var children = [
|
|
11200
|
+
h('div', { className: 'rw-group-head' },
|
|
11201
|
+
h('span', { className: 'rw-group-title' }, t('sshTrustTitle')),
|
|
11202
|
+
local.saving ? Spinner(12) : null),
|
|
11203
|
+
h('div', { className: 'rw-group-hint' }, t('sshTrustHint')),
|
|
11204
|
+
h('div', { className: 'rw-inline', style: { marginTop: 10, flexWrap: 'wrap', gap: 12 } },
|
|
11205
|
+
h('span', { className: 'rw-setting-label' }, t('hostKeyPolicyLabel')),
|
|
11206
|
+
h('select', {
|
|
11207
|
+
className: 'rw-input',
|
|
11208
|
+
value: values.hostKeyPolicy,
|
|
11209
|
+
onChange: function (event) {
|
|
11210
|
+
var next = event.currentTarget.value;
|
|
11211
|
+
setValues(function (previous) { return Object.assign({}, previous, { hostKeyPolicy: next }); });
|
|
11212
|
+
save({ hostKeyPolicy: next }, t('sshTrustSaved'));
|
|
11213
|
+
},
|
|
11214
|
+
},
|
|
11215
|
+
h('option', { value: 'tofu' }, t('hostKeyPolicyTofu')),
|
|
11216
|
+
h('option', { value: 'strict' }, t('hostKeyPolicyStrict')))),
|
|
11217
|
+
h('div', { className: 'rw-inline', style: { marginTop: 10, flexWrap: 'wrap', gap: 12 } },
|
|
11218
|
+
h('span', { className: 'rw-setting-label' }, t('outputEncodingLabel')),
|
|
11219
|
+
h('select', {
|
|
11220
|
+
className: 'rw-input',
|
|
11221
|
+
value: values.outputEncoding,
|
|
11222
|
+
onChange: function (event) {
|
|
11223
|
+
var next = event.currentTarget.value;
|
|
11224
|
+
setValues(function (previous) { return Object.assign({}, previous, { outputEncoding: next }); });
|
|
11225
|
+
save({ outputEncoding: next }, t('sshTrustSaved'));
|
|
11226
|
+
},
|
|
11227
|
+
},
|
|
11228
|
+
h('option', { value: 'utf8' }, t('outputEncodingUtf8')),
|
|
11229
|
+
h('option', { value: 'gbk' }, t('outputEncodingGbk')))),
|
|
11230
|
+
h('div', { className: 'rw-group-head', style: { marginTop: 14 } },
|
|
11231
|
+
h('span', { className: 'rw-group-title' }, t('knownKeysTitle'))),
|
|
11232
|
+
];
|
|
11233
|
+
|
|
11234
|
+
if (keys.length === 0) {
|
|
11235
|
+
children.push(h('div', { className: 'rw-group-hint' }, t('knownKeysEmpty')));
|
|
11236
|
+
} else {
|
|
11237
|
+
children.push(h('div', { className: 'rw-known-keys' }, keys.map(function (entry) {
|
|
11238
|
+
return h('div', { className: 'rw-known-key', key: entry.authority },
|
|
11239
|
+
h('div', { className: 'rw-known-key-main' },
|
|
11240
|
+
h('span', { className: 'rw-known-key-host' }, entry.hostName ? entry.hostName + ' · ' + entry.authority : entry.authority),
|
|
11241
|
+
h('span', { className: 'rw-known-key-fp', title: entry.fingerprint }, entry.fingerprint)),
|
|
11242
|
+
h('button', {
|
|
11243
|
+
type: 'button',
|
|
11244
|
+
className: 'rw-btn rw-btn-sm',
|
|
11245
|
+
onClick: function () { forget(entry); },
|
|
11246
|
+
}, t('forgetHostKey')));
|
|
11247
|
+
})));
|
|
11248
|
+
}
|
|
11249
|
+
|
|
11250
|
+
if (local.message) {
|
|
11251
|
+
children.push(h(Banner, {
|
|
11252
|
+
kind: local.message.kind === 'success' ? 'success' : 'error',
|
|
11253
|
+
onClose: function () {
|
|
11254
|
+
setLocal(function (previous) { return Object.assign({}, previous, { message: null }); });
|
|
11255
|
+
},
|
|
11256
|
+
}, local.message.text));
|
|
11257
|
+
}
|
|
11258
|
+
|
|
11259
|
+
return h('div', { className: 'rw-group' }, children);
|
|
11260
|
+
}
|
|
11261
|
+
|
|
10775
11262
|
function ConnectionsPage(props) {
|
|
10776
11263
|
var ctx = props.ctx;
|
|
10777
11264
|
var locale = useLocale(ctx);
|
|
@@ -10838,6 +11325,8 @@ function rememberShowHidden(value) {
|
|
|
10838
11325
|
hosts: remote.data.hosts || [],
|
|
10839
11326
|
workspaces: links.concat(remotes),
|
|
10840
11327
|
}),
|
|
11328
|
+
h(AutoPushSettingsGroup, { t: t, locale: locale }),
|
|
11329
|
+
h(SshTrustSettingsGroup, { t: t, locale: locale }),
|
|
10841
11330
|
adding === 'linked'
|
|
10842
11331
|
? h(AddWorkspaceFlow, {
|
|
10843
11332
|
ctx: ctx, t: t, locale: locale,
|