dsh-linked-workspace 0.10.0 → 0.12.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/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
- var REMOTE_TAB_TYPE = 'dsh-linked-workspace:remote';
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
- var hasRemoteDirectories = false;
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
- window.dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape', code: 'Escape', bubbles: true }));
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
- function rememberDirectoryAvailability(links, workspaces) {
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
- hasRemoteDirectories = Array.isArray(workspaces) && workspaces.length > 0;
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('workspaces.list').catch(function () { return { workspaces: [] }; }),
2065
+ apiCall('remote_workspaces.list').catch(function () { return { workspaces: [] }; }),
2014
2066
  ]).then(function (results) {
2015
- var links = results[0] && results[0].links ? results[0].links : [];
2016
- var workspaces = results[1] && results[1].workspaces ? results[1].workspaces : [];
2017
- rememberDirectoryAvailability(links, workspaces);
2018
- publishLinkedWorkspaceIcons(links);
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: '把已建立的 SSH 连接变成远程目录;或把本地目录与远端目录联动起来——会话可以直接读取、搜索和编辑远端文件。',
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: '选择一个已建立的 SSH 连接,就能把远端目录加进侧边栏。',
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',
@@ -2203,8 +2261,19 @@ function attributeViolation(name, value, tagName) {
2203
2261
  sheetTruncated: '仅显示前 {{rows}} 行 × {{cols}} 列',
2204
2262
  sheetMore: '工作表较多,仅显示前 20 个',
2205
2263
  noCredential: '缺少凭据',
2264
+ needPassword: '需要密码',
2265
+ sshPassword: 'SSH 密码',
2266
+ sshPasswordPlaceholder: '输入这台主机的密码',
2267
+ sshPasswordHint: '密码只保存在本机(DSH 数据目录的 ssh-credentials.json),只有本插件读取;不需要安装 SSH Manager 插件。',
2268
+ sshPasswordStored: '已保存密码,留空则保持不变',
2269
+ sshPasswordStoredHint: '已保存密码。想更换就重新输入,留空则继续使用原密码。',
2270
+ sshPasswordRequired: '请先在下面填写这台 SSH 主机的密码',
2271
+ sshVerify: '验证密码',
2272
+ sshVerifying: '验证中…',
2273
+ sshPasswordOk: '密码可用,可以继续创建。',
2274
+ sshPasswordFailed: '验证失败:',
2275
+ staleHost: 'DSH 的插件进程仍在运行旧版代码,请完全退出并重启 DSH 后再试',
2206
2276
  sourceManagerShort: 'SSH',
2207
- remoteGroup: '远程目录',
2208
2277
  linkedGroup: '联动工作区',
2209
2278
  linkedEmpty: '还没有联动工作区。联动工作区会把本地目录与远端目录配对,会话可直接编辑远端文件。',
2210
2279
  linkedName: '联动工作区',
@@ -2281,10 +2350,6 @@ function attributeViolation(name, value, tagName) {
2281
2350
  docPageOf: '第 {page} / {total} 页',
2282
2351
  docExportDone: '已导出 PDF:{path}',
2283
2352
  docPreviewFailed: '预览失败',
2284
- remoteTabTitle: '远程目录',
2285
- remoteTabDesc: '只读查看已添加的远程目录及其文件,不允许编辑。',
2286
- remoteDirsTitle: '远程目录',
2287
- remoteDirsHint: '直接浏览远端目录(只读)。',
2288
2353
  linkedTitle: '联动工作区',
2289
2354
  linkedHint: '本地目录与远端目录成对出现:DSH 会话在该本地目录中工作,并通过 linked_workspace 工具直接编辑远端文件。',
2290
2355
  localFlow: '本地目录',
@@ -2307,6 +2372,32 @@ function attributeViolation(name, value, tagName) {
2307
2372
  openInTab: '在标签中打开',
2308
2373
  linkedBadge: '本地 ⇄ 远端',
2309
2374
  linkedChip: '联动',
2375
+ remoteChip: '远程',
2376
+ remoteGroup: '远程工作区',
2377
+ remoteEmpty: '还没有远程工作区。远程工作区会让会话直接运行在 SSH 主机的目录里,本地不落任何项目文件。',
2378
+ remoteTitle: '远程工作区',
2379
+ remoteHint: '会话运行在远端目录:DSH 不在本地创建项目文件,模型通过 remote_workspace 与 linked_workspace 工具读写远端。',
2380
+ addRemote: '添加远程工作区',
2381
+ createRemote: '创建远程工作区',
2382
+ remoteTabTitle: '远程工作区目录',
2383
+ remoteTabDesc: '远程工作区的远端目录;点击文件在新标签页打开。',
2384
+ remotePlaceholderLabel: '本地占位目录',
2385
+ remotePlaceholderHint: '占位目录只用于把工作区注册进 DSH,不会同步任何远端文件;请不要在里面存放项目文件。',
2386
+ remoteCreateFailed: '创建远程工作区失败',
2387
+ remoteUpdateFailed: '重命名远程工作区失败',
2388
+ remoteRemoveFailed: '移除远程工作区失败',
2389
+ remoteRemoved: '已移除远程工作区',
2390
+ removeRemote: '移除远程工作区',
2391
+ remoteRemoveHint: '只移除记录与占位目录,不会删除远端文件。',
2392
+ remoteSessionHint: '在该工作区下新建会话即可直接使用远端目录。',
2393
+ flowRemote: '远程工作区',
2394
+ flowRemoteDesc: '会话运行在远端目录,本地只保留一个占位目录',
2395
+ localSideMissing: '该工作区没有本地目录',
2396
+ remoteWorkspacesFailed: '读取远程工作区失败',
2397
+ openTree: '打开目录树',
2398
+ testConnection: '测试连接',
2399
+ testFailed: '连接失败',
2400
+ rename: '重命名',
2310
2401
  pathLocalShort: '本地',
2311
2402
  pathRemoteShort: '远端',
2312
2403
  flowTitle: '添加工作区',
@@ -2449,14 +2540,13 @@ function attributeViolation(name, value, tagName) {
2449
2540
  };
2450
2541
 
2451
2542
  var EN = {
2452
- settingsNav: 'Connections',
2453
- title: 'Connections & Linked Workspaces',
2454
- intro: 'Turn an existing SSH connection into a remote directory, or pair a local folder with a remote folder so sessions can read, search and edit remote files directly.',
2543
+ settingsNav: 'Linked workspaces',
2544
+ title: 'Linked & remote workspaces',
2545
+ 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
2546
  addWorkspace: 'Add workspace',
2456
2547
  addRemoteDir: 'Add remote directory',
2457
2548
  addLinked: 'Add linked workspace',
2458
2549
  createLinked: 'Create linked workspace',
2459
- addAction: 'Add',
2460
2550
  addShort: 'Add',
2461
2551
  refresh: 'Refresh',
2462
2552
  open: 'Open',
@@ -2465,15 +2555,17 @@ function attributeViolation(name, value, tagName) {
2465
2555
  remove: 'Remove',
2466
2556
  confirmRemove: 'Confirm remove',
2467
2557
  removeHint: 'Removes the record only; remote files stay untouched.',
2468
- emptyTitle: 'No remote directories yet',
2469
- emptyBody: 'Pick an SSH connection you already set up to bring a remote directory into the sidebar.',
2558
+ emptyTitle: 'No workspace to browse yet',
2559
+ emptyBody: 'Create a linked or remote workspace in Settings → Connections, or from “Add workspace” on the left.',
2470
2560
  emptyHint: 'No SSH connections found. Add a host in the Side card’s SSH Tunnel panel first.',
2471
2561
  stepHost: '1. Choose an SSH connection',
2472
2562
  stepPath: '2. Remote directory',
2473
2563
  stepLocalPath: '3. Local directory',
2474
2564
  stepName: '4. Workspace name',
2565
+ remoteStepName: '3. Workspace name',
2475
2566
  pathPlaceholder: '/home/you/project',
2476
2567
  localPathPlaceholder: 'C:\\Users\\you\\projects\\demo',
2568
+ localPathRequired: 'Choose or enter a local directory first',
2477
2569
  namePlaceholder: 'Defaults to the directory name',
2478
2570
  browse: 'Browse…',
2479
2571
  browsing: 'Browsing…',
@@ -2489,6 +2581,7 @@ function attributeViolation(name, value, tagName) {
2489
2581
  connected: 'Connected',
2490
2582
  idle: 'Not connected',
2491
2583
  errorState: 'Connection error',
2584
+ disconnected: 'Connection lost',
2492
2585
  testOk: 'Connection OK',
2493
2586
  testFail: 'Connection failed',
2494
2587
  testRunning: 'Testing…',
@@ -2525,7 +2618,7 @@ function attributeViolation(name, value, tagName) {
2525
2618
  moveHint: 'Open the destination folder, then click “Use this directory”',
2526
2619
  ctxMove: 'Move to…',
2527
2620
  noWorkspace: 'This remote workspace no longer exists. Add it again.',
2528
- noTarget: 'No remote directory is available. Add one in Settings → Connections, or click “Add workspace” on the left.',
2621
+ noTarget: 'No workspace to browse. Create one in Settings → Connections, or click “Add workspace” on the left.',
2529
2622
  treeEmpty: 'Empty directory',
2530
2623
  sourceManager: 'SSH Manager',
2531
2624
  sourceConfig: '~/.ssh/config',
@@ -2585,8 +2678,19 @@ function attributeViolation(name, value, tagName) {
2585
2678
  sheetTruncated: 'Showing the first {{rows}} rows × {{cols}} columns',
2586
2679
  sheetMore: 'Showing the first 20 worksheets only',
2587
2680
  noCredential: 'No credentials',
2681
+ needPassword: 'Password needed',
2682
+ sshPassword: 'SSH password',
2683
+ sshPasswordPlaceholder: 'Enter the password for this host',
2684
+ sshPasswordHint: 'Stored on this machine only (ssh-credentials.json in the DSH data directory) and read by this plugin. The SSH Manager plugin is not required.',
2685
+ sshPasswordStored: 'Password stored — leave empty to keep it',
2686
+ sshPasswordStoredHint: 'A password is already stored. Type a new one to replace it, or leave empty to keep it.',
2687
+ sshPasswordRequired: 'Enter the password for this SSH host below first',
2688
+ sshVerify: 'Check password',
2689
+ sshVerifying: 'Checking…',
2690
+ sshPasswordOk: 'The password works — you can create the workspace now.',
2691
+ sshPasswordFailed: 'Check failed:',
2692
+ staleHost: 'The plugin host is still running older code; quit and restart DSH, then retry',
2588
2693
  sourceManagerShort: 'SSH',
2589
- remoteGroup: 'Remote directories',
2590
2694
  linkedGroup: 'Linked workspaces',
2591
2695
  linkedEmpty: 'No linked workspaces yet. A linked workspace pairs a local folder with a remote folder so sessions can edit remote files directly.',
2592
2696
  linkedName: 'Linked workspace',
@@ -2663,10 +2767,6 @@ function attributeViolation(name, value, tagName) {
2663
2767
  docPageOf: 'Page {page} / {total}',
2664
2768
  docExportDone: 'Exported PDF: {path}',
2665
2769
  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
2770
  linkedTitle: 'Linked workspaces',
2671
2771
  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
2772
  localFlow: 'Local folder',
@@ -2689,6 +2789,32 @@ function attributeViolation(name, value, tagName) {
2689
2789
  openInTab: 'Open in tab',
2690
2790
  linkedBadge: 'Local ⇄ remote',
2691
2791
  linkedChip: 'Linked',
2792
+ remoteChip: 'Remote',
2793
+ remoteGroup: 'Remote workspaces',
2794
+ remoteEmpty: 'No remote workspace yet. A remote workspace runs sessions directly inside an SSH host folder, so nothing is written to your machine.',
2795
+ remoteTitle: 'Remote workspaces',
2796
+ 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.',
2797
+ addRemote: 'Add remote workspace',
2798
+ createRemote: 'Create remote workspace',
2799
+ remoteTabTitle: 'Remote workspace tree',
2800
+ remoteTabDesc: 'The remote folder of this remote workspace; click a file to open it in a new tab.',
2801
+ remotePlaceholderLabel: 'Local placeholder',
2802
+ remotePlaceholderHint: 'The placeholder only registers the workspace in DSH and never mirrors remote files; do not keep project files in it.',
2803
+ remoteCreateFailed: 'Could not create the remote workspace',
2804
+ remoteUpdateFailed: 'Could not rename the remote workspace',
2805
+ remoteRemoveFailed: 'Could not remove the remote workspace',
2806
+ remoteRemoved: 'Remote workspace removed',
2807
+ removeRemote: 'Remove remote workspace',
2808
+ remoteRemoveHint: 'Only the record and the placeholder are removed; remote files are untouched.',
2809
+ remoteSessionHint: 'Start a session in this workspace to work directly in the remote folder.',
2810
+ flowRemote: 'Remote workspace',
2811
+ flowRemoteDesc: 'Sessions run in the remote folder; only a placeholder stays local',
2812
+ localSideMissing: 'This workspace has no local folder',
2813
+ remoteWorkspacesFailed: 'Could not read remote workspaces',
2814
+ openTree: 'Open tree',
2815
+ testConnection: 'Test connection',
2816
+ testFailed: 'Connection failed',
2817
+ rename: 'Rename',
2692
2818
  pathLocalShort: 'Local',
2693
2819
  pathRemoteShort: 'Remote',
2694
2820
  flowTitle: 'Add workspace',
@@ -2936,9 +3062,19 @@ function attributeViolation(name, value, tagName) {
2936
3062
 
2937
3063
  function messageOf(error, t, locale) {
2938
3064
  if (!error) return '';
3065
+ // `unknown method` means the page is newer than the Host process: the
3066
+ // plugin's server half only changes on restart.
3067
+ if (typeof error.message === 'string' && error.message.indexOf('unknown method:') === 0) {
3068
+ return t('staleHost') + ' (' + error.message + ')';
3069
+ }
2939
3070
  var known = error.code ? (locale === 'zh' ? CODE_TEXT.zh : CODE_TEXT.en)[error.code] : '';
2940
- if (known) return error.code === 'BAD_REQUEST' && error.message ? error.message : known;
2941
- return error.message || String(error);
3071
+ if (!known) return error.message || String(error);
3072
+ if (error.code === 'BAD_REQUEST' && error.message) return error.message;
3073
+ // Keep the server's own wording: "All configured authentication methods
3074
+ // failed" tells the user far more than the generic code text alone.
3075
+ var detail = typeof error.message === 'string' ? error.message.trim() : '';
3076
+ if (!detail || detail === known) return known;
3077
+ return known + (locale === 'zh' ? ':' : ': ') + detail;
2942
3078
  }
2943
3079
 
2944
3080
  function documentKindOf(path) {
@@ -3056,6 +3192,7 @@ function attributeViolation(name, value, tagName) {
3056
3192
  function scopeParams(scope) {
3057
3193
  if (!scope) return {};
3058
3194
  if (scope.kind === 'linked') return { linkedId: scope.id };
3195
+ if (scope.kind === 'remote') return { remoteId: scope.id };
3059
3196
  return { workspaceId: scope.id };
3060
3197
  }
3061
3198
 
@@ -3184,8 +3321,9 @@ function attributeViolation(name, value, tagName) {
3184
3321
  '.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
3322
  '.rw-btn:hover{background:var(--dsw-alias-interactive-bg-hover,rgba(127,127,127,.12))}',
3186
3323
  '.rw-btn:disabled{opacity:.5;cursor:not-allowed}',
3187
- '.rw-btn-primary{background:var(--dsw-alias-brand-primary);border-color:transparent;color:#fff}',
3324
+ '.rw-btn-primary{background:var(--dsw-alias-brand-primary);border-color:transparent;color:var(--dsw-alias-bg-base)}',
3188
3325
  '.rw-btn-primary:hover{filter:brightness(1.06)}',
3326
+ 'body[data-ds-dark-theme] .rw-btn-primary{color:#000}',
3189
3327
  '.rw-btn-ghost{background:transparent;border-color:transparent;color:var(--dsw-alias-label-secondary)}',
3190
3328
  '.rw-btn-ghost:hover{background:var(--dsw-alias-interactive-bg-hover,rgba(127,127,127,.12))}',
3191
3329
  '.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 +3342,11 @@ function attributeViolation(name, value, tagName) {
3204
3342
  '.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
3343
  '.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
3344
  '.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}',
3345
+ // Injected into the host's workspace hover preview, which always paints on
3346
+ // a fixed dark card, so these colours cannot follow the theme tokens.
3347
+ '.rw-hover-status{margin:1px 0 0;font-size:12px;line-height:18px;color:rgb(207,211,214)}',
3348
+ '.rw-hover-status.is-on{color:#3fb950}',
3349
+ '.rw-hover-status.is-off{color:#f85149}',
3207
3350
  '.rw-meta{display:flex;align-items:center;gap:8px;flex-wrap:wrap;min-width:0}',
3208
3351
  '.rw-meta-text{font-size:12px;line-height:18px;color:var(--dsw-alias-label-tertiary);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}',
3209
3352
  '.rw-pair{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:8px}',
@@ -3318,7 +3461,7 @@ function attributeViolation(name, value, tagName) {
3318
3461
  '.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
3462
  '.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
3463
  '.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:#fff}',
3464
+ '.rw-switch input:checked + .rw-switch-track .rw-switch-thumb{transform:translateX(12px);background:var(--dsw-alias-bg-base)}',
3322
3465
  '.rw-theme-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(168px,1fr));gap:10px}',
3323
3466
  '.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
3467
  '.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 +3659,53 @@ function attributeViolation(name, value, tagName) {
3516
3659
  };
3517
3660
  }
3518
3661
 
3519
- // ── linked workspace row icon ──────────────────────────────────────────
3662
+ // ── workspace row icons ────────────────────────────────────────────────
3520
3663
  // DSH renders a fixed folder glyph for every workspace row; the sidebar
3521
3664
  // gives plugins no per-row icon slot. This stylesheet swaps that glyph for
3522
- // a link icon on rows of linked workspaces (identified by the documented
3665
+ // the icon of the workspace kind (identified by the documented
3523
3666
  // data-row-key attribute). If the host markup ever changes the selector
3524
3667
  // simply stops matching and the folder glyph stays — a safe degradation.
3525
3668
 
3526
- var LINK_ICON_MASK = encodeURIComponent(
3527
- '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="none" stroke="black" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round">'
3528
- + '<path d="M6.4 9.6a2.8 2.8 0 0 0 4 0l2-2a2.8 2.8 0 0 0-4-4l-1 1"/>'
3529
- + '<path d="M9.6 6.4a2.8 2.8 0 0 0-4 0l-2 2a2.8 2.8 0 0 0 4 4l1-1"/>'
3530
- + '</svg>',
3531
- );
3669
+ // Filled 1024-unit shapes, shared by the row masks and the JSX icons so a
3670
+ // workspace looks the same in the sidebar, the settings cards, the dialogs
3671
+ // and the sidebar "+" menu.
3672
+ // Linked workspace: two interlocking chain links (local ⇄ remote).
3673
+ var LINKED_ICON_PATHS = [
3674
+ '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',
3675
+ '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',
3676
+ ];
3677
+ // Remote workspace: a display with an outbound arrow — the session itself
3678
+ // runs on the far side of the connection.
3679
+ var REMOTE_ICON_PATHS = [
3680
+ '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',
3681
+ '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',
3682
+ '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',
3683
+ ];
3684
+
3685
+ // Settings-nav glyph: a stack of sheets (the linked / remote pairing sits on
3686
+ // top of the plain local workspace). Registered through the host's
3687
+ // `settings.section.icon` seat so the settings list shows it instead of the
3688
+ // default gear.
3689
+ var SETTINGS_ICON_PATHS = [
3690
+ 'M20.66204445 509.34044445l475.70488888 256.27306667A35.10044445 35.10044445 0 0 0 542.72 753.6896a31.07271111 31.07271111 0 0 0-10.71786667-42.60977778c-0.63715555-0.38684445-1.29706667-0.73955555-1.96835555-1.08088888L54.35164445 453.72586667a35.11182222 35.11182222 0 0 0-46.31893334 11.91253333 31.08408889 31.08408889 0 0 0 10.68373334 42.63253334c0.62577778 0.37546667 1.28568889 0.73955555 1.9456 1.06951111z',
3691
+ 'M972.07182222 453.72586667l-475.70488889 256.27306667a31.07271111 31.07271111 0 0 0-13.65333333 41.75644444c0.34133333 0.65991111 0.69404445 1.30844445 1.06951111 1.93422222 9.29564445 15.38275555 30.04871111 20.69617778 46.31893334 11.92391112L1005.79555555 509.34044445a31.07271111 31.07271111 0 0 0 13.76711112-41.73368889c-0.32995555-0.67128889-0.69404445-1.31982222-1.13777778-1.96835556a35.10044445 35.10044445 0 0 0-46.35306667-11.91253333z',
3692
+ 'M20.66204445 701.54524445l475.70488888 256.27306667A35.10044445 35.10044445 0 0 0 542.72 945.84888889a31.07271111 31.07271111 0 0 0-10.71786667-42.60977777c-0.63715555-0.38684445-1.29706667-0.75093333-1.96835555-1.13777778L54.35164445 645.93066667a35.11182222 35.11182222 0 0 0-46.31893334 11.91253333 31.08408889 31.08408889 0 0 0 10.68373334 42.63253334c0.62577778 0.37546667 1.28568889 0.75093333 1.9456 1.06951111z',
3693
+ 'M972.07182222 645.93066667l-475.70488889 256.27306667a31.07271111 31.07271111 0 0 0-13.65333333 41.75644444c0.34133333 0.65991111 0.69404445 1.30844445 1.06951111 1.93422222 9.29564445 15.38275555 30.04871111 20.69617778 46.31893334 11.92391112L1005.79555555 701.54524445a31.07271111 31.07271111 0 0 0 13.76711112-41.73368889c-0.32995555-0.67128889-0.69404445-1.31982222-1.13777778-1.96835556a35.10044445 35.10044445 0 0 0-46.35306667-11.91253333z',
3694
+ 'M500.62222222 122.496L142.32462222 291.62666667 512 509.34044445l357.48977778-196.36906667z m3.77742223-70.54222222l483.04355555 249.42364444a13.75573333 13.75573333 0 0 1 6.53084445 17.80622223 12.12871111 12.12871111 0 0 1-5.12 5.50684444L520.64711111 581.76a13.23235555 13.23235555 0 0 1-13.07306666-0.38684444L23.54062222 296.24604445a13.65333333 13.65333333 0 0 1-5.44995555-18.20444445 12.25386667 12.25386667 0 0 1 5.44995555-5.13137778l469.17404445-221.27502222a13.18684445 13.18684445 0 0 1 11.71911111 0.31857778z',
3695
+ ];
3696
+
3697
+ var ICON_DISCONNECTED_COLOR = '#f85149';
3698
+ var ICON_BUSY_COLOR = '#2f81f7';
3699
+
3700
+ function iconMaskUrl(paths) {
3701
+ var markup = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" fill="black">'
3702
+ + paths.map(function (path) { return '<path d="' + path + '"/>'; }).join('')
3703
+ + '</svg>';
3704
+ return 'url("data:image/svg+xml,' + encodeURIComponent(markup) + '")';
3705
+ }
3706
+
3707
+ var LINKED_ICON_MASK = iconMaskUrl(LINKED_ICON_PATHS);
3708
+ var REMOTE_ICON_MASK = iconMaskUrl(REMOTE_ICON_PATHS);
3532
3709
 
3533
3710
  function workspaceIconStyleTag() {
3534
3711
  if (typeof document === 'undefined' || !document.head) return null;
@@ -3542,22 +3719,216 @@ function attributeViolation(name, value, tagName) {
3542
3719
  return tag;
3543
3720
  }
3544
3721
 
3545
- function publishLinkedWorkspaceIcons(links) {
3722
+ function stateOf(item) {
3723
+ var status = item && item.status;
3724
+ var state = status && status.state;
3725
+ return typeof state === 'string' && state !== '' ? state : 'idle';
3726
+ }
3727
+
3728
+ function isDisconnected(item) {
3729
+ return stateOf(item) === 'error';
3730
+ }
3731
+
3732
+ // Rows are React-rendered and get recreated on every sidebar update, so the
3733
+ // decorations have to be re-applied. A debounced observer handles that.
3734
+ var workspaceRowTips = [];
3735
+ var workspaceRowObserver = null;
3736
+ var workspaceRowTimer = null;
3737
+ var workspaceHoverRecords = {};
3738
+
3739
+ function applyWorkspaceRowTips() {
3740
+ if (typeof document === 'undefined') return;
3741
+ for (var index = 0; index < workspaceRowTips.length; index += 1) {
3742
+ var tip = workspaceRowTips[index];
3743
+ var rows = document.querySelectorAll('[data-row-key="workspace:' + tip.id + '"]');
3744
+ for (var rowIndex = 0; rowIndex < rows.length; rowIndex += 1) {
3745
+ var row = rows[rowIndex];
3746
+ if (tip.disconnected) row.setAttribute('data-lw-disconnected', 'true');
3747
+ else row.removeAttribute('data-lw-disconnected');
3748
+ // The native tooltip would pop up next to the hover preview card, so
3749
+ // the connection state is written into that card instead.
3750
+ if (row.hasAttribute('title')) row.removeAttribute('title');
3751
+ }
3752
+ }
3753
+ }
3754
+
3755
+ function queueWorkspaceRowTips() {
3756
+ if (typeof window === 'undefined' || workspaceRowTimer !== null) return;
3757
+ workspaceRowTimer = window.setTimeout(function () {
3758
+ workspaceRowTimer = null;
3759
+ applyWorkspaceRowTips();
3760
+ applyHoverCards();
3761
+ }, 200);
3762
+ if (workspaceRowTimer && typeof workspaceRowTimer.unref === 'function') workspaceRowTimer.unref();
3763
+ }
3764
+
3765
+ function watchWorkspaceRows() {
3766
+ if (workspaceRowObserver !== null) return;
3767
+ if (typeof MutationObserver === 'undefined' || typeof document === 'undefined' || !document.body) return;
3768
+ try {
3769
+ workspaceRowObserver = new MutationObserver(function () { queueWorkspaceRowTips(); });
3770
+ // Only structural changes: our own attribute writes must not retrigger it.
3771
+ workspaceRowObserver.observe(document.body, { childList: true, subtree: true });
3772
+ } catch (error) {
3773
+ workspaceRowObserver = null;
3774
+ }
3775
+ }
3776
+
3777
+ function statusLabel(t, item) {
3778
+ var state = stateOf(item);
3779
+ if (state === 'error') return item && item.status && item.status.reason === 'lost' ? t('disconnected') : t('errorState');
3780
+ return state === 'connected' ? t('connected') : t('idle');
3781
+ }
3782
+
3783
+ // ── workspace hover preview ────────────────────────────────────────────
3784
+ // The host renders the hover card itself (name / directory / created at)
3785
+ // inside a portal that lives outside our row, so it can only be enriched by
3786
+ // decorating it after it appears. Class names are hashed, hence the
3787
+ // substring selectors.
3788
+ var HOVER_CARD_QUERY = '[class*="hoverContent"]';
3789
+ var HOVER_LINE_ATTR = 'data-lw-hover-line';
3790
+ var hoverCardObserver = null;
3791
+ var hoverCardState = typeof WeakMap === 'function' ? new WeakMap() : null;
3792
+
3793
+ function clearHoverLines(card) {
3794
+ var injected = card.querySelectorAll('[' + HOVER_LINE_ATTR + ']');
3795
+ for (var index = 0; index < injected.length; index += 1) {
3796
+ var node = injected[index];
3797
+ if (node.parentNode) node.parentNode.removeChild(node);
3798
+ }
3799
+ }
3800
+
3801
+ function decorateHoverCard(card) {
3802
+ if (!card || !hoverCardState || !card.querySelector) return;
3803
+ var pathEl = card.querySelector('[class*="hoverPath"]');
3804
+ if (!pathEl) return;
3805
+ var known = hoverCardState.get(card);
3806
+ var current = (pathEl.textContent || '').trim();
3807
+ // Already decorated for this very content: nothing to do.
3808
+ if (known && known.rendered === current) return;
3809
+ // The host re-rendered the card for another workspace: drop our lines.
3810
+ if (known) clearHoverLines(card);
3811
+ var record = workspaceHoverRecords[linkedScopeKey(current)];
3812
+ if (!record || !record.remotePath) return;
3813
+ var t = makeT(readLocale());
3814
+ var remote = record.remotePath;
3815
+ var local = record.localPath || '';
3816
+
3817
+ var status = document.createElement('div');
3818
+ status.className = 'rw-hover-status' + (record.disconnected ? ' is-off' : record.connected ? ' is-on' : '');
3819
+ status.setAttribute(HOVER_LINE_ATTR, '1');
3820
+ status.textContent = record.status;
3821
+ var titleEl = card.querySelector('[class*="hoverTitle"]');
3822
+ var anchor = titleEl || pathEl;
3823
+ anchor.parentNode.insertBefore(status, anchor.nextSibling);
3824
+
3825
+ if (record.kind === 'linked' && local !== '') {
3826
+ pathEl.textContent = t('pathRemoteShort') + ' ' + remote;
3827
+ var localEl = pathEl.cloneNode(false);
3828
+ localEl.setAttribute(HOVER_LINE_ATTR, '1');
3829
+ localEl.textContent = t('pathLocalShort') + ' ' + local;
3830
+ pathEl.parentNode.insertBefore(localEl, pathEl.nextSibling);
3831
+ } else {
3832
+ pathEl.textContent = remote;
3833
+ }
3834
+
3835
+ // The card doubles as a "copy this path" button; keep its label in sync so
3836
+ // a remote workspace copies the remote directory, not the placeholder.
3837
+ var host = card.parentElement;
3838
+ var label = host && host.getAttribute ? host.getAttribute('aria-label') : null;
3839
+ if (label && current !== '' && label.indexOf(current) !== -1) {
3840
+ host.setAttribute('aria-label', label.split(current).join(remote));
3841
+ }
3842
+
3843
+ hoverCardState.set(card, { rendered: (pathEl.textContent || '').trim() });
3844
+ }
3845
+
3846
+ function applyHoverCards() {
3847
+ if (typeof document === 'undefined') return;
3848
+ var cards = document.querySelectorAll(HOVER_CARD_QUERY);
3849
+ for (var index = 0; index < cards.length; index += 1) decorateHoverCard(cards[index]);
3850
+ }
3851
+
3852
+ function watchHoverCards() {
3853
+ if (hoverCardObserver !== null) return;
3854
+ if (typeof MutationObserver === 'undefined' || typeof document === 'undefined' || !document.body) return;
3855
+ try {
3856
+ hoverCardObserver = new MutationObserver(function (records) {
3857
+ for (var index = 0; index < records.length; index += 1) {
3858
+ var added = records[index].addedNodes;
3859
+ for (var nodeIndex = 0; nodeIndex < added.length; nodeIndex += 1) {
3860
+ var node = added[nodeIndex];
3861
+ if (!node || node.nodeType !== 1) continue;
3862
+ if (node.closest) {
3863
+ var outer = node.closest(HOVER_CARD_QUERY);
3864
+ if (outer) decorateHoverCard(outer);
3865
+ }
3866
+ if (node.querySelectorAll) {
3867
+ var inner = node.querySelectorAll(HOVER_CARD_QUERY);
3868
+ for (var innerIndex = 0; innerIndex < inner.length; innerIndex += 1) decorateHoverCard(inner[innerIndex]);
3869
+ }
3870
+ }
3871
+ }
3872
+ });
3873
+ hoverCardObserver.observe(document.body, { childList: true, subtree: true });
3874
+ } catch (error) {
3875
+ hoverCardObserver = null;
3876
+ }
3877
+ }
3878
+
3879
+ function publishRowTips(entries) {
3880
+ var t = makeT(readLocale());
3881
+ var records = {};
3882
+ workspaceRowTips = entries.map(function (entry) {
3883
+ var item = entry.item || {};
3884
+ var linked = entry.kind === 'linked';
3885
+ var key = linkedScopeKey(linked ? item.localPath : item.placeholderPath);
3886
+ if (key !== '') {
3887
+ records[key] = {
3888
+ kind: entry.kind,
3889
+ name: item.name,
3890
+ remotePath: item.remotePath || '',
3891
+ localPath: linked ? (item.localPath || '') : '',
3892
+ status: statusLabel(t, item),
3893
+ connected: stateOf(item) === 'connected',
3894
+ disconnected: isDisconnected(item),
3895
+ };
3896
+ }
3897
+ return { id: entry.id, disconnected: isDisconnected(item) };
3898
+ });
3899
+ workspaceHoverRecords = records;
3900
+ applyWorkspaceRowTips();
3901
+ watchWorkspaceRows();
3902
+ watchHoverCards();
3903
+ applyHoverCards();
3904
+ }
3905
+
3906
+ function publishWorkspaceIcons(links, remotes) {
3546
3907
  var tag = workspaceIconStyleTag();
3547
3908
  if (!tag) return;
3548
- var mask = 'url("data:image/svg+xml,' + LINK_ICON_MASK + '")';
3549
- var rules = (links || []).map(function (link) {
3550
- var id = link && link.workspaceId ? String(link.workspaceId).replace(/[^0-9a-zA-Z-]/g, '') : '';
3909
+ var entries = [];
3910
+ (links || []).forEach(function (link) {
3911
+ entries.push({ item: link, id: link && link.workspaceId, mask: LINKED_ICON_MASK, running: Boolean(link.running), kind: 'linked' });
3912
+ });
3913
+ (remotes || []).forEach(function (workspace) {
3914
+ entries.push({ item: workspace, id: workspace && workspace.workspaceId, mask: REMOTE_ICON_MASK, running: false, kind: 'remote' });
3915
+ });
3916
+ var rules = entries.map(function (entry) {
3917
+ var id = entry.id ? String(entry.id).replace(/[^0-9a-zA-Z-]/g, '') : '';
3551
3918
  if (id === '') return '';
3552
3919
  var row = '[data-row-key="workspace:' + id + '"] > span:first-child';
3553
3920
  var rule = row + '{display:inline-flex;align-items:center;justify-content:center;flex:none;}'
3554
3921
  + row + ' svg{display:none!important;}'
3555
3922
  + 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
- if (link.running) rule += row + '::before{background:#2f81f7!important}';
3923
+ + '-webkit-mask:' + entry.mask + ' center/contain no-repeat;mask:' + entry.mask + ' center/contain no-repeat;}';
3924
+ // A dropped SSH connection turns the row icon red; a running mirror
3925
+ // sync keeps the existing accent highlight.
3926
+ if (isDisconnected(entry.item)) rule += row + '::before{background:' + ICON_DISCONNECTED_COLOR + '!important}';
3927
+ else if (entry.running) rule += row + '::before{background:' + ICON_BUSY_COLOR + '!important}';
3558
3928
  return rule;
3559
3929
  }).filter(function (rule) { return rule !== ''; });
3560
3930
  tag.textContent = rules.join('\n');
3931
+ publishRowTips(entries);
3561
3932
  }
3562
3933
 
3563
3934
  // ── icons (16px outline set, currentColor) ─────────────────────────────
@@ -3576,6 +3947,32 @@ function attributeViolation(name, value, tagName) {
3576
3947
  return h('svg', props, children);
3577
3948
  }
3578
3949
 
3950
+ // Filled workspace-kind icons. The supplied shapes are drawn on a 1024 grid
3951
+ // and carry no stroke, so they are rendered apart from the outline set.
3952
+ function solidIcon(size, paths) {
3953
+ return h('svg', {
3954
+ width: size,
3955
+ height: size,
3956
+ viewBox: '0 0 1024 1024',
3957
+ fill: 'currentColor',
3958
+ xmlns: 'http://www.w3.org/2000/svg',
3959
+ 'aria-hidden': 'true',
3960
+ focusable: 'false',
3961
+ }, paths.map(function (path, index) { return h('path', { key: index, d: path }); }));
3962
+ }
3963
+
3964
+ function IconLinkedWorkspace(size) {
3965
+ return solidIcon(size || 14, LINKED_ICON_PATHS);
3966
+ }
3967
+
3968
+ function IconRemoteWorkspace(size) {
3969
+ return solidIcon(size || 14, REMOTE_ICON_PATHS);
3970
+ }
3971
+
3972
+ function IconSettingsNav(size) {
3973
+ return solidIcon(size || 16, SETTINGS_ICON_PATHS);
3974
+ }
3975
+
3579
3976
  function IconChevron(size) {
3580
3977
  return svg(size || 14, h('path', {
3581
3978
  d: 'm6 3 5 5-5 5', stroke: 'currentColor', strokeWidth: 1.6,
@@ -3755,14 +4152,14 @@ function attributeViolation(name, value, tagName) {
3755
4152
  // ── data hooks ─────────────────────────────────────────────────────────
3756
4153
 
3757
4154
  function useRemoteData(ctx) {
3758
- var dataState = useState({ loading: true, hosts: [], workspaces: [], links: [], error: null, hostError: null, linkError: null });
4155
+ var dataState = useState({ loading: true, hosts: [], remotes: [], links: [], error: null, hostError: null, linkError: null });
3759
4156
  var data = dataState[0];
3760
4157
  var setData = dataState[1];
3761
4158
  var alive = useRef(true);
3762
4159
 
3763
4160
  var load = useCallback(function () {
3764
4161
  var jobs = [
3765
- apiCall('workspaces.list').then(function (result) { return { workspaces: result.workspaces || [] }; }),
4162
+ apiCall('remote_workspaces.list').then(function (result) { return { remotes: result.workspaces || [] }; }),
3766
4163
  apiCall('hosts.list').then(function (result) { return { hosts: result.hosts || [] }; }),
3767
4164
  apiCall('linked.list').then(function (result) { return { links: result.links || [] }; }),
3768
4165
  ];
@@ -3770,22 +4167,22 @@ function attributeViolation(name, value, tagName) {
3770
4167
  return promise.then(function (value) { return { ok: true, value: value }; }, function (error) { return { ok: false, error: error }; });
3771
4168
  })).then(function (results) {
3772
4169
  if (!alive.current) return;
3773
- var workspacesResult = results[0];
4170
+ var remotesResult = results[0];
3774
4171
  var hostsResult = results[1];
3775
4172
  var linksResult = results[2];
3776
4173
  setData(function (previous) {
3777
4174
  return {
3778
4175
  loading: false,
3779
- workspaces: workspacesResult.ok ? workspacesResult.value.workspaces : previous.workspaces,
4176
+ remotes: remotesResult.ok ? remotesResult.value.remotes : previous.remotes,
3780
4177
  hosts: hostsResult.ok ? hostsResult.value.hosts : previous.hosts,
3781
4178
  links: linksResult.ok ? linksResult.value.links : previous.links,
3782
- error: workspacesResult.ok ? null : workspacesResult.error,
4179
+ error: remotesResult.ok ? null : remotesResult.error,
3783
4180
  hostError: hostsResult.ok ? null : hostsResult.error,
3784
4181
  linkError: linksResult.ok ? null : linksResult.error,
3785
4182
  };
3786
4183
  });
3787
- rememberDirectoryAvailability(linksResult.ok ? linksResult.value.links : [], workspacesResult.ok ? workspacesResult.value.workspaces : []);
3788
- publishLinkedWorkspaceIcons(linksResult.ok ? linksResult.value.links : []);
4184
+ rememberDirectoryAvailability(linksResult.ok ? linksResult.value.links : [], remotesResult.ok ? remotesResult.value.remotes : []);
4185
+ publishWorkspaceIcons(linksResult.ok ? linksResult.value.links : [], remotesResult.ok ? remotesResult.value.remotes : []);
3789
4186
  });
3790
4187
  }, []);
3791
4188
 
@@ -3804,13 +4201,28 @@ function attributeViolation(name, value, tagName) {
3804
4201
 
3805
4202
  // ── small building blocks ───────────────────────────────────────────────
3806
4203
 
4204
+ function statusTitle(t, item) {
4205
+ var status = (item && item.status) || {};
4206
+ if (status.state === 'connected') {
4207
+ return typeof status.latencyMs === 'number' ? t('connected') + ' · ' + status.latencyMs + ' ms' : t('connected');
4208
+ }
4209
+ if (status.state === 'error') {
4210
+ if (status.reason === 'lost') return t('disconnected');
4211
+ return status.message ? t('errorState') + ' · ' + status.message : t('errorState');
4212
+ }
4213
+ return t('idle');
4214
+ }
4215
+
3807
4216
  function StatusPill(props) {
3808
4217
  var t = props.t;
3809
4218
  var status = props.status || { state: 'idle' };
3810
4219
  var cls = status.state === 'connected' ? 'rw-dot-ok' : status.state === 'error' ? 'rw-dot-error' : '';
3811
- var label = status.state === 'connected' ? t('connected') : status.state === 'error' ? t('errorState') : t('idle');
3812
- var title = status.state === 'error' ? status.message || '' : status.state === 'connected' && status.latencyMs ? t('latency') + ' ' + status.latencyMs + ' ms' : '';
3813
- return h('span', { className: 'rw-chip', title: title || label },
4220
+ var label = status.state === 'connected'
4221
+ ? t('connected')
4222
+ : status.state === 'error'
4223
+ ? (status.reason === 'lost' ? t('disconnected') : t('errorState'))
4224
+ : t('idle');
4225
+ return h('span', { className: 'rw-chip', title: statusTitle(t, props) || label },
3814
4226
  h('span', { className: 'rw-dot ' + cls }),
3815
4227
  label);
3816
4228
  }
@@ -4438,7 +4850,7 @@ function attributeViolation(name, value, tagName) {
4438
4850
  var local = props.local === true;
4439
4851
  var readOnly = props.readOnly === true;
4440
4852
  var filePath = props.path;
4441
- var sidebar = ctx.get && ctx.get('betterSidebar');
4853
+ var sidebar = sidebarService(ctx);
4442
4854
  var settings = useRuntimeSettings();
4443
4855
  var theme = getTheme(resolveEditorTheme(settings));
4444
4856
  var language = languageOf(filePath);
@@ -4890,13 +5302,14 @@ function attributeViolation(name, value, tagName) {
4890
5302
 
4891
5303
  function sourceScopeOf(source) {
4892
5304
  if (source && source.kind === 'linked') return { kind: 'linked', id: source.id };
5305
+ if (source && source.kind === 'remote') return { kind: 'remote', id: source.id };
4893
5306
  return { kind: 'workspace', id: source ? source.id : '' };
4894
5307
  }
4895
5308
 
4896
5309
  function sourceMetaOf(source) {
4897
- return source && source.kind === 'linked'
4898
- ? { linkedId: source.id, linkedName: source.name }
4899
- : { workspaceId: source ? source.id : undefined, workspaceName: source ? source.name : undefined };
5310
+ if (source && source.kind === 'linked') return { linkedId: source.id, linkedName: source.name };
5311
+ if (source && source.kind === 'remote') return { remoteId: source.id, remoteName: source.name };
5312
+ return { workspaceId: source ? source.id : undefined, workspaceName: source ? source.name : undefined };
4900
5313
  }
4901
5314
 
4902
5315
  function workspaceRelativePath(rootPath, filePath) {
@@ -5975,7 +6388,7 @@ function attributeViolation(name, value, tagName) {
5975
6388
  var remoteOnly = props.variant === 'remote';
5976
6389
  var data = useRemoteData(ctx);
5977
6390
  var settings = useRuntimeSettings();
5978
- var sidebar = ctx.get && ctx.get('betterSidebar');
6391
+ var sidebar = sidebarService(ctx);
5979
6392
  var selectedState = useState('');
5980
6393
  var selectedKey = selectedState[0];
5981
6394
  var setSelectedKey = selectedState[1];
@@ -6045,46 +6458,52 @@ function attributeViolation(name, value, tagName) {
6045
6458
  var pinnedLinkedId = tabMeta.linkedId ? String(tabMeta.linkedId) : '';
6046
6459
  var pinnedRemoteId = tabMeta.remoteId ? String(tabMeta.remoteId) : '';
6047
6460
  var sources = useMemo(function () {
6048
- var list = [];
6461
+ var pinned = remoteOnly ? pinnedRemoteId : pinnedLinkedId;
6049
6462
  var scopeKey = linkedScopeKey(scope && scope.cwd);
6050
- if (!remoteOnly) {
6051
- (data.data.links || []).forEach(function (link) {
6052
- if (pinnedLinkedId) { if (String(link.id) !== pinnedLinkedId) return; }
6053
- else if (scopeKey && linkedScopeKey(link.localPath) !== scopeKey) return;
6054
- list.push({
6055
- key: 'linked:' + link.id,
6056
- kind: 'linked',
6057
- id: link.id,
6058
- name: link.name,
6059
- localPath: link.localPath,
6060
- remotePath: link.remotePath,
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,
6463
+ var all = (remoteOnly ? (data.data.remotes || []) : (data.data.links || []));
6464
+ function pathOf(item) {
6465
+ return remoteOnly ? item.placeholderPath : item.localPath;
6466
+ }
6467
+ function toSource(item) {
6468
+ if (remoteOnly) {
6469
+ return {
6470
+ key: 'remote:' + item.id,
6471
+ kind: 'remote',
6472
+ id: item.id,
6473
+ name: item.name,
6076
6474
  localPath: null,
6077
- remotePath: workspace.remotePath,
6078
- host: workspace.host,
6079
- username: workspace.username,
6080
- hostName: workspace.hostName,
6475
+ placeholderPath: item.placeholderPath,
6476
+ remotePath: item.remotePath,
6477
+ host: item.host,
6478
+ username: item.username,
6479
+ hostName: item.hostName,
6081
6480
  mirror: false,
6082
- status: workspace.status,
6083
- });
6084
- });
6481
+ status: item.status,
6482
+ };
6483
+ }
6484
+ return {
6485
+ key: 'linked:' + item.id,
6486
+ kind: 'linked',
6487
+ id: item.id,
6488
+ name: item.name,
6489
+ localPath: item.localPath,
6490
+ remotePath: item.remotePath,
6491
+ host: item.host,
6492
+ username: item.username,
6493
+ hostName: item.hostName,
6494
+ mirror: item.mirror,
6495
+ status: item.status,
6496
+ };
6085
6497
  }
6086
- return list;
6087
- }, [data.data.links, data.data.workspaces, remoteOnly, scope && scope.cwd, pinnedLinkedId, pinnedRemoteId]);
6498
+ var matched = all.filter(function (item) {
6499
+ if (pinned) return String(item.id) === pinned;
6500
+ if (!scopeKey) return true;
6501
+ return linkedScopeKey(pathOf(item)) === scopeKey;
6502
+ });
6503
+ // 标签页也可能从起始页或设置页直接打开:当前会话不属于任何联动/远程工作区时,
6504
+ // 列出全部,而不是让标签页空着。
6505
+ return (matched.length === 0 && !pinned ? all : matched).map(toSource);
6506
+ }, [data.data.links, data.data.remotes, remoteOnly, scope && scope.cwd, pinnedLinkedId, pinnedRemoteId]);
6088
6507
 
6089
6508
  var selected = useMemo(function () {
6090
6509
  return sources.filter(function (source) { return source.key === selectedKey; })[0] || sources[0] || null;
@@ -6238,10 +6657,12 @@ function attributeViolation(name, value, tagName) {
6238
6657
 
6239
6658
  function openTerminal(side, atPath) {
6240
6659
  if (!selected) return;
6241
- var request = { side: side };
6660
+ if (side === 'local' && selected.kind !== 'linked') {
6661
+ showNotice('info', t('localSideMissing'));
6662
+ return;
6663
+ }
6664
+ var request = Object.assign({ side: side }, scopeParams(selected));
6242
6665
  if (typeof atPath === 'string' && atPath !== '') request.path = atPath;
6243
- if (selected.kind === 'linked') request.linkedId = selected.id;
6244
- else request.workspaceId = selected.id;
6245
6666
  apiCall('terminal.open', request).then(function () {
6246
6667
  showNotice('success', t('terminalOpened'));
6247
6668
  }).catch(function (error) {
@@ -7073,7 +7494,7 @@ function attributeViolation(name, value, tagName) {
7073
7494
  h(TreeSection, {
7074
7495
  key: 'remote:' + selected.key + ':' + version + ':' + (showHidden ? 'h' : 's'),
7075
7496
  title: t('remoteTree'),
7076
- icon: IconServer(11),
7497
+ icon: IconRemoteWorkspace(11),
7077
7498
  }, h(TreePanel, {
7078
7499
  key: 'remote:' + selected.key + ':' + version + ':' + (showHidden ? 'h' : 's'),
7079
7500
  kind: 'remote',
@@ -7243,9 +7664,9 @@ function attributeViolation(name, value, tagName) {
7243
7664
  key: source.key,
7244
7665
  type: 'button',
7245
7666
  className: 'rw-chip-btn' + (selected.key === source.key ? ' is-on' : ''),
7246
- title: source.name + ' · ' + source.remotePath,
7667
+ title: source.name + ' · ' + source.remotePath + ' · ' + statusTitle(t, source),
7247
7668
  onClick: function () { setSelectedKey(source.key); },
7248
- }, source.kind === 'linked' ? IconLink(11) : IconServer(11), h('span', { style: { overflow: 'hidden', textOverflow: 'ellipsis' } }, source.name));
7669
+ }, source.kind === 'linked' ? IconLinkedWorkspace(11) : source.kind === 'remote' ? IconRemoteWorkspace(11) : IconFolderTree(11), h('span', { style: { overflow: 'hidden', textOverflow: 'ellipsis' } }, source.name));
7249
7670
  }))
7250
7671
  : null,
7251
7672
  info,
@@ -7299,7 +7720,9 @@ function attributeViolation(name, value, tagName) {
7299
7720
  var meta = tab && tab.meta ? tab.meta : {};
7300
7721
  var scope = meta.linkedId
7301
7722
  ? { kind: 'linked', id: meta.linkedId }
7302
- : { kind: 'workspace', id: meta.workspaceId };
7723
+ : meta.remoteId
7724
+ ? { kind: 'remote', id: meta.remoteId }
7725
+ : { kind: 'workspace', id: meta.workspaceId };
7303
7726
  var filePath = tab && tab.path ? tab.path : '';
7304
7727
  return h('div', { className: 'rw-editor-pane' },
7305
7728
  h(RemoteFileEditor, {
@@ -7520,8 +7943,7 @@ function attributeViolation(name, value, tagName) {
7520
7943
  }
7521
7944
 
7522
7945
  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 });
7946
+ return Object.assign({ path: path, limit: TREE_PAGE_SIZE, offset: offset }, scopeParams(source));
7525
7947
  }
7526
7948
 
7527
7949
  function load(path) {
@@ -7618,13 +8040,15 @@ function attributeViolation(name, value, tagName) {
7618
8040
  className: 'rw-tree-ws-head',
7619
8041
  onClick: function () { setOpen(function (value) { return !value; }); },
7620
8042
  'aria-expanded': open,
8043
+ title: source.name + ' · ' + statusTitle(t, source),
7621
8044
  },
7622
8045
  h('span', { className: 'rw-chevron' + (open ? ' is-open' : '') }, IconChevron(12)),
7623
8046
  h('span', { className: 'rw-icon-chip' + (source.kind === 'linked' ? ' rw-icon-chip-link' : ''), style: { width: 24, height: 24, borderRadius: 7 } },
7624
- source.kind === 'linked' ? IconLink(13) : IconServer(13)),
8047
+ source.kind === 'linked' ? IconLinkedWorkspace(13) : source.kind === 'remote' ? IconRemoteWorkspace(13) : IconFolderTree(13)),
7625
8048
  h('span', { className: 'rw-tree-ws-title' },
7626
8049
  h('span', { className: 'rw-tree-ws-name' }, source.name),
7627
- h('span', { className: 'rw-tree-ws-sub' }, source.username + '@' + source.host + (source.kind === 'linked' ? ' · ' + t('linkedChip') : ''))),
8050
+ h('span', { className: 'rw-tree-ws-sub' }, source.username + '@' + source.host
8051
+ + (source.kind === 'linked' ? ' · ' + t('linkedChip') : source.kind === 'remote' ? ' · ' + t('remoteChip') : ''))),
7628
8052
  h(StatusPill, { status: source.status, t: t })),
7629
8053
  open
7630
8054
  ? h('div', { className: 'rw-tree-body', role: 'tree', 'aria-label': source.name },
@@ -7662,10 +8086,9 @@ function attributeViolation(name, value, tagName) {
7662
8086
  type: 'button',
7663
8087
  role: 'option',
7664
8088
  'aria-selected': on,
7665
- disabled: !usable,
7666
- title: usable ? host.name : t('noCredential'),
8089
+ title: host.name,
7667
8090
  className: 'rw-host' + (on ? ' is-on' : ''),
7668
- onClick: function () { if (usable && props.onSelect) props.onSelect(host); },
8091
+ onClick: function () { if (props.onSelect) props.onSelect(host); },
7669
8092
  },
7670
8093
  h('span', { className: 'rw-file-icon', style: { color: on ? 'var(--dsw-alias-brand-primary)' : undefined } }, IconServer(16)),
7671
8094
  h('span', { className: 'rw-host-main' },
@@ -7673,20 +8096,78 @@ function attributeViolation(name, value, tagName) {
7673
8096
  h('span', { className: 'rw-host-meta' }, host.username + '@' + host.host + ':' + host.port)),
7674
8097
  usable
7675
8098
  ? h('span', { className: 'rw-chip' }, host.source === 'ssh-config' ? t('sourceConfig') : t('sourceManager'))
7676
- : h('span', { className: 'rw-chip', style: { color: 'var(--dsw-alias-state-warn-primary)' } }, t('noCredential')));
8099
+ : h('span', { className: 'rw-chip', style: { color: 'var(--dsw-alias-state-warn-primary)' } }, t('needPassword')));
7677
8100
  }));
7678
8101
  }
7679
8102
 
7680
- function AddWorkspaceFlow(props) {
7681
- var ctx = props.ctx;
8103
+ // Password field for a host that has no usable key. The plugin keeps the
8104
+ // secret itself, so this works without the optional `dsh-ssh-tunnel` plugin.
8105
+ function SshCredentialField(props) {
8106
+ var t = props.t;
8107
+ var host = props.host;
8108
+ if (!host) return null;
8109
+ var stored = host.hasStoredPassword === true;
8110
+ var needed = host.hasCredential === false || host.authType === 'password';
8111
+ if (!needed && !stored) return null;
8112
+ var checkState = useState({ busy: false, ok: false, message: '' });
8113
+ var check = checkState[0];
8114
+ var setCheck = checkState[1];
8115
+ var inputRef = useRef(null);
8116
+ // Selecting a host that still needs a secret should put the cursor in the
8117
+ // password box, so the dialog asks for it instead of leaving the user to
8118
+ // find the field.
8119
+ useEffect(function () {
8120
+ if (!needed && !stored) return;
8121
+ var node = inputRef.current;
8122
+ if (node && typeof node.focus === 'function') node.focus();
8123
+ }, [host.id, needed, stored]);
8124
+ function verify() {
8125
+ if (check.busy || props.busy) return;
8126
+ var value = props.value || '';
8127
+ if (value === '') { setCheck({ busy: false, ok: false, message: t('sshPasswordRequired') }); return; }
8128
+ setCheck({ busy: true, ok: false, message: '' });
8129
+ apiCall('hosts.credentials', { hostId: host.id, password: value })
8130
+ .then(function () { return apiCall('hosts.browse', { hostId: host.id, path: '' }); })
8131
+ .then(function () {
8132
+ setCheck({ busy: false, ok: true, message: t('sshPasswordOk') });
8133
+ if (props.onVerified) props.onVerified();
8134
+ })
8135
+ .catch(function (err) {
8136
+ setCheck({ busy: false, ok: false, message: t('sshPasswordFailed') + ' ' + messageOf(err, t, props.locale) });
8137
+ if (props.onVerified) props.onVerified();
8138
+ });
8139
+ }
8140
+ return h('div', { className: 'rw-field' },
8141
+ h('div', { className: 'rw-label' }, t('sshPassword')),
8142
+ h('div', { className: 'rw-inline' },
8143
+ h('input', {
8144
+ className: 'rw-input',
8145
+ type: 'password',
8146
+ ref: inputRef,
8147
+ value: props.value || '',
8148
+ placeholder: stored ? t('sshPasswordStored') : t('sshPasswordPlaceholder'),
8149
+ autoComplete: 'new-password',
8150
+ spellCheck: false,
8151
+ disabled: props.busy,
8152
+ onChange: function (event) { props.onChange(event.currentTarget.value); },
8153
+ onKeyDown: function (event) { if (event.key === 'Enter' && props.onSubmit) props.onSubmit(); },
8154
+ }),
8155
+ h('button', {
8156
+ type: 'button',
8157
+ className: 'rw-btn rw-btn-sm',
8158
+ disabled: check.busy || props.busy,
8159
+ onClick: verify,
8160
+ }, check.busy ? t('sshVerifying') : t('sshVerify'))),
8161
+ check.message
8162
+ ? h('div', { className: 'rw-hint', style: check.ok ? { color: '#3fb950' } : { color: '#f85149' } }, check.message)
8163
+ : h('div', { className: 'rw-hint' }, needed && !stored ? t('sshPasswordHint') : t('sshPasswordStoredHint')));
8164
+ }
8165
+
8166
+ function AddWorkspaceFlow(props) { var ctx = props.ctx;
7682
8167
  var t = props.t;
7683
8168
  var locale = props.locale;
7684
8169
  var onDone = props.onDone;
7685
8170
  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
8171
 
7691
8172
  var hostState = useState({ loading: true, hosts: [], error: null });
7692
8173
  var hostData = hostState[0];
@@ -7718,6 +8199,9 @@ function attributeViolation(name, value, tagName) {
7718
8199
  var localOpenState = useState(false);
7719
8200
  var localOpen = localOpenState[0];
7720
8201
  var setLocalOpen = localOpenState[1];
8202
+ var passwordState = useState('');
8203
+ var password = passwordState[0];
8204
+ var setPassword = passwordState[1];
7721
8205
 
7722
8206
  var loadHosts = useCallback(function () {
7723
8207
  setHostData(function (previous) { return { loading: previous.hosts.length === 0, hosts: previous.hosts, error: null }; });
@@ -7736,6 +8220,7 @@ function attributeViolation(name, value, tagName) {
7736
8220
 
7737
8221
  function chooseHost(host) {
7738
8222
  setSelectedHostId(host.id);
8223
+ setPassword('');
7739
8224
  setError('');
7740
8225
  setRemoteOpen(false);
7741
8226
  if (remotePath.trim() === '' && host && host.hasCredential !== false) {
@@ -7745,36 +8230,38 @@ function attributeViolation(name, value, tagName) {
7745
8230
  }
7746
8231
  }
7747
8232
 
8233
+ function selectedHost() {
8234
+ return hostData.hosts.filter(function (item) { return item.id === selectedHostId; })[0] || null;
8235
+ }
8236
+
8237
+ function needsPassword(host) {
8238
+ if (!host) return false;
8239
+ if (host.hasCredential === false) return true;
8240
+ return host.authType === 'password' && host.hasStoredPassword !== true;
8241
+ }
8242
+
7748
8243
  function submit() {
7749
8244
  if (busy) return;
7750
8245
  if (!selectedHostId) { setError(t('stepHost')); return; }
7751
8246
  var trimmedRemote = remotePath.trim();
7752
8247
  if (trimmedRemote === '') { setError(t('stepPath')); return; }
8248
+ var trimmedLocal = localPath.trim();
8249
+ if (trimmedLocal === '') { setBusy(false); setError(t('stepLocalPath')); return; }
8250
+ var typedPassword = password;
8251
+ if (needsPassword(selectedHost()) && typedPassword === '') { setError(t('sshPasswordRequired')); return; }
7753
8252
  setBusy(true);
7754
8253
  setError('');
7755
- if (mode === 'remote') {
7756
- apiCall('workspaces.add', {
8254
+ var stored = typedPassword === ''
8255
+ ? Promise.resolve()
8256
+ : apiCall('hosts.credentials', { hostId: selectedHostId, password: typedPassword }).then(loadHosts);
8257
+ stored.then(function () {
8258
+ return apiCall('linked.create', {
7757
8259
  hostId: selectedHostId,
7758
8260
  remotePath: trimmedRemote,
8261
+ localPath: trimmedLocal,
7759
8262
  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));
8263
+ mirror: mirror,
7767
8264
  });
7768
- return;
7769
- }
7770
- var trimmedLocal = localPath.trim();
7771
- if (trimmedLocal === '') { setBusy(false); setError(t('stepLocalPath')); return; }
7772
- apiCall('linked.create', {
7773
- hostId: selectedHostId,
7774
- remotePath: trimmedRemote,
7775
- localPath: trimmedLocal,
7776
- name: name.trim(),
7777
- mirror: mirror,
7778
8265
  }).then(function () {
7779
8266
  setBusy(false);
7780
8267
  bus.emit();
@@ -7785,20 +8272,19 @@ function attributeViolation(name, value, tagName) {
7785
8272
  });
7786
8273
  }
7787
8274
 
7788
- if (props.submitRef) props.submitRef.current = { submit: submit, busy: busy, mode: mode };
8275
+ if (props.submitRef) props.submitRef.current = { submit: submit, busy: busy };
7789
8276
 
7790
8277
  return h('div', { className: 'rw-add' },
7791
8278
  h('div', { className: 'rw-inline', style: { justifyContent: 'space-between' } },
7792
- h('div', { className: 'rw-add-title' }, mode === 'linked' ? t('createLinked') : t('addRemoteDir')),
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),
8279
+ h('div', { className: 'rw-add-title' }, t('createLinked'))),
7798
8280
  h('div', { className: 'rw-field' },
7799
8281
  h('div', { className: 'rw-label' }, t('stepHost')),
7800
8282
  h(HostList, { t: t, hosts: hostData.hosts, loading: hostData.loading, selectedId: selectedHostId, onSelect: chooseHost }),
7801
8283
  hostData.error ? h(Banner, { kind: 'error' }, t('hostsFailed') + ':' + messageOf(hostData.error, t, locale)) : null),
8284
+ h(SshCredentialField, {
8285
+ t: t, locale: locale, host: selectedHost(), value: password, busy: busy,
8286
+ onChange: setPassword, onSubmit: submit, onVerified: loadHosts,
8287
+ }),
7802
8288
  h('div', { className: 'rw-field' },
7803
8289
  h('div', { className: 'rw-label' }, t('stepPath')),
7804
8290
  h('div', { className: 'rw-input-row' },
@@ -7824,8 +8310,7 @@ function attributeViolation(name, value, tagName) {
7824
8310
  })
7825
8311
  : null,
7826
8312
  h('div', { className: 'rw-hint' }, t('diskHint'))),
7827
- mode === 'linked'
7828
- ? h('div', { className: 'rw-field' },
8313
+ h('div', { className: 'rw-field' },
7829
8314
  h('div', { className: 'rw-label' }, t('stepLocalPath')),
7830
8315
  h('div', { className: 'rw-input-row' },
7831
8316
  h('input', {
@@ -7851,28 +8336,183 @@ function attributeViolation(name, value, tagName) {
7851
8336
  checked: mirror, onChange: setMirror, label: t('mirrorLabel'),
7852
8337
  text: t('mirrorLabel'),
7853
8338
  })),
7854
- h('div', { className: 'rw-hint' }, t('mirrorHint')))
7855
- : null,
7856
- mode === 'linked'
7857
- ? h('div', { className: 'rw-field' },
7858
- h('div', { className: 'rw-label' }, t('stepName')),
8339
+ h('div', { className: 'rw-hint' }, t('mirrorHint'))),
8340
+ h('div', { className: 'rw-field' },
8341
+ h('div', { className: 'rw-label' }, t('stepName')),
8342
+ h('input', {
8343
+ className: 'rw-input',
8344
+ value: name,
8345
+ placeholder: basename(localPath) || t('namePlaceholder'),
8346
+ maxLength: 120,
8347
+ onChange: function (event) { setName(event.currentTarget.value); },
8348
+ onKeyDown: function (event) { if (event.key === 'Enter') submit(); },
8349
+ })),
8350
+ error ? h(Banner, { kind: 'error' }, error) : null,
8351
+ props.compact ? null : h('div', { className: 'rw-actions' },
8352
+ h('button', { type: 'button', className: 'rw-btn', disabled: busy, onClick: onCancel }, t('cancel')),
8353
+ h('button', {
8354
+ type: 'button', className: 'rw-btn rw-btn-primary',
8355
+ disabled: busy || !selectedHostId || remotePath.trim() === '' || localPath.trim() === '',
8356
+ onClick: submit,
8357
+ }, busy ? Spinner(13) : IconLinkedWorkspace(13), busy ? t('creating') : t('create'))));
8358
+ }
8359
+
8360
+ // ── remote workspace flow (sessions run inside the remote folder) ──────
8361
+
8362
+ function AddRemoteWorkspaceFlow(props) {
8363
+ var t = props.t;
8364
+ var locale = props.locale;
8365
+ var onDone = props.onDone;
8366
+ var onCancel = props.onCancel;
8367
+
8368
+ var hostState = useState({ loading: true, hosts: [], error: null });
8369
+ var hostData = hostState[0];
8370
+ var setHostData = hostState[1];
8371
+ var selectedState = useState('');
8372
+ var selectedHostId = selectedState[0];
8373
+ var setSelectedHostId = selectedState[1];
8374
+ var pathState = useState('');
8375
+ var remotePath = pathState[0];
8376
+ var setRemotePath = pathState[1];
8377
+ var nameState = useState('');
8378
+ var name = nameState[0];
8379
+ var setName = nameState[1];
8380
+ var busyState = useState(false);
8381
+ var busy = busyState[0];
8382
+ var setBusy = busyState[1];
8383
+ var errorState = useState('');
8384
+ var error = errorState[0];
8385
+ var setError = errorState[1];
8386
+ var remoteOpenState = useState(false);
8387
+ var remoteOpen = remoteOpenState[0];
8388
+ var setRemoteOpen = remoteOpenState[1];
8389
+ var passwordState = useState('');
8390
+ var password = passwordState[0];
8391
+ var setPassword = passwordState[1];
8392
+
8393
+ var loadHosts = useCallback(function () {
8394
+ setHostData(function (previous) { return { loading: previous.hosts.length === 0, hosts: previous.hosts, error: null }; });
8395
+ apiCall('hosts.list', {}).then(function (result) {
8396
+ setHostData({ loading: false, hosts: result.hosts || [], error: null });
8397
+ setSelectedHostId(function (current) {
8398
+ if (current) return current;
8399
+ return result.hosts && result.hosts.length > 0 ? result.hosts[0].id : '';
8400
+ });
8401
+ }).catch(function (err) {
8402
+ setHostData({ loading: false, hosts: [], error: err });
8403
+ });
8404
+ }, []);
8405
+
8406
+ useEffect(function () { loadHosts(); }, [loadHosts]);
8407
+
8408
+ function chooseHost(host) {
8409
+ setSelectedHostId(host.id);
8410
+ setPassword('');
8411
+ setError('');
8412
+ setRemoteOpen(false);
8413
+ if (remotePath.trim() === '' && host && host.hasCredential !== false) {
8414
+ apiCall('hosts.browse', { hostId: host.id }).then(function (result) {
8415
+ setRemotePath(function (current) { return current.trim() === '' ? result.home : current; });
8416
+ }).catch(function () { /* silent prefill */ });
8417
+ }
8418
+ }
8419
+
8420
+ function selectedHost() {
8421
+ return hostData.hosts.filter(function (item) { return item.id === selectedHostId; })[0] || null;
8422
+ }
8423
+
8424
+ function needsPassword(host) {
8425
+ if (!host) return false;
8426
+ if (host.hasCredential === false) return true;
8427
+ return host.authType === 'password' && host.hasStoredPassword !== true;
8428
+ }
8429
+
8430
+ function submit() {
8431
+ if (busy) return;
8432
+ if (!selectedHostId) { setError(t('stepHost')); return; }
8433
+ var trimmedRemote = remotePath.trim();
8434
+ if (trimmedRemote === '') { setError(t('stepPath')); return; }
8435
+ var typedPassword = password;
8436
+ if (needsPassword(selectedHost()) && typedPassword === '') { setError(t('sshPasswordRequired')); return; }
8437
+ setBusy(true);
8438
+ setError('');
8439
+ var stored = typedPassword === ''
8440
+ ? Promise.resolve()
8441
+ : apiCall('hosts.credentials', { hostId: selectedHostId, password: typedPassword }).then(loadHosts);
8442
+ stored.then(function () {
8443
+ return apiCall('remote_workspaces.create', {
8444
+ hostId: selectedHostId,
8445
+ remotePath: trimmedRemote,
8446
+ name: name.trim(),
8447
+ });
8448
+ }).then(function () {
8449
+ setBusy(false);
8450
+ bus.emit();
8451
+ if (onDone) onDone();
8452
+ }).catch(function (err) {
8453
+ setBusy(false);
8454
+ setError(t('remoteCreateFailed') + ':' + messageOf(err, t, locale));
8455
+ });
8456
+ }
8457
+
8458
+ if (props.submitRef) props.submitRef.current = { submit: submit, busy: busy };
8459
+
8460
+ return h('div', { className: 'rw-add' },
8461
+ h('div', { className: 'rw-inline', style: { justifyContent: 'space-between' } },
8462
+ h('div', { className: 'rw-add-title' }, t('createRemote'))),
8463
+ h('div', { className: 'rw-hint' }, t('flowRemoteDesc')),
8464
+ h('div', { className: 'rw-field' },
8465
+ h('div', { className: 'rw-label' }, t('stepHost')),
8466
+ h(HostList, { t: t, hosts: hostData.hosts, loading: hostData.loading, selectedId: selectedHostId, onSelect: chooseHost }),
8467
+ hostData.error ? h(Banner, { kind: 'error' }, t('hostsFailed') + ':' + messageOf(hostData.error, t, locale)) : null),
8468
+ h(SshCredentialField, {
8469
+ t: t, locale: locale, host: selectedHost(), value: password, busy: busy,
8470
+ onChange: setPassword, onSubmit: submit, onVerified: loadHosts,
8471
+ }),
8472
+ h('div', { className: 'rw-field' },
8473
+ h('div', { className: 'rw-label' }, t('stepPath')),
8474
+ h('div', { className: 'rw-input-row' },
7859
8475
  h('input', {
7860
- className: 'rw-input',
7861
- value: name,
7862
- placeholder: basename(localPath) || t('namePlaceholder'),
7863
- maxLength: 120,
7864
- onChange: function (event) { setName(event.currentTarget.value); },
8476
+ className: 'rw-input rw-input-mono',
8477
+ value: remotePath,
8478
+ placeholder: t('pathPlaceholder'),
8479
+ spellCheck: false,
8480
+ autoComplete: 'off',
8481
+ onChange: function (event) { setRemotePath(event.currentTarget.value); },
7865
8482
  onKeyDown: function (event) { if (event.key === 'Enter') submit(); },
7866
- }))
7867
- : null,
8483
+ }),
8484
+ h('button', {
8485
+ type: 'button', className: 'rw-btn',
8486
+ onClick: function () { setRemoteOpen(function (value) { return !value; }); },
8487
+ disabled: !selectedHostId,
8488
+ }, IconFolder(13), remoteOpen ? t('cancel') : t('browse'))),
8489
+ remoteOpen
8490
+ ? h(RemotePathPicker, {
8491
+ t: t, locale: locale, hostId: selectedHostId,
8492
+ initialPath: remotePath,
8493
+ onPick: function (picked) { setRemotePath(picked); setRemoteOpen(false); },
8494
+ })
8495
+ : null,
8496
+ h('div', { className: 'rw-hint' }, t('diskHint'))),
8497
+ h('div', { className: 'rw-field' },
8498
+ h('div', { className: 'rw-label' }, t('remoteStepName')),
8499
+ h('input', {
8500
+ className: 'rw-input',
8501
+ value: name,
8502
+ placeholder: basename(remotePath) || t('namePlaceholder'),
8503
+ maxLength: 120,
8504
+ onChange: function (event) { setName(event.currentTarget.value); },
8505
+ onKeyDown: function (event) { if (event.key === 'Enter') submit(); },
8506
+ })),
8507
+ h('div', { className: 'rw-hint' }, t('remotePlaceholderHint')),
7868
8508
  error ? h(Banner, { kind: 'error' }, error) : null,
7869
8509
  props.compact ? null : h('div', { className: 'rw-actions' },
7870
8510
  h('button', { type: 'button', className: 'rw-btn', disabled: busy, onClick: onCancel }, t('cancel')),
7871
8511
  h('button', {
7872
8512
  type: 'button', className: 'rw-btn rw-btn-primary',
7873
- disabled: busy || !selectedHostId || remotePath.trim() === '' || (mode === 'linked' && localPath.trim() === ''),
8513
+ disabled: busy || !selectedHostId || remotePath.trim() === '',
7874
8514
  onClick: submit,
7875
- }, busy ? Spinner(13) : (mode === 'linked' ? IconLink(13) : IconPlus(13)), busy ? t('creating') : (mode === 'linked' ? t('create') : t('addAction')))));
8515
+ }, busy ? Spinner(13) : IconRemoteWorkspace(13), busy ? t('creating') : t('create'))));
7876
8516
  }
7877
8517
 
7878
8518
  // ── directory flow (sidebar / hero "add workspace" hole) ───────────────
@@ -7903,7 +8543,10 @@ function attributeViolation(name, value, tagName) {
7903
8543
 
7904
8544
  function createLocal() {
7905
8545
  var target = localPath.trim();
7906
- if (target === '' || localBusy) return;
8546
+ if (localBusy) return;
8547
+ // Keep the button looking the same as the linked/remote ones and report
8548
+ // the missing folder instead of silently ignoring the click.
8549
+ if (target === '') { setLocalError(t('localPathRequired')); return; }
7907
8550
  setLocalBusy(true);
7908
8551
  setLocalError('');
7909
8552
  apiCall('localWorkspace.create', { path: target, name: localName.trim() }).then(function () {
@@ -7934,6 +8577,50 @@ function attributeViolation(name, value, tagName) {
7934
8577
  if (target && typeof target.focus === 'function') target.focus();
7935
8578
  }, [props.open, flow]);
7936
8579
 
8580
+ // The app shell listens for wheel gestures on the document root and moves
8581
+ // the conversation behind the dialog, so a wheel over the host list (or
8582
+ // anywhere else in the dialog) never reaches the dialog's own scroll
8583
+ // areas. Take the gesture in the capture phase: scroll the innermost
8584
+ // scrollable element inside the dialog, chain to the next one at the
8585
+ // edges, and never let the page behind move while the dialog is open.
8586
+ useEffect(function () {
8587
+ if (!props.open) return undefined;
8588
+ var node = modalRef.current;
8589
+ if (!node) return undefined;
8590
+ var overlay = node.closest ? (node.closest('.rw-modal-backdrop') || node) : node;
8591
+
8592
+ function firstScrollable(start) {
8593
+ var el = start;
8594
+ while (el && el !== overlay) {
8595
+ if (el.scrollHeight > el.clientHeight + 1) {
8596
+ var overflow = getComputedStyle(el).overflowY;
8597
+ if (overflow === 'auto' || overflow === 'scroll') return el;
8598
+ }
8599
+ el = el.parentElement;
8600
+ }
8601
+ return null;
8602
+ }
8603
+
8604
+ function onWheel(event) {
8605
+ if (!event.deltaY) return;
8606
+ if (!overlay.contains(event.target)) return;
8607
+ event.preventDefault();
8608
+ event.stopPropagation();
8609
+ if (event.stopImmediatePropagation) event.stopImmediatePropagation();
8610
+ var step = event.deltaY * (event.deltaMode === 1 ? 16 : event.deltaMode === 2 ? 400 : 1);
8611
+ var el = firstScrollable(event.target && event.target.nodeType === 1 ? event.target : overlay);
8612
+ while (el) {
8613
+ var before = el.scrollTop;
8614
+ el.scrollTop = before + step;
8615
+ if (el.scrollTop !== before) return;
8616
+ el = firstScrollable(el.parentElement);
8617
+ }
8618
+ }
8619
+
8620
+ window.addEventListener('wheel', onWheel, { passive: false, capture: true });
8621
+ return function () { window.removeEventListener('wheel', onWheel, { capture: true }); };
8622
+ }, [props.open]);
8623
+
7937
8624
  function onModalKeyDown(event) {
7938
8625
  if (event.key === 'Escape') {
7939
8626
  event.preventDefault();
@@ -7969,14 +8656,15 @@ function attributeViolation(name, value, tagName) {
7969
8656
  onKeyDown: onModalKeyDown,
7970
8657
  },
7971
8658
  h('div', { className: 'rw-modal-head' },
7972
- h('span', { className: 'rw-icon-chip' }, IconLink(16)),
8659
+ h('span', { className: 'rw-icon-chip' }, IconFolderTree(16)),
7973
8660
  h('span', { className: 'rw-modal-title' }, t('flowTitle')),
7974
8661
  h('button', { type: 'button', className: 'rw-icon-btn', title: t('cancel'), onClick: function () { if (props.onCancel) props.onCancel(); } }, IconClose(14))),
7975
8662
  h('div', { className: 'rw-modal-body' },
7976
8663
  h('div', { className: 'rw-tabs' },
7977
8664
  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'); } }, IconLink(13), t('flowLinked'))),
7979
- h('div', { className: 'rw-hint' }, flow === 'local' ? t('localFlowHint') : t('linkedFlowHint')),
8665
+ h('button', { type: 'button', className: 'rw-tab' + (flow === 'linked' ? ' is-on' : ''), onClick: function () { setFlow('linked'); } }, IconLinkedWorkspace(13), t('flowLinked')),
8666
+ h('button', { type: 'button', className: 'rw-tab' + (flow === 'remote' ? ' is-on' : ''), onClick: function () { setFlow('remote'); } }, IconRemoteWorkspace(13), t('flowRemote'))),
8667
+ h('div', { className: 'rw-hint' }, flow === 'local' ? t('localFlowHint') : flow === 'remote' ? t('flowRemoteDesc') : t('linkedFlowHint')),
7980
8668
  flow === 'local'
7981
8669
  ? h('div', { className: 'rw-add' },
7982
8670
  h('div', { className: 'rw-field' },
@@ -7987,7 +8675,7 @@ function attributeViolation(name, value, tagName) {
7987
8675
  value: localPath,
7988
8676
  placeholder: t('localPathPlaceholder'),
7989
8677
  spellCheck: false,
7990
- onChange: function (event) { setLocalPath(event.currentTarget.value); },
8678
+ onChange: function (event) { setLocalPath(event.currentTarget.value); if (localError) setLocalError(''); },
7991
8679
  }),
7992
8680
  h('button', {
7993
8681
  type: 'button', className: 'rw-btn',
@@ -8010,13 +8698,19 @@ function attributeViolation(name, value, tagName) {
8010
8698
  onKeyDown: function (event) { if (event.key === 'Enter') createLocal(); },
8011
8699
  })),
8012
8700
  localError ? h(Banner, { kind: 'error' }, localError) : null)
8013
- : h(AddWorkspaceFlow, {
8014
- ctx: ctx, t: t, locale: locale, compact: true, initialMode: 'linked', lockedMode: 'linked', submitRef: flowSubmitRef,
8015
- onDone: function () { if (props.onCancel) props.onCancel(); },
8016
- onCancel: function () { if (props.onCancel) props.onCancel(); },
8017
- })),
8701
+ : flow === 'remote'
8702
+ ? h(AddRemoteWorkspaceFlow, {
8703
+ ctx: ctx, t: t, locale: locale, compact: true, submitRef: flowSubmitRef,
8704
+ onDone: function () { if (props.onCancel) props.onCancel(); },
8705
+ onCancel: function () { if (props.onCancel) props.onCancel(); },
8706
+ })
8707
+ : h(AddWorkspaceFlow, {
8708
+ ctx: ctx, t: t, locale: locale, compact: true, submitRef: flowSubmitRef,
8709
+ onDone: function () { if (props.onCancel) props.onCancel(); },
8710
+ onCancel: function () { if (props.onCancel) props.onCancel(); },
8711
+ })),
8018
8712
  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')),
8713
+ 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
8714
  h('button', {
8021
8715
  type: 'button', className: 'rw-btn', disabled: Boolean(props.busy) || localBusy,
8022
8716
  onClick: function () { if (props.onCancel) props.onCancel(); },
@@ -8024,7 +8718,7 @@ function attributeViolation(name, value, tagName) {
8024
8718
  flow === 'local'
8025
8719
  ? h('button', {
8026
8720
  type: 'button', className: 'rw-btn rw-btn-primary',
8027
- disabled: localBusy || localPath.trim() === '',
8721
+ disabled: Boolean(props.busy) || localBusy,
8028
8722
  onClick: createLocal,
8029
8723
  }, localBusy ? Spinner(13) : IconPlus(13), localBusy ? t('creating') : t('create'))
8030
8724
  : h('button', {
@@ -8039,89 +8733,6 @@ function attributeViolation(name, value, tagName) {
8039
8733
 
8040
8734
  // ── settings section ───────────────────────────────────────────────────
8041
8735
 
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
8736
  function LinkedWorkspaceCard(props) {
8126
8737
  var link = props.link;
8127
8738
  var t = props.t;
@@ -8247,9 +8858,9 @@ function attributeViolation(name, value, tagName) {
8247
8858
  });
8248
8859
  }
8249
8860
 
8250
- return h('div', { className: 'rw-card' },
8861
+ return h('div', { className: 'rw-card', title: link.name + ' · ' + statusTitle(t, link) },
8251
8862
  h('div', { className: 'rw-card-head' },
8252
- h('span', { className: 'rw-icon-chip rw-icon-chip-link' }, IconLink(16)),
8863
+ h('span', { className: 'rw-icon-chip rw-icon-chip-link' }, IconLinkedWorkspace(16)),
8253
8864
  h('div', { className: 'rw-fill', style: { flex: '1 1 auto', minWidth: 0 } },
8254
8865
  h('div', { className: 'rw-card-title' },
8255
8866
  h('span', { className: 'rw-name', title: link.name }, link.name),
@@ -8314,6 +8925,157 @@ function attributeViolation(name, value, tagName) {
8314
8925
  : null);
8315
8926
  }
8316
8927
 
8928
+ function RemoteWorkspaceCard(props) {
8929
+ var workspace = props.workspace;
8930
+ var t = props.t;
8931
+ var ctx = props.ctx;
8932
+ var locale = props.locale;
8933
+ var refresh = props.refresh;
8934
+ var state = useState({ busy: '', message: null, removing: false, renaming: false, draft: workspace.name });
8935
+ var local = state[0];
8936
+ var setLocal = state[1];
8937
+
8938
+ function openWorkspace() {
8939
+ if (!workspace.workspaceId) return;
8940
+ var uiWorkspace = null;
8941
+ try { uiWorkspace = ctx.get('uiWorkspace'); } catch (error) { uiWorkspace = null; }
8942
+ if (!uiWorkspace && ctx.root && typeof ctx.root.get === 'function') {
8943
+ try { uiWorkspace = ctx.root.get('uiWorkspace'); } catch (error) { uiWorkspace = null; }
8944
+ }
8945
+ if (uiWorkspace && typeof uiWorkspace.openWorkspace === 'function') {
8946
+ try {
8947
+ var navigation = uiWorkspace.openWorkspace(workspace.workspaceId);
8948
+ if (navigation && typeof navigation.catch === 'function') navigation.catch(function () { /* navigation aborted */ });
8949
+ } catch (error) { /* ignore */ }
8950
+ }
8951
+ dismissSettingsOverlay();
8952
+ }
8953
+
8954
+ function openTree() {
8955
+ var sidebar = sidebarService(ctx);
8956
+ if (!sidebar || typeof sidebar.openTab !== 'function') return;
8957
+ sidebar.openTab({
8958
+ type: REMOTE_TREE_TAB_TYPE,
8959
+ id: REMOTE_TREE_TAB_TYPE,
8960
+ title: workspace.name,
8961
+ path: '/',
8962
+ meta: { remoteId: workspace.id },
8963
+ });
8964
+ dismissSettingsOverlay();
8965
+ }
8966
+
8967
+ function startRename() {
8968
+ setLocal(function (previous) { return Object.assign({}, previous, { renaming: true, draft: workspace.name, message: null }); });
8969
+ }
8970
+
8971
+ function submitRename() {
8972
+ var next = String(local.draft == null ? '' : local.draft).trim();
8973
+ if (next === '' || next === workspace.name) {
8974
+ setLocal(function (previous) { return Object.assign({}, previous, { renaming: false }); });
8975
+ return;
8976
+ }
8977
+ setLocal(function (previous) { return Object.assign({}, previous, { busy: 'rename', message: null }); });
8978
+ apiCall('remote_workspaces.update', { id: workspace.id, name: next }).then(function () {
8979
+ setLocal(function (previous) { return Object.assign({}, previous, { busy: '', renaming: false }); });
8980
+ refresh();
8981
+ }).catch(function (error) {
8982
+ setLocal(function (previous) {
8983
+ return Object.assign({}, previous, { busy: '', message: { kind: 'error', text: t('remoteUpdateFailed') + ':' + messageOf(error, t, locale) } });
8984
+ });
8985
+ });
8986
+ }
8987
+
8988
+ function testConnection() {
8989
+ setLocal(function (previous) { return Object.assign({}, previous, { busy: 'test', message: null }); });
8990
+ apiCall('remote_workspaces.test', { id: workspace.id }).then(function (result) {
8991
+ var ok = result && result.ok;
8992
+ var text = ok
8993
+ ? t('testOk', { ms: result.latencyMs == null ? '' : result.latencyMs })
8994
+ : (t('testFailed') + ':' + (result && result.error ? result.error : t('testFailed')));
8995
+ setLocal(function (previous) { return Object.assign({}, previous, { busy: '', message: { kind: ok ? 'success' : 'error', text: text } }); });
8996
+ }).catch(function (error) {
8997
+ setLocal(function (previous) {
8998
+ return Object.assign({}, previous, { busy: '', message: { kind: 'error', text: t('testFailed') + ':' + messageOf(error, t, locale) } });
8999
+ });
9000
+ });
9001
+ }
9002
+
9003
+ function remove() {
9004
+ if (!local.removing) {
9005
+ setLocal(function (previous) { return Object.assign({}, previous, { removing: true, message: null }); });
9006
+ return;
9007
+ }
9008
+ setLocal(function (previous) { return Object.assign({}, previous, { busy: 'remove' }); });
9009
+ apiCall('remote_workspaces.remove', { id: workspace.id }).then(function () {
9010
+ setLocal(function (previous) { return Object.assign({}, previous, { busy: '', removing: false, message: { kind: 'success', text: t('remoteRemoved') } }); });
9011
+ bus.emit();
9012
+ refresh();
9013
+ }).catch(function (error) {
9014
+ setLocal(function (previous) {
9015
+ return Object.assign({}, previous, { busy: '', message: { kind: 'error', text: t('remoteRemoveFailed') + ':' + messageOf(error, t, locale) } });
9016
+ });
9017
+ });
9018
+ }
9019
+
9020
+ var hostLabel = (workspace.username ? workspace.username + '@' : '') + (workspace.host || workspace.hostName || '');
9021
+
9022
+ return h('div', { className: 'rw-card', title: workspace.name + ' · ' + statusTitle(t, workspace) },
9023
+ h('div', { className: 'rw-card-head' },
9024
+ h('span', { className: 'rw-icon-chip' }, IconRemoteWorkspace(16)),
9025
+ h('div', { className: 'rw-fill', style: { flex: '1 1 auto', minWidth: 0 } },
9026
+ h('div', { className: 'rw-card-title' },
9027
+ local.renaming
9028
+ ? h('input', {
9029
+ className: 'rw-input',
9030
+ value: local.draft,
9031
+ autoFocus: true,
9032
+ onChange: function (event) { setLocal(function (previous) { return Object.assign({}, previous, { draft: event.target.value }); }); },
9033
+ onKeyDown: function (event) {
9034
+ if (event.key === 'Enter') { event.preventDefault(); submitRename(); }
9035
+ if (event.key === 'Escape') { event.preventDefault(); setLocal(function (previous) { return Object.assign({}, previous, { renaming: false }); }); }
9036
+ },
9037
+ })
9038
+ : h('span', { className: 'rw-name', title: workspace.name }, workspace.name),
9039
+ h('span', { className: 'rw-chip' }, t('remoteChip')),
9040
+ h(StatusPill, { status: workspace.status, t: t })),
9041
+ local.renaming
9042
+ ? null
9043
+ : h('div', { className: 'rw-pair' },
9044
+ h('div', { className: 'rw-pair-item' },
9045
+ h('span', { className: 'rw-pair-label' }, t('pathRemoteShort') + (hostLabel ? ' · ' + hostLabel : '')),
9046
+ h('span', { className: 'rw-path', title: workspace.remotePath }, workspace.remotePath)),
9047
+ h('div', { className: 'rw-pair-item' },
9048
+ h('span', { className: 'rw-pair-label' }, t('remotePlaceholderLabel')),
9049
+ h('span', { className: 'rw-path', title: workspace.placeholderPath }, workspace.placeholderPath)))),
9050
+ h('div', { className: 'rw-actions' },
9051
+ local.renaming
9052
+ ? h('span', null,
9053
+ 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')),
9054
+ 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')))
9055
+ : h('span', null,
9056
+ workspace.workspaceId
9057
+ ? h('button', { type: 'button', className: 'rw-btn rw-btn-sm', onClick: openWorkspace }, IconExternal(12), t('openWorkspace'))
9058
+ : null,
9059
+ h('button', { type: 'button', className: 'rw-btn rw-btn-sm', onClick: openTree }, IconFolderTree(12), t('openTree')),
9060
+ 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')),
9061
+ h('button', { type: 'button', className: 'rw-btn rw-btn-sm rw-btn-ghost', onClick: startRename, disabled: local.busy !== '' }, t('rename')),
9062
+ h('button', { type: 'button', className: 'rw-btn rw-btn-sm rw-btn-ghost', onClick: remove, disabled: local.busy === 'remove' }, IconTrash(12), t('removeRemote'))))),
9063
+ h('div', { className: 'rw-hint' }, t('remoteSessionHint')),
9064
+ local.removing
9065
+ ? h('div', { className: 'rw-warn-box' },
9066
+ h('div', null, t('remoteRemoveHint')),
9067
+ h('div', { className: 'rw-actions', style: { marginTop: 8 } },
9068
+ h('button', { type: 'button', className: 'rw-btn rw-btn-sm', onClick: function () { setLocal(function (previous) { return Object.assign({}, previous, { removing: false }); }); } }, t('cancel')),
9069
+ h('button', { type: 'button', className: 'rw-btn rw-btn-sm rw-btn-danger', onClick: remove, disabled: local.busy === 'remove' }, IconTrash(12), t('confirmRemove'))))
9070
+ : null,
9071
+ local.message
9072
+ ? h(Banner, {
9073
+ kind: local.message.kind === 'success' ? 'success' : local.message.kind === 'error' ? 'error' : undefined,
9074
+ onClose: function () { setLocal(function (previous) { return Object.assign({}, previous, { message: null }); }); },
9075
+ }, local.message.text)
9076
+ : null);
9077
+ }
9078
+
8317
9079
  function ThemeGroup(props) {
8318
9080
  var t = props.t;
8319
9081
  var locale = props.locale;
@@ -8456,13 +9218,13 @@ function attributeViolation(name, value, tagName) {
8456
9218
  var addingState = useState('');
8457
9219
  var adding = addingState[0];
8458
9220
  var setAdding = addingState[1];
8459
- var sidebarAvailable = Boolean(ctx.get && ctx.get('betterSidebar'));
9221
+ var sidebarAvailable = Boolean(sidebarService(ctx));
8460
9222
  var links = remote.data.links || [];
8461
- var workspaces = remote.data.workspaces || [];
9223
+ var remotes = remote.data.remotes || [];
8462
9224
  var hosts = remote.data.hosts || [];
8463
9225
 
8464
9226
  function openTree() {
8465
- var sidebar = ctx.get && ctx.get('betterSidebar');
9227
+ var sidebar = sidebarService(ctx);
8466
9228
  if (!sidebar || typeof sidebar.openTab !== 'function') return;
8467
9229
  sidebar.openTab({
8468
9230
  type: TREE_TAB_TYPE,
@@ -8471,6 +9233,11 @@ function attributeViolation(name, value, tagName) {
8471
9233
  path: '/',
8472
9234
  meta: {},
8473
9235
  });
9236
+ dismissSettingsOverlay();
9237
+ }
9238
+
9239
+ function toggleAdding(mode) {
9240
+ setAdding(adding === mode ? '' : mode);
8474
9241
  }
8475
9242
 
8476
9243
  return h('div', { className: 'rw-root' },
@@ -8481,23 +9248,30 @@ function attributeViolation(name, value, tagName) {
8481
9248
  h('div', { className: 'rw-actions' },
8482
9249
  h('button', {
8483
9250
  type: 'button', className: 'rw-btn' + (adding === 'linked' ? '' : ' rw-btn-primary'),
8484
- onClick: function () { setAdding(adding === 'linked' ? '' : 'linked'); },
8485
- }, adding === 'linked' ? IconClose(13) : IconLink(13), t('createLinked')),
9251
+ onClick: function () { toggleAdding('linked'); },
9252
+ }, adding === 'linked' ? IconClose(13) : IconLinkedWorkspace(13), t('createLinked')),
8486
9253
  h('button', {
8487
9254
  type: 'button', className: 'rw-btn' + (adding === 'remote' ? '' : ' rw-btn-primary'),
8488
- onClick: function () { setAdding(adding === 'remote' ? '' : 'remote'); },
8489
- }, adding === 'remote' ? IconClose(13) : IconServer(13), t('addRemoteDir')))),
9255
+ onClick: function () { toggleAdding('remote'); },
9256
+ }, adding === 'remote' ? IconClose(13) : IconRemoteWorkspace(13), t('createRemote')))),
8490
9257
  !sidebarAvailable ? h(Banner, { kind: 'warn' }, t('needsSidebar')) : null,
8491
9258
  h(ThemeGroup, { t: t, locale: locale }),
8492
9259
  h(EditorSettingsGroup, { t: t, locale: locale }),
8493
- adding !== ''
9260
+ adding === 'linked'
8494
9261
  ? h(AddWorkspaceFlow, {
8495
- ctx: ctx, t: t, locale: locale, initialMode: adding, lockedMode: adding,
9262
+ ctx: ctx, t: t, locale: locale,
9263
+ onDone: function () { setAdding(''); remote.reload(); },
9264
+ onCancel: function () { setAdding(''); },
9265
+ })
9266
+ : null,
9267
+ adding === 'remote'
9268
+ ? h(AddRemoteWorkspaceFlow, {
9269
+ ctx: ctx, t: t, locale: locale,
8496
9270
  onDone: function () { setAdding(''); remote.reload(); },
8497
9271
  onCancel: function () { setAdding(''); },
8498
9272
  })
8499
9273
  : null,
8500
- remote.data.error ? h(Banner, { kind: 'error' }, t('workspacesFailed') + ':' + messageOf(remote.data.error, t, locale)) : null,
9274
+ remote.data.error ? h(Banner, { kind: 'error' }, t('remoteWorkspacesFailed') + ':' + messageOf(remote.data.error, t, locale)) : null,
8501
9275
  remote.data.hostError ? h(Banner, { kind: 'error' }, t('hostsFailed') + ':' + messageOf(remote.data.hostError, t, locale)) : null,
8502
9276
  remote.data.linkError ? h(Banner, { kind: 'error' }, t('linksFailed') + ':' + messageOf(remote.data.linkError, t, locale)) : null,
8503
9277
  h('div', { className: 'rw-group' },
@@ -8520,15 +9294,13 @@ function attributeViolation(name, value, tagName) {
8520
9294
  }))),
8521
9295
  h('div', { className: 'rw-group' },
8522
9296
  h('div', { className: 'rw-group-head' },
8523
- h('span', { className: 'rw-group-title' }, t('remoteDirsTitle')),
8524
- h('span', { className: 'rw-chip' }, String(workspaces.length)),
8525
- h('span', { className: 'rw-group-hint' }, t('remoteDirsHint'))),
8526
- workspaces.length === 0
8527
- ? h('div', { className: 'rw-empty', style: { border: 'none', padding: '18px 8px' } },
8528
- h('div', { className: 'rw-empty-title' }, t('emptyTitle')),
8529
- h('div', { className: 'rw-empty-body' }, hosts.length === 0 ? t('emptyHint') : t('emptyBody')))
9297
+ h('span', { className: 'rw-group-title' }, t('remoteGroup')),
9298
+ h('span', { className: 'rw-chip' }, String(remotes.length)),
9299
+ h('span', { className: 'rw-group-hint' }, t('remoteHint'))),
9300
+ remotes.length === 0
9301
+ ? h('div', { className: 'rw-hint' }, t('remoteEmpty'))
8530
9302
  : h('div', { className: 'rw-list' },
8531
- workspaces.map(function (workspace) {
9303
+ remotes.map(function (workspace) {
8532
9304
  return h(RemoteWorkspaceCard, {
8533
9305
  key: workspace.id,
8534
9306
  workspace: workspace,
@@ -8538,14 +9310,16 @@ function attributeViolation(name, value, tagName) {
8538
9310
  refresh: remote.reload,
8539
9311
  });
8540
9312
  }))),
8541
- h('div', { className: 'rw-inline', style: { justifyContent: 'space-between' } },
8542
- h('span', { className: 'rw-hint' }, workspaces.length + ' ' + t('remoteGroup') + ' · ' + links.length + ' ' + t('linkedGroup')),
9313
+ h('div', { className: 'rw-inline', style: { justifyContent: 'flex-end' } },
8543
9314
  h('button', { type: 'button', className: 'rw-btn rw-btn-ghost rw-btn-sm', onClick: remote.reload }, IconRefresh(12), t('refresh'))));
8544
9315
  }
8545
9316
 
8546
9317
  // ── apply ──────────────────────────────────────────────────────────────
8547
9318
 
8548
- var inject = ['slots', 'locale'];
9319
+ // `sessions` is a core client service (the sidebar shell injects it too):
9320
+ // the directory entries need the focused session's cwd/workspaceId to
9321
+ // decide whether they belong in the "+" menu.
9322
+ var inject = ['slots', 'locale', 'sessions'];
8549
9323
 
8550
9324
  function apply(ctx) {
8551
9325
  ctx.effect(installStyles, 'dsh-linked-workspace: styles');
@@ -8584,6 +9358,23 @@ function attributeViolation(name, value, tagName) {
8584
9358
  };
8585
9359
  }, 'dsh-linked-workspace: workspace row icons');
8586
9360
 
9361
+ // The settings list draws a default glyph unless a plugin claims the icon
9362
+ // seat; the id has to match the section id above.
9363
+ try {
9364
+ ctx.slots.inject('settings.section.icon', function () {
9365
+ return ctx.slots.register({
9366
+ name: 'settings.section.icon',
9367
+ id: 'linked-workspaces',
9368
+ order: 52,
9369
+ label: function () { return makeT(readLocale(ctx))('settingsNav'); },
9370
+ }, function (props) {
9371
+ return IconSettingsNav(props && props.size ? props.size : 16);
9372
+ });
9373
+ });
9374
+ } catch (error) {
9375
+ console.error('[dsh-linked-workspace] settings icon registration failed', error && error.message ? error.message : error);
9376
+ }
9377
+
8587
9378
  try {
8588
9379
  ctx.slots.inject('settings.section', function () {
8589
9380
  return ctx.slots.register({
@@ -8625,12 +9416,7 @@ function attributeViolation(name, value, tagName) {
8625
9416
 
8626
9417
  function registerSidebarTabs() {
8627
9418
  if (sidebarRegistered) return;
8628
- var sidebar = undefined;
8629
- try {
8630
- sidebar = ctx.get('betterSidebar');
8631
- } catch (error) {
8632
- sidebar = undefined;
8633
- }
9419
+ var sidebar = sidebarService(ctx);
8634
9420
  if (!sidebar || typeof sidebar.registerTab !== 'function') return;
8635
9421
  sidebarRegistered = true;
8636
9422
  if (tabPollTimer !== null) {
@@ -8639,22 +9425,97 @@ function attributeViolation(name, value, tagName) {
8639
9425
  }
8640
9426
  var syncDirectoryTabsInFlight = false;
8641
9427
 
8642
- function installLinkedTab() {
9428
+ // The "+" menu filters on `descriptor.hidden` and only maps `available`
9429
+ // to a disabled flag, so a per-session entry has to be hidden rather
9430
+ // than marked unavailable. These two helpers resolve the session on
9431
+ // screen right when the menu asks, which keeps the entries in sync with
9432
+ // the workspace kind without unregistering anything (an unregistered
9433
+ // kind would orphan its open pages and break "Open directory tree").
9434
+ var activeScopeCache = { cwd: '', workspaceId: '' };
9435
+
9436
+ function readActiveScope() {
9437
+ var info = { cwd: '', workspaceId: '' };
9438
+ try {
9439
+ var snapshot = typeof sidebar.getSnapshot === 'function' ? sidebar.getSnapshot() : null;
9440
+ var sessionId = snapshot && snapshot.sessionId;
9441
+ if (!sessionId) return info;
9442
+ var sessions = ctx.sessions || (ctx.get && ctx.get('sessions'));
9443
+ var list = sessions && sessions.list ? sessions.list : sessions;
9444
+ var sessionState = list && typeof list.getSnapshot === 'function' ? list.getSnapshot() : null;
9445
+ var record = sessionState && sessionState.byId ? sessionState.byId[sessionId] : null;
9446
+ if (record) {
9447
+ info.cwd = record.cwd || '';
9448
+ info.workspaceId = record.workspaceId || '';
9449
+ }
9450
+ } catch (error) { /* fall back to an empty scope */ }
9451
+ return info;
9452
+ }
9453
+
9454
+ function activeScope() {
9455
+ activeScopeCache = readActiveScope();
9456
+ return activeScopeCache;
9457
+ }
9458
+
9459
+ function linkedTabHidden() {
9460
+ var scope = activeScope();
9461
+ return !(isLinkedScope(scope) || isLinkedWorkspaceId(scope.workspaceId));
9462
+ }
9463
+
9464
+ function remoteTabHidden() {
9465
+ var scope = activeScope();
9466
+ return !(isRemoteScope(scope) || isRemoteWorkspaceId(scope.workspaceId));
9467
+ }
9468
+
9469
+ // `hidden` is read whenever the sidebar builds its "+" entries, so the
9470
+ // answer is always fresh — but the sidebar only rebuilds those entries
9471
+ // when something notifies it. Re-registering the same two descriptors
9472
+ // notifies without touching the stored tabs, so open pages survive.
9473
+ var visibilitySignature = '';
9474
+
9475
+ function currentVisibilitySignature() {
9476
+ return (linkedTabHidden() ? '0' : '1') + (remoteTabHidden() ? '0' : '1');
9477
+ }
9478
+
9479
+ function syncTabVisibility() {
9480
+ var next = currentVisibilitySignature();
9481
+ if (next === visibilitySignature) return;
9482
+ visibilitySignature = next;
9483
+ if (linkedTabDisposer === null && remoteTabDisposer === null) return;
9484
+ disposeLinkedTab();
9485
+ disposeRemoteTab();
9486
+ installLinkedTab(false);
9487
+ installRemoteTab(false);
9488
+ }
9489
+
9490
+ function watchSessionScope() {
9491
+ visibilitySignature = currentVisibilitySignature();
9492
+ try {
9493
+ var sessions = ctx.sessions || (ctx.get && ctx.get('sessions'));
9494
+ var list = sessions && (sessions.list || sessions);
9495
+ if (!list || typeof list.subscribe !== 'function') return;
9496
+ var unsubscribe = list.subscribe(function () { syncTabVisibility(); });
9497
+ if (typeof unsubscribe === 'function') tabDisposers.push(unsubscribe);
9498
+ } catch (error) { /* without a store the entries simply stay as they are */ }
9499
+ }
9500
+
9501
+ function installLinkedTab(track) {
8643
9502
  if (linkedTabDisposer !== null) return;
8644
9503
  linkedTabDisposer = sidebar.registerTab({
8645
9504
  id: TREE_TAB_TYPE,
8646
9505
  title: function () { return makeT(readLocale(ctx))('tabTitle'); },
8647
9506
  description: function () { return makeT(readLocale(ctx))('tabDesc'); },
8648
- icon: function (size) { return IconFolderTree(size); },
9507
+ icon: function (size) { return IconLinkedWorkspace(size); },
8649
9508
  order: 62,
8650
9509
  single: true,
8651
- available: function (_ctx, sessionScope) { return isLinkedScope(sessionScope); },
9510
+ get hidden() { return linkedTabHidden(); },
9511
+ available: function () { return true; },
8652
9512
  component: function (props) {
8653
9513
  var currentLocale = useLocale(ctx);
8654
9514
  var t = useMemo(function () { return makeT(currentLocale); }, [currentLocale]);
8655
9515
  return h(RemoteDirectoryTab, Object.assign({}, props, { ctx: ctx, t: t, locale: currentLocale, variant: 'linked' }));
8656
9516
  },
8657
9517
  });
9518
+ if (track !== false) tabDisposers.push(function () { disposeLinkedTab(); });
8658
9519
  }
8659
9520
 
8660
9521
  function disposeLinkedTab() {
@@ -8663,22 +9524,24 @@ function attributeViolation(name, value, tagName) {
8663
9524
  linkedTabDisposer = null;
8664
9525
  }
8665
9526
 
8666
- function installRemoteTab() {
9527
+ function installRemoteTab(track) {
8667
9528
  if (remoteTabDisposer !== null) return;
8668
9529
  remoteTabDisposer = sidebar.registerTab({
8669
- id: REMOTE_TAB_TYPE,
9530
+ id: REMOTE_TREE_TAB_TYPE,
8670
9531
  title: function () { return makeT(readLocale(ctx))('remoteTabTitle'); },
8671
9532
  description: function () { return makeT(readLocale(ctx))('remoteTabDesc'); },
8672
- icon: function (size) { return IconServer(size); },
9533
+ icon: function (size) { return IconRemoteWorkspace(size); },
8673
9534
  order: 61,
8674
9535
  single: true,
8675
- available: function () { return hasRemoteDirectories; },
9536
+ get hidden() { return remoteTabHidden(); },
9537
+ available: function () { return true; },
8676
9538
  component: function (props) {
8677
9539
  var currentLocale = useLocale(ctx);
8678
9540
  var t = useMemo(function () { return makeT(currentLocale); }, [currentLocale]);
8679
9541
  return h(RemoteDirectoryTab, Object.assign({}, props, { ctx: ctx, t: t, locale: currentLocale, variant: 'remote' }));
8680
9542
  },
8681
9543
  });
9544
+ if (track !== false) tabDisposers.push(function () { disposeRemoteTab(); });
8682
9545
  }
8683
9546
 
8684
9547
  function disposeRemoteTab() {
@@ -8687,50 +9550,25 @@ function attributeViolation(name, value, tagName) {
8687
9550
  remoteTabDisposer = null;
8688
9551
  }
8689
9552
 
8690
- function activeSessionClientInfo(sessionId) {
8691
- if (!sessionId) return null;
8692
- try {
8693
- var sessions = ctx.sessions || (ctx.get && ctx.get('sessions'));
8694
- var list = sessions && sessions.list;
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
-
9553
+ // Both page kinds stay registered for the whole session: `available`
9554
+ // only greys out the "+" entry for a mismatched session, while
9555
+ // `openTab` refuses a kind it has never seen. Registering lazily per
9556
+ // session meant "open the tree" from the settings page silently did
9557
+ // nothing whenever the workspace was not the one on screen.
8709
9558
  function syncDirectoryTabs() {
8710
9559
  if (syncDirectoryTabsInFlight) return;
8711
9560
  syncDirectoryTabsInFlight = true;
8712
9561
  refreshDirectoryAvailability().catch(function () { /* ignore */ }).then(function () {
8713
- if (hasRemoteDirectories) installRemoteTab();
8714
- else disposeRemoteTab();
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; });
9562
+ syncDirectoryTabsInFlight = false;
9563
+ });
8731
9564
  }
8732
9565
 
8733
9566
  syncDirectoryTabsRef = syncDirectoryTabs;
9567
+ refreshTabVisibilityRef = syncTabVisibility;
9568
+ installLinkedTab();
9569
+ installRemoteTab();
9570
+ watchSessionScope();
9571
+ syncTabVisibility();
8734
9572
  try {
8735
9573
  tabDisposers.push(sidebar.subscribeState(function () { syncDirectoryTabs(); }));
8736
9574
  } catch (error) { /* state subscription is optional */ }
@@ -8775,22 +9613,11 @@ function attributeViolation(name, value, tagName) {
8775
9613
  }
8776
9614
  }
8777
9615
 
8778
- // Tabs persisted before the 0.3.0 rename still carry the old type ids;
8779
- // register hidden aliases so a reloaded page restores them instead of
8780
- // showing "no available view" for the legacy tab.
9616
+ // Tabs persisted before the 0.3.0 rename still carry the old file type
9617
+ // id; register a hidden alias so a reloaded page restores it instead of
9618
+ // showing "no available view" for the legacy tab. The legacy tree kind
9619
+ // ("dsh-remote-workspace") is now the real remote-workspace tab.
8781
9620
  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
9621
  tabDisposers.push(sidebar.registerTab({
8795
9622
  id: 'dsh-remote-workspace:file',
8796
9623
  title: function () { return makeT(readLocale(ctx))('fileTabTitle'); },