dsh-remote-vs 0.25.0 → 0.26.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/README.en.md +11 -7
- package/README.md +10 -7
- package/THIRD-PARTY-NOTICES.md +188 -0
- package/lib/client.js +6512 -79961
- package/lib/index.js +1283 -992
- package/lib/p2-router-fs.js +1 -1
- package/lib/types/client/CodeEditor.d.ts +8 -0
- package/lib/types/client/RemoteExplorer.d.ts +53 -0
- package/lib/types/client/api.d.ts +37 -2
- package/lib/types/client/changes/review-state.d.ts +19 -0
- package/lib/types/client/connection.d.ts +16 -0
- package/lib/types/client/request-gate.d.ts +110 -0
- package/lib/types/client/scm/DiffView.d.ts +45 -7
- package/lib/types/client/scm/actions.d.ts +31 -3
- package/lib/types/client/store.d.ts +53 -0
- package/lib/types/client/vsc/FindWidget.d.ts +6 -0
- package/lib/types/client/vsc/change-marks.d.ts +16 -6
- package/lib/types/client/vsc/editor-keymap.d.ts +35 -1
- package/lib/types/client/vsc/kit.d.ts +11 -0
- package/lib/types/client/vsc/save-shortcut.d.ts +21 -0
- package/lib/types/client/vsc/terminal-theme.d.ts +28 -2
- package/lib/types/forward.d.ts +12 -0
- package/lib/types/fs-ops.d.ts +42 -0
- package/lib/types/http.d.ts +2 -0
- package/lib/types/keygen.d.ts +9 -0
- package/lib/types/monitor.d.ts +8 -0
- package/lib/types/notices.d.ts +16 -1
- package/lib/types/p2/helper-rpc.d.ts +45 -0
- package/lib/types/routes.d.ts +2 -0
- package/lib/types/store.d.ts +7 -0
- package/lib/types/terminal.d.ts +8 -0
- package/lib/types/view-settings.d.ts +5 -0
- package/lib/{worlds-B7gEDBzC.js → worlds-RG8K5eom.js} +113 -15
- package/package.json +2 -1
- package/src/client/CodeEditor.tsx +151 -8
- package/src/client/DirectoryFlow.tsx +16 -0
- package/src/client/DoctorPanel.tsx +70 -7
- package/src/client/EditorPane.tsx +63 -14
- package/src/client/HostsView.tsx +12 -3
- package/src/client/RemoteDirectoryPicker.tsx +12 -0
- package/src/client/RemoteExplorer.tsx +929 -40
- package/src/client/RemoteRoot.tsx +147 -22
- package/src/client/SearchView.tsx +8 -0
- package/src/client/TerminalSnippets.tsx +83 -8
- package/src/client/api.ts +106 -13
- package/src/client/changes/ChangesDock.tsx +188 -6
- package/src/client/changes/changes.css +10 -3
- package/src/client/changes/review-state.ts +34 -0
- package/src/client/connection.ts +29 -0
- package/src/client/downloads.ts +49 -4
- package/src/client/i18n.ts +82 -8
- package/src/client/request-gate.ts +221 -0
- package/src/client/scm/CommitPane.tsx +20 -2
- package/src/client/scm/DiffView.tsx +343 -117
- package/src/client/scm/HistoryPanel.tsx +23 -2
- package/src/client/scm/RepoPicker.tsx +1 -1
- package/src/client/scm/ScmPanel.tsx +391 -87
- package/src/client/scm/actions.ts +95 -12
- package/src/client/store.tsx +372 -9
- package/src/client/ui.tsx +4 -0
- package/src/client/vsc/FindWidget.tsx +24 -9
- package/src/client/vsc/breadcrumb.tsx +91 -3
- package/src/client/vsc/change-marks.ts +93 -44
- package/src/client/vsc/editor-keymap.ts +59 -1
- package/src/client/vsc/file-icons.tsx +17 -3
- package/src/client/vsc/kit.tsx +26 -9
- package/src/client/vsc/save-shortcut.ts +47 -1
- package/src/client/vsc/terminal-theme.ts +44 -18
- package/src/client/vsc/vsc.css +411 -153
- package/src/forward.ts +47 -9
- package/src/fs-ops.ts +124 -4
- package/src/git-ops.ts +20 -3
- package/src/http.ts +35 -4
- package/src/keygen.ts +55 -4
- package/src/monitor.ts +13 -0
- package/src/notices.ts +23 -1
- package/src/p2/helper-rpc.ts +113 -7
- package/src/p2/worlds.ts +14 -1
- package/src/routes.ts +212 -43
- package/src/sftp.ts +51 -14
- package/src/store.ts +10 -0
- package/src/terminal.ts +73 -26
- package/src/view-settings.ts +50 -10
- package/lib/types/client/Dialog.d.ts +0 -14
- package/src/client/Dialog.tsx +0 -76
package/src/client/i18n.ts
CHANGED
|
@@ -210,6 +210,9 @@ const zh: Record<string, string> = {
|
|
|
210
210
|
'files.referenceFile': '@文件',
|
|
211
211
|
'files.addToConversation': '添加到对话',
|
|
212
212
|
'editor.save': '保存',
|
|
213
|
+
'editor.gotoLine': '转到行',
|
|
214
|
+
'editor.gotoLineText': '跳转到行(共 {total} 行):',
|
|
215
|
+
'editor.gotoLineInvalid': '行号无效',
|
|
213
216
|
'editor.saving': '保存中…',
|
|
214
217
|
'editor.saved': '已保存',
|
|
215
218
|
'editor.unsaved': '● 未保存',
|
|
@@ -269,7 +272,7 @@ const zh: Record<string, string> = {
|
|
|
269
272
|
'flow.mkdir': '新建文件夹',
|
|
270
273
|
'flow.mkdirName': '文件夹名',
|
|
271
274
|
'flow.create': '创建',
|
|
272
|
-
'flow.noHosts': '还没有主机。先去「设置 →
|
|
275
|
+
'flow.noHosts': '还没有主机。先去「设置 → 远程主机」配置,再回来添加远程工作区。',
|
|
273
276
|
'flow.retry': '重试',
|
|
274
277
|
'flow.truncated': '条目过多,仅显示前一部分。',
|
|
275
278
|
'route.mode': '路由模式',
|
|
@@ -299,10 +302,14 @@ const zh: Record<string, string> = {
|
|
|
299
302
|
'files.created': '已创建',
|
|
300
303
|
'files.renamed': '已重命名',
|
|
301
304
|
'files.deleted': '已删除',
|
|
305
|
+
'files.openInTerminal': '在终端中打开',
|
|
302
306
|
'files.items': '个项目',
|
|
303
307
|
'files.deleteTitle': '删除',
|
|
304
308
|
'files.delete': '删除',
|
|
305
309
|
'files.deleteConfirm': '确定删除 {target} 吗?此操作在远端不可撤销。',
|
|
310
|
+
'files.deleting': '删除中 {done}/{total} · {name}',
|
|
311
|
+
'files.deleteCancel': '取消删除',
|
|
312
|
+
'files.deleteCancelled': '已取消删除:已删除 {removed} 项,{left} 项未处理。',
|
|
306
313
|
'files.open': '打开',
|
|
307
314
|
'files.openAsText': '以文本打开',
|
|
308
315
|
'files.openInFloat': '在悬浮编辑器中打开',
|
|
@@ -392,7 +399,7 @@ const zh: Record<string, string> = {
|
|
|
392
399
|
'scm.commit': '提交',
|
|
393
400
|
'scm.committing': '提交中',
|
|
394
401
|
'scm.commitPlaceholder': '提交变更内容(Ctrl+Enter 提交)',
|
|
395
|
-
'scm.commitHint': '
|
|
402
|
+
'scm.commitHint': '先暂存更改,再提交(提交框内按 Ctrl+Enter 可直接提交)',
|
|
396
403
|
'scm.commitNeedsStage': '还没有暂存的更改 — 先点击 + 暂存文件。',
|
|
397
404
|
'scm.amend': '修改上次提交信息',
|
|
398
405
|
'scm.amendTitle': '修改上次提交',
|
|
@@ -475,6 +482,17 @@ const zh: Record<string, string> = {
|
|
|
475
482
|
'scm.syncText': '将执行 git pull 然后 git push。',
|
|
476
483
|
'scm.syncDone': '同步完成',
|
|
477
484
|
'scm.branches': '分支',
|
|
485
|
+
'scm.initRepo': '初始化仓库',
|
|
486
|
+
'scm.initRepoText': '将在 {path} 初始化一个 Git 仓库。',
|
|
487
|
+
'scm.initRepoDone': '仓库已初始化',
|
|
488
|
+
'scm.renameBranch': '重命名分支',
|
|
489
|
+
'scm.renameBranchText': '将分支 {branch} 重命名为:',
|
|
490
|
+
'scm.renameBranchInvalid': '分支名不能为空或与原分支相同',
|
|
491
|
+
'scm.renameBranchDone': '分支已重命名',
|
|
492
|
+
'scm.setRemoteUrl': '修改远程 URL',
|
|
493
|
+
'scm.setRemoteUrlText': '修改远程 {name} 的 URL:',
|
|
494
|
+
'scm.remoteUrlEmpty': '远程 URL 不能为空',
|
|
495
|
+
'scm.setRemoteUrlDone': '远程 URL 已更新',
|
|
478
496
|
'scm.remotes': '远程',
|
|
479
497
|
'scm.newBranch': '新分支名',
|
|
480
498
|
'scm.create': '创建',
|
|
@@ -613,7 +631,7 @@ const zh: Record<string, string> = {
|
|
|
613
631
|
'editor.dockEmptyHint': '从资源管理器或搜索结果中打开一个文件',
|
|
614
632
|
'editor.centerEmptyTitle': '远程编辑器',
|
|
615
633
|
'editor.centerEmptyHint': '从侧边栏的「资源管理器」或「搜索」打开一个文件,它会在这里全宽显示。',
|
|
616
|
-
'editor.emptyShortcuts': 'Ctrl+S 保存 · Ctrl+F 查找 · Ctrl+滚轮缩放字号',
|
|
634
|
+
'editor.emptyShortcuts': 'Ctrl+S 保存 · Ctrl+F 查找 · Ctrl+P 快速打开 · Ctrl+滚轮缩放字号',
|
|
617
635
|
'editor.statusSaving': '保存中…',
|
|
618
636
|
'editor.statusClean': '已保存',
|
|
619
637
|
'editor.statusLanguage': '语言',
|
|
@@ -643,9 +661,21 @@ const zh: Record<string, string> = {
|
|
|
643
661
|
'editor.imageTooLargeTitle': '图片过大',
|
|
644
662
|
'editor.imageTooLargeHint': '大小 {size} KiB,超出读取上限,不提供预览。',
|
|
645
663
|
'editor.switchToEdit': '切换为内容编辑(在编辑器里打开这个文件)',
|
|
664
|
+
// -- 编辑器内查找(vsc/FindWidget.tsx:输入框与三个开关/前后跳转/关闭)
|
|
665
|
+
'find.placeholder': '查找',
|
|
666
|
+
'find.caseSensitive': '区分大小写(Aa)',
|
|
667
|
+
'find.wholeWord': '全字匹配(ab_)',
|
|
668
|
+
'find.regexp': '正则表达式(.*)',
|
|
669
|
+
'find.noResults': '无结果',
|
|
670
|
+
'find.prev': '上一个(Shift+Enter)',
|
|
671
|
+
'find.next': '下一个(Enter)',
|
|
672
|
+
'find.close': '关闭(Esc)',
|
|
646
673
|
'git.notARepo': '当前远端工作区不是 git 仓库。',
|
|
647
674
|
// -- session change panel (above the composer)
|
|
648
675
|
'changes.title': '本次改动',
|
|
676
|
+
'changes.onlyUnreviewed': '只看未审阅',
|
|
677
|
+
'changes.nextUnreviewed': '下一个未审阅',
|
|
678
|
+
'changes.allReviewed': '全部已审阅',
|
|
649
679
|
'changes.toggle': '展开或收起本次会话的改动文件',
|
|
650
680
|
'changes.empty': '本会话还没有改动文件。',
|
|
651
681
|
'changes.pending': '正在统计…',
|
|
@@ -685,6 +715,13 @@ const zh: Record<string, string> = {
|
|
|
685
715
|
'changes.stale': '位置已过期',
|
|
686
716
|
'changes.staleHint': '编辑器内容已改动,改动位置可能不准。点击列表里的文件重新计算。',
|
|
687
717
|
'changes.noWorkspace': '找不到该主机对应的工作区,无法打开文件。',
|
|
718
|
+
// -- 编辑器 gutter 标记与删除 chip(vsc/change-marks.ts 的 title / aria-label)
|
|
719
|
+
'changes.markAdd': '新增行',
|
|
720
|
+
'changes.markMod': '修改行',
|
|
721
|
+
'changes.markDel': '删除行',
|
|
722
|
+
'changes.deletedChip': '已删除的内容',
|
|
723
|
+
'changes.deletedBlock': '已删除的整块内容({count} 行)',
|
|
724
|
+
'changes.deletedLines': '−{count} 行已删除',
|
|
688
725
|
// -- 悬浮在改动行上撤销这一处改动
|
|
689
726
|
'changes.undoAction': '撤销这处改动',
|
|
690
727
|
'changes.undoActionDelete': '撤销这处删除',
|
|
@@ -822,7 +859,7 @@ const en: Record<string, string> = {
|
|
|
822
859
|
'hosts.deleted': '{alias}: deleted',
|
|
823
860
|
'hosts.saved': '{alias}: saved',
|
|
824
861
|
'hosts.helperPushed': '{alias}: pushed remote helper {version} automatically',
|
|
825
|
-
'hosts.imported': 'Imported {count}
|
|
862
|
+
'hosts.imported': 'Imported hosts ({count})',
|
|
826
863
|
'hosts.importedSkipped': '; skipped: {list}',
|
|
827
864
|
'form.alias': 'Alias',
|
|
828
865
|
'form.unchanged': 'leave empty to keep',
|
|
@@ -917,6 +954,9 @@ const en: Record<string, string> = {
|
|
|
917
954
|
'files.referenceFile': '@File',
|
|
918
955
|
'files.addToConversation': 'Add to conversation',
|
|
919
956
|
'editor.save': 'Save',
|
|
957
|
+
'editor.gotoLine': 'Go to line',
|
|
958
|
+
'editor.gotoLineText': 'Go to line (1–{total}):',
|
|
959
|
+
'editor.gotoLineInvalid': 'Invalid line number',
|
|
920
960
|
'editor.saving': 'Saving…',
|
|
921
961
|
'editor.saved': 'Saved',
|
|
922
962
|
'editor.unsaved': '● Unsaved',
|
|
@@ -1006,10 +1046,14 @@ const en: Record<string, string> = {
|
|
|
1006
1046
|
'files.created': 'Created',
|
|
1007
1047
|
'files.renamed': 'Renamed',
|
|
1008
1048
|
'files.deleted': 'Deleted',
|
|
1049
|
+
'files.openInTerminal': 'Open in Terminal',
|
|
1009
1050
|
'files.items': 'items',
|
|
1010
1051
|
'files.deleteTitle': 'Delete',
|
|
1011
1052
|
'files.delete': 'Delete',
|
|
1012
1053
|
'files.deleteConfirm': 'Delete {target}? This cannot be undone on the remote host.',
|
|
1054
|
+
'files.deleting': 'Deleting {done}/{total} · {name}',
|
|
1055
|
+
'files.deleteCancel': 'Cancel delete',
|
|
1056
|
+
'files.deleteCancelled': 'Delete cancelled: {removed} removed, {left} untouched.',
|
|
1013
1057
|
'files.open': 'Open',
|
|
1014
1058
|
'files.openAsText': 'Open as text',
|
|
1015
1059
|
'files.openInFloat': 'Open in floating editor',
|
|
@@ -1099,7 +1143,7 @@ const en: Record<string, string> = {
|
|
|
1099
1143
|
'scm.commit': 'Commit',
|
|
1100
1144
|
'scm.committing': 'Committing',
|
|
1101
1145
|
'scm.commitPlaceholder': 'Commit message (Ctrl+Enter to commit)',
|
|
1102
|
-
'scm.commitHint': 'Stage changes, then commit',
|
|
1146
|
+
'scm.commitHint': 'Stage changes, then commit (Ctrl+Enter in the message box commits)',
|
|
1103
1147
|
'scm.commitNeedsStage': 'Nothing staged yet — press + on a file first.',
|
|
1104
1148
|
'scm.amend': 'Edit last commit message',
|
|
1105
1149
|
'scm.amendTitle': 'Amend last commit',
|
|
@@ -1182,6 +1226,17 @@ const en: Record<string, string> = {
|
|
|
1182
1226
|
'scm.syncText': 'Runs git pull, then git push.',
|
|
1183
1227
|
'scm.syncDone': 'Sync finished',
|
|
1184
1228
|
'scm.branches': 'Branches',
|
|
1229
|
+
'scm.initRepo': 'Initialize repository',
|
|
1230
|
+
'scm.initRepoText': 'Initialize a Git repository in {path}.',
|
|
1231
|
+
'scm.initRepoDone': 'Repository initialized',
|
|
1232
|
+
'scm.renameBranch': 'Rename branch',
|
|
1233
|
+
'scm.renameBranchText': 'Rename branch {branch} to:',
|
|
1234
|
+
'scm.renameBranchInvalid': 'The branch name must be non-empty and different',
|
|
1235
|
+
'scm.renameBranchDone': 'Branch renamed',
|
|
1236
|
+
'scm.setRemoteUrl': 'Edit remote URL',
|
|
1237
|
+
'scm.setRemoteUrlText': 'URL for remote {name}:',
|
|
1238
|
+
'scm.remoteUrlEmpty': 'The remote URL must not be empty',
|
|
1239
|
+
'scm.setRemoteUrlDone': 'Remote URL updated',
|
|
1185
1240
|
'scm.remotes': 'Remotes',
|
|
1186
1241
|
'scm.newBranch': 'New branch name',
|
|
1187
1242
|
'scm.create': 'Create',
|
|
@@ -1320,7 +1375,7 @@ const en: Record<string, string> = {
|
|
|
1320
1375
|
'editor.dockEmptyHint': 'Open a file from the explorer or the search results',
|
|
1321
1376
|
'editor.centerEmptyTitle': 'Remote editor',
|
|
1322
1377
|
'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',
|
|
1378
|
+
'editor.emptyShortcuts': 'Ctrl+S save · Ctrl+F find · Ctrl+P quick open · Ctrl+wheel zoom',
|
|
1324
1379
|
'editor.statusSaving': 'Saving…',
|
|
1325
1380
|
'editor.statusClean': 'Saved',
|
|
1326
1381
|
'editor.statusLanguage': 'Language',
|
|
@@ -1350,9 +1405,21 @@ const en: Record<string, string> = {
|
|
|
1350
1405
|
'editor.imageTooLargeTitle': 'Image too large',
|
|
1351
1406
|
'editor.imageTooLargeHint': 'Size {size} KiB, above the read cap; no preview is provided.',
|
|
1352
1407
|
'editor.switchToEdit': 'Switch to content editing (open this file in the editor)',
|
|
1408
|
+
// -- in-editor find (vsc/FindWidget.tsx: the query box, toggles, stepping, close)
|
|
1409
|
+
'find.placeholder': 'Find',
|
|
1410
|
+
'find.caseSensitive': 'Match case (Aa)',
|
|
1411
|
+
'find.wholeWord': 'Match whole word (ab_)',
|
|
1412
|
+
'find.regexp': 'Use regular expression (.*)',
|
|
1413
|
+
'find.noResults': 'No results',
|
|
1414
|
+
'find.prev': 'Previous match (Shift+Enter)',
|
|
1415
|
+
'find.next': 'Next match (Enter)',
|
|
1416
|
+
'find.close': 'Close (Esc)',
|
|
1353
1417
|
'git.notARepo': 'This remote workspace is not a git repository.',
|
|
1354
1418
|
// -- session change panel (above the composer)
|
|
1355
1419
|
'changes.title': 'Changed files',
|
|
1420
|
+
'changes.onlyUnreviewed': 'Only unreviewed',
|
|
1421
|
+
'changes.nextUnreviewed': 'Next unreviewed',
|
|
1422
|
+
'changes.allReviewed': 'All reviewed',
|
|
1356
1423
|
'changes.toggle': 'Show or hide the files this session changed',
|
|
1357
1424
|
'changes.empty': 'This session has not changed any file yet.',
|
|
1358
1425
|
'changes.pending': 'Computing…',
|
|
@@ -1392,6 +1459,13 @@ const en: Record<string, string> = {
|
|
|
1392
1459
|
'changes.stale': 'positions stale',
|
|
1393
1460
|
'changes.staleHint': 'The editor content changed, so the marked positions may be off. Click the file in the list to recompute.',
|
|
1394
1461
|
'changes.noWorkspace': 'No workspace is bound to that host, so the file cannot be opened.',
|
|
1462
|
+
// -- editor gutter marks and deleted chips (title / aria-label in vsc/change-marks.ts)
|
|
1463
|
+
'changes.markAdd': 'Added line',
|
|
1464
|
+
'changes.markMod': 'Modified line',
|
|
1465
|
+
'changes.markDel': 'Deleted line',
|
|
1466
|
+
'changes.deletedChip': 'Deleted content',
|
|
1467
|
+
'changes.deletedBlock': 'Deleted block ({count} lines)',
|
|
1468
|
+
'changes.deletedLines': '−{count} lines deleted',
|
|
1395
1469
|
// -- reverting one change by hovering over its line
|
|
1396
1470
|
'changes.undoAction': 'Revert this change',
|
|
1397
1471
|
'changes.undoActionDelete': 'Revert this deletion',
|
|
@@ -1449,12 +1523,12 @@ const en: Record<string, string> = {
|
|
|
1449
1523
|
'ports.forward': 'Forward to local',
|
|
1450
1524
|
'ports.stateListening': 'Listening',
|
|
1451
1525
|
'ports.stateError': 'Connection failed',
|
|
1452
|
-
'ports.connections': '{count}
|
|
1526
|
+
'ports.connections': 'Connections: {count}',
|
|
1453
1527
|
'ports.emptyListen': 'The remote host listed no listening ports.',
|
|
1454
1528
|
'ports.listenUnavailable': 'Cannot enumerate remote ports: neither ss nor netstat is available on the host.',
|
|
1455
1529
|
'ports.listenUnknown': 'Cannot enumerate remote ports: the probe did not answer.',
|
|
1456
1530
|
'ports.badPort': 'Port must be an integer between 1 and 65535; leave the local port empty to auto-assign.',
|
|
1457
|
-
'ports.restoreFailed': '
|
|
1531
|
+
'ports.restoreFailed': 'Could not restore saved forwards: {count} — the local port may be taken, or the per-host rule limit reached.',
|
|
1458
1532
|
'ports.forgetFailed': 'Forget these rules',
|
|
1459
1533
|
'ports.remoteHostHint': 'The target is dialed from the remote host, so it can reach that host’s private network; the local listener binds 127.0.0.1 only.',
|
|
1460
1534
|
// -- host monitor (sidebar "Monitor" view): full metrics on Linux; 5 s while visible
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Request priority gate: a foreground request never waits, background ones yield.
|
|
3
|
+
*
|
|
4
|
+
* The symptom this exists for: switching the remote workspace made the tree
|
|
5
|
+
* crawl. The switch starts a full `git status` walk of the new repository
|
|
6
|
+
* (minutes on an AOSP monorepo) while the tree itself needs a handful of small
|
|
7
|
+
* foreground reads. A browser gives ONE origin six connections, so the walk —
|
|
8
|
+
* probe + status + branch header, three at once — filled the pool and the
|
|
9
|
+
* directory listing queued behind it. Measured on the reported trees: the git
|
|
10
|
+
* walk took 8–9 s (1.6–1.9 s with `-uno`), and during that window a purely
|
|
11
|
+
* in-memory Host route (`/status`, normally < 1 ms) answered in 2.7–4.6 s. The
|
|
12
|
+
* directory list itself was 175–180 ms; the rest was queueing.
|
|
13
|
+
*
|
|
14
|
+
* The contract is one sentence per direction:
|
|
15
|
+
*
|
|
16
|
+
* - FOREGROUND — every request somebody is waiting on (directory list, file
|
|
17
|
+
* read/write, session cwd, connection status, terminal exec): it never waits
|
|
18
|
+
* for a background slot. It only bumps a counter, so a background request that
|
|
19
|
+
* is already running cannot hold it up (that one still owns a TCP connection,
|
|
20
|
+
* which is what `maxBackground` and the abort in `store.readGit` are for).
|
|
21
|
+
* - BACKGROUND — repository-wide git walks: started only while NO foreground
|
|
22
|
+
* request is in flight and fewer than `maxBackground` background requests run.
|
|
23
|
+
* Otherwise queued (FIFO). `maxBackground: 1` is deliberate: the walk's own
|
|
24
|
+
* steps (probe, status, branch header) are work on ONE repository, and letting
|
|
25
|
+
* three of them hold three connections is exactly the pool exhaustion this
|
|
26
|
+
* gate exists to prevent.
|
|
27
|
+
*
|
|
28
|
+
* Aborting: a queued entry leaves the queue and rejects with `AbortError`. A
|
|
29
|
+
* request that already STARTED cannot be un-sent — its slot is released the
|
|
30
|
+
* moment its signal aborts (a cancelled fetch frees its connection right away,
|
|
31
|
+
* and the channel must not depend on the transport noticing), while the outcome
|
|
32
|
+
* of the underlying promise stays the transport's business: a real `fetch`
|
|
33
|
+
* rejects with `AbortError`, which is what the store sees. A signal that is
|
|
34
|
+
* ALREADY aborted when the request is handed over is passed to the transport
|
|
35
|
+
* unchanged — `fetch` refuses it at once, and deciding that here would swallow
|
|
36
|
+
* a step of a read that chose to keep going.
|
|
37
|
+
*
|
|
38
|
+
* Kept dependency-free (no store, no React, no fetch) on purpose: a node gate
|
|
39
|
+
* imports this class and proves the ordering with its own deferreds, and the
|
|
40
|
+
* store/api wiring is a one-liner at each call site.
|
|
41
|
+
*/
|
|
42
|
+
|
|
43
|
+
/** What `pending()` reports: counts only, never the queued closures. */
|
|
44
|
+
export interface RequestGatePending {
|
|
45
|
+
/** Foreground requests in flight. */
|
|
46
|
+
foreground: number
|
|
47
|
+
/** Background requests in flight. */
|
|
48
|
+
background: number
|
|
49
|
+
/** Background requests waiting for a slot. */
|
|
50
|
+
queued: number
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** One background request, either queued or running. */
|
|
54
|
+
interface BackgroundEntry {
|
|
55
|
+
/** The request itself (a `fetch` wrapped in a closure by `api.call`). */
|
|
56
|
+
readonly run: () => Promise<unknown>
|
|
57
|
+
/** Hand the transport's answer to the caller (no-op once settled/aborted). */
|
|
58
|
+
readonly resolve: (value: unknown) => void
|
|
59
|
+
/** Hand the transport's failure to the caller (queued-abort uses it too). */
|
|
60
|
+
readonly reject: (error: unknown) => void
|
|
61
|
+
/** Removes this entry's abort listener (set by `runBackground`). */
|
|
62
|
+
readonly detach: () => void
|
|
63
|
+
/**
|
|
64
|
+
* Gives the background slot back. A no-op while the entry is still queued;
|
|
65
|
+
* `pump` replaces it with the real release when the request starts.
|
|
66
|
+
*/
|
|
67
|
+
release: () => void
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* The cancellation error a queued background request rejects with when its
|
|
72
|
+
* signal aborts (`AbortError`, the same name `fetch` uses for its own aborts).
|
|
73
|
+
*/
|
|
74
|
+
export function requestAbortError(): Error {
|
|
75
|
+
if (typeof DOMException === 'function') return new DOMException('Aborted', 'AbortError')
|
|
76
|
+
const error = new Error('Aborted')
|
|
77
|
+
error.name = 'AbortError'
|
|
78
|
+
return error
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* True when `error` is an abort, not a failure.
|
|
83
|
+
*
|
|
84
|
+
* Callers that cancelled a request on purpose (a workspace switch) must not
|
|
85
|
+
* report it: "the read you superseded was cancelled" is not an error the user
|
|
86
|
+
* can act on.
|
|
87
|
+
*/
|
|
88
|
+
export function isRequestAbort(error: unknown): boolean {
|
|
89
|
+
return typeof error === 'object' && error !== null
|
|
90
|
+
&& (error as { name?: unknown }).name === 'AbortError'
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* The gate itself.
|
|
95
|
+
*
|
|
96
|
+
* One instance per page is enough and is what `api.ts` uses; the class is
|
|
97
|
+
* exported so a gate can drive several independent instances with its own
|
|
98
|
+
* timings instead of sharing module state.
|
|
99
|
+
*/
|
|
100
|
+
export class RequestGate {
|
|
101
|
+
/** Foreground requests in flight. */
|
|
102
|
+
private foregroundCount = 0
|
|
103
|
+
/** Background requests in flight (a slot is held until it settles or aborts). */
|
|
104
|
+
private backgroundCount = 0
|
|
105
|
+
/** Background requests waiting for a slot, in arrival order (FIFO). */
|
|
106
|
+
private readonly queued: BackgroundEntry[] = []
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* @param maxBackground - how many background requests may run at once.
|
|
110
|
+
* `1` is the client's choice; see the module comment.
|
|
111
|
+
*/
|
|
112
|
+
constructor(private readonly maxBackground = 1) {}
|
|
113
|
+
|
|
114
|
+
/** Run one foreground request. It never waits for a background slot. */
|
|
115
|
+
async runForeground<T>(fn: () => Promise<T>): Promise<T> {
|
|
116
|
+
this.foregroundCount += 1
|
|
117
|
+
try {
|
|
118
|
+
return await fn()
|
|
119
|
+
} finally {
|
|
120
|
+
this.foregroundCount -= 1
|
|
121
|
+
// The last foreground request is gone: the background channel may start.
|
|
122
|
+
if (this.foregroundCount === 0) this.pump()
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Run one background request, waiting for a slot.
|
|
128
|
+
*
|
|
129
|
+
* @param signal - a QUEUED request leaves the queue and rejects with
|
|
130
|
+
* `AbortError`; a request that already started releases its slot at once
|
|
131
|
+
* (its own `fetch` gets the same signal, so the transport is cancelled too).
|
|
132
|
+
* An already-aborted signal is handed to the transport, which refuses it.
|
|
133
|
+
*/
|
|
134
|
+
runBackground<T>(fn: () => Promise<T>, signal?: AbortSignal): Promise<T> {
|
|
135
|
+
return new Promise<T>((resolve, reject) => {
|
|
136
|
+
let settled = false
|
|
137
|
+
let detach = (): void => {}
|
|
138
|
+
const entry: BackgroundEntry = {
|
|
139
|
+
run: () => fn() as Promise<unknown>,
|
|
140
|
+
resolve: (value) => {
|
|
141
|
+
if (settled) return
|
|
142
|
+
settled = true
|
|
143
|
+
detach()
|
|
144
|
+
entry.release()
|
|
145
|
+
resolve(value as T)
|
|
146
|
+
},
|
|
147
|
+
reject: (error) => {
|
|
148
|
+
if (settled) return
|
|
149
|
+
settled = true
|
|
150
|
+
detach()
|
|
151
|
+
entry.release()
|
|
152
|
+
reject(error)
|
|
153
|
+
},
|
|
154
|
+
detach: () => detach(),
|
|
155
|
+
release: () => {},
|
|
156
|
+
}
|
|
157
|
+
if (signal !== undefined) {
|
|
158
|
+
const onAbort = (): void => {
|
|
159
|
+
const at = this.queued.indexOf(entry)
|
|
160
|
+
if (at >= 0) {
|
|
161
|
+
// Never started: the cancellation is the caller's answer.
|
|
162
|
+
this.queued.splice(at, 1)
|
|
163
|
+
entry.reject(requestAbortError())
|
|
164
|
+
return
|
|
165
|
+
}
|
|
166
|
+
// Already running: give the slot back NOW. The transport is cancelled
|
|
167
|
+
// through the same signal (a real fetch rejects and the caller sees
|
|
168
|
+
// the AbortError); a transport that ignores it keeps the promise, but
|
|
169
|
+
// must not wedge every later background read behind a dead walk.
|
|
170
|
+
entry.release()
|
|
171
|
+
}
|
|
172
|
+
signal.addEventListener('abort', onAbort, { once: true })
|
|
173
|
+
detach = () => signal.removeEventListener('abort', onAbort)
|
|
174
|
+
}
|
|
175
|
+
this.queued.push(entry)
|
|
176
|
+
this.pump()
|
|
177
|
+
})
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/** Snapshot of the counts (gates assert ordering with this). */
|
|
181
|
+
pending(): RequestGatePending {
|
|
182
|
+
return { foreground: this.foregroundCount, background: this.backgroundCount, queued: this.queued.length }
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Start as many queued background requests as the rule allows.
|
|
187
|
+
*
|
|
188
|
+
* Called when a foreground request finishes, when a background one settles and
|
|
189
|
+
* when a running one's signal aborts. A background request that is RUNNING is
|
|
190
|
+
* never recalled (a fetch cannot be un-sent), so a foreground request arriving
|
|
191
|
+
* mid-walk simply runs alongside it until it settles.
|
|
192
|
+
*/
|
|
193
|
+
private pump(): void {
|
|
194
|
+
while (this.foregroundCount === 0 && this.backgroundCount < this.maxBackground && this.queued.length > 0) {
|
|
195
|
+
const entry = this.queued.shift() as BackgroundEntry
|
|
196
|
+
this.backgroundCount += 1
|
|
197
|
+
let released = false
|
|
198
|
+
// The real release: give the slot back once, then let the next entry in.
|
|
199
|
+
entry.release = () => {
|
|
200
|
+
if (released) return
|
|
201
|
+
released = true
|
|
202
|
+
this.backgroundCount -= 1
|
|
203
|
+
this.pump()
|
|
204
|
+
}
|
|
205
|
+
// A deferred call turns a synchronous throw into a rejection, and the slot
|
|
206
|
+
// is given back before the next entry is considered.
|
|
207
|
+
void Promise.resolve()
|
|
208
|
+
.then(entry.run)
|
|
209
|
+
.then(entry.resolve, entry.reject)
|
|
210
|
+
.finally(entry.release)
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/** The one gate the client uses (see `api.call`). */
|
|
216
|
+
export const requestGate = new RequestGate(1)
|
|
217
|
+
|
|
218
|
+
/** Snapshot of {@link requestGate} — for gates that assert the wiring. */
|
|
219
|
+
export function pending(): RequestGatePending {
|
|
220
|
+
return requestGate.pending()
|
|
221
|
+
}
|
|
@@ -33,7 +33,7 @@ import type { Lang } from '../i18n.ts'
|
|
|
33
33
|
import { buildCommitReviewPrompt, diffByteLength, pickReviewMode } from '../ai-review.ts'
|
|
34
34
|
import { appendToDraft, canInsertDraft, sameLocalDir } from '../composer.ts'
|
|
35
35
|
import { GIT_CAP } from '../../git-ops.ts'
|
|
36
|
-
import {
|
|
36
|
+
import { shallowEqual, useExplorerSelector, type ExplorerValue } from '../store.tsx'
|
|
37
37
|
import { useRemoteChatTarget } from '../use-remote-chat-target.ts'
|
|
38
38
|
import {
|
|
39
39
|
ContextMenu,
|
|
@@ -456,6 +456,24 @@ function contentBody(
|
|
|
456
456
|
)
|
|
457
457
|
}
|
|
458
458
|
|
|
459
|
+
/**
|
|
460
|
+
* The store fields the 差异 tab reads — and only those.
|
|
461
|
+
*
|
|
462
|
+
* Only the AI-review wiring needs the store here (the commit/body/files/patch
|
|
463
|
+
* arrive as props), so subscribing to the whole snapshot meant the patch view —
|
|
464
|
+
* up to a capped commit patch, thousands of rows — repainted on every save, git
|
|
465
|
+
* refresh and rail switch. The slice is the workspace identity a review prompt
|
|
466
|
+
* names plus the draft channel (`ctx`).
|
|
467
|
+
*/
|
|
468
|
+
const selectCommitStore = (snapshot: ExplorerValue) => ({
|
|
469
|
+
ctx: snapshot.ctx,
|
|
470
|
+
workspace: snapshot.workspace,
|
|
471
|
+
aliasPaths: snapshot.aliasPaths,
|
|
472
|
+
alias: snapshot.alias,
|
|
473
|
+
repoRoot: snapshot.repoRoot,
|
|
474
|
+
root: snapshot.root,
|
|
475
|
+
})
|
|
476
|
+
|
|
459
477
|
function DiffTab(props: CommitPaneProps & { hidden: boolean; wrap: boolean; onToggleWrap: () => void }): ReactNode {
|
|
460
478
|
const { t } = props
|
|
461
479
|
const model = useMemo(() => buildCommitPatch(props.patch ?? ''), [props.patch])
|
|
@@ -490,7 +508,7 @@ function DiffTab(props: CommitPaneProps & { hidden: boolean; wrap: boolean; onTo
|
|
|
490
508
|
* extra remote round trip; `patchTruncated` comes from the loader that
|
|
491
509
|
* computed the byte cap — the one place that knows the read was cut.
|
|
492
510
|
*/
|
|
493
|
-
const store =
|
|
511
|
+
const store = useExplorerSelector(selectCommitStore, shallowEqual)
|
|
494
512
|
const chat = useRemoteChatTarget(store.ctx)
|
|
495
513
|
const viewedAliasPath = store.workspace === undefined ? undefined : store.aliasPaths[store.workspace.id]
|
|
496
514
|
const chatEnabled = chat.sessionId !== undefined
|