dsh-remote 1.2.0 → 1.3.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
@@ -27,7 +27,7 @@ window.__ModuleLoader__.load({
27
27
 
28
28
  const React = require('react')
29
29
  const name = 'dsh-remote'
30
- const CLIENT_VERSION = '1.2.0'
30
+ const CLIENT_VERSION = '1.3.0'
31
31
 
32
32
  // ── optional host primitives ────────────────────────────────────────────
33
33
  // Issue #74: a remote session's .md link must open over SFTP, NOT via the
@@ -82,6 +82,18 @@ window.__ModuleLoader__.load({
82
82
  const HostSwitch = (Primitives && typeof Primitives.Switch === 'function') ? Primitives.Switch : null
83
83
  const HostSegmentedTabs = (Primitives && typeof Primitives.SegmentedTabs === 'function') ? Primitives.SegmentedTabs : null
84
84
  const HostFileTypeIcon = (Primitives && typeof Primitives.FileTypeIcon === 'function') ? Primitives.FileTypeIcon : null
85
+ const HostCheckbox = (Primitives && typeof Primitives.Checkbox === 'function') ? Primitives.Checkbox : null
86
+ const HostChevronDownIcon = (Primitives && typeof Primitives.IconChevronDownOutlineRegular === 'function') ? Primitives.IconChevronDownOutlineRegular : null
87
+ const HostChevronRightIcon = (Primitives && typeof Primitives.IconChevronRightOutlineRegular === 'function') ? Primitives.IconChevronRightOutlineRegular : null
88
+ const HostChevronLeftIcon = (Primitives && typeof Primitives.IconChevronLeftOutlineRegular === 'function') ? Primitives.IconChevronLeftOutlineRegular : null
89
+ const HostChevronUpIcon = (Primitives && typeof Primitives.IconChevronUpOutlineRegular === 'function') ? Primitives.IconChevronUpOutlineRegular : null
90
+ const HostEllipsisIcon = (Primitives && typeof Primitives.IconEllipsisOutlineRegular === 'function') ? Primitives.IconEllipsisOutlineRegular : null
91
+ const HostCloseIcon = (Primitives && typeof Primitives.IconCloseOutlineRegular === 'function') ? Primitives.IconCloseOutlineRegular : null
92
+ const HostGlobeIcon = (Primitives && typeof Primitives.IconGlobeOutlineRegular === 'function') ? Primitives.IconGlobeOutlineRegular : null
93
+ const HostForwardIcon = (Primitives && typeof Primitives.IconRightUpOutlineRegular === 'function') ? Primitives.IconRightUpOutlineRegular : null
94
+ const HostLogIcon = (Primitives && typeof Primitives.IconListPenOutlineRegular === 'function') ? Primitives.IconListPenOutlineRegular : null
95
+ const HostCleanupIcon = (Primitives && typeof Primitives.IconTrashOutlineRegular === 'function') ? Primitives.IconTrashOutlineRegular : null
96
+ const HostSlidersIcon = (Primitives && typeof Primitives.IconSlidersTwoOutlineRegular === 'function') ? Primitives.IconSlidersTwoOutlineRegular : null
85
97
 
86
98
  // Issue #93: floating layers must PORTAL to document.body, exactly like the
87
99
  // host's own Modal/Menu (and like our context menu already does with an
@@ -211,7 +223,6 @@ window.__ModuleLoader__.load({
211
223
  'ide.unsupported': '当前宿主未提供原生编辑区,无法启用 IDE 模式。',
212
224
 
213
225
  'workspaceSearch.options': '搜索选项',
214
- 'workspaceSearch.details': '扫描详情',
215
226
  'workspaceSearch.matches': '{n} 个结果',
216
227
  'workspaceSearch.scanned': '已扫描 {n} 项',
217
228
  'workspaceSearch.activeOptions': '搜索选项 · {n}',
@@ -382,6 +393,8 @@ window.__ModuleLoader__.load({
382
393
  'settings.edit': '编辑',
383
394
  'settings.delete': '删除',
384
395
  'settings.editMachine': '编辑机器',
396
+ 'settings.addMachine': '新增机器',
397
+ 'settings.adoptAliasHint': '把 {alias} 保存为机器,可在这里填写登录密码(保存后即可继续编辑)',
385
398
  'settings.badgeSshConfig': 'ssh cfg',
386
399
  // Issue #51 — transport backend (GSSAPI/Kerberos via system OpenSSH).
387
400
  'settings.badgeOpenssh': 'openssh',
@@ -432,7 +445,8 @@ window.__ModuleLoader__.load({
432
445
  // 灰按钮必须能解释自己:用户「点了没反应」时唯一能拿到的线索就是 hover 提示。
433
446
  'settings.saveNeedsHost': '先填写主机地址才能保存',
434
447
  'settings.saveHint': '保存这台机器(留空的密码/私钥/passphrase 沿用已保存的值)',
435
- 'settings.fwdNeedsPort': '先填写本地监听端口才能添加转发',
448
+ 'settings.poolRepointFailed': '机器已保存,但切换当前连接失败:{msg}。请重新选择这台机器,或重启 DSH。',
449
+ 'settings.fwdNeedsPort': '先填写监听端口才能添加转发',
436
450
  'settings.fwdAddHint': '添加一条端口转发',
437
451
  'settings.advCollapse': '收起高级配置',
438
452
  'settings.advExpand': '高级配置:认证与连接选项',
@@ -456,16 +470,46 @@ window.__ModuleLoader__.load({
456
470
  'settings.saving': '保存中…',
457
471
  'settings.save': '保存',
458
472
  'settings.forwards': '端口转发(SSH 隧道)',
473
+ 'settings.forwardsHint': '谁要发起访问,就在谁那边开监听口:监听口开在本机就是本地转发(ssh -L),开在远端就是远程转发(ssh -R)。',
474
+ 'settings.fwdLocalHint': '监听口开在本机,连接转发到远端目标。',
475
+ 'settings.fwdSideLocal': '本机 -L',
476
+ 'settings.fwdSideReverse': '远端 -R',
477
+ 'settings.fwdReverseHint': '监听口开在远端,连接转发回本机目标。',
459
478
  'settings.fwdStop': '停止',
460
479
  'settings.fwdStart': '启动',
480
+ 'settings.fwdStarting': '启动中…',
461
481
  'settings.fwdRemove': '删除',
462
- 'settings.fwdDirLocal': '本地→远端',
463
- 'settings.fwdDirReverse': '远端→本地',
482
+ 'settings.fwdDirLocal': '本地 (-L)',
483
+ 'settings.fwdDirReverse': '远程 (-R)',
464
484
  'settings.fwdListen': '监听端口',
465
485
  'settings.fwdTargetHost': '目标主机',
466
486
  'settings.fwdTargetPort': '目标端口',
467
487
  'settings.fwdAuto': '自动重连',
488
+ 'settings.fwdAutoHint': '掉线重连后自动恢复这条转发',
489
+ 'settings.fwdLegacyBadge': '需重新确认',
490
+ 'settings.fwdLegacyHint': '旧版「自动重连」配置已暂停:重新勾选,并在需要时手动启动一次。',
491
+ 'settings.fwdAutoNoticeTitle': '自动重连会做什么?',
492
+ 'settings.fwdAutoNoticeBody': '勾选后,这条转发会记住“上次是否在运行”。\n\ndsh-web 启动时会自动连接当前机器,连上后恢复这条转发。\n\n如果机器连不上、凭据失效或端口被占用,本次恢复会失败,但不影响其他功能。\n\nDSH 重启后,只会恢复上次运行中的转发(从没启动过的不会自动启动)。',
493
+ 'settings.fwdAutoNoticeTitleReverse': '反向转发的自动重连会做什么?',
494
+ 'settings.fwdAutoNoticeBodyReverse': '勾选后,这条反向转发会记住“上次是否在运行”。\n\ndsh-web 启动时会自动连接当前机器,并在这台机器上重新监听端口、把连接转发回你本机;也就是说,重启后它会在远端自动重新打开监听。\n\n只有上次运行中的反向转发会被恢复;如果机器连不上、远端 AllowTcpForwarding 被关闭或端口被占用,本次恢复会失败,但不影响其他功能。\n\n如果不想让远端自动重新监听,请取消勾选或手动停止。',
495
+ 'settings.fwdAutoNoticeConfirm': '仍然勾选',
496
+ 'settings.fwdAutoNoticeCancel': '取消',
497
+ 'settings.fwdAutoNoticeDontShow': '不再提示',
468
498
  'settings.fwdAdd': '添加转发',
499
+ 'settings.fwdHost': '主机',
500
+ 'settings.fwdHostHint': '这条转发属于哪台主机;只有连上该主机时才能启动。可以给还没连接的主机先存下转发。',
501
+ 'settings.fwdHostCurrent': '当前',
502
+ 'settings.fwdHostEmpty': '(暂无主机)',
503
+ 'settings.fwdHostNeeds': '先选择一台主机才能添加转发',
504
+ 'settings.fwdAddedOther': '已添加:连上 {name} 后即可启动这条转发',
505
+ 'settings.fwdHostStale': '当前运行的插件宿主端还是旧版本,不认识“主机”字段;已撤销这条转发。请重启 DSH 后再添加。',
506
+ 'settings.fwdEdit': '编辑',
507
+ 'settings.fwdEditHint': '修改方向、监听端口、目标或所属主机;运行中的转发会先停止,保存后按新配置重新启动',
508
+ 'settings.fwdSaveChanges': '保存修改',
509
+ 'settings.fwdCancelEdit': '取消',
510
+ 'settings.fwdUpdated': '已保存修改',
511
+ 'settings.fwdEditingBadge': '编辑中',
512
+ 'settings.fwdUpdateStale': '当前运行的插件宿主端还是旧版本,没能保存这些修改;已恢复原来的转发。请重启 DSH 后再编辑。',
469
513
  'settings.cleanup': '工作区清理(本地镜像与对话)',
470
514
  'settings.cleanupRefresh': '刷新',
471
515
  'settings.cleanupEmpty': '没有本地镜像。选定一个远程工作区后它会出现在这里。',
@@ -515,8 +559,6 @@ window.__ModuleLoader__.load({
515
559
  'settings.badgePwd': '密码',
516
560
  'settings.badgeKeychain': '钥匙串',
517
561
  'settings.badgeProxy': '跳板',
518
- 'settings.sectionHide': '收起此栏',
519
- 'settings.sectionShow': '展开此栏',
520
562
  'settings.update': '更新',
521
563
  'settings.updateChecking': '版本信息加载中…',
522
564
  'settings.checking': '检查中…',
@@ -574,7 +616,7 @@ window.__ModuleLoader__.load({
574
616
  'settings.modeOff': '关闭',
575
617
  'settings.modeManual': '手动',
576
618
  'picker.title': '选择工作目录',
577
- 'picker.close': '关闭 ✕',
619
+ 'picker.close': '关闭',
578
620
  'picker.tabLocal': '本机',
579
621
  'picker.tabRemote': '远程',
580
622
  'picker.localIntro': '弹出系统文件夹对话框选择;不可用时用内置目录浏览,也可直接输入本机目录。',
@@ -602,8 +644,8 @@ window.__ModuleLoader__.load({
602
644
  'picker.emptyDir': '(空目录)',
603
645
  'picker.loading': '加载中…',
604
646
  'picker.readingRoot': '正在读取根目录…',
605
- 'picker.back': '回上一级 ▴',
606
- 'picker.closeBtn': '关闭 ✕',
647
+ 'picker.back': '回上一级',
648
+ 'picker.closeBtn': '关闭',
607
649
  'picker.newDir': '新建目录',
608
650
  'picker.newFolder': '新建文件夹',
609
651
  'picker.create': '新建',
@@ -807,7 +849,6 @@ window.__ModuleLoader__.load({
807
849
  'ide.unsupported': 'This host does not expose the native editor area required by IDE mode.',
808
850
 
809
851
  'workspaceSearch.options': 'Search options',
810
- 'workspaceSearch.details': 'Scan details',
811
852
  'workspaceSearch.matches': '{n} results',
812
853
  'workspaceSearch.scanned': '{n} scanned',
813
854
  'workspaceSearch.activeOptions': 'Search options · {n}',
@@ -976,6 +1017,8 @@ window.__ModuleLoader__.load({
976
1017
  'settings.edit': 'Edit',
977
1018
  'settings.delete': 'Delete',
978
1019
  'settings.editMachine': 'Edit machine',
1020
+ 'settings.addMachine': 'New machine',
1021
+ 'settings.adoptAliasHint': 'Save {alias} as a machine so you can set its login password here (it stays editable afterwards)',
979
1022
  'settings.badgeSshConfig': 'ssh cfg',
980
1023
  // Issue #51 — transport backend (GSSAPI/Kerberos via system OpenSSH).
981
1024
  'settings.badgeOpenssh': 'openssh',
@@ -1020,7 +1063,8 @@ window.__ModuleLoader__.load({
1020
1063
  'settings.testNeedsHost': 'Fill in the host before testing',
1021
1064
  'settings.saveNeedsHost': 'Fill in the host before saving',
1022
1065
  'settings.saveHint': 'Save this machine (a blank password/key/passphrase keeps the saved one)',
1023
- 'settings.fwdNeedsPort': 'Fill in the local listen port before adding a forward',
1066
+ 'settings.poolRepointFailed': 'The machine was saved, but re-pointing the active connection failed: {msg}. Select the machine again or restart DSH.',
1067
+ 'settings.fwdNeedsPort': 'Fill in the listen port before adding a forward',
1024
1068
  'settings.fwdAddHint': 'Add a port forward',
1025
1069
  'settings.advCollapse': 'Hide advanced options',
1026
1070
  'settings.advExpand': 'Advanced authentication and connection options',
@@ -1044,16 +1088,46 @@ window.__ModuleLoader__.load({
1044
1088
  'settings.saving': 'Saving…',
1045
1089
  'settings.save': 'Save',
1046
1090
  'settings.forwards': 'Port forwarding (SSH tunnels)',
1091
+ 'settings.forwardsHint': 'Open the listener on the side that starts the connection: a listener here is a local forward (ssh -L); one on the remote is a reverse forward (ssh -R).',
1092
+ 'settings.fwdLocalHint': 'The listener is on this machine; connections go to the remote target.',
1093
+ 'settings.fwdSideLocal': 'Local -L',
1094
+ 'settings.fwdSideReverse': 'Remote -R',
1095
+ 'settings.fwdReverseHint': 'The listener is on the remote; connections come back to the local target.',
1047
1096
  'settings.fwdStop': 'Stop',
1048
1097
  'settings.fwdStart': 'Start',
1098
+ 'settings.fwdStarting': 'Starting…',
1049
1099
  'settings.fwdRemove': 'Remove',
1050
- 'settings.fwdDirLocal': 'Local → remote',
1051
- 'settings.fwdDirReverse': 'Remote → local',
1100
+ 'settings.fwdDirLocal': 'Local (-L)',
1101
+ 'settings.fwdDirReverse': 'Remote (-R)',
1052
1102
  'settings.fwdListen': 'Listen port',
1053
1103
  'settings.fwdTargetHost': 'Target host',
1054
1104
  'settings.fwdTargetPort': 'Target port',
1055
1105
  'settings.fwdAuto': 'Auto reconnect',
1106
+ 'settings.fwdAutoHint': 'Restore this forward automatically after a reconnect',
1107
+ 'settings.fwdLegacyBadge': 'Re-confirm',
1108
+ 'settings.fwdLegacyHint': 'The legacy auto-reconnect setting was paused: tick it again and start the forward once if needed.',
1109
+ 'settings.fwdAutoNoticeTitle': 'What does Auto reconnect do?',
1110
+ 'settings.fwdAutoNoticeBody': 'When checked, this forward remembers whether it was running.\n\ndsh web connects the current machine on startup and restores the forward once connected.\n\nIf the host is unreachable, credentials fail, or the port is taken, that restore fails without affecting anything else.\n\nAfter a DSH restart only forwards that were running come back (one that was never started stays down).',
1111
+ 'settings.fwdAutoNoticeTitleReverse': 'What does Auto reconnect do for a reverse forward?',
1112
+ 'settings.fwdAutoNoticeBodyReverse': 'When checked, this reverse forward remembers whether it was running.\n\ndsh web connects the current machine on startup and makes the REMOTE listen again, piping connections back to your machine. In other words, it re-opens the remote listener automatically after a restart.\n\nOnly reverse forwards that were running are restored; if the host is unreachable, AllowTcpForwarding was disabled, or the port is taken, that restore fails without affecting anything else.\n\nUncheck this or stop the forward if the remote must not listen again on its own.',
1113
+ 'settings.fwdAutoNoticeConfirm': 'Enable anyway',
1114
+ 'settings.fwdAutoNoticeCancel': 'Cancel',
1115
+ 'settings.fwdAutoNoticeDontShow': "Don't show again",
1056
1116
  'settings.fwdAdd': 'Add forward',
1117
+ 'settings.fwdHost': 'Host',
1118
+ 'settings.fwdHostHint': 'Which host this tunnel belongs to. It can start only while that host is connected; you can still define it for a host that is not connected yet.',
1119
+ 'settings.fwdHostCurrent': 'current',
1120
+ 'settings.fwdHostEmpty': '(no hosts yet)',
1121
+ 'settings.fwdHostNeeds': 'Pick a host before adding a forward',
1122
+ 'settings.fwdAddedOther': 'Added — start it once {name} is connected',
1123
+ 'settings.fwdHostStale': 'The running host half predates the host field and would have attached this tunnel to the connected machine. The forward was removed — restart DSH and add it again.',
1124
+ 'settings.fwdEdit': 'Edit',
1125
+ 'settings.fwdEditHint': 'Change the direction, listen port, target or host; a running forward is stopped first and then restarted with the new settings',
1126
+ 'settings.fwdSaveChanges': 'Save changes',
1127
+ 'settings.fwdCancelEdit': 'Cancel',
1128
+ 'settings.fwdUpdated': 'Changes saved',
1129
+ 'settings.fwdEditingBadge': 'Editing',
1130
+ 'settings.fwdUpdateStale': 'The running host half predates forward editing and could not store these changes; the previous forward was restored. Restart DSH and edit again.',
1057
1131
  'settings.cleanup': 'Workspace cleanup (local mirrors & chats)',
1058
1132
  'settings.cleanupRefresh': 'Refresh',
1059
1133
  'settings.cleanupEmpty': 'No local mirrors yet. Pick a remote workspace and it shows up here.',
@@ -1103,8 +1177,6 @@ window.__ModuleLoader__.load({
1103
1177
  'settings.badgePwd': 'password',
1104
1178
  'settings.badgeKeychain': 'keychain',
1105
1179
  'settings.badgeProxy': 'jump',
1106
- 'settings.sectionHide': 'Collapse section',
1107
- 'settings.sectionShow': 'Expand section',
1108
1180
  'settings.update': 'Update',
1109
1181
  'settings.updateChecking': 'Loading version info…',
1110
1182
  'settings.checking': 'Checking…',
@@ -1163,7 +1235,7 @@ window.__ModuleLoader__.load({
1163
1235
  'settings.modeOff': 'Off',
1164
1236
  'settings.modeManual': 'Manual',
1165
1237
  'picker.title': 'Select working directory',
1166
- 'picker.close': 'Close ✕',
1238
+ 'picker.close': 'Close',
1167
1239
  'picker.tabLocal': 'Local',
1168
1240
  'picker.tabRemote': 'Remote',
1169
1241
  'picker.localIntro': 'Opens the system folder dialog; when unavailable, uses the built-in directory browser. You can also type a local path directly.',
@@ -1191,8 +1263,8 @@ window.__ModuleLoader__.load({
1191
1263
  'picker.emptyDir': ' (empty directory)',
1192
1264
  'picker.loading': 'Loading…',
1193
1265
  'picker.readingRoot': 'Reading root directory…',
1194
- 'picker.back': 'Back ▴',
1195
- 'picker.closeBtn': 'Close ✕',
1266
+ 'picker.back': 'Back',
1267
+ 'picker.closeBtn': 'Close',
1196
1268
  'picker.newDir': 'New directory',
1197
1269
  'picker.newFolder': 'New folder',
1198
1270
  'picker.create': 'Create',
@@ -1440,7 +1512,7 @@ window.__ModuleLoader__.load({
1440
1512
  // Theme via DSH design tokens so this follows the harness light/dark theme.
1441
1513
  const v = (name, fb) => `var(${name}, ${fb})`
1442
1514
  const T = {
1443
- bg: v('--dsw-alias-bg-layer-1', 'rgba(128,128,128,0.07)'),
1515
+ bg: v('--dsw-alias-bg-layer-2', 'rgba(128,128,128,0.07)'),
1444
1516
  bg2: v('--dsw-alias-interactive-bg-hover', 'rgba(128,128,128,0.10)'),
1445
1517
  border: v('--dsw-alias-border-l2', 'rgba(128,128,128,0.35)'),
1446
1518
  borderStrong: v('--dsw-alias-border-l3', 'rgba(128,128,128,0.5)'),
@@ -1475,10 +1547,10 @@ window.__ModuleLoader__.load({
1475
1547
  const CHROME_CSS_ID = 'dsh-remote-chrome'
1476
1548
  const CHROME_CSS_TEXT = [
1477
1549
  '[data-rw-settings-legacy-icon]{position:relative}[data-rw-settings-legacy-icon]>svg{opacity:0}[data-rw-settings-legacy-icon]::before{content:"";position:absolute;left:12px;top:50%;transform:translateY(-50%);width:16px;height:16px;background:currentColor;mask:url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22black%22%20stroke-width%3D%221.6%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpath%20d%3D%22M3%204h18v12H3zM8%2020h8M12%2016v4M7%208l3%202-3%202M13%2012h4%22%2F%3E%3C%2Fsvg%3E") center/contain no-repeat;-webkit-mask:url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22black%22%20stroke-width%3D%221.6%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpath%20d%3D%22M3%204h18v12H3zM8%2020h8M12%2016v4M7%208l3%202-3%202M13%2012h4%22%2F%3E%3C%2Fsvg%3E") center/contain no-repeat;pointer-events:none}',
1478
- '.dsh-rw-search-scope{display:flex;gap:8px;align-items:center;margin-top:6px;font-size:11px}.dsh-rw-search-options{position:relative;flex-shrink:0}.dsh-rw-search-options>summary{cursor:pointer;padding:4px 0;color:var(--dsw-alias-label-tertiary,#777);white-space:nowrap}.dsh-rw-search-option-body{position:absolute;right:0;top:100%;z-index:45;width:220px;max-width:calc(100vw - 40px);box-sizing:border-box;padding:12px;background:var(--dsw-alias-bg-base,#fff);border:1px solid var(--dsw-alias-border-l2,#ddd);border-radius:8px;box-shadow:0 4px 16px #0002}.dsh-rw-search-option-body label{display:flex;gap:7px;align-items:center;padding:5px 0}.dsh-rw-search-option-body p{font-size:10px;color:var(--dsw-alias-label-tertiary,#777);line-height:1.6;margin:8px 0 0}.dsh-rw-search-details{flex:1;min-width:0;font-size:11px}.dsh-rw-search-details>summary{cursor:pointer;padding:4px 0;list-style-position:inside}.dsh-rw-search-status{display:inline;line-height:1.6}.dsh-rw-search-status>span+span:before{content:" · ";color:var(--dsw-alias-label-tertiary,#777)}.dsh-rw-search-detail-body{padding:7px 0 2px;line-height:1.7;color:var(--dsw-alias-label-tertiary,#777)}',
1550
+ '.dsh-rw-search-scope{display:flex;gap:8px;align-items:center;margin-top:6px;font-size:11px}.dsh-rw-search-detail-body{padding:7px 0 2px;line-height:1.7;color:var(--dsw-alias-label-tertiary,#777)}',
1479
1551
  '.dsh-rw-search-controls{margin-top:8px;min-width:0}.dsh-rw-search-panel{display:flex;flex-direction:column;flex:1;min-height:0;min-width:0}.dsh-rw-search-progress{display:flex;align-items:flex-start;gap:8px;padding:7px 10px;border-bottom:1px solid var(--dsw-alias-border-l2,rgba(128,128,128,.2));font-size:12px}.dsh-rw-search-progress button{flex-shrink:0;white-space:nowrap}.dsh-rw-search-indicator{width:100%;height:3px;flex-shrink:0;border:0}.dsh-rw-search-results{overflow:auto;flex:1;min-height:0}.dsh-rw-search-result{width:100%;box-sizing:border-box;display:flex;gap:8px;align-items:flex-start;text-align:left;border:0;border-bottom:1px solid rgba(128,128,128,.12);background:transparent;color:inherit;padding:9px 10px;cursor:pointer}.dsh-rw-search-result:hover{background:rgba(128,128,128,.08)}.dsh-rw-search-result:focus-visible{outline:2px solid var(--dsw-alias-button-primary-fill,#2563eb);outline-offset:-2px}',
1480
1552
  '.dsh-rw-git{height:100%;min-height:0;display:flex;flex-direction:column;font-size:12px;overflow:hidden;color:inherit}.dsh-rw-git-header{padding:10px;display:flex;flex-direction:column;gap:7px;border-bottom:1px solid var(--dsw-alias-border-l2,rgba(128,128,128,.2));flex-shrink:0}.dsh-rw-git-title{display:flex;align-items:center;gap:7px}.dsh-rw-git-title>strong{flex:1}.dsh-rw-git-repo{font-size:11px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dsh-rw-git-hint{font-size:11px;opacity:.7;line-height:1.5}.dsh-rw-git-mode{display:flex;gap:6px}.dsh-rw-git-mode button{padding:4px 8px;white-space:nowrap}.dsh-rw-git-mode button[aria-pressed=true]{font-weight:600;background:rgba(128,128,128,.14)}.dsh-rw-git-header input{box-sizing:border-box;width:100%;font-size:12px}.dsh-rw-git-message{padding:10px;line-height:1.6;overflow-wrap:anywhere}.dsh-rw-git-message button{margin-left:8px}.dsh-rw-git-files{flex:0 1 auto;max-height:34%;overflow:auto;padding:4px;min-height:40px;border-bottom:1px solid var(--dsw-alias-border-l2,rgba(128,128,128,.2))}.dsh-rw-git-file{display:flex;gap:7px;align-items:center;width:100%;min-height:30px;padding:5px 8px;border:0;border-radius:4px;background:transparent;color:inherit;cursor:pointer;text-align:left}.dsh-rw-git-file:hover,.dsh-rw-git-file[aria-selected=true]{background:rgba(128,128,128,.13)}.dsh-rw-git-file:focus-visible{outline:2px solid var(--dsw-alias-button-primary-fill,#2563eb);outline-offset:-2px}.dsh-rw-git-file-path{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dsh-rw-git-status{flex-shrink:0;font-size:11px;font-family:monospace}.dsh-rw-git-preview{flex:1;min-height:0;display:flex;flex-direction:column;overflow:hidden}.dsh-rw-git-preview-title{display:flex;align-items:center;gap:8px;padding:8px 10px}.dsh-rw-git-preview-title>strong{font-size:12px;flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dsh-rw-git-preview>.dsh-rw-git-hint{padding:0 10px 7px}.dsh-rw-git-diff{flex:1;min-height:0;overflow:auto;font:11px/1.6 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;tab-size:4;padding:4px 0}.dsh-rw-git-diff-line{display:flex;min-width:max-content;white-space:pre}.dsh-rw-git-diff-line>span:last-child{padding-right:12px}.dsh-rw-git-diff-line[data-rw-diff-kind=added]{background:rgba(34,197,94,.11)}.dsh-rw-git-diff-line[data-rw-diff-kind=removed]{background:rgba(239,68,68,.11)}.dsh-rw-git-diff-line[data-rw-diff-kind=hunk]{background:rgba(59,130,246,.1)}.dsh-rw-git-line-number{box-sizing:border-box;flex:0 0 48px;width:48px;padding:0 7px;border:0;background:transparent;color:inherit;opacity:.6;font:inherit;text-align:right;user-select:none}.dsh-rw-git-diff button.dsh-rw-git-line-number{cursor:pointer}.dsh-rw-git-diff button.dsh-rw-git-line-number:hover{opacity:1;text-decoration:underline}',
1481
- '.dsh-rw-applied-change{border-top:1px solid var(--dsw-alias-border-l2,rgba(128,128,128,.2));min-width:0;overflow:hidden}.dsh-rw-change-heading{display:flex;gap:8px;align-items:center;padding:7px 10px;font-size:11px}.dsh-rw-change-heading strong{font-weight:500}.dsh-rw-change-hunk{margin:0 8px 6px}.dsh-rw-change-hunk>summary{font-size:11px;cursor:pointer;padding:4px 2px}',
1553
+ '.dsh-rw-applied-change{border-top:1px solid var(--dsw-alias-border-l2,rgba(128,128,128,.2));min-width:0;overflow:hidden}.dsh-rw-change-heading{display:flex;gap:8px;align-items:center;padding:7px 10px;font-size:11px}.dsh-rw-change-heading strong{font-weight:500}.dsh-rw-change-hunk{margin:0 8px 6px}',
1482
1554
  '.dsh-rw-btn{transition:background .12s ease,opacity .12s ease,border-color .12s ease}',
1483
1555
  '.dsh-rw-btn:hover:not(:disabled){background:rgba(128,128,128,.18)}',
1484
1556
  '.dsh-rw-btn:focus-visible{outline:2px solid var(--dsw-alias-button-primary-fill,#2563eb);outline-offset:1px}',
@@ -1496,10 +1568,14 @@ window.__ModuleLoader__.load({
1496
1568
  '.dsh-rw-row{border-radius:8px;margin:0 -6px;padding-left:8px;padding-right:8px;transition:background .12s ease}',
1497
1569
  '.dsh-rw-row:hover{background:rgba(128,128,128,.14)}',
1498
1570
  '.dsh-rw-list-item{transition:background .1s ease}',
1499
- '.dsh-rw-action{display:inline-flex;align-items:center;justify-content:center;width:28px;height:28px;flex-shrink:0;border:0;border-radius:5px;background:transparent;color:var(--dsw-alias-label-secondary,#929298);cursor:pointer}',
1571
+ '.dsh-rw-action{display:inline-flex;align-items:center;justify-content:center;width:28px;height:28px;flex-shrink:0;border:0;border-radius:var(--dsw-radius-sm,5px);background:transparent;color:var(--dsw-alias-label-secondary,#929298);cursor:pointer}',
1500
1572
  '.dsh-rw-action:hover:not(:disabled),.dsh-rw-action[aria-pressed=true]{background:var(--dsw-alias-interactive-bg-hover,rgba(128,128,128,.12));color:var(--dsw-alias-label-primary,#e4e4e7)}',
1501
1573
  '.dsh-rw-action:focus-visible{outline:2px solid var(--dsw-alias-button-primary-fill,#2563eb);outline-offset:-2px}',
1502
1574
  '.dsh-rw-action:disabled{opacity:.4;cursor:default}',
1575
+ '.dsh-rw-select{display:inline-flex;align-items:center;justify-content:space-between;gap:6px;min-width:0;max-width:100%;box-sizing:border-box;border:0;border-radius:var(--dsw-radius-md,8px);background:var(--dsw-alias-bg-module-platform,rgba(128,128,128,.12));color:var(--dsw-alias-label-primary,#e4e4e7);font:inherit;line-height:1.35;cursor:pointer;text-align:left;transition:background .12s ease}.dsh-rw-select:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover,rgba(128,128,128,.18))}.dsh-rw-select:focus-visible{outline:2px solid var(--dsw-alias-button-primary-fill,#2563eb);outline-offset:1px}.dsh-rw-select:disabled{opacity:.5;cursor:default}.dsh-rw-select-value{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dsh-rw-select-chevron{flex:none;color:var(--dsw-alias-label-secondary,#929298)}',
1576
+ '.dsh-rw-select-anchor{min-width:0;max-width:100%}.dsh-rw-search-scope>.dsh-rw-select-anchor{flex:1;min-width:0}.dsh-rw-search-scope>.dsh-rw-select-anchor>.dsh-rw-select{width:100%}.dsh-rw-settings-field>.dsh-rw-select-anchor,.dsh-rw-settings-field>select{justify-self:start;min-width:0}.dsh-rw-settings-field>.dsh-rw-check{justify-self:start}',
1577
+ '.dsh-rw-disclosure{width:100%;min-width:0}.dsh-rw-disclosure-head{display:flex;align-items:center;gap:8px;min-width:0;flex-wrap:wrap}.dsh-rw-disclosure-head[data-open]{margin-bottom:8px}.dsh-rw-disclosure-head>*:not(.dsh-rw-disclosure-row){flex-shrink:0;white-space:nowrap}.dsh-rw-disclosure-row{flex:1 1 auto;display:inline-flex;align-items:center;gap:6px;min-width:0;padding:0;border:0;background:transparent;color:inherit;font:inherit;text-align:left;cursor:pointer}.dsh-rw-disclosure-row:hover{opacity:.78}.dsh-rw-disclosure-row:focus-visible{outline:2px solid var(--dsw-alias-button-primary-fill,#2563eb);outline-offset:2px;border-radius:4px}.dsh-rw-disclosure-title{font-size:13px;font-weight:600;color:var(--dsw-alias-label-primary,#e4e4e7)}.dsh-rw-disclosure-label{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dsh-rw-disclosure-chevron,.dsh-rw-disclosure-icon{flex:none;color:var(--dsw-alias-label-tertiary,#929298)}.dsh-rw-disclosure-icon{display:inline-flex}',
1578
+ '.dsh-rw-check{display:inline-flex;align-items:center;gap:8px;font-size:12px;line-height:20px;color:inherit;cursor:pointer}.dsh-rw-check input{width:16px;height:16px;margin:0;flex:none;accent-color:var(--dsw-alias-button-primary-fill,#2563eb);cursor:inherit}',
1503
1579
  '.dsh-rw-tree-row:hover{background:var(--dsw-alias-interactive-bg-hover,rgba(128,128,128,.10))!important}',
1504
1580
  '.dsh-rw-tree-row[aria-selected=true]{background:color-mix(in srgb,var(--dsw-alias-button-primary-fill,#2563eb) 10%,transparent)!important}',
1505
1581
  '.dsh-rw-tree-row .dsh-rw-row-meta{opacity:0;transition:opacity .1s}',
@@ -1536,7 +1612,7 @@ window.__ModuleLoader__.load({
1536
1612
  '.dsh-rw-settings-tabs{display:flex;gap:20px;position:sticky;top:0;z-index:4;background:var(--dsw-alias-background-primary,#fff);border-bottom:1px solid var(--dsw-alias-border-primary,#ddd);padding-top:6px}',
1537
1613
  '.dsh-rw-settings-tabs [role=tab]{background:none;border:0;border-bottom:2px solid transparent;padding:8px 0 12px;cursor:pointer;font:inherit;font-size:12px;color:inherit;opacity:.6;white-space:nowrap}',
1538
1614
  '.dsh-rw-settings-tabs [aria-selected=true]{opacity:1;border-bottom-color:currentColor;font-weight:600}',
1539
- '.dsh-rw-settings-tabs button:focus-visible,.dsh-rw-settings-menu summary:focus-visible{outline:2px solid currentColor;outline-offset:3px}',
1615
+ '[data-rw-settings] button:focus-visible,.dsh-rw-settings-tabs button:focus-visible{outline:2px solid currentColor;outline-offset:3px}',
1540
1616
  '.dsh-rw-settings-panel{flex-direction:column;gap:16px;min-width:0}',
1541
1617
  '.dsh-rw-settings-card{min-width:0}',
1542
1618
  '.dsh-rw-settings-hosts{border:0!important;padding:0!important}',
@@ -1566,20 +1642,15 @@ window.__ModuleLoader__.load({
1566
1642
  '.dsh-rw-settings-menu-items button{border:0!important;text-align:left;background:transparent!important;padding:8px 10px!important}',
1567
1643
  '.dsh-rw-settings-menu-items button:hover{background:rgba(128,128,128,.1)!important}',
1568
1644
  '.dsh-rw-settings .dsh-rw-pill{border-color:transparent!important;background:rgba(128,128,128,.07);color:inherit!important;font-size:10px}',
1569
- '.dsh-rw-settings-advanced{display:flex;gap:6px;align-items:center;border:0!important;background:transparent!important;text-align:left;padding:8px 0!important}',
1570
1645
  '.dsh-rw-settings-editor{border:0!important;padding:0!important}',
1571
1646
  '.dsh-rw-settings-editor-heading{display:flex;gap:12px;align-items:center;padding:0 0 4px}',
1572
1647
  '.dsh-rw-settings-editor-heading>button{display:flex;gap:4px;align-items:center;border:0!important;padding:4px 0!important;font-size:11px;opacity:.7}',
1573
1648
  '.dsh-rw-settings-editor-actions{position:sticky;top:47px;z-index:3;display:flex;justify-content:flex-end;gap:8px;padding:10px 0 14px;border-bottom:1px solid;margin-bottom:16px}',
1574
1649
  '.dsh-rw-settings-field{display:grid;grid-template-columns:108px minmax(0,1fr);gap:12px;align-items:center;margin-bottom:14px}',
1575
1650
  '.dsh-rw-settings-field input:not([type=checkbox]),.dsh-rw-settings-field select{min-width:0;max-width:100%;box-sizing:border-box}',
1576
- '.dsh-rw-settings-field input[type=checkbox]{justify-self:start}',
1577
1651
  '.dsh-rw-settings-message{padding:9px 12px;border-radius:6px;background:rgba(128,128,128,.06);overflow-wrap:anywhere}',
1578
- '.dsh-rw-settings-section-heading{flex-wrap:wrap}.dsh-rw-settings-section-heading>.dsh-rw-section-btn{flex:1;min-width:150px;width:auto;line-height:1.6}.dsh-rw-settings-section-heading>.dsh-rw-btn{white-space:nowrap;flex-shrink:0}',
1579
1652
  '@media(max-width:600px){[data-shortcut-modal=settings]:has([data-rw-settings]){display:flex!important;flex-direction:column!important;overflow:hidden!important}[data-shortcut-modal=settings]:has([data-rw-settings])>nav{flex:0 0 auto!important;width:100%!important;max-width:none!important;padding:16px 16px 0!important;box-sizing:border-box}[data-shortcut-modal=settings]:has([data-rw-settings])>nav>div:first-child{padding:0!important;margin:0 0 10px!important;min-height:32px}[data-shortcut-modal=settings]:has([data-rw-settings])>nav>div:last-child{display:flex!important;flex-direction:row!important;overflow-x:auto!important;gap:4px;padding-bottom:8px}[data-shortcut-modal=settings]:has([data-rw-settings]) nav button{flex:0 0 auto!important;white-space:nowrap;padding:8px 10px!important}[data-shortcut-modal=settings]:has([data-rw-settings])>nav+div{flex:1!important;min-width:0!important;min-height:0!important;width:100%!important;overflow:auto}[data-shortcut-modal=settings]:has([data-rw-settings])>nav+div>div:first-child{position:absolute!important;top:16px;right:16px;padding:0!important;min-height:30px;z-index:1}[data-shortcut-modal=settings]:has([data-rw-settings])>nav+div>div:last-child{padding:0 16px 16px!important;min-width:0!important}[data-rw-settings]{box-sizing:border-box}.dsh-rw-settings{padding:16px 0!important}}',
1580
- '@media(max-width:600px){.dsh-rw-settings-section-heading>.dsh-rw-section-btn{flex-basis:100%}}',
1581
1653
  '@media(max-width:600px){.dsh-rw-settings{padding:16px;gap:14px}.dsh-rw-settings-tabs{gap:18px}.dsh-rw-settings-field{grid-template-columns:1fr;gap:5px}.dsh-rw-settings-editor [style*="margin-left"]{margin-left:0!important}.dsh-rw-settings-editor [style*="padding-left"]{padding-left:0!important}.dsh-rw-settings-editor-actions{flex-wrap:wrap;top:47px}.dsh-rw-settings-panel>div{min-width:0}.dsh-rw-settings-panel [style*="min-width: 260px"]{min-width:0!important}}',
1582
- '.dsh-rw-section-btn{width:100%;text-align:left;display:flex;align-items:center;gap:8px;background:transparent;border:none;cursor:pointer;padding:0;color:inherit}',
1583
1654
  '@keyframes dsh-rw-in{from{opacity:0;transform:translateY(6px) scale(.98)}to{opacity:1;transform:none}}',
1584
1655
  '.dsh-rw-modal-panel{animation:dsh-rw-in .14s ease-out}',
1585
1656
  ].join('')
@@ -1671,7 +1742,7 @@ window.__ModuleLoader__.load({
1671
1742
  },
1672
1743
  React.createElement('div', {
1673
1744
  className: 'dsh-rw-modal-panel',
1674
- style: { background: v('--dsw-alias-bg-overlay', '#1e1e1e'), border: '1px solid ' + T.borderStrong, borderRadius: 10, padding: 14, width: 'min(420px, 92vw)', display: 'flex', flexDirection: 'column', gap: 10, boxShadow: '0 12px 40px rgba(0,0,0,0.4)' },
1745
+ style: { background: v('--dsw-alias-bg-layer-2', '#1e1e1e'), border: '1px solid ' + T.borderStrong, borderRadius: 10, padding: 14, width: 'min(420px, 92vw)', display: 'flex', flexDirection: 'column', gap: 10, boxShadow: '0 12px 40px rgba(0,0,0,0.4)' },
1675
1746
  onClick: (e) => e.stopPropagation(),
1676
1747
  },
1677
1748
  React.createElement('div', { style: { fontSize: 13, fontWeight: 600, color: T.label } }, title),
@@ -1825,9 +1896,80 @@ window.__ModuleLoader__.load({
1825
1896
  observer.observe(document.body, { childList: true, subtree: true }); sync()
1826
1897
  return () => { observer.disconnect(); for (const button of marked) button.removeAttribute('data-rw-settings-legacy-icon') }
1827
1898
  }
1828
- function discoveredProbeTargets(hosts, machines) {
1829
- return (hosts || []).filter(host => !machines.some(machine => machine.useSshConfig && machine.host === String(host.alias || host.host))).map(host => ({ key: 'ssh:' + String(host.alias || host.host), body: { host: String(host.alias || host.host), port: Number(host.port) || 22, username: host.user || '', useSshConfig: true }, fingerprint: host }))
1899
+ // A slow probe uses the server's configured connectTimeoutMs; the client
1900
+ // never overrides it. Only a genuine timeout may be retried (never exit -1).
1901
+ const isProbeTimeout = (error) => /\bETIMEDOUT\b|\btimed[\s-]?out\b|\btimeout\b/i.test(String((error && error.message) || error || ''))
1902
+ // dsh-remote-fix4: identity, not alias, is what a probe may dial once, and
1903
+ // what a list row may show once. `dogyun`, `dg` and `dogyun.up2mountain.top`
1904
+ // are one machine; showing or probing them three times was how the same
1905
+ // server came out green, red and green in one sweep.
1906
+ const identityKeyOf = (host, port, username) => String(host || '').trim().toLowerCase() + '|' + (Number(port) || 22) + '|' + String(username || '').trim()
1907
+ /** Resolved identity of a ~/.ssh/config entry — the alias is only a name. */
1908
+ const hostIdentityKey = (h) => identityKeyOf(h && (h.hostName || h.alias || h.host), h && h.port, h && h.user)
1909
+ /** A discovered alias may share a probe only when its effective SSH
1910
+ * connection settings match, not merely when HostName/User/Port match. */
1911
+ const discoveredConfigKey = (h) => JSON.stringify([hostIdentityKey(h), String((h && h.identityFile) || ''), String((h && h.proxyJump) || ''), String((h && h.proxyCommand) || '')])
1912
+ /** Resolved identity of a saved machine (registry values may be stale). */
1913
+ const machineIdentityKey = (m) => identityKeyOf((m && m.sshConfigResolved && m.sshConfigResolved.host) || (m && m.host), (m && m.sshConfigResolved && m.sshConfigResolved.port) || (m && m.port), (m && m.sshConfigResolved && m.sshConfigResolved.username) || (m && m.username))
1914
+ /** Effective SSH settings of a saved alias, in the same key shape as a
1915
+ * discovered entry. Missing metadata never becomes an endpoint fallback. */
1916
+ const machineConfigKey = (m) => {
1917
+ const r = m && m.sshConfigResolved
1918
+ if (!r || !r.matched) return ''
1919
+ return discoveredConfigKey({ hostName: r.host, port: r.port, user: r.username,
1920
+ identityFile: r.identityFile, proxyJump: r.proxyJump, proxyCommand: r.proxyCommand })
1830
1921
  }
1922
+ /** Git-only hosts: SSH works, but there is no shell and no workspace. */
1923
+ const isGitHost = (value) => /(^|\.)github\.com$/i.test(String(value || '').trim())
1924
+ // Saved GitHub rows remain manageable, but a known shell-less endpoint is
1925
+ // not probed as if it were a remote workspace host.
1926
+ const shouldProbeMachine = (m) => !isGitHost(m && m.host) && !isGitHost(m && m.sshConfigResolved && m.sshConfigResolved.host)
1927
+ /**
1928
+ * One entry per resolved identity, preferring the block's canonical name
1929
+ * (the alias that equals HostName) over a short alias.
1930
+ */
1931
+ function dedupeHostEntries(hosts) {
1932
+ const byIdentity = new Map()
1933
+ for (const host of hosts || []) {
1934
+ const name = String((host && (host.alias || host.host)) || '')
1935
+ if (isGitHost(name) || isGitHost(host && host.hostName) || isGitHost(host && host.host)) continue
1936
+ const key = discoveredConfigKey(host)
1937
+ const current = byIdentity.get(key)
1938
+ if (!current) { byIdentity.set(key, host); continue }
1939
+ const currentName = String(current.alias || current.host || '')
1940
+ const canonical = String((host && host.hostName) || '')
1941
+ if (currentName !== String(current.hostName || '') && name === canonical) byIdentity.set(key, host)
1942
+ }
1943
+ return [...byIdentity.values()]
1944
+ }
1945
+
1946
+ /** Saved records keep their own management and probe identity. Only a
1947
+ * resolved SSH identity or an exact alias may suppress a discovered row. */
1948
+ function savedSshIdentitySets(machines) {
1949
+ const resolvedIdentities = new Set(), aliases = new Set()
1950
+ for (const m of machines || []) {
1951
+ if (m && m.sshConfigResolved && m.sshConfigResolved.matched) resolvedIdentities.add(machineConfigKey(m))
1952
+ if (m && m.useSshConfig && m.host) aliases.add(String(m.host))
1953
+ }
1954
+ return { resolvedIdentities, aliases }
1955
+ }
1956
+ function dedupeDiscoveredForSaved(hosts, machines) {
1957
+ const { resolvedIdentities, aliases } = savedSshIdentitySets(machines)
1958
+ const suppressed = new Set(resolvedIdentities)
1959
+ // Resolve an exact saved alias through the discovered config itself. This
1960
+ // suppresses the whole alias group before canonical-name selection, so a
1961
+ // saved short alias cannot reappear under its full HostName sibling.
1962
+ for (const h of hosts || []) {
1963
+ const alias = String((h && (h.alias || h.host)) || '')
1964
+ if (aliases.has(alias)) suppressed.add(discoveredConfigKey(h))
1965
+ }
1966
+ return dedupeHostEntries(hosts).filter((h) => !suppressed.has(discoveredConfigKey(h)))
1967
+ }
1968
+ // dsh-remote-fix4: the old discoveredProbeTargets() built one probe target
1969
+ // per ~/.ssh/config alias and only filtered exact-name duplicates. The sweep
1970
+ // now derives its targets from the deduped lists inside each component, so
1971
+ // keeping a second, differently-deduped builder here would invite the two to
1972
+ // drift apart.
1831
1973
  function RemoteWorkspacePage() {
1832
1974
  const settingsId = React.useId()
1833
1975
  const [settingsTab, setSettingsTab] = React.useState('hosts')
@@ -1841,7 +1983,14 @@ window.__ModuleLoader__.load({
1841
1983
  const formBaseline = React.useRef(settingsEditorDraft?.baseline || null)
1842
1984
  const probeRevision = React.useRef(0)
1843
1985
  const [machines, setMachines] = React.useState([])
1986
+ // Which machine the pool is on: the forwards form defaults its host select
1987
+ // to it, marks it as 当前, and uses it to tell the user when a newly added
1988
+ // forward belongs to a different host.
1989
+ const [currentId, setCurrentId] = React.useState('')
1844
1990
  const [hostsLoaded, setHostsLoaded] = React.useState(false)
1991
+ // The machine editor also serves NEW records (adopting a ~/.ssh/config
1992
+ // host or a manual machine), so it cannot be keyed on `form.id`.
1993
+ const [formOpen, setFormOpen] = React.useState(() => !!settingsEditorDraft)
1845
1994
  const [form, setForm] = React.useState(() => settingsEditorDraft?.form || {
1846
1995
  name: '', host: '', port: '22', username: 'root', password: '', privateKeyPath: '',
1847
1996
  passphrase: '', workspace: '', hostKeyMode: '', useAgent: false, keyboardInteractive: false,
@@ -1855,8 +2004,8 @@ window.__ModuleLoader__.load({
1855
2004
  // between "the plugin remembered my password" and "the plugin lost it".
1856
2005
  passwordSet: false, passphraseSet: false, proxyPasswordSet: false,
1857
2006
  })
1858
- React.useEffect(() => { if (form.id) document.getElementById(settingsId + '-field-n')?.focus?.() }, [form.id])
1859
- const formDirty = !!form.id && formBaseline.current !== null && JSON.stringify(form) !== formBaseline.current
2007
+ React.useEffect(() => { if (formOpen) document.getElementById(settingsId + '-field-n')?.focus?.() }, [formOpen])
2008
+ const formDirty = formOpen && formBaseline.current !== null && JSON.stringify(form) !== formBaseline.current
1860
2009
  React.useEffect(() => {
1861
2010
  settingsEditorDraft = formDirty ? { form, baseline: formBaseline.current } : null
1862
2011
  }, [form, formDirty])
@@ -1865,7 +2014,9 @@ window.__ModuleLoader__.load({
1865
2014
  const [err, setErr] = React.useState('')
1866
2015
  const [tst, setTst] = React.useState('') // idle | testing | ok | failing
1867
2016
  const [forwards, setForwards] = React.useState([])
1868
- const [fwdForm, setFwdForm] = React.useState({ listenPort: '', targetHost: '127.0.0.1', targetPort: '', direction: 'local', autoStart: false })
2017
+ const [fwdForm, setFwdForm] = React.useState({ listenPort: '', targetHost: '127.0.0.1', targetPort: '', direction: 'local', autoStart: false, machineId: '' })
2018
+ // Which saved definition the form is editing ('' = the form adds a new one).
2019
+ const [fwdEditId, setFwdEditId] = React.useState('')
1869
2020
  const [auditLines, setAuditLines] = React.useState([])
1870
2021
  // The audit LOG FILE on the host machine: its path plus the outcome of the last
1871
2022
  // 打开/显示 attempt. The browser cannot open a file that lives on the host, so
@@ -1877,6 +2028,14 @@ window.__ModuleLoader__.load({
1877
2028
  // push the update/audit cards far down the page for a feature most sessions
1878
2029
  // never touch.
1879
2030
  const [fwdOpen, setFwdOpen] = React.useState(false)
2031
+ // id → true while a start/stop request is in flight; the row shows a
2032
+ // pending label and cannot be clicked twice (a second click used to race
2033
+ // the first one for the same listen port).
2034
+ const [fwdBusy, setFwdBusy] = React.useState({})
2035
+ // First-time explanation for 自动重连. `fwdNotice.target` is either
2036
+ // {kind:'row', id} or {kind:'form'} (the add-forward form's checkbox).
2037
+ const [fwdNotice, setFwdNotice] = React.useState(null)
2038
+ const [fwdNoticeDontShow, setFwdNoticeDontShow] = React.useState(false)
1880
2039
  const [auditOpen, setAuditOpen] = React.useState(false)
1881
2040
  // Issue #96: workspace cleanup on Web/Desktop (the TUI's machine-menu
1882
2041
  // cleanup page has an in-process API; here it is these two routes).
@@ -2022,7 +2181,7 @@ window.__ModuleLoader__.load({
2022
2181
  }
2023
2182
 
2024
2183
  const refresh = () => api('GET', '/dsh-remote/machines').then((r) => {
2025
- setMachines(r.machines || []); setHostsLoaded(true)
2184
+ setMachines(r.machines || []); setCurrentId(String((r && r.currentId) || '')); setHostsLoaded(true)
2026
2185
  })
2027
2186
  React.useEffect(() => { refresh().catch(error => setErr(String(error.message || error))) }, [])
2028
2187
 
@@ -2042,6 +2201,15 @@ window.__ModuleLoader__.load({
2042
2201
  }
2043
2202
  }, [])
2044
2203
 
2204
+ React.useEffect(() => {
2205
+ setFwdForm((prev) => {
2206
+ if (!machines.length) return prev.machineId ? { ...prev, machineId: '' } : prev
2207
+ if (prev.machineId && machines.some((m) => m.id === prev.machineId)) return prev
2208
+ const next = machines.some((m) => m.id === currentId) ? currentId : machines[0].id
2209
+ return next === prev.machineId ? prev : { ...prev, machineId: next }
2210
+ })
2211
+ }, [machines, currentId])
2212
+
2045
2213
  // ── update state ────────────────────────────────────────────────────────
2046
2214
  const [upd, setUpd] = React.useState(null) // { current, latest, updateAvailable, updateMode, updatedMarker }
2047
2215
  const [updBusy, setUpdBusy] = React.useState(false)
@@ -2151,7 +2319,8 @@ window.__ModuleLoader__.load({
2151
2319
  }
2152
2320
 
2153
2321
  const setF = (k) => (ev) => { probeRevision.current++; setTst(''); setForm({ ...form, [k]: ev.target.value }) }
2154
- const setFb = (k) => (ev) => { probeRevision.current++; setTst(''); setForm({ ...form, [k]: ev.target.checked }) }
2322
+ const setV = (k) => (value) => { probeRevision.current++; setTst(''); setForm({ ...form, [k]: value }) }
2323
+ const setB = (k) => (checked) => { probeRevision.current++; setTst(''); setForm({ ...form, [k]: checked === true }) }
2155
2324
  // Issue #125: attach rows relay WHY a tunnel is a fresh spawn (or that it
2156
2325
  // reuses the resident instance). Declared as a table so the i18n dead-key
2157
2326
  // guard sees each status string referenced.
@@ -2187,6 +2356,7 @@ window.__ModuleLoader__.load({
2187
2356
  }
2188
2357
  formBaseline.current = JSON.stringify(next)
2189
2358
  setForm(next)
2359
+ setFormOpen(true)
2190
2360
  // 编辑时若该机器用了高级配置(私钥/agent/跳板/钥匙串/系统 OpenSSH 后端),自动展开折叠区
2191
2361
  setAdvOpen(!!(m.privateKeyPath || m.useAgent || m.keyboardInteractive || (m.proxy && m.proxy.host) || m.backend === 'openssh' || m.webAttachCommand || m.webAttachDiscoverCommand || (m.credentialBackend && m.credentialBackend !== 'plain')))
2192
2362
  }
@@ -2200,9 +2370,13 @@ window.__ModuleLoader__.load({
2200
2370
  probeRevision.current++; settingsEditorDraft = null; formBaseline.current = null
2201
2371
  const focusId = settingsId + '-actions-' + form.id
2202
2372
  clearForm(); setErr(''); setMsg(''); setTst(''); setAdvOpen(false)
2373
+ setProbeGeneration(value => value + 1)
2203
2374
  window.setTimeout(() => document.getElementById(focusId)?.focus?.(), 0)
2204
2375
  }
2205
- const clearForm = () => setForm({ name: '', host: '', port: '22', username: 'root', password: '', privateKeyPath: '', passphrase: '', workspace: '', hostKeyMode: '', useAgent: false, keyboardInteractive: false, encryptPassword: false, proxyHost: '', proxyPort: '22', proxyUser: '', proxyPassword: '', proxyKey: '', backend: 'native', sshBinary: '', webAttachCommand: '', webAttachDiscoverCommand: '', id: '', useSshConfig: false, passwordSet: false, passphraseSet: false, proxyPasswordSet: false })
2376
+ const clearForm = () => {
2377
+ setFormOpen(false)
2378
+ setForm({ name: '', host: '', port: '22', username: 'root', password: '', privateKeyPath: '', passphrase: '', workspace: '', hostKeyMode: '', useAgent: false, keyboardInteractive: false, encryptPassword: false, proxyHost: '', proxyPort: '22', proxyUser: '', proxyPassword: '', proxyKey: '', backend: 'native', sshBinary: '', webAttachCommand: '', webAttachDiscoverCommand: '', id: '', useSshConfig: false, passwordSet: false, passphraseSet: false, proxyPasswordSet: false })
2379
+ }
2206
2380
  const save = (action) => {
2207
2381
  if (busy) return
2208
2382
  probeRevision.current++
@@ -2262,6 +2436,9 @@ window.__ModuleLoader__.load({
2262
2436
  // say so, or the user cannot tell their workspaces came along.
2263
2437
  else if (r && r.reboundMirrors) setMsg(tr('settings.saved') + ' — ' + tr('settings.rebound', { n: r.reboundMirrors }))
2264
2438
  else setMsg(form.id ? tr('settings.saved') : tr('settings.added'))
2439
+ // The record is saved, but the LIVE pool could not be re-pointed at
2440
+ // the new address — say so, or the next 启动 still dials the old host.
2441
+ if (r && r.poolWarning) setErr(tr('settings.poolRepointFailed', { msg: r.poolWarning }))
2265
2442
  setProbeGeneration(value => value + 1)
2266
2443
  }).catch((e) => setErr(String((e && e.message) || e))).finally(() => setBusy(false))
2267
2444
  }
@@ -2271,10 +2448,57 @@ window.__ModuleLoader__.load({
2271
2448
  // Every visible host is tested once on entry/config changes; at most three
2272
2449
  // probes run together. Leaving the page cancels queued work and stale results.
2273
2450
  const [probeGeneration, setProbeGeneration] = React.useState(0)
2274
- const probeTargets = [
2275
- ...discoveredProbeTargets(sshHosts, machines),
2276
- ...machines.map(machine => ({ key: 'machine:' + machine.id, body: { id: machine.id, host: machine.host, port: machine.port, username: machine.username, useSshConfig: !!machine.useSshConfig }, fingerprint: machine })),
2277
- ]
2451
+ // dsh-remote-fix5: derivation hoisted - the probe queue below reads
2452
+ // these lists, so declaring them afterwards is a TDZ crash at render.
2453
+ //
2454
+ // Saved records are NEVER collapsed: the same endpoint can intentionally
2455
+ // use different credentials, backends or proxies. Only discovered rows
2456
+ // are deduped, and explicit saved records (including GitHub) stay visible.
2457
+ const uniqueMachines = machines
2458
+ const discovered = dedupeDiscoveredForSaved(sshHosts || [], machines)
2459
+
2460
+ // A discovered ~/.ssh/config entry is not a registry record yet; the menu
2461
+ // edits it through the SAME machine form, prefilled as an alias.
2462
+ const discoveredMachine = (h) => {
2463
+ const alias = String(h.alias || h.host)
2464
+ return {
2465
+ name: alias, host: alias, port: Number(h.port) || 22, username: h.user || '',
2466
+ useSshConfig: true, backend: 'openssh',
2467
+ }
2468
+ }
2469
+
2470
+ // Open the shared host menu ATTACHED to the `...` button that was pressed.
2471
+ //
2472
+ // DSH 0.2.2-alpha.2 replaced `getAnchorRect` with CSS anchors
2473
+ // (`anchorRef` / `anchorPoint`). An older host ignores the new props, a
2474
+ // newer host ignores the old one, so pass BOTH: before the refactor the
2475
+ // rect was the only way to anchor a body-portaled menu to a host-owned
2476
+ // trigger, and after it the ref is. Passing only the rect (the old code)
2477
+ // left the menu unattached on a current host.
2478
+ const openHostMenu = (event, key, machine, discovered) => {
2479
+ const el = event.currentTarget
2480
+ setSettingsMenu({
2481
+ key, machine, discovered: !!discovered, el,
2482
+ anchorRef: { current: el },
2483
+ getAnchorRect: () => el.getBoundingClientRect(),
2484
+ })
2485
+ }
2486
+
2487
+ // Keep row order stable while connectivity results arrive.
2488
+ const sortedMachines = [...uniqueMachines].sort((a, b) => String(a.name || a.host).localeCompare(String(b.name || b.host)))
2489
+ // Every saved machine id gets its own probe (credentials and backend are
2490
+ // record-specific); each discovered effective config gets at most one.
2491
+ const probeTargets = []
2492
+ for (const machine of uniqueMachines) {
2493
+ if (!shouldProbeMachine(machine)) continue
2494
+ const identity = machineIdentityKey(machine)
2495
+ probeTargets.push({ key: 'machine:' + machine.id, identity, body: { id: machine.id, host: machine.host, port: machine.port, username: machine.username, useSshConfig: !!machine.useSshConfig }, fingerprint: machine })
2496
+ }
2497
+ for (const host of discovered) {
2498
+ const identity = discoveredConfigKey(host)
2499
+ const alias = String(host.alias || host.host)
2500
+ probeTargets.push({ key: 'ssh:' + alias, identity, body: { host: alias, port: Number(host.port) || 22, username: host.user || '', useSshConfig: true }, fingerprint: host })
2501
+ }
2278
2502
  probeTargets.sort((a, b) => a.key.localeCompare(b.key))
2279
2503
  const probeSignature = JSON.stringify(probeTargets.map(target => ({ ...target, fingerprint: target.fingerprint && { ...target.fingerprint, connected: undefined, lastConnectedAt: undefined, latencyMs: undefined, recentWorkspaces: undefined, workspace: undefined } })))
2280
2504
  React.useEffect(() => {
@@ -2286,7 +2510,21 @@ window.__ModuleLoader__.load({
2286
2510
  while (queue.length && !controller.signal.aborted) {
2287
2511
  const target = queue.shift()
2288
2512
  try {
2289
- const result = await api('POST', '/dsh-remote/test-connect', { ...target.body, connectTimeoutMs: 5000 }, controller.signal)
2513
+ // Omitting connectTimeoutMs lets the server use its real config.
2514
+ // The route reports failures as 200 + {ok:false,error}, so one
2515
+ // loop handles both throw and payload forms, at most two attempts.
2516
+ const probeBody = target.body
2517
+ let result
2518
+ for (let attempt = 1; attempt <= 2; attempt++) {
2519
+ try {
2520
+ result = await api('POST', '/dsh-remote/test-connect', probeBody, controller.signal)
2521
+ } catch (error) {
2522
+ if (controller.signal.aborted || attempt === 2 || !isProbeTimeout(error)) throw error
2523
+ continue
2524
+ }
2525
+ if (attempt < 2 && !controller.signal.aborted && result && result.ok === false && isProbeTimeout(result.error)) continue
2526
+ break
2527
+ }
2290
2528
  if (!controller.signal.aborted) setRow(target.key, { ok: !!result?.ok, latencyMs: result?.latencyMs, text: result?.ok ? '' : result?.error || tr('settings.connFail') })
2291
2529
  } catch (error) {
2292
2530
  if (!controller.signal.aborted) setRow(target.key, { ok: false, text: String(error.message || error) })
@@ -2294,51 +2532,181 @@ window.__ModuleLoader__.load({
2294
2532
  }
2295
2533
  }
2296
2534
  Promise.all(Array.from({ length: Math.min(3, queue.length) }, () => worker()))
2297
- return () => controller.abort()
2535
+ return () => {
2536
+ controller.abort()
2537
+ // Aborted rows must not remain visually pending forever. Completed
2538
+ // results stay; a new effect will rebuild its own pending queue.
2539
+ setRowState((prev) => Object.fromEntries(Object.entries(prev || {}).filter(([, value]) => !value || !value.pending)))
2540
+ }
2298
2541
  }, [probeSignature, probeGeneration, hostsLoaded, sshHosts === null])
2299
2542
  const refreshHosts = () => { setProbeGeneration(value => value + 1); refresh().catch(error => setErr(String(error.message || error))); loadSshHosts() }
2300
2543
 
2301
2544
  // ── forwards panel ────────────────────────────────────────────────────
2302
- const fwdAction = (action, id) => {
2303
- api('POST', '/dsh-remote/forwards', { action, id })
2304
- .then((r) => { setForwards(r.forwards || []); setErr(''); setMsg('') })
2305
- .catch((e) => setErr(String((e && e.message) || e)))
2545
+ const fwdAction = (action, id, extra) => {
2546
+ setFwdBusy((m) => ({ ...m, [id]: true }))
2547
+ // apiRaw, not api: a failed start still carries the CURRENT list (a
2548
+ // concurrent autoStart pass may have bound the port already), and the UI
2549
+ // must not keep showing 启动 for a tunnel that is listening.
2550
+ apiRaw('POST', '/dsh-remote/forwards', { action, id, ...(extra || {}) })
2551
+ .then(({ status, data }) => {
2552
+ const body = data || {}
2553
+ if (Array.isArray(body.forwards)) setForwards(body.forwards)
2554
+ if (status >= 400 || body.ok === false) {
2555
+ setErr(String(body.error || ('HTTP ' + status)))
2556
+ if (!Array.isArray(body.forwards)) refreshForwards()
2557
+ return
2558
+ }
2559
+ setErr('')
2560
+ setMsg('')
2561
+ })
2562
+ .catch((e) => { setErr(String((e && e.message) || e)); refreshForwards() })
2563
+ .finally(() => setFwdBusy((m) => {
2564
+ if (!m[id]) return m
2565
+ const next = { ...m }
2566
+ delete next[id]
2567
+ return next
2568
+ }))
2569
+ }
2570
+ // The two directions carry different risks, so they are explained (and
2571
+ // remembered) separately: dismissing the local notice must not silence
2572
+ // the reverse-listener warning.
2573
+ const fwdNoticeKey = (direction) => 'dsh-remote.fwd-auto-notice-' + (direction === 'reverse' ? 'reverse' : 'local') + '-v1'
2574
+ const fwdNoticeDismissed = (direction) => {
2575
+ try { return window.localStorage.getItem(fwdNoticeKey(direction)) === '1' } catch { return false }
2306
2576
  }
2577
+ const dismissFwdNotice = (direction) => {
2578
+ try { window.localStorage.setItem(fwdNoticeKey(direction), '1') } catch { /* private mode */ }
2579
+ }
2580
+ const applyFwdAutoStart = (target, value) => {
2581
+ if (target.kind === 'form') { setFwdForm((form) => ({ ...form, autoStart: !!value })); return }
2582
+ fwdAction('update', target.id, { autoStart: !!value })
2583
+ }
2584
+ // The semantics are not obvious on first use: explain once, with a
2585
+ // "不再提示" opt-out stored in the browser.
2586
+ const requestFwdAutoStart = (target, value, direction) => {
2587
+ if (!value) { applyFwdAutoStart(target, false); return }
2588
+ if (fwdNoticeDismissed(direction)) { applyFwdAutoStart(target, true); return }
2589
+ setFwdNoticeDontShow(false)
2590
+ setFwdNotice({ target, direction })
2591
+ }
2592
+ const confirmFwdNotice = () => {
2593
+ if (!fwdNotice) return
2594
+ if (fwdNoticeDontShow) dismissFwdNotice(fwdNotice.direction)
2595
+ applyFwdAutoStart(fwdNotice.target, true)
2596
+ setFwdNotice(null)
2597
+ }
2598
+ const resetFwdForm = () => setFwdForm((form) => ({ listenPort: '', targetHost: '127.0.0.1', targetPort: '', direction: 'local', autoStart: false, machineId: form.machineId }))
2599
+ const fwdFields = () => ({
2600
+ direction: fwdForm.direction,
2601
+ listenPort: Number(fwdForm.listenPort),
2602
+ targetHost: fwdForm.targetHost || '127.0.0.1',
2603
+ targetPort: Number(fwdForm.targetPort) || Number(fwdForm.listenPort),
2604
+ autoStart: !!fwdForm.autoStart,
2605
+ machineId: fwdForm.machineId,
2606
+ })
2607
+ const beginFwdEdit = (f) => {
2608
+ setFwdEditId(f.id); setErr(''); setMsg('')
2609
+ setFwdForm({
2610
+ listenPort: String(f.listenPort ?? ''), targetHost: String(f.targetHost || '127.0.0.1'),
2611
+ targetPort: String(f.targetPort ?? ''), direction: f.direction === 'reverse' ? 'reverse' : 'local',
2612
+ autoStart: !!f.autoStart, machineId: f.machineId || '',
2613
+ })
2614
+ setFwdOpen(true)
2615
+ // With several forwards the form sits below all rows; bring it into view
2616
+ // so the click visibly lands somewhere.
2617
+ window.setTimeout(() => {
2618
+ document.getElementById(settingsId + '-fwd-form')?.scrollIntoView?.({ block: 'nearest', behavior: 'smooth' })
2619
+ }, 0)
2620
+ }
2621
+ const cancelFwdEdit = () => { setFwdEditId(''); setErr(''); resetFwdForm() }
2307
2622
  const fwdDefine = () => {
2308
2623
  if (!fwdForm.listenPort) return
2309
- api('POST', '/dsh-remote/forwards', { action: 'define', listenPort: Number(fwdForm.listenPort), targetHost: fwdForm.targetHost || '127.0.0.1', targetPort: Number(fwdForm.targetPort) || Number(fwdForm.listenPort), direction: fwdForm.direction, autoStart: fwdForm.autoStart })
2310
- .then((r) => { setForwards(r.forwards || []); setFwdForm({ listenPort: '', targetHost: '127.0.0.1', targetPort: '', direction: 'local', autoStart: false }) })
2624
+ if (!fwdForm.machineId) { setErr(tr('settings.fwdHostNeeds')); return }
2625
+ const machineId = fwdForm.machineId
2626
+ api('POST', '/dsh-remote/forwards', { action: 'define', ...fwdFields() })
2627
+ .then((r) => {
2628
+ const added = r && r.forward
2629
+ // A running HOST half that predates this field ignores `machineId` and
2630
+ // tags the ACTIVE machine instead — the tunnel would silently belong to
2631
+ // the wrong host. Detect it, undo the definition and say what to do.
2632
+ if (added && added.machineId !== machineId) {
2633
+ api('POST', '/dsh-remote/forwards', { action: 'remove', id: added.id }).then(refreshForwards).catch(() => {})
2634
+ setErr(tr('settings.fwdHostStale'))
2635
+ return
2636
+ }
2637
+ setForwards(r.forwards || [])
2638
+ resetFwdForm()
2639
+ // Defining for a host that is not connected is legitimate (it becomes
2640
+ // startable once that host is), but the row gives no other clue — say
2641
+ // which host the tunnel now belongs to.
2642
+ if (added && added.machineId && added.machineId !== currentId) {
2643
+ const target = machines.find((m) => m.id === added.machineId)
2644
+ setMsg(tr('settings.fwdAddedOther', { name: (target && (target.name || target.host)) || added.machineId }))
2645
+ }
2646
+ })
2311
2647
  .catch((e) => setErr(String((e && e.message) || e)))
2312
2648
  }
2649
+ // Editing an EXISTING definition, including one that is running. A live
2650
+ // tunnel keeps its old bind until it is torn down, so the client stops it,
2651
+ // patches the record and starts it again — "adjust it and keep it running"
2652
+ // is what the button promises.
2653
+ const fwdSaveEdit = async () => {
2654
+ const id = fwdEditId
2655
+ const target = forwards.find((f) => f.id === id)
2656
+ if (!id || !target) { setFwdEditId(''); resetFwdForm(); return }
2657
+ if (!fwdForm.listenPort) return
2658
+ if (!fwdForm.machineId) { setErr(tr('settings.fwdHostNeeds')); return }
2659
+ const wasActive = !!target.active
2660
+ setFwdBusy((m) => ({ ...m, [id]: true })); setErr(''); setMsg('')
2661
+ const fields = fwdFields()
2662
+ try {
2663
+ if (wasActive) await api('POST', '/dsh-remote/forwards', { action: 'stop', id })
2664
+ const r = await api('POST', '/dsh-remote/forwards', { action: 'update', id, ...fields })
2665
+ const saved = r && r.forward
2666
+ // An older HOST half only knows `autoStart` and ignores the bind
2667
+ // fields — it would answer "ok" while nothing changed. Compare what it
2668
+ // stored with what was asked, put the tunnel back and say so.
2669
+ const applied = saved && saved.direction === fields.direction
2670
+ && saved.listenPort === fields.listenPort && saved.targetHost === fields.targetHost
2671
+ && saved.targetPort === fields.targetPort
2672
+ && (saved.machineId || null) === (fields.machineId || null)
2673
+ if (saved && !applied) {
2674
+ setErr(tr('settings.fwdUpdateStale'))
2675
+ refreshForwards()
2676
+ if (wasActive) api('POST', '/dsh-remote/forwards', { action: 'start', id }).catch(() => {})
2677
+ return
2678
+ }
2679
+ if (Array.isArray(r.forwards)) setForwards(r.forwards)
2680
+ setFwdEditId(''); resetFwdForm(); setMsg(tr('settings.fwdUpdated'))
2681
+ if (wasActive) {
2682
+ const s = await api('POST', '/dsh-remote/forwards', { action: 'start', id })
2683
+ if (Array.isArray(s.forwards)) setForwards(s.forwards)
2684
+ }
2685
+ } catch (e) {
2686
+ setErr(String((e && e.message) || e))
2687
+ refreshForwards()
2688
+ } finally {
2689
+ setFwdBusy((m) => { const next = { ...m }; delete next[id]; return next })
2690
+ }
2691
+ }
2313
2692
 
2314
2693
  const fieldNote = text => React.createElement('div', { className: 'dsh-rw-settings-field-note', style: { color: T.muted } }, text)
2315
2694
  const row = (label, ctrl, k) => {
2316
2695
  const id = ctrl.props.id || settingsId + '-field-' + k
2317
- if (ctrl.props.type === 'checkbox') return React.createElement('div', { key: k, className: 'dsh-rw-settings-field is-toggle' }, React.createElement('span', { 'aria-hidden': true }), React.createElement('label', { htmlFor: id, className: 'dsh-rw-settings-check' }, React.cloneElement(ctrl, { id }), label))
2696
+ if (ctrl.type === RwSelect) return React.createElement('div', { key: k, className: 'dsh-rw-settings-field' }, React.createElement('span', { style: { fontSize: 12, color: T.muted } }, label), React.cloneElement(ctrl, { id, label }))
2697
+ if (ctrl.type === RwCheckbox) return React.createElement('div', { key: k, className: 'dsh-rw-settings-field is-toggle' }, React.createElement('span', { 'aria-hidden': true }), React.cloneElement(ctrl, { id, label }))
2318
2698
  return React.createElement('div', { key: k, className: 'dsh-rw-settings-field' },
2319
2699
  React.createElement('label', { htmlFor: id, style: { fontSize: 12, color: T.muted } }, label),
2320
2700
  React.cloneElement(ctrl, { id }))
2321
2701
  }
2322
2702
  const pill = (cls, text) => React.createElement('span', { className: 'dsh-rw-pill' + (cls ? ' ' + cls : ''), style: { marginLeft: 4 } }, text)
2323
- const sectionToggle = (open, setOpen, title, extra) => React.createElement('div', { className: 'dsh-rw-settings-section-heading', style: { display: 'flex', alignItems: 'center', gap: 8, marginBottom: open ? 8 : 0 } },
2324
- React.createElement('button', {
2325
- type: 'button', className: 'dsh-rw-section-btn',
2326
- title: open ? tr('settings.sectionHide') : tr('settings.sectionShow'), 'aria-expanded': open,
2327
- onClick: () => setOpen(!open),
2328
- style: { fontSize: 13, fontWeight: 600 },
2329
- }, React.createElement('span', { style: { opacity: 0.7, width: 12 } }, open ? '▾' : '▸'), title),
2330
- extra || null,
2331
- )
2703
+ const sectionIcon = (Icon) => Icon ? React.createElement(Icon, { size: 14 }) : null
2704
+ const sectionToggle = (open, setOpen, title, extra, icon) => disclosureRow({ open, onToggle: () => setOpen(!open), title, icon, accessory: extra || null, titleClassName: 'dsh-rw-disclosure-title' })
2332
2705
 
2333
2706
  // Issue #73: hosts from ~/.ssh/config that are NOT saved yet — they are the
2334
2707
  // first thing the page shows, because that is the whole list a VSCode
2335
2708
  // Remote-SSH user expects. A saved alias machine hides its file entry (the row
2336
2709
  // below it is the same host, with the actions that belong to a saved machine).
2337
- const savedAliases = new Set(machines.filter((m) => m.useSshConfig).map((m) => String(m.host)))
2338
- const discovered = (sshHosts || []).filter((h) => !savedAliases.has(String(h.alias || h.host)))
2339
-
2340
- // Keep row order stable while connectivity results arrive.
2341
- const sortedMachines = [...machines].sort((a, b) => String(a.name || a.host).localeCompare(String(b.name || b.host)))
2342
2710
 
2343
2711
  // One filter box for BOTH halves of the list (ssh-config hosts + saved ones).
2344
2712
  const needle = hostFilter.trim().toLowerCase()
@@ -2355,11 +2723,30 @@ window.__ModuleLoader__.load({
2355
2723
  style: { color: pending ? T.muted : result.ok ? 'var(--dsw-alias-state-success-primary,#25845b)' : 'var(--dsw-alias-state-error-primary,#c44b4b)' },
2356
2724
  }, pending ? tr('settings.testing') : result.ok ? tr('settings.reachable') + (result.latencyMs != null ? ' · ' + result.latencyMs + ' ms' : '') : tr('settings.unreachable'))
2357
2725
  }
2358
- const rowResult = key => rowState[key]?.ok === false ? React.createElement('details', { className: 'dsh-rw-settings-probe-error', style: { fontSize: 11, color: T.muted, lineHeight: 1.6, marginTop: 3, overflowWrap: 'anywhere' } }, React.createElement('summary', { style: { cursor: 'pointer' } }, tr('settings.probeDetails')), React.createElement('div', { style: { paddingTop: 5 } }, rowState[key].text)) : null
2726
+ const rowResult = key => rowState[key]?.ok === false ? React.createElement(RwDetails, { className: 'dsh-rw-settings-probe-error', title: tr('settings.probeDetails') }, React.createElement('div', { style: { fontSize: 11, color: T.muted, lineHeight: 1.6, overflowWrap: 'anywhere', paddingTop: 2 } }, rowState[key].text)) : null
2359
2727
 
2360
2728
  return React.createElement('div',
2361
2729
  { className: 'dsh-rw-settings', 'data-rw-settings': true, 'aria-label': tr('settings.title'), style: { color: T.label } },
2362
2730
  confirmUi.node,
2731
+ fwdNotice ? React.createElement('div', {
2732
+ style: { position: 'fixed', inset: 0, background: 'rgba(0,0,0,0.45)', display: 'flex', alignItems: 'center', justifyContent: 'center', zIndex: 3000 },
2733
+ },
2734
+ React.createElement('div', {
2735
+ role: 'dialog', 'aria-modal': 'true',
2736
+ 'aria-label': tr(fwdNotice.direction === 'reverse' ? 'settings.fwdAutoNoticeTitleReverse' : 'settings.fwdAutoNoticeTitle'),
2737
+ className: 'dsh-rw-forward-notice',
2738
+ style: { width: 480, maxWidth: '92vw', background: T.bg, border: '1px solid ' + T.border, borderRadius: 12, padding: '18px 20px', boxShadow: '0 16px 48px rgba(0,0,0,0.35)', color: T.label },
2739
+ },
2740
+ React.createElement('div', { style: { fontSize: 15, fontWeight: 650, letterSpacing: '-0.01em', marginBottom: 10 } }, tr(fwdNotice.direction === 'reverse' ? 'settings.fwdAutoNoticeTitleReverse' : 'settings.fwdAutoNoticeTitle')),
2741
+ React.createElement('div', { style: { display: 'flex', flexDirection: 'column', gap: 8 } },
2742
+ tr(fwdNotice.direction === 'reverse' ? 'settings.fwdAutoNoticeBodyReverse' : 'settings.fwdAutoNoticeBody').split('\n\n').map((paragraph, index) => React.createElement('div', {
2743
+ key: index,
2744
+ style: { fontSize: 12.5, lineHeight: 1.6, color: index === 0 ? T.label : T.muted },
2745
+ }, paragraph))),
2746
+ React.createElement('div', { style: { marginTop: 16 } }, React.createElement(RwCheckbox, { checked: fwdNoticeDontShow, onChange: (next) => setFwdNoticeDontShow(next === true), label: tr('settings.fwdAutoNoticeDontShow') })),
2747
+ React.createElement('div', { style: { display: 'flex', gap: 8, justifyContent: 'flex-end', marginTop: 16 } },
2748
+ React.createElement('button', { type: 'button', className: 'dsh-rw-btn', style: { ...buttonS, padding: '4px 14px' }, onClick: () => setFwdNotice(null) }, tr('settings.fwdAutoNoticeCancel')),
2749
+ React.createElement('button', { type: 'button', className: 'dsh-rw-btn dsh-rw-primary', style: { ...primaryBtnS, padding: '4px 14px' }, onClick: confirmFwdNotice }, tr('settings.fwdAutoNoticeConfirm'))))) : null,
2363
2750
  React.createElement('div', { style: { fontSize: 16, fontWeight: 650, letterSpacing: '-0.01em' } }, tr('settings.pageTitle')),
2364
2751
  React.createElement('div', { style: { fontSize: 12, opacity: 0.8, lineHeight: 1.55 } },
2365
2752
  tr('settings.intro')),
@@ -2369,7 +2756,7 @@ window.__ModuleLoader__.load({
2369
2756
  msg ? React.createElement('div', { role: 'status', 'aria-live': 'polite', className: 'dsh-rw-settings-message', style: { color: T.muted, fontSize: 12, lineHeight: 1.5 } }, msg) : null,
2370
2757
  err ? React.createElement('div', { role: 'alert', className: 'dsh-rw-settings-message', style: { color: T.danger, fontSize: 13, lineHeight: 1.5 } }, err) : null,
2371
2758
  React.createElement('div', { id: settingsId + '-hosts', role: 'tabpanel', 'aria-labelledby': settingsId + '-tab-hosts', hidden: settingsTab !== 'hosts', className: 'dsh-rw-settings-panel', style: { display: settingsTab === 'hosts' ? 'flex' : 'none' } },
2372
- React.createElement('div', { className: 'dsh-rw-settings-card dsh-rw-settings-hosts', hidden: !!form.id || !!sshEditor, style: { ...boxS, display: form.id || sshEditor ? 'none' : undefined } },
2759
+ React.createElement('div', { className: 'dsh-rw-settings-card dsh-rw-settings-hosts', hidden: formOpen || !!sshEditor, style: { ...boxS, display: formOpen || sshEditor ? 'none' : undefined } },
2373
2760
  React.createElement('div', { style: { display: 'flex', alignItems: 'center', gap: 8, marginBottom: 6, flexWrap: 'wrap' } },
2374
2761
  React.createElement('div', { style: { fontSize: 13, fontWeight: 600 } }, tr('settings.pickHost')),
2375
2762
  React.createElement('span', { style: { fontSize: 11, opacity: 0.6 } }, tr('settings.hostListSource')),
@@ -2406,7 +2793,24 @@ window.__ModuleLoader__.load({
2406
2793
  React.createElement('div', { style: { flex: 1, fontSize: 13, minWidth: 180 } },
2407
2794
  React.createElement('div', { className: 'dsh-rw-settings-identity' }, React.createElement('span', { style: { fontWeight: 600 } }, alias), React.createElement('code', { style: { fontSize: 12, opacity: 0.75 } }, target), React.createElement('div', { className: 'dsh-rw-settings-host-flags' }, h.proxyJump ? pill('', tr('settings.badgeProxy')) : null, h.identityFile ? pill('', tr('settings.badgeKey')) : null)),
2408
2795
  rowResult(key)),
2409
- React.createElement('div', { className: 'dsh-rw-settings-host-actions' }, hostProbe(key), React.createElement('span', { className: 'dsh-rw-settings-menu-spacer', 'aria-hidden': true })))
2796
+ React.createElement('div', { className: 'dsh-rw-settings-host-actions' },
2797
+ hostProbe(key),
2798
+ // Same `...` entry as a saved machine, so the row does not
2799
+ // change shape the moment it is adopted. The menu only holds
2800
+ // 编辑 (there is no registry record to delete — the alias
2801
+ // lives in ~/.ssh/config).
2802
+ HostMenu ? React.createElement('button', {
2803
+ type: 'button', className: 'dsh-rw-action',
2804
+ title: tr('settings.adoptAliasHint', { alias }), 'aria-label': tr('settings.adoptAliasHint', { alias }),
2805
+ id: settingsId + '-actions-ssh-' + alias, 'aria-haspopup': 'menu',
2806
+ 'aria-expanded': settingsMenu?.key === key,
2807
+ onClick: event => openHostMenu(event, key, discoveredMachine(h), true),
2808
+ }, React.createElement(WorkbenchIcon, { name: 'more' }))
2809
+ : React.createElement('details', { className: 'dsh-rw-settings-menu' },
2810
+ React.createElement('summary', { 'aria-label': tr('settings.adoptAliasHint', { alias }) }, React.createElement(WorkbenchIcon, { name: 'more', size: 16 })),
2811
+ React.createElement('div', { className: 'dsh-rw-settings-menu-items', style: { background: T.bg, borderColor: T.border } },
2812
+ React.createElement('button', { type: 'button', className: 'dsh-rw-btn', style: buttonS, onClick: () => startEdit(discoveredMachine(h)) }, tr('settings.edit')))),
2813
+ React.createElement('span', { className: 'dsh-rw-settings-menu-spacer', 'aria-hidden': true })))
2410
2814
  })
2411
2815
  : (sshError
2412
2816
  ? React.createElement('div', { style: { fontSize: 11, color: T.danger, lineHeight: 1.6, marginBottom: 6, wordBreak: 'break-all' } },
@@ -2429,7 +2833,7 @@ window.__ModuleLoader__.load({
2429
2833
  rowResult('machine:' + m.id)),
2430
2834
  React.createElement('div', { className: 'dsh-rw-settings-host-actions' },
2431
2835
  hostProbe('machine:' + m.id),
2432
- HostMenu ? React.createElement('button', { type: 'button', className: 'dsh-rw-action', title: tr('settings.hostActions', { name: m.name || m.host }), 'aria-label': tr('settings.hostActions', { name: m.name || m.host }), id: settingsId + '-actions-' + m.id, 'aria-haspopup': 'menu', 'aria-expanded': settingsMenu?.machine.id === m.id, onClick: event => setSettingsMenu({ machine: m, anchor: event.currentTarget.getBoundingClientRect() }) }, React.createElement(WorkbenchIcon, { name: 'more' }))
2836
+ HostMenu ? React.createElement('button', { type: 'button', className: 'dsh-rw-action', title: tr('settings.hostActions', { name: m.name || m.host }), 'aria-label': tr('settings.hostActions', { name: m.name || m.host }), id: settingsId + '-actions-' + m.id, 'aria-haspopup': 'menu', 'aria-expanded': settingsMenu?.key === 'machine:' + m.id, onClick: event => openHostMenu(event, 'machine:' + m.id, m, false) }, HostEllipsisIcon ? React.createElement(HostEllipsisIcon, { size: 16 }) : React.createElement(WorkbenchIcon, { name: 'more' }))
2433
2837
  : React.createElement('details', { className: 'dsh-rw-settings-menu' },
2434
2838
  React.createElement('summary', { 'aria-label': tr('settings.hostActions', { name: m.name || m.host }) }, React.createElement(WorkbenchIcon, { name: 'more', size: 16 })),
2435
2839
  React.createElement('div', { className: 'dsh-rw-settings-menu-items', style: { background: T.bg, borderColor: T.border } },
@@ -2438,7 +2842,7 @@ window.__ModuleLoader__.load({
2438
2842
  !shownMachines.length && !shownDiscovered.length && !hostFilter ? React.createElement('div', { style: { fontSize: 12, color: T.muted } }, tr('settings.noMachines')) : null),
2439
2843
  sshEditor ? React.createElement('div', { className: 'dsh-rw-settings-editor', 'data-rw-ssh-editor': true },
2440
2844
  React.createElement('div', { className: 'dsh-rw-settings-editor-heading' },
2441
- React.createElement('button', { type: 'button', className: 'dsh-rw-btn', style: buttonS, disabled: sshEditorBusy, onClick: closeSshConfig }, React.createElement(WorkbenchIcon, { name: 'left', size: 14 }), tr('settings.backHosts')),
2845
+ React.createElement('button', { type: 'button', className: 'dsh-rw-btn', style: buttonS, disabled: sshEditorBusy, onClick: closeSshConfig }, React.createElement(Chevron, { dir: 'left', size: 14 }), tr('settings.backHosts')),
2442
2846
  React.createElement('div', null, React.createElement('strong', null, tr('settings.sshConfigEditorTitle')), React.createElement('div', { style: { fontSize: 11, color: T.muted, overflowWrap: 'anywhere' } }, sshEditor.file))),
2443
2847
  React.createElement('div', { className: 'dsh-rw-settings-editor-actions', style: { background: T.bg, borderColor: T.border } },
2444
2848
  React.createElement('button', { type: 'button', className: 'dsh-rw-btn', style: buttonS, disabled: sshEditorBusy, onClick: closeSshConfig }, tr('settings.cancelEdit')),
@@ -2447,10 +2851,10 @@ window.__ModuleLoader__.load({
2447
2851
  React.createElement('label', { htmlFor: settingsId + '-ssh-text', style: { fontSize: 12, color: T.muted } }, tr('settings.sshConfigEditorHint')),
2448
2852
  React.createElement('textarea', { id: settingsId + '-ssh-text', 'aria-label': tr('settings.sshConfigEditorTitle'), spellCheck: false, autoCapitalize: 'off', readOnly: sshEditorBusy, value: sshEditor.text, onChange: event => setSshEditor({ ...sshEditor, text: event.target.value }), onKeyDown: event => { if ((event.ctrlKey || event.metaKey) && event.key.toLowerCase() === 's') { event.preventDefault(); saveSshConfig() } }, style: { ...inputS, width: '100%', boxSizing: 'border-box', minHeight: 320, resize: 'vertical', fontFamily: 'ui-monospace, SFMono-Regular, Consolas, monospace', fontSize: 12, lineHeight: 1.7, whiteSpace: 'pre', tabSize: 2, marginTop: 8 } }),
2449
2853
  React.createElement('div', { role: 'status', style: { fontSize: 11, color: T.muted, marginTop: 6 } }, sshEditorDirty ? tr('settings.unsaved') : tr('settings.sshConfigClean'))) : null,
2450
- form.id ? React.createElement('div', { className: 'dsh-rw-settings-card dsh-rw-settings-editor', style: boxS },
2854
+ formOpen ? React.createElement('div', { className: 'dsh-rw-settings-card dsh-rw-settings-editor', style: boxS },
2451
2855
  React.createElement('div', { className: 'dsh-rw-settings-editor-heading' },
2452
- React.createElement('button', { type: 'button', className: 'dsh-rw-btn', style: buttonS, onClick: closeEditor, disabled: busy, 'aria-label': tr('settings.backHosts') }, React.createElement(WorkbenchIcon, { name: 'left', size: 14 }), tr('settings.backHosts')),
2453
- React.createElement('div', { style: { minWidth: 0, flex: 1 } }, React.createElement('strong', {}, form.name || form.host), React.createElement('div', { style: { color: formDirty ? T.warn : T.muted, fontSize: 11 } }, formDirty ? tr('settings.unsaved') : tr('settings.editMachine')))),
2856
+ React.createElement('button', { type: 'button', className: 'dsh-rw-btn', style: buttonS, onClick: closeEditor, disabled: busy, 'aria-label': tr('settings.backHosts') }, React.createElement(Chevron, { dir: 'left', size: 14 }), tr('settings.backHosts')),
2857
+ React.createElement('div', { style: { minWidth: 0, flex: 1 } }, React.createElement('strong', {}, form.name || form.host), React.createElement('div', { style: { color: formDirty ? T.warn : T.muted, fontSize: 11 } }, formDirty ? tr('settings.unsaved') : (form.id ? tr('settings.editMachine') : tr('settings.addMachine'))))),
2454
2858
  React.createElement('div', { className: 'dsh-rw-settings-editor-actions', style: { background: T.bg, borderColor: T.border } },
2455
2859
  React.createElement('button', { type: 'button', className: 'dsh-rw-btn', style: buttonS, onClick: closeEditor, disabled: busy }, tr('settings.cancelEdit')),
2456
2860
  React.createElement('button', { type: 'button', className: 'dsh-rw-btn', style: buttonS, onClick: testConn, disabled: busy || !form.host.trim() || tst === 'testing', title: form.host.trim() ? tr('settings.testHint') : tr('settings.testNeedsHost') }, tst === 'testing' ? tr('settings.testing') : tst === 'ok' ? tr('settings.testOk') : tr('settings.testConn')),
@@ -2458,7 +2862,7 @@ window.__ModuleLoader__.load({
2458
2862
  React.createElement(React.Fragment, null,
2459
2863
  row(tr('settings.name'), React.createElement('input', { className: 'dsh-rw-input', value: form.name, onChange: setF('name'), placeholder: tr('settings.name') + ' (e.g. build-server)', style: inputS }), 'n'),
2460
2864
  row(tr('settings.host'), React.createElement('input', { className: 'dsh-rw-input', value: form.host, onChange: setF('host'), placeholder: form.useSshConfig ? tr('settings.sshImport') + ' Host 别名' : 'IP or hostname', style: inputS }), 'h'),
2461
- row(tr('settings.useSshConfig'), React.createElement('input', { type: 'checkbox', checked: !!form.useSshConfig, onChange: setFb('useSshConfig') }), 'sshc'),
2865
+ row(tr('settings.useSshConfig'), React.createElement(RwCheckbox, { checked: !!form.useSshConfig, onChange: setB('useSshConfig') }), 'sshc'),
2462
2866
  form.useSshConfig ? fieldNote(tr('settings.useSshConfigHint')) : null,
2463
2867
  // Issue #50: a literal save also touches ~/.ssh/config (managed
2464
2868
  // block) — say so where the choice is made.
@@ -2503,20 +2907,13 @@ window.__ModuleLoader__.load({
2503
2907
  tr('settings.noCredentialHint'))
2504
2908
  : null,
2505
2909
  // 高级配置折叠开关
2506
- React.createElement('button', {
2507
- type: 'button',
2508
- className: 'dsh-rw-btn dsh-rw-settings-advanced', 'aria-expanded': advOpen,
2509
- onClick: () => setAdvOpen(!advOpen),
2510
- style: { ...buttonS, width: '100%', marginBottom: advOpen ? 10 : 0, color: advOpen ? T.primary : 'inherit', fontWeight: advOpen ? 600 : 400, borderStyle: 'dashed' },
2511
- }, React.createElement(WorkbenchIcon, { name: advOpen ? 'down' : 'right', size: 14 }), advOpen ? tr('settings.advCollapse') : tr('settings.advExpand')),
2910
+ React.createElement('div', { style: { marginBottom: advOpen ? 0 : 6 } }, disclosureRow({ open: advOpen, onToggle: () => setAdvOpen(!advOpen), title: advOpen ? tr('settings.advCollapse') : tr('settings.advExpand'), icon: sectionIcon(HostSlidersIcon) })),
2512
2911
  advOpen ? React.createElement('div', { key: 'adv', style: { paddingTop: 2 } },
2513
2912
  // Issue #51 — transport backend. Placed FIRST in the advanced block
2514
2913
  // because it changes what the fields below even mean: with the
2515
2914
  // system-OpenSSH backend, host/user/port/key all come from
2516
2915
  // ~/.ssh/config and only the machine name (an alias) matters.
2517
- row(tr('settings.backend'), React.createElement('select', { value: form.backend || 'native', onChange: setF('backend'), style: { ...inputS, maxWidth: 260 } },
2518
- React.createElement('option', { value: 'native' }, tr('settings.backendNative')),
2519
- React.createElement('option', { value: 'openssh' }, tr('settings.backendOpenssh'))), 'be'),
2916
+ row(tr('settings.backend'), React.createElement(RwSelect, { value: form.backend || 'native', options: [{ value: 'native', label: tr('settings.backendNative') }, { value: 'openssh', label: tr('settings.backendOpenssh') }], onChange: setV('backend'), label: tr('settings.backend'), style: { maxWidth: 260 } }), 'be'),
2520
2917
  (form.backend === 'openssh')
2521
2918
  ? React.createElement('div', { style: { fontSize: 11, opacity: 0.85, marginBottom: 8, marginLeft: LABEL_W + 12, lineHeight: 1.55 } },
2522
2919
  React.createElement('div', null, tr('settings.backendOpensshHint')),
@@ -2532,18 +2929,11 @@ window.__ModuleLoader__.load({
2532
2929
  form.passphraseSet
2533
2930
  ? React.createElement('div', { style: { marginLeft: LABEL_W + 12, marginBottom: 8, fontSize: 11, lineHeight: 1.5, color: T.muted } }, tr('settings.passphraseSavedHint'))
2534
2931
  : null,
2535
- row(tr('settings.hostKeyMode'), React.createElement('select', { value: form.hostKeyMode, onChange: setF('hostKeyMode'), style: { ...inputS, maxWidth: 220 } },
2536
- React.createElement('option', { value: '' }, tr('settings.hkDefault')),
2537
- React.createElement('option', { value: 'accept-new' }, tr('settings.hkAccept')),
2538
- React.createElement('option', { value: 'verify' }, tr('settings.hkVerify')),
2539
- React.createElement('option', { value: 'off' }, tr('settings.hkOff'))), 'hkm'),
2932
+ row(tr('settings.hostKeyMode'), React.createElement(RwSelect, { value: form.hostKeyMode || '', options: [{ value: '', label: tr('settings.hkDefault') }, { value: 'accept-new', label: tr('settings.hkAccept') }, { value: 'verify', label: tr('settings.hkVerify') }, { value: 'off', label: tr('settings.hkOff') }], onChange: setV('hostKeyMode'), label: tr('settings.hostKeyMode'), style: { maxWidth: 220 } }), 'hkm'),
2540
2933
  React.createElement('div', { style: { display: 'flex', gap: 16, paddingLeft: LABEL_W + 12, flexWrap: 'wrap', marginBottom: 8 } },
2541
- React.createElement('label', { style: { fontSize: 12, display: 'flex', gap: 4, alignItems: 'center' } },
2542
- React.createElement('input', { type: 'checkbox', checked: form.useAgent, onChange: setFb('useAgent') }), tr('settings.agent')),
2543
- React.createElement('label', { style: { fontSize: 12, display: 'flex', gap: 4, alignItems: 'center' } },
2544
- React.createElement('input', { type: 'checkbox', checked: form.keyboardInteractive, onChange: setFb('keyboardInteractive') }), tr('settings.keyboardInteractive')),
2545
- React.createElement('label', { style: { fontSize: 12, display: 'flex', gap: 4, alignItems: 'center' } },
2546
- React.createElement('input', { type: 'checkbox', checked: form.encryptPassword, onChange: setFb('encryptPassword') }), tr('settings.encryptPassword'))),
2934
+ React.createElement(RwCheckbox, { checked: form.useAgent, onChange: setB('useAgent'), label: tr('settings.agent') }),
2935
+ React.createElement(RwCheckbox, { checked: form.keyboardInteractive, onChange: setB('keyboardInteractive'), label: tr('settings.keyboardInteractive') }),
2936
+ React.createElement(RwCheckbox, { checked: form.encryptPassword, onChange: setB('encryptPassword'), label: tr('settings.encryptPassword') })),
2547
2937
  row(tr('settings.proxyHost'), React.createElement('input', { value: form.proxyHost, onChange: setF('proxyHost'), placeholder: 'Route through this host (optional)', style: inputS }), 'ph'),
2548
2938
  row(tr('settings.proxyPortUser'), React.createElement('div', { style: { display: 'flex', gap: 6, flex: 1, flexWrap: 'wrap' } },
2549
2939
  React.createElement('input', { value: form.proxyPort, onChange: setF('proxyPort'), placeholder: 'Port (22)', style: { ...inputS, minWidth: 90, maxWidth: 120 } }),
@@ -2565,7 +2955,7 @@ window.__ModuleLoader__.load({
2565
2955
  ) : null),
2566
2956
  React.createElement('div', { id: settingsId + '-tools', role: 'tabpanel', 'aria-labelledby': settingsId + '-tab-tools', hidden: settingsTab !== 'tools', className: 'dsh-rw-settings-panel', style: { display: settingsTab === 'tools' ? 'flex' : 'none' } },
2567
2957
  React.createElement('div', { style: boxS },
2568
- sectionToggle(webAttachOpen, setWebAttachOpen, tr('settings.webAttach')),
2958
+ sectionToggle(webAttachOpen, setWebAttachOpen, tr('settings.webAttach'), null, sectionIcon(HostGlobeIcon)),
2569
2959
  webAttachOpen ? React.createElement(React.Fragment, null,
2570
2960
  React.createElement('div', { style: { opacity: 0.65, fontSize: 11, lineHeight: 1.5, marginBottom: 6 } }, tr('settings.webAttachHint')),
2571
2961
  // The URL below carries a one-time login token. It stays on loopback,
@@ -2607,9 +2997,7 @@ window.__ModuleLoader__.load({
2607
2997
  disabled: !!webAttachBusy, onClick: () => webAttachAction('close', a.machineId, { stopRemote: true }) }, tr('settings.webAttachCloseStop'))
2608
2998
  : null)) : React.createElement('div', { style: { opacity: 0.6, fontSize: 12 } }, tr('settings.webAttachNone')),
2609
2999
  React.createElement('div', { style: { display: 'flex', gap: 6, alignItems: 'center', marginTop: 8, flexWrap: 'wrap' } },
2610
- React.createElement('select', { className: 'dsh-rw-input', value: webAttachMachine, onChange: (e) => setWebAttachMachine(e.target.value), style: { ...inputS, maxWidth: 200 } },
2611
- React.createElement('option', { value: '' }, tr('settings.webAttachMachine') + '…'),
2612
- machines.map((m) => React.createElement('option', { key: m.id, value: m.id }, `${m.name || m.host} (${m.username}@${m.host})`))),
3000
+ React.createElement(RwSelect, { value: webAttachMachine, options: [{ value: '', label: tr('settings.webAttachMachine') + '…' }, ...machines.map((m) => ({ value: m.id, label: `${m.name || m.host} (${m.username}@${m.host})` }))], onChange: (next) => setWebAttachMachine(next), label: tr('settings.webAttachMachine'), style: { maxWidth: 200 } }),
2613
3001
  React.createElement('button', {
2614
3002
  type: 'button', className: 'dsh-rw-btn dsh-rw-primary', style: primaryBtnS,
2615
3003
  disabled: !!webAttachBusy || !webAttachMachine,
@@ -2626,25 +3014,103 @@ window.__ModuleLoader__.load({
2626
3014
  ) : null,
2627
3015
  ),
2628
3016
  React.createElement('div', { style: boxS },
2629
- sectionToggle(fwdOpen, setFwdOpen, tr('settings.forwards')),
3017
+ sectionToggle(fwdOpen, setFwdOpen, tr('settings.forwards'), null, sectionIcon(HostForwardIcon)),
2630
3018
  fwdOpen ? React.createElement(React.Fragment, null,
2631
- forwards.length ? forwards.map((f) => React.createElement('div', { key: f.id, className: 'dsh-rw-row', style: { display: 'flex', gap: 8, alignItems: 'center', padding: '6px 0', fontSize: 12, fontFamily: 'monospace' } },
2632
- React.createElement('span', { style: { color: f.active ? T.ok : T.muted } }, f.active ? '●' : '○'),
2633
- React.createElement('span', { style: { flex: 1 } }, `${f.direction} 127.0.0.1:${f.listenPort} → ${f.targetHost}:${f.targetPort}${f.autoStart ? ' [auto]' : ''}`),
2634
- f.active
2635
- ? React.createElement('button', { type: 'button', className: 'dsh-rw-btn', style: { ...buttonS, padding: '2px 8px' }, onClick: () => fwdAction('stop', f.id) }, tr('settings.fwdStop'))
2636
- : React.createElement('button', { type: 'button', className: 'dsh-rw-btn', style: { ...buttonS, padding: '2px 8px' }, onClick: () => fwdAction('start', f.id) }, tr('settings.fwdStart')),
2637
- React.createElement('button', { type: 'button', className: 'dsh-rw-btn', style: { ...buttonS, padding: '2px 8px' }, onClick: () => fwdAction('remove', f.id) }, tr('settings.fwdRemove')))) : null,
2638
- React.createElement('div', { style: { display: 'flex', gap: 6, alignItems: 'center', marginTop: 6, flexWrap: 'wrap' } },
2639
- React.createElement('select', { className: 'dsh-rw-input', value: fwdForm.direction, onChange: (e) => setFwdForm({ ...fwdForm, direction: e.target.value }), style: { ...inputS, maxWidth: 110 } },
2640
- React.createElement('option', { value: 'local' }, tr('settings.fwdDirLocal')),
2641
- React.createElement('option', { value: 'reverse' }, tr('settings.fwdDirReverse'))),
2642
- React.createElement('input', { className: 'dsh-rw-input', value: fwdForm.listenPort, onChange: (e) => setFwdForm({ ...fwdForm, listenPort: e.target.value }), placeholder: tr('settings.fwdListen'), style: { ...inputS, maxWidth: 90 } }),
2643
- React.createElement('input', { className: 'dsh-rw-input', value: fwdForm.targetHost, onChange: (e) => setFwdForm({ ...fwdForm, targetHost: e.target.value }), placeholder: tr('settings.fwdTargetHost'), style: { ...inputS, maxWidth: 120 } }),
2644
- React.createElement('input', { className: 'dsh-rw-input', value: fwdForm.targetPort, onChange: (e) => setFwdForm({ ...fwdForm, targetPort: e.target.value }), placeholder: tr('settings.fwdTargetPort'), style: { ...inputS, maxWidth: 90 } }),
2645
- React.createElement('label', { style: { fontSize: 12, display: 'flex', gap: 4, alignItems: 'center' } },
2646
- React.createElement('input', { type: 'checkbox', checked: fwdForm.autoStart, onChange: (e) => setFwdForm({ ...fwdForm, autoStart: e.target.checked }) }), tr('settings.fwdAuto')),
2647
- React.createElement('button', { type: 'button', className: 'dsh-rw-btn dsh-rw-primary', style: primaryBtnS, onClick: fwdDefine, disabled: !fwdForm.listenPort, title: fwdForm.listenPort ? tr('settings.fwdAddHint') : tr('settings.fwdNeedsPort') }, tr('settings.fwdAdd'))),
3019
+ React.createElement('div', { style: { opacity: 0.65, fontSize: 11, lineHeight: 1.5, marginBottom: 8 } }, tr('settings.forwardsHint')),
3020
+ forwards.length ? forwards.map((f) => {
3021
+ const busy = !!fwdBusy[f.id]
3022
+ const editing = fwdEditId === f.id
3023
+ return React.createElement('div', {
3024
+ key: f.id, className: 'dsh-rw-row', 'data-fwd-editing': editing ? 'true' : undefined,
3025
+ 'aria-current': editing ? 'true' : undefined,
3026
+ style: {
3027
+ display: 'flex', gap: 8, rowGap: 4, alignItems: 'center', flexWrap: 'wrap', padding: '6px 8px', margin: '0 -8px', fontSize: 12, fontFamily: 'monospace',
3028
+ // The row the form below is editing must stay identifiable while
3029
+ // the user is typing in fields that hide the original values.
3030
+ borderRadius: 6, transition: 'background .12s ease, box-shadow .12s ease',
3031
+ background: editing ? T.bg2 : undefined,
3032
+ boxShadow: editing ? 'inset 3px 0 0 ' + T.primary : undefined,
3033
+ },
3034
+ },
3035
+ React.createElement('span', { style: { color: f.active ? T.ok : T.muted } }, f.active ? '●' : '○'),
3036
+ React.createElement('span', {
3037
+ title: f.direction === 'reverse' ? tr('settings.fwdDirReverse') : tr('settings.fwdDirLocal'),
3038
+ style: { flex: '0 0 auto', color: T.muted, opacity: 0.85 },
3039
+ }, f.direction === 'reverse' ? '-R' : '-L'),
3040
+ editing ? React.createElement('span', { style: { flex: '0 0 auto', fontSize: 10, fontWeight: 600, color: T.onPrimary, background: T.primary, borderRadius: 4, padding: '0 5px', whiteSpace: 'nowrap' } }, tr('settings.fwdEditingBadge')) : null,
3041
+ React.createElement('span', {
3042
+ title: tr(f.direction === 'reverse' ? 'settings.fwdReverseHint' : 'settings.fwdLocalHint'),
3043
+ style: { flex: 1 },
3044
+ }, `127.0.0.1:${f.listenPort} → ${f.targetHost}:${f.targetPort}`),
3045
+ f.needsReconsent ? React.createElement('span', {
3046
+ title: tr('settings.fwdLegacyHint'),
3047
+ style: { fontSize: 10, color: T.warn, border: '1px solid ' + T.border, borderRadius: 4, padding: '0 4px', whiteSpace: 'nowrap' },
3048
+ }, tr('settings.fwdLegacyBadge')) : null,
3049
+ React.createElement(RwCheckbox, { checked: !!f.autoStart, disabled: busy, title: tr('settings.fwdAutoHint'), label: tr('settings.fwdAuto'), onChange: (next) => requestFwdAutoStart({ kind: 'row', id: f.id }, next === true, f.direction) }),
3050
+ React.createElement('button', { type: 'button', className: 'dsh-rw-btn', 'data-testid': 'fwd-edit', style: { ...buttonS, padding: '2px 8px' }, disabled: busy, title: tr('settings.fwdEditHint'), onClick: () => beginFwdEdit(f) }, tr('settings.fwdEdit')),
3051
+ f.active
3052
+ ? React.createElement('button', { type: 'button', className: 'dsh-rw-btn', style: { ...buttonS, padding: '2px 8px' }, disabled: busy, onClick: () => fwdAction('stop', f.id) }, tr('settings.fwdStop'))
3053
+ : React.createElement('button', { type: 'button', className: 'dsh-rw-btn', style: { ...buttonS, padding: '2px 8px' }, disabled: busy, onClick: () => fwdAction('start', f.id) }, busy ? tr('settings.fwdStarting') : tr('settings.fwdStart')),
3054
+ React.createElement('button', { type: 'button', className: 'dsh-rw-btn', style: { ...buttonS, padding: '2px 8px' }, disabled: busy, onClick: () => fwdAction('remove', f.id) }, tr('settings.fwdRemove')))
3055
+ }) : null,
3056
+ React.createElement('div', {
3057
+ // Scroll anchor for 编辑: the form can sit below a long row list.
3058
+ id: settingsId + '-fwd-form',
3059
+ style: { display: 'flex', gap: 6, alignItems: 'center', marginTop: 8, flexWrap: 'wrap' },
3060
+ },
3061
+ React.createElement('div', {
3062
+ role: 'group', 'aria-label': tr('settings.forwards'),
3063
+ style: { display: 'flex', alignItems: 'stretch', flex: '0 0 auto', height: 30, border: '1px solid ' + T.border, borderRadius: T.radius, overflow: 'hidden' },
3064
+ },
3065
+ ['local', 'reverse'].map((value) => React.createElement('button', {
3066
+ key: value, type: 'button',
3067
+ 'aria-pressed': fwdForm.direction === value,
3068
+ onClick: () => setFwdForm({ ...fwdForm, direction: value }),
3069
+ style: {
3070
+ border: 'none', cursor: 'pointer', padding: '0 8px', fontSize: 11, whiteSpace: 'nowrap',
3071
+ background: fwdForm.direction === value ? T.primary : 'transparent',
3072
+ color: fwdForm.direction === value ? T.onPrimary : T.muted,
3073
+ },
3074
+ }, tr(value === 'local' ? 'settings.fwdSideLocal' : 'settings.fwdSideReverse')))),
3075
+ React.createElement('input', { className: 'dsh-rw-input', value: fwdForm.listenPort, onChange: (e) => setFwdForm({ ...fwdForm, listenPort: e.target.value }), placeholder: tr('settings.fwdListen'), style: { ...inputS, flex: '0 0 90px', width: 90, minWidth: 0, boxSizing: 'border-box', padding: '6px 8px' } }),
3076
+ React.createElement('span', { style: { opacity: 0.55, fontSize: 12, flex: '0 0 auto' } }, '→'),
3077
+ React.createElement('input', { className: 'dsh-rw-input', value: fwdForm.targetHost, onChange: (e) => setFwdForm({ ...fwdForm, targetHost: e.target.value }), placeholder: tr('settings.fwdTargetHost'), style: { ...inputS, flex: '1 1 100px', width: 'auto', minWidth: 90, maxWidth: 240, boxSizing: 'border-box', padding: '6px 8px' } }),
3078
+ React.createElement('span', { style: { opacity: 0.55, fontSize: 12, flex: '0 0 auto' } }, ':'),
3079
+ React.createElement('input', { className: 'dsh-rw-input', value: fwdForm.targetPort, onChange: (e) => setFwdForm({ ...fwdForm, targetPort: e.target.value }), placeholder: tr('settings.fwdTargetPort'), style: { ...inputS, flex: '0 0 72px', width: 72, minWidth: 0, boxSizing: 'border-box', padding: '6px 8px' } })),
3080
+ // Fields on their own row, then the option + primary action: this is
3081
+ // the plugin's existing form pattern (.dsh-rw-settings-editor-actions
3082
+ // right-aligns its primary button), and it keeps 添加转发 from sitting
3083
+ // alone on a wrapped third line.
3084
+ React.createElement('div', { style: { display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 8, marginTop: 8, flexWrap: 'wrap' } },
3085
+ React.createElement('div', { style: { display: 'flex', alignItems: 'center', gap: 8, flexWrap: 'wrap', minWidth: 0 } },
3086
+ // Which host this tunnel belongs to. Without it the form silently
3087
+ // attached the forward to whatever machine happened to be
3088
+ // connected, so a host that was not connected yet could never be
3089
+ // given one.
3090
+ React.createElement('label', { htmlFor: settingsId + '-fwd-host', style: { fontSize: 12, display: 'flex', gap: 4, alignItems: 'center', whiteSpace: 'nowrap', color: T.muted } }, tr('settings.fwdHost')),
3091
+ React.createElement('select', {
3092
+ id: settingsId + '-fwd-host', className: 'dsh-rw-input', 'data-testid': 'fwd-host',
3093
+ value: fwdForm.machineId,
3094
+ onChange: (e) => setFwdForm({ ...fwdForm, machineId: e.target.value }),
3095
+ disabled: !machines.length,
3096
+ title: tr('settings.fwdHostHint'),
3097
+ 'aria-label': tr('settings.fwdHost'),
3098
+ style: { ...inputS, maxWidth: 260, minWidth: 130, padding: '6px 8px' },
3099
+ },
3100
+ !machines.length ? React.createElement('option', { value: '' }, tr('settings.fwdHostEmpty')) : null,
3101
+ machines.map((m) => React.createElement('option', { key: m.id, value: m.id },
3102
+ `${m.name || m.host} (${m.username || 'root'}@${m.host})` + (m.id === currentId ? ' · ' + tr('settings.fwdHostCurrent') : '')))),
3103
+ React.createElement(RwCheckbox, { checked: fwdForm.autoStart, label: tr('settings.fwdAuto'), onChange: (next) => requestFwdAutoStart({ kind: 'form' }, next === true, fwdForm.direction) })),
3104
+ React.createElement('div', { style: { display: 'flex', gap: 6, alignItems: 'center', flexWrap: 'wrap' } },
3105
+ fwdEditId ? React.createElement('button', { type: 'button', className: 'dsh-rw-btn', style: buttonS, onClick: cancelFwdEdit, disabled: !!fwdBusy[fwdEditId] }, tr('settings.fwdCancelEdit')) : null,
3106
+ React.createElement('button', {
3107
+ type: 'button', className: 'dsh-rw-btn dsh-rw-primary', style: primaryBtnS,
3108
+ onClick: () => (fwdEditId ? fwdSaveEdit() : fwdDefine()),
3109
+ disabled: !fwdForm.listenPort || !fwdForm.machineId || !!fwdBusy[fwdEditId],
3110
+ title: !fwdForm.listenPort ? tr('settings.fwdNeedsPort') : !fwdForm.machineId ? tr('settings.fwdHostNeeds') : (fwdEditId ? tr('settings.fwdEditHint') : tr('settings.fwdAddHint')),
3111
+ }, fwdEditId ? tr('settings.fwdSaveChanges') : tr('settings.fwdAdd')))),
3112
+ React.createElement('div', { style: { opacity: 0.6, fontSize: 11, lineHeight: 1.5, marginTop: 6 } },
3113
+ tr(fwdForm.direction === 'reverse' ? 'settings.fwdReverseHint' : 'settings.fwdLocalHint')),
2648
3114
  ) : null,
2649
3115
  ),
2650
3116
  React.createElement('div', { style: boxS },
@@ -2672,7 +3138,8 @@ window.__ModuleLoader__.load({
2672
3138
  .then((r) => { if (r && r.file) setAuditFile(String(r.file)); setAuditMsg(tr('settings.auditRevealed', { file: (r && r.file) || auditFile })) })
2673
3139
  .catch((err) => setAuditMsg(tr('settings.auditOpenFailed', { msg: String((err && err.message) || err) })))
2674
3140
  },
2675
- }, tr('settings.auditReveal')))),
3141
+ }, tr('settings.auditReveal'))),
3142
+ sectionIcon(HostLogIcon)),
2676
3143
  auditOpen
2677
3144
  ? React.createElement(React.Fragment, null,
2678
3145
  // The path is always shown: even where the OS cannot open it (headless
@@ -2692,7 +3159,8 @@ window.__ModuleLoader__.load({
2692
3159
  React.createElement('button', {
2693
3160
  type: 'button', className: 'dsh-rw-btn', style: { ...buttonS, padding: '2px 8px', fontSize: 12, marginLeft: 'auto' },
2694
3161
  onClick: (e) => { e.stopPropagation(); loadCleanup() },
2695
- }, tr('settings.cleanupRefresh'))),
3162
+ }, tr('settings.cleanupRefresh')),
3163
+ sectionIcon(HostCleanupIcon)),
2696
3164
  cleanupOpen
2697
3165
  ? (cleanupRows.length
2698
3166
  ? React.createElement('div', { style: { display: 'flex', flexDirection: 'column', gap: 4 } },
@@ -2760,9 +3228,8 @@ window.__ModuleLoader__.load({
2760
3228
  // Host Switch when shipped: its onChange hands back a bare boolean
2761
3229
  // and it does not forward unknown props, so the stable test id lives
2762
3230
  // on the tight wrapper span. The caption keeps label-like behaviour
2763
- // (click toggles) so the swap is purely visual. Older hosts keep the
2764
- // native checkbox — which then OWNS the data-testid: exactly one
2765
- // element carries each id on either path.
3231
+ // (click toggles) so the swap is purely visual. Every other host gets
3232
+ // the unified checkbox under the same wrapper: one id on either path.
2766
3233
  HostSwitch
2767
3234
  ? React.createElement('span', { style: { display: 'inline-flex', gap: 6, alignItems: 'center', opacity: 0.85 } },
2768
3235
  React.createElement('span', { 'data-testid': 'explorer-auto-open', style: { display: 'inline-flex' } },
@@ -2773,13 +3240,7 @@ window.__ModuleLoader__.load({
2773
3240
  })),
2774
3241
  React.createElement('span', { style: { cursor: 'pointer' }, onClick: () => applyExplorerAutoOpen(!explorerAuto) }, tr('settings.explorerAutoOpen')),
2775
3242
  )
2776
- : React.createElement('label', { style: { display: 'flex', gap: 6, alignItems: 'center', cursor: 'pointer', opacity: 0.85 } },
2777
- React.createElement('input', {
2778
- type: 'checkbox', checked: explorerAuto, 'data-testid': 'explorer-auto-open',
2779
- onChange: (e) => applyExplorerAutoOpen(!!(e && e.target && e.target.checked)),
2780
- }),
2781
- tr('settings.explorerAutoOpen'),
2782
- ),
3243
+ : React.createElement('span', { 'data-testid': 'explorer-auto-open', style: { display: 'inline-flex', opacity: 0.85 } }, React.createElement(RwCheckbox, { checked: explorerAuto, label: tr('settings.explorerAutoOpen'), onChange: (on) => applyExplorerAutoOpen(on === true) })),
2783
3244
  ),
2784
3245
  upd?.lastReload?.ok === false
2785
3246
  ? React.createElement('div', { role: 'status', style: { marginTop: 8, fontSize: 12, lineHeight: 1.6, color: T.warn } }, tr('settings.updateReloadFailed', { reason: upd.lastReload.reason || '' }))
@@ -2801,7 +3262,22 @@ window.__ModuleLoader__.load({
2801
3262
  React.createElement('a', { href: 'https://github.com/flymysql/dsh-remote/issues/new', target: '_blank', rel: 'noopener noreferrer', style: { color: 'inherit' } }, tr('settings.feedback')),
2802
3263
  React.createElement('span', { style: { marginLeft: 'auto', opacity: 0.5 } }, 'dsh-remote v' + CLIENT_VERSION),
2803
3264
  ),
2804
- settingsMenu && HostMenu ? React.createElement(HostMenu, { open: true, portal: true, getAnchorRect: () => settingsMenu.anchor, items: [ { id: 'edit', label: tr('settings.edit') }, { id: 'delete', label: tr('settings.delete'), danger: true } ], onClose: () => setSettingsMenu(null), onSelect: id => { const machine = settingsMenu.machine; setSettingsMenu(null); if (id === 'edit') startEdit(machine); else if (id === 'delete') del(machine.id) } }) : null)
3265
+ settingsMenu && HostMenu ? React.createElement(HostMenu, {
3266
+ open: true, portal: true,
3267
+ // Anchor the popup to the `...` button itself, right-aligned under it,
3268
+ // and hand focus back to that button when the menu closes.
3269
+ anchor: null, anchorRef: settingsMenu.anchorRef,
3270
+ getAnchorRect: settingsMenu.getAnchorRect,
3271
+ returnFocus: () => settingsMenu.el,
3272
+ align: 'end', side: 'bottom',
3273
+ // A discovered alias has no registry record to delete: 编辑 is the only
3274
+ // action it can offer, exactly like the saved rows' first item.
3275
+ items: settingsMenu.discovered
3276
+ ? [ { id: 'edit', label: tr('settings.edit') } ]
3277
+ : [ { id: 'edit', label: tr('settings.edit') }, { id: 'delete', label: tr('settings.delete'), danger: true } ],
3278
+ onClose: () => setSettingsMenu(null),
3279
+ onSelect: id => { const menu = settingsMenu; setSettingsMenu(null); if (id === 'edit') startEdit(menu.machine); else if (id === 'delete') del(menu.machine.id) },
3280
+ }) : null)
2805
3281
  }
2806
3282
 
2807
3283
  // ── Unified picker (fill the directory-flow holes) ───────────────────
@@ -2868,7 +3344,7 @@ window.__ModuleLoader__.load({
2868
3344
  React.createElement('div', { style: { fontWeight: 600 } }, cancelled ? error : tr('project.failed')),
2869
3345
  !cancelled ? React.createElement(React.Fragment, null,
2870
3346
  React.createElement('div', {}, tr(key)),
2871
- React.createElement('details', { style: { marginTop: 4 } }, React.createElement('summary', { style: { cursor: 'pointer' } }, tr('project.details')), React.createElement('div', { style: { whiteSpace: 'pre-wrap', fontFamily: 'monospace', paddingTop: 6 } }, error))) : null)
3347
+ React.createElement('div', { style: { marginTop: 4 } }, React.createElement(RwDetails, { title: tr('project.details') }, React.createElement('div', { style: { whiteSpace: 'pre-wrap', fontFamily: 'monospace', paddingTop: 6 } }, error)))) : null)
2872
3348
  }
2873
3349
 
2874
3350
  // Shared project-first entry inside both native directory-flow seats.
@@ -2894,8 +3370,9 @@ window.__ModuleLoader__.load({
2894
3370
  const matches = (...fields) => !needle || fields.some((f) => String(f || '').toLowerCase().includes(needle))
2895
3371
  const sorted = machines.slice().sort((a, b) => (Date.parse(b.lastConnectedAt) || 0) - (Date.parse(a.lastConnectedAt) || 0))
2896
3372
  const recentProjects = sorted.flatMap((m) => (m.recentWorkspaces || []).filter((p) => matches(m.name, m.host, p)).map((path) => ({ machine: m, path })))
2897
- const aliases = new Set(machines.filter((m) => m.useSshConfig).map((m) => m.host))
2898
- const discovered = (hosts || []).filter((h) => !aliases.has(h.alias || h.host) && matches(h.alias, h.hostName, h.host, h.user))
3373
+ // The picker keeps every saved record too; only discovered aliases are
3374
+ // deduped or hidden behind a saved SSH identity / exact alias.
3375
+ const discovered = dedupeDiscoveredForSaved(hosts || [], sorted).filter((h) => matches(h.alias, h.hostName, h.host, h.user))
2899
3376
  const saved = sorted.filter((m) => matches(m.name, m.host, m.username))
2900
3377
  const chooseAlias = async (h) => {
2901
3378
  if (busy || opening) return
@@ -2920,7 +3397,7 @@ window.__ModuleLoader__.load({
2920
3397
  React.createElement('span', { style: { display: 'flex', flexDirection: 'column', gap: 3, minWidth: 0, flex: 1 } },
2921
3398
  React.createElement('span', { style: { fontSize: 13, fontWeight: 600, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' } }, title),
2922
3399
  React.createElement('span', { style: { fontSize: 11, color: T.muted, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' } }, subtitle)),
2923
- React.createElement('span', { 'aria-hidden': true, style: { color: T.muted } }, '›'))
3400
+ React.createElement('span', { 'aria-hidden': true, style: { color: T.muted, display: 'inline-flex', flexShrink: 0 } }, React.createElement(Chevron, { dir: 'right', size: 12 })))
2924
3401
  const heading = (text) => React.createElement('div', { style: { padding: '10px 12px 4px', fontSize: 11, fontWeight: 600, color: T.muted } }, text)
2925
3402
  return React.createElement('div', { style: { display: 'flex', flexDirection: 'column', minHeight: 0, gap: 8 } },
2926
3403
  React.createElement('input', { className: 'dsh-rw-input', 'data-modal-autofocus': true, 'aria-label': tr('project.search'), placeholder: tr('project.search'), value: query, disabled: busy || !!opening,
@@ -3086,6 +3563,13 @@ window.__ModuleLoader__.load({
3086
3563
  const cands = [{ host: String(m.host || ''), port: Number(m.port) || 22, username: String(m.username || '') }]
3087
3564
  const r = m.sshConfigResolved
3088
3565
  if (r && r.host) cands.push({ host: String(r.host), port: Number(r.port) || 22, username: String(r.username || m.username || '') })
3566
+ // System OpenSSH hands the alias to ssh and deliberately emits no -l/-p.
3567
+ // Its pool echo is therefore alias/22/'' even when the registry and
3568
+ // resolved config name a concrete user and a non-default SSH Port.
3569
+ // Accept that exact transport identity without making '' a wildcard.
3570
+ const aliasOpenssh = String(m.backend || '').toLowerCase() === 'openssh'
3571
+ && (m.useSshConfig || (r && r.matched))
3572
+ if (aliasOpenssh) cands.push({ host: String(m.host || ''), port: 22, username: '' })
3089
3573
  return cands.some((c) => c.host === String(echo.host) && c.port === (Number(echo.port) || 22) && c.username === String(echo.username || ''))
3090
3574
  }
3091
3575
 
@@ -3403,6 +3887,33 @@ window.__ModuleLoader__.load({
3403
3887
  const res = await api('POST', '/dsh-remote/mirror', { path: target, machineId: selectedMachineId, registerWorkspace: registerWorkspace !== false }, signal)
3404
3888
  if (!current()) return
3405
3889
  if (!res || !res.localMirror) throw new Error((res && res.error) || tr('project.failed'))
3890
+ // dsh-remote-fix2: mirror-cache — record the mirror BEFORE the host adopts it.
3891
+ // `localWorkspaceSession()` classifies a session as local when its
3892
+ // cwd is outside every cached mirror, and the host rejects local
3893
+ // requests for a mirror it binds remotely (409 "Workspace execution
3894
+ // context changed"). The registry here is normally loaded once at
3895
+ // startup, so a mirror created a second ago is missing from it: the
3896
+ // first requests of the new session would be misclassified. Adding
3897
+ // the entry now makes the new session remote from request one; the
3898
+ // delayed refresh below then replaces it with the on-disk record.
3899
+ const newMirror = res.machine || {}
3900
+ const newMirrorDir = String(res.localMirror || '')
3901
+ mirrorGeneration += 1 // supersede any registry request started before this mutation
3902
+ if (newMirrorDir && !MIRRORS.list.some((m) => m && sameMirrorDir(m.dir, newMirrorDir))) {
3903
+ MIRRORS.list.push({
3904
+ dir: newMirrorDir,
3905
+ host: String(newMirror.host || ''),
3906
+ port: Number(newMirror.port) || 22,
3907
+ username: String(newMirror.username || ''),
3908
+ remotePath: String(res.path || target),
3909
+ alias: '',
3910
+ name: '',
3911
+ })
3912
+ }
3913
+ // Keep loaded/error tied to the latest authoritative GET. An optimistic
3914
+ // entry is confirmed, but a partial or failed registry is not healthy.
3915
+ notifyMirrors()
3916
+ setTimeout(() => { void refreshMirrors() }, 2000)
3406
3917
  await onPicked(res.localMirror, res.path || target)
3407
3918
  })
3408
3919
  }
@@ -3450,7 +3961,7 @@ window.__ModuleLoader__.load({
3450
3961
  if (!crumbs.length) return React.createElement('span', null, '/')
3451
3962
  const out = []
3452
3963
  crumbs.forEach((c, i) => {
3453
- if (i > 0) out.push(React.createElement('span', { key: 'sep' + i, style: { color: T.muted } }, ' › '))
3964
+ if (i > 0) out.push(React.createElement('span', { key: 'sep' + i, style: { color: T.muted, display: 'inline-flex', flexShrink: 0 } }, React.createElement(Chevron, { dir: 'right', size: 12 })))
3454
3965
  out.push(React.createElement('span', {
3455
3966
  key: c.path || i,
3456
3967
  title: c.path,
@@ -3473,12 +3984,12 @@ window.__ModuleLoader__.load({
3473
3984
  onMouseDown: localBackdrop.onMouseDown,
3474
3985
  onClick: (e) => { if (localBackdrop.onClick(e)) setLocalPop(null) },
3475
3986
  },
3476
- React.createElement('div', { style: { background: v('--dsw-alias-bg-overlay', '#1e1e1e'), border: '1px solid ' + T.borderStrong, borderRadius: 10, boxShadow: '0 10px 40px rgba(0,0,0,0.5)', width: 'min(560px, 94vw)', minWidth: 320, display: 'flex', flexDirection: 'column', maxHeight: 'min(460px, 84vh)', overflow: 'hidden' }, onClick: (e) => e.stopPropagation() },
3987
+ React.createElement('div', { style: { background: v('--dsw-alias-bg-layer-2', '#1e1e1e'), border: '1px solid ' + T.borderStrong, borderRadius: 10, boxShadow: '0 10px 40px rgba(0,0,0,0.5)', width: 'min(560px, 94vw)', minWidth: 320, display: 'flex', flexDirection: 'column', maxHeight: 'min(460px, 84vh)', overflow: 'hidden' }, onClick: (e) => e.stopPropagation() },
3477
3988
  React.createElement('div', { style: { display: 'flex', gap: 6, alignItems: 'center', padding: '8px 12px', borderBottom: '1px solid ' + T.border } },
3478
- React.createElement('button', { style: { ...buttonS, padding: '3px 10px' }, onClick: () => parent && loadLocal(parent), disabled: !parent || loading, title: parent || '' }, tr('picker.back')),
3989
+ React.createElement('button', { style: { ...buttonS, padding: '3px 10px', display: 'inline-flex', alignItems: 'center', gap: 4 }, onClick: () => parent && loadLocal(parent), disabled: !parent || loading, title: parent || '' }, React.createElement(Chevron, { dir: 'up', size: 12 }), tr('picker.back')),
3479
3990
  cur.home ? React.createElement('button', { style: { ...buttonS, padding: '3px 8px' }, onClick: () => loadLocal(cur.home), disabled: loading, title: tr('picker.goHome') }, tr('picker.homeBtn')) : null,
3480
3991
  React.createElement('div', { style: { fontSize: 11, opacity: 0.75, fontFamily: 'monospace', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap', flex: 1 } }, localCrumbs(cur)),
3481
- React.createElement('button', { style: { ...buttonS, padding: '3px 10px' }, onClick: () => setLocalPop(null) }, tr('picker.closeBtn')),
3992
+ React.createElement(CloseButton, { label: tr('picker.closeBtn'), onClick: () => setLocalPop(null) }),
3482
3993
  ),
3483
3994
  // 盘符切换行(Windows 无统一根目录,browse 面包屑到不了其他盘)。
3484
3995
  (cur.drives && cur.drives.length > 1) ? React.createElement('div', { style: { display: 'flex', gap: 4, flexWrap: 'wrap', padding: '6px 12px', borderBottom: '1px solid ' + T.border } },
@@ -3525,12 +4036,12 @@ window.__ModuleLoader__.load({
3525
4036
  }
3526
4037
  const last = levels[levels.length - 1]
3527
4038
  const entries = last.all || []
3528
- return React.createElement('div', { 'data-rw-directory-browser': true, style: { border: '1px solid ' + T.borderStrong, borderRadius: 8, background: v('--dsw-alias-bg-overlay', '#1e1e1e'), display: 'flex', flexDirection: 'column', flex: '1 1 0', minHeight: 0, overflow: 'hidden' } },
4039
+ return React.createElement('div', { 'data-rw-directory-browser': true, style: { border: '1px solid ' + T.borderStrong, borderRadius: 8, background: v('--dsw-alias-bg-layer-2', '#1e1e1e'), display: 'flex', flexDirection: 'column', flex: '1 1 0', minHeight: 0, overflow: 'hidden' } },
3529
4040
  React.createElement('div', { style: { display: 'flex', gap: 6, alignItems: 'center', flexShrink: 0, padding: '6px 10px', borderBottom: '1px solid ' + T.border } },
3530
- React.createElement('button', { style: { ...buttonS, padding: '2px 8px' }, onClick: goUp, disabled: loading || (levels.length <= 1 && !parentOf(last.path)) }, tr('picker.back')),
4041
+ React.createElement('button', { style: { ...buttonS, padding: '2px 8px', display: 'inline-flex', alignItems: 'center', gap: 4 }, onClick: goUp, disabled: loading || (levels.length <= 1 && !parentOf(last.path)) }, React.createElement(Chevron, { dir: 'up', size: 12 }), tr('picker.back')),
3531
4042
  React.createElement('div', { style: { fontSize: 11, opacity: 0.75, fontFamily: 'monospace', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap', flex: 1 } }, breadcrumb(!!machineId, last.path, win, (p) => { if (loading) return; const cut = (levels || []).findIndex((lv) => lv.path === p); if (cut >= 0) setLevels(levels.slice(0, cut + 1)); else loadLevels(machineId, p, 0) })),
3532
4043
  React.createElement('button', { style: { ...buttonS, padding: '2px 8px' }, onClick: mkdirHere }, tr('picker.newDir')),
3533
- React.createElement('button', { style: { ...buttonS, padding: '2px 8px' }, onClick: () => setPopOpen(false) }, tr('picker.closeBtn')),
4044
+ React.createElement(CloseButton, { label: tr('picker.closeBtn'), onClick: () => setPopOpen(false) }),
3534
4045
  ),
3535
4046
  React.createElement('div', { 'data-rw-directory-list': true, role: 'region', 'aria-label': tr('picker.browse'), style: { flex: 1, minHeight: 0, overflowY: 'auto', overflowX: 'hidden' } },
3536
4047
  loading ? React.createElement('div', { style: { opacity: 0.7, padding: 12 } }, tr('picker.loading'))
@@ -3640,7 +4151,7 @@ window.__ModuleLoader__.load({
3640
4151
  React.createElement('div', { ref: pickerLayerRef, tabIndex: -1, role: 'dialog', 'aria-modal': true, 'aria-labelledby': suggestListId + '-title', 'data-rw-dir-picker': true, className: 'dsh-rw-modal-panel', style: { background: v('--dsw-alias-bg-layer-1', '#18181b'), color: T.label, border: '1px solid ' + T.borderStrong, borderRadius: 12, boxShadow: '0 12px 48px rgba(0,0,0,0.5)', width: 'min(720px, 94vw)', height: popOpen && tab === 'remote' ? 'min(760px, calc(100dvh - 32px))' : undefined, maxHeight: 'min(760px, calc(100dvh - 32px))', display: 'flex', flexDirection: 'column', padding: 16, boxSizing: 'border-box' }, onClick: (e) => e.stopPropagation() },
3641
4152
  React.createElement('div', { style: { display: 'flex', alignItems: 'center', justifyContent: 'space-between', marginBottom: 10 } },
3642
4153
  React.createElement('div', { id: suggestListId + '-title', style: { fontSize: 15, fontWeight: 650 } }, tr('picker.title')),
3643
- React.createElement('button', { type: 'button', className: 'dsh-rw-btn', style: { ...buttonS, padding: '2px 8px' }, onClick: closePicker, disabled: !!externalBusy }, tr('picker.close')),
4154
+ React.createElement(CloseButton, { label: tr('picker.close'), onClick: closePicker, disabled: !!externalBusy }),
3644
4155
  ),
3645
4156
  // 本机/远程 switch: host SegmentedTabs when the bundle ships one
3646
4157
  // (sliding-indicator tablist, roving tabindex and arrow-key navigation
@@ -3683,7 +4194,7 @@ window.__ModuleLoader__.load({
3683
4194
  onProject: (m, p) => { setMachineId(m.id); setRecent(m.recentWorkspaces || []); setPath(p); setChoosingProject(false); commitPath(p, m.id) },
3684
4195
  })
3685
4196
  : React.createElement('div', { 'data-rw-picker-remote': true, style: { display: 'flex', flexDirection: 'column', flex: popOpen ? '1 1 0' : '0 1 auto', gap: 8, minHeight: 0, overflowY: popOpen ? 'hidden' : 'auto' } },
3686
- React.createElement('button', { type: 'button', className: 'dsh-rw-btn', disabled: busy, style: { ...buttonS, alignSelf: 'flex-start', fontSize: 12 }, onClick: () => { killSuggestions(); resetPickerFetchState(); setPath(''); setChoosingProject(true) } }, '‹ ' + tr('project.back')),
4197
+ React.createElement('button', { type: 'button', className: 'dsh-rw-btn', disabled: busy, style: { ...buttonS, alignSelf: 'flex-start', fontSize: 12, display: 'inline-flex', alignItems: 'center', gap: 4 }, onClick: () => { killSuggestions(); resetPickerFetchState(); setPath(''); setChoosingProject(true) } }, React.createElement(Chevron, { dir: 'left', size: 12 }), tr('project.back')),
3687
4198
  React.createElement('div', { style: { display: 'flex', gap: 6, alignItems: 'center' } },
3688
4199
  React.createElement('label', { style: { fontSize: 12, opacity: 0.8, whiteSpace: 'nowrap' } }, tr('picker.remoteMachine')),
3689
4200
  React.createElement('div', { ref: ddRef, style: { position: 'relative', display: 'inline-block' } },
@@ -3691,7 +4202,7 @@ window.__ModuleLoader__.load({
3691
4202
  (machines.find((m) => m.id === machineId) || {}).name || (machineId ? '…' : tr('picker.chooseMachine')),
3692
4203
  ),
3693
4204
  mOpen
3694
- ? React.createElement('div', { style: { position: 'absolute', top: '100%', left: 0, zIndex: 1000, marginTop: 2, minWidth: 300, maxHeight: 260, overflow: 'auto', background: v('--dsw-alias-bg-overlay', '#1f1f23'), color: T.label, border: '1px solid ' + T.border, borderRadius: T.radius, padding: 4 } },
4205
+ ? React.createElement('div', { style: { position: 'absolute', top: '100%', left: 0, zIndex: 1000, marginTop: 2, minWidth: 300, maxHeight: 260, overflow: 'auto', background: v('--dsw-alias-bg-layer-2', '#1f1f23'), color: T.label, border: '1px solid ' + T.border, borderRadius: T.radius, padding: 4 } },
3695
4206
  machines.length
3696
4207
  ? machines.map((m) => React.createElement('div', { key: m.id, className: 'dsh-rw-list-item', onClick: () => { setMachineId(m.id); setRecent(m.recentWorkspaces || []); setLevels(null); setPath(''); setMOpen(false); resetPickerFetchState(); killSuggestions(); setLoading(false); setErr(''); if (m.id) loadLevels(m.id, '', 0) }, style: { padding: '6px 8px', borderRadius: 4, cursor: 'pointer', color: m.id === machineId ? T.ok : 'inherit' } }, m.name + ' (' + m.username + '@' + m.host + ':' + m.port + ')'))
3697
4208
  : React.createElement('div', { style: { padding: 6, opacity: 0.6 } }, tr('picker.noMachines')),
@@ -3744,7 +4255,7 @@ window.__ModuleLoader__.load({
3744
4255
  // never move the dialog or sit beneath the workspace action.
3745
4256
  !popOpen ? React.createElement('div', { className: 'dsh-rw-suggestions', style: { position: 'relative', height: 'min(180px, 25vh)', marginTop: 8, border: '1px solid ' + T.border, borderRadius: 8, background: T.bg } },
3746
4257
  (suggestOpen && suggest.length)
3747
- ? React.createElement('div', { id: suggestListId, role: 'listbox', 'aria-label': tr('picker.pathPlaceholder'), style: { position: 'absolute', top: 0, bottom: 0, left: 0, right: 0, zIndex: 60, background: v('--dsw-alias-bg-overlay', '#1e1e1e'), color: T.label, borderRadius: 8, maxHeight: 200, overflowY: 'auto' } },
4258
+ ? React.createElement('div', { id: suggestListId, role: 'listbox', 'aria-label': tr('picker.pathPlaceholder'), style: { position: 'absolute', top: 0, bottom: 0, left: 0, right: 0, zIndex: 60, color: T.label, borderRadius: 8, maxHeight: 200, overflowY: 'auto' } },
3748
4259
  // Issue #52 defect 1, local belt-and-braces: swallow the
3749
4260
  // gesture so no ancestor (least of all the backdrop) can
3750
4261
  // observe a click that began on a suggestion.
@@ -3844,11 +4355,15 @@ window.__ModuleLoader__.load({
3844
4355
  return api('POST', EXPLORER_AUTO_OPEN_ROUTE, { enabled: on }).catch(() => null)
3845
4356
  }
3846
4357
 
3847
- // A loaded registry plus the session's own cwd proves local vs remote.
3848
- // Registry failure never turns an unrecognised mirror into a local project.
4358
+ // A registry read at least once, plus the session's own cwd, proves local vs
4359
+ // remote. `known` rather than `loaded` is deliberate: `refreshMirrors()`
4360
+ // clears `loaded` while /bindings is in flight, and classifying against that
4361
+ // window demoted a local session to "remote with no root" mid-refresh, which
4362
+ // reset the pane and discarded the refresh the user had just asked for.
4363
+ // Registry failure still never turns an unrecognised mirror into local.
3849
4364
  function localWorkspaceSession(sessionId) {
3850
4365
  const cwd = sessionCwdFor(sessionId)
3851
- return !!(cwd && MIRRORS.loaded && !MIRRORS.error && !mirrorForCwd(cwd, MIRRORS.list))
4366
+ return !!(cwd && MIRRORS.known && !MIRRORS.error && !mirrorForCwd(cwd, MIRRORS.list))
3852
4367
  }
3853
4368
  function workspaceText(key, sessionId, params) {
3854
4369
  return tr(localWorkspaceSession(sessionId) && L.en['local.' + key] ? 'local.' + key : key, params)
@@ -3917,9 +4432,13 @@ window.__ModuleLoader__.load({
3917
4432
  // Failure is not fatal and not retried in a loop: no registry means no
3918
4433
  // badge, which is exactly what a user with zero mirrors sees.
3919
4434
 
3920
- const MIRRORS = { list: [], loaded: false, error: '' }
4435
+ // `loaded` is cleared for the duration of a forced refresh; `known` latches
4436
+ // on the first successful read, so "which workspace is this?" does not
4437
+ // depend on a /bindings round-trip being in flight.
4438
+ const MIRRORS = { list: [], loaded: false, known: false, error: '' }
3921
4439
  const mirrorWatchers = new Set()
3922
- let mirrorLoad = null
4440
+ let mirrorLoad = null // { generation, promise } for the current request only
4441
+ let mirrorGeneration = 0
3923
4442
  let mirrorTimer = null
3924
4443
 
3925
4444
  const notifyMirrors = () => {
@@ -3928,26 +4447,52 @@ window.__ModuleLoader__.load({
3928
4447
  /** Load the mirror registry once (concurrent callers share the request). */
3929
4448
  function ensureMirrors() {
3930
4449
  if (MIRRORS.loaded) return Promise.resolve(MIRRORS)
3931
- if (mirrorLoad) return mirrorLoad
3932
- mirrorLoad = api('GET', '/dsh-remote/bindings')
4450
+ if (mirrorLoad && mirrorLoad.generation === mirrorGeneration) return mirrorLoad.promise
4451
+ const generation = ++mirrorGeneration
4452
+ const promise = api('GET', '/dsh-remote/bindings')
3933
4453
  .then((r) => {
4454
+ if (generation !== mirrorGeneration) return MIRRORS
3934
4455
  MIRRORS.list = (r && Array.isArray(r.mirrors)) ? r.mirrors : []
3935
4456
  MIRRORS.error = ''
4457
+ MIRRORS.known = true
4458
+ })
4459
+ .catch((e) => {
4460
+ if (generation === mirrorGeneration) MIRRORS.error = String((e && e.message) || e)
3936
4461
  })
3937
- .catch((e) => { MIRRORS.error = String((e && e.message) || e) })
3938
4462
  .then(() => {
3939
- MIRRORS.loaded = true
3940
- mirrorLoad = null
3941
- notifyMirrors()
4463
+ if (generation === mirrorGeneration) {
4464
+ MIRRORS.loaded = true
4465
+ notifyMirrors()
4466
+ }
4467
+ // An old request must not clear the pointer of a newer one.
4468
+ if (mirrorLoad && mirrorLoad.generation === generation) mirrorLoad = null
3942
4469
  return MIRRORS
3943
4470
  })
3944
- return mirrorLoad
4471
+ mirrorLoad = { generation, promise }
4472
+ return promise
3945
4473
  }
3946
4474
  /** Force a refresh (mirrors appear when a workspace is picked). */
3947
4475
  function refreshMirrors() {
3948
4476
  MIRRORS.loaded = false
4477
+ mirrorGeneration += 1
3949
4478
  return ensureMirrors()
3950
4479
  }
4480
+
4481
+ /** A client-safe path grammar: Windows drive/UNC paths fold case and
4482
+ * separators; POSIX paths keep case and backslashes. */
4483
+ function mirrorPathKey(value) {
4484
+ const raw = String(value || '')
4485
+ if (!raw) return { windows: false, key: '' }
4486
+ // Detect the grammar BEFORE trimming: C:\ and UNC roots must stay
4487
+ // Windows, while POSIX / remains a real root instead of an empty key.
4488
+ const windows = /^(?:[a-z]:[\\/]|[a-z]:$|[\\/]{2})/i.test(raw)
4489
+ const trimmed = raw.replace(/[\\/]+$/, '')
4490
+ return { windows, key: windows ? trimmed.replace(/\\/g, '/').toLowerCase() : (trimmed || '/') }
4491
+ }
4492
+ function sameMirrorDir(a, b) {
4493
+ const left = mirrorPathKey(a), right = mirrorPathKey(b)
4494
+ return !!(left.key && right.key && left.windows === right.windows && left.key === right.key)
4495
+ }
3951
4496
  /**
3952
4497
  * The mirror containing a local path, or null.
3953
4498
  *
@@ -3957,20 +4502,20 @@ window.__ModuleLoader__.load({
3957
4502
  * case-insensitively because the platform does.
3958
4503
  */
3959
4504
  function mirrorForCwd(cwd, mirrors) {
3960
- const raw = String(cwd || '')
3961
- if (!raw) return null
4505
+ const base = mirrorPathKey(cwd)
4506
+ if (!base.key) return null
3962
4507
  const list = Array.isArray(mirrors) ? mirrors : []
3963
- const isWin = raw.includes('\\')
3964
- const sep = isWin ? '\\' : '/'
3965
- const fold = (s) => (isWin ? s.toLowerCase() : s)
3966
- const base = fold(raw.replace(/[\\/]+$/, ''))
3967
- let best = null
4508
+ let best = null, bestKey = ''
3968
4509
  for (const m of list) {
3969
- const dirRaw = String((m && m.dir) || '').replace(/[\\/]+$/, '')
3970
- if (!dirRaw) continue
3971
- const dir = fold(dirRaw)
3972
- if (base !== dir && !base.startsWith(dir + sep) && !base.startsWith(dir + '/')) continue
3973
- if (!best || dir.length > fold(String(best.dir).replace(/[\\/]+$/, '')).length) best = m
4510
+ const dir = mirrorPathKey(m && m.dir)
4511
+ if (!dir.key || dir.windows !== base.windows) continue
4512
+ if (base.key !== dir.key) {
4513
+ // POSIX root contains every absolute child (dir + '/' would be '//').
4514
+ if (dir.key === '/') {
4515
+ if (!base.key.startsWith('/')) continue
4516
+ } else if (!base.key.startsWith(dir.key) || base.key.charAt(dir.key.length) !== '/') continue
4517
+ }
4518
+ if (dir.key.length > bestKey.length) { best = m; bestKey = dir.key }
3974
4519
  }
3975
4520
  return best
3976
4521
  }
@@ -4401,7 +4946,7 @@ window.__ModuleLoader__.load({
4401
4946
  }
4402
4947
  return { open, pending, error }
4403
4948
  }
4404
- function WorkbenchIcon({ name, size = 16 }) {
4949
+ function WorkbenchIcon({ name, size = 16, className }) {
4405
4950
  const paths = {
4406
4951
  remote: 'M2 3h12v8H2zM6 14h4M8 11v3m-3-7 2 2-2 2m4 0h2',
4407
4952
  terminal: 'm3 4 4 4-4 4m6 0h4',
@@ -4415,16 +4960,63 @@ window.__ModuleLoader__.load({
4415
4960
  folder: 'M2 4h5l2 2h5v7H2z',
4416
4961
  file: 'M4 2h5l3 3v9H4zM9 2v4h3',
4417
4962
  down: 'm5 6 3 3 3-3',
4963
+ up: 'm5 10 3-3 3 3',
4418
4964
  right: 'm6 4 4 4-4 4',
4419
4965
  left: 'm10 4-4 4 4 4',
4420
4966
  more: 'M3 8h.01M8 8h.01M13 8h.01',
4421
4967
  }
4422
- return React.createElement('svg', { width: size, height: size, viewBox: '0 0 16 16', fill: 'none', stroke: 'currentColor', strokeWidth: 1.25, strokeLinecap: 'round', strokeLinejoin: 'round', 'aria-hidden': true, style: { flexShrink: 0 } }, React.createElement('path', { d: paths[name] || paths.file }))
4968
+ return React.createElement('svg', { width: size, height: size, viewBox: '0 0 16 16', fill: 'none', stroke: 'currentColor', strokeWidth: 1.25, strokeLinecap: 'round', strokeLinejoin: 'round', 'aria-hidden': true, className, style: { flexShrink: 0 } }, React.createElement('path', { d: paths[name] || paths.file }))
4423
4969
  }
4424
4970
  function WorkbenchAction({ icon, label, onClick, disabled, pressed }) {
4425
4971
  return React.createElement('button', { type: 'button', className: 'dsh-rw-action', title: label, 'aria-label': label, 'aria-pressed': pressed, disabled, onClick }, React.createElement(WorkbenchIcon, { name: icon }))
4426
4972
  }
4427
4973
 
4974
+ function CloseButton({ label, onClick, disabled, title, size = 14 }) {
4975
+ return React.createElement('button', { type: 'button', className: 'dsh-rw-action', 'aria-label': label, title: title === undefined ? label : title, disabled, onClick },
4976
+ HostCloseIcon ? React.createElement(HostCloseIcon, { size }) : React.createElement(WorkbenchIcon, { name: 'close', size: size + 2 }))
4977
+ }
4978
+ function Chevron({ dir = 'right', size = 14, className }) {
4979
+ const host = dir === 'down' ? HostChevronDownIcon : dir === 'up' ? HostChevronUpIcon : dir === 'left' ? HostChevronLeftIcon : HostChevronRightIcon
4980
+ return host ? React.createElement(host, { size, className }) : React.createElement(WorkbenchIcon, { name: dir, size: size + 2, className })
4981
+ }
4982
+ function RwCheckbox({ checked, onChange, label, disabled, title, className }) {
4983
+ if (HostCheckbox) return React.createElement(HostCheckbox, { checked: !!checked, onChange, label, disabled, title, className })
4984
+ return React.createElement('label', { className: 'dsh-rw-check' + (className ? ' ' + className : ''), title }, React.createElement('input', { type: 'checkbox', checked: !!checked, disabled, onChange: (event) => onChange(event.target.checked) }), label)
4985
+ }
4986
+ function disclosureRow({ open, onToggle, title, icon, accessory, className, titleClassName }) {
4987
+ return React.createElement('div', { className: 'dsh-rw-disclosure-head' + (className ? ' ' + className : ''), 'data-open': open || undefined },
4988
+ React.createElement('button', { type: 'button', className: 'dsh-rw-disclosure-row' + (titleClassName ? ' ' + titleClassName : ''), 'aria-expanded': open, onClick: onToggle },
4989
+ React.createElement(Chevron, { dir: open ? 'down' : 'right', size: 14, className: 'dsh-rw-disclosure-chevron' }),
4990
+ icon ? React.createElement('span', { className: 'dsh-rw-disclosure-icon' }, icon) : null,
4991
+ React.createElement('span', { className: 'dsh-rw-disclosure-label' }, title)),
4992
+ accessory || null)
4993
+ }
4994
+ function RwDisclosure({ open, onToggle, title, icon, accessory, children, className, titleClassName }) {
4995
+ return React.createElement('div', { className: 'dsh-rw-disclosure' + (className ? ' ' + className : '') },
4996
+ disclosureRow({ open, onToggle, title, icon, accessory, titleClassName }), open && children ? children : null)
4997
+ }
4998
+ function RwDetails({ title, accessory, children, className, defaultOpen = false, icon, titleClassName }) {
4999
+ const [open, setOpen] = React.useState(defaultOpen)
5000
+ return React.createElement(RwDisclosure, { open, onToggle: () => setOpen(!open), title, icon, accessory, className, titleClassName }, children)
5001
+ }
5002
+ function RwSelect({ id, label, value, options, onChange, disabled, size = 'md', style, align = 'end', title, className }) {
5003
+ const [open, setOpen] = React.useState(false)
5004
+ const compact = size === 'sm'
5005
+ const current = options.find(option => option.value === value)
5006
+ const text = current ? current.label : (value || '')
5007
+ const triggerStyle = { ...(compact ? { height: 26, padding: '0 8px', gap: 4, fontSize: 11 } : { height: 32, padding: '0 12px', gap: 6, fontSize: 13 }), ...style }
5008
+ const cls = 'dsh-rw-select' + (className ? ' ' + className : '')
5009
+ if (!HostMenu) return React.createElement('select', { id, value, disabled, title: title === undefined ? label : title, 'aria-label': label, className: cls, onChange: (event) => onChange(event.target.value), style: triggerStyle },
5010
+ options.map(option => React.createElement('option', { key: option.value, value: option.value }, option.label)))
5011
+ return React.createElement(HostMenu, {
5012
+ open, onClose: () => setOpen(false), portal: true, align, selectedId: value,
5013
+ className: 'dsh-rw-select-anchor', items: options.map(option => ({ id: option.value, label: option.label })),
5014
+ onSelect: (next) => { setOpen(false); if (next !== value) onChange(next) },
5015
+ anchor: React.createElement('button', { id, type: 'button', className: cls, disabled, title: title === undefined ? text : title, 'aria-label': label, 'aria-haspopup': 'menu', 'aria-expanded': open, onClick: (event) => { event.preventDefault(); event.stopPropagation(); setOpen(v => !v) }, style: triggerStyle },
5016
+ React.createElement('span', { className: 'dsh-rw-select-value' }, text),
5017
+ React.createElement(Chevron, { dir: 'down', size: compact ? 12 : 14, className: 'dsh-rw-select-chevron' })),
5018
+ })
5019
+ }
4428
5020
  // Tree-style remote file explorer. Data is listed live from the remote host
4429
5021
  // over /dsh-remote/ls, rooted at this session's remote workspace dir.
4430
5022
  function RemoteWorkspaceSearch(props) {
@@ -4476,16 +5068,12 @@ window.__ModuleLoader__.load({
4476
5068
  }
4477
5069
  return React.createElement('section', { className: 'dsh-rw-search-panel', 'aria-label': tr('workspaceSearch.results'), 'aria-busy': running },
4478
5070
  React.createElement('div', { className: 'dsh-rw-search-progress' },
4479
- React.createElement('details', { className: 'dsh-rw-search-details' },
4480
- React.createElement('summary', { title: tr('workspaceSearch.details'), 'aria-label': tr('workspaceSearch.details') },
4481
- React.createElement('span', { role: 'status', 'aria-live': 'polite', className: 'dsh-rw-search-status' },
4482
- React.createElement('span', {}, tr(statusKey)),
4483
- React.createElement('span', { style: { color: T.muted } }, tr('workspaceSearch.matches', { n: current.results.length })),
4484
- running ? React.createElement('span', { style: { color: T.muted } }, tr('workspaceSearch.scanned', { n: (current.scannedDirs || 0) + (current.scannedFiles || 0) })) : null)),
4485
- React.createElement('div', { className: 'dsh-rw-search-detail-body' },
4486
- React.createElement('div', {}, tr('workspaceSearch.progress', { dirs: current.scannedDirs || 0, files: current.scannedFiles || 0, results: current.results.length, seconds: ((current.elapsedMs || 0) / 1000).toFixed(1) })),
4487
- current.skipped || current.errors ? React.createElement('div', {}, tr('workspaceSearch.skipped', { skipped: current.skipped || 0, errors: current.errors || 0 })) : null,
4488
- current.currentPath ? React.createElement('div', { className: 'dsh-rw-path', title: current.currentPath }, current.currentPath) : null)),
5071
+ React.createElement('div', { role: 'status', 'aria-live': 'polite', style: { flex: 1, minWidth: 0 } },
5072
+ React.createElement(RwDetails, { className: 'dsh-rw-search-details', title: [tr(statusKey), tr('workspaceSearch.matches', { n: current.results.length }), running ? tr('workspaceSearch.scanned', { n: (current.scannedDirs || 0) + (current.scannedFiles || 0) }) : null].filter(Boolean).join(' · ') },
5073
+ React.createElement('div', { className: 'dsh-rw-search-detail-body' },
5074
+ React.createElement('div', {}, tr('workspaceSearch.progress', { dirs: current.scannedDirs || 0, files: current.scannedFiles || 0, results: current.results.length, seconds: ((current.elapsedMs || 0) / 1000).toFixed(1) })),
5075
+ current.skipped || current.errors ? React.createElement('div', {}, tr('workspaceSearch.skipped', { skipped: current.skipped || 0, errors: current.errors || 0 })) : null,
5076
+ current.currentPath ? React.createElement('div', { className: 'dsh-rw-path', title: current.currentPath }, current.currentPath) : null))),
4489
5077
  React.createElement('button', { type: 'button', className: 'dsh-rw-btn', style: { ...buttonS, fontSize: 11, padding: '3px 7px' }, onClick: () => running ? stopRef.current?.() : setRetry(value => value + 1) }, tr(running ? 'workspaceSearch.stop' : 'workspaceSearch.retry'))),
4490
5078
  current.error ? React.createElement('div', { role: 'alert', style: { padding: '8px 10px', fontSize: 12, color: T.danger, overflowWrap: 'anywhere' } }, current.error) : null,
4491
5079
  current.status === 'partial' ? React.createElement('div', { style: { padding: '6px 10px', fontSize: 11, color: T.warn } }, tr('workspaceSearch.partialHint')) : null,
@@ -4526,6 +5114,7 @@ window.__ModuleLoader__.load({
4526
5114
  const [searchMode, setSearchMode] = React.useState('names')
4527
5115
  const [searchIgnored, setSearchIgnored] = React.useState(false)
4528
5116
  const [searchCase, setSearchCase] = React.useState(false)
5117
+ const [searchOptionsOpen, setSearchOptionsOpen] = React.useState(false)
4529
5118
  const [searchRetry, setSearchRetry] = React.useState(0)
4530
5119
  const revealPending = React.useRef(null)
4531
5120
  const filterRef = React.useRef(null)
@@ -4704,7 +5293,7 @@ window.__ModuleLoader__.load({
4704
5293
  const host = document.createElement('div')
4705
5294
  host.style.cssText = 'position:fixed;z-index:999999;pointer-events:auto'
4706
5295
  const box = document.createElement('div')
4707
- box.style.cssText = 'position:fixed;left:' + menu.x + 'px;top:' + menu.y + 'px;z-index:999999;background:var(--dsw-alias-bg-overlay,#1f1f23);border:1px solid var(--dsw-alias-border-l3,rgba(128,128,128,0.5));border-radius:8px;padding:4px;box-shadow:0 8px 24px rgba(0,0,0,0.4);min-width:170px;font-family:system-ui,sans-serif;color:var(--dsw-alias-label-primary,#e4e4e7)'
5296
+ box.style.cssText = 'position:fixed;left:' + menu.x + 'px;top:' + menu.y + 'px;z-index:999999;background:var(--dsw-alias-bg-layer-2,#1f1f23);border:1px solid var(--dsw-alias-border-l3,rgba(128,128,128,0.5));border-radius:8px;padding:4px;box-shadow:0 8px 24px rgba(0,0,0,0.4);min-width:170px;font-family:system-ui,sans-serif;color:var(--dsw-alias-label-primary,#e4e4e7)'
4708
5297
  const mkItem = (label, danger, fn) => {
4709
5298
  const d = document.createElement('div')
4710
5299
  d.textContent = label
@@ -4881,7 +5470,7 @@ window.__ModuleLoader__.load({
4881
5470
  style: base,
4882
5471
  title: entry.path,
4883
5472
  },
4884
- React.createElement('span', { className: 'dsh-rw-tree-chevron' }, React.createElement(WorkbenchIcon, { name: isOpen ? 'down' : 'right', size: 12 })),
5473
+ React.createElement('span', { className: 'dsh-rw-tree-chevron' }, React.createElement(Chevron, { dir: isOpen ? 'down' : 'right', size: 12 })),
4885
5474
  React.createElement('span', { style: { flexShrink: 0, color: T.label, display: 'inline-flex' } }, IconFolder(isOpen)),
4886
5475
  React.createElement('span', { style: { overflow: 'hidden', textOverflow: 'ellipsis', flex: 1, fontWeight: 500 } }, entry.name),
4887
5476
  copiedMark(entry.path),
@@ -4965,13 +5554,16 @@ window.__ModuleLoader__.load({
4965
5554
  filterOpen ? React.createElement('div', { className: 'dsh-rw-search-controls' },
4966
5555
  React.createElement('input', { ref: filterRef, type: 'search', className: 'dsh-rw-input', 'aria-label': tr('workspaceSearch.query'), placeholder: tr('workspaceSearch.placeholder'), value: filter, onChange: e => setFilter(e.target.value), onKeyDown: e => { if (e.isComposing) return; if (e.key === 'Escape') { e.stopPropagation(); setFilter(''); setFilterOpen(false) } else if (e.key === 'Enter') { e.preventDefault(); setSearchRetry(value => value + 1) } }, style: { ...inputS, boxSizing: 'border-box', width: '100%', fontSize: 12 } }),
4967
5556
  React.createElement('div', { className: 'dsh-rw-search-scope' },
4968
- React.createElement('select', { 'aria-label': tr('workspaceSearch.mode'), value: searchMode, onChange: e => setSearchMode(e.target.value), style: { ...inputS, width: 'auto', flex: 1, minWidth: 0, fontSize: 11, padding: '4px 6px' } }, ['names','files','directories','content'].map(value => React.createElement('option', { key: value, value }, tr(({ names: 'workspaceSearch.names', files: 'workspaceSearch.files', directories: 'workspaceSearch.directories', content: 'workspaceSearch.content' })[value])))),
4969
- React.createElement('details', { className: 'dsh-rw-search-options' },
4970
- React.createElement('summary', { 'aria-label': tr('workspaceSearch.options') }, searchCase || searchIgnored ? tr('workspaceSearch.activeOptions', { n: Number(searchCase) + Number(searchIgnored) }) : tr('workspaceSearch.options')),
4971
- React.createElement('div', { className: 'dsh-rw-search-option-body' },
4972
- React.createElement('label', {}, React.createElement('input', { type: 'checkbox', checked: searchCase, onChange: e => setSearchCase(e.target.checked) }), tr('workspaceSearch.caseSensitive')),
4973
- React.createElement('label', {}, React.createElement('input', { type: 'checkbox', checked: searchIgnored, onChange: e => setSearchIgnored(e.target.checked) }), tr('workspaceSearch.includeIgnored')),
4974
- React.createElement('p', {}, tr('workspaceSearch.ignoreHint')))))) : null,
5557
+ React.createElement(RwSelect, { value: searchMode, options: ['names', 'files', 'directories', 'content'].map(value => ({ value, label: tr(({ names: 'workspaceSearch.names', files: 'workspaceSearch.files', directories: 'workspaceSearch.directories', content: 'workspaceSearch.content' })[value]) })), onChange: (next) => setSearchMode(next), label: tr('workspaceSearch.mode'), size: 'sm', style: { flex: 1, minWidth: 0 } }),
5558
+ HostMenu ? React.createElement(HostMenu, { open: searchOptionsOpen, onClose: () => setSearchOptionsOpen(false), portal: true, align: 'end', selectedIds: [searchCase ? 'case' : null, searchIgnored ? 'ignored' : null].filter(Boolean),
5559
+ items: [{ id: 'case', label: tr('workspaceSearch.caseSensitive') }, { id: 'ignored', label: React.createElement('span', { title: tr('workspaceSearch.ignoreHint') }, tr('workspaceSearch.includeIgnored')) }],
5560
+ onSelect: (id) => { if (id === 'case') setSearchCase(value => !value); else setSearchIgnored(value => !value) },
5561
+ anchor: React.createElement('button', { type: 'button', className: 'dsh-rw-select', 'aria-haspopup': 'menu', 'aria-expanded': searchOptionsOpen, 'aria-label': tr('workspaceSearch.options'), onClick: () => setSearchOptionsOpen(value => !value), style: { height: 26, padding: '0 8px', gap: 4, fontSize: 11, flex: 'none' } },
5562
+ React.createElement('span', { className: 'dsh-rw-select-value' }, searchCase || searchIgnored ? tr('workspaceSearch.activeOptions', { n: Number(searchCase) + Number(searchIgnored) }) : tr('workspaceSearch.options')),
5563
+ React.createElement(Chevron, { dir: 'down', size: 12, className: 'dsh-rw-select-chevron' })) })
5564
+ : React.createElement('div', { style: { display: 'flex', gap: 10, alignItems: 'center', flexShrink: 0 } },
5565
+ React.createElement(RwCheckbox, { checked: searchCase, onChange: setSearchCase, label: tr('workspaceSearch.caseSensitive') }),
5566
+ React.createElement(RwCheckbox, { checked: searchIgnored, onChange: setSearchIgnored, title: tr('workspaceSearch.ignoreHint'), label: tr('workspaceSearch.includeIgnored') })))) : null,
4975
5567
  ),
4976
5568
  connectionState === 'interrupted' && root ? React.createElement('div', { role: 'status', style: { padding: '6px 10px', display: 'flex', gap: 6, fontSize: 11, color: T.warn, background: T.bg } },
4977
5569
  React.createElement('span', { style: { flex: 1 } }, tr('explorer.connection.interrupted')),
@@ -4993,7 +5585,7 @@ window.__ModuleLoader__.load({
4993
5585
  style: { display: 'flex', alignItems: 'center', gap: 6, padding: '5px 8px', paddingLeft: 6, borderRadius: 5, cursor: 'pointer', fontSize: 13, whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis', color: T.label, fontWeight: 600 },
4994
5586
  title: root,
4995
5587
  },
4996
- React.createElement('span', { className: 'dsh-rw-tree-chevron' }, React.createElement(WorkbenchIcon, { name: rootOpen ? 'down' : 'right', size: 12 })),
5588
+ React.createElement('span', { className: 'dsh-rw-tree-chevron' }, React.createElement(Chevron, { dir: rootOpen ? 'down' : 'right', size: 12 })),
4997
5589
  React.createElement('span', { style: { flexShrink: 0, color: T.label, display: 'inline-flex' } }, IconFolder(rootOpen)),
4998
5590
  React.createElement('span', { style: { overflow: 'hidden', textOverflow: 'ellipsis', flex: 1 } }, rootName || root),
4999
5591
  ),
@@ -5008,7 +5600,13 @@ window.__ModuleLoader__.load({
5008
5600
  menu && HostMenu ? React.createElement(HostMenu, {
5009
5601
  open: true,
5010
5602
  portal: true,
5603
+ // Pointer menu: a current host takes client coordinates (`anchorPoint`),
5604
+ // an older one the equivalent zero-size rect. `contextual` adds the
5605
+ // standard cursor clearance.
5606
+ anchor: null,
5607
+ anchorPoint: { x: menu.x, y: menu.y },
5011
5608
  getAnchorRect: () => ({ left: menu.x, top: menu.y, right: menu.x, bottom: menu.y, width: 0, height: 0 }),
5609
+ contextual: true,
5012
5610
  items: [
5013
5611
  { id: 'open', label: menu.isDir ? tr('explorer.menuExpand') : tr('explorer.menuOpen') },
5014
5612
  ...(!localWorkspaceSession(sessionId) ? [{ id: 'download', label: tr('explorer.menuDownload') }] : []),
@@ -5937,9 +6535,11 @@ window.__ModuleLoader__.load({
5937
6535
  } catch { return '' }
5938
6536
  }
5939
6537
  // The shipped workspace-files command opens kind "files". Route that
5940
- // intent before navigation, using the captured session's binding. Proven
5941
- // local projects now share this explorer; unknown roots and other kinds
5942
- // retain the host's original routing.
6538
+ // intent before navigation, using the captured session's binding. Only
6539
+ // sessions bound to a mirror can use this explorer: a plain local project
6540
+ // keeps the host's own explorer, which offers reveal/open-with, upload,
6541
+ // create and archive actions this one does not implement. Unknown roots
6542
+ // and other kinds retain the host's original routing.
5943
6543
  function routeWorkspaceFiles(sidebar) {
5944
6544
  const originals = new Map(), pending = new Map()
5945
6545
  let disposed = false
@@ -5959,7 +6559,7 @@ window.__ModuleLoader__.load({
5959
6559
  if (sessionIndex == null && sidebar.mounted?.getSnapshot?.() !== sessionId) return
5960
6560
  const remote = mirrorForCwd(sessionCwdFor(sessionId), MIRRORS.list)
5961
6561
  const next = args.slice()
5962
- next[kindIndex] = remote || localWorkspaceSession(sessionId) ? NATIVE_EXPLORER : kind
6562
+ next[kindIndex] = remote ? NATIVE_EXPLORER : kind
5963
6563
  return Reflect.apply(original, owner, next)
5964
6564
  }
5965
6565
  if (MIRRORS.loaded) return open()
@@ -6372,8 +6972,7 @@ window.__ModuleLoader__.load({
6372
6972
  React.createElement('span', { style: { color: T.ok } }, '+' + (change.additions || 0)), ' ', React.createElement('span', { style: { color: T.danger } }, '−' + (change.deletions || 0))) : null),
6373
6973
  change.diffs.length ? NativeDiffBlock
6374
6974
  ? React.createElement(NativeDiffBlock, { diffs: change.diffs, labels, maxLines: 12 })
6375
- : React.createElement('div', {}, change.diffs.map((diff, index) => React.createElement('details', { key: index, open: index === 0, className: 'dsh-rw-change-hunk' },
6376
- React.createElement('summary', {}, tr('change.hunk', { n: index + 1 })),
6975
+ : React.createElement('div', {}, change.diffs.map((diff, index) => React.createElement(RwDetails, { key: index, defaultOpen: index === 0, className: 'dsh-rw-change-hunk', title: tr('change.hunk', { n: index + 1 }) },
6377
6976
  React.createElement('div', { style: { color: T.muted, padding: '3px 10px', fontSize: 11 } }, tr('agent.before')),
6378
6977
  React.createElement('pre', { className: 'dsh-rw-agent-output', style: { color: T.danger, background: 'rgba(239,68,68,.06)' } }, diff.oldText ?? ''),
6379
6978
  React.createElement('div', { style: { color: T.muted, padding: '3px 10px', fontSize: 11 } }, tr('agent.after')),
@@ -6416,7 +7015,7 @@ window.__ModuleLoader__.load({
6416
7015
  }
6417
7016
  return React.createElement('section', { className: 'dsh-rw-agent-card', 'data-rw-agent-status': view.status, 'data-rw-agent-tool': props.toolName, style: { borderColor: attention ? T.danger : T.border, color: T.label } },
6418
7017
  React.createElement('button', { type: 'button', className: 'dsh-rw-agent-header', 'aria-expanded': !!open, 'aria-controls': bodyId, onClick: () => { setTouched(true); setOpen(!open) }, title: summary },
6419
- React.createElement(WorkbenchIcon, { name: open ? 'down' : 'right', size: 12 }),
7018
+ React.createElement(Chevron, { dir: open ? 'down' : 'right', size: 12 }),
6420
7019
  React.createElement(WorkbenchIcon, { name: props.toolName === 'rw_exec' ? 'terminal' : props.toolName === 'rw_search' ? 'search' : 'file' }),
6421
7020
  React.createElement('strong', { style: { flexShrink: 0, fontWeight: 500 } }, title),
6422
7021
  React.createElement('span', { className: 'dsh-rw-agent-summary', style: { color: T.muted } }, summary),
@@ -6519,6 +7118,17 @@ window.__ModuleLoader__.load({
6519
7118
  [data-rw-ide-navigation]{display:flex;gap:3px}
6520
7119
  [data-rw-ide-navigation] button[aria-pressed=true]{background:var(--dsw-alias-interactive-bg-hover,#eee);font-weight:600}
6521
7120
  @media(max-width:600px){[data-rw-ide-header]{gap:5px;padding:0 6px}[data-rw-ide-title]{display:none}[data-rw-ide-header] button{font-size:11px!important;padding:4px 6px!important}}
7121
+ /* macOS desktop (titleBarStyle hiddenInset) floats the native traffic lights at
7122
+ * x 16..68 over the window's top strip, which this shell's header covers. That
7123
+ * strip is 48px tall and its chrome sits on the y=25 centre line (28px controls
7124
+ * at top:11), so the header takes the same height and one pixel of top padding
7125
+ * (at 38px the title sat ~6px above the lights, and plain 48px centring left it
7126
+ * ~1px high). Pad the leading edge by the 88px the host keeps for its fullscreen
7127
+ * panels (lights end at 68, then 20px of air). Fullscreen hides the lights, so
7128
+ * the ordinary 38px header and 12px inset return. The selector out-specifies the
7129
+ * narrow-mode shorthand above, which stays in effect for its right inset. */
7130
+ html[data-platform='darwin'] [data-rw-ide-header]{height:48px;min-height:48px;padding-top:1px;padding-left:88px}
7131
+ html[data-platform='darwin'][data-fullscreen] [data-rw-ide-header]{height:38px;min-height:38px;padding-top:0;padding-left:12px}
6522
7132
  /* Reversible IDE-only header adapter for DSH 0.2.1/0.2.2.
6523
7133
  * Uses published slot/DOM markers rather than compiled class names.
6524
7134
  * Removing data-rw-ide-chat restores all native host styles automatically. */