dsh-linked-workspace 0.26.1 → 0.27.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 +49 -0
- package/README.en.md +10 -1
- package/README.md +12 -1
- package/docs/API.md +3 -2
- package/docs/VERIFY.md +34 -1
- package/lib/client.js +528 -45
- package/lib/index.js +158 -13
- package/lib/markdown.js +96 -0
- package/package.json +8 -3
- package/scripts/doc_tool.py +27 -0
- package/scripts/md-to-html.mjs +19 -0
package/lib/client.js
CHANGED
|
@@ -2091,12 +2091,66 @@ function urlAttributeViolation(name, value, tagName) {
|
|
|
2091
2091
|
// Complete attribute policy for the document preview. Inline styles are dropped
|
|
2092
2092
|
// as well: `position:fixed; inset:0; z-index:99999` can cover the whole Harness
|
|
2093
2093
|
// window, which turns a preview into a clickjacking / phishing surface without
|
|
2094
|
-
// a single line of script.
|
|
2095
|
-
|
|
2096
|
-
|
|
2094
|
+
// a single line of script. Callers may opt in to `allowInlineStyle` for KaTeX
|
|
2095
|
+
// subtrees, where the style attribute is the layout (see katexStyleViolation).
|
|
2096
|
+
function attributeViolation(name, value, tagName, options) {
|
|
2097
|
+
if (String(name || '').toLowerCase() === 'style') {
|
|
2098
|
+
if (options && options.allowInlineStyle && katexStyleViolation(value) === '') return '';
|
|
2099
|
+
return 'inline style';
|
|
2100
|
+
}
|
|
2097
2101
|
return urlAttributeViolation(name, value, tagName);
|
|
2098
2102
|
}
|
|
2099
2103
|
|
|
2104
|
+
// KaTeX positions every glyph with an inline style — `height:1.2em` on a vlist,
|
|
2105
|
+
// `top:-0.5em` on its children, `vertical-align:-0.2em` on the base — so a
|
|
2106
|
+
// preview that drops them turns each formula into a pile of overlapping spans.
|
|
2107
|
+
// Only that shape is accepted, and only inside `.katex`: lengths, `position:
|
|
2108
|
+
// relative`, and a solid border. Anything that could escape the box
|
|
2109
|
+
// (absolute/fixed positioning, inset, z-index, transforms, url()) is refused.
|
|
2110
|
+
var KATEX_STYLE_PROPERTIES = {
|
|
2111
|
+
height: 'length',
|
|
2112
|
+
top: 'length',
|
|
2113
|
+
left: 'length',
|
|
2114
|
+
width: 'length',
|
|
2115
|
+
'min-width': 'length',
|
|
2116
|
+
'margin-left': 'length',
|
|
2117
|
+
'margin-right': 'length',
|
|
2118
|
+
'padding-left': 'length',
|
|
2119
|
+
'vertical-align': 'length',
|
|
2120
|
+
'border-width': 'length',
|
|
2121
|
+
'border-bottom-width': 'length',
|
|
2122
|
+
'border-style': 'keyword',
|
|
2123
|
+
position: 'keyword',
|
|
2124
|
+
};
|
|
2125
|
+
|
|
2126
|
+
var KATEX_LENGTH = /^-?(?:\d+\.?\d*|\.\d+)(?:em|ex|px|pt|rem|%)?$/;
|
|
2127
|
+
var KATEX_KEYWORDS = {
|
|
2128
|
+
'border-style': /^(?:solid|dashed|dotted)$/,
|
|
2129
|
+
position: /^relative$/,
|
|
2130
|
+
};
|
|
2131
|
+
|
|
2132
|
+
function katexStyleViolation(value) {
|
|
2133
|
+
var text = normalizeUrlValue(value);
|
|
2134
|
+
if (text === '') return '';
|
|
2135
|
+
var declarations = text.split(';');
|
|
2136
|
+
for (var index = 0; index < declarations.length; index += 1) {
|
|
2137
|
+
var declaration = declarations[index].trim();
|
|
2138
|
+
if (declaration === '') continue;
|
|
2139
|
+
var colon = declaration.indexOf(':');
|
|
2140
|
+
if (colon < 0) return 'unsafe style';
|
|
2141
|
+
var property = declaration.slice(0, colon).trim().toLowerCase();
|
|
2142
|
+
var kind = KATEX_STYLE_PROPERTIES[property];
|
|
2143
|
+
if (!kind) return 'unsafe style';
|
|
2144
|
+
var value = declaration.slice(colon + 1).trim();
|
|
2145
|
+
if (kind === 'keyword') {
|
|
2146
|
+
if (!KATEX_KEYWORDS[property].test(value)) return 'unsafe style';
|
|
2147
|
+
} else if (!KATEX_LENGTH.test(value)) {
|
|
2148
|
+
return 'unsafe style';
|
|
2149
|
+
}
|
|
2150
|
+
}
|
|
2151
|
+
return '';
|
|
2152
|
+
}
|
|
2153
|
+
|
|
2100
2154
|
var TREE_TAB_TYPE = 'dsh-linked-workspace';
|
|
2101
2155
|
// Remote workspaces get their own page kind: the two modes show different
|
|
2102
2156
|
// trees (local ⇄ remote pair vs. a plain remote root), so a session must be
|
|
@@ -2112,6 +2166,9 @@ function attributeViolation(name, value, tagName) {
|
|
|
2112
2166
|
// but a full remote listing on a huge folder is expensive; 15 s keeps the
|
|
2113
2167
|
// tree fresh without hammering the SSH channel.
|
|
2114
2168
|
var REFRESH_MIN_INTERVAL_MS = 15000;
|
|
2169
|
+
// Long enough for a slow directory on a busy cluster, short enough that a
|
|
2170
|
+
// dead request does not stare back at the user forever.
|
|
2171
|
+
var TREE_LIST_TIMEOUT_MS = 20000;
|
|
2115
2172
|
// HTML previews read the whole document (a plotly/figure page is one big
|
|
2116
2173
|
// inlined script), so they ask the Host for the 8 MB read cap instead of
|
|
2117
2174
|
// the editor's 2 MB one.
|
|
@@ -2273,6 +2330,26 @@ function attributeViolation(name, value, tagName) {
|
|
|
2273
2330
|
return true;
|
|
2274
2331
|
}
|
|
2275
2332
|
|
|
2333
|
+
// Chat artifacts live outside our tabs, so opening one has to travel
|
|
2334
|
+
// through the tab meta: the tab component reads revealPath on every render.
|
|
2335
|
+
function openTreeTabAt(ctx, options, scope) {
|
|
2336
|
+
var sidebar = sidebarService(ctx);
|
|
2337
|
+
if (!sidebar || typeof sidebar.openTab !== 'function') return false;
|
|
2338
|
+
var remoteOnly = options.kind === 'remote';
|
|
2339
|
+
var type = remoteOnly ? REMOTE_TREE_TAB_TYPE : TREE_TAB_TYPE;
|
|
2340
|
+
var t = makeT(readLocale(ctx));
|
|
2341
|
+
var meta = remoteOnly ? { remoteId: options.id } : { linkedId: options.id };
|
|
2342
|
+
meta.revealPath = options.relative || '';
|
|
2343
|
+
meta.revealSide = options.side === 'local' ? 'local' : 'remote';
|
|
2344
|
+
meta.revealAt = String(Date.now());
|
|
2345
|
+
try {
|
|
2346
|
+
sidebar.openTab({ type: type, id: type, title: t(remoteOnly ? 'remoteTabTitle' : 'tabTitle'), path: '/', meta: meta }, scope);
|
|
2347
|
+
return true;
|
|
2348
|
+
} catch (error) {
|
|
2349
|
+
return false;
|
|
2350
|
+
}
|
|
2351
|
+
}
|
|
2352
|
+
|
|
2276
2353
|
var FILE_TAB_TYPE = 'dsh-linked-workspace:file';
|
|
2277
2354
|
var FILE_SLOT_PREFIX = 'dsh-linked-workspace:file:';
|
|
2278
2355
|
var FILE_SLOT_COUNT = 12;
|
|
@@ -2289,6 +2366,17 @@ function attributeViolation(name, value, tagName) {
|
|
|
2289
2366
|
|
|
2290
2367
|
var ZH = {
|
|
2291
2368
|
settingsNav: '联动工作区',
|
|
2369
|
+
revealSection: '最近产物打开位置',
|
|
2370
|
+
revealHint: '会话里点开会话产物(截图、图表、生成的文件)时,默认落到哪一侧。远程工作区只有远程侧。',
|
|
2371
|
+
revealSideRemote: '优先远程目录',
|
|
2372
|
+
revealSideLocal: '优先本地目录',
|
|
2373
|
+
locateArtifact: '定位最近产物',
|
|
2374
|
+
revealOutside: '这个文件不在任何联动/远程工作区目录里:{{path}}',
|
|
2375
|
+
revealOpenTree: '展开定位',
|
|
2376
|
+
artifactNone: '聊天里还没有可定位的产物',
|
|
2377
|
+
artifactNoSession: '当前会话不可用,无法定位产物',
|
|
2378
|
+
revealMissing: '找不到这个文件在工作区里的相对路径,已复制实际路径:{{path}}',
|
|
2379
|
+
revealCopied: '已复制远程路径:{{path}}',
|
|
2292
2380
|
title: '联动&远程工作区',
|
|
2293
2381
|
welcomeEyebrow: 'DSH-LINKED-WORKSPACE',
|
|
2294
2382
|
welcomeTitle: '欢迎使用联动工作区插件',
|
|
@@ -2757,6 +2845,9 @@ function attributeViolation(name, value, tagName) {
|
|
|
2757
2845
|
execAuditOpen: '打开审计日志',
|
|
2758
2846
|
execSaved: '远端命令执行设置已保存',
|
|
2759
2847
|
shortcutTitle: '常用快捷键',
|
|
2848
|
+
shortcutShow: '展开({{count}} 条)',
|
|
2849
|
+
shortcutHide: '收起',
|
|
2850
|
+
listTimedOut: '加载超时,点击重试',
|
|
2760
2851
|
shortcutHint: '与 VS Code 类似的默认快捷键;macOS 上把 Ctrl 换成 ⌘。',
|
|
2761
2852
|
shortcutSave: '保存当前文件',
|
|
2762
2853
|
shortcutClose: '关闭当前文件',
|
|
@@ -2876,6 +2967,17 @@ function attributeViolation(name, value, tagName) {
|
|
|
2876
2967
|
|
|
2877
2968
|
var EN = {
|
|
2878
2969
|
settingsNav: 'Linked workspaces',
|
|
2970
|
+
revealSection: 'Where the last artifact opens',
|
|
2971
|
+
revealHint: 'Side used when a chat artifact (screenshot, chart, generated file) is opened from the conversation. Remote workspaces only have the remote side.',
|
|
2972
|
+
revealSideRemote: 'Prefer the remote tree',
|
|
2973
|
+
revealSideLocal: 'Prefer the local tree',
|
|
2974
|
+
locateArtifact: 'Locate last artifact',
|
|
2975
|
+
revealOutside: 'This file is not inside any linked or remote workspace directory: {{path}}',
|
|
2976
|
+
revealOpenTree: 'Reveal in the tree',
|
|
2977
|
+
artifactNone: 'No artifact to locate in this chat yet',
|
|
2978
|
+
artifactNoSession: 'This session is not available, so the artifact cannot be located',
|
|
2979
|
+
revealMissing: 'No workspace-relative path for this file; the real path was copied: {{path}}',
|
|
2980
|
+
revealCopied: 'Remote path copied: {{path}}',
|
|
2879
2981
|
title: 'Linked & remote workspaces',
|
|
2880
2982
|
welcomeEyebrow: 'DSH-LINKED-WORKSPACE',
|
|
2881
2983
|
welcomeTitle: 'Welcome to the linked-workspaces plugin',
|
|
@@ -3344,6 +3446,9 @@ function attributeViolation(name, value, tagName) {
|
|
|
3344
3446
|
execAuditOpen: 'Open the audit log',
|
|
3345
3447
|
execSaved: 'Remote-execution settings saved',
|
|
3346
3448
|
shortcutTitle: 'Keyboard shortcuts',
|
|
3449
|
+
shortcutShow: 'Show ({{count}})',
|
|
3450
|
+
shortcutHide: 'Hide',
|
|
3451
|
+
listTimedOut: 'Taking too long — click to retry',
|
|
3347
3452
|
shortcutHint: 'VS Code-like defaults; use ⌘ instead of Ctrl on macOS.',
|
|
3348
3453
|
shortcutSave: 'Save the current file',
|
|
3349
3454
|
shortcutClose: 'Close the current file',
|
|
@@ -3537,7 +3642,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
3537
3642
|
* Host methods the running DSH process does not have yet, the directory
|
|
3538
3643
|
* pane says so instead of surfacing an unrelated error.
|
|
3539
3644
|
*/
|
|
3540
|
-
var HOST_API_REVISION =
|
|
3645
|
+
var HOST_API_REVISION = 14;
|
|
3541
3646
|
var hostInfoProbe = null;
|
|
3542
3647
|
|
|
3543
3648
|
function probeHostInfo() {
|
|
@@ -3668,20 +3773,35 @@ function attributeViolation(name, value, tagName) {
|
|
|
3668
3773
|
return semicolons > commas ? ';' : ',';
|
|
3669
3774
|
}
|
|
3670
3775
|
|
|
3776
|
+
// Returns `{ html, css }`. The stylesheet is handed back separately because
|
|
3777
|
+
// the HTML parser moves a <style> start tag into <head>, so it never reached
|
|
3778
|
+
// `body.innerHTML` — and KaTeX needs those rules: without them a formula
|
|
3779
|
+
// collapses into a pile of overlapping spans.
|
|
3671
3780
|
function sanitizeDocumentHtml(html) {
|
|
3672
3781
|
try {
|
|
3673
3782
|
var parsed = new DOMParser().parseFromString(String(html || ''), 'text/html');
|
|
3674
|
-
|
|
3783
|
+
var css = '';
|
|
3784
|
+
// The renderer ships exactly one stylesheet, marked for this purpose;
|
|
3785
|
+
// anything else is removed like before.
|
|
3786
|
+
parsed.querySelectorAll('style').forEach(function (node) {
|
|
3787
|
+
if (node.getAttribute('data-rw-katex') === '1') css += node.textContent || '';
|
|
3788
|
+
node.remove();
|
|
3789
|
+
});
|
|
3790
|
+
parsed.querySelectorAll('script,iframe,object,embed,link,meta,base,form').forEach(function (node) { node.remove(); });
|
|
3675
3791
|
parsed.querySelectorAll('*').forEach(function (element) {
|
|
3792
|
+
// KaTeX lays a formula out with inline lengths and nothing else, so
|
|
3793
|
+
// that shape survives inside `.katex` while the rest of the document
|
|
3794
|
+
// keeps the `position:fixed; inset:0` defence.
|
|
3795
|
+
var inFormula = typeof element.closest === 'function' && element.closest('.katex') !== null;
|
|
3676
3796
|
Array.from(element.attributes).forEach(function (attribute) {
|
|
3677
|
-
if (attributeViolation(attribute.name, attribute.value, element.tagName)) {
|
|
3797
|
+
if (attributeViolation(attribute.name, attribute.value, element.tagName, { allowInlineStyle: inFormula })) {
|
|
3678
3798
|
element.removeAttribute(attribute.name);
|
|
3679
3799
|
}
|
|
3680
3800
|
});
|
|
3681
3801
|
});
|
|
3682
|
-
return parsed.body.innerHTML;
|
|
3802
|
+
return { html: parsed.body.innerHTML, css: css };
|
|
3683
3803
|
} catch (error) {
|
|
3684
|
-
return '';
|
|
3804
|
+
return { html: '', css: '' };
|
|
3685
3805
|
}
|
|
3686
3806
|
}
|
|
3687
3807
|
|
|
@@ -3745,7 +3865,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
3745
3865
|
};
|
|
3746
3866
|
|
|
3747
3867
|
var runtimeSettings = {
|
|
3748
|
-
value: { editorTheme: DEFAULT_THEME_ID, editorThemeFamily: DEFAULT_THEME_FAMILY, editorThemeMode: 'system', appThemeDark: false, fileOpenMode: 'editor', autoSave: false },
|
|
3868
|
+
value: { editorTheme: DEFAULT_THEME_ID, editorThemeFamily: DEFAULT_THEME_FAMILY, editorThemeMode: 'system', appThemeDark: false, fileOpenMode: 'editor', autoSave: false, revealSide: 'remote' },
|
|
3749
3869
|
loaded: false,
|
|
3750
3870
|
loading: null,
|
|
3751
3871
|
listeners: new Set(),
|
|
@@ -3768,7 +3888,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
3768
3888
|
runtimeSettings.loading = null;
|
|
3769
3889
|
var openMode = settings && (settings.fileOpenMode === 'system' || settings.fileOpenMode === 'copy') ? settings.fileOpenMode : 'editor';
|
|
3770
3890
|
var mode = settings && (settings.editorThemeMode === 'light' || settings.editorThemeMode === 'dark') ? settings.editorThemeMode : 'system';
|
|
3771
|
-
runtimeSettings.apply({ editorTheme: settings && settings.editorTheme ? settings.editorTheme : DEFAULT_THEME_ID, editorThemeFamily: themeFamilyFor(settings), editorThemeMode: mode, fileOpenMode: openMode, autoSave: Boolean(settings && settings.autoSave) });
|
|
3891
|
+
runtimeSettings.apply({ editorTheme: settings && settings.editorTheme ? settings.editorTheme : DEFAULT_THEME_ID, editorThemeFamily: themeFamilyFor(settings), editorThemeMode: mode, fileOpenMode: openMode, autoSave: Boolean(settings && settings.autoSave), revealSide: settings && settings.revealSide === 'local' ? 'local' : 'remote' });
|
|
3772
3892
|
return runtimeSettings.value;
|
|
3773
3893
|
}).catch(function () {
|
|
3774
3894
|
runtimeSettings.loaded = true;
|
|
@@ -4191,6 +4311,8 @@ function attributeViolation(name, value, tagName) {
|
|
|
4191
4311
|
'.rw-mode-card:hover{border-color:var(--dsw-alias-border-l3,rgba(127,127,127,.4))}',
|
|
4192
4312
|
'.rw-mode-card.is-on{border-color:var(--dsw-alias-brand-primary);background:color-mix(in srgb,var(--dsw-alias-brand-primary) 9%,transparent)}',
|
|
4193
4313
|
'.rw-mode-card.is-on .rw-mode-name{color:var(--dsw-alias-brand-primary)}',
|
|
4314
|
+
'.rw-btn.is-on{border-color:var(--dsw-alias-brand-primary);background:color-mix(in srgb,var(--dsw-alias-brand-primary) 10%,transparent);color:var(--dsw-alias-label-primary);font-weight:600}',
|
|
4315
|
+
'.rw-btn.is-on:hover{border-color:var(--dsw-alias-brand-primary)}',
|
|
4194
4316
|
'.rw-mode-name{font-size:12px;font-weight:600;line-height:17px}',
|
|
4195
4317
|
'.rw-mode-desc{font-size:10.5px;line-height:14px;color:var(--dsw-alias-label-tertiary)}',
|
|
4196
4318
|
'.rw-ctx-menu{position:fixed;min-width:214px;max-height:min(70vh,520px);overflow:auto;padding:4px 0;border:1px solid var(--dsw-alias-border-l2);border-radius:7px;background:var(--dsw-alias-bg-overlay);box-shadow:0 12px 36px rgba(0,0,0,.3);z-index:71;font-size:12px;user-select:none}',
|
|
@@ -4835,6 +4957,13 @@ function attributeViolation(name, value, tagName) {
|
|
|
4835
4957
|
h('path', { key: 'b', d: 'M11.2 2.2v3h-3M4.8 13.8v-3h3', stroke: 'currentColor', strokeWidth: 1.3, strokeLinecap: 'round', strokeLinejoin: 'round' }),
|
|
4836
4958
|
]);
|
|
4837
4959
|
}
|
|
4960
|
+
function IconLocate(size) {
|
|
4961
|
+
return svg(size || 14, [
|
|
4962
|
+
h('circle', { key: 'a', cx: 8, cy: 8, r: 4.2, stroke: 'currentColor', strokeWidth: 1.3 }),
|
|
4963
|
+
h('path', { key: 'b', d: 'M8 1.4v2.6M8 12v2.6M1.4 8h2.6M12 8h2.6', stroke: 'currentColor', strokeWidth: 1.3, strokeLinecap: 'round' }),
|
|
4964
|
+
h('circle', { key: 'c', cx: 8, cy: 8, r: 0.9, fill: 'currentColor' }),
|
|
4965
|
+
]);
|
|
4966
|
+
}
|
|
4838
4967
|
function IconClock(size) {
|
|
4839
4968
|
return svg(size || 14, [
|
|
4840
4969
|
h('circle', { key: 'a', cx: 8, cy: 8, r: 5.8, stroke: 'currentColor', strokeWidth: 1.3 }),
|
|
@@ -6259,7 +6388,8 @@ function attributeViolation(name, value, tagName) {
|
|
|
6259
6388
|
var entries = new Map();
|
|
6260
6389
|
if (rememberedTree && Array.isArray(rememberedTree.entries)) {
|
|
6261
6390
|
rememberedTree.entries.forEach(function (pair) {
|
|
6262
|
-
if (pair
|
|
6391
|
+
if (!pair || pair.length !== 2) return;
|
|
6392
|
+
entries.set(pair[0], Object.assign({}, pair[1] || {}, { loading: false, loadingMore: false }));
|
|
6263
6393
|
});
|
|
6264
6394
|
}
|
|
6265
6395
|
return { entries: entries };
|
|
@@ -6268,9 +6398,15 @@ function attributeViolation(name, value, tagName) {
|
|
|
6268
6398
|
var setCache = cacheState[1];
|
|
6269
6399
|
|
|
6270
6400
|
useEffect(function () {
|
|
6401
|
+
// A record captured while its request was still in flight comes back
|
|
6402
|
+
// with `loading: true` and nothing will ever clear it (the request died
|
|
6403
|
+
// with the panel), so the tree would spin forever. Persist only what is
|
|
6404
|
+
// settled; the reload below refetches the rest.
|
|
6271
6405
|
rememberPanel(props.memoryKey, {
|
|
6272
6406
|
expanded: Array.from(expanded),
|
|
6273
|
-
entries: Array.from(cache.entries.entries())
|
|
6407
|
+
entries: Array.from(cache.entries.entries()).map(function (pair) {
|
|
6408
|
+
return [pair[0], Object.assign({}, pair[1] || {}, { loading: false, loadingMore: false })];
|
|
6409
|
+
}),
|
|
6274
6410
|
});
|
|
6275
6411
|
}, [expanded, cache]);
|
|
6276
6412
|
var pending = useRef(new Set());
|
|
@@ -6371,6 +6507,15 @@ function attributeViolation(name, value, tagName) {
|
|
|
6371
6507
|
});
|
|
6372
6508
|
}
|
|
6373
6509
|
|
|
6510
|
+
// `load` refuses to re-ask while a path is pending, which is what keeps
|
|
6511
|
+
// duplicate requests down but also traps a request whose response never
|
|
6512
|
+
// arrived. The retry below drops the guard first.
|
|
6513
|
+
function retry(path) {
|
|
6514
|
+
pending.current.delete(path);
|
|
6515
|
+
lastRefreshAt.current.delete(path);
|
|
6516
|
+
load(path);
|
|
6517
|
+
}
|
|
6518
|
+
|
|
6374
6519
|
function loadMore(path) {
|
|
6375
6520
|
var record = cache.entries.get(path);
|
|
6376
6521
|
if (!record || record.loadingMore || !record.hasMore) return;
|
|
@@ -6437,6 +6582,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
6437
6582
|
toggle: toggle,
|
|
6438
6583
|
state: { entries: cache.entries },
|
|
6439
6584
|
load: load,
|
|
6585
|
+
retry: retry,
|
|
6440
6586
|
loadMore: loadMore,
|
|
6441
6587
|
onSelect: props.onSelect,
|
|
6442
6588
|
onPin: props.onPin,
|
|
@@ -6503,6 +6649,12 @@ function attributeViolation(name, value, tagName) {
|
|
|
6503
6649
|
return h('div', { className: 'rw-linked-toolbar' },
|
|
6504
6650
|
h('span', { className: 'rw-tree-toolbar-title' }, props.title || t('tabTitle')),
|
|
6505
6651
|
h('div', { className: 'rw-actions', style: { marginLeft: 'auto', gap: 2 } },
|
|
6652
|
+
h('button', {
|
|
6653
|
+
type: 'button',
|
|
6654
|
+
className: 'rw-icon-btn',
|
|
6655
|
+
title: props.locateTitle || t('locateArtifact'),
|
|
6656
|
+
onClick: function () { if (props.onLocate) props.onLocate(); },
|
|
6657
|
+
}, IconLocate(14)),
|
|
6506
6658
|
h('button', {
|
|
6507
6659
|
type: 'button',
|
|
6508
6660
|
className: 'rw-icon-btn',
|
|
@@ -7565,7 +7717,7 @@ function rememberShowHidden(value) {
|
|
|
7565
7717
|
var stateRef = useState({
|
|
7566
7718
|
loading: true, error: '', data: null, text: '', dirty: false, saving: false,
|
|
7567
7719
|
preview: rememberedView ? rememberedView.preview === true : kind === 'markdown',
|
|
7568
|
-
html: '', previewLoading: false,
|
|
7720
|
+
html: '', css: '', previewLoading: false,
|
|
7569
7721
|
page: rememberedView ? Number(rememberedView.page) || 0 : 0,
|
|
7570
7722
|
sheet: rememberedView ? Number(rememberedView.sheet) || 0 : 0,
|
|
7571
7723
|
slide: rememberedView ? Number(rememberedView.slide) || 0 : 0,
|
|
@@ -7635,7 +7787,8 @@ function rememberShowHidden(value) {
|
|
|
7635
7787
|
if (state.loading || !state.preview || kind !== 'markdown' || state.html || state.previewLoading) return;
|
|
7636
7788
|
patch({ previewLoading: true });
|
|
7637
7789
|
apiCall('docs.mdPreview', params({ text: state.text })).then(function (result) {
|
|
7638
|
-
|
|
7790
|
+
var clean = sanitizeDocumentHtml(result.html);
|
|
7791
|
+
patch({ previewLoading: false, html: clean.html, css: clean.css });
|
|
7639
7792
|
}).catch(function (error) {
|
|
7640
7793
|
patch({ previewLoading: false, error: messageOf(error, t, locale) });
|
|
7641
7794
|
});
|
|
@@ -7752,7 +7905,8 @@ function rememberShowHidden(value) {
|
|
|
7752
7905
|
patch({ preview: next, previewLoading: next && !state.html });
|
|
7753
7906
|
if (!next || state.html) return;
|
|
7754
7907
|
apiCall('docs.mdPreview', params({ text: state.text })).then(function (result) {
|
|
7755
|
-
|
|
7908
|
+
var clean = sanitizeDocumentHtml(result.html);
|
|
7909
|
+
patch({ previewLoading: false, html: clean.html, css: clean.css });
|
|
7756
7910
|
}).catch(function (error) {
|
|
7757
7911
|
patch({ previewLoading: false, error: messageOf(error, t, locale) });
|
|
7758
7912
|
});
|
|
@@ -7848,6 +8002,7 @@ function rememberShowHidden(value) {
|
|
|
7848
8002
|
body = state.preview
|
|
7849
8003
|
? h('div', { className: 'rw-doc-body', ref: docBodyRef, onScroll: rememberScroll },
|
|
7850
8004
|
state.previewLoading ? h('div', { className: 'rw-editor-message' }, Spinner(14), t('loading')) : null,
|
|
8005
|
+
state.html ? h('style', { 'data-rw-katex': '1', dangerouslySetInnerHTML: { __html: state.css || '' } }) : null,
|
|
7851
8006
|
state.html ? h('div', { ref: docPreviewRef, className: 'rw-doc-preview', onScroll: rememberScroll, dangerouslySetInnerHTML: { __html: state.html } }) : null)
|
|
7852
8007
|
: h('div', { className: 'rw-doc-body', ref: docBodyRef, onScroll: rememberScroll },
|
|
7853
8008
|
state.findOpen ? h('div', { className: 'rw-find-bar rw-doc-find' },
|
|
@@ -8172,6 +8327,19 @@ function rememberShowHidden(value) {
|
|
|
8172
8327
|
if (!exists) setSelectedKey(sources[0].key);
|
|
8173
8328
|
}, [sources.length, selectedKey]);
|
|
8174
8329
|
|
|
8330
|
+
// Reveal a chat artifact: the tab meta carries the workspace-relative
|
|
8331
|
+
// path, and every new reveal bumps revealAt so repeats still fire.
|
|
8332
|
+
var revealedRef = useRef('');
|
|
8333
|
+
useEffect(function () {
|
|
8334
|
+
var wanted = tabMeta.revealPath ? String(tabMeta.revealPath) : '';
|
|
8335
|
+
if (!wanted || !selected) return;
|
|
8336
|
+
var stamp = String(tabMeta.revealAt || '') + ':' + wanted;
|
|
8337
|
+
if (revealedRef.current === stamp) return;
|
|
8338
|
+
revealedRef.current = stamp;
|
|
8339
|
+
var side = tabMeta.revealSide === 'local' && !remoteOnly ? 'local' : 'remote';
|
|
8340
|
+
openInternalFile(side, wanted, { pinned: true });
|
|
8341
|
+
}, [tabMeta.revealPath, tabMeta.revealAt, tabMeta.revealSide, selected && selected.key]);
|
|
8342
|
+
|
|
8175
8343
|
var scopeRef = selected ? sourceScopeOf(selected) : null;
|
|
8176
8344
|
|
|
8177
8345
|
// Free space on the remote volume (F2): fetched once per workspace and
|
|
@@ -8373,6 +8541,15 @@ function rememberShowHidden(value) {
|
|
|
8373
8541
|
});
|
|
8374
8542
|
}
|
|
8375
8543
|
|
|
8544
|
+
function activeTabSessionId() {
|
|
8545
|
+
try {
|
|
8546
|
+
var snapshot = typeof sidebar.getSnapshot === 'function' ? sidebar.getSnapshot() : null;
|
|
8547
|
+
return snapshot && snapshot.sessionId ? String(snapshot.sessionId) : '';
|
|
8548
|
+
} catch (error) {
|
|
8549
|
+
return '';
|
|
8550
|
+
}
|
|
8551
|
+
}
|
|
8552
|
+
|
|
8376
8553
|
function openTerminal(side, atPath) {
|
|
8377
8554
|
if (!selected) return;
|
|
8378
8555
|
if (side === 'local' && selected.kind !== 'linked') {
|
|
@@ -9822,6 +9999,17 @@ function rememberShowHidden(value) {
|
|
|
9822
9999
|
directoryOpen: directoryOpen,
|
|
9823
10000
|
onToggleDirectory: function () { setDirectoryOpen(!directoryOpen); },
|
|
9824
10001
|
onOpenTerminal: openTerminal,
|
|
10002
|
+
onLocate: function () {
|
|
10003
|
+
locateLastArtifact({
|
|
10004
|
+
ctx: ctx,
|
|
10005
|
+
t: t,
|
|
10006
|
+
locale: locale,
|
|
10007
|
+
settings: settings,
|
|
10008
|
+
showNotice: showNotice,
|
|
10009
|
+
sessionId: props.sessionId || activeTabSessionId(),
|
|
10010
|
+
data: data.data || {},
|
|
10011
|
+
});
|
|
10012
|
+
},
|
|
9825
10013
|
localEnabled: !remoteOnly && selected.kind === 'linked',
|
|
9826
10014
|
showHidden: showHidden,
|
|
9827
10015
|
onToggleHidden: function () {
|
|
@@ -10111,8 +10299,19 @@ function rememberShowHidden(value) {
|
|
|
10111
10299
|
});
|
|
10112
10300
|
// Hovering over a collapsed folder during a drag expands it after a short
|
|
10113
10301
|
// delay, so dropping into a nested folder does not require two passes.
|
|
10302
|
+
// A listing that never settles (dropped socket, aborted request) has to
|
|
10303
|
+
// stop looking like progress at some point.
|
|
10304
|
+
var stalledState = useState(false);
|
|
10305
|
+
var stalled = stalledState[0];
|
|
10306
|
+
var setStalled = stalledState[1];
|
|
10114
10307
|
var dragOpenTimer = useRef(null);
|
|
10115
10308
|
|
|
10309
|
+
useEffect(function () {
|
|
10310
|
+
if (!entry.loading) { setStalled(false); return undefined; }
|
|
10311
|
+
var timer = setTimeout(function () { setStalled(true); }, TREE_LIST_TIMEOUT_MS);
|
|
10312
|
+
return function () { clearTimeout(timer); };
|
|
10313
|
+
}, [entry.loading, path]);
|
|
10314
|
+
|
|
10116
10315
|
useEffect(function () {
|
|
10117
10316
|
return function () {
|
|
10118
10317
|
if (dragOpenTimer.current) clearTimeout(dragOpenTimer.current);
|
|
@@ -10120,12 +10319,25 @@ function rememberShowHidden(value) {
|
|
|
10120
10319
|
}, []);
|
|
10121
10320
|
|
|
10122
10321
|
useEffect(function () {
|
|
10123
|
-
|
|
10124
|
-
|
|
10322
|
+
// `load` is guarded per path, so asking again while a request is in
|
|
10323
|
+
// flight costs nothing; doing it whenever the record is unsettled also
|
|
10324
|
+
// heals one restored from panel memory still flagged as loading.
|
|
10325
|
+
if (isOpen && !entry.loaded && !entry.error) props.load(path);
|
|
10326
|
+
}, [isOpen, entry.loading, entry.loaded, entry.error]);
|
|
10125
10327
|
|
|
10126
10328
|
var children = [];
|
|
10127
10329
|
if (isOpen) {
|
|
10128
|
-
if (entry.loading)
|
|
10330
|
+
if (entry.loading) {
|
|
10331
|
+
children.push(stalled
|
|
10332
|
+
? h('button', {
|
|
10333
|
+
key: 'loading',
|
|
10334
|
+
type: 'button',
|
|
10335
|
+
className: 'rw-row-msg',
|
|
10336
|
+
style: { width: '100%', border: 0, background: 'transparent', cursor: 'pointer', textAlign: 'left' },
|
|
10337
|
+
onClick: function () { setStalled(false); props.retry(path); },
|
|
10338
|
+
}, IconAlert(12), t('listTimedOut'))
|
|
10339
|
+
: h('div', { key: 'loading', className: 'rw-row-msg' }, Spinner(12), t('loading')));
|
|
10340
|
+
}
|
|
10129
10341
|
else if (entry.error) children.push(h('button', {
|
|
10130
10342
|
key: 'error',
|
|
10131
10343
|
type: 'button',
|
|
@@ -10149,6 +10361,7 @@ function rememberShowHidden(value) {
|
|
|
10149
10361
|
toggle: toggle,
|
|
10150
10362
|
state: state,
|
|
10151
10363
|
load: props.load,
|
|
10364
|
+
retry: props.retry,
|
|
10152
10365
|
loadMore: props.loadMore,
|
|
10153
10366
|
onSelect: onSelect,
|
|
10154
10367
|
onPin: onPin,
|
|
@@ -10365,6 +10578,11 @@ function rememberShowHidden(value) {
|
|
|
10365
10578
|
});
|
|
10366
10579
|
}
|
|
10367
10580
|
|
|
10581
|
+
function retry(path) {
|
|
10582
|
+
pending.current.delete(path);
|
|
10583
|
+
load(path);
|
|
10584
|
+
}
|
|
10585
|
+
|
|
10368
10586
|
function loadMore(path) {
|
|
10369
10587
|
var record = cache.entries.get(path);
|
|
10370
10588
|
if (!record || record.loadingMore || !record.hasMore) return;
|
|
@@ -10409,7 +10627,7 @@ function rememberShowHidden(value) {
|
|
|
10409
10627
|
return next;
|
|
10410
10628
|
});
|
|
10411
10629
|
var record = cache.entries.get(root);
|
|
10412
|
-
if (!record || (!record.loaded && !record.
|
|
10630
|
+
if (!record || (!record.loaded && !record.error)) load(root);
|
|
10413
10631
|
}, [open]);
|
|
10414
10632
|
|
|
10415
10633
|
return h('div', { className: 'rw-tree-ws' },
|
|
@@ -10448,6 +10666,7 @@ function rememberShowHidden(value) {
|
|
|
10448
10666
|
toggle: toggle,
|
|
10449
10667
|
state: { entries: cache.entries },
|
|
10450
10668
|
load: load,
|
|
10669
|
+
retry: retry,
|
|
10451
10670
|
loadMore: loadMore,
|
|
10452
10671
|
onSelect: props.onSelect,
|
|
10453
10672
|
selectedPath: props.selectedPath,
|
|
@@ -11634,6 +11853,11 @@ function rememberShowHidden(value) {
|
|
|
11634
11853
|
var state = useState({ saving: false, message: null });
|
|
11635
11854
|
var local = state[0];
|
|
11636
11855
|
var setLocal = state[1];
|
|
11856
|
+
// The key list is reference material: folded until asked for, like the
|
|
11857
|
+
// second-layer lists below it.
|
|
11858
|
+
var shortcutOpenState = useState(false);
|
|
11859
|
+
var shortcutsOpen = shortcutOpenState[0];
|
|
11860
|
+
var setShortcutsOpen = shortcutOpenState[1];
|
|
11637
11861
|
var shortcuts = [
|
|
11638
11862
|
['Ctrl+S', t('shortcutSave')],
|
|
11639
11863
|
['Ctrl+W', t('shortcutClose')],
|
|
@@ -11667,14 +11891,22 @@ function rememberShowHidden(value) {
|
|
|
11667
11891
|
local.saving ? Spinner(12) : null),
|
|
11668
11892
|
h('div', { className: 'rw-group-head', style: { marginTop: 14 } },
|
|
11669
11893
|
h('span', { className: 'rw-group-title' }, t('shortcutTitle')),
|
|
11670
|
-
h('
|
|
11671
|
-
|
|
11672
|
-
|
|
11673
|
-
|
|
11674
|
-
|
|
11675
|
-
|
|
11676
|
-
|
|
11677
|
-
|
|
11894
|
+
h('button', {
|
|
11895
|
+
type: 'button',
|
|
11896
|
+
className: 'rw-btn rw-btn-ghost rw-btn-sm',
|
|
11897
|
+
onClick: function () { setShortcutsOpen(function (open) { return !open; }); },
|
|
11898
|
+
}, t(shortcutsOpen ? 'shortcutHide' : 'shortcutShow', { count: String(shortcuts.length) }))),
|
|
11899
|
+
shortcutsOpen
|
|
11900
|
+
? h('div', null,
|
|
11901
|
+
h('div', { className: 'rw-group-hint', style: { marginTop: 4 } }, t('shortcutHint')),
|
|
11902
|
+
h('div', { className: 'rw-shortcut-grid' },
|
|
11903
|
+
shortcuts.map(function (item) {
|
|
11904
|
+
return h('div', { key: item[0], className: 'rw-shortcut-row' },
|
|
11905
|
+
h('kbd', { className: 'rw-kbd' }, item[0]),
|
|
11906
|
+
h('span', null, item[1]));
|
|
11907
|
+
})),
|
|
11908
|
+
h('div', { className: 'rw-group-hint', style: { marginTop: 8 } }, t('shortcutWebNote')))
|
|
11909
|
+
: null,
|
|
11678
11910
|
local.message
|
|
11679
11911
|
? h(Banner, {
|
|
11680
11912
|
kind: local.message.kind === 'success' ? 'success' : 'error',
|
|
@@ -11700,7 +11932,10 @@ function rememberShowHidden(value) {
|
|
|
11700
11932
|
});
|
|
11701
11933
|
var local = state[0];
|
|
11702
11934
|
var setLocal = state[1];
|
|
11703
|
-
//
|
|
11935
|
+
// Both lists are long and rarely touched: start collapsed.
|
|
11936
|
+
var hostListState = useState(false);
|
|
11937
|
+
var hostsOpen = hostListState[0];
|
|
11938
|
+
var setHostsOpen = hostListState[1];
|
|
11704
11939
|
var workspaceListState = useState(false);
|
|
11705
11940
|
var workspacesOpen = workspaceListState[0];
|
|
11706
11941
|
var setWorkspacesOpen = workspaceListState[1];
|
|
@@ -11812,23 +12047,36 @@ function rememberShowHidden(value) {
|
|
|
11812
12047
|
if (local.execEnabled) {
|
|
11813
12048
|
children.push(h('div', { className: 'rw-group-hint', style: { marginTop: 8, color: 'rgb(210,153,34)' } }, t('execWarn')));
|
|
11814
12049
|
children.push(h('div', { className: 'rw-group-head', style: { marginTop: 12 } },
|
|
11815
|
-
h('span', { className: 'rw-group-title' }, t('execHostsTitle'))
|
|
11816
|
-
|
|
11817
|
-
|
|
11818
|
-
|
|
11819
|
-
|
|
11820
|
-
|
|
11821
|
-
|
|
11822
|
-
|
|
11823
|
-
|
|
11824
|
-
|
|
11825
|
-
|
|
11826
|
-
|
|
11827
|
-
|
|
11828
|
-
|
|
11829
|
-
|
|
11830
|
-
|
|
11831
|
-
|
|
12050
|
+
h('span', { className: 'rw-group-title' }, t('execHostsTitle')),
|
|
12051
|
+
h('button', {
|
|
12052
|
+
type: 'button',
|
|
12053
|
+
className: 'rw-btn rw-btn-ghost rw-btn-sm',
|
|
12054
|
+
onClick: function () { setHostsOpen(function (open) { return !open; }); },
|
|
12055
|
+
}, t(hostsOpen ? 'execWorkspacesHide' : 'execWorkspacesShow', { count: String(local.execHostIds.length) }))));
|
|
12056
|
+
if (hostsOpen) {
|
|
12057
|
+
children.push(hosts.length === 0
|
|
12058
|
+
? h('div', { className: 'rw-hint' }, t('execHostsEmpty'))
|
|
12059
|
+
: h('div', { className: 'rw-exec-list' }, hosts.map(function (host) {
|
|
12060
|
+
var checked = local.execHostIds.indexOf(host.id) >= 0;
|
|
12061
|
+
return h('label', { key: host.id, className: 'rw-exec-item' },
|
|
12062
|
+
h('input', {
|
|
12063
|
+
type: 'checkbox',
|
|
12064
|
+
checked: checked,
|
|
12065
|
+
onChange: function (event) {
|
|
12066
|
+
var on = event.currentTarget.checked;
|
|
12067
|
+
save({ execHostIds: withId(local.execHostIds, host.id, on) }, t('execSaved'));
|
|
12068
|
+
},
|
|
12069
|
+
}),
|
|
12070
|
+
h('span', { className: 'rw-exec-name' }, host.name || host.host || host.id),
|
|
12071
|
+
h('span', { className: 'rw-exec-meta' }, (host.username ? host.username + '@' : '') + (host.host || '') + (host.port ? ':' + host.port : '')));
|
|
12072
|
+
})));
|
|
12073
|
+
} else {
|
|
12074
|
+
var pickedNames = hosts.filter(function (host) {
|
|
12075
|
+
return local.execHostIds.indexOf(host.id) >= 0;
|
|
12076
|
+
}).map(function (host) { return host.name || host.host || host.id; });
|
|
12077
|
+
children.push(h('div', { className: 'rw-group-hint', style: { marginTop: 4 } },
|
|
12078
|
+
pickedNames.length === 0 ? t('execHostsEmpty') : pickedNames.join('、')));
|
|
12079
|
+
}
|
|
11832
12080
|
var picked = local.execWorkspaceIds;
|
|
11833
12081
|
children.push(h('div', { className: 'rw-group-head', style: { marginTop: 12 } },
|
|
11834
12082
|
h('span', { className: 'rw-group-title' }, t('execWorkspacesTitle')),
|
|
@@ -12375,6 +12623,135 @@ function rememberShowHidden(value) {
|
|
|
12375
12623
|
return h('div', { className: 'rw-group' }, children);
|
|
12376
12624
|
}
|
|
12377
12625
|
|
|
12626
|
+
// ── chat artifacts: open them in our own tree ───────────────────────────
|
|
12627
|
+
// DSH hands every file chip, deliverable card and file tool row the same
|
|
12628
|
+
// context-menu target: { kind: 'file', value: { sessionId, path } }. That is
|
|
12629
|
+
// the only place the original path survives, so the reveal action lives here.
|
|
12630
|
+
|
|
12631
|
+
function workspaceRelativePath(source, filePath) {
|
|
12632
|
+
var path = String(filePath || '');
|
|
12633
|
+
if (!path || !source) return '';
|
|
12634
|
+
if (source.kind === 'remote') {
|
|
12635
|
+
var remoteRoot = String(source.remotePath || '');
|
|
12636
|
+
if (remoteRoot && (path === remoteRoot || path.indexOf(remoteRoot + '/') === 0)) {
|
|
12637
|
+
return path.slice(remoteRoot.length).replace(/^\/+/, '');
|
|
12638
|
+
}
|
|
12639
|
+
return '';
|
|
12640
|
+
}
|
|
12641
|
+
var posixPath = path.split('\\').join('/');
|
|
12642
|
+
var localRoot = String(source.localPath || '').split('\\').join('/');
|
|
12643
|
+
if (localRoot && (posixPath.toLowerCase() === localRoot.toLowerCase() || posixPath.toLowerCase().indexOf((localRoot + '/').toLowerCase()) === 0)) {
|
|
12644
|
+
return posixPath.slice(localRoot.length).replace(/^\/+/, '');
|
|
12645
|
+
}
|
|
12646
|
+
var linkedRemote = String(source.remotePath || '');
|
|
12647
|
+
if (linkedRemote && (path === linkedRemote || path.indexOf(linkedRemote + '/') === 0)) {
|
|
12648
|
+
return path.slice(linkedRemote.length).replace(/^\/+/, '');
|
|
12649
|
+
}
|
|
12650
|
+
return '';
|
|
12651
|
+
}
|
|
12652
|
+
|
|
12653
|
+
function remoteAbsolutePath(source, relative) {
|
|
12654
|
+
var root = String(source.remotePath || '').replace(/\/+$/, '');
|
|
12655
|
+
var rel = String(relative || '').replace(/^\/+/, '');
|
|
12656
|
+
if (!root) return rel;
|
|
12657
|
+
return rel ? root + '/' + rel : root;
|
|
12658
|
+
}
|
|
12659
|
+
|
|
12660
|
+
function localAbsolutePath(source, relative) {
|
|
12661
|
+
var root = String(source.localPath || '').replace(/[\\/]+$/, '');
|
|
12662
|
+
var rel = String(relative || '').replace(/^[\\/]+/, '');
|
|
12663
|
+
return rel ? root + '\\' + rel.replace(/\//g, '\\') : root;
|
|
12664
|
+
}
|
|
12665
|
+
|
|
12666
|
+
function revealCandidates(data) {
|
|
12667
|
+
var out = [];
|
|
12668
|
+
(data.links || []).forEach(function (item) {
|
|
12669
|
+
out.push({ kind: 'linked', id: item.id, name: item.name, localPath: item.localPath, remotePath: item.remotePath, status: item.status });
|
|
12670
|
+
});
|
|
12671
|
+
(data.remotes || []).forEach(function (item) {
|
|
12672
|
+
out.push({ kind: 'remote', id: item.id, name: item.name, localPath: null, remotePath: item.remotePath, status: item.status });
|
|
12673
|
+
});
|
|
12674
|
+
return out;
|
|
12675
|
+
}
|
|
12676
|
+
|
|
12677
|
+
function locateLastArtifact(options) {
|
|
12678
|
+
var ctx = options.ctx;
|
|
12679
|
+
var t = options.t;
|
|
12680
|
+
var locale = options.locale;
|
|
12681
|
+
var settings = options.settings;
|
|
12682
|
+
var showNotice = options.showNotice;
|
|
12683
|
+
var sessionId = String(options.sessionId || '');
|
|
12684
|
+
if (!sessionId) {
|
|
12685
|
+
showNotice('error', t('artifactNoSession'));
|
|
12686
|
+
return;
|
|
12687
|
+
}
|
|
12688
|
+
apiCall('linked.lastArtifact', { sessionId: sessionId }).then(function (result) {
|
|
12689
|
+
var artifact = result && result.artifact ? result.artifact : null;
|
|
12690
|
+
if (!artifact || !artifact.path) {
|
|
12691
|
+
showNotice('info', t('artifactNone'));
|
|
12692
|
+
return;
|
|
12693
|
+
}
|
|
12694
|
+
var filePath = String(artifact.path);
|
|
12695
|
+
var candidates = revealCandidates(options.data || {});
|
|
12696
|
+
var hit = null;
|
|
12697
|
+
for (var index = 0; index < candidates.length; index += 1) {
|
|
12698
|
+
var relative = workspaceRelativePath(candidates[index], filePath);
|
|
12699
|
+
if (relative) { hit = { source: candidates[index], relative: relative }; break; }
|
|
12700
|
+
}
|
|
12701
|
+
if (!hit) {
|
|
12702
|
+
copyPathToClipboard(filePath);
|
|
12703
|
+
showNotice('warn', t('revealOutside', { path: filePath }));
|
|
12704
|
+
return;
|
|
12705
|
+
}
|
|
12706
|
+
var side = settings.revealSide === 'local' && hit.source.kind === 'linked' ? 'local' : 'remote';
|
|
12707
|
+
var opened = openTreeTabAt(ctx, { kind: hit.source.kind, id: hit.source.id, relative: hit.relative, side: side }, sessionId);
|
|
12708
|
+
if (!opened) showNotice('error', t('revealMissing'));
|
|
12709
|
+
}).catch(function (error) {
|
|
12710
|
+
showNotice('error', messageOf(error, t, locale));
|
|
12711
|
+
});
|
|
12712
|
+
}
|
|
12713
|
+
|
|
12714
|
+
function RevealSettingsGroup(props) {
|
|
12715
|
+
var t = props.t;
|
|
12716
|
+
var settings = useRuntimeSettings();
|
|
12717
|
+
var state = useState({ saving: false, message: null });
|
|
12718
|
+
var local = state[0];
|
|
12719
|
+
var setLocal = state[1];
|
|
12720
|
+
var current = settings.revealSide === 'local' ? 'local' : 'remote';
|
|
12721
|
+
|
|
12722
|
+
function choose(side) {
|
|
12723
|
+
if (local.saving || side === current) return;
|
|
12724
|
+
setLocal({ saving: true, message: null });
|
|
12725
|
+
apiCall('settings.update', { revealSide: side }).then(function () {
|
|
12726
|
+
runtimeSettings.apply({ revealSide: side });
|
|
12727
|
+
bus.emit();
|
|
12728
|
+
setLocal({ saving: false, message: null });
|
|
12729
|
+
}).catch(function (error) {
|
|
12730
|
+
setLocal({ saving: false, message: { kind: 'error', text: messageOf(error, t, props.locale) } });
|
|
12731
|
+
});
|
|
12732
|
+
}
|
|
12733
|
+
|
|
12734
|
+
return h('div', { className: 'rw-group' },
|
|
12735
|
+
h('div', { className: 'rw-group-head' },
|
|
12736
|
+
h('span', { className: 'rw-group-title' }, t('revealSection')),
|
|
12737
|
+
h('span', { className: 'rw-group-hint' }, t('revealHint'))),
|
|
12738
|
+
h('div', { className: 'rw-setting-row' },
|
|
12739
|
+
h('button', {
|
|
12740
|
+
type: 'button',
|
|
12741
|
+
className: 'rw-btn rw-btn-sm' + (current === 'remote' ? ' is-on' : ''),
|
|
12742
|
+
onClick: function () { choose('remote'); },
|
|
12743
|
+
'aria-pressed': current === 'remote',
|
|
12744
|
+
}, t('revealSideRemote')),
|
|
12745
|
+
h('button', {
|
|
12746
|
+
type: 'button',
|
|
12747
|
+
className: 'rw-btn rw-btn-sm' + (current === 'local' ? ' is-on' : ''),
|
|
12748
|
+
onClick: function () { choose('local'); },
|
|
12749
|
+
'aria-pressed': current === 'local',
|
|
12750
|
+
}, t('revealSideLocal')),
|
|
12751
|
+
local.saving ? Spinner(12) : null),
|
|
12752
|
+
local.message ? h(Banner, { kind: local.message.kind === 'error' ? 'error' : 'success' }, local.message.text) : null);
|
|
12753
|
+
}
|
|
12754
|
+
|
|
12378
12755
|
function ConnectionsPage(props) {
|
|
12379
12756
|
var ctx = props.ctx;
|
|
12380
12757
|
var locale = useLocale(ctx);
|
|
@@ -12435,6 +12812,7 @@ function rememberShowHidden(value) {
|
|
|
12435
12812
|
!sidebarAvailable ? h(Banner, { kind: 'warn' }, t('needsSidebar')) : null,
|
|
12436
12813
|
h(ThemeGroup, { t: t, locale: locale }),
|
|
12437
12814
|
h(EditorSettingsGroup, { t: t, locale: locale }),
|
|
12815
|
+
h(RevealSettingsGroup, { t: t, locale: locale }),
|
|
12438
12816
|
h(ExecSettingsGroup, {
|
|
12439
12817
|
t: t,
|
|
12440
12818
|
locale: locale,
|
|
@@ -12692,6 +13070,110 @@ function rememberShowHidden(value) {
|
|
|
12692
13070
|
}, 'dsh-linked-workspace: @ reference source');
|
|
12693
13071
|
}
|
|
12694
13072
|
|
|
13073
|
+
// ── placeholder hand-over ─────────────────────────────────────────────
|
|
13074
|
+
|
|
13075
|
+
// A remote workspace's session cwd is an EMPTY local placeholder: the files
|
|
13076
|
+
// only exist on the SSH host. So a relative link in the chat ("docs/plan.md")
|
|
13077
|
+
// is resolved against the placeholder and the native editor tries to read it
|
|
13078
|
+
// from the local disk, where it can never exist — the user gets a "file not
|
|
13079
|
+
// found" page for a file that is right there on the remote machine.
|
|
13080
|
+
//
|
|
13081
|
+
// Whenever the sidebar opens a tab bound to a path under
|
|
13082
|
+
// "remote-placeholders/<uuid>/", reopen that same file in our own remote tab
|
|
13083
|
+
// (which reads AND writes over SSH) and drop the broken one. Only the
|
|
13084
|
+
// placeholder prefix is claimed, so ordinary local files are untouched, and
|
|
13085
|
+
// our own tabs carry the resolved remote path — never a placeholder — so the
|
|
13086
|
+
// hand-over cannot repeat itself.
|
|
13087
|
+
var PLACEHOLDER_PATH = /[\\/]remote-placeholders[\\/]([^\\/]+)([\\/].*)$/i;
|
|
13088
|
+
|
|
13089
|
+
function installPlaceholderHandover(ctx) {
|
|
13090
|
+
var sidebar = sidebarService(ctx);
|
|
13091
|
+
if (!sidebar || typeof sidebar.nativePathTabs !== 'function' || typeof sidebar.subscribeState !== 'function') return;
|
|
13092
|
+
var handled = new Set();
|
|
13093
|
+
var known = null;
|
|
13094
|
+
var knownAt = 0;
|
|
13095
|
+
var scanning = false;
|
|
13096
|
+
|
|
13097
|
+
// The list is asked for at most once every 30 s, and once more (uncached)
|
|
13098
|
+
// when a placeholder path matches nothing — a workspace created while the
|
|
13099
|
+
// page is open then works without a reload.
|
|
13100
|
+
function remoteWorkspaces(fresh) {
|
|
13101
|
+
if (!fresh && known && Date.now() - knownAt < 30000) return Promise.resolve(known);
|
|
13102
|
+
return apiCall('remote_workspaces.list').then(function (result) {
|
|
13103
|
+
known = (result && result.workspaces) || [];
|
|
13104
|
+
knownAt = Date.now();
|
|
13105
|
+
return known;
|
|
13106
|
+
}).catch(function () { return []; });
|
|
13107
|
+
}
|
|
13108
|
+
|
|
13109
|
+
function placeholderOwnerOf(list, normalized) {
|
|
13110
|
+
for (var index = 0; index < list.length; index += 1) {
|
|
13111
|
+
var placeholder = String(list[index].placeholderPath || '').replace(/\\/g, '/').replace(/\/+$/, '');
|
|
13112
|
+
if (placeholder !== '' && normalized.indexOf(placeholder + '/') === 0) return list[index];
|
|
13113
|
+
}
|
|
13114
|
+
return null;
|
|
13115
|
+
}
|
|
13116
|
+
|
|
13117
|
+
function openOnRemote(owner, relative, scope, tab) {
|
|
13118
|
+
var remotePath = String(owner.remotePath || '').replace(/\/+$/, '') + '/' + relative;
|
|
13119
|
+
var source = { kind: 'remote', id: owner.id, name: owner.name };
|
|
13120
|
+
if (!openRemoteFileTab(sidebar, scope, source, remotePath)) return;
|
|
13121
|
+
try { sidebar.closeTab(tab.id, scope); } catch (error) { /* the page is gone already */ }
|
|
13122
|
+
}
|
|
13123
|
+
|
|
13124
|
+
function handOver(tab) {
|
|
13125
|
+
var normalized = String(tab && tab.path ? tab.path : '').replace(/\\/g, '/');
|
|
13126
|
+
var match = PLACEHOLDER_PATH.exec(normalized);
|
|
13127
|
+
if (!match) return;
|
|
13128
|
+
var relative = String(match[2] || '').replace(/^\/+/, '');
|
|
13129
|
+
// Directories and extension-less names are not ours to render.
|
|
13130
|
+
if (relative === '' || /\/$/.test(relative) || !/\.[^./]+$/.test(relative)) return;
|
|
13131
|
+
var key = String(tab.sessionId || '') + '|' + String(tab.id || '');
|
|
13132
|
+
if (handled.has(key)) return;
|
|
13133
|
+
// Tab ids are recycled, so the set only has to outlive the pass that
|
|
13134
|
+
// closed the page — keeping it bounded is enough.
|
|
13135
|
+
if (handled.size > 200) handled.clear();
|
|
13136
|
+
handled.add(key);
|
|
13137
|
+
var scope = { sessionId: tab.sessionId };
|
|
13138
|
+
if (tab.cwd) scope.cwd = tab.cwd;
|
|
13139
|
+
remoteWorkspaces(false).then(function (list) {
|
|
13140
|
+
var owner = placeholderOwnerOf(list, normalized);
|
|
13141
|
+
if (owner) return openOnRemote(owner, relative, scope, tab);
|
|
13142
|
+
return remoteWorkspaces(true).then(function (fresh) {
|
|
13143
|
+
var again = placeholderOwnerOf(fresh, normalized);
|
|
13144
|
+
if (again) openOnRemote(again, relative, scope, tab);
|
|
13145
|
+
});
|
|
13146
|
+
});
|
|
13147
|
+
}
|
|
13148
|
+
|
|
13149
|
+
function scan() {
|
|
13150
|
+
if (scanning) return;
|
|
13151
|
+
scanning = true;
|
|
13152
|
+
try {
|
|
13153
|
+
var tabs = sidebar.nativePathTabs() || [];
|
|
13154
|
+
for (var index = 0; index < tabs.length; index += 1) handOver(tabs[index]);
|
|
13155
|
+
} catch (error) {
|
|
13156
|
+
/* a sidebar without path tabs simply never hands over */
|
|
13157
|
+
} finally {
|
|
13158
|
+
scanning = false;
|
|
13159
|
+
}
|
|
13160
|
+
}
|
|
13161
|
+
|
|
13162
|
+
scan();
|
|
13163
|
+
// Native right-column tabs live in the sidebar's own adapter and never
|
|
13164
|
+
// reach the shared store, so `subscribeState` stays silent when one opens
|
|
13165
|
+
// — the interval is what actually catches them. It only runs the prefix
|
|
13166
|
+
// test, so a tick costs nothing when nothing is open.
|
|
13167
|
+
ctx.effect(function () {
|
|
13168
|
+
var stop = sidebar.subscribeState(scan);
|
|
13169
|
+
var timer = setInterval(scan, 1000);
|
|
13170
|
+
return function () {
|
|
13171
|
+
try { stop(); } catch (error) { /* already disposed */ }
|
|
13172
|
+
clearInterval(timer);
|
|
13173
|
+
};
|
|
13174
|
+
}, 'dsh-linked-workspace: placeholder hand-over');
|
|
13175
|
+
}
|
|
13176
|
+
|
|
12695
13177
|
// ── apply ──────────────────────────────────────────────────────────────
|
|
12696
13178
|
|
|
12697
13179
|
// `sessions` is a core client service (the sidebar shell injects it too):
|
|
@@ -12702,6 +13184,7 @@ function rememberShowHidden(value) {
|
|
|
12702
13184
|
function apply(ctx) {
|
|
12703
13185
|
ctx.effect(installStyles, 'dsh-linked-workspace: styles');
|
|
12704
13186
|
installReferenceTriggers(ctx);
|
|
13187
|
+
installPlaceholderHandover(ctx);
|
|
12705
13188
|
ctx.effect(function () {
|
|
12706
13189
|
var lastDark = null;
|
|
12707
13190
|
var sync = function () {
|