dsh-linked-workspace 0.17.0 → 0.19.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 +18 -0
- package/README.en.md +13 -0
- package/README.md +13 -0
- package/docs/API.md +16 -4
- package/docs/VERIFY.md +20 -0
- package/lib/client.js +421 -3
- package/lib/index.js +810 -37
- 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,32 @@ function attributeViolation(name, value, tagName) {
|
|
|
2494
2501
|
autoSaveHint: '编辑停顿约 1 秒后自动保存;关闭后请按 Ctrl+S 手动保存。',
|
|
2495
2502
|
autoSaveLabel: '开启自动保存',
|
|
2496
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: '自动推送设置已保存',
|
|
2497
2530
|
execTitle: '远端命令执行',
|
|
2498
2531
|
execHint: '默认关闭。开启后,会话里的模型可以通过 linked_workspace 的 exec 动作在远端跑命令;只对下面勾选的主机/工作区生效,每次尝试(含被拒)都记进审计日志。',
|
|
2499
2532
|
execEnabledLabel: '允许在远端执行命令',
|
|
@@ -2758,6 +2791,13 @@ function attributeViolation(name, value, tagName) {
|
|
|
2758
2791
|
searchRegex: 'Regular expression',
|
|
2759
2792
|
searchScopeAll: 'Whole workspace',
|
|
2760
2793
|
searchScopeHere: 'Current folder only',
|
|
2794
|
+
searchIncludeIgnored: 'Also search usually ignored folders (.git stays out)',
|
|
2795
|
+
searchFilesOnly: 'List file names only (no matching lines)',
|
|
2796
|
+
searchStop: 'Stop',
|
|
2797
|
+
searchStats: 'Scanned {{files}} files · {{size}}',
|
|
2798
|
+
searchStatsSkipped: '{{count}} skipped',
|
|
2799
|
+
ctxCopyReference: 'Copy as @ reference',
|
|
2800
|
+
referenceCopied: 'Copied {{reference}}',
|
|
2761
2801
|
searchScopeLabel: 'Scope: {{scope}}',
|
|
2762
2802
|
findPlaceholder: 'Find…',
|
|
2763
2803
|
replacePlaceholder: 'Replace with…',
|
|
@@ -2985,6 +3025,32 @@ function attributeViolation(name, value, tagName) {
|
|
|
2985
3025
|
autoSaveHint: 'Saves about one second after you stop typing. When off, press Ctrl+S to save.',
|
|
2986
3026
|
autoSaveLabel: 'Enable auto save',
|
|
2987
3027
|
autoSaveSaved: 'Auto-save setting saved',
|
|
3028
|
+
syncTitle: 'Push local changes back to the remote side',
|
|
3029
|
+
syncNeedsLinked: 'Only a linked workspace has a local directory to push',
|
|
3030
|
+
syncSummary: 'added {{added}} · changed {{changed}} · conflict {{conflict}} · gone upstream {{removed}}',
|
|
3031
|
+
syncNothing: 'Local and remote agree; nothing to push.',
|
|
3032
|
+
syncTruncated: 'Too many files; only the first {{max}} were compared. Tidy up or push in batches.',
|
|
3033
|
+
syncSkipped: '{{count}} skipped (too large or unreadable).',
|
|
3034
|
+
syncAdded: 'added',
|
|
3035
|
+
syncChanged: 'changed',
|
|
3036
|
+
syncConflict: 'conflict',
|
|
3037
|
+
syncRemoved: 'gone upstream',
|
|
3038
|
+
syncMore: '{{count}} more not listed…',
|
|
3039
|
+
syncPushSkip: 'Push (skip conflicts)',
|
|
3040
|
+
syncPushOverwrite: 'Push and overwrite conflicts',
|
|
3041
|
+
syncPushing: 'Pushing…',
|
|
3042
|
+
syncPushed: 'Pushed {{pushed}} file(s)',
|
|
3043
|
+
syncConflictLeft: '{{count}} conflict(s) left',
|
|
3044
|
+
ctxPushThis: 'Push this to the remote side',
|
|
3045
|
+
autoPushTitle: 'Push back automatically',
|
|
3046
|
+
autoPushLabel: 'Enable automatic push',
|
|
3047
|
+
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).',
|
|
3048
|
+
autoPushConfirm: 'I understand, enable it',
|
|
3049
|
+
autoPushCancel: 'Not now',
|
|
3050
|
+
autoPushIncludeLabel: 'Only push these paths (one per line, * allowed)',
|
|
3051
|
+
autoPushExcludeLabel: 'Never push these paths (one per line, * allowed)',
|
|
3052
|
+
autoPushDebounceLabel: 'Wait after editing stops (ms)',
|
|
3053
|
+
autoPushSaved: 'Automatic push settings saved',
|
|
2988
3054
|
execTitle: 'Remote command execution',
|
|
2989
3055
|
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.',
|
|
2990
3056
|
execEnabledLabel: 'Allow running commands remotely',
|
|
@@ -3189,7 +3255,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
3189
3255
|
* Host methods the running DSH process does not have yet, the directory
|
|
3190
3256
|
* pane says so instead of surfacing an unrelated error.
|
|
3191
3257
|
*/
|
|
3192
|
-
var HOST_API_REVISION =
|
|
3258
|
+
var HOST_API_REVISION = 5;
|
|
3193
3259
|
var hostInfoProbe = null;
|
|
3194
3260
|
|
|
3195
3261
|
function probeHostInfo() {
|
|
@@ -3668,6 +3734,11 @@ function attributeViolation(name, value, tagName) {
|
|
|
3668
3734
|
'.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}',
|
|
3669
3735
|
'.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)}',
|
|
3670
3736
|
'.rw-exec-list{display:flex;flex-direction:column;gap:4px;margin-top:8px}',
|
|
3737
|
+
'.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)}',
|
|
3738
|
+
'.rw-sync-row{display:flex;align-items:center;gap:8px;font-size:12px;line-height:20px}',
|
|
3739
|
+
'.rw-sync-tag{flex:none;min-width:52px;color:rgb(150,150,152)}',
|
|
3740
|
+
'.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)}',
|
|
3741
|
+
'.rw-autopush-list{width:100%;resize:vertical;font-family:var(--dsw-font-mono,monospace);font-size:12px}',
|
|
3671
3742
|
'.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}',
|
|
3672
3743
|
'.rw-exec-item input[type=checkbox]{margin:0;flex:none}',
|
|
3673
3744
|
'.rw-exec-name{flex:1 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}',
|
|
@@ -3718,6 +3789,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
3718
3789
|
'.rw-disk{flex:none;font-size:11px;color:var(--dsw-alias-label-secondary,#8b949e);font-variant-numeric:tabular-nums}',
|
|
3719
3790
|
'.rw-search-history{display:flex;align-items:center;gap:6px;flex-wrap:wrap;padding:4px 8px 6px}',
|
|
3720
3791
|
'.rw-search-history-label{font-size:11px;color:var(--dsw-alias-label-secondary,#8b949e);flex:none}',
|
|
3792
|
+
'.rw-search-stats{padding:2px 8px 4px;font-size:11px;color:var(--dsw-alias-label-secondary,#8b949e);font-variant-numeric:tabular-nums}',
|
|
3721
3793
|
'.rw-queue-history{margin-top:12px;border-top:1px solid var(--dsw-alias-border-l1,rgba(127,127,127,.28));padding-top:8px}',
|
|
3722
3794
|
'.rw-queue-history-title{font-size:11px;color:var(--dsw-alias-label-secondary,#8b949e);margin-bottom:4px}',
|
|
3723
3795
|
'.rw-queue-row.is-history .rw-queue-state{opacity:.75}',
|
|
@@ -6065,6 +6137,14 @@ function attributeViolation(name, value, tagName) {
|
|
|
6065
6137
|
style: props.transferEnabled ? undefined : { opacity: 0.42, cursor: 'default' },
|
|
6066
6138
|
onClick: props.transferSelected,
|
|
6067
6139
|
}, IconDownload(14)),
|
|
6140
|
+
h('button', {
|
|
6141
|
+
type: 'button',
|
|
6142
|
+
className: 'rw-icon-btn' + (props.syncBusy ? ' is-on' : ''),
|
|
6143
|
+
title: props.syncTitle || t('syncTitle'),
|
|
6144
|
+
disabled: !props.syncEnabled,
|
|
6145
|
+
style: props.syncEnabled ? undefined : { opacity: 0.42, cursor: 'default' },
|
|
6146
|
+
onClick: props.onSync,
|
|
6147
|
+
}, IconSync(14)),
|
|
6068
6148
|
h('button', {
|
|
6069
6149
|
type: 'button',
|
|
6070
6150
|
className: 'rw-icon-btn',
|
|
@@ -6748,6 +6828,50 @@ function rememberShowHidden(value) {
|
|
|
6748
6828
|
h('button', { type: 'button', className: 'rw-btn rw-btn-sm', onClick: props.onClose }, props.t('cancel'))));
|
|
6749
6829
|
}
|
|
6750
6830
|
|
|
6831
|
+
function SyncPlanDialog(props) {
|
|
6832
|
+
var t = props.t;
|
|
6833
|
+
var plan = props.plan;
|
|
6834
|
+
var rows = []
|
|
6835
|
+
.concat((plan.added || []).map(function (item) { return { tag: t('syncAdded'), item: item }; }))
|
|
6836
|
+
.concat((plan.changed || []).map(function (item) { return { tag: t('syncChanged'), item: item }; }))
|
|
6837
|
+
.concat((plan.conflict || []).map(function (item) { return { tag: t('syncConflict'), item: item }; }))
|
|
6838
|
+
.concat((plan.removed || []).map(function (item) { return { tag: t('syncRemoved'), item: item }; }));
|
|
6839
|
+
var busy = Boolean(props.busy);
|
|
6840
|
+
return h(DialogShell, { title: t('syncTitle'), onClose: busy ? function () {} : props.onClose },
|
|
6841
|
+
h('div', { className: 'rw-dialog-message' },
|
|
6842
|
+
t('syncSummary', {
|
|
6843
|
+
added: (plan.added || []).length,
|
|
6844
|
+
changed: (plan.changed || []).length,
|
|
6845
|
+
conflict: (plan.conflict || []).length,
|
|
6846
|
+
removed: (plan.removed || []).length,
|
|
6847
|
+
})),
|
|
6848
|
+
plan.truncated ? h('div', { className: 'rw-dialog-message rw-warn-text' }, t('syncTruncated', { max: plan.maxFiles })) : null,
|
|
6849
|
+
plan.skipped ? h('div', { className: 'rw-dialog-message' }, t('syncSkipped', { count: plan.skipped })) : null,
|
|
6850
|
+
rows.length === 0
|
|
6851
|
+
? h('div', { className: 'rw-dialog-message' }, t('syncNothing'))
|
|
6852
|
+
: h('div', { className: 'rw-sync-list' }, rows.slice(0, 40).map(function (row) {
|
|
6853
|
+
return h('div', { key: row.tag + row.item.relative, className: 'rw-sync-row' },
|
|
6854
|
+
h('span', { className: 'rw-sync-tag' }, row.tag),
|
|
6855
|
+
h('span', { className: 'rw-sync-path', title: row.item.relative }, row.item.relative));
|
|
6856
|
+
})),
|
|
6857
|
+
rows.length > 40 ? h('div', { className: 'rw-dialog-message' }, t('syncMore', { count: rows.length - 40 })) : null,
|
|
6858
|
+
props.message ? h('div', { className: 'rw-dialog-message' }, props.message) : null,
|
|
6859
|
+
h('div', { className: 'rw-dialog-actions' },
|
|
6860
|
+
h('button', { type: 'button', className: 'rw-btn rw-btn-sm', disabled: busy, onClick: props.onClose }, t('cancel')),
|
|
6861
|
+
h('button', {
|
|
6862
|
+
type: 'button',
|
|
6863
|
+
className: 'rw-btn rw-btn-sm',
|
|
6864
|
+
disabled: busy || plan.pending === 0,
|
|
6865
|
+
onClick: function () { props.onPush('skip'); },
|
|
6866
|
+
}, t('syncPushSkip')),
|
|
6867
|
+
h('button', {
|
|
6868
|
+
type: 'button',
|
|
6869
|
+
className: 'rw-btn rw-btn-sm rw-btn-primary',
|
|
6870
|
+
disabled: busy,
|
|
6871
|
+
onClick: function () { props.onPush('overwrite'); },
|
|
6872
|
+
}, t('syncPushOverwrite'))));
|
|
6873
|
+
}
|
|
6874
|
+
|
|
6751
6875
|
function QueueDialog(props) {
|
|
6752
6876
|
var history = props.history && props.history.length > 0 ? props.history : null;
|
|
6753
6877
|
return h(DialogShell, { title: props.title, onClose: props.onClose },
|
|
@@ -7200,6 +7324,16 @@ function rememberShowHidden(value) {
|
|
|
7200
7324
|
var searchHereState = useState(false);
|
|
7201
7325
|
var searchHere = searchHereState[0];
|
|
7202
7326
|
var setSearchHere = searchHereState[1];
|
|
7327
|
+
var searchIncludeIgnoredState = useState(false);
|
|
7328
|
+
var searchIncludeIgnored = searchIncludeIgnoredState[0];
|
|
7329
|
+
var setSearchIncludeIgnored = searchIncludeIgnoredState[1];
|
|
7330
|
+
var searchFilesOnlyState = useState(false);
|
|
7331
|
+
var searchFilesOnly = searchFilesOnlyState[0];
|
|
7332
|
+
var setSearchFilesOnly = searchFilesOnlyState[1];
|
|
7333
|
+
var searchStatsState = useState(null);
|
|
7334
|
+
var searchStats = searchStatsState[0];
|
|
7335
|
+
var setSearchStats = searchStatsState[1];
|
|
7336
|
+
var searchJobRef = useRef('');
|
|
7203
7337
|
var searchState = useState({ loading: false, remote: [], local: [], truncated: false, truncatedReason: '', error: null });
|
|
7204
7338
|
var search = searchState[0];
|
|
7205
7339
|
var setSearch = searchState[1];
|
|
@@ -7751,6 +7885,27 @@ function rememberShowHidden(value) {
|
|
|
7751
7885
|
} catch (error) { /* clipboard unavailable */ }
|
|
7752
7886
|
}
|
|
7753
7887
|
|
|
7888
|
+
/** Copy the `@relative/path` form the model understands for a workspace path. */
|
|
7889
|
+
function copyReference(filePath) {
|
|
7890
|
+
var scope = sourceScopeOf(selected);
|
|
7891
|
+
var root = selected && selected.kind === 'remote' ? selected.remotePath : (selected && selected.remotePath) || '';
|
|
7892
|
+
var relative = String(filePath || '');
|
|
7893
|
+
if (root && relative.indexOf(root) === 0) {
|
|
7894
|
+
relative = relative.slice(root.length);
|
|
7895
|
+
if (relative.charAt(0) !== '/') relative = '/' + relative;
|
|
7896
|
+
}
|
|
7897
|
+
var reference = '@' + relative.replace(/^\/+/, '');
|
|
7898
|
+
try {
|
|
7899
|
+
if (navigator.clipboard && navigator.clipboard.writeText) {
|
|
7900
|
+
navigator.clipboard.writeText(reference).then(function () {
|
|
7901
|
+
showNotice('success', t('referenceCopied', { reference: reference }));
|
|
7902
|
+
}).catch(function () {});
|
|
7903
|
+
return;
|
|
7904
|
+
}
|
|
7905
|
+
} catch (error) { /* clipboard unavailable */ }
|
|
7906
|
+
void scope
|
|
7907
|
+
}
|
|
7908
|
+
|
|
7754
7909
|
/** Copy a ready-made ssh command that lands in the given remote directory. */
|
|
7755
7910
|
function copySshCommand(dirPath) {
|
|
7756
7911
|
var source = selected || {};
|
|
@@ -7885,6 +8040,40 @@ function rememberShowHidden(value) {
|
|
|
7885
8040
|
});
|
|
7886
8041
|
}
|
|
7887
8042
|
|
|
8043
|
+
/** Open the diff preview for the whole workspace (or the given paths). */
|
|
8044
|
+
function openSyncPlan(paths) {
|
|
8045
|
+
var scope = sourceScopeOf(selected);
|
|
8046
|
+
if (!scope || scope.kind !== 'linked') return;
|
|
8047
|
+
apiCall('linked.plan', { id: scope.id, maxFiles: 2000 }).then(function (plan) {
|
|
8048
|
+
setDialog({
|
|
8049
|
+
kind: 'syncPlan',
|
|
8050
|
+
plan: plan,
|
|
8051
|
+
paths: Array.isArray(paths) && paths.length > 0 ? paths : null,
|
|
8052
|
+
busy: false,
|
|
8053
|
+
message: '',
|
|
8054
|
+
});
|
|
8055
|
+
}).catch(noticeError);
|
|
8056
|
+
}
|
|
8057
|
+
|
|
8058
|
+
/** Push the planned files back to the remote directory. */
|
|
8059
|
+
function pushPlan(plan, conflict, paths) {
|
|
8060
|
+
var scope = sourceScopeOf(selected);
|
|
8061
|
+
if (!scope || scope.kind !== 'linked') return;
|
|
8062
|
+
setDialog({ kind: 'syncPlan', plan: plan, paths: paths || null, busy: true, message: t('syncPushing') });
|
|
8063
|
+
var jobId = 'push-' + Date.now() + '-' + Math.random().toString(36).slice(2, 8);
|
|
8064
|
+
var params = { id: scope.id, conflict: conflict, jobId: jobId };
|
|
8065
|
+
if (Array.isArray(paths) && paths.length > 0) params.paths = paths;
|
|
8066
|
+
apiCall('linked.push', params).then(function (result) {
|
|
8067
|
+
setDialog(null);
|
|
8068
|
+
var text = t('syncPushed', { pushed: result.pushed, skipped: result.skipped });
|
|
8069
|
+
if (result.conflictsLeft > 0) text += ' · ' + t('syncConflictLeft', { count: result.conflictsLeft });
|
|
8070
|
+
showNotice(result.pushed > 0 ? 'success' : 'warn', text);
|
|
8071
|
+
refreshTree();
|
|
8072
|
+
}).catch(function (error) {
|
|
8073
|
+
setDialog({ kind: 'syncPlan', plan: plan, paths: paths || null, busy: false, message: messageOf(error, t, locale) });
|
|
8074
|
+
});
|
|
8075
|
+
}
|
|
8076
|
+
|
|
7888
8077
|
function editNotepad(side, filePath) {
|
|
7889
8078
|
var method = side === 'remote' ? 'fs.edit' : 'local.edit';
|
|
7890
8079
|
var params = side === 'remote'
|
|
@@ -8316,9 +8505,19 @@ function rememberShowHidden(value) {
|
|
|
8316
8505
|
items.push({ label: t('ctxPaste'), disabled: !canPaste, onSelect: function () { pasteEntry(menu); } });
|
|
8317
8506
|
items.push({ separator: true });
|
|
8318
8507
|
items.push({ label: t('ctxCopyPath'), onSelect: function () { copyPathToClipboard(menu.path); } });
|
|
8508
|
+
items.push({ label: t('ctxCopyReference'), onSelect: function () { copyReference(menu.path); } });
|
|
8319
8509
|
if (menu.side === 'remote' && menu.isDir) {
|
|
8320
8510
|
items.push({ label: t('ctxCopySsh'), onSelect: function () { copySshCommand(menu.path); } });
|
|
8321
8511
|
}
|
|
8512
|
+
if (selected.kind === 'linked' && menu.side === 'remote') {
|
|
8513
|
+
var remoteRoot = selected.remotePath;
|
|
8514
|
+
var relativePath = menu.path.indexOf(remoteRoot) === 0
|
|
8515
|
+
? menu.path.slice(remoteRoot.length).replace(/^\/+/, '')
|
|
8516
|
+
: '';
|
|
8517
|
+
if (relativePath !== '') {
|
|
8518
|
+
items.push({ label: t('ctxPushThis'), onSelect: function () { openSyncPlan([relativePath]); } });
|
|
8519
|
+
}
|
|
8520
|
+
}
|
|
8322
8521
|
items.push({ separator: true });
|
|
8323
8522
|
var rootPath = menu.side === 'remote' ? selected.remotePath : selected.localPath;
|
|
8324
8523
|
if (menu.path !== rootPath) {
|
|
@@ -8464,6 +8663,16 @@ function rememberShowHidden(value) {
|
|
|
8464
8663
|
onPick: function (targetDir) { moveEntries(dialog.side, moveTargets, targetDir); },
|
|
8465
8664
|
});
|
|
8466
8665
|
}
|
|
8666
|
+
if (dialog.kind === 'syncPlan') {
|
|
8667
|
+
return h(SyncPlanDialog, {
|
|
8668
|
+
t: t,
|
|
8669
|
+
plan: dialog.plan,
|
|
8670
|
+
busy: Boolean(dialog.busy),
|
|
8671
|
+
message: dialog.message,
|
|
8672
|
+
onClose: function () { if (!dialog.busy) setDialog(null); },
|
|
8673
|
+
onPush: function (conflict) { return pushPlan(dialog.plan, conflict, dialog.paths); },
|
|
8674
|
+
});
|
|
8675
|
+
}
|
|
8467
8676
|
if (dialog.kind === 'renameMany') {
|
|
8468
8677
|
return h(BatchRenameDialog, {
|
|
8469
8678
|
t: t,
|
|
@@ -8550,11 +8759,18 @@ function rememberShowHidden(value) {
|
|
|
8550
8759
|
var contentMode = searchMode === 'content';
|
|
8551
8760
|
var method = contentMode ? 'fs.grep' : 'fs.search';
|
|
8552
8761
|
var extra = { side: 'remote', query: query, maxResults: 200 };
|
|
8762
|
+
var jobId = '';
|
|
8553
8763
|
if (contentMode) {
|
|
8554
8764
|
// F3: narrow the sweep to the folder the user is standing in.
|
|
8555
8765
|
if (searchHere && searchRootPath !== '') extra.path = searchRootPath;
|
|
8556
8766
|
extra.ignoreCase = !searchCase;
|
|
8557
8767
|
extra.regex = searchRegex;
|
|
8768
|
+
extra.includeIgnored = searchIncludeIgnored;
|
|
8769
|
+
extra.resultMode = searchFilesOnly ? 'files' : 'lines';
|
|
8770
|
+
// One job id per sweep so 「停止」 can cancel it on the Host.
|
|
8771
|
+
jobId = 'grep-' + Date.now() + '-' + Math.random().toString(36).slice(2, 8);
|
|
8772
|
+
extra.jobId = jobId;
|
|
8773
|
+
searchJobRef.current = jobId;
|
|
8558
8774
|
}
|
|
8559
8775
|
var jobs = [apiCall(method, Object.assign(extra, scopeParams(scopeNow))).catch(function (error) {
|
|
8560
8776
|
return { ok: false, entries: [], error: messageOf(error, t, locale) };
|
|
@@ -8570,6 +8786,16 @@ function rememberShowHidden(value) {
|
|
|
8570
8786
|
}
|
|
8571
8787
|
Promise.all(jobs).then(function (results) {
|
|
8572
8788
|
if (!alive) return;
|
|
8789
|
+
if (contentMode && jobId !== '' && searchJobRef.current === jobId) searchJobRef.current = '';
|
|
8790
|
+
var stats = null;
|
|
8791
|
+
if (contentMode && results[0] && typeof results[0].scannedFiles === 'number') {
|
|
8792
|
+
stats = {
|
|
8793
|
+
files: (results[0].scannedFiles || 0) + ((results[1] && results[1].scannedFiles) || 0),
|
|
8794
|
+
bytes: (results[0].scannedBytes || 0) + ((results[1] && results[1].scannedBytes) || 0),
|
|
8795
|
+
skipped: (results[0].skippedFiles || 0) + ((results[1] && results[1].skippedFiles) || 0),
|
|
8796
|
+
};
|
|
8797
|
+
}
|
|
8798
|
+
if (contentMode) setSearchStats(stats);
|
|
8573
8799
|
setSearch({
|
|
8574
8800
|
loading: false,
|
|
8575
8801
|
remote: results[0] && results[0].entries ? results[0].entries : [],
|
|
@@ -8581,7 +8807,7 @@ function rememberShowHidden(value) {
|
|
|
8581
8807
|
});
|
|
8582
8808
|
}, 320);
|
|
8583
8809
|
return function () { alive = false; clearTimeout(timer); };
|
|
8584
|
-
}, [searchOpen, searchQuery, selectedKey, version, searchMode, searchCase, searchRegex, searchHere]);
|
|
8810
|
+
}, [searchOpen, searchQuery, selectedKey, version, searchMode, searchCase, searchRegex, searchHere, searchIncludeIgnored, searchFilesOnly]);
|
|
8585
8811
|
|
|
8586
8812
|
if (!selected) {
|
|
8587
8813
|
return h('div', { className: 'rw-workbench rw-workspace', ref: workbenchRef },
|
|
@@ -8776,6 +9002,9 @@ function rememberShowHidden(value) {
|
|
|
8776
9002
|
onToggleSearch: function () { setSearchOpen(!searchOpen); },
|
|
8777
9003
|
onOpenMode: updateOpenMode,
|
|
8778
9004
|
onRefresh: refreshAll,
|
|
9005
|
+
syncEnabled: selected.kind === 'linked',
|
|
9006
|
+
syncTitle: selected.kind === 'linked' ? t('syncTitle') : t('syncNeedsLinked'),
|
|
9007
|
+
onSync: function () { openSyncPlan(null); },
|
|
8779
9008
|
}),
|
|
8780
9009
|
searchOpen
|
|
8781
9010
|
? h('div', { className: 'rw-searchbar' },
|
|
@@ -8838,7 +9067,33 @@ function rememberShowHidden(value) {
|
|
|
8838
9067
|
'aria-pressed': searchHere ? 'true' : 'false',
|
|
8839
9068
|
disabled: searchRootPath === '',
|
|
8840
9069
|
onClick: function () { setSearchHere(!searchHere); },
|
|
8841
|
-
}, IconFolderTree(11))
|
|
9070
|
+
}, IconFolderTree(11)),
|
|
9071
|
+
h('button', {
|
|
9072
|
+
type: 'button',
|
|
9073
|
+
className: 'rw-chip-btn' + (searchIncludeIgnored ? ' is-on' : ''),
|
|
9074
|
+
title: t('searchIncludeIgnored'),
|
|
9075
|
+
'aria-pressed': searchIncludeIgnored ? 'true' : 'false',
|
|
9076
|
+
onClick: function () { setSearchIncludeIgnored(!searchIncludeIgnored); },
|
|
9077
|
+
}, '.*/'),
|
|
9078
|
+
h('button', {
|
|
9079
|
+
type: 'button',
|
|
9080
|
+
className: 'rw-chip-btn' + (searchFilesOnly ? ' is-on' : ''),
|
|
9081
|
+
title: t('searchFilesOnly'),
|
|
9082
|
+
'aria-pressed': searchFilesOnly ? 'true' : 'false',
|
|
9083
|
+
onClick: function () { setSearchFilesOnly(!searchFilesOnly); },
|
|
9084
|
+
}, IconFile(11)),
|
|
9085
|
+
search.loading && searchJobRef.current !== ''
|
|
9086
|
+
? h('button', {
|
|
9087
|
+
type: 'button',
|
|
9088
|
+
className: 'rw-chip-btn',
|
|
9089
|
+
title: t('searchStop'),
|
|
9090
|
+
onClick: function () {
|
|
9091
|
+
var jobId = searchJobRef.current;
|
|
9092
|
+
searchJobRef.current = '';
|
|
9093
|
+
if (jobId) apiCall('fs.grepCancel', { jobId }).catch(function () {});
|
|
9094
|
+
},
|
|
9095
|
+
}, t('searchStop'))
|
|
9096
|
+
: null)
|
|
8842
9097
|
: null,
|
|
8843
9098
|
h('button', {
|
|
8844
9099
|
type: 'button', className: 'rw-icon-btn', title: t('cancel'),
|
|
@@ -8858,6 +9113,11 @@ function rememberShowHidden(value) {
|
|
|
8858
9113
|
}, h('span', { style: { overflow: 'hidden', textOverflow: 'ellipsis', maxWidth: '160px' } }, term));
|
|
8859
9114
|
}))
|
|
8860
9115
|
: null,
|
|
9116
|
+
searchOpen && searchMode === 'content' && !search.loading && searchStats && searchStats.files > 0
|
|
9117
|
+
? h('div', { className: 'rw-search-stats' },
|
|
9118
|
+
t('searchStats', { files: searchStats.files, size: formatBytes(searchStats.bytes) }),
|
|
9119
|
+
searchStats.skipped > 0 ? ' · ' + t('searchStatsSkipped', { count: searchStats.skipped }) : '')
|
|
9120
|
+
: null,
|
|
8861
9121
|
sources.length > 1
|
|
8862
9122
|
? h('div', { className: 'rw-chips' },
|
|
8863
9123
|
sources.map(function (source) {
|
|
@@ -10677,6 +10937,163 @@ function rememberShowHidden(value) {
|
|
|
10677
10937
|
return h('div', { className: 'rw-group' }, children);
|
|
10678
10938
|
}
|
|
10679
10939
|
|
|
10940
|
+
function AutoPushSettingsGroup(props) {
|
|
10941
|
+
var t = props.t;
|
|
10942
|
+
var locale = props.locale;
|
|
10943
|
+
var localState = useState({ loading: true, saving: false, message: null, asking: false });
|
|
10944
|
+
var local = localState[0];
|
|
10945
|
+
var setLocal = localState[1];
|
|
10946
|
+
var valuesState = useState({
|
|
10947
|
+
autoPushEnabled: false,
|
|
10948
|
+
autoPushDebounceMs: 1500,
|
|
10949
|
+
autoPushInclude: '',
|
|
10950
|
+
autoPushExclude: '',
|
|
10951
|
+
});
|
|
10952
|
+
var values = valuesState[0];
|
|
10953
|
+
var setValues = valuesState[1];
|
|
10954
|
+
|
|
10955
|
+
useEffect(function () {
|
|
10956
|
+
var alive = true;
|
|
10957
|
+
apiCall('settings.get', {}).then(function (settings) {
|
|
10958
|
+
if (!alive) return;
|
|
10959
|
+
setValues({
|
|
10960
|
+
autoPushEnabled: settings.autoPushEnabled === true,
|
|
10961
|
+
autoPushDebounceMs: Number(settings.autoPushDebounceMs) || 1500,
|
|
10962
|
+
autoPushInclude: (settings.autoPushInclude || []).join('\n'),
|
|
10963
|
+
autoPushExclude: (settings.autoPushExclude || []).join('\n'),
|
|
10964
|
+
});
|
|
10965
|
+
setLocal(function (previous) { return Object.assign({}, previous, { loading: false }); });
|
|
10966
|
+
}).catch(function () {
|
|
10967
|
+
if (alive) setLocal(function (previous) { return Object.assign({}, previous, { loading: false }); });
|
|
10968
|
+
});
|
|
10969
|
+
return function () { alive = false; };
|
|
10970
|
+
}, []);
|
|
10971
|
+
|
|
10972
|
+
function save(patch, okText) {
|
|
10973
|
+
setLocal(function (previous) { return Object.assign({}, previous, { saving: true, message: null }); });
|
|
10974
|
+
apiCall('settings.update', patch).then(function (settings) {
|
|
10975
|
+
setValues({
|
|
10976
|
+
autoPushEnabled: settings.autoPushEnabled === true,
|
|
10977
|
+
autoPushDebounceMs: Number(settings.autoPushDebounceMs) || 1500,
|
|
10978
|
+
autoPushInclude: (settings.autoPushInclude || []).join('\n'),
|
|
10979
|
+
autoPushExclude: (settings.autoPushExclude || []).join('\n'),
|
|
10980
|
+
});
|
|
10981
|
+
setLocal({ loading: false, saving: false, asking: false, message: { kind: 'success', text: okText } });
|
|
10982
|
+
}).catch(function (error) {
|
|
10983
|
+
setLocal({
|
|
10984
|
+
loading: false,
|
|
10985
|
+
saving: false,
|
|
10986
|
+
asking: false,
|
|
10987
|
+
message: { kind: 'error', text: messageOf(error, t, locale) },
|
|
10988
|
+
});
|
|
10989
|
+
});
|
|
10990
|
+
}
|
|
10991
|
+
|
|
10992
|
+
function toggle(next) {
|
|
10993
|
+
if (next === true && values.autoPushEnabled === false) {
|
|
10994
|
+
// Turning it on writes files behind the user's back: ask once, in
|
|
10995
|
+
// place, before the switch actually flips.
|
|
10996
|
+
setLocal(function (previous) { return Object.assign({}, previous, { asking: true, message: null }); });
|
|
10997
|
+
return;
|
|
10998
|
+
}
|
|
10999
|
+
save({ autoPushEnabled: Boolean(next) }, t('autoPushSaved'));
|
|
11000
|
+
}
|
|
11001
|
+
|
|
11002
|
+
function commitList(field, key) {
|
|
11003
|
+
var lines = String(values[field] || '').split('\n').map(function (line) { return line.trim(); }).filter(function (line) { return line !== ''; });
|
|
11004
|
+
var patch = {};
|
|
11005
|
+
patch[key] = lines;
|
|
11006
|
+
save(patch, t('autoPushSaved'));
|
|
11007
|
+
}
|
|
11008
|
+
|
|
11009
|
+
var children = [
|
|
11010
|
+
h('div', { className: 'rw-group-head' },
|
|
11011
|
+
h('span', { className: 'rw-group-title' }, t('autoPushTitle'))),
|
|
11012
|
+
h('div', { className: 'rw-setting-row' },
|
|
11013
|
+
h(Switch, {
|
|
11014
|
+
checked: values.autoPushEnabled,
|
|
11015
|
+
onChange: toggle,
|
|
11016
|
+
label: t('autoPushLabel'),
|
|
11017
|
+
text: t('autoPushLabel'),
|
|
11018
|
+
}),
|
|
11019
|
+
local.saving ? Spinner(12) : null),
|
|
11020
|
+
];
|
|
11021
|
+
|
|
11022
|
+
if (local.asking && !values.autoPushEnabled) {
|
|
11023
|
+
children.push(h('div', { className: 'rw-group-hint', style: { marginTop: 8, color: 'rgb(210,153,34)' } }, t('autoPushWarn')));
|
|
11024
|
+
children.push(h('div', { className: 'rw-dialog-actions', style: { marginTop: 10 } },
|
|
11025
|
+
h('button', {
|
|
11026
|
+
type: 'button',
|
|
11027
|
+
className: 'rw-btn rw-btn-sm',
|
|
11028
|
+
onClick: function () { setLocal(function (previous) { return Object.assign({}, previous, { asking: false }); }); },
|
|
11029
|
+
}, t('autoPushCancel')),
|
|
11030
|
+
h('button', {
|
|
11031
|
+
type: 'button',
|
|
11032
|
+
className: 'rw-btn rw-btn-sm rw-btn-primary',
|
|
11033
|
+
onClick: function () { save({ autoPushEnabled: true }, t('autoPushSaved')); },
|
|
11034
|
+
}, t('autoPushConfirm'))));
|
|
11035
|
+
}
|
|
11036
|
+
|
|
11037
|
+
if (values.autoPushEnabled) {
|
|
11038
|
+
children.push(h('div', { className: 'rw-group-hint', style: { marginTop: 8 } }, t('autoPushWarn')));
|
|
11039
|
+
children.push(h('div', { className: 'rw-group-head', style: { marginTop: 12 } },
|
|
11040
|
+
h('span', { className: 'rw-group-title' }, t('autoPushIncludeLabel'))));
|
|
11041
|
+
children.push(h('textarea', {
|
|
11042
|
+
className: 'rw-input rw-input-mono rw-autopush-list',
|
|
11043
|
+
rows: 3,
|
|
11044
|
+
value: values.autoPushInclude,
|
|
11045
|
+
placeholder: 'src/**\ndocs/*.md',
|
|
11046
|
+
onChange: function (event) {
|
|
11047
|
+
var value = event.currentTarget.value;
|
|
11048
|
+
setValues(function (previous) { return Object.assign({}, previous, { autoPushInclude: value }); });
|
|
11049
|
+
},
|
|
11050
|
+
onBlur: function () { commitList('autoPushInclude', 'autoPushInclude'); },
|
|
11051
|
+
}));
|
|
11052
|
+
children.push(h('div', { className: 'rw-group-head', style: { marginTop: 12 } },
|
|
11053
|
+
h('span', { className: 'rw-group-title' }, t('autoPushExcludeLabel'))));
|
|
11054
|
+
children.push(h('textarea', {
|
|
11055
|
+
className: 'rw-input rw-input-mono rw-autopush-list',
|
|
11056
|
+
rows: 3,
|
|
11057
|
+
value: values.autoPushExclude,
|
|
11058
|
+
placeholder: '*.log\n.remote/**',
|
|
11059
|
+
onChange: function (event) {
|
|
11060
|
+
var value = event.currentTarget.value;
|
|
11061
|
+
setValues(function (previous) { return Object.assign({}, previous, { autoPushExclude: value }); });
|
|
11062
|
+
},
|
|
11063
|
+
onBlur: function () { commitList('autoPushExclude', 'autoPushExclude'); },
|
|
11064
|
+
}));
|
|
11065
|
+
children.push(h('div', { className: 'rw-inline', style: { marginTop: 12, flexWrap: 'wrap', gap: 12 } },
|
|
11066
|
+
h('span', { className: 'rw-setting-label' }, t('autoPushDebounceLabel')),
|
|
11067
|
+
h('input', {
|
|
11068
|
+
className: 'rw-input rw-input-num',
|
|
11069
|
+
type: 'number',
|
|
11070
|
+
min: 300,
|
|
11071
|
+
max: 60000,
|
|
11072
|
+
step: 100,
|
|
11073
|
+
value: values.autoPushDebounceMs,
|
|
11074
|
+
onChange: function (event) {
|
|
11075
|
+
var value = event.currentTarget.value;
|
|
11076
|
+
setValues(function (previous) { return Object.assign({}, previous, { autoPushDebounceMs: value }); });
|
|
11077
|
+
},
|
|
11078
|
+
onBlur: function () {
|
|
11079
|
+
var ms = Math.round(Number(values.autoPushDebounceMs) || 1500);
|
|
11080
|
+
save({ autoPushDebounceMs: ms }, t('autoPushSaved'));
|
|
11081
|
+
},
|
|
11082
|
+
})));
|
|
11083
|
+
}
|
|
11084
|
+
|
|
11085
|
+
if (local.message) {
|
|
11086
|
+
children.push(h(Banner, {
|
|
11087
|
+
kind: local.message.kind === 'success' ? 'success' : 'error',
|
|
11088
|
+
onClose: function () {
|
|
11089
|
+
setLocal(function (previous) { return Object.assign({}, previous, { message: null }); });
|
|
11090
|
+
},
|
|
11091
|
+
}, local.message.text));
|
|
11092
|
+
}
|
|
11093
|
+
|
|
11094
|
+
return h('div', { className: 'rw-group' }, children);
|
|
11095
|
+
}
|
|
11096
|
+
|
|
10680
11097
|
function ConnectionsPage(props) {
|
|
10681
11098
|
var ctx = props.ctx;
|
|
10682
11099
|
var locale = useLocale(ctx);
|
|
@@ -10743,6 +11160,7 @@ function rememberShowHidden(value) {
|
|
|
10743
11160
|
hosts: remote.data.hosts || [],
|
|
10744
11161
|
workspaces: links.concat(remotes),
|
|
10745
11162
|
}),
|
|
11163
|
+
h(AutoPushSettingsGroup, { t: t, locale: locale }),
|
|
10746
11164
|
adding === 'linked'
|
|
10747
11165
|
? h(AddWorkspaceFlow, {
|
|
10748
11166
|
ctx: ctx, t: t, locale: locale,
|