dsh-remote-vs 0.23.0 → 0.25.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.
Files changed (81) hide show
  1. package/README.en.md +49 -15
  2. package/README.md +40 -14
  3. package/lib/client.js +45978 -43338
  4. package/lib/index.js +388 -90
  5. package/lib/p2-router-fs.js +1 -1
  6. package/lib/types/client/CodeEditor.d.ts +17 -0
  7. package/lib/types/client/EditorPane.d.ts +16 -5
  8. package/lib/types/client/FloatingPlaceholder.d.ts +16 -5
  9. package/lib/types/client/RemoteEditorView.d.ts +13 -10
  10. package/lib/types/client/RemoteRoot.d.ts +5 -5
  11. package/lib/types/client/SettingsHosts.d.ts +3 -0
  12. package/lib/types/client/TerminalSnippets.d.ts +36 -0
  13. package/lib/types/client/TerminalView.d.ts +1 -1
  14. package/lib/types/client/XTerm.d.ts +33 -0
  15. package/lib/types/client/api.d.ts +4 -1
  16. package/lib/types/client/auto-open-remote.d.ts +41 -0
  17. package/lib/types/client/editor-capability.d.ts +27 -0
  18. package/lib/types/client/i18n.d.ts +1 -1
  19. package/lib/types/client/store.d.ts +59 -4
  20. package/lib/types/client/terminal-input.d.ts +23 -0
  21. package/lib/types/client/terminal-snippets.d.ts +86 -0
  22. package/lib/types/client/use-remote-chat-target.d.ts +2 -0
  23. package/lib/types/client/view-settings.d.ts +40 -0
  24. package/lib/types/client/vsc/breadcrumb.d.ts +30 -0
  25. package/lib/types/client/vsc/editor-caret.d.ts +32 -0
  26. package/lib/types/client/vsc/editor-langs.d.ts +9 -0
  27. package/lib/types/client/vsc/editor-settings.d.ts +55 -0
  28. package/lib/types/client/vsc/image-preview.d.ts +36 -0
  29. package/lib/types/client/vsc/kit.d.ts +2 -0
  30. package/lib/types/client/vsc/terminal-clipboard.d.ts +15 -0
  31. package/lib/types/client/vsc/terminal-line.d.ts +25 -0
  32. package/lib/types/client/vsc/terminal-links.d.ts +62 -0
  33. package/lib/types/client/vsc/terminal-theme.d.ts +22 -0
  34. package/lib/types/client/vsc/terminal-writer.d.ts +52 -0
  35. package/lib/types/paths.d.ts +9 -0
  36. package/lib/types/pool.d.ts +25 -0
  37. package/lib/types/protocol.d.ts +35 -0
  38. package/lib/types/routes.d.ts +7 -0
  39. package/lib/types/terminal.d.ts +25 -1
  40. package/lib/types/view-settings.d.ts +26 -0
  41. package/lib/{worlds-DXdP4SMn.js → worlds-B7gEDBzC.js} +13 -1
  42. package/package.json +36 -36
  43. package/src/client/CodeEditor.tsx +54 -2
  44. package/src/client/EditorPane.tsx +485 -107
  45. package/src/client/FloatingPlaceholder.tsx +34 -5
  46. package/src/client/RemoteEditorView.tsx +14 -11
  47. package/src/client/RemoteRoot.tsx +20 -125
  48. package/src/client/SettingsHosts.tsx +81 -3
  49. package/src/client/TerminalSnippets.tsx +357 -0
  50. package/src/client/TerminalView.tsx +50 -1
  51. package/src/client/XTerm.tsx +228 -58
  52. package/src/client/api.ts +7 -0
  53. package/src/client/auto-open-remote.ts +439 -0
  54. package/src/client/editor-capability.ts +42 -0
  55. package/src/client/i18n.ts +158 -6
  56. package/src/client/index.tsx +30 -6
  57. package/src/client/store.tsx +165 -13
  58. package/src/client/terminal-input.ts +44 -0
  59. package/src/client/terminal-snippets.ts +216 -0
  60. package/src/client/use-remote-chat-target.ts +1 -1
  61. package/src/client/view-settings.ts +99 -0
  62. package/src/client/vsc/breadcrumb.tsx +251 -0
  63. package/src/client/vsc/editor-caret.ts +30 -0
  64. package/src/client/vsc/editor-langs.ts +20 -0
  65. package/src/client/vsc/editor-settings.ts +146 -0
  66. package/src/client/vsc/editor-theme.ts +4 -5
  67. package/src/client/vsc/image-preview.tsx +110 -0
  68. package/src/client/vsc/kit.tsx +20 -1
  69. package/src/client/vsc/terminal-clipboard.ts +19 -0
  70. package/src/client/vsc/terminal-line.ts +101 -0
  71. package/src/client/vsc/terminal-links.ts +166 -0
  72. package/src/client/vsc/terminal-theme.ts +71 -0
  73. package/src/client/vsc/terminal-writer.ts +112 -0
  74. package/src/client/vsc/vsc.css +687 -48
  75. package/src/index.ts +6 -0
  76. package/src/paths.ts +13 -0
  77. package/src/pool.ts +99 -27
  78. package/src/protocol.ts +45 -0
  79. package/src/routes.ts +47 -0
  80. package/src/terminal.ts +160 -6
  81. package/src/view-settings.ts +133 -0
@@ -70,6 +70,20 @@ export const DYNAMIC_KEYS = [
70
70
  'doctor.item.memory',
71
71
  'doctor.item.helpers',
72
72
  'doctor.item.sshd',
73
+ // Reached through the `fallback` wrappers in the ported editor chrome
74
+ // (`vsc/breadcrumb.tsx` / `vsc/image-preview.tsx`): the call site reads the
75
+ // dictionary value, or the inline English when the dictionary lacks it, so no
76
+ // literal translator call exists for the scanner to see. One block per
77
+ // component.
78
+ 'editor.crumbRoot',
79
+ 'editor.crumbLabel',
80
+ 'editor.crumbUp',
81
+ 'editor.crumbEmpty',
82
+ 'editor.imageHint',
83
+ 'editor.imageFitHint',
84
+ 'editor.imageFailedHint',
85
+ 'editor.imageTooLargeTitle',
86
+ 'editor.imageTooLargeHint',
73
87
  ] as const
74
88
 
75
89
  const zh: Record<string, string> = {
@@ -212,6 +226,25 @@ const zh: Record<string, string> = {
212
226
  'term.copy': '复制',
213
227
  'term.paste': '粘贴',
214
228
  'term.selectAll': '全选',
229
+ 'term.pathMissing': '终端里的这个路径在远端不存在,无法在目录中定位。',
230
+ 'term.pathOutside': '这个路径不在任何远端工作区内,目录树里没有它的位置。',
231
+ 'term.pathBlocked': '有未保存的编辑器标签:切换工作区会关闭它们,先处理再跳转。',
232
+ 'term.snippets': '常用指令',
233
+ 'term.snippetAdd': '新增常用指令',
234
+ 'term.snippetEdit': '修改常用指令',
235
+ 'term.snippetDelete': '删除',
236
+ 'term.snippetDeleteTitle': '删除这条常用指令?',
237
+ 'term.snippetName': '指令名',
238
+ 'term.snippetNamePlaceholder': '例如:推送 master',
239
+ 'term.snippetCommand': '指令内容',
240
+ 'term.snippetCommandPlaceholder': '例如:git push origin master',
241
+ 'term.snippetEmpty': '还没有常用指令:点「+」或按 Ctrl+B 新增。',
242
+ 'term.snippetInsertHint': '点一下粘贴到终端命令行(不发送)',
243
+ 'term.snippetFootHint': '点条目粘贴(不发送)· 拖拽排序 · Ctrl+B 新增',
244
+ 'term.snippetDragHint': '拖拽调整顺序(Alt+↑/↓ 也可)',
245
+ 'term.snippetNameRequired': '指令名不能为空。',
246
+ 'term.snippetCommandRequired': '指令内容不能为空。',
247
+ 'term.snippetNoTerminal': '当前没有已连接的终端,先新建一个终端。',
215
248
  'term.noHosts': '还没有主机,请先去「设置 → 远程主机」配置。',
216
249
  'tab.git': 'Git',
217
250
  'git.hint': '请选择远端路径为 git 仓库的工作区。',
@@ -225,6 +258,7 @@ const zh: Record<string, string> = {
225
258
  'common.loading': '加载中…',
226
259
  'common.ok': '确定',
227
260
  'common.cancel': '取消',
261
+ 'common.save': '保存',
228
262
  'flow.title': '添加工作区',
229
263
  'flow.local': '本地',
230
264
  'flow.remote': '远程',
@@ -248,6 +282,11 @@ const zh: Record<string, string> = {
248
282
  'route.aliasPath': '本地别名目录(原生工作区入口)',
249
283
  'settings.hosts': '远程主机',
250
284
  'settings.workspaces': '远程工作区',
285
+ 'viewSettings.title': '远程工作区面板',
286
+ 'viewSettings.autoOpen': '新建的远程会话自动打开远程工作区',
287
+ 'viewSettings.autoOpenHint': '只对远端工作区的会话生效,本机会话永不触发;每次页面加载对同一会话只判断一次,手动关掉的面板不会被重新打开。',
288
+ 'viewSettings.width': '远程工作区占比',
289
+ 'viewSettings.widthHint': '打开时右侧「远程工作台」面板占窗口宽度的比例(20%–70%,默认 45%)。',
251
290
  'plugin.version': '插件版本',
252
291
  'native.tab': '远程工作台',
253
292
  'native.guide.title': '远程工作台',
@@ -281,6 +320,11 @@ const zh: Record<string, string> = {
281
320
  'float.placeholderHint': '编辑器只有一份实例,已浮出到窗口中央;关闭悬浮窗或点「停靠」后回到这里。',
282
321
  'float.dockBack': '停靠回主界面',
283
322
  'float.unavailable': '当前宿主没有全帧悬浮层(shell.overlay),悬浮编辑器不可用。',
323
+ 'float.dockedElsewhere': '远程编辑器已停靠在侧边栏',
324
+ 'float.dockedElsewhereHint': '编辑器只有一份实例,当前在侧边栏里;点下面的按钮把它移到这里全宽显示。',
325
+ 'float.openHere': '在这里全宽打开',
326
+ 'float.centerElsewhere': '远程编辑器在会话区全宽显示',
327
+ 'float.centerElsewhereHint': '编辑器只有一份实例,当前在会话区的「远程编辑器」标签里;点下面的按钮把它收回侧边栏。',
284
328
  'files.rename': '重命名',
285
329
  'files.copy': '复制',
286
330
  'files.cut': '剪切',
@@ -528,14 +572,11 @@ const zh: Record<string, string> = {
528
572
  'history.expand': '展开详情面板',
529
573
  'history.restore': '还原列表布局',
530
574
  'history.diffToolbar': '补丁工具',
531
- 'editor.empty': '没有打开的文件。在资源管理器里双击文件,或在源代码管理里点击更改。',
532
- 'editor.saveHint': '保存',
533
575
  'editor.preview': '预览',
534
576
  'editor.source': '源码',
535
577
  'editor.imageFailed': '图片读取失败。',
536
578
  'editor.closeDirty': '有未保存的修改',
537
579
  'editor.discardClose': '放弃并关闭',
538
- 'editor.resizeHint': '拖拽调整面板 / 编辑器占比',
539
580
  'editor.openedIn': '已在顶部标签打开:',
540
581
  'editor.readTimeout': '读取超时(远端无响应)',
541
582
  'editor.conflictTitle': '远端文件已变更,已阻止覆盖',
@@ -560,6 +601,48 @@ const zh: Record<string, string> = {
560
601
  'editor.discardSwitch': '放弃修改并切换',
561
602
  'editor.switchTimeout': '等待切换确认超时,已取消本次切换(未保存的修改仍在);请重新选择工作区。',
562
603
  'editor.truncatedReadOnly': '文件超过可编辑上限(8MiB),只读呈现,不能保存。',
604
+ 'editor.tabsLabel': '打开的编辑器',
605
+ 'editor.diffSuffix': '(差异)',
606
+ 'editor.wrap': '自动换行',
607
+ 'editor.fontSmaller': '减小字号(Ctrl+滚轮)',
608
+ 'editor.fontLarger': '增大字号(Ctrl+滚轮)',
609
+ 'editor.openInCenter': '在会话区全宽打开',
610
+ 'editor.dockToSidebar': '收回侧边栏',
611
+ 'editor.binaryTitle': '二进制文件',
612
+ 'editor.dockEmptyTitle': '编辑器',
613
+ 'editor.dockEmptyHint': '从资源管理器或搜索结果中打开一个文件',
614
+ 'editor.centerEmptyTitle': '远程编辑器',
615
+ 'editor.centerEmptyHint': '从侧边栏的「资源管理器」或「搜索」打开一个文件,它会在这里全宽显示。',
616
+ 'editor.emptyShortcuts': 'Ctrl+S 保存 · Ctrl+F 查找 · Ctrl+滚轮缩放字号',
617
+ 'editor.statusSaving': '保存中…',
618
+ 'editor.statusClean': '已保存',
619
+ 'editor.statusLanguage': '语言',
620
+ 'editor.statusPosition': '行:列(1-based)',
621
+ 'editor.statusPositionValue': '行 {line},列 {column}',
622
+ 'editor.statusSelected': '已选字符数',
623
+ 'editor.statusSelectedValue': '已选 {count}',
624
+ 'editor.statusIndent': '缩进(按文件内容推测)',
625
+ 'editor.statusReadOnly': '只读',
626
+ 'editor.statusReadOnlyTitle': '只读(二进制、文件过大或连接断开)',
627
+ 'editor.statusWrapOn': '自动换行:开',
628
+ 'editor.statusWrapOff': '自动换行:关',
629
+ 'editor.statusWrapToggle': '切换自动换行',
630
+ 'editor.statusFont': '字号(Ctrl+滚轮可缩放)',
631
+ 'editor.statusSaved': '保存状态',
632
+ 'editor.statusEncoding': '文件编码(远端按 UTF-8 读写)',
633
+ 'editor.statusError': '错误',
634
+ 'editor.diffTitle': '差异',
635
+ 'editor.diffReadOnlyTitle': '统一 diff 以只读方式渲染',
636
+ 'editor.crumbRoot': '工作区',
637
+ 'editor.crumbLabel': '文件路径',
638
+ 'editor.crumbUp': '上一级',
639
+ 'editor.crumbEmpty': '空目录',
640
+ 'editor.imageHint': '点击切换适应窗口 / 原始大小',
641
+ 'editor.imageFitHint': '点击适应窗口',
642
+ 'editor.imageFailedHint': '文件可能已损坏,或不是受支持的图片格式。',
643
+ 'editor.imageTooLargeTitle': '图片过大',
644
+ 'editor.imageTooLargeHint': '大小 {size} KiB,超出读取上限,不提供预览。',
645
+ 'editor.switchToEdit': '切换为内容编辑(在编辑器里打开这个文件)',
563
646
  'git.notARepo': '当前远端工作区不是 git 仓库。',
564
647
  // -- session change panel (above the composer)
565
648
  'changes.title': '本次改动',
@@ -850,6 +933,25 @@ const en: Record<string, string> = {
850
933
  'term.copy': 'Copy',
851
934
  'term.paste': 'Paste',
852
935
  'term.selectAll': 'Select all',
936
+ 'term.pathMissing': 'That path does not exist on the remote host, so there is nothing to reveal.',
937
+ 'term.pathOutside': 'That path is outside every remote workspace, so the directory tree cannot show it.',
938
+ 'term.pathBlocked': 'Some editor tabs have unsaved changes; switching workspace would close them. Save or discard those first.',
939
+ 'term.snippets': 'Snippets',
940
+ 'term.snippetAdd': 'Add snippet',
941
+ 'term.snippetEdit': 'Edit snippet',
942
+ 'term.snippetDelete': 'Delete',
943
+ 'term.snippetDeleteTitle': 'Delete this snippet?',
944
+ 'term.snippetName': 'Name',
945
+ 'term.snippetNamePlaceholder': 'e.g. push master',
946
+ 'term.snippetCommand': 'Command',
947
+ 'term.snippetCommandPlaceholder': 'e.g. git push origin master',
948
+ 'term.snippetEmpty': 'No snippets yet: press "+" or Ctrl+B to add one.',
949
+ 'term.snippetInsertHint': 'Click to paste into the terminal (not sent)',
950
+ 'term.snippetFootHint': 'Click a row to paste (no Enter) · drag to reorder · Ctrl+B to add',
951
+ 'term.snippetDragHint': 'Drag to reorder (Alt+Up/Down works too)',
952
+ 'term.snippetNameRequired': 'The name cannot be empty.',
953
+ 'term.snippetCommandRequired': 'The command cannot be empty.',
954
+ 'term.snippetNoTerminal': 'No connected terminal: open one first.',
853
955
  'term.noHosts': 'No hosts yet. Configure one in Settings → Remote Hosts first.',
854
956
  'tab.git': 'Git',
855
957
  'git.hint': 'Pick a workspace whose remote path is a git repository.',
@@ -863,6 +965,7 @@ const en: Record<string, string> = {
863
965
  'common.loading': 'Loading…',
864
966
  'common.ok': 'OK',
865
967
  'common.cancel': 'Cancel',
968
+ 'common.save': 'Save',
866
969
  'flow.title': 'Add workspace',
867
970
  'flow.local': 'Local',
868
971
  'flow.remote': 'Remote',
@@ -886,6 +989,11 @@ const en: Record<string, string> = {
886
989
  'route.aliasPath': 'Local alias dir (native workspace entry)',
887
990
  'settings.hosts': 'Remote hosts',
888
991
  'settings.workspaces': 'Remote workspaces',
992
+ 'viewSettings.title': 'Remote workspace panel',
993
+ 'viewSettings.autoOpen': 'Open the remote workspace for a new remote session',
994
+ 'viewSettings.autoOpenHint': 'Only remote-workspace sessions trigger it — local sessions never do. Decided once per session per page load, so a panel you close stays closed.',
995
+ 'viewSettings.width': 'Remote workspace width',
996
+ 'viewSettings.widthHint': 'Share of the window width the “Remote Workspace” panel takes when this plugin opens it (20%–70%; 45% by default).',
889
997
  'plugin.version': 'Plugin version',
890
998
  'native.tab': 'Remote Workspace',
891
999
  'native.guide.title': 'Remote Workspace',
@@ -919,6 +1027,11 @@ const en: Record<string, string> = {
919
1027
  'float.placeholderHint': 'There is only one editor instance and it is out in the floating window; close that window or press Dock to bring it back here.',
920
1028
  'float.dockBack': 'Dock back',
921
1029
  'float.unavailable': 'This host has no frame-wide overlay slot (shell.overlay); the floating editor is unavailable.',
1030
+ 'float.dockedElsewhere': 'The remote editor is docked in the sidebar',
1031
+ 'float.dockedElsewhereHint': 'There is only one editor instance and it lives in the sidebar; press the button below to show it here at full width.',
1032
+ 'float.openHere': 'Open here at full width',
1033
+ 'float.centerElsewhere': 'The remote editor is shown full width in the conversation view',
1034
+ 'float.centerElsewhereHint': 'There is only one editor instance and it lives in the conversation view\'s "remote editor" tab; press the button below to dock it back into the sidebar.',
922
1035
  'files.rename': 'Rename',
923
1036
  'files.copy': 'Copy',
924
1037
  'files.cut': 'Cut',
@@ -1166,14 +1279,11 @@ const en: Record<string, string> = {
1166
1279
  'history.expand': 'Expand the details pane',
1167
1280
  'history.restore': 'Restore the list layout',
1168
1281
  'history.diffToolbar': 'Patch tools',
1169
- 'editor.empty': 'No open file. Double-click a file in the explorer, or click a change in source control.',
1170
- 'editor.saveHint': 'save',
1171
1282
  'editor.preview': 'Preview',
1172
1283
  'editor.source': 'Source',
1173
1284
  'editor.imageFailed': 'Could not read the image.',
1174
1285
  'editor.closeDirty': 'Unsaved changes',
1175
1286
  'editor.discardClose': 'Discard and close',
1176
- 'editor.resizeHint': 'Drag to resize panel / editor',
1177
1287
  'editor.openedIn': 'Opened in the top tab:',
1178
1288
  'editor.readTimeout': 'Read timed out (host not responding)',
1179
1289
  'editor.conflictTitle': 'Remote file changed — save blocked',
@@ -1198,6 +1308,48 @@ const en: Record<string, string> = {
1198
1308
  'editor.discardSwitch': 'Discard changes and switch',
1199
1309
  'editor.switchTimeout': 'Timed out waiting for the switch confirmation, so the switch was cancelled (unsaved edits are kept). Pick the workspace again.',
1200
1310
  'editor.truncatedReadOnly': 'File is larger than the editable limit (8MiB): read-only, saving is blocked.',
1311
+ 'editor.tabsLabel': 'Open editors',
1312
+ 'editor.diffSuffix': ' (diff)',
1313
+ 'editor.wrap': 'Word wrap',
1314
+ 'editor.fontSmaller': 'Smaller font (Ctrl+wheel)',
1315
+ 'editor.fontLarger': 'Larger font (Ctrl+wheel)',
1316
+ 'editor.openInCenter': 'Open full width in the conversation view',
1317
+ 'editor.dockToSidebar': 'Dock back to the sidebar',
1318
+ 'editor.binaryTitle': 'Binary file',
1319
+ 'editor.dockEmptyTitle': 'Editor',
1320
+ 'editor.dockEmptyHint': 'Open a file from the explorer or the search results',
1321
+ 'editor.centerEmptyTitle': 'Remote editor',
1322
+ 'editor.centerEmptyHint': 'Open a file from the sidebar Explorer or Search and it appears here at full width.',
1323
+ 'editor.emptyShortcuts': 'Ctrl+S save · Ctrl+F find · Ctrl+wheel zoom',
1324
+ 'editor.statusSaving': 'Saving…',
1325
+ 'editor.statusClean': 'Saved',
1326
+ 'editor.statusLanguage': 'Language',
1327
+ 'editor.statusPosition': 'Line:column (1-based)',
1328
+ 'editor.statusPositionValue': 'Line {line}, column {column}',
1329
+ 'editor.statusSelected': 'Selected characters',
1330
+ 'editor.statusSelectedValue': '{count} selected',
1331
+ 'editor.statusIndent': 'Indentation (guessed from the content)',
1332
+ 'editor.statusReadOnly': 'Read-only',
1333
+ 'editor.statusReadOnlyTitle': 'Read-only (binary, over the read cap, or the link is down)',
1334
+ 'editor.statusWrapOn': 'Word wrap: on',
1335
+ 'editor.statusWrapOff': 'Word wrap: off',
1336
+ 'editor.statusWrapToggle': 'Toggle word wrap',
1337
+ 'editor.statusFont': 'Font size (Ctrl+wheel to zoom)',
1338
+ 'editor.statusSaved': 'Save state',
1339
+ 'editor.statusEncoding': 'File encoding (the remote side is read and written as UTF-8)',
1340
+ 'editor.statusError': 'Error',
1341
+ 'editor.diffTitle': 'Diff',
1342
+ 'editor.diffReadOnlyTitle': 'A unified diff is rendered read-only',
1343
+ 'editor.crumbRoot': 'Workspace',
1344
+ 'editor.crumbLabel': 'File path',
1345
+ 'editor.crumbUp': 'Parent folder',
1346
+ 'editor.crumbEmpty': 'Empty directory',
1347
+ 'editor.imageHint': 'Click to toggle fit / actual size',
1348
+ 'editor.imageFitHint': 'Click to fit the window',
1349
+ 'editor.imageFailedHint': 'The file may be damaged or not a supported image format.',
1350
+ 'editor.imageTooLargeTitle': 'Image too large',
1351
+ 'editor.imageTooLargeHint': 'Size {size} KiB, above the read cap; no preview is provided.',
1352
+ 'editor.switchToEdit': 'Switch to content editing (open this file in the editor)',
1201
1353
  'git.notARepo': 'This remote workspace is not a git repository.',
1202
1354
  // -- session change panel (above the composer)
1203
1355
  'changes.title': 'Changed files',
@@ -18,7 +18,9 @@ import type {} from '@deepseek-ai/dsh-client-ui-renderer/client'
18
18
  import type {} from '@deepseek-ai/dsh-client-ui-settings/client'
19
19
  import type {} from '@deepseek-ai/dsh-client-ui-workspace/client'
20
20
  import './vsc/vsc.css'
21
+ import { installAutoOpenRemote } from './auto-open-remote.ts'
21
22
  import { RemoteDirectoryFlow } from './DirectoryFlow.tsx'
23
+ import { noteEditorSeatAvailable, noteEditorSeatGone } from './editor-capability.ts'
22
24
  import { FloatingEditorWindow } from './FloatingEditorWindow.tsx'
23
25
  import { installFloatTabTrigger } from './float-tab-trigger.ts'
24
26
  import { registerNativeExplorer } from './NativeExplorer.tsx'
@@ -113,6 +115,9 @@ export function apply(ctx: Context): void {
113
115
  } catch {
114
116
  return false
115
117
  }
118
+ // A tab exists: this page now has a seat that can render our editor, so
119
+ // file clicks may be intercepted (see `editor-capability.ts`).
120
+ noteEditorSeatAvailable()
116
121
  done = true
117
122
  stopTimer()
118
123
  return true
@@ -124,6 +129,8 @@ export function apply(ctx: Context): void {
124
129
  // Undefined when the registry is unavailable (older host): stay quiet,
125
130
  // directoryFlow + settings work standalone.
126
131
  disposeNative = registerNativeExplorer(ctx, nativeT) ?? undefined
132
+ // A registered native page is a seat too; `undefined` (no registry) is not.
133
+ if (disposeNative !== undefined) noteEditorSeatAvailable()
127
134
  }
128
135
  if (!goBetter()) {
129
136
  // Early-settle signal: once every profile entry has mounted, a still
@@ -161,6 +168,7 @@ export function apply(ctx: Context): void {
161
168
  } catch {
162
169
  // Ignore.
163
170
  }
171
+ if (disposeBetter !== undefined || disposeNative !== undefined) noteEditorSeatGone()
164
172
  }
165
173
  }, 'dsh-remote-vs: explorer surface (better tab preferred, native fallback)')
166
174
  // Phase 4: shadow the stock directory picker in both directory-flow holes
@@ -248,11 +256,21 @@ export function apply(ctx: Context): void {
248
256
  label: () => settingsT('settings.workspaces'),
249
257
  }, SettingsWorkspacesSection),
250
258
  ), 'dsh-remote-vs: settings workspaces')
251
- // The editor tab in the conversation view (right next to 对话 / 轨迹): at
252
- // full width the file editor and the side-by-side diff stop competing with
253
- // the tree for a narrow sidebar column. The store then flips the editor
254
- // surface to 'center' and the sidebar keeps the whole column for browsing.
255
- // A host without this slot keeps the old sidebar split (nothing disappears).
259
+ // The behaviour behind those settings' third block: open this plugin's page
260
+ // when a REMOTE session first appears, and size the right column. Frame-wide
261
+ // on purpose — the page it opens is usually closed, so no seat of ours is
262
+ // mounted when the trigger happens. All service reads are soft (a host without
263
+ // `sidebarRight` degrades to a no-op); see `auto-open-remote.ts` for how
264
+ // "remote" is proven and why the width goes through the drag handle.
265
+ ctx.effect(() => installAutoOpenRemote(ctx), 'dsh-remote-vs: auto-open remote workspace')
266
+ // The editor tab in the conversation view (right next to 对话 / 轨迹) is the
267
+ // OPTIONAL full-width seat: the DOCKED sidebar pane is the default one (the
268
+ // surface stays 'sidebar' here), and the editor's own "open in the
269
+ // conversation view" button moves the same buffer over when the user wants the
270
+ // extra width. Registering this slot must NOT flip the default — doing that is
271
+ // what made every file click jump away from the sidebar. A host without the
272
+ // slot simply keeps the single docked seat (nothing disappears, and the
273
+ // corresponding button is simply never the way to go anywhere).
256
274
  //
257
275
  // `conversation.view` is a runtime slot whose TYPE comes from
258
276
  // dsh-better-sidebar's declarations — and depending on that package for types
@@ -277,12 +295,18 @@ export function apply(ctx: Context): void {
277
295
  order: 30,
278
296
  label: () => viewT('view.editor'),
279
297
  }, () => <RemoteEditorView ctx={ctx} />))
298
+ // The full-width seat exists (even while another conversation tab is
299
+ // selected): together with the docked pane it makes this page able to show
300
+ // a remote file, which is what the click interceptor asks.
301
+ noteEditorSeatAvailable()
280
302
  } catch (error) {
281
303
  console.warn('[dsh-remote-vs] conversation.view registration failed:', error)
282
304
  return () => {}
283
305
  }
284
- setEditorSurface('center')
285
306
  return () => {
307
+ // The slot went away: if the editor was living in it, dock it back rather
308
+ // than leaving the store pointing at a surface that no longer exists.
309
+ noteEditorSeatGone()
286
310
  setEditorSurface('sidebar')
287
311
  try {
288
312
  dispose?.()
@@ -20,6 +20,7 @@ import type {
20
20
  RemoteHostSummary,
21
21
  RemoteRoutingStatus,
22
22
  RemoteWorkspaceBinding,
23
+ RemoteFileEntry,
23
24
  } from '../protocol.ts'
24
25
  import { api, RemoteApiError, configureTimeouts, fileReadTimeoutMs, gitTimeoutMs } from './api.ts'
25
26
  import { DEFAULT_GIT_TIMEOUT_MS, clientDeadlineFor } from '../timeouts.ts'
@@ -47,10 +48,17 @@ import {
47
48
  import { detectLang, makeT, type Lang } from './i18n.ts'
48
49
  import { effectiveEditorSurface, type EditorSurface } from './float-editor.ts'
49
50
  import { captureLiveEditorPosition, captureLiveEditorText, isLiveEditorDirty, isLiveEditorFor, markLiveEditorSaved } from './live-editor.ts'
51
+ import { editorSeatCount } from './editor-capability.ts'
50
52
  import { planWorkspaceFollow, selectionIsSessionBinding, type WorkspaceFollowDecision } from './remote-file-open-target.ts'
51
53
  import { revealViewTab } from './reveal.ts'
52
54
  import { connectionStateOf, isConnectionFailure } from './connection.ts'
53
55
  import { confirmDialog, isHtmlFile, isImageFile, isMarkdownFile, toast } from './vsc/kit.tsx'
56
+ import {
57
+ isWithinRoot,
58
+ normalizeRemotePath,
59
+ parentDirectoryOf,
60
+ resolutionCandidates,
61
+ } from './vsc/terminal-links.ts'
54
62
 
55
63
  /** One editor tab (code file, preview or diff). */
56
64
  export interface EditorTab {
@@ -632,6 +640,17 @@ export interface ExplorerValue {
632
640
  openFloatingEditor: () => void
633
641
  /** 停靠回主界面(底层的中心视图或侧栏表面)。 */
634
642
  dockFloatingEditor: () => void
643
+ /**
644
+ * Show the SAME editor in the conversation-view tab (full width).
645
+ *
646
+ * The docked sidebar pane is the default seat; the centre tab is an optional
647
+ * second seat for the same buffer. Flipping the surface unmounts one mount and
648
+ * mounts the other, so the live buffer is captured first (see
649
+ * `captureLiveBuffer`).
650
+ */
651
+ openEditorInCenter: () => void
652
+ /** Dock the editor back into the sidebar (the reverse of `openEditorInCenter`). */
653
+ dockEditorSidebar: () => void
635
654
  openDiff: (rel: string, staged: boolean, untracked?: boolean) => void
636
655
  openCommitFile: (hash: string, rel: string, origPath?: string) => void
637
656
  activateTab: (id: string) => void
@@ -768,6 +787,8 @@ function build(): ExplorerValue {
768
787
  openDiffInFloatEditor,
769
788
  openFloatingEditor,
770
789
  dockFloatingEditor,
790
+ openEditorInCenter,
791
+ dockEditorSidebar,
771
792
  openDiff,
772
793
  openCommitFile,
773
794
  activateTab,
@@ -1176,6 +1197,76 @@ export function revealInExplorer(dir: string): void {
1176
1197
  setView('explorer')
1177
1198
  }
1178
1199
 
1200
+ /** Outcome of one terminal path click (see `jumpToTerminalPath`). */
1201
+ export type TerminalPathJump = 'revealed' | 'missing' | 'outside' | 'blocked'
1202
+
1203
+ /**
1204
+ * Jump from a path printed in the TERMINAL to that folder in the directory tree
1205
+ * (Ctrl+Click in the terminal; the wiring lives in `XTerm`/`TerminalView`).
1206
+ *
1207
+ * The token is only text, so the absolute path is decided by a short candidate
1208
+ * chain (`vsc/terminal-links.ts`) and then CONFIRMED against the host: the first
1209
+ * candidate that exists wins, and its directory (the path itself for a folder,
1210
+ * its parent for a file) is revealed in the tree. A hit outside every binding on
1211
+ * that host is reported instead of silently jumping somewhere unrelated — the
1212
+ * tree can only show what a binding covers.
1213
+ *
1214
+ * @param alias - host the terminal TAB is connected to (not the panel's host
1215
+ * picker: a tab can outlive a picker change).
1216
+ * @param token - the path as printed in the terminal.
1217
+ * @param hints - shell cwd (OSC 7) and remote home, for relative/`~` tokens.
1218
+ */
1219
+ export async function jumpToTerminalPath(
1220
+ alias: string,
1221
+ token: string,
1222
+ hints: { home?: string; cwd?: string } = {},
1223
+ ): Promise<TerminalPathJump> {
1224
+ if (alias === '' || token === '') return 'missing'
1225
+ const bindings = state.workspaces.filter(item => item.alias === alias)
1226
+ const roots = bindings
1227
+ .map(item => item.remotePath)
1228
+ .sort((left, right) => right.length - left.length)
1229
+ const candidates = resolutionCandidates(token, {
1230
+ ...(hints.home === undefined ? {} : { home: hints.home }),
1231
+ ...(hints.cwd === undefined ? {} : { cwd: hints.cwd }),
1232
+ roots,
1233
+ })
1234
+ if (candidates.length === 0) {
1235
+ toast(t('term.pathOutside'), true)
1236
+ return 'outside'
1237
+ }
1238
+ for (const candidate of candidates) {
1239
+ let entry: RemoteFileEntry
1240
+ try {
1241
+ // Bounded: a dead link must not leave the click hanging with no answer.
1242
+ entry = await withDeadline(
1243
+ api.fileOp.stat(alias, candidate),
1244
+ clientDeadlineFor(fileReadTimeoutMs()),
1245
+ t('editor.readTimeout'),
1246
+ )
1247
+ } catch {
1248
+ // Not this candidate (or the link hiccuped): try the next one.
1249
+ continue
1250
+ }
1251
+ const dir = entry.isDir ? normalizeRemotePath(candidate) : parentDirectoryOf(candidate)
1252
+ const binding = bindings.find(item => isWithinRoot(dir, item.remotePath))
1253
+ if (binding === undefined) {
1254
+ // The path exists but no workspace covers it: the tree has nowhere to show
1255
+ // it, and moving the panel somewhere unrelated would be a lie.
1256
+ toast(t('term.pathOutside'), true)
1257
+ return 'outside'
1258
+ }
1259
+ if (state.workspaceId !== binding.id && !selectWorkspaceAuto(binding.id)) {
1260
+ toast(t('term.pathBlocked'), true)
1261
+ return 'blocked'
1262
+ }
1263
+ revealInExplorer(dir)
1264
+ return 'revealed'
1265
+ }
1266
+ toast(t('term.pathMissing'), true)
1267
+ return 'missing'
1268
+ }
1269
+
1179
1270
  /** Monotonic ticket for "open a terminal here" requests. */
1180
1271
  let terminalSeq = 0
1181
1272
 
@@ -2002,16 +2093,27 @@ function upsertTab(tab: EditorTab): void {
2002
2093
  let revealRetry: ReturnType<typeof setTimeout> | undefined
2003
2094
 
2004
2095
  /**
2005
- * Bring the editor into view. On the 'center' surface the shell renders only
2006
- * the selected conversation view, so a file opened from the sidebar must also
2007
- * select that tab — otherwise the click looks like a no-op. When the tab
2008
- * cannot be found (another host build, or the shell's markup changed) the user
2009
- * is told where the file opened instead of being left guessing.
2096
+ * Bring the editor into view.
2097
+ *
2098
+ * The docked surface (the default) is a FULL-COLUMN rail page, so opening a file
2099
+ * switches the column to the editor (the tree stays one click away on the rail)
2100
+ * — without this the click looks like a no-op. Closing its last file switches
2101
+ * back to the directory (see `closeTab`).
2102
+ *
2103
+ * On the 'center' surface the shell renders only the selected conversation
2104
+ * view, so a file opened from the sidebar must also select that tab. When the
2105
+ * tab cannot be found (another host build, or the shell's markup changed) the
2106
+ * user is told where the file opened instead of being left guessing.
2010
2107
  */
2011
2108
  function revealEditor(): void {
2012
- // While the editor floats, the shell tab has no editor to reveal: the file
2013
- // just went into the floating window (which is already on screen).
2014
- if (effectiveEditorSurface(state.editorSurface, state.floatOpen) !== 'center') return
2109
+ const surface = effectiveEditorSurface(state.editorSurface, state.floatOpen)
2110
+ // While the editor floats, neither docked surface has an editor to reveal:
2111
+ // the file just went into the floating window (which is already on screen).
2112
+ if (surface === 'float') return
2113
+ if (surface === 'sidebar') {
2114
+ if (state.view !== 'editor') setView('editor')
2115
+ return
2116
+ }
2015
2117
  const label = t('view.editor')
2016
2118
  // A newer open supersedes the pending retry: arming a second one left the
2017
2119
  // timers piling up one per opened file (each doing its own full-document tab
@@ -2267,13 +2369,18 @@ export function openRemoteFileInBinding(
2267
2369
  * Whether the plugin's own rich editor is the place a remote file click should
2268
2370
  * land (the click interceptor's gate, see `remote-file-open.ts`).
2269
2371
  *
2270
- * The centre conversation view is the normal case; while the editor floats it
2271
- * is the floating window instead — the file still belongs in OUR editor, not in
2272
- * the host's native preview. On the sidebar-fallback layout (`sidebar`) the
2273
- * interceptor stays off, exactly as before this feature.
2372
+ * True while at least one SEAT exists that can render our editor in this page
2373
+ * (see `editor-capability.ts`): the docked sidebar pane is the default seat and
2374
+ * the conversation-view tab is the optional second one. "Registered" rather than
2375
+ * "currently mounted" on purpose — the panels are lazy/keep-alive, so a fresh
2376
+ * page has no mounted pane until the rail visits it, and asking for a mount
2377
+ * would send the first click to the host's native preview, which cannot resolve
2378
+ * a remote path at all. A host where no seat registers falls back to that native
2379
+ * preview, which is the only thing it can do. Unknown bindings are still
2380
+ * answered by `openRemoteFileInBinding` returning false.
2274
2381
  */
2275
2382
  export function isEditorTakeoverActive(): boolean {
2276
- return effectiveEditorSurface(state.editorSurface, state.floatOpen) !== 'sidebar'
2383
+ return editorSeatCount() > 0
2277
2384
  }
2278
2385
 
2279
2386
  /** Open (or focus) a working-tree diff of one repository path. */
@@ -2410,6 +2517,16 @@ export function closeTab(id: string): void {
2410
2517
  ? (next[Math.min(index, next.length - 1)]?.id ?? next[next.length - 1]?.id)
2411
2518
  : state.activeTabId
2412
2519
  patch({ tabs: next, activeTabId })
2520
+ // Closing the LAST file returns to the directory: an empty editor page (or a
2521
+ // full-width tab with nothing in it) is where a reader has no next action.
2522
+ // Dirty tabs still go through the pane's confirmation before they get here.
2523
+ if (next.length === 0) {
2524
+ // The centre seat has nowhere to go once its last tab is gone: dock back and
2525
+ // show the directory. On the docked surface the editor IS the rail page, so
2526
+ // that page hands the column back to the explorer.
2527
+ if (state.editorSurface === 'center') setEditorSurface('sidebar')
2528
+ if (state.view === 'editor') setView('explorer')
2529
+ }
2413
2530
  }
2414
2531
 
2415
2532
  export function updateTab(id: string, next: Partial<EditorTab>): void {
@@ -2759,6 +2876,41 @@ export function setEditorSurface(surface: 'center' | 'sidebar'): void {
2759
2876
  patch({ editorSurface: surface })
2760
2877
  }
2761
2878
 
2879
+ /**
2880
+ * Move the editor into the conversation-view tab (full width).
2881
+ *
2882
+ * The live buffer is captured BEFORE the surface flips: the flip unmounts the
2883
+ * mount that owns it (see `captureLiveBuffer`'s header), and without that
2884
+ * handoff the edits typed since the load would disappear. The host tab is then
2885
+ * selected so the user actually sees where the editor went.
2886
+ */
2887
+ export function openEditorInCenter(): void {
2888
+ if (state.editorSurface === 'center') {
2889
+ revealEditor()
2890
+ return
2891
+ }
2892
+ captureLiveBuffer()
2893
+ patch({ editorSurface: 'center' })
2894
+ revealEditor()
2895
+ }
2896
+
2897
+ /**
2898
+ * Dock the editor back into the sidebar (the reverse of `openEditorInCenter`).
2899
+ *
2900
+ * The docked pane is the default seat and owns the whole sidebar column, so
2901
+ * `revealEditor` switches the rail to the editor page (from whatever view was
2902
+ * showing) and the tree stays one click away.
2903
+ */
2904
+ export function dockEditorSidebar(): void {
2905
+ if (state.editorSurface === 'sidebar') {
2906
+ revealEditor()
2907
+ return
2908
+ }
2909
+ captureLiveBuffer()
2910
+ patch({ editorSurface: 'sidebar' })
2911
+ revealEditor()
2912
+ }
2913
+
2762
2914
  /**
2763
2915
  * Record that the host's frame-wide overlay slot actually rendered the
2764
2916
  * floating window host (see `FloatingEditorWindow`).
@@ -0,0 +1,44 @@
1
+ /**
2
+ * One registry for "type this into that terminal's command line".
3
+ *
4
+ * The snippet panel lives in the terminal's HEADER while the xterm instance is
5
+ * owned by a child component, so the panel needs an imperative handle without
6
+ * lifting xterm state into React (a re-render per keystroke would be absurd).
7
+ * Each mounted `XTerm` registers a paste function under its tab id and removes
8
+ * it on unmount; the panel asks for the ACTIVE tab.
9
+ *
10
+ * Deliberately NOT exported as a React hook: callers are event handlers inside
11
+ * a portal, not render code.
12
+ */
13
+
14
+ /** Registered terminals: tab id → "paste this text, do not press Enter". */
15
+ const pasters = new Map<string, (text: string) => void>()
16
+
17
+ /** Register one mounted terminal; returns the unregister. */
18
+ export function registerTerminalPaste(tabId: string, paste: (text: string) => void): () => void {
19
+ pasters.set(tabId, paste)
20
+ return () => {
21
+ // Only remove OUR entry: a remount (reconnect) registers again under the
22
+ // same id and its cleanup must not delete the newcomer.
23
+ if (pasters.get(tabId) === paste) pasters.delete(tabId)
24
+ }
25
+ }
26
+
27
+ /**
28
+ * Insert one command into the given terminal without sending it.
29
+ *
30
+ * @returns false when that tab has no mounted terminal any more (a closed tab, a
31
+ * panel that is not rendered) — the caller says so instead of pretending.
32
+ */
33
+ export function pasteIntoTerminal(tabId: string | undefined, text: string): boolean {
34
+ if (tabId === undefined || text === '') return false
35
+ const paste = pasters.get(tabId)
36
+ if (paste === undefined) return false
37
+ paste(text)
38
+ return true
39
+ }
40
+
41
+ /** How many terminals are registered (diagnostics; also handy for the gate). */
42
+ export function registeredTerminalCount(): number {
43
+ return pasters.size
44
+ }