dsh-linked-workspace 0.10.0 → 0.11.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 +24 -0
- package/README.en.md +164 -162
- package/README.md +148 -173
- package/docs/API.md +47 -36
- package/docs/VERIFY.md +53 -17
- package/lib/client.js +945 -340
- package/lib/index.js +455 -246
- package/lib/ssh.js +20 -4
- package/locale/en.json +2 -2
- package/locale/zh.json +2 -2
- package/package.json +3 -4
package/lib/client.js
CHANGED
|
@@ -1947,7 +1947,10 @@ function attributeViolation(name, value, tagName) {
|
|
|
1947
1947
|
}
|
|
1948
1948
|
|
|
1949
1949
|
var TREE_TAB_TYPE = 'dsh-linked-workspace';
|
|
1950
|
-
|
|
1950
|
+
// Remote workspaces get their own page kind: the two modes show different
|
|
1951
|
+
// trees (local ⇄ remote pair vs. a plain remote root), so a session must be
|
|
1952
|
+
// able to hold both, and each one filters its own workspace list.
|
|
1953
|
+
var REMOTE_TREE_TAB_TYPE = 'dsh-remote-workspace';
|
|
1951
1954
|
// One tree page; a folder with 20k entries must not render 20k rows.
|
|
1952
1955
|
var TREE_PAGE_SIZE = 500;
|
|
1953
1956
|
var TREE_PAGE_MAX = 5000;
|
|
@@ -1957,10 +1960,16 @@ function attributeViolation(name, value, tagName) {
|
|
|
1957
1960
|
var REFRESH_MIN_INTERVAL_MS = 15000;
|
|
1958
1961
|
var linkedLocalKeys = new Set();
|
|
1959
1962
|
var linkedWorkspaceKeys = new Set();
|
|
1960
|
-
|
|
1963
|
+
// Remote workspaces run inside a placeholder directory, so they are matched
|
|
1964
|
+
// by that path (and by their DSH workspace id) instead of a local directory.
|
|
1965
|
+
var remotePlaceholderKeys = new Set();
|
|
1966
|
+
var remoteWorkspaceKeys = new Set();
|
|
1961
1967
|
var linkedTabDisposer = null;
|
|
1962
1968
|
var remoteTabDisposer = null;
|
|
1963
1969
|
var syncDirectoryTabsRef = null;
|
|
1970
|
+
// Set by the sidebar registration block so the availability refresh can ask
|
|
1971
|
+
// the sidebar to rebuild its "+" entries after the workspace lists change.
|
|
1972
|
+
var refreshTabVisibilityRef = null;
|
|
1964
1973
|
|
|
1965
1974
|
function linkedScopeKey(cwd) {
|
|
1966
1975
|
return String(cwd || '').replace(/\\/g, '/').replace(/\/+$/, '').toLowerCase();
|
|
@@ -1988,13 +1997,47 @@ function attributeViolation(name, value, tagName) {
|
|
|
1988
1997
|
return found;
|
|
1989
1998
|
}
|
|
1990
1999
|
|
|
2000
|
+
function isRemoteWorkspaceId(workspaceId) {
|
|
2001
|
+
return Boolean(workspaceId) && remoteWorkspaceKeys.has(String(workspaceId));
|
|
2002
|
+
}
|
|
2003
|
+
|
|
2004
|
+
function isRemoteScope(scope) {
|
|
2005
|
+
var key = linkedScopeKey(scope && scope.cwd);
|
|
2006
|
+
if (!key) return false;
|
|
2007
|
+
var found = false;
|
|
2008
|
+
remotePlaceholderKeys.forEach(function (placeholderKey) {
|
|
2009
|
+
if (found) return;
|
|
2010
|
+
if (key === placeholderKey || key.indexOf(placeholderKey + '/') === 0) found = true;
|
|
2011
|
+
});
|
|
2012
|
+
return found;
|
|
2013
|
+
}
|
|
2014
|
+
|
|
1991
2015
|
function dismissSettingsOverlay() {
|
|
2016
|
+
// 设置面板以 Escape 关闭;事件必须落在当前焦点元素上,直接派发到 window 不会触发它。
|
|
2017
|
+
function fire(target) {
|
|
2018
|
+
if (!target || typeof target.dispatchEvent !== 'function') return;
|
|
2019
|
+
target.dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape', code: 'Escape', keyCode: 27, which: 27, bubbles: true, cancelable: true }));
|
|
2020
|
+
}
|
|
1992
2021
|
try {
|
|
1993
|
-
|
|
2022
|
+
fire((typeof document !== 'undefined' && (document.activeElement || document.body)) || null);
|
|
2023
|
+
fire(typeof window !== 'undefined' ? window : null);
|
|
1994
2024
|
} catch (error) { /* keyboard unavailable */ }
|
|
1995
2025
|
}
|
|
1996
2026
|
|
|
1997
|
-
|
|
2027
|
+
// `dsh-better-sidebar` is an optional companion: everything that touches
|
|
2028
|
+
// its service goes through here, so a deployment without it keeps the
|
|
2029
|
+
// settings page, the directory flows and the agent tools working instead of
|
|
2030
|
+
// failing on a missing service lookup.
|
|
2031
|
+
function sidebarService(ctx) {
|
|
2032
|
+
if (!ctx || typeof ctx.get !== 'function') return undefined;
|
|
2033
|
+
try {
|
|
2034
|
+
return ctx.get('betterSidebar') || undefined;
|
|
2035
|
+
} catch (error) {
|
|
2036
|
+
return undefined;
|
|
2037
|
+
}
|
|
2038
|
+
}
|
|
2039
|
+
|
|
2040
|
+
function rememberDirectoryAvailability(links, remotes) {
|
|
1998
2041
|
var next = new Set();
|
|
1999
2042
|
var workspaceKeys = new Set();
|
|
2000
2043
|
(links || []).forEach(function (link) {
|
|
@@ -2004,18 +2047,32 @@ function attributeViolation(name, value, tagName) {
|
|
|
2004
2047
|
});
|
|
2005
2048
|
linkedLocalKeys = next;
|
|
2006
2049
|
linkedWorkspaceKeys = workspaceKeys;
|
|
2007
|
-
|
|
2050
|
+
|
|
2051
|
+
var placeholderKeys = new Set();
|
|
2052
|
+
var remoteKeys = new Set();
|
|
2053
|
+
(remotes || []).forEach(function (workspace) {
|
|
2054
|
+
var key = linkedScopeKey(workspace.placeholderPath);
|
|
2055
|
+
if (key) placeholderKeys.add(key);
|
|
2056
|
+
if (workspace.workspaceId) remoteKeys.add(String(workspace.workspaceId));
|
|
2057
|
+
});
|
|
2058
|
+
remotePlaceholderKeys = placeholderKeys;
|
|
2059
|
+
remoteWorkspaceKeys = remoteKeys;
|
|
2008
2060
|
}
|
|
2009
2061
|
|
|
2010
2062
|
function refreshDirectoryAvailability() {
|
|
2011
2063
|
return Promise.all([
|
|
2012
2064
|
apiCall('linked.list').catch(function () { return { links: [] }; }),
|
|
2013
|
-
apiCall('
|
|
2065
|
+
apiCall('remote_workspaces.list').catch(function () { return { workspaces: [] }; }),
|
|
2014
2066
|
]).then(function (results) {
|
|
2015
|
-
var links = results[0] && results[0].links
|
|
2016
|
-
var
|
|
2017
|
-
rememberDirectoryAvailability(links,
|
|
2018
|
-
|
|
2067
|
+
var links = (results[0] && results[0].links) || [];
|
|
2068
|
+
var remotes = (results[1] && results[1].workspaces) || [];
|
|
2069
|
+
rememberDirectoryAvailability(links, remotes);
|
|
2070
|
+
publishWorkspaceIcons(links, remotes);
|
|
2071
|
+
// The "+" menu decides visibility from this availability data, and the
|
|
2072
|
+
// sidebar only rebuilds its entries when something notifies it.
|
|
2073
|
+
if (refreshTabVisibilityRef !== null) {
|
|
2074
|
+
try { refreshTabVisibilityRef(); } catch (error) { /* ignore */ }
|
|
2075
|
+
}
|
|
2019
2076
|
});
|
|
2020
2077
|
}
|
|
2021
2078
|
function releaseRemoteFileSlot(kind) {
|
|
@@ -2067,14 +2124,12 @@ function attributeViolation(name, value, tagName) {
|
|
|
2067
2124
|
// ── i18n ────────────────────────────────────────────────────────────────
|
|
2068
2125
|
|
|
2069
2126
|
var ZH = {
|
|
2070
|
-
settingsNav: '
|
|
2071
|
-
title: '
|
|
2072
|
-
intro: '
|
|
2127
|
+
settingsNav: '联动工作区',
|
|
2128
|
+
title: '联动&远程工作区',
|
|
2129
|
+
intro: '把 SSH 连接变成工作区:联动工作区把本地目录与远端目录配对,远程工作区让会话直接运行在远端目录。会话都能读取、搜索和编辑远端文件。',
|
|
2073
2130
|
addWorkspace: '添加工作区',
|
|
2074
|
-
addRemoteDir: '添加远程目录',
|
|
2075
2131
|
addLinked: '添加联动工作区',
|
|
2076
2132
|
createLinked: '创建联动工作区',
|
|
2077
|
-
addAction: '添加',
|
|
2078
2133
|
addShort: '添加',
|
|
2079
2134
|
refresh: '刷新',
|
|
2080
2135
|
open: '打开',
|
|
@@ -2083,15 +2138,17 @@ function attributeViolation(name, value, tagName) {
|
|
|
2083
2138
|
remove: '移除',
|
|
2084
2139
|
confirmRemove: '确认移除',
|
|
2085
2140
|
removeHint: '只移除记录,不会删除远端文件。',
|
|
2086
|
-
emptyTitle: '
|
|
2087
|
-
emptyBody: '
|
|
2141
|
+
emptyTitle: '还没有可浏览的工作区',
|
|
2142
|
+
emptyBody: '先在「设置 → 连接」里创建联动工作区或远程工作区,左侧「添加工作区」里也能创建。',
|
|
2088
2143
|
emptyHint: '没有找到可用的 SSH 连接。请先在右侧栏的 SSH Tunnel 面板里添加主机。',
|
|
2089
2144
|
stepHost: '1. 选择 SSH 连接',
|
|
2090
2145
|
stepPath: '2. 远程目录',
|
|
2091
2146
|
stepLocalPath: '3. 本地目录',
|
|
2092
2147
|
stepName: '4. 工作区名称',
|
|
2148
|
+
remoteStepName: '3. 工作区名称',
|
|
2093
2149
|
pathPlaceholder: '/shared_data_ssd1/huangjh/project',
|
|
2094
2150
|
localPathPlaceholder: 'C:\\Users\\you\\projects\\demo',
|
|
2151
|
+
localPathRequired: '先选择或填写一个本地目录',
|
|
2095
2152
|
namePlaceholder: '留空则使用目录名',
|
|
2096
2153
|
browse: '浏览…',
|
|
2097
2154
|
browsing: '正在浏览…',
|
|
@@ -2107,6 +2164,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
2107
2164
|
connected: '已连接',
|
|
2108
2165
|
idle: '未连接',
|
|
2109
2166
|
errorState: '连接异常',
|
|
2167
|
+
disconnected: '连接已断开',
|
|
2110
2168
|
testOk: '连接正常',
|
|
2111
2169
|
testFail: '连接失败',
|
|
2112
2170
|
testRunning: '正在测试…',
|
|
@@ -2143,7 +2201,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
2143
2201
|
moveHint: '进入目标文件夹后点击「使用此目录」',
|
|
2144
2202
|
ctxMove: '移动到…',
|
|
2145
2203
|
noWorkspace: '远程工作区不存在,请重新添加。',
|
|
2146
|
-
noTarget: '
|
|
2204
|
+
noTarget: '没有可浏览的工作区。先在设置 → 连接中创建,或点击左侧「添加工作区」。',
|
|
2147
2205
|
treeEmpty: '空目录',
|
|
2148
2206
|
sourceManager: 'SSH 管理器',
|
|
2149
2207
|
sourceConfig: '~/.ssh/config',
|
|
@@ -2204,7 +2262,6 @@ function attributeViolation(name, value, tagName) {
|
|
|
2204
2262
|
sheetMore: '工作表较多,仅显示前 20 个',
|
|
2205
2263
|
noCredential: '缺少凭据',
|
|
2206
2264
|
sourceManagerShort: 'SSH',
|
|
2207
|
-
remoteGroup: '远程目录',
|
|
2208
2265
|
linkedGroup: '联动工作区',
|
|
2209
2266
|
linkedEmpty: '还没有联动工作区。联动工作区会把本地目录与远端目录配对,会话可直接编辑远端文件。',
|
|
2210
2267
|
linkedName: '联动工作区',
|
|
@@ -2281,10 +2338,6 @@ function attributeViolation(name, value, tagName) {
|
|
|
2281
2338
|
docPageOf: '第 {page} / {total} 页',
|
|
2282
2339
|
docExportDone: '已导出 PDF:{path}',
|
|
2283
2340
|
docPreviewFailed: '预览失败',
|
|
2284
|
-
remoteTabTitle: '远程目录',
|
|
2285
|
-
remoteTabDesc: '只读查看已添加的远程目录及其文件,不允许编辑。',
|
|
2286
|
-
remoteDirsTitle: '远程目录',
|
|
2287
|
-
remoteDirsHint: '直接浏览远端目录(只读)。',
|
|
2288
2341
|
linkedTitle: '联动工作区',
|
|
2289
2342
|
linkedHint: '本地目录与远端目录成对出现:DSH 会话在该本地目录中工作,并通过 linked_workspace 工具直接编辑远端文件。',
|
|
2290
2343
|
localFlow: '本地目录',
|
|
@@ -2307,6 +2360,32 @@ function attributeViolation(name, value, tagName) {
|
|
|
2307
2360
|
openInTab: '在标签中打开',
|
|
2308
2361
|
linkedBadge: '本地 ⇄ 远端',
|
|
2309
2362
|
linkedChip: '联动',
|
|
2363
|
+
remoteChip: '远程',
|
|
2364
|
+
remoteGroup: '远程工作区',
|
|
2365
|
+
remoteEmpty: '还没有远程工作区。远程工作区会让会话直接运行在 SSH 主机的目录里,本地不落任何项目文件。',
|
|
2366
|
+
remoteTitle: '远程工作区',
|
|
2367
|
+
remoteHint: '会话运行在远端目录:DSH 不在本地创建项目文件,模型通过 remote_workspace 与 linked_workspace 工具读写远端。',
|
|
2368
|
+
addRemote: '添加远程工作区',
|
|
2369
|
+
createRemote: '创建远程工作区',
|
|
2370
|
+
remoteTabTitle: '远程工作区目录',
|
|
2371
|
+
remoteTabDesc: '远程工作区的远端目录;点击文件在新标签页打开。',
|
|
2372
|
+
remotePlaceholderLabel: '本地占位目录',
|
|
2373
|
+
remotePlaceholderHint: '占位目录只用于把工作区注册进 DSH,不会同步任何远端文件;请不要在里面存放项目文件。',
|
|
2374
|
+
remoteCreateFailed: '创建远程工作区失败',
|
|
2375
|
+
remoteUpdateFailed: '重命名远程工作区失败',
|
|
2376
|
+
remoteRemoveFailed: '移除远程工作区失败',
|
|
2377
|
+
remoteRemoved: '已移除远程工作区',
|
|
2378
|
+
removeRemote: '移除远程工作区',
|
|
2379
|
+
remoteRemoveHint: '只移除记录与占位目录,不会删除远端文件。',
|
|
2380
|
+
remoteSessionHint: '在该工作区下新建会话即可直接使用远端目录。',
|
|
2381
|
+
flowRemote: '远程工作区',
|
|
2382
|
+
flowRemoteDesc: '会话运行在远端目录,本地只保留一个占位目录',
|
|
2383
|
+
localSideMissing: '该工作区没有本地目录',
|
|
2384
|
+
remoteWorkspacesFailed: '读取远程工作区失败',
|
|
2385
|
+
openTree: '打开目录树',
|
|
2386
|
+
testConnection: '测试连接',
|
|
2387
|
+
testFailed: '连接失败',
|
|
2388
|
+
rename: '重命名',
|
|
2310
2389
|
pathLocalShort: '本地',
|
|
2311
2390
|
pathRemoteShort: '远端',
|
|
2312
2391
|
flowTitle: '添加工作区',
|
|
@@ -2449,14 +2528,13 @@ function attributeViolation(name, value, tagName) {
|
|
|
2449
2528
|
};
|
|
2450
2529
|
|
|
2451
2530
|
var EN = {
|
|
2452
|
-
settingsNav: '
|
|
2453
|
-
title: '
|
|
2454
|
-
intro: 'Turn an
|
|
2531
|
+
settingsNav: 'Linked workspaces',
|
|
2532
|
+
title: 'Linked & remote workspaces',
|
|
2533
|
+
intro: 'Turn an SSH connection into a workspace: a linked workspace pairs a local folder with a remote folder, and a remote workspace runs sessions directly inside the remote folder. Either way sessions can read, search and edit remote files.',
|
|
2455
2534
|
addWorkspace: 'Add workspace',
|
|
2456
2535
|
addRemoteDir: 'Add remote directory',
|
|
2457
2536
|
addLinked: 'Add linked workspace',
|
|
2458
2537
|
createLinked: 'Create linked workspace',
|
|
2459
|
-
addAction: 'Add',
|
|
2460
2538
|
addShort: 'Add',
|
|
2461
2539
|
refresh: 'Refresh',
|
|
2462
2540
|
open: 'Open',
|
|
@@ -2465,15 +2543,17 @@ function attributeViolation(name, value, tagName) {
|
|
|
2465
2543
|
remove: 'Remove',
|
|
2466
2544
|
confirmRemove: 'Confirm remove',
|
|
2467
2545
|
removeHint: 'Removes the record only; remote files stay untouched.',
|
|
2468
|
-
emptyTitle: 'No
|
|
2469
|
-
emptyBody: '
|
|
2546
|
+
emptyTitle: 'No workspace to browse yet',
|
|
2547
|
+
emptyBody: 'Create a linked or remote workspace in Settings → Connections, or from “Add workspace” on the left.',
|
|
2470
2548
|
emptyHint: 'No SSH connections found. Add a host in the Side card’s SSH Tunnel panel first.',
|
|
2471
2549
|
stepHost: '1. Choose an SSH connection',
|
|
2472
2550
|
stepPath: '2. Remote directory',
|
|
2473
2551
|
stepLocalPath: '3. Local directory',
|
|
2474
2552
|
stepName: '4. Workspace name',
|
|
2553
|
+
remoteStepName: '3. Workspace name',
|
|
2475
2554
|
pathPlaceholder: '/home/you/project',
|
|
2476
2555
|
localPathPlaceholder: 'C:\\Users\\you\\projects\\demo',
|
|
2556
|
+
localPathRequired: 'Choose or enter a local directory first',
|
|
2477
2557
|
namePlaceholder: 'Defaults to the directory name',
|
|
2478
2558
|
browse: 'Browse…',
|
|
2479
2559
|
browsing: 'Browsing…',
|
|
@@ -2489,6 +2569,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
2489
2569
|
connected: 'Connected',
|
|
2490
2570
|
idle: 'Not connected',
|
|
2491
2571
|
errorState: 'Connection error',
|
|
2572
|
+
disconnected: 'Connection lost',
|
|
2492
2573
|
testOk: 'Connection OK',
|
|
2493
2574
|
testFail: 'Connection failed',
|
|
2494
2575
|
testRunning: 'Testing…',
|
|
@@ -2525,7 +2606,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
2525
2606
|
moveHint: 'Open the destination folder, then click “Use this directory”',
|
|
2526
2607
|
ctxMove: 'Move to…',
|
|
2527
2608
|
noWorkspace: 'This remote workspace no longer exists. Add it again.',
|
|
2528
|
-
noTarget: 'No
|
|
2609
|
+
noTarget: 'No workspace to browse. Create one in Settings → Connections, or click “Add workspace” on the left.',
|
|
2529
2610
|
treeEmpty: 'Empty directory',
|
|
2530
2611
|
sourceManager: 'SSH Manager',
|
|
2531
2612
|
sourceConfig: '~/.ssh/config',
|
|
@@ -2586,7 +2667,6 @@ function attributeViolation(name, value, tagName) {
|
|
|
2586
2667
|
sheetMore: 'Showing the first 20 worksheets only',
|
|
2587
2668
|
noCredential: 'No credentials',
|
|
2588
2669
|
sourceManagerShort: 'SSH',
|
|
2589
|
-
remoteGroup: 'Remote directories',
|
|
2590
2670
|
linkedGroup: 'Linked workspaces',
|
|
2591
2671
|
linkedEmpty: 'No linked workspaces yet. A linked workspace pairs a local folder with a remote folder so sessions can edit remote files directly.',
|
|
2592
2672
|
linkedName: 'Linked workspace',
|
|
@@ -2663,10 +2743,6 @@ function attributeViolation(name, value, tagName) {
|
|
|
2663
2743
|
docPageOf: 'Page {page} / {total}',
|
|
2664
2744
|
docExportDone: 'Exported PDF: {path}',
|
|
2665
2745
|
docPreviewFailed: 'Preview failed',
|
|
2666
|
-
remoteTabTitle: 'Remote directories',
|
|
2667
|
-
remoteTabDesc: 'Read-only view of configured remote directories and files; editing is disabled.',
|
|
2668
|
-
remoteDirsTitle: 'Remote directories',
|
|
2669
|
-
remoteDirsHint: 'Browse remote directories read-only (no local copy).',
|
|
2670
2746
|
linkedTitle: 'Linked workspaces',
|
|
2671
2747
|
linkedHint: 'A local folder paired with a remote folder: DSH sessions work in the local folder and edit remote files through the linked_workspace tool.',
|
|
2672
2748
|
localFlow: 'Local folder',
|
|
@@ -2689,6 +2765,32 @@ function attributeViolation(name, value, tagName) {
|
|
|
2689
2765
|
openInTab: 'Open in tab',
|
|
2690
2766
|
linkedBadge: 'Local ⇄ remote',
|
|
2691
2767
|
linkedChip: 'Linked',
|
|
2768
|
+
remoteChip: 'Remote',
|
|
2769
|
+
remoteGroup: 'Remote workspaces',
|
|
2770
|
+
remoteEmpty: 'No remote workspace yet. A remote workspace runs sessions directly inside an SSH host folder, so nothing is written to your machine.',
|
|
2771
|
+
remoteTitle: 'Remote workspaces',
|
|
2772
|
+
remoteHint: 'Sessions run in the remote folder: DSH creates no local project files, and the model reads and writes the remote side through the remote_workspace and linked_workspace tools.',
|
|
2773
|
+
addRemote: 'Add remote workspace',
|
|
2774
|
+
createRemote: 'Create remote workspace',
|
|
2775
|
+
remoteTabTitle: 'Remote workspace tree',
|
|
2776
|
+
remoteTabDesc: 'The remote folder of this remote workspace; click a file to open it in a new tab.',
|
|
2777
|
+
remotePlaceholderLabel: 'Local placeholder',
|
|
2778
|
+
remotePlaceholderHint: 'The placeholder only registers the workspace in DSH and never mirrors remote files; do not keep project files in it.',
|
|
2779
|
+
remoteCreateFailed: 'Could not create the remote workspace',
|
|
2780
|
+
remoteUpdateFailed: 'Could not rename the remote workspace',
|
|
2781
|
+
remoteRemoveFailed: 'Could not remove the remote workspace',
|
|
2782
|
+
remoteRemoved: 'Remote workspace removed',
|
|
2783
|
+
removeRemote: 'Remove remote workspace',
|
|
2784
|
+
remoteRemoveHint: 'Only the record and the placeholder are removed; remote files are untouched.',
|
|
2785
|
+
remoteSessionHint: 'Start a session in this workspace to work directly in the remote folder.',
|
|
2786
|
+
flowRemote: 'Remote workspace',
|
|
2787
|
+
flowRemoteDesc: 'Sessions run in the remote folder; only a placeholder stays local',
|
|
2788
|
+
localSideMissing: 'This workspace has no local folder',
|
|
2789
|
+
remoteWorkspacesFailed: 'Could not read remote workspaces',
|
|
2790
|
+
openTree: 'Open tree',
|
|
2791
|
+
testConnection: 'Test connection',
|
|
2792
|
+
testFailed: 'Connection failed',
|
|
2793
|
+
rename: 'Rename',
|
|
2692
2794
|
pathLocalShort: 'Local',
|
|
2693
2795
|
pathRemoteShort: 'Remote',
|
|
2694
2796
|
flowTitle: 'Add workspace',
|
|
@@ -3056,6 +3158,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
3056
3158
|
function scopeParams(scope) {
|
|
3057
3159
|
if (!scope) return {};
|
|
3058
3160
|
if (scope.kind === 'linked') return { linkedId: scope.id };
|
|
3161
|
+
if (scope.kind === 'remote') return { remoteId: scope.id };
|
|
3059
3162
|
return { workspaceId: scope.id };
|
|
3060
3163
|
}
|
|
3061
3164
|
|
|
@@ -3184,8 +3287,9 @@ function attributeViolation(name, value, tagName) {
|
|
|
3184
3287
|
'.rw-btn{display:inline-flex;align-items:center;justify-content:center;gap:6px;height:30px;padding:0 12px;border-radius:8px;border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-label-primary);font:inherit;font-size:13px;cursor:pointer;white-space:nowrap;transition:background .12s ease,border-color .12s ease,opacity .12s ease}',
|
|
3185
3288
|
'.rw-btn:hover{background:var(--dsw-alias-interactive-bg-hover,rgba(127,127,127,.12))}',
|
|
3186
3289
|
'.rw-btn:disabled{opacity:.5;cursor:not-allowed}',
|
|
3187
|
-
'.rw-btn-primary{background:var(--dsw-alias-brand-primary);border-color:transparent;color
|
|
3290
|
+
'.rw-btn-primary{background:var(--dsw-alias-brand-primary);border-color:transparent;color:var(--dsw-alias-bg-base)}',
|
|
3188
3291
|
'.rw-btn-primary:hover{filter:brightness(1.06)}',
|
|
3292
|
+
'body[data-ds-dark-theme] .rw-btn-primary{color:#000}',
|
|
3189
3293
|
'.rw-btn-ghost{background:transparent;border-color:transparent;color:var(--dsw-alias-label-secondary)}',
|
|
3190
3294
|
'.rw-btn-ghost:hover{background:var(--dsw-alias-interactive-bg-hover,rgba(127,127,127,.12))}',
|
|
3191
3295
|
'.rw-btn-danger{color:var(--dsw-alias-state-error-primary);border-color:color-mix(in srgb,var(--dsw-alias-state-error-primary) 40%,transparent)}',
|
|
@@ -3204,6 +3308,11 @@ function attributeViolation(name, value, tagName) {
|
|
|
3204
3308
|
'.rw-chip{display:inline-flex;align-items:center;gap:4px;padding:1px 8px;border-radius:999px;background:var(--dsw-alias-bg-layer-2);border:1px solid var(--dsw-alias-border-l1);color:var(--dsw-alias-label-secondary);font-size:11px;line-height:16px;white-space:nowrap}',
|
|
3205
3309
|
'.rw-chip-link{color:var(--dsw-alias-state-success-primary);border-color:color-mix(in srgb,var(--dsw-alias-state-success-primary) 45%,transparent)}',
|
|
3206
3310
|
'.rw-path{font-family:ui-monospace,"Cascadia Code",Consolas,monospace;font-size:12px;line-height:18px;color:var(--dsw-alias-label-secondary);word-break:break-all}',
|
|
3311
|
+
// Injected into the host's workspace hover preview, which always paints on
|
|
3312
|
+
// a fixed dark card, so these colours cannot follow the theme tokens.
|
|
3313
|
+
'.rw-hover-status{margin:1px 0 0;font-size:12px;line-height:18px;color:rgb(207,211,214)}',
|
|
3314
|
+
'.rw-hover-status.is-on{color:#3fb950}',
|
|
3315
|
+
'.rw-hover-status.is-off{color:#f85149}',
|
|
3207
3316
|
'.rw-meta{display:flex;align-items:center;gap:8px;flex-wrap:wrap;min-width:0}',
|
|
3208
3317
|
'.rw-meta-text{font-size:12px;line-height:18px;color:var(--dsw-alias-label-tertiary);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}',
|
|
3209
3318
|
'.rw-pair{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:8px}',
|
|
@@ -3318,7 +3427,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
3318
3427
|
'.rw-switch-track{position:relative;flex:none;width:30px;height:18px;border-radius:999px;background:var(--dsw-alias-bg-layer-1);border:1px solid var(--dsw-alias-border-l2);transition:background .12s ease,border-color .12s ease}',
|
|
3319
3428
|
'.rw-switch-thumb{position:absolute;top:2px;left:2px;width:12px;height:12px;border-radius:50%;background:var(--dsw-alias-label-tertiary);transition:transform .12s ease,background .12s ease}',
|
|
3320
3429
|
'.rw-switch input:checked + .rw-switch-track{background:color-mix(in srgb,var(--dsw-alias-brand-primary) 55%,transparent);border-color:transparent}',
|
|
3321
|
-
'.rw-switch input:checked + .rw-switch-track .rw-switch-thumb{transform:translateX(12px);background
|
|
3430
|
+
'.rw-switch input:checked + .rw-switch-track .rw-switch-thumb{transform:translateX(12px);background:var(--dsw-alias-bg-base)}',
|
|
3322
3431
|
'.rw-theme-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(168px,1fr));gap:10px}',
|
|
3323
3432
|
'.rw-theme-card{display:flex;flex-direction:column;gap:6px;padding:8px;border:1px solid var(--dsw-alias-border-l2);border-radius:10px;background:var(--dsw-alias-bg-layer-1);cursor:pointer;font:inherit;color:inherit;text-align:left}',
|
|
3324
3433
|
'.rw-theme-card.is-on{border-color:var(--dsw-alias-brand-primary);box-shadow:0 0 0 1px color-mix(in srgb,var(--dsw-alias-brand-primary) 45%,transparent)}',
|
|
@@ -3516,19 +3625,41 @@ function attributeViolation(name, value, tagName) {
|
|
|
3516
3625
|
};
|
|
3517
3626
|
}
|
|
3518
3627
|
|
|
3519
|
-
// ──
|
|
3628
|
+
// ── workspace row icons ────────────────────────────────────────────────
|
|
3520
3629
|
// DSH renders a fixed folder glyph for every workspace row; the sidebar
|
|
3521
3630
|
// gives plugins no per-row icon slot. This stylesheet swaps that glyph for
|
|
3522
|
-
//
|
|
3631
|
+
// the icon of the workspace kind (identified by the documented
|
|
3523
3632
|
// data-row-key attribute). If the host markup ever changes the selector
|
|
3524
3633
|
// simply stops matching and the folder glyph stays — a safe degradation.
|
|
3525
3634
|
|
|
3526
|
-
|
|
3527
|
-
|
|
3528
|
-
|
|
3529
|
-
|
|
3530
|
-
|
|
3531
|
-
|
|
3635
|
+
// Filled 1024-unit shapes, shared by the row masks and the JSX icons so a
|
|
3636
|
+
// workspace looks the same in the sidebar, the settings cards, the dialogs
|
|
3637
|
+
// and the sidebar "+" menu.
|
|
3638
|
+
// Linked workspace: two interlocking chain links (local ⇄ remote).
|
|
3639
|
+
var LINKED_ICON_PATHS = [
|
|
3640
|
+
'M861.866667 164.266667c-87.466667-87.466667-230.4-89.6-320-2.133334l-68.266667 68.266667c-12.8 12.8-12.8 32 0 44.8s32 12.8 44.8 0l68.266667-68.266667c64-61.866667 166.4-61.866667 230.4 2.133334 64 64 64 168.533333 2.133333 232.533333l-117.333333 119.466667c-34.133333 34.133333-81.066667 51.2-128 49.066666-46.933333-4.266667-91.733333-27.733333-119.466667-66.133333-10.666667-14.933333-29.866667-17.066667-44.8-6.4-14.933333 10.666667-17.066667 29.866667-6.4 44.8 40.533333 53.333333 100.266667 87.466667 166.4 91.733333h17.066667c59.733333 0 119.466667-23.466667 162.133333-68.266666l117.333333-119.466667c83.2-89.6 83.2-234.666667-4.266666-322.133333z',
|
|
3641
|
+
'M505.6 750.933333l-66.133333 68.266667c-64 61.866667-166.4 61.866667-230.4-2.133333-64-64-64-168.533333-2.133334-232.533334l117.333334-119.466666c34.133333-34.133333 81.066667-51.2 128-49.066667 46.933333 4.266667 91.733333 27.733333 119.466666 66.133333 10.666667 14.933333 29.866667 17.066667 44.8 6.4 14.933333-10.666667 17.066667-29.866667 6.4-44.8-40.533333-53.333333-100.266667-87.466667-166.4-91.733333-66.133333-4.266667-130.133333 19.2-177.066666 66.133333l-117.333334 119.466667c-85.333333 89.6-85.333333 234.666667 2.133334 322.133333 44.8 44.8 102.4 66.133333 162.133333 66.133334 57.6 0 115.2-21.333333 160-64l66.133333-68.266667c12.8-12.8 12.8-32 0-44.8-14.933333-10.666667-34.133333-10.666667-46.933333 2.133333z',
|
|
3642
|
+
];
|
|
3643
|
+
// Remote workspace: a display with an outbound arrow — the session itself
|
|
3644
|
+
// runs on the far side of the connection.
|
|
3645
|
+
var REMOTE_ICON_PATHS = [
|
|
3646
|
+
'M896 64a64 64 0 0 1 64 64v608a64 64 0 0 1-64 64H128a64 64 0 0 1-64-64V128a64 64 0 0 1 64-64h768z m-12.8 76.8H140.8v582.4h742.4V140.8z',
|
|
3647
|
+
'M320 883.2m38.4 0l307.2 0q38.4 0 38.4 38.4l0 0q0 38.4-38.4 38.4l-307.2 0q-38.4 0-38.4-38.4l0 0q0-38.4 38.4-38.4Z',
|
|
3648
|
+
'M262.4 224h243.2a38.4 38.4 0 1 1 0 76.8H351.808L586.24 535.168a38.4 38.4 0 0 1 4.032 49.536l-4.032 4.736-4.736 4.032a38.4 38.4 0 0 1-49.6-4.032L300.8 358.272 300.8 505.6a38.4 38.4 0 0 1-76.8 0V262.4a38.4 38.4 0 0 1 38.4-38.4z',
|
|
3649
|
+
];
|
|
3650
|
+
|
|
3651
|
+
var ICON_DISCONNECTED_COLOR = '#f85149';
|
|
3652
|
+
var ICON_BUSY_COLOR = '#2f81f7';
|
|
3653
|
+
|
|
3654
|
+
function iconMaskUrl(paths) {
|
|
3655
|
+
var markup = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" fill="black">'
|
|
3656
|
+
+ paths.map(function (path) { return '<path d="' + path + '"/>'; }).join('')
|
|
3657
|
+
+ '</svg>';
|
|
3658
|
+
return 'url("data:image/svg+xml,' + encodeURIComponent(markup) + '")';
|
|
3659
|
+
}
|
|
3660
|
+
|
|
3661
|
+
var LINKED_ICON_MASK = iconMaskUrl(LINKED_ICON_PATHS);
|
|
3662
|
+
var REMOTE_ICON_MASK = iconMaskUrl(REMOTE_ICON_PATHS);
|
|
3532
3663
|
|
|
3533
3664
|
function workspaceIconStyleTag() {
|
|
3534
3665
|
if (typeof document === 'undefined' || !document.head) return null;
|
|
@@ -3542,22 +3673,216 @@ function attributeViolation(name, value, tagName) {
|
|
|
3542
3673
|
return tag;
|
|
3543
3674
|
}
|
|
3544
3675
|
|
|
3545
|
-
function
|
|
3676
|
+
function stateOf(item) {
|
|
3677
|
+
var status = item && item.status;
|
|
3678
|
+
var state = status && status.state;
|
|
3679
|
+
return typeof state === 'string' && state !== '' ? state : 'idle';
|
|
3680
|
+
}
|
|
3681
|
+
|
|
3682
|
+
function isDisconnected(item) {
|
|
3683
|
+
return stateOf(item) === 'error';
|
|
3684
|
+
}
|
|
3685
|
+
|
|
3686
|
+
// Rows are React-rendered and get recreated on every sidebar update, so the
|
|
3687
|
+
// decorations have to be re-applied. A debounced observer handles that.
|
|
3688
|
+
var workspaceRowTips = [];
|
|
3689
|
+
var workspaceRowObserver = null;
|
|
3690
|
+
var workspaceRowTimer = null;
|
|
3691
|
+
var workspaceHoverRecords = {};
|
|
3692
|
+
|
|
3693
|
+
function applyWorkspaceRowTips() {
|
|
3694
|
+
if (typeof document === 'undefined') return;
|
|
3695
|
+
for (var index = 0; index < workspaceRowTips.length; index += 1) {
|
|
3696
|
+
var tip = workspaceRowTips[index];
|
|
3697
|
+
var rows = document.querySelectorAll('[data-row-key="workspace:' + tip.id + '"]');
|
|
3698
|
+
for (var rowIndex = 0; rowIndex < rows.length; rowIndex += 1) {
|
|
3699
|
+
var row = rows[rowIndex];
|
|
3700
|
+
if (tip.disconnected) row.setAttribute('data-lw-disconnected', 'true');
|
|
3701
|
+
else row.removeAttribute('data-lw-disconnected');
|
|
3702
|
+
// The native tooltip would pop up next to the hover preview card, so
|
|
3703
|
+
// the connection state is written into that card instead.
|
|
3704
|
+
if (row.hasAttribute('title')) row.removeAttribute('title');
|
|
3705
|
+
}
|
|
3706
|
+
}
|
|
3707
|
+
}
|
|
3708
|
+
|
|
3709
|
+
function queueWorkspaceRowTips() {
|
|
3710
|
+
if (typeof window === 'undefined' || workspaceRowTimer !== null) return;
|
|
3711
|
+
workspaceRowTimer = window.setTimeout(function () {
|
|
3712
|
+
workspaceRowTimer = null;
|
|
3713
|
+
applyWorkspaceRowTips();
|
|
3714
|
+
applyHoverCards();
|
|
3715
|
+
}, 200);
|
|
3716
|
+
if (workspaceRowTimer && typeof workspaceRowTimer.unref === 'function') workspaceRowTimer.unref();
|
|
3717
|
+
}
|
|
3718
|
+
|
|
3719
|
+
function watchWorkspaceRows() {
|
|
3720
|
+
if (workspaceRowObserver !== null) return;
|
|
3721
|
+
if (typeof MutationObserver === 'undefined' || typeof document === 'undefined' || !document.body) return;
|
|
3722
|
+
try {
|
|
3723
|
+
workspaceRowObserver = new MutationObserver(function () { queueWorkspaceRowTips(); });
|
|
3724
|
+
// Only structural changes: our own attribute writes must not retrigger it.
|
|
3725
|
+
workspaceRowObserver.observe(document.body, { childList: true, subtree: true });
|
|
3726
|
+
} catch (error) {
|
|
3727
|
+
workspaceRowObserver = null;
|
|
3728
|
+
}
|
|
3729
|
+
}
|
|
3730
|
+
|
|
3731
|
+
function statusLabel(t, item) {
|
|
3732
|
+
var state = stateOf(item);
|
|
3733
|
+
if (state === 'error') return item && item.status && item.status.reason === 'lost' ? t('disconnected') : t('errorState');
|
|
3734
|
+
return state === 'connected' ? t('connected') : t('idle');
|
|
3735
|
+
}
|
|
3736
|
+
|
|
3737
|
+
// ── workspace hover preview ────────────────────────────────────────────
|
|
3738
|
+
// The host renders the hover card itself (name / directory / created at)
|
|
3739
|
+
// inside a portal that lives outside our row, so it can only be enriched by
|
|
3740
|
+
// decorating it after it appears. Class names are hashed, hence the
|
|
3741
|
+
// substring selectors.
|
|
3742
|
+
var HOVER_CARD_QUERY = '[class*="hoverContent"]';
|
|
3743
|
+
var HOVER_LINE_ATTR = 'data-lw-hover-line';
|
|
3744
|
+
var hoverCardObserver = null;
|
|
3745
|
+
var hoverCardState = typeof WeakMap === 'function' ? new WeakMap() : null;
|
|
3746
|
+
|
|
3747
|
+
function clearHoverLines(card) {
|
|
3748
|
+
var injected = card.querySelectorAll('[' + HOVER_LINE_ATTR + ']');
|
|
3749
|
+
for (var index = 0; index < injected.length; index += 1) {
|
|
3750
|
+
var node = injected[index];
|
|
3751
|
+
if (node.parentNode) node.parentNode.removeChild(node);
|
|
3752
|
+
}
|
|
3753
|
+
}
|
|
3754
|
+
|
|
3755
|
+
function decorateHoverCard(card) {
|
|
3756
|
+
if (!card || !hoverCardState || !card.querySelector) return;
|
|
3757
|
+
var pathEl = card.querySelector('[class*="hoverPath"]');
|
|
3758
|
+
if (!pathEl) return;
|
|
3759
|
+
var known = hoverCardState.get(card);
|
|
3760
|
+
var current = (pathEl.textContent || '').trim();
|
|
3761
|
+
// Already decorated for this very content: nothing to do.
|
|
3762
|
+
if (known && known.rendered === current) return;
|
|
3763
|
+
// The host re-rendered the card for another workspace: drop our lines.
|
|
3764
|
+
if (known) clearHoverLines(card);
|
|
3765
|
+
var record = workspaceHoverRecords[linkedScopeKey(current)];
|
|
3766
|
+
if (!record || !record.remotePath) return;
|
|
3767
|
+
var t = makeT(readLocale());
|
|
3768
|
+
var remote = record.remotePath;
|
|
3769
|
+
var local = record.localPath || '';
|
|
3770
|
+
|
|
3771
|
+
var status = document.createElement('div');
|
|
3772
|
+
status.className = 'rw-hover-status' + (record.disconnected ? ' is-off' : record.connected ? ' is-on' : '');
|
|
3773
|
+
status.setAttribute(HOVER_LINE_ATTR, '1');
|
|
3774
|
+
status.textContent = record.status;
|
|
3775
|
+
var titleEl = card.querySelector('[class*="hoverTitle"]');
|
|
3776
|
+
var anchor = titleEl || pathEl;
|
|
3777
|
+
anchor.parentNode.insertBefore(status, anchor.nextSibling);
|
|
3778
|
+
|
|
3779
|
+
if (record.kind === 'linked' && local !== '') {
|
|
3780
|
+
pathEl.textContent = t('pathRemoteShort') + ' ' + remote;
|
|
3781
|
+
var localEl = pathEl.cloneNode(false);
|
|
3782
|
+
localEl.setAttribute(HOVER_LINE_ATTR, '1');
|
|
3783
|
+
localEl.textContent = t('pathLocalShort') + ' ' + local;
|
|
3784
|
+
pathEl.parentNode.insertBefore(localEl, pathEl.nextSibling);
|
|
3785
|
+
} else {
|
|
3786
|
+
pathEl.textContent = remote;
|
|
3787
|
+
}
|
|
3788
|
+
|
|
3789
|
+
// The card doubles as a "copy this path" button; keep its label in sync so
|
|
3790
|
+
// a remote workspace copies the remote directory, not the placeholder.
|
|
3791
|
+
var host = card.parentElement;
|
|
3792
|
+
var label = host && host.getAttribute ? host.getAttribute('aria-label') : null;
|
|
3793
|
+
if (label && current !== '' && label.indexOf(current) !== -1) {
|
|
3794
|
+
host.setAttribute('aria-label', label.split(current).join(remote));
|
|
3795
|
+
}
|
|
3796
|
+
|
|
3797
|
+
hoverCardState.set(card, { rendered: (pathEl.textContent || '').trim() });
|
|
3798
|
+
}
|
|
3799
|
+
|
|
3800
|
+
function applyHoverCards() {
|
|
3801
|
+
if (typeof document === 'undefined') return;
|
|
3802
|
+
var cards = document.querySelectorAll(HOVER_CARD_QUERY);
|
|
3803
|
+
for (var index = 0; index < cards.length; index += 1) decorateHoverCard(cards[index]);
|
|
3804
|
+
}
|
|
3805
|
+
|
|
3806
|
+
function watchHoverCards() {
|
|
3807
|
+
if (hoverCardObserver !== null) return;
|
|
3808
|
+
if (typeof MutationObserver === 'undefined' || typeof document === 'undefined' || !document.body) return;
|
|
3809
|
+
try {
|
|
3810
|
+
hoverCardObserver = new MutationObserver(function (records) {
|
|
3811
|
+
for (var index = 0; index < records.length; index += 1) {
|
|
3812
|
+
var added = records[index].addedNodes;
|
|
3813
|
+
for (var nodeIndex = 0; nodeIndex < added.length; nodeIndex += 1) {
|
|
3814
|
+
var node = added[nodeIndex];
|
|
3815
|
+
if (!node || node.nodeType !== 1) continue;
|
|
3816
|
+
if (node.closest) {
|
|
3817
|
+
var outer = node.closest(HOVER_CARD_QUERY);
|
|
3818
|
+
if (outer) decorateHoverCard(outer);
|
|
3819
|
+
}
|
|
3820
|
+
if (node.querySelectorAll) {
|
|
3821
|
+
var inner = node.querySelectorAll(HOVER_CARD_QUERY);
|
|
3822
|
+
for (var innerIndex = 0; innerIndex < inner.length; innerIndex += 1) decorateHoverCard(inner[innerIndex]);
|
|
3823
|
+
}
|
|
3824
|
+
}
|
|
3825
|
+
}
|
|
3826
|
+
});
|
|
3827
|
+
hoverCardObserver.observe(document.body, { childList: true, subtree: true });
|
|
3828
|
+
} catch (error) {
|
|
3829
|
+
hoverCardObserver = null;
|
|
3830
|
+
}
|
|
3831
|
+
}
|
|
3832
|
+
|
|
3833
|
+
function publishRowTips(entries) {
|
|
3834
|
+
var t = makeT(readLocale());
|
|
3835
|
+
var records = {};
|
|
3836
|
+
workspaceRowTips = entries.map(function (entry) {
|
|
3837
|
+
var item = entry.item || {};
|
|
3838
|
+
var linked = entry.kind === 'linked';
|
|
3839
|
+
var key = linkedScopeKey(linked ? item.localPath : item.placeholderPath);
|
|
3840
|
+
if (key !== '') {
|
|
3841
|
+
records[key] = {
|
|
3842
|
+
kind: entry.kind,
|
|
3843
|
+
name: item.name,
|
|
3844
|
+
remotePath: item.remotePath || '',
|
|
3845
|
+
localPath: linked ? (item.localPath || '') : '',
|
|
3846
|
+
status: statusLabel(t, item),
|
|
3847
|
+
connected: stateOf(item) === 'connected',
|
|
3848
|
+
disconnected: isDisconnected(item),
|
|
3849
|
+
};
|
|
3850
|
+
}
|
|
3851
|
+
return { id: entry.id, disconnected: isDisconnected(item) };
|
|
3852
|
+
});
|
|
3853
|
+
workspaceHoverRecords = records;
|
|
3854
|
+
applyWorkspaceRowTips();
|
|
3855
|
+
watchWorkspaceRows();
|
|
3856
|
+
watchHoverCards();
|
|
3857
|
+
applyHoverCards();
|
|
3858
|
+
}
|
|
3859
|
+
|
|
3860
|
+
function publishWorkspaceIcons(links, remotes) {
|
|
3546
3861
|
var tag = workspaceIconStyleTag();
|
|
3547
3862
|
if (!tag) return;
|
|
3548
|
-
var
|
|
3549
|
-
|
|
3550
|
-
|
|
3863
|
+
var entries = [];
|
|
3864
|
+
(links || []).forEach(function (link) {
|
|
3865
|
+
entries.push({ item: link, id: link && link.workspaceId, mask: LINKED_ICON_MASK, running: Boolean(link.running), kind: 'linked' });
|
|
3866
|
+
});
|
|
3867
|
+
(remotes || []).forEach(function (workspace) {
|
|
3868
|
+
entries.push({ item: workspace, id: workspace && workspace.workspaceId, mask: REMOTE_ICON_MASK, running: false, kind: 'remote' });
|
|
3869
|
+
});
|
|
3870
|
+
var rules = entries.map(function (entry) {
|
|
3871
|
+
var id = entry.id ? String(entry.id).replace(/[^0-9a-zA-Z-]/g, '') : '';
|
|
3551
3872
|
if (id === '') return '';
|
|
3552
3873
|
var row = '[data-row-key="workspace:' + id + '"] > span:first-child';
|
|
3553
3874
|
var rule = row + '{display:inline-flex;align-items:center;justify-content:center;flex:none;}'
|
|
3554
3875
|
+ row + ' svg{display:none!important;}'
|
|
3555
3876
|
+ row + '::before{content:"";display:block;width:14px;height:14px;background:currentColor;'
|
|
3556
|
-
+ '-webkit-mask:' + mask + ' center/contain no-repeat;mask:' + mask + ' center/contain no-repeat;}';
|
|
3557
|
-
|
|
3877
|
+
+ '-webkit-mask:' + entry.mask + ' center/contain no-repeat;mask:' + entry.mask + ' center/contain no-repeat;}';
|
|
3878
|
+
// A dropped SSH connection turns the row icon red; a running mirror
|
|
3879
|
+
// sync keeps the existing accent highlight.
|
|
3880
|
+
if (isDisconnected(entry.item)) rule += row + '::before{background:' + ICON_DISCONNECTED_COLOR + '!important}';
|
|
3881
|
+
else if (entry.running) rule += row + '::before{background:' + ICON_BUSY_COLOR + '!important}';
|
|
3558
3882
|
return rule;
|
|
3559
3883
|
}).filter(function (rule) { return rule !== ''; });
|
|
3560
3884
|
tag.textContent = rules.join('\n');
|
|
3885
|
+
publishRowTips(entries);
|
|
3561
3886
|
}
|
|
3562
3887
|
|
|
3563
3888
|
// ── icons (16px outline set, currentColor) ─────────────────────────────
|
|
@@ -3576,6 +3901,28 @@ function attributeViolation(name, value, tagName) {
|
|
|
3576
3901
|
return h('svg', props, children);
|
|
3577
3902
|
}
|
|
3578
3903
|
|
|
3904
|
+
// Filled workspace-kind icons. The supplied shapes are drawn on a 1024 grid
|
|
3905
|
+
// and carry no stroke, so they are rendered apart from the outline set.
|
|
3906
|
+
function solidIcon(size, paths) {
|
|
3907
|
+
return h('svg', {
|
|
3908
|
+
width: size,
|
|
3909
|
+
height: size,
|
|
3910
|
+
viewBox: '0 0 1024 1024',
|
|
3911
|
+
fill: 'currentColor',
|
|
3912
|
+
xmlns: 'http://www.w3.org/2000/svg',
|
|
3913
|
+
'aria-hidden': 'true',
|
|
3914
|
+
focusable: 'false',
|
|
3915
|
+
}, paths.map(function (path, index) { return h('path', { key: index, d: path }); }));
|
|
3916
|
+
}
|
|
3917
|
+
|
|
3918
|
+
function IconLinkedWorkspace(size) {
|
|
3919
|
+
return solidIcon(size || 14, LINKED_ICON_PATHS);
|
|
3920
|
+
}
|
|
3921
|
+
|
|
3922
|
+
function IconRemoteWorkspace(size) {
|
|
3923
|
+
return solidIcon(size || 14, REMOTE_ICON_PATHS);
|
|
3924
|
+
}
|
|
3925
|
+
|
|
3579
3926
|
function IconChevron(size) {
|
|
3580
3927
|
return svg(size || 14, h('path', {
|
|
3581
3928
|
d: 'm6 3 5 5-5 5', stroke: 'currentColor', strokeWidth: 1.6,
|
|
@@ -3755,14 +4102,14 @@ function attributeViolation(name, value, tagName) {
|
|
|
3755
4102
|
// ── data hooks ─────────────────────────────────────────────────────────
|
|
3756
4103
|
|
|
3757
4104
|
function useRemoteData(ctx) {
|
|
3758
|
-
var dataState = useState({ loading: true, hosts: [],
|
|
4105
|
+
var dataState = useState({ loading: true, hosts: [], remotes: [], links: [], error: null, hostError: null, linkError: null });
|
|
3759
4106
|
var data = dataState[0];
|
|
3760
4107
|
var setData = dataState[1];
|
|
3761
4108
|
var alive = useRef(true);
|
|
3762
4109
|
|
|
3763
4110
|
var load = useCallback(function () {
|
|
3764
4111
|
var jobs = [
|
|
3765
|
-
apiCall('
|
|
4112
|
+
apiCall('remote_workspaces.list').then(function (result) { return { remotes: result.workspaces || [] }; }),
|
|
3766
4113
|
apiCall('hosts.list').then(function (result) { return { hosts: result.hosts || [] }; }),
|
|
3767
4114
|
apiCall('linked.list').then(function (result) { return { links: result.links || [] }; }),
|
|
3768
4115
|
];
|
|
@@ -3770,22 +4117,22 @@ function attributeViolation(name, value, tagName) {
|
|
|
3770
4117
|
return promise.then(function (value) { return { ok: true, value: value }; }, function (error) { return { ok: false, error: error }; });
|
|
3771
4118
|
})).then(function (results) {
|
|
3772
4119
|
if (!alive.current) return;
|
|
3773
|
-
var
|
|
4120
|
+
var remotesResult = results[0];
|
|
3774
4121
|
var hostsResult = results[1];
|
|
3775
4122
|
var linksResult = results[2];
|
|
3776
4123
|
setData(function (previous) {
|
|
3777
4124
|
return {
|
|
3778
4125
|
loading: false,
|
|
3779
|
-
|
|
4126
|
+
remotes: remotesResult.ok ? remotesResult.value.remotes : previous.remotes,
|
|
3780
4127
|
hosts: hostsResult.ok ? hostsResult.value.hosts : previous.hosts,
|
|
3781
4128
|
links: linksResult.ok ? linksResult.value.links : previous.links,
|
|
3782
|
-
error:
|
|
4129
|
+
error: remotesResult.ok ? null : remotesResult.error,
|
|
3783
4130
|
hostError: hostsResult.ok ? null : hostsResult.error,
|
|
3784
4131
|
linkError: linksResult.ok ? null : linksResult.error,
|
|
3785
4132
|
};
|
|
3786
4133
|
});
|
|
3787
|
-
rememberDirectoryAvailability(linksResult.ok ? linksResult.value.links : [],
|
|
3788
|
-
|
|
4134
|
+
rememberDirectoryAvailability(linksResult.ok ? linksResult.value.links : [], remotesResult.ok ? remotesResult.value.remotes : []);
|
|
4135
|
+
publishWorkspaceIcons(linksResult.ok ? linksResult.value.links : [], remotesResult.ok ? remotesResult.value.remotes : []);
|
|
3789
4136
|
});
|
|
3790
4137
|
}, []);
|
|
3791
4138
|
|
|
@@ -3804,13 +4151,28 @@ function attributeViolation(name, value, tagName) {
|
|
|
3804
4151
|
|
|
3805
4152
|
// ── small building blocks ───────────────────────────────────────────────
|
|
3806
4153
|
|
|
4154
|
+
function statusTitle(t, item) {
|
|
4155
|
+
var status = (item && item.status) || {};
|
|
4156
|
+
if (status.state === 'connected') {
|
|
4157
|
+
return typeof status.latencyMs === 'number' ? t('connected') + ' · ' + status.latencyMs + ' ms' : t('connected');
|
|
4158
|
+
}
|
|
4159
|
+
if (status.state === 'error') {
|
|
4160
|
+
if (status.reason === 'lost') return t('disconnected');
|
|
4161
|
+
return status.message ? t('errorState') + ' · ' + status.message : t('errorState');
|
|
4162
|
+
}
|
|
4163
|
+
return t('idle');
|
|
4164
|
+
}
|
|
4165
|
+
|
|
3807
4166
|
function StatusPill(props) {
|
|
3808
4167
|
var t = props.t;
|
|
3809
4168
|
var status = props.status || { state: 'idle' };
|
|
3810
4169
|
var cls = status.state === 'connected' ? 'rw-dot-ok' : status.state === 'error' ? 'rw-dot-error' : '';
|
|
3811
|
-
var label = status.state === 'connected'
|
|
3812
|
-
|
|
3813
|
-
|
|
4170
|
+
var label = status.state === 'connected'
|
|
4171
|
+
? t('connected')
|
|
4172
|
+
: status.state === 'error'
|
|
4173
|
+
? (status.reason === 'lost' ? t('disconnected') : t('errorState'))
|
|
4174
|
+
: t('idle');
|
|
4175
|
+
return h('span', { className: 'rw-chip', title: statusTitle(t, props) || label },
|
|
3814
4176
|
h('span', { className: 'rw-dot ' + cls }),
|
|
3815
4177
|
label);
|
|
3816
4178
|
}
|
|
@@ -4438,7 +4800,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
4438
4800
|
var local = props.local === true;
|
|
4439
4801
|
var readOnly = props.readOnly === true;
|
|
4440
4802
|
var filePath = props.path;
|
|
4441
|
-
var sidebar = ctx
|
|
4803
|
+
var sidebar = sidebarService(ctx);
|
|
4442
4804
|
var settings = useRuntimeSettings();
|
|
4443
4805
|
var theme = getTheme(resolveEditorTheme(settings));
|
|
4444
4806
|
var language = languageOf(filePath);
|
|
@@ -4890,13 +5252,14 @@ function attributeViolation(name, value, tagName) {
|
|
|
4890
5252
|
|
|
4891
5253
|
function sourceScopeOf(source) {
|
|
4892
5254
|
if (source && source.kind === 'linked') return { kind: 'linked', id: source.id };
|
|
5255
|
+
if (source && source.kind === 'remote') return { kind: 'remote', id: source.id };
|
|
4893
5256
|
return { kind: 'workspace', id: source ? source.id : '' };
|
|
4894
5257
|
}
|
|
4895
5258
|
|
|
4896
5259
|
function sourceMetaOf(source) {
|
|
4897
|
-
|
|
4898
|
-
|
|
4899
|
-
|
|
5260
|
+
if (source && source.kind === 'linked') return { linkedId: source.id, linkedName: source.name };
|
|
5261
|
+
if (source && source.kind === 'remote') return { remoteId: source.id, remoteName: source.name };
|
|
5262
|
+
return { workspaceId: source ? source.id : undefined, workspaceName: source ? source.name : undefined };
|
|
4900
5263
|
}
|
|
4901
5264
|
|
|
4902
5265
|
function workspaceRelativePath(rootPath, filePath) {
|
|
@@ -5975,7 +6338,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
5975
6338
|
var remoteOnly = props.variant === 'remote';
|
|
5976
6339
|
var data = useRemoteData(ctx);
|
|
5977
6340
|
var settings = useRuntimeSettings();
|
|
5978
|
-
var sidebar = ctx
|
|
6341
|
+
var sidebar = sidebarService(ctx);
|
|
5979
6342
|
var selectedState = useState('');
|
|
5980
6343
|
var selectedKey = selectedState[0];
|
|
5981
6344
|
var setSelectedKey = selectedState[1];
|
|
@@ -6045,46 +6408,52 @@ function attributeViolation(name, value, tagName) {
|
|
|
6045
6408
|
var pinnedLinkedId = tabMeta.linkedId ? String(tabMeta.linkedId) : '';
|
|
6046
6409
|
var pinnedRemoteId = tabMeta.remoteId ? String(tabMeta.remoteId) : '';
|
|
6047
6410
|
var sources = useMemo(function () {
|
|
6048
|
-
var
|
|
6411
|
+
var pinned = remoteOnly ? pinnedRemoteId : pinnedLinkedId;
|
|
6049
6412
|
var scopeKey = linkedScopeKey(scope && scope.cwd);
|
|
6050
|
-
|
|
6051
|
-
|
|
6052
|
-
|
|
6053
|
-
|
|
6054
|
-
|
|
6055
|
-
|
|
6056
|
-
|
|
6057
|
-
|
|
6058
|
-
|
|
6059
|
-
|
|
6060
|
-
|
|
6061
|
-
host: link.host,
|
|
6062
|
-
username: link.username,
|
|
6063
|
-
hostName: link.hostName,
|
|
6064
|
-
mirror: link.mirror,
|
|
6065
|
-
status: link.status,
|
|
6066
|
-
});
|
|
6067
|
-
});
|
|
6068
|
-
} else {
|
|
6069
|
-
(data.data.workspaces || []).forEach(function (workspace) {
|
|
6070
|
-
if (pinnedRemoteId && String(workspace.id) !== pinnedRemoteId) return;
|
|
6071
|
-
list.push({
|
|
6072
|
-
key: 'workspace:' + workspace.id,
|
|
6073
|
-
kind: 'workspace',
|
|
6074
|
-
id: workspace.id,
|
|
6075
|
-
name: workspace.name,
|
|
6413
|
+
var all = (remoteOnly ? (data.data.remotes || []) : (data.data.links || []));
|
|
6414
|
+
function pathOf(item) {
|
|
6415
|
+
return remoteOnly ? item.placeholderPath : item.localPath;
|
|
6416
|
+
}
|
|
6417
|
+
function toSource(item) {
|
|
6418
|
+
if (remoteOnly) {
|
|
6419
|
+
return {
|
|
6420
|
+
key: 'remote:' + item.id,
|
|
6421
|
+
kind: 'remote',
|
|
6422
|
+
id: item.id,
|
|
6423
|
+
name: item.name,
|
|
6076
6424
|
localPath: null,
|
|
6077
|
-
|
|
6078
|
-
|
|
6079
|
-
|
|
6080
|
-
|
|
6425
|
+
placeholderPath: item.placeholderPath,
|
|
6426
|
+
remotePath: item.remotePath,
|
|
6427
|
+
host: item.host,
|
|
6428
|
+
username: item.username,
|
|
6429
|
+
hostName: item.hostName,
|
|
6081
6430
|
mirror: false,
|
|
6082
|
-
status:
|
|
6083
|
-
}
|
|
6084
|
-
}
|
|
6431
|
+
status: item.status,
|
|
6432
|
+
};
|
|
6433
|
+
}
|
|
6434
|
+
return {
|
|
6435
|
+
key: 'linked:' + item.id,
|
|
6436
|
+
kind: 'linked',
|
|
6437
|
+
id: item.id,
|
|
6438
|
+
name: item.name,
|
|
6439
|
+
localPath: item.localPath,
|
|
6440
|
+
remotePath: item.remotePath,
|
|
6441
|
+
host: item.host,
|
|
6442
|
+
username: item.username,
|
|
6443
|
+
hostName: item.hostName,
|
|
6444
|
+
mirror: item.mirror,
|
|
6445
|
+
status: item.status,
|
|
6446
|
+
};
|
|
6085
6447
|
}
|
|
6086
|
-
|
|
6087
|
-
|
|
6448
|
+
var matched = all.filter(function (item) {
|
|
6449
|
+
if (pinned) return String(item.id) === pinned;
|
|
6450
|
+
if (!scopeKey) return true;
|
|
6451
|
+
return linkedScopeKey(pathOf(item)) === scopeKey;
|
|
6452
|
+
});
|
|
6453
|
+
// 标签页也可能从起始页或设置页直接打开:当前会话不属于任何联动/远程工作区时,
|
|
6454
|
+
// 列出全部,而不是让标签页空着。
|
|
6455
|
+
return (matched.length === 0 && !pinned ? all : matched).map(toSource);
|
|
6456
|
+
}, [data.data.links, data.data.remotes, remoteOnly, scope && scope.cwd, pinnedLinkedId, pinnedRemoteId]);
|
|
6088
6457
|
|
|
6089
6458
|
var selected = useMemo(function () {
|
|
6090
6459
|
return sources.filter(function (source) { return source.key === selectedKey; })[0] || sources[0] || null;
|
|
@@ -6238,10 +6607,12 @@ function attributeViolation(name, value, tagName) {
|
|
|
6238
6607
|
|
|
6239
6608
|
function openTerminal(side, atPath) {
|
|
6240
6609
|
if (!selected) return;
|
|
6241
|
-
|
|
6610
|
+
if (side === 'local' && selected.kind !== 'linked') {
|
|
6611
|
+
showNotice('info', t('localSideMissing'));
|
|
6612
|
+
return;
|
|
6613
|
+
}
|
|
6614
|
+
var request = Object.assign({ side: side }, scopeParams(selected));
|
|
6242
6615
|
if (typeof atPath === 'string' && atPath !== '') request.path = atPath;
|
|
6243
|
-
if (selected.kind === 'linked') request.linkedId = selected.id;
|
|
6244
|
-
else request.workspaceId = selected.id;
|
|
6245
6616
|
apiCall('terminal.open', request).then(function () {
|
|
6246
6617
|
showNotice('success', t('terminalOpened'));
|
|
6247
6618
|
}).catch(function (error) {
|
|
@@ -7073,7 +7444,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
7073
7444
|
h(TreeSection, {
|
|
7074
7445
|
key: 'remote:' + selected.key + ':' + version + ':' + (showHidden ? 'h' : 's'),
|
|
7075
7446
|
title: t('remoteTree'),
|
|
7076
|
-
icon:
|
|
7447
|
+
icon: IconRemoteWorkspace(11),
|
|
7077
7448
|
}, h(TreePanel, {
|
|
7078
7449
|
key: 'remote:' + selected.key + ':' + version + ':' + (showHidden ? 'h' : 's'),
|
|
7079
7450
|
kind: 'remote',
|
|
@@ -7243,9 +7614,9 @@ function attributeViolation(name, value, tagName) {
|
|
|
7243
7614
|
key: source.key,
|
|
7244
7615
|
type: 'button',
|
|
7245
7616
|
className: 'rw-chip-btn' + (selected.key === source.key ? ' is-on' : ''),
|
|
7246
|
-
title: source.name + ' · ' + source.remotePath,
|
|
7617
|
+
title: source.name + ' · ' + source.remotePath + ' · ' + statusTitle(t, source),
|
|
7247
7618
|
onClick: function () { setSelectedKey(source.key); },
|
|
7248
|
-
}, source.kind === 'linked' ?
|
|
7619
|
+
}, source.kind === 'linked' ? IconLinkedWorkspace(11) : source.kind === 'remote' ? IconRemoteWorkspace(11) : IconFolderTree(11), h('span', { style: { overflow: 'hidden', textOverflow: 'ellipsis' } }, source.name));
|
|
7249
7620
|
}))
|
|
7250
7621
|
: null,
|
|
7251
7622
|
info,
|
|
@@ -7299,7 +7670,9 @@ function attributeViolation(name, value, tagName) {
|
|
|
7299
7670
|
var meta = tab && tab.meta ? tab.meta : {};
|
|
7300
7671
|
var scope = meta.linkedId
|
|
7301
7672
|
? { kind: 'linked', id: meta.linkedId }
|
|
7302
|
-
:
|
|
7673
|
+
: meta.remoteId
|
|
7674
|
+
? { kind: 'remote', id: meta.remoteId }
|
|
7675
|
+
: { kind: 'workspace', id: meta.workspaceId };
|
|
7303
7676
|
var filePath = tab && tab.path ? tab.path : '';
|
|
7304
7677
|
return h('div', { className: 'rw-editor-pane' },
|
|
7305
7678
|
h(RemoteFileEditor, {
|
|
@@ -7520,8 +7893,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
7520
7893
|
}
|
|
7521
7894
|
|
|
7522
7895
|
function listRequest(path, offset) {
|
|
7523
|
-
return Object.assign({ path: path, limit: TREE_PAGE_SIZE, offset: offset },
|
|
7524
|
-
source.kind === 'linked' ? { linkedId: source.id } : { workspaceId: source.id });
|
|
7896
|
+
return Object.assign({ path: path, limit: TREE_PAGE_SIZE, offset: offset }, scopeParams(source));
|
|
7525
7897
|
}
|
|
7526
7898
|
|
|
7527
7899
|
function load(path) {
|
|
@@ -7618,13 +7990,15 @@ function attributeViolation(name, value, tagName) {
|
|
|
7618
7990
|
className: 'rw-tree-ws-head',
|
|
7619
7991
|
onClick: function () { setOpen(function (value) { return !value; }); },
|
|
7620
7992
|
'aria-expanded': open,
|
|
7993
|
+
title: source.name + ' · ' + statusTitle(t, source),
|
|
7621
7994
|
},
|
|
7622
7995
|
h('span', { className: 'rw-chevron' + (open ? ' is-open' : '') }, IconChevron(12)),
|
|
7623
7996
|
h('span', { className: 'rw-icon-chip' + (source.kind === 'linked' ? ' rw-icon-chip-link' : ''), style: { width: 24, height: 24, borderRadius: 7 } },
|
|
7624
|
-
source.kind === 'linked' ?
|
|
7997
|
+
source.kind === 'linked' ? IconLinkedWorkspace(13) : source.kind === 'remote' ? IconRemoteWorkspace(13) : IconFolderTree(13)),
|
|
7625
7998
|
h('span', { className: 'rw-tree-ws-title' },
|
|
7626
7999
|
h('span', { className: 'rw-tree-ws-name' }, source.name),
|
|
7627
|
-
h('span', { className: 'rw-tree-ws-sub' }, source.username + '@' + source.host
|
|
8000
|
+
h('span', { className: 'rw-tree-ws-sub' }, source.username + '@' + source.host
|
|
8001
|
+
+ (source.kind === 'linked' ? ' · ' + t('linkedChip') : source.kind === 'remote' ? ' · ' + t('remoteChip') : ''))),
|
|
7628
8002
|
h(StatusPill, { status: source.status, t: t })),
|
|
7629
8003
|
open
|
|
7630
8004
|
? h('div', { className: 'rw-tree-body', role: 'tree', 'aria-label': source.name },
|
|
@@ -7683,10 +8057,6 @@ function attributeViolation(name, value, tagName) {
|
|
|
7683
8057
|
var locale = props.locale;
|
|
7684
8058
|
var onDone = props.onDone;
|
|
7685
8059
|
var onCancel = props.onCancel;
|
|
7686
|
-
var lockedMode = props.lockedMode === 'linked' ? 'linked' : props.lockedMode === 'remote' ? 'remote' : '';
|
|
7687
|
-
var modeState = useState(lockedMode || (props.initialMode === 'linked' ? 'linked' : 'remote'));
|
|
7688
|
-
var mode = lockedMode || modeState[0];
|
|
7689
|
-
var setMode = modeState[1];
|
|
7690
8060
|
|
|
7691
8061
|
var hostState = useState({ loading: true, hosts: [], error: null });
|
|
7692
8062
|
var hostData = hostState[0];
|
|
@@ -7750,25 +8120,10 @@ function attributeViolation(name, value, tagName) {
|
|
|
7750
8120
|
if (!selectedHostId) { setError(t('stepHost')); return; }
|
|
7751
8121
|
var trimmedRemote = remotePath.trim();
|
|
7752
8122
|
if (trimmedRemote === '') { setError(t('stepPath')); return; }
|
|
7753
|
-
setBusy(true);
|
|
7754
|
-
setError('');
|
|
7755
|
-
if (mode === 'remote') {
|
|
7756
|
-
apiCall('workspaces.add', {
|
|
7757
|
-
hostId: selectedHostId,
|
|
7758
|
-
remotePath: trimmedRemote,
|
|
7759
|
-
name: name.trim(),
|
|
7760
|
-
}).then(function () {
|
|
7761
|
-
setBusy(false);
|
|
7762
|
-
bus.emit();
|
|
7763
|
-
if (onDone) onDone();
|
|
7764
|
-
}).catch(function (err) {
|
|
7765
|
-
setBusy(false);
|
|
7766
|
-
setError(t('addFailed') + ':' + messageOf(err, t, locale));
|
|
7767
|
-
});
|
|
7768
|
-
return;
|
|
7769
|
-
}
|
|
7770
8123
|
var trimmedLocal = localPath.trim();
|
|
7771
8124
|
if (trimmedLocal === '') { setBusy(false); setError(t('stepLocalPath')); return; }
|
|
8125
|
+
setBusy(true);
|
|
8126
|
+
setError('');
|
|
7772
8127
|
apiCall('linked.create', {
|
|
7773
8128
|
hostId: selectedHostId,
|
|
7774
8129
|
remotePath: trimmedRemote,
|
|
@@ -7785,16 +8140,11 @@ function attributeViolation(name, value, tagName) {
|
|
|
7785
8140
|
});
|
|
7786
8141
|
}
|
|
7787
8142
|
|
|
7788
|
-
if (props.submitRef) props.submitRef.current = { submit: submit, busy: busy
|
|
8143
|
+
if (props.submitRef) props.submitRef.current = { submit: submit, busy: busy };
|
|
7789
8144
|
|
|
7790
8145
|
return h('div', { className: 'rw-add' },
|
|
7791
8146
|
h('div', { className: 'rw-inline', style: { justifyContent: 'space-between' } },
|
|
7792
|
-
h('div', { className: 'rw-add-title' },
|
|
7793
|
-
lockedMode === ''
|
|
7794
|
-
? h('div', { className: 'rw-tabs' },
|
|
7795
|
-
h('button', { type: 'button', className: 'rw-tab' + (mode === 'remote' ? ' is-on' : ''), onClick: function () { setMode('remote'); } }, IconServer(13), t('remoteGroup')),
|
|
7796
|
-
h('button', { type: 'button', className: 'rw-tab' + (mode === 'linked' ? ' is-on' : ''), onClick: function () { setMode('linked'); } }, IconLink(13), t('linkedName')))
|
|
7797
|
-
: null),
|
|
8147
|
+
h('div', { className: 'rw-add-title' }, t('createLinked'))),
|
|
7798
8148
|
h('div', { className: 'rw-field' },
|
|
7799
8149
|
h('div', { className: 'rw-label' }, t('stepHost')),
|
|
7800
8150
|
h(HostList, { t: t, hosts: hostData.hosts, loading: hostData.loading, selectedId: selectedHostId, onSelect: chooseHost }),
|
|
@@ -7824,8 +8174,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
7824
8174
|
})
|
|
7825
8175
|
: null,
|
|
7826
8176
|
h('div', { className: 'rw-hint' }, t('diskHint'))),
|
|
7827
|
-
|
|
7828
|
-
? h('div', { className: 'rw-field' },
|
|
8177
|
+
h('div', { className: 'rw-field' },
|
|
7829
8178
|
h('div', { className: 'rw-label' }, t('stepLocalPath')),
|
|
7830
8179
|
h('div', { className: 'rw-input-row' },
|
|
7831
8180
|
h('input', {
|
|
@@ -7851,28 +8200,158 @@ function attributeViolation(name, value, tagName) {
|
|
|
7851
8200
|
checked: mirror, onChange: setMirror, label: t('mirrorLabel'),
|
|
7852
8201
|
text: t('mirrorLabel'),
|
|
7853
8202
|
})),
|
|
7854
|
-
h('div', { className: 'rw-hint' }, t('mirrorHint')))
|
|
7855
|
-
|
|
7856
|
-
|
|
7857
|
-
|
|
7858
|
-
|
|
8203
|
+
h('div', { className: 'rw-hint' }, t('mirrorHint'))),
|
|
8204
|
+
h('div', { className: 'rw-field' },
|
|
8205
|
+
h('div', { className: 'rw-label' }, t('stepName')),
|
|
8206
|
+
h('input', {
|
|
8207
|
+
className: 'rw-input',
|
|
8208
|
+
value: name,
|
|
8209
|
+
placeholder: basename(localPath) || t('namePlaceholder'),
|
|
8210
|
+
maxLength: 120,
|
|
8211
|
+
onChange: function (event) { setName(event.currentTarget.value); },
|
|
8212
|
+
onKeyDown: function (event) { if (event.key === 'Enter') submit(); },
|
|
8213
|
+
})),
|
|
8214
|
+
error ? h(Banner, { kind: 'error' }, error) : null,
|
|
8215
|
+
props.compact ? null : h('div', { className: 'rw-actions' },
|
|
8216
|
+
h('button', { type: 'button', className: 'rw-btn', disabled: busy, onClick: onCancel }, t('cancel')),
|
|
8217
|
+
h('button', {
|
|
8218
|
+
type: 'button', className: 'rw-btn rw-btn-primary',
|
|
8219
|
+
disabled: busy || !selectedHostId || remotePath.trim() === '' || localPath.trim() === '',
|
|
8220
|
+
onClick: submit,
|
|
8221
|
+
}, busy ? Spinner(13) : IconLinkedWorkspace(13), busy ? t('creating') : t('create'))));
|
|
8222
|
+
}
|
|
8223
|
+
|
|
8224
|
+
// ── remote workspace flow (sessions run inside the remote folder) ──────
|
|
8225
|
+
|
|
8226
|
+
function AddRemoteWorkspaceFlow(props) {
|
|
8227
|
+
var t = props.t;
|
|
8228
|
+
var locale = props.locale;
|
|
8229
|
+
var onDone = props.onDone;
|
|
8230
|
+
var onCancel = props.onCancel;
|
|
8231
|
+
|
|
8232
|
+
var hostState = useState({ loading: true, hosts: [], error: null });
|
|
8233
|
+
var hostData = hostState[0];
|
|
8234
|
+
var setHostData = hostState[1];
|
|
8235
|
+
var selectedState = useState('');
|
|
8236
|
+
var selectedHostId = selectedState[0];
|
|
8237
|
+
var setSelectedHostId = selectedState[1];
|
|
8238
|
+
var pathState = useState('');
|
|
8239
|
+
var remotePath = pathState[0];
|
|
8240
|
+
var setRemotePath = pathState[1];
|
|
8241
|
+
var nameState = useState('');
|
|
8242
|
+
var name = nameState[0];
|
|
8243
|
+
var setName = nameState[1];
|
|
8244
|
+
var busyState = useState(false);
|
|
8245
|
+
var busy = busyState[0];
|
|
8246
|
+
var setBusy = busyState[1];
|
|
8247
|
+
var errorState = useState('');
|
|
8248
|
+
var error = errorState[0];
|
|
8249
|
+
var setError = errorState[1];
|
|
8250
|
+
var remoteOpenState = useState(false);
|
|
8251
|
+
var remoteOpen = remoteOpenState[0];
|
|
8252
|
+
var setRemoteOpen = remoteOpenState[1];
|
|
8253
|
+
|
|
8254
|
+
var loadHosts = useCallback(function () {
|
|
8255
|
+
setHostData(function (previous) { return { loading: previous.hosts.length === 0, hosts: previous.hosts, error: null }; });
|
|
8256
|
+
apiCall('hosts.list', {}).then(function (result) {
|
|
8257
|
+
setHostData({ loading: false, hosts: result.hosts || [], error: null });
|
|
8258
|
+
setSelectedHostId(function (current) {
|
|
8259
|
+
if (current) return current;
|
|
8260
|
+
return result.hosts && result.hosts.length > 0 ? result.hosts[0].id : '';
|
|
8261
|
+
});
|
|
8262
|
+
}).catch(function (err) {
|
|
8263
|
+
setHostData({ loading: false, hosts: [], error: err });
|
|
8264
|
+
});
|
|
8265
|
+
}, []);
|
|
8266
|
+
|
|
8267
|
+
useEffect(function () { loadHosts(); }, [loadHosts]);
|
|
8268
|
+
|
|
8269
|
+
function chooseHost(host) {
|
|
8270
|
+
setSelectedHostId(host.id);
|
|
8271
|
+
setError('');
|
|
8272
|
+
setRemoteOpen(false);
|
|
8273
|
+
if (remotePath.trim() === '' && host && host.hasCredential !== false) {
|
|
8274
|
+
apiCall('hosts.browse', { hostId: host.id }).then(function (result) {
|
|
8275
|
+
setRemotePath(function (current) { return current.trim() === '' ? result.home : current; });
|
|
8276
|
+
}).catch(function () { /* silent prefill */ });
|
|
8277
|
+
}
|
|
8278
|
+
}
|
|
8279
|
+
|
|
8280
|
+
function submit() {
|
|
8281
|
+
if (busy) return;
|
|
8282
|
+
if (!selectedHostId) { setError(t('stepHost')); return; }
|
|
8283
|
+
var trimmedRemote = remotePath.trim();
|
|
8284
|
+
if (trimmedRemote === '') { setError(t('stepPath')); return; }
|
|
8285
|
+
setBusy(true);
|
|
8286
|
+
setError('');
|
|
8287
|
+
apiCall('remote_workspaces.create', {
|
|
8288
|
+
hostId: selectedHostId,
|
|
8289
|
+
remotePath: trimmedRemote,
|
|
8290
|
+
name: name.trim(),
|
|
8291
|
+
}).then(function () {
|
|
8292
|
+
setBusy(false);
|
|
8293
|
+
bus.emit();
|
|
8294
|
+
if (onDone) onDone();
|
|
8295
|
+
}).catch(function (err) {
|
|
8296
|
+
setBusy(false);
|
|
8297
|
+
setError(t('remoteCreateFailed') + ':' + messageOf(err, t, locale));
|
|
8298
|
+
});
|
|
8299
|
+
}
|
|
8300
|
+
|
|
8301
|
+
if (props.submitRef) props.submitRef.current = { submit: submit, busy: busy };
|
|
8302
|
+
|
|
8303
|
+
return h('div', { className: 'rw-add' },
|
|
8304
|
+
h('div', { className: 'rw-inline', style: { justifyContent: 'space-between' } },
|
|
8305
|
+
h('div', { className: 'rw-add-title' }, t('createRemote'))),
|
|
8306
|
+
h('div', { className: 'rw-hint' }, t('flowRemoteDesc')),
|
|
8307
|
+
h('div', { className: 'rw-field' },
|
|
8308
|
+
h('div', { className: 'rw-label' }, t('stepHost')),
|
|
8309
|
+
h(HostList, { t: t, hosts: hostData.hosts, loading: hostData.loading, selectedId: selectedHostId, onSelect: chooseHost }),
|
|
8310
|
+
hostData.error ? h(Banner, { kind: 'error' }, t('hostsFailed') + ':' + messageOf(hostData.error, t, locale)) : null),
|
|
8311
|
+
h('div', { className: 'rw-field' },
|
|
8312
|
+
h('div', { className: 'rw-label' }, t('stepPath')),
|
|
8313
|
+
h('div', { className: 'rw-input-row' },
|
|
7859
8314
|
h('input', {
|
|
7860
|
-
className: 'rw-input',
|
|
7861
|
-
value:
|
|
7862
|
-
placeholder:
|
|
7863
|
-
|
|
7864
|
-
|
|
8315
|
+
className: 'rw-input rw-input-mono',
|
|
8316
|
+
value: remotePath,
|
|
8317
|
+
placeholder: t('pathPlaceholder'),
|
|
8318
|
+
spellCheck: false,
|
|
8319
|
+
autoComplete: 'off',
|
|
8320
|
+
onChange: function (event) { setRemotePath(event.currentTarget.value); },
|
|
7865
8321
|
onKeyDown: function (event) { if (event.key === 'Enter') submit(); },
|
|
7866
|
-
})
|
|
7867
|
-
|
|
8322
|
+
}),
|
|
8323
|
+
h('button', {
|
|
8324
|
+
type: 'button', className: 'rw-btn',
|
|
8325
|
+
onClick: function () { setRemoteOpen(function (value) { return !value; }); },
|
|
8326
|
+
disabled: !selectedHostId,
|
|
8327
|
+
}, IconFolder(13), remoteOpen ? t('cancel') : t('browse'))),
|
|
8328
|
+
remoteOpen
|
|
8329
|
+
? h(RemotePathPicker, {
|
|
8330
|
+
t: t, locale: locale, hostId: selectedHostId,
|
|
8331
|
+
initialPath: remotePath,
|
|
8332
|
+
onPick: function (picked) { setRemotePath(picked); setRemoteOpen(false); },
|
|
8333
|
+
})
|
|
8334
|
+
: null,
|
|
8335
|
+
h('div', { className: 'rw-hint' }, t('diskHint'))),
|
|
8336
|
+
h('div', { className: 'rw-field' },
|
|
8337
|
+
h('div', { className: 'rw-label' }, t('remoteStepName')),
|
|
8338
|
+
h('input', {
|
|
8339
|
+
className: 'rw-input',
|
|
8340
|
+
value: name,
|
|
8341
|
+
placeholder: basename(remotePath) || t('namePlaceholder'),
|
|
8342
|
+
maxLength: 120,
|
|
8343
|
+
onChange: function (event) { setName(event.currentTarget.value); },
|
|
8344
|
+
onKeyDown: function (event) { if (event.key === 'Enter') submit(); },
|
|
8345
|
+
})),
|
|
8346
|
+
h('div', { className: 'rw-hint' }, t('remotePlaceholderHint')),
|
|
7868
8347
|
error ? h(Banner, { kind: 'error' }, error) : null,
|
|
7869
8348
|
props.compact ? null : h('div', { className: 'rw-actions' },
|
|
7870
8349
|
h('button', { type: 'button', className: 'rw-btn', disabled: busy, onClick: onCancel }, t('cancel')),
|
|
7871
8350
|
h('button', {
|
|
7872
8351
|
type: 'button', className: 'rw-btn rw-btn-primary',
|
|
7873
|
-
disabled: busy || !selectedHostId || remotePath.trim() === ''
|
|
8352
|
+
disabled: busy || !selectedHostId || remotePath.trim() === '',
|
|
7874
8353
|
onClick: submit,
|
|
7875
|
-
}, busy ? Spinner(13) : (
|
|
8354
|
+
}, busy ? Spinner(13) : IconRemoteWorkspace(13), busy ? t('creating') : t('create'))));
|
|
7876
8355
|
}
|
|
7877
8356
|
|
|
7878
8357
|
// ── directory flow (sidebar / hero "add workspace" hole) ───────────────
|
|
@@ -7903,7 +8382,10 @@ function attributeViolation(name, value, tagName) {
|
|
|
7903
8382
|
|
|
7904
8383
|
function createLocal() {
|
|
7905
8384
|
var target = localPath.trim();
|
|
7906
|
-
if (
|
|
8385
|
+
if (localBusy) return;
|
|
8386
|
+
// Keep the button looking the same as the linked/remote ones and report
|
|
8387
|
+
// the missing folder instead of silently ignoring the click.
|
|
8388
|
+
if (target === '') { setLocalError(t('localPathRequired')); return; }
|
|
7907
8389
|
setLocalBusy(true);
|
|
7908
8390
|
setLocalError('');
|
|
7909
8391
|
apiCall('localWorkspace.create', { path: target, name: localName.trim() }).then(function () {
|
|
@@ -7969,14 +8451,15 @@ function attributeViolation(name, value, tagName) {
|
|
|
7969
8451
|
onKeyDown: onModalKeyDown,
|
|
7970
8452
|
},
|
|
7971
8453
|
h('div', { className: 'rw-modal-head' },
|
|
7972
|
-
h('span', { className: 'rw-icon-chip' },
|
|
8454
|
+
h('span', { className: 'rw-icon-chip' }, IconFolderTree(16)),
|
|
7973
8455
|
h('span', { className: 'rw-modal-title' }, t('flowTitle')),
|
|
7974
8456
|
h('button', { type: 'button', className: 'rw-icon-btn', title: t('cancel'), onClick: function () { if (props.onCancel) props.onCancel(); } }, IconClose(14))),
|
|
7975
8457
|
h('div', { className: 'rw-modal-body' },
|
|
7976
8458
|
h('div', { className: 'rw-tabs' },
|
|
7977
8459
|
h('button', { type: 'button', className: 'rw-tab' + (flow === 'local' ? ' is-on' : ''), onClick: function () { setFlow('local'); } }, IconFolder(13), t('flowLocal')),
|
|
7978
|
-
h('button', { type: 'button', className: 'rw-tab' + (flow === 'linked' ? ' is-on' : ''), onClick: function () { setFlow('linked'); } },
|
|
7979
|
-
|
|
8460
|
+
h('button', { type: 'button', className: 'rw-tab' + (flow === 'linked' ? ' is-on' : ''), onClick: function () { setFlow('linked'); } }, IconLinkedWorkspace(13), t('flowLinked')),
|
|
8461
|
+
h('button', { type: 'button', className: 'rw-tab' + (flow === 'remote' ? ' is-on' : ''), onClick: function () { setFlow('remote'); } }, IconRemoteWorkspace(13), t('flowRemote'))),
|
|
8462
|
+
h('div', { className: 'rw-hint' }, flow === 'local' ? t('localFlowHint') : flow === 'remote' ? t('flowRemoteDesc') : t('linkedFlowHint')),
|
|
7980
8463
|
flow === 'local'
|
|
7981
8464
|
? h('div', { className: 'rw-add' },
|
|
7982
8465
|
h('div', { className: 'rw-field' },
|
|
@@ -7987,7 +8470,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
7987
8470
|
value: localPath,
|
|
7988
8471
|
placeholder: t('localPathPlaceholder'),
|
|
7989
8472
|
spellCheck: false,
|
|
7990
|
-
onChange: function (event) { setLocalPath(event.currentTarget.value); },
|
|
8473
|
+
onChange: function (event) { setLocalPath(event.currentTarget.value); if (localError) setLocalError(''); },
|
|
7991
8474
|
}),
|
|
7992
8475
|
h('button', {
|
|
7993
8476
|
type: 'button', className: 'rw-btn',
|
|
@@ -8010,13 +8493,19 @@ function attributeViolation(name, value, tagName) {
|
|
|
8010
8493
|
onKeyDown: function (event) { if (event.key === 'Enter') createLocal(); },
|
|
8011
8494
|
})),
|
|
8012
8495
|
localError ? h(Banner, { kind: 'error' }, localError) : null)
|
|
8013
|
-
:
|
|
8014
|
-
|
|
8015
|
-
|
|
8016
|
-
|
|
8017
|
-
|
|
8496
|
+
: flow === 'remote'
|
|
8497
|
+
? h(AddRemoteWorkspaceFlow, {
|
|
8498
|
+
ctx: ctx, t: t, locale: locale, compact: true, submitRef: flowSubmitRef,
|
|
8499
|
+
onDone: function () { if (props.onCancel) props.onCancel(); },
|
|
8500
|
+
onCancel: function () { if (props.onCancel) props.onCancel(); },
|
|
8501
|
+
})
|
|
8502
|
+
: h(AddWorkspaceFlow, {
|
|
8503
|
+
ctx: ctx, t: t, locale: locale, compact: true, submitRef: flowSubmitRef,
|
|
8504
|
+
onDone: function () { if (props.onCancel) props.onCancel(); },
|
|
8505
|
+
onCancel: function () { if (props.onCancel) props.onCancel(); },
|
|
8506
|
+
})),
|
|
8018
8507
|
h('div', { className: 'rw-modal-foot' },
|
|
8019
|
-
h('span', { className: 'rw-hint', style: { flex: '1 1 auto' } }, props.busy ? t('wsFlowBusy') : flow === 'linked' ? t('linkedFlowHint') : t('useLocalDirHint')),
|
|
8508
|
+
h('span', { className: 'rw-hint', style: { flex: '1 1 auto' } }, props.busy ? t('wsFlowBusy') : flow === 'linked' ? t('linkedFlowHint') : flow === 'remote' ? t('flowRemoteDesc') : t('useLocalDirHint')),
|
|
8020
8509
|
h('button', {
|
|
8021
8510
|
type: 'button', className: 'rw-btn', disabled: Boolean(props.busy) || localBusy,
|
|
8022
8511
|
onClick: function () { if (props.onCancel) props.onCancel(); },
|
|
@@ -8024,7 +8513,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
8024
8513
|
flow === 'local'
|
|
8025
8514
|
? h('button', {
|
|
8026
8515
|
type: 'button', className: 'rw-btn rw-btn-primary',
|
|
8027
|
-
disabled:
|
|
8516
|
+
disabled: Boolean(props.busy) || localBusy,
|
|
8028
8517
|
onClick: createLocal,
|
|
8029
8518
|
}, localBusy ? Spinner(13) : IconPlus(13), localBusy ? t('creating') : t('create'))
|
|
8030
8519
|
: h('button', {
|
|
@@ -8039,89 +8528,6 @@ function attributeViolation(name, value, tagName) {
|
|
|
8039
8528
|
|
|
8040
8529
|
// ── settings section ───────────────────────────────────────────────────
|
|
8041
8530
|
|
|
8042
|
-
function RemoteWorkspaceCard(props) {
|
|
8043
|
-
var workspace = props.workspace;
|
|
8044
|
-
var t = props.t;
|
|
8045
|
-
var ctx = props.ctx;
|
|
8046
|
-
var locale = props.locale;
|
|
8047
|
-
var refresh = props.refresh;
|
|
8048
|
-
var state = useState({ testing: false, removing: false, message: null });
|
|
8049
|
-
var local = state[0];
|
|
8050
|
-
var setLocal = state[1];
|
|
8051
|
-
|
|
8052
|
-
function open() {
|
|
8053
|
-
var sidebar = ctx.get && ctx.get('betterSidebar');
|
|
8054
|
-
if (!sidebar || typeof sidebar.openTab !== 'function') return;
|
|
8055
|
-
sidebar.openTab({
|
|
8056
|
-
type: REMOTE_TAB_TYPE,
|
|
8057
|
-
id: REMOTE_TAB_TYPE,
|
|
8058
|
-
title: t('remoteTabTitle'),
|
|
8059
|
-
path: '/',
|
|
8060
|
-
meta: { remoteId: workspace.id },
|
|
8061
|
-
});
|
|
8062
|
-
dismissSettingsOverlay();
|
|
8063
|
-
}
|
|
8064
|
-
|
|
8065
|
-
function test() {
|
|
8066
|
-
setLocal({ testing: true, removing: false, message: null });
|
|
8067
|
-
apiCall('workspaces.test', { id: workspace.id }).then(function (result) {
|
|
8068
|
-
setLocal({
|
|
8069
|
-
testing: false,
|
|
8070
|
-
removing: false,
|
|
8071
|
-
message: result.ok
|
|
8072
|
-
? { kind: 'success', text: t('testOk') + (result.latencyMs ? ' · ' + result.latencyMs + ' ms' : '') }
|
|
8073
|
-
: { kind: 'error', text: t('testFail') + ':' + (result.error || '') },
|
|
8074
|
-
});
|
|
8075
|
-
refresh();
|
|
8076
|
-
}).catch(function (error) {
|
|
8077
|
-
setLocal({ testing: false, removing: false, message: { kind: 'error', text: t('testFail') + ':' + messageOf(error, t, locale) } });
|
|
8078
|
-
});
|
|
8079
|
-
}
|
|
8080
|
-
|
|
8081
|
-
function remove() {
|
|
8082
|
-
if (!local.removing) {
|
|
8083
|
-
setLocal({ testing: false, removing: true, message: null });
|
|
8084
|
-
return;
|
|
8085
|
-
}
|
|
8086
|
-
setLocal({ testing: false, removing: true, message: { kind: 'info', text: t('loading') } });
|
|
8087
|
-
apiCall('workspaces.remove', { id: workspace.id }).then(function () {
|
|
8088
|
-
bus.emit();
|
|
8089
|
-
}).catch(function (error) {
|
|
8090
|
-
setLocal({ testing: false, removing: false, message: { kind: 'error', text: messageOf(error, t, locale) } });
|
|
8091
|
-
});
|
|
8092
|
-
}
|
|
8093
|
-
|
|
8094
|
-
var title = workspace.name || basename(workspace.remotePath) || workspace.hostName;
|
|
8095
|
-
var hostLabel = workspace.username + '@' + workspace.host + ':' + workspace.port;
|
|
8096
|
-
|
|
8097
|
-
return h('div', { className: 'rw-card' },
|
|
8098
|
-
h('div', { className: 'rw-card-head' },
|
|
8099
|
-
h('span', { className: 'rw-icon-chip' }, IconServer(16)),
|
|
8100
|
-
h('div', { className: 'rw-fill', style: { flex: '1 1 auto', minWidth: 0 } },
|
|
8101
|
-
h('div', { className: 'rw-card-title' },
|
|
8102
|
-
h('span', { className: 'rw-name', title: title }, title),
|
|
8103
|
-
h(StatusPill, { status: workspace.status, t: t })),
|
|
8104
|
-
h('div', { className: 'rw-path', title: workspace.remotePath }, workspace.remotePath)),
|
|
8105
|
-
h('div', { className: 'rw-actions' },
|
|
8106
|
-
h('button', { type: 'button', className: 'rw-btn rw-btn-sm', onClick: open, disabled: !(ctx.get && ctx.get('betterSidebar')) }, IconExternal(12), t('open')),
|
|
8107
|
-
h('button', { type: 'button', className: 'rw-btn rw-btn-sm', onClick: test, disabled: local.testing }, local.testing ? Spinner(12) : IconRefresh(12), local.testing ? t('testRunning') : t('test')),
|
|
8108
|
-
h('button', {
|
|
8109
|
-
type: 'button',
|
|
8110
|
-
className: 'rw-btn rw-btn-sm' + (local.removing ? ' rw-btn-danger' : ' rw-btn-ghost'),
|
|
8111
|
-
onClick: remove,
|
|
8112
|
-
title: local.removing ? t('removeHint') : t('remove'),
|
|
8113
|
-
}, IconTrash(12), local.removing ? t('confirmRemove') : t('remove')))),
|
|
8114
|
-
h('div', { className: 'rw-meta' },
|
|
8115
|
-
h('span', { className: 'rw-chip' }, IconServer(11), workspace.hostName),
|
|
8116
|
-
h('span', { className: 'rw-meta-text rw-input-mono', title: hostLabel }, hostLabel)),
|
|
8117
|
-
local.message
|
|
8118
|
-
? h(Banner, {
|
|
8119
|
-
kind: local.message.kind === 'success' ? 'success' : local.message.kind === 'error' ? 'error' : undefined,
|
|
8120
|
-
onClose: function () { setLocal({ testing: false, removing: false, message: null }); },
|
|
8121
|
-
}, local.message.text)
|
|
8122
|
-
: null);
|
|
8123
|
-
}
|
|
8124
|
-
|
|
8125
8531
|
function LinkedWorkspaceCard(props) {
|
|
8126
8532
|
var link = props.link;
|
|
8127
8533
|
var t = props.t;
|
|
@@ -8247,9 +8653,9 @@ function attributeViolation(name, value, tagName) {
|
|
|
8247
8653
|
});
|
|
8248
8654
|
}
|
|
8249
8655
|
|
|
8250
|
-
return h('div', { className: 'rw-card' },
|
|
8656
|
+
return h('div', { className: 'rw-card', title: link.name + ' · ' + statusTitle(t, link) },
|
|
8251
8657
|
h('div', { className: 'rw-card-head' },
|
|
8252
|
-
h('span', { className: 'rw-icon-chip rw-icon-chip-link' },
|
|
8658
|
+
h('span', { className: 'rw-icon-chip rw-icon-chip-link' }, IconLinkedWorkspace(16)),
|
|
8253
8659
|
h('div', { className: 'rw-fill', style: { flex: '1 1 auto', minWidth: 0 } },
|
|
8254
8660
|
h('div', { className: 'rw-card-title' },
|
|
8255
8661
|
h('span', { className: 'rw-name', title: link.name }, link.name),
|
|
@@ -8314,6 +8720,157 @@ function attributeViolation(name, value, tagName) {
|
|
|
8314
8720
|
: null);
|
|
8315
8721
|
}
|
|
8316
8722
|
|
|
8723
|
+
function RemoteWorkspaceCard(props) {
|
|
8724
|
+
var workspace = props.workspace;
|
|
8725
|
+
var t = props.t;
|
|
8726
|
+
var ctx = props.ctx;
|
|
8727
|
+
var locale = props.locale;
|
|
8728
|
+
var refresh = props.refresh;
|
|
8729
|
+
var state = useState({ busy: '', message: null, removing: false, renaming: false, draft: workspace.name });
|
|
8730
|
+
var local = state[0];
|
|
8731
|
+
var setLocal = state[1];
|
|
8732
|
+
|
|
8733
|
+
function openWorkspace() {
|
|
8734
|
+
if (!workspace.workspaceId) return;
|
|
8735
|
+
var uiWorkspace = null;
|
|
8736
|
+
try { uiWorkspace = ctx.get('uiWorkspace'); } catch (error) { uiWorkspace = null; }
|
|
8737
|
+
if (!uiWorkspace && ctx.root && typeof ctx.root.get === 'function') {
|
|
8738
|
+
try { uiWorkspace = ctx.root.get('uiWorkspace'); } catch (error) { uiWorkspace = null; }
|
|
8739
|
+
}
|
|
8740
|
+
if (uiWorkspace && typeof uiWorkspace.openWorkspace === 'function') {
|
|
8741
|
+
try {
|
|
8742
|
+
var navigation = uiWorkspace.openWorkspace(workspace.workspaceId);
|
|
8743
|
+
if (navigation && typeof navigation.catch === 'function') navigation.catch(function () { /* navigation aborted */ });
|
|
8744
|
+
} catch (error) { /* ignore */ }
|
|
8745
|
+
}
|
|
8746
|
+
dismissSettingsOverlay();
|
|
8747
|
+
}
|
|
8748
|
+
|
|
8749
|
+
function openTree() {
|
|
8750
|
+
var sidebar = sidebarService(ctx);
|
|
8751
|
+
if (!sidebar || typeof sidebar.openTab !== 'function') return;
|
|
8752
|
+
sidebar.openTab({
|
|
8753
|
+
type: REMOTE_TREE_TAB_TYPE,
|
|
8754
|
+
id: REMOTE_TREE_TAB_TYPE,
|
|
8755
|
+
title: workspace.name,
|
|
8756
|
+
path: '/',
|
|
8757
|
+
meta: { remoteId: workspace.id },
|
|
8758
|
+
});
|
|
8759
|
+
dismissSettingsOverlay();
|
|
8760
|
+
}
|
|
8761
|
+
|
|
8762
|
+
function startRename() {
|
|
8763
|
+
setLocal(function (previous) { return Object.assign({}, previous, { renaming: true, draft: workspace.name, message: null }); });
|
|
8764
|
+
}
|
|
8765
|
+
|
|
8766
|
+
function submitRename() {
|
|
8767
|
+
var next = String(local.draft == null ? '' : local.draft).trim();
|
|
8768
|
+
if (next === '' || next === workspace.name) {
|
|
8769
|
+
setLocal(function (previous) { return Object.assign({}, previous, { renaming: false }); });
|
|
8770
|
+
return;
|
|
8771
|
+
}
|
|
8772
|
+
setLocal(function (previous) { return Object.assign({}, previous, { busy: 'rename', message: null }); });
|
|
8773
|
+
apiCall('remote_workspaces.update', { id: workspace.id, name: next }).then(function () {
|
|
8774
|
+
setLocal(function (previous) { return Object.assign({}, previous, { busy: '', renaming: false }); });
|
|
8775
|
+
refresh();
|
|
8776
|
+
}).catch(function (error) {
|
|
8777
|
+
setLocal(function (previous) {
|
|
8778
|
+
return Object.assign({}, previous, { busy: '', message: { kind: 'error', text: t('remoteUpdateFailed') + ':' + messageOf(error, t, locale) } });
|
|
8779
|
+
});
|
|
8780
|
+
});
|
|
8781
|
+
}
|
|
8782
|
+
|
|
8783
|
+
function testConnection() {
|
|
8784
|
+
setLocal(function (previous) { return Object.assign({}, previous, { busy: 'test', message: null }); });
|
|
8785
|
+
apiCall('remote_workspaces.test', { id: workspace.id }).then(function (result) {
|
|
8786
|
+
var ok = result && result.ok;
|
|
8787
|
+
var text = ok
|
|
8788
|
+
? t('testOk', { ms: result.latencyMs == null ? '' : result.latencyMs })
|
|
8789
|
+
: (t('testFailed') + ':' + (result && result.error ? result.error : t('testFailed')));
|
|
8790
|
+
setLocal(function (previous) { return Object.assign({}, previous, { busy: '', message: { kind: ok ? 'success' : 'error', text: text } }); });
|
|
8791
|
+
}).catch(function (error) {
|
|
8792
|
+
setLocal(function (previous) {
|
|
8793
|
+
return Object.assign({}, previous, { busy: '', message: { kind: 'error', text: t('testFailed') + ':' + messageOf(error, t, locale) } });
|
|
8794
|
+
});
|
|
8795
|
+
});
|
|
8796
|
+
}
|
|
8797
|
+
|
|
8798
|
+
function remove() {
|
|
8799
|
+
if (!local.removing) {
|
|
8800
|
+
setLocal(function (previous) { return Object.assign({}, previous, { removing: true, message: null }); });
|
|
8801
|
+
return;
|
|
8802
|
+
}
|
|
8803
|
+
setLocal(function (previous) { return Object.assign({}, previous, { busy: 'remove' }); });
|
|
8804
|
+
apiCall('remote_workspaces.remove', { id: workspace.id }).then(function () {
|
|
8805
|
+
setLocal(function (previous) { return Object.assign({}, previous, { busy: '', removing: false, message: { kind: 'success', text: t('remoteRemoved') } }); });
|
|
8806
|
+
bus.emit();
|
|
8807
|
+
refresh();
|
|
8808
|
+
}).catch(function (error) {
|
|
8809
|
+
setLocal(function (previous) {
|
|
8810
|
+
return Object.assign({}, previous, { busy: '', message: { kind: 'error', text: t('remoteRemoveFailed') + ':' + messageOf(error, t, locale) } });
|
|
8811
|
+
});
|
|
8812
|
+
});
|
|
8813
|
+
}
|
|
8814
|
+
|
|
8815
|
+
var hostLabel = (workspace.username ? workspace.username + '@' : '') + (workspace.host || workspace.hostName || '');
|
|
8816
|
+
|
|
8817
|
+
return h('div', { className: 'rw-card', title: workspace.name + ' · ' + statusTitle(t, workspace) },
|
|
8818
|
+
h('div', { className: 'rw-card-head' },
|
|
8819
|
+
h('span', { className: 'rw-icon-chip' }, IconRemoteWorkspace(16)),
|
|
8820
|
+
h('div', { className: 'rw-fill', style: { flex: '1 1 auto', minWidth: 0 } },
|
|
8821
|
+
h('div', { className: 'rw-card-title' },
|
|
8822
|
+
local.renaming
|
|
8823
|
+
? h('input', {
|
|
8824
|
+
className: 'rw-input',
|
|
8825
|
+
value: local.draft,
|
|
8826
|
+
autoFocus: true,
|
|
8827
|
+
onChange: function (event) { setLocal(function (previous) { return Object.assign({}, previous, { draft: event.target.value }); }); },
|
|
8828
|
+
onKeyDown: function (event) {
|
|
8829
|
+
if (event.key === 'Enter') { event.preventDefault(); submitRename(); }
|
|
8830
|
+
if (event.key === 'Escape') { event.preventDefault(); setLocal(function (previous) { return Object.assign({}, previous, { renaming: false }); }); }
|
|
8831
|
+
},
|
|
8832
|
+
})
|
|
8833
|
+
: h('span', { className: 'rw-name', title: workspace.name }, workspace.name),
|
|
8834
|
+
h('span', { className: 'rw-chip' }, t('remoteChip')),
|
|
8835
|
+
h(StatusPill, { status: workspace.status, t: t })),
|
|
8836
|
+
local.renaming
|
|
8837
|
+
? null
|
|
8838
|
+
: h('div', { className: 'rw-pair' },
|
|
8839
|
+
h('div', { className: 'rw-pair-item' },
|
|
8840
|
+
h('span', { className: 'rw-pair-label' }, t('pathRemoteShort') + (hostLabel ? ' · ' + hostLabel : '')),
|
|
8841
|
+
h('span', { className: 'rw-path', title: workspace.remotePath }, workspace.remotePath)),
|
|
8842
|
+
h('div', { className: 'rw-pair-item' },
|
|
8843
|
+
h('span', { className: 'rw-pair-label' }, t('remotePlaceholderLabel')),
|
|
8844
|
+
h('span', { className: 'rw-path', title: workspace.placeholderPath }, workspace.placeholderPath)))),
|
|
8845
|
+
h('div', { className: 'rw-actions' },
|
|
8846
|
+
local.renaming
|
|
8847
|
+
? h('span', null,
|
|
8848
|
+
h('button', { type: 'button', className: 'rw-btn rw-btn-sm rw-btn-ghost', onClick: function () { setLocal(function (previous) { return Object.assign({}, previous, { renaming: false }); }); } }, t('cancel')),
|
|
8849
|
+
h('button', { type: 'button', className: 'rw-btn rw-btn-sm rw-btn-primary', onClick: submitRename, disabled: local.busy === 'rename' }, local.busy === 'rename' ? Spinner(12) : null, t('save')))
|
|
8850
|
+
: h('span', null,
|
|
8851
|
+
workspace.workspaceId
|
|
8852
|
+
? h('button', { type: 'button', className: 'rw-btn rw-btn-sm', onClick: openWorkspace }, IconExternal(12), t('openWorkspace'))
|
|
8853
|
+
: null,
|
|
8854
|
+
h('button', { type: 'button', className: 'rw-btn rw-btn-sm', onClick: openTree }, IconFolderTree(12), t('openTree')),
|
|
8855
|
+
h('button', { type: 'button', className: 'rw-btn rw-btn-sm rw-btn-ghost', onClick: testConnection, disabled: local.busy !== '' }, local.busy === 'test' ? Spinner(12) : IconRefresh(12), t('testConnection')),
|
|
8856
|
+
h('button', { type: 'button', className: 'rw-btn rw-btn-sm rw-btn-ghost', onClick: startRename, disabled: local.busy !== '' }, t('rename')),
|
|
8857
|
+
h('button', { type: 'button', className: 'rw-btn rw-btn-sm rw-btn-ghost', onClick: remove, disabled: local.busy === 'remove' }, IconTrash(12), t('removeRemote'))))),
|
|
8858
|
+
h('div', { className: 'rw-hint' }, t('remoteSessionHint')),
|
|
8859
|
+
local.removing
|
|
8860
|
+
? h('div', { className: 'rw-warn-box' },
|
|
8861
|
+
h('div', null, t('remoteRemoveHint')),
|
|
8862
|
+
h('div', { className: 'rw-actions', style: { marginTop: 8 } },
|
|
8863
|
+
h('button', { type: 'button', className: 'rw-btn rw-btn-sm', onClick: function () { setLocal(function (previous) { return Object.assign({}, previous, { removing: false }); }); } }, t('cancel')),
|
|
8864
|
+
h('button', { type: 'button', className: 'rw-btn rw-btn-sm rw-btn-danger', onClick: remove, disabled: local.busy === 'remove' }, IconTrash(12), t('confirmRemove'))))
|
|
8865
|
+
: null,
|
|
8866
|
+
local.message
|
|
8867
|
+
? h(Banner, {
|
|
8868
|
+
kind: local.message.kind === 'success' ? 'success' : local.message.kind === 'error' ? 'error' : undefined,
|
|
8869
|
+
onClose: function () { setLocal(function (previous) { return Object.assign({}, previous, { message: null }); }); },
|
|
8870
|
+
}, local.message.text)
|
|
8871
|
+
: null);
|
|
8872
|
+
}
|
|
8873
|
+
|
|
8317
8874
|
function ThemeGroup(props) {
|
|
8318
8875
|
var t = props.t;
|
|
8319
8876
|
var locale = props.locale;
|
|
@@ -8456,13 +9013,13 @@ function attributeViolation(name, value, tagName) {
|
|
|
8456
9013
|
var addingState = useState('');
|
|
8457
9014
|
var adding = addingState[0];
|
|
8458
9015
|
var setAdding = addingState[1];
|
|
8459
|
-
var sidebarAvailable = Boolean(ctx
|
|
9016
|
+
var sidebarAvailable = Boolean(sidebarService(ctx));
|
|
8460
9017
|
var links = remote.data.links || [];
|
|
8461
|
-
var
|
|
9018
|
+
var remotes = remote.data.remotes || [];
|
|
8462
9019
|
var hosts = remote.data.hosts || [];
|
|
8463
9020
|
|
|
8464
9021
|
function openTree() {
|
|
8465
|
-
var sidebar = ctx
|
|
9022
|
+
var sidebar = sidebarService(ctx);
|
|
8466
9023
|
if (!sidebar || typeof sidebar.openTab !== 'function') return;
|
|
8467
9024
|
sidebar.openTab({
|
|
8468
9025
|
type: TREE_TAB_TYPE,
|
|
@@ -8471,6 +9028,11 @@ function attributeViolation(name, value, tagName) {
|
|
|
8471
9028
|
path: '/',
|
|
8472
9029
|
meta: {},
|
|
8473
9030
|
});
|
|
9031
|
+
dismissSettingsOverlay();
|
|
9032
|
+
}
|
|
9033
|
+
|
|
9034
|
+
function toggleAdding(mode) {
|
|
9035
|
+
setAdding(adding === mode ? '' : mode);
|
|
8474
9036
|
}
|
|
8475
9037
|
|
|
8476
9038
|
return h('div', { className: 'rw-root' },
|
|
@@ -8481,23 +9043,30 @@ function attributeViolation(name, value, tagName) {
|
|
|
8481
9043
|
h('div', { className: 'rw-actions' },
|
|
8482
9044
|
h('button', {
|
|
8483
9045
|
type: 'button', className: 'rw-btn' + (adding === 'linked' ? '' : ' rw-btn-primary'),
|
|
8484
|
-
onClick: function () {
|
|
8485
|
-
}, adding === 'linked' ? IconClose(13) :
|
|
9046
|
+
onClick: function () { toggleAdding('linked'); },
|
|
9047
|
+
}, adding === 'linked' ? IconClose(13) : IconLinkedWorkspace(13), t('createLinked')),
|
|
8486
9048
|
h('button', {
|
|
8487
9049
|
type: 'button', className: 'rw-btn' + (adding === 'remote' ? '' : ' rw-btn-primary'),
|
|
8488
|
-
onClick: function () {
|
|
8489
|
-
}, adding === 'remote' ? IconClose(13) :
|
|
9050
|
+
onClick: function () { toggleAdding('remote'); },
|
|
9051
|
+
}, adding === 'remote' ? IconClose(13) : IconRemoteWorkspace(13), t('createRemote')))),
|
|
8490
9052
|
!sidebarAvailable ? h(Banner, { kind: 'warn' }, t('needsSidebar')) : null,
|
|
8491
9053
|
h(ThemeGroup, { t: t, locale: locale }),
|
|
8492
9054
|
h(EditorSettingsGroup, { t: t, locale: locale }),
|
|
8493
|
-
adding
|
|
9055
|
+
adding === 'linked'
|
|
8494
9056
|
? h(AddWorkspaceFlow, {
|
|
8495
|
-
ctx: ctx, t: t, locale: locale,
|
|
9057
|
+
ctx: ctx, t: t, locale: locale,
|
|
9058
|
+
onDone: function () { setAdding(''); remote.reload(); },
|
|
9059
|
+
onCancel: function () { setAdding(''); },
|
|
9060
|
+
})
|
|
9061
|
+
: null,
|
|
9062
|
+
adding === 'remote'
|
|
9063
|
+
? h(AddRemoteWorkspaceFlow, {
|
|
9064
|
+
ctx: ctx, t: t, locale: locale,
|
|
8496
9065
|
onDone: function () { setAdding(''); remote.reload(); },
|
|
8497
9066
|
onCancel: function () { setAdding(''); },
|
|
8498
9067
|
})
|
|
8499
9068
|
: null,
|
|
8500
|
-
remote.data.error ? h(Banner, { kind: 'error' }, t('
|
|
9069
|
+
remote.data.error ? h(Banner, { kind: 'error' }, t('remoteWorkspacesFailed') + ':' + messageOf(remote.data.error, t, locale)) : null,
|
|
8501
9070
|
remote.data.hostError ? h(Banner, { kind: 'error' }, t('hostsFailed') + ':' + messageOf(remote.data.hostError, t, locale)) : null,
|
|
8502
9071
|
remote.data.linkError ? h(Banner, { kind: 'error' }, t('linksFailed') + ':' + messageOf(remote.data.linkError, t, locale)) : null,
|
|
8503
9072
|
h('div', { className: 'rw-group' },
|
|
@@ -8520,15 +9089,13 @@ function attributeViolation(name, value, tagName) {
|
|
|
8520
9089
|
}))),
|
|
8521
9090
|
h('div', { className: 'rw-group' },
|
|
8522
9091
|
h('div', { className: 'rw-group-head' },
|
|
8523
|
-
h('span', { className: 'rw-group-title' }, t('
|
|
8524
|
-
h('span', { className: 'rw-chip' }, String(
|
|
8525
|
-
h('span', { className: 'rw-group-hint' }, t('
|
|
8526
|
-
|
|
8527
|
-
? h('div', { className: 'rw-
|
|
8528
|
-
h('div', { className: 'rw-empty-title' }, t('emptyTitle')),
|
|
8529
|
-
h('div', { className: 'rw-empty-body' }, hosts.length === 0 ? t('emptyHint') : t('emptyBody')))
|
|
9092
|
+
h('span', { className: 'rw-group-title' }, t('remoteGroup')),
|
|
9093
|
+
h('span', { className: 'rw-chip' }, String(remotes.length)),
|
|
9094
|
+
h('span', { className: 'rw-group-hint' }, t('remoteHint'))),
|
|
9095
|
+
remotes.length === 0
|
|
9096
|
+
? h('div', { className: 'rw-hint' }, t('remoteEmpty'))
|
|
8530
9097
|
: h('div', { className: 'rw-list' },
|
|
8531
|
-
|
|
9098
|
+
remotes.map(function (workspace) {
|
|
8532
9099
|
return h(RemoteWorkspaceCard, {
|
|
8533
9100
|
key: workspace.id,
|
|
8534
9101
|
workspace: workspace,
|
|
@@ -8538,14 +9105,16 @@ function attributeViolation(name, value, tagName) {
|
|
|
8538
9105
|
refresh: remote.reload,
|
|
8539
9106
|
});
|
|
8540
9107
|
}))),
|
|
8541
|
-
h('div', { className: 'rw-inline', style: { justifyContent: '
|
|
8542
|
-
h('span', { className: 'rw-hint' }, workspaces.length + ' ' + t('remoteGroup') + ' · ' + links.length + ' ' + t('linkedGroup')),
|
|
9108
|
+
h('div', { className: 'rw-inline', style: { justifyContent: 'flex-end' } },
|
|
8543
9109
|
h('button', { type: 'button', className: 'rw-btn rw-btn-ghost rw-btn-sm', onClick: remote.reload }, IconRefresh(12), t('refresh'))));
|
|
8544
9110
|
}
|
|
8545
9111
|
|
|
8546
9112
|
// ── apply ──────────────────────────────────────────────────────────────
|
|
8547
9113
|
|
|
8548
|
-
|
|
9114
|
+
// `sessions` is a core client service (the sidebar shell injects it too):
|
|
9115
|
+
// the directory entries need the focused session's cwd/workspaceId to
|
|
9116
|
+
// decide whether they belong in the "+" menu.
|
|
9117
|
+
var inject = ['slots', 'locale', 'sessions'];
|
|
8549
9118
|
|
|
8550
9119
|
function apply(ctx) {
|
|
8551
9120
|
ctx.effect(installStyles, 'dsh-linked-workspace: styles');
|
|
@@ -8625,12 +9194,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
8625
9194
|
|
|
8626
9195
|
function registerSidebarTabs() {
|
|
8627
9196
|
if (sidebarRegistered) return;
|
|
8628
|
-
var sidebar =
|
|
8629
|
-
try {
|
|
8630
|
-
sidebar = ctx.get('betterSidebar');
|
|
8631
|
-
} catch (error) {
|
|
8632
|
-
sidebar = undefined;
|
|
8633
|
-
}
|
|
9197
|
+
var sidebar = sidebarService(ctx);
|
|
8634
9198
|
if (!sidebar || typeof sidebar.registerTab !== 'function') return;
|
|
8635
9199
|
sidebarRegistered = true;
|
|
8636
9200
|
if (tabPollTimer !== null) {
|
|
@@ -8639,22 +9203,97 @@ function attributeViolation(name, value, tagName) {
|
|
|
8639
9203
|
}
|
|
8640
9204
|
var syncDirectoryTabsInFlight = false;
|
|
8641
9205
|
|
|
8642
|
-
|
|
9206
|
+
// The "+" menu filters on `descriptor.hidden` and only maps `available`
|
|
9207
|
+
// to a disabled flag, so a per-session entry has to be hidden rather
|
|
9208
|
+
// than marked unavailable. These two helpers resolve the session on
|
|
9209
|
+
// screen right when the menu asks, which keeps the entries in sync with
|
|
9210
|
+
// the workspace kind without unregistering anything (an unregistered
|
|
9211
|
+
// kind would orphan its open pages and break "Open directory tree").
|
|
9212
|
+
var activeScopeCache = { cwd: '', workspaceId: '' };
|
|
9213
|
+
|
|
9214
|
+
function readActiveScope() {
|
|
9215
|
+
var info = { cwd: '', workspaceId: '' };
|
|
9216
|
+
try {
|
|
9217
|
+
var snapshot = typeof sidebar.getSnapshot === 'function' ? sidebar.getSnapshot() : null;
|
|
9218
|
+
var sessionId = snapshot && snapshot.sessionId;
|
|
9219
|
+
if (!sessionId) return info;
|
|
9220
|
+
var sessions = ctx.sessions || (ctx.get && ctx.get('sessions'));
|
|
9221
|
+
var list = sessions && sessions.list ? sessions.list : sessions;
|
|
9222
|
+
var sessionState = list && typeof list.getSnapshot === 'function' ? list.getSnapshot() : null;
|
|
9223
|
+
var record = sessionState && sessionState.byId ? sessionState.byId[sessionId] : null;
|
|
9224
|
+
if (record) {
|
|
9225
|
+
info.cwd = record.cwd || '';
|
|
9226
|
+
info.workspaceId = record.workspaceId || '';
|
|
9227
|
+
}
|
|
9228
|
+
} catch (error) { /* fall back to an empty scope */ }
|
|
9229
|
+
return info;
|
|
9230
|
+
}
|
|
9231
|
+
|
|
9232
|
+
function activeScope() {
|
|
9233
|
+
activeScopeCache = readActiveScope();
|
|
9234
|
+
return activeScopeCache;
|
|
9235
|
+
}
|
|
9236
|
+
|
|
9237
|
+
function linkedTabHidden() {
|
|
9238
|
+
var scope = activeScope();
|
|
9239
|
+
return !(isLinkedScope(scope) || isLinkedWorkspaceId(scope.workspaceId));
|
|
9240
|
+
}
|
|
9241
|
+
|
|
9242
|
+
function remoteTabHidden() {
|
|
9243
|
+
var scope = activeScope();
|
|
9244
|
+
return !(isRemoteScope(scope) || isRemoteWorkspaceId(scope.workspaceId));
|
|
9245
|
+
}
|
|
9246
|
+
|
|
9247
|
+
// `hidden` is read whenever the sidebar builds its "+" entries, so the
|
|
9248
|
+
// answer is always fresh — but the sidebar only rebuilds those entries
|
|
9249
|
+
// when something notifies it. Re-registering the same two descriptors
|
|
9250
|
+
// notifies without touching the stored tabs, so open pages survive.
|
|
9251
|
+
var visibilitySignature = '';
|
|
9252
|
+
|
|
9253
|
+
function currentVisibilitySignature() {
|
|
9254
|
+
return (linkedTabHidden() ? '0' : '1') + (remoteTabHidden() ? '0' : '1');
|
|
9255
|
+
}
|
|
9256
|
+
|
|
9257
|
+
function syncTabVisibility() {
|
|
9258
|
+
var next = currentVisibilitySignature();
|
|
9259
|
+
if (next === visibilitySignature) return;
|
|
9260
|
+
visibilitySignature = next;
|
|
9261
|
+
if (linkedTabDisposer === null && remoteTabDisposer === null) return;
|
|
9262
|
+
disposeLinkedTab();
|
|
9263
|
+
disposeRemoteTab();
|
|
9264
|
+
installLinkedTab(false);
|
|
9265
|
+
installRemoteTab(false);
|
|
9266
|
+
}
|
|
9267
|
+
|
|
9268
|
+
function watchSessionScope() {
|
|
9269
|
+
visibilitySignature = currentVisibilitySignature();
|
|
9270
|
+
try {
|
|
9271
|
+
var sessions = ctx.sessions || (ctx.get && ctx.get('sessions'));
|
|
9272
|
+
var list = sessions && (sessions.list || sessions);
|
|
9273
|
+
if (!list || typeof list.subscribe !== 'function') return;
|
|
9274
|
+
var unsubscribe = list.subscribe(function () { syncTabVisibility(); });
|
|
9275
|
+
if (typeof unsubscribe === 'function') tabDisposers.push(unsubscribe);
|
|
9276
|
+
} catch (error) { /* without a store the entries simply stay as they are */ }
|
|
9277
|
+
}
|
|
9278
|
+
|
|
9279
|
+
function installLinkedTab(track) {
|
|
8643
9280
|
if (linkedTabDisposer !== null) return;
|
|
8644
9281
|
linkedTabDisposer = sidebar.registerTab({
|
|
8645
9282
|
id: TREE_TAB_TYPE,
|
|
8646
9283
|
title: function () { return makeT(readLocale(ctx))('tabTitle'); },
|
|
8647
9284
|
description: function () { return makeT(readLocale(ctx))('tabDesc'); },
|
|
8648
|
-
icon: function (size) { return
|
|
9285
|
+
icon: function (size) { return IconLinkedWorkspace(size); },
|
|
8649
9286
|
order: 62,
|
|
8650
9287
|
single: true,
|
|
8651
|
-
|
|
9288
|
+
get hidden() { return linkedTabHidden(); },
|
|
9289
|
+
available: function () { return true; },
|
|
8652
9290
|
component: function (props) {
|
|
8653
9291
|
var currentLocale = useLocale(ctx);
|
|
8654
9292
|
var t = useMemo(function () { return makeT(currentLocale); }, [currentLocale]);
|
|
8655
9293
|
return h(RemoteDirectoryTab, Object.assign({}, props, { ctx: ctx, t: t, locale: currentLocale, variant: 'linked' }));
|
|
8656
9294
|
},
|
|
8657
9295
|
});
|
|
9296
|
+
if (track !== false) tabDisposers.push(function () { disposeLinkedTab(); });
|
|
8658
9297
|
}
|
|
8659
9298
|
|
|
8660
9299
|
function disposeLinkedTab() {
|
|
@@ -8663,22 +9302,24 @@ function attributeViolation(name, value, tagName) {
|
|
|
8663
9302
|
linkedTabDisposer = null;
|
|
8664
9303
|
}
|
|
8665
9304
|
|
|
8666
|
-
function installRemoteTab() {
|
|
9305
|
+
function installRemoteTab(track) {
|
|
8667
9306
|
if (remoteTabDisposer !== null) return;
|
|
8668
9307
|
remoteTabDisposer = sidebar.registerTab({
|
|
8669
|
-
id:
|
|
9308
|
+
id: REMOTE_TREE_TAB_TYPE,
|
|
8670
9309
|
title: function () { return makeT(readLocale(ctx))('remoteTabTitle'); },
|
|
8671
9310
|
description: function () { return makeT(readLocale(ctx))('remoteTabDesc'); },
|
|
8672
|
-
icon: function (size) { return
|
|
9311
|
+
icon: function (size) { return IconRemoteWorkspace(size); },
|
|
8673
9312
|
order: 61,
|
|
8674
9313
|
single: true,
|
|
8675
|
-
|
|
9314
|
+
get hidden() { return remoteTabHidden(); },
|
|
9315
|
+
available: function () { return true; },
|
|
8676
9316
|
component: function (props) {
|
|
8677
9317
|
var currentLocale = useLocale(ctx);
|
|
8678
9318
|
var t = useMemo(function () { return makeT(currentLocale); }, [currentLocale]);
|
|
8679
9319
|
return h(RemoteDirectoryTab, Object.assign({}, props, { ctx: ctx, t: t, locale: currentLocale, variant: 'remote' }));
|
|
8680
9320
|
},
|
|
8681
9321
|
});
|
|
9322
|
+
if (track !== false) tabDisposers.push(function () { disposeRemoteTab(); });
|
|
8682
9323
|
}
|
|
8683
9324
|
|
|
8684
9325
|
function disposeRemoteTab() {
|
|
@@ -8687,50 +9328,25 @@ function attributeViolation(name, value, tagName) {
|
|
|
8687
9328
|
remoteTabDisposer = null;
|
|
8688
9329
|
}
|
|
8689
9330
|
|
|
8690
|
-
|
|
8691
|
-
|
|
8692
|
-
|
|
8693
|
-
|
|
8694
|
-
|
|
8695
|
-
var snapshot = list && typeof list.getSnapshot === 'function' ? list.getSnapshot() : null;
|
|
8696
|
-
var record = snapshot && snapshot.byId ? snapshot.byId[sessionId] : null;
|
|
8697
|
-
if (!record) return null;
|
|
8698
|
-
var header = record.header || record;
|
|
8699
|
-
return { cwd: header.cwd || record.cwd || '', workspaceId: header.workspaceId || record.workspaceId || '' };
|
|
8700
|
-
} catch (error) {
|
|
8701
|
-
return null;
|
|
8702
|
-
}
|
|
8703
|
-
}
|
|
8704
|
-
|
|
8705
|
-
function isLinkedSessionInfo(info) {
|
|
8706
|
-
return Boolean(info && ((info.cwd && isLinkedScope({ cwd: info.cwd })) || isLinkedWorkspaceId(info.workspaceId)));
|
|
8707
|
-
}
|
|
8708
|
-
|
|
9331
|
+
// Both page kinds stay registered for the whole session: `available`
|
|
9332
|
+
// only greys out the "+" entry for a mismatched session, while
|
|
9333
|
+
// `openTab` refuses a kind it has never seen. Registering lazily per
|
|
9334
|
+
// session meant "open the tree" from the settings page silently did
|
|
9335
|
+
// nothing whenever the workspace was not the one on screen.
|
|
8709
9336
|
function syncDirectoryTabs() {
|
|
8710
9337
|
if (syncDirectoryTabsInFlight) return;
|
|
8711
9338
|
syncDirectoryTabsInFlight = true;
|
|
8712
9339
|
refreshDirectoryAvailability().catch(function () { /* ignore */ }).then(function () {
|
|
8713
|
-
|
|
8714
|
-
|
|
8715
|
-
var snapshot = typeof sidebar.getSnapshot === 'function' ? sidebar.getSnapshot() : null;
|
|
8716
|
-
var sessionId = snapshot && snapshot.sessionId;
|
|
8717
|
-
if (!sessionId) {
|
|
8718
|
-
disposeLinkedTab();
|
|
8719
|
-
return undefined;
|
|
8720
|
-
}
|
|
8721
|
-
var clientInfo = activeSessionClientInfo(sessionId);
|
|
8722
|
-
if (isLinkedSessionInfo(clientInfo)) {
|
|
8723
|
-
installLinkedTab();
|
|
8724
|
-
return undefined;
|
|
8725
|
-
}
|
|
8726
|
-
return apiCall('session.info', { sessionId: sessionId }).then(function (info) {
|
|
8727
|
-
if (isLinkedSessionInfo(info)) installLinkedTab();
|
|
8728
|
-
else disposeLinkedTab();
|
|
8729
|
-
}).catch(function () { disposeLinkedTab(); });
|
|
8730
|
-
}).catch(function () { /* ignore */ }).then(function () { syncDirectoryTabsInFlight = false; });
|
|
9340
|
+
syncDirectoryTabsInFlight = false;
|
|
9341
|
+
});
|
|
8731
9342
|
}
|
|
8732
9343
|
|
|
8733
9344
|
syncDirectoryTabsRef = syncDirectoryTabs;
|
|
9345
|
+
refreshTabVisibilityRef = syncTabVisibility;
|
|
9346
|
+
installLinkedTab();
|
|
9347
|
+
installRemoteTab();
|
|
9348
|
+
watchSessionScope();
|
|
9349
|
+
syncTabVisibility();
|
|
8734
9350
|
try {
|
|
8735
9351
|
tabDisposers.push(sidebar.subscribeState(function () { syncDirectoryTabs(); }));
|
|
8736
9352
|
} catch (error) { /* state subscription is optional */ }
|
|
@@ -8775,22 +9391,11 @@ function attributeViolation(name, value, tagName) {
|
|
|
8775
9391
|
}
|
|
8776
9392
|
}
|
|
8777
9393
|
|
|
8778
|
-
// Tabs persisted before the 0.3.0 rename still carry the old type
|
|
8779
|
-
// register hidden
|
|
8780
|
-
// showing "no available view" for the legacy tab.
|
|
9394
|
+
// Tabs persisted before the 0.3.0 rename still carry the old file type
|
|
9395
|
+
// id; register a hidden alias so a reloaded page restores it instead of
|
|
9396
|
+
// showing "no available view" for the legacy tab. The legacy tree kind
|
|
9397
|
+
// ("dsh-remote-workspace") is now the real remote-workspace tab.
|
|
8781
9398
|
try {
|
|
8782
|
-
tabDisposers.push(sidebar.registerTab({
|
|
8783
|
-
id: 'dsh-remote-workspace',
|
|
8784
|
-
title: function () { return makeT(readLocale(ctx))('tabTitle'); },
|
|
8785
|
-
hidden: true,
|
|
8786
|
-
order: 64,
|
|
8787
|
-
single: true,
|
|
8788
|
-
component: function (props) {
|
|
8789
|
-
var currentLocale = useLocale(ctx);
|
|
8790
|
-
var t = useMemo(function () { return makeT(currentLocale); }, [currentLocale]);
|
|
8791
|
-
return h(RemoteDirectoryTab, Object.assign({}, props, { ctx: ctx, t: t, locale: currentLocale, variant: 'linked' }));
|
|
8792
|
-
},
|
|
8793
|
-
}));
|
|
8794
9399
|
tabDisposers.push(sidebar.registerTab({
|
|
8795
9400
|
id: 'dsh-remote-workspace:file',
|
|
8796
9401
|
title: function () { return makeT(readLocale(ctx))('fileTabTitle'); },
|