dsh-linked-workspace 0.12.0 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -0
- package/README.en.md +7 -6
- package/README.md +7 -6
- package/docs/API.md +5 -2
- package/docs/VERIFY.md +32 -7
- package/lib/client.js +927 -124
- package/lib/index.js +248 -50
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -2126,6 +2126,20 @@ function attributeViolation(name, value, tagName) {
|
|
|
2126
2126
|
var ZH = {
|
|
2127
2127
|
settingsNav: '联动工作区',
|
|
2128
2128
|
title: '联动&远程工作区',
|
|
2129
|
+
welcomeEyebrow: 'DSH-LINKED-WORKSPACE',
|
|
2130
|
+
welcomeTitle: '欢迎使用联动工作区插件',
|
|
2131
|
+
welcomeLead: '把 SSH 主机上的远端目录接进 DSH:既能和本地目录配对成联动工作区,也能让会话直接运行在远端目录。会话里的模型可以读写远端代码。',
|
|
2132
|
+
welcomeCreate: '创建联动或远程工作区',
|
|
2133
|
+
welcomeCreateWhere: '设置 →「联动工作区」,或左侧工作区栏的「添加工作区」',
|
|
2134
|
+
welcomeBrowse: '在右侧栏浏览远端文件',
|
|
2135
|
+
welcomeBrowseWhere: '标签栏「+」→「联动工作区目录」或「远程工作区目录」',
|
|
2136
|
+
welcomeTools: '让模型读写远端代码',
|
|
2137
|
+
welcomeToolsWhere: '直接在会话里提需求,模型会用 linked_workspace 工具',
|
|
2138
|
+
welcomePassword: '不用装 SSH Manager 也能连',
|
|
2139
|
+
welcomePasswordWhere: '添加工作区时直接填 SSH 密码,只保存在本机',
|
|
2140
|
+
welcomeStar: '★ 点个 Star',
|
|
2141
|
+
welcomeDone: '知道了',
|
|
2142
|
+
welcomeReplay: '再次查看欢迎卡片',
|
|
2129
2143
|
intro: '把 SSH 连接变成工作区:联动工作区把本地目录与远端目录配对,远程工作区让会话直接运行在远端目录。会话都能读取、搜索和编辑远端文件。',
|
|
2130
2144
|
addWorkspace: '添加工作区',
|
|
2131
2145
|
addLinked: '添加联动工作区',
|
|
@@ -2195,11 +2209,14 @@ function attributeViolation(name, value, tagName) {
|
|
|
2195
2209
|
csvTruncated: '仅显示前 1000 行',
|
|
2196
2210
|
moveTitle: '移动到…',
|
|
2197
2211
|
moveMessage: '选择「{{name}}」要移动到的目录',
|
|
2212
|
+
moveMessageMany: '选择这 {{count}} 项要移动到的目录',
|
|
2198
2213
|
moveDone: '已移动',
|
|
2214
|
+
moveDoneCount: '已移动 {{count}} 项',
|
|
2199
2215
|
moveDirty: '该文件有未保存修改,请先保存或关闭后再移动',
|
|
2200
2216
|
moveFailed: '移动失败',
|
|
2201
2217
|
moveHint: '进入目标文件夹后点击「使用此目录」',
|
|
2202
2218
|
ctxMove: '移动到…',
|
|
2219
|
+
ctxMoveSelected: '移动所选的 {{count}} 项…',
|
|
2203
2220
|
noWorkspace: '远程工作区不存在,请重新添加。',
|
|
2204
2221
|
noTarget: '没有可浏览的工作区。先在设置 → 连接中创建,或点击左侧「添加工作区」。',
|
|
2205
2222
|
treeEmpty: '空目录',
|
|
@@ -2232,6 +2249,14 @@ function attributeViolation(name, value, tagName) {
|
|
|
2232
2249
|
filterPlaceholder: '按名称过滤…',
|
|
2233
2250
|
filterEmpty: '没有匹配当前过滤条件的条目',
|
|
2234
2251
|
searchTruncated: '结果过多,仅显示前 200 条;请输入更精确的关键词',
|
|
2252
|
+
searchTruncatedFiles: '文件太多,搜索结果不完整;请缩小目录范围或换个关键词',
|
|
2253
|
+
searchTruncatedBytes: '读取的文件总量已达上限,搜索结果不完整;请缩小目录范围',
|
|
2254
|
+
searchTruncatedDeadline: '搜索超时,结果不完整;请缩小目录范围或换个关键词',
|
|
2255
|
+
searchCase: '区分大小写',
|
|
2256
|
+
searchRegex: '正则表达式',
|
|
2257
|
+
searchScopeAll: '整个工作区',
|
|
2258
|
+
searchScopeHere: '只搜当前目录',
|
|
2259
|
+
searchScopeLabel: '范围:{{scope}}',
|
|
2235
2260
|
findPlaceholder: '查找…',
|
|
2236
2261
|
replacePlaceholder: '替换为…',
|
|
2237
2262
|
findCounter: '第 {{index}} / {{total}} 个',
|
|
@@ -2313,6 +2338,24 @@ function attributeViolation(name, value, tagName) {
|
|
|
2313
2338
|
searchModeContent: '内容',
|
|
2314
2339
|
searchPlaceholderContent: '在文件内容中搜索…',
|
|
2315
2340
|
queueRetry: '重试',
|
|
2341
|
+
rowModifiedAt: '修改于 {{when}}',
|
|
2342
|
+
ctxRenameSelected: '批量重命名所选的 {{count}} 项…',
|
|
2343
|
+
renameManyTitle: '批量重命名 {{count}} 项',
|
|
2344
|
+
renameManyPattern: '按序号',
|
|
2345
|
+
renameManyReplace: '查找替换',
|
|
2346
|
+
renameManyPrefix: '前缀',
|
|
2347
|
+
renameManyStart: '起始序号',
|
|
2348
|
+
renameManyPad: '序号位数',
|
|
2349
|
+
renameManyFind: '查找',
|
|
2350
|
+
renameManyReplaceWith: '替换为',
|
|
2351
|
+
renameManyEmpty: '(名称不能为空)',
|
|
2352
|
+
renameManyConflict: '有重名,先调整规则再重命名',
|
|
2353
|
+
renameManyApply: '重命名 {{count}} 项',
|
|
2354
|
+
renameManyDone: '已重命名 {{count}} 项',
|
|
2355
|
+
queueCancel: '取消',
|
|
2356
|
+
queueProgress: '已传 {{files}} 个 · {{size}}',
|
|
2357
|
+
queueCancelling: '正在取消…',
|
|
2358
|
+
queueCancelled: '已取消(已传 {{files}} 个)',
|
|
2316
2359
|
shortcutWebNote: 'Web GUI 中 Ctrl+W、Ctrl+Tab 由浏览器占用,请在 DSH 桌面端使用这些快捷键。',
|
|
2317
2360
|
themeTitle: '编辑器主题',
|
|
2318
2361
|
themeHint: '远程文件编辑器的配色;主题只影响本插件的远程文件视图。',
|
|
@@ -2542,6 +2585,20 @@ function attributeViolation(name, value, tagName) {
|
|
|
2542
2585
|
var EN = {
|
|
2543
2586
|
settingsNav: 'Linked workspaces',
|
|
2544
2587
|
title: 'Linked & remote workspaces',
|
|
2588
|
+
welcomeEyebrow: 'DSH-LINKED-WORKSPACE',
|
|
2589
|
+
welcomeTitle: 'Welcome to the linked-workspaces plugin',
|
|
2590
|
+
welcomeLead: 'Bring a folder on an SSH host into DSH: pair it with a local folder as a linked workspace, or run sessions straight inside the remote folder. Sessions can read and edit the remote code.',
|
|
2591
|
+
welcomeCreate: 'Create a linked or remote workspace',
|
|
2592
|
+
welcomeCreateWhere: 'Settings → “Linked workspaces”, or “Add workspace” in the left column',
|
|
2593
|
+
welcomeBrowse: 'Browse remote files in the right sidebar',
|
|
2594
|
+
welcomeBrowseWhere: 'Tab bar “+” → “Linked workspace directory” or “Remote workspace directory”',
|
|
2595
|
+
welcomeTools: 'Let the model read and write remote code',
|
|
2596
|
+
welcomeToolsWhere: 'Just ask in a session; the model uses the linked_workspace tool',
|
|
2597
|
+
welcomePassword: 'No SSH Manager needed',
|
|
2598
|
+
welcomePasswordWhere: 'Type the SSH password when adding a workspace; it stays on this machine',
|
|
2599
|
+
welcomeStar: '★ Star the repo',
|
|
2600
|
+
welcomeDone: 'Got it',
|
|
2601
|
+
welcomeReplay: 'Show the welcome card again',
|
|
2545
2602
|
intro: 'Turn an SSH connection into a workspace: a linked workspace pairs a local folder with a remote folder, and a remote workspace runs sessions directly inside the remote folder. Either way sessions can read, search and edit remote files.',
|
|
2546
2603
|
addWorkspace: 'Add workspace',
|
|
2547
2604
|
addRemoteDir: 'Add remote directory',
|
|
@@ -2612,11 +2669,14 @@ function attributeViolation(name, value, tagName) {
|
|
|
2612
2669
|
csvTruncated: 'Showing the first 1000 rows',
|
|
2613
2670
|
moveTitle: 'Move to…',
|
|
2614
2671
|
moveMessage: 'Choose the destination folder for "{{name}}"',
|
|
2672
|
+
moveMessageMany: 'Choose the destination folder for these {{count}} items',
|
|
2615
2673
|
moveDone: 'Moved',
|
|
2674
|
+
moveDoneCount: 'Moved {{count}} items',
|
|
2616
2675
|
moveDirty: 'This file has unsaved changes; save or close it before moving',
|
|
2617
2676
|
moveFailed: 'Move failed',
|
|
2618
2677
|
moveHint: 'Open the destination folder, then click “Use this directory”',
|
|
2619
2678
|
ctxMove: 'Move to…',
|
|
2679
|
+
ctxMoveSelected: 'Move selected ({{count}})…',
|
|
2620
2680
|
noWorkspace: 'This remote workspace no longer exists. Add it again.',
|
|
2621
2681
|
noTarget: 'No workspace to browse. Create one in Settings → Connections, or click “Add workspace” on the left.',
|
|
2622
2682
|
treeEmpty: 'Empty directory',
|
|
@@ -2649,6 +2709,14 @@ function attributeViolation(name, value, tagName) {
|
|
|
2649
2709
|
filterPlaceholder: 'Filter by name…',
|
|
2650
2710
|
filterEmpty: 'No entries match the current filter',
|
|
2651
2711
|
searchTruncated: 'Too many results; showing the first 200. Narrow the query.',
|
|
2712
|
+
searchTruncatedFiles: 'Too many files were scanned; results are incomplete. Narrow the folder or the query.',
|
|
2713
|
+
searchTruncatedBytes: 'The byte budget ran out; results are incomplete. Narrow the folder.',
|
|
2714
|
+
searchTruncatedDeadline: 'The search timed out; results are incomplete. Narrow the folder or the query.',
|
|
2715
|
+
searchCase: 'Match case',
|
|
2716
|
+
searchRegex: 'Regular expression',
|
|
2717
|
+
searchScopeAll: 'Whole workspace',
|
|
2718
|
+
searchScopeHere: 'Current folder only',
|
|
2719
|
+
searchScopeLabel: 'Scope: {{scope}}',
|
|
2652
2720
|
findPlaceholder: 'Find…',
|
|
2653
2721
|
replacePlaceholder: 'Replace with…',
|
|
2654
2722
|
findCounter: '{{index}} / {{total}}',
|
|
@@ -2730,6 +2798,24 @@ function attributeViolation(name, value, tagName) {
|
|
|
2730
2798
|
searchModeContent: 'Content',
|
|
2731
2799
|
searchPlaceholderContent: 'Search file contents…',
|
|
2732
2800
|
queueRetry: 'Retry',
|
|
2801
|
+
rowModifiedAt: 'Modified {{when}}',
|
|
2802
|
+
ctxRenameSelected: 'Rename the {{count}} selected…',
|
|
2803
|
+
renameManyTitle: 'Rename {{count}} entries',
|
|
2804
|
+
renameManyPattern: 'Numbering',
|
|
2805
|
+
renameManyReplace: 'Find and replace',
|
|
2806
|
+
renameManyPrefix: 'Prefix',
|
|
2807
|
+
renameManyStart: 'Start at',
|
|
2808
|
+
renameManyPad: 'Digits',
|
|
2809
|
+
renameManyFind: 'Find',
|
|
2810
|
+
renameManyReplaceWith: 'Replace with',
|
|
2811
|
+
renameManyEmpty: '(name cannot be empty)',
|
|
2812
|
+
renameManyConflict: 'Two entries would share a name — adjust the rule first',
|
|
2813
|
+
renameManyApply: 'Rename {{count}}',
|
|
2814
|
+
renameManyDone: 'Renamed {{count}} entries',
|
|
2815
|
+
queueCancel: 'Cancel',
|
|
2816
|
+
queueProgress: '{{files}} sent · {{size}}',
|
|
2817
|
+
queueCancelling: 'Cancelling…',
|
|
2818
|
+
queueCancelled: 'Cancelled ({{files}} sent)',
|
|
2733
2819
|
shortcutWebNote: 'In the Web GUI, Ctrl+W and Ctrl+Tab are reserved by the browser; use these shortcuts in the DSH desktop app.',
|
|
2734
2820
|
themeTitle: 'Editor theme',
|
|
2735
2821
|
themeHint: 'Colors of the remote file editor. Themes affect this plugin’s remote file views only.',
|
|
@@ -3344,9 +3430,9 @@ function attributeViolation(name, value, tagName) {
|
|
|
3344
3430
|
'.rw-path{font-family:ui-monospace,"Cascadia Code",Consolas,monospace;font-size:12px;line-height:18px;color:var(--dsw-alias-label-secondary);word-break:break-all}',
|
|
3345
3431
|
// Injected into the host's workspace hover preview, which always paints on
|
|
3346
3432
|
// a fixed dark card, so these colours cannot follow the theme tokens.
|
|
3347
|
-
'.rw-hover-
|
|
3348
|
-
'.rw-hover-
|
|
3349
|
-
'.rw-hover-
|
|
3433
|
+
'.rw-hover-host{margin:1px 0 0;font-size:12px;line-height:18px;color:rgb(207,211,214)}',
|
|
3434
|
+
'.rw-hover-host.is-on{color:#3fb950}',
|
|
3435
|
+
'.rw-hover-host.is-off{color:#f85149}',
|
|
3350
3436
|
'.rw-meta{display:flex;align-items:center;gap:8px;flex-wrap:wrap;min-width:0}',
|
|
3351
3437
|
'.rw-meta-text{font-size:12px;line-height:18px;color:var(--dsw-alias-label-tertiary);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}',
|
|
3352
3438
|
'.rw-pair{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:8px}',
|
|
@@ -3370,6 +3456,9 @@ function attributeViolation(name, value, tagName) {
|
|
|
3370
3456
|
'.rw-input{height:32px;padding:0 10px;border-radius:8px;border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-1);color:var(--dsw-alias-label-primary);font:inherit;font-size:13px;outline:none;min-width:0;box-sizing:border-box}',
|
|
3371
3457
|
'.rw-input:focus{border-color:var(--dsw-alias-brand-primary)}',
|
|
3372
3458
|
'.rw-input-mono{font-family:ui-monospace,"Cascadia Code",Consolas,monospace;font-size:12.5px}',
|
|
3459
|
+
// A long remote path must never push the "use this directory" button out of
|
|
3460
|
+
// the row; it ellipsizes inside its own flex item instead.
|
|
3461
|
+
'.rw-path-text{display:block;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}',
|
|
3373
3462
|
'.rw-input-row{display:flex;align-items:center;gap:8px;min-width:0}',
|
|
3374
3463
|
'.rw-input-row .rw-input{flex:1 1 auto}',
|
|
3375
3464
|
'.rw-host-list{display:flex;flex-direction:column;gap:2px;max-height:216px;overflow:auto;padding:4px;border:1px solid var(--dsw-alias-border-l2);border-radius:10px;background:var(--dsw-alias-bg-layer-1)}',
|
|
@@ -3498,6 +3587,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
3498
3587
|
'.rw-menu-backdrop{position:fixed;inset:0;z-index:40}',
|
|
3499
3588
|
'.rw-searchbar{display:flex;align-items:center;gap:6px;margin:6px 8px 0;padding:0 8px;height:30px;border:1px solid var(--dsw-alias-border-l2);border-radius:8px;background:var(--dsw-alias-bg-layer-1);flex:none}',
|
|
3500
3589
|
'.rw-searchbar input{flex:1 1 auto;border:0;outline:0;background:transparent;color:var(--dsw-alias-label-primary);font:inherit;font-size:12px;min-width:0}',
|
|
3590
|
+
'.rw-search-flags{display:inline-flex;align-items:center;gap:2px;flex:none}',
|
|
3501
3591
|
'.rw-chips{display:flex;gap:4px;padding:6px 8px 0;overflow:auto;flex:none}',
|
|
3502
3592
|
'.rw-chip-btn{display:inline-flex;align-items:center;gap:4px;max-width:190px;padding:2px 8px;border-radius:999px;border:1px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-bg-layer-1);color:var(--dsw-alias-label-secondary);font:inherit;font-size:11px;line-height:16px;cursor:pointer;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;flex:none}',
|
|
3503
3593
|
'.rw-chip-btn.is-on{border-color:var(--dsw-alias-brand-primary);color:var(--dsw-alias-label-primary);background:color-mix(in srgb,var(--dsw-alias-brand-primary) 10%,transparent)}',
|
|
@@ -3518,6 +3608,10 @@ function attributeViolation(name, value, tagName) {
|
|
|
3518
3608
|
'.rw-change-meta{flex:none;font-size:10.5px;color:var(--dsw-alias-label-tertiary)}',
|
|
3519
3609
|
'.rw-search-results{flex:1 1 auto;min-height:0;overflow:auto;padding:6px 8px}',
|
|
3520
3610
|
'.rw-result-row{display:flex;align-items:center;gap:6px;width:100%;padding:4px;border:0;border-radius:5px;background:transparent;color:var(--dsw-alias-label-primary);font:inherit;font-size:12px;cursor:pointer;text-align:left}',
|
|
3611
|
+
'.rw-result-row.is-content{flex-direction:column;align-items:stretch;gap:1px}',
|
|
3612
|
+
'.rw-result-head{display:flex;align-items:center;gap:6px;min-width:0}',
|
|
3613
|
+
'.rw-result-line{flex:none;font-size:11px;color:var(--dsw-alias-label-secondary)}',
|
|
3614
|
+
'.rw-result-preview{display:block;font-size:11px;line-height:15px;color:var(--dsw-alias-label-secondary);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}',
|
|
3521
3615
|
'.rw-result-row:hover{background:var(--dsw-alias-interactive-bg-hover,rgba(127,127,127,.12))}',
|
|
3522
3616
|
'.rw-hint-row{padding:9px 6px;font-size:11.5px;line-height:17px;color:var(--dsw-alias-label-tertiary)}',
|
|
3523
3617
|
'.rw-linked-notice{margin:6px 8px 0}',
|
|
@@ -3612,13 +3706,30 @@ function attributeViolation(name, value, tagName) {
|
|
|
3612
3706
|
'.rw-ctx-arrow{display:inline-flex;color:var(--dsw-alias-label-tertiary)}',
|
|
3613
3707
|
'.rw-ctx-sub{display:none;position:absolute;left:100%;top:-5px;min-width:150px;padding:4px 0;border:1px solid var(--dsw-alias-border-l2);border-radius:7px;background:var(--dsw-alias-bg-overlay);box-shadow:0 12px 36px rgba(0,0,0,.3)}',
|
|
3614
3708
|
'.rw-ctx-item.has-sub:hover .rw-ctx-sub{display:block}',
|
|
3615
|
-
'.rw-dialog-backdrop{position:fixed;inset:0;z-index:80;background:rgba(0,0,0,.
|
|
3616
|
-
|
|
3617
|
-
|
|
3709
|
+
'.rw-dialog-backdrop{position:fixed;inset:0;z-index:80;padding:24px;background:rgba(0,0,0,.34);backdrop-filter:blur(2px);display:flex;align-items:center;justify-content:center}',
|
|
3710
|
+
// D4: dialogs share the add-workspace modal's frame so a confirm never
|
|
3711
|
+
// looks like a foreign panel next to it.
|
|
3712
|
+
'.rw-dialog{width:min(460px,calc(100vw - 48px));max-height:min(80vh,620px);overflow:auto;border:1px solid var(--dsw-alias-border-l2);border-radius:16px;background:var(--dsw-alias-bg-overlay);box-shadow:0 18px 60px rgba(0,0,0,.35);padding:18px 20px}',
|
|
3713
|
+
'.rw-dialog-title{font-size:15px;font-weight:600;line-height:22px;margin-bottom:10px}',
|
|
3618
3714
|
'.rw-dialog-label{display:block;margin:7px 0 4px;font-size:11.5px;color:var(--dsw-alias-label-tertiary)}',
|
|
3619
3715
|
'.rw-dialog-input{width:100%;box-sizing:border-box;padding:6px 9px;border:1px solid var(--dsw-alias-border-l2);border-radius:6px;background:var(--dsw-alias-bg-layer-1);color:var(--dsw-alias-label-primary);font:inherit;font-size:12px;outline:none}',
|
|
3620
|
-
'.rw-dialog-actions{display:flex;justify-content:flex-end;gap:
|
|
3621
|
-
'.rw-dialog-message{font-size:
|
|
3716
|
+
'.rw-dialog-actions{display:flex;justify-content:flex-end;gap:8px;margin-top:14px}',
|
|
3717
|
+
'.rw-dialog-message{font-size:13px;line-height:19px;color:var(--dsw-alias-label-secondary)}',
|
|
3718
|
+
// First-run welcome card: sits in shell.overlay, so the backdrop is its own.
|
|
3719
|
+
'.rw-welcome-backdrop{position:fixed;inset:0;z-index:2000;display:flex;align-items:center;justify-content:center;padding:24px;background:rgba(0,0,0,.42)}',
|
|
3720
|
+
'.rw-welcome{position:relative;width:min(470px,100%);max-height:min(86vh,700px);overflow:auto;box-sizing:border-box;padding:22px 22px 18px;border:1px solid var(--dsw-alias-border-l2);border-radius:18px;background:var(--dsw-alias-bg-layer-2);box-shadow:0 26px 70px rgba(0,0,0,.42);color:var(--dsw-alias-label-primary)}',
|
|
3721
|
+
'.rw-welcome-x{position:absolute;top:12px;right:12px;display:inline-flex;align-items:center;justify-content:center;width:26px;height:26px;padding:0;border:0;border-radius:7px;background:transparent;color:var(--dsw-alias-label-tertiary);cursor:pointer}',
|
|
3722
|
+
'.rw-welcome-x:hover{background:var(--dsw-alias-interactive-bg-hover,rgba(127,127,127,.14))}',
|
|
3723
|
+
'.rw-welcome-eyebrow{display:inline-flex;align-items:center;gap:6px;font-size:11px;letter-spacing:.06em;text-transform:uppercase;color:var(--dsw-alias-label-tertiary)}',
|
|
3724
|
+
'.rw-welcome-dot{width:6px;height:6px;border-radius:50%;background:var(--dsw-alias-brand-primary)}',
|
|
3725
|
+
'.rw-welcome-title{margin:8px 0 0;font-size:19px;line-height:26px;font-weight:650}',
|
|
3726
|
+
'.rw-welcome-lead{margin:8px 0 0;font-size:13px;line-height:20px;color:var(--dsw-alias-label-secondary)}',
|
|
3727
|
+
'.rw-welcome-rows{display:flex;flex-direction:column;gap:8px;margin:16px 0 0}',
|
|
3728
|
+
'.rw-welcome-row{padding:10px 12px;border:1px solid var(--dsw-alias-border-l1);border-radius:11px;background:var(--dsw-alias-bg-base)}',
|
|
3729
|
+
'.rw-welcome-row-main{font-size:13px;line-height:19px;font-weight:600}',
|
|
3730
|
+
'.rw-welcome-row-where{margin-top:2px;font-size:12px;line-height:18px;color:var(--dsw-alias-label-tertiary)}',
|
|
3731
|
+
'.rw-welcome-foot{display:flex;align-items:center;gap:10px;margin-top:18px}',
|
|
3732
|
+
'.rw-welcome-foot .rw-btn{height:32px;padding:0 16px;text-decoration:none}',
|
|
3622
3733
|
'.rw-props{display:grid;grid-template-columns:70px minmax(0,1fr);gap:5px 9px;font-size:12px;line-height:18px}',
|
|
3623
3734
|
'.rw-props-key{color:var(--dsw-alias-label-tertiary)}',
|
|
3624
3735
|
'.rw-props-value{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}',
|
|
@@ -3640,6 +3751,12 @@ function attributeViolation(name, value, tagName) {
|
|
|
3640
3751
|
'.rw-csv-table tr:nth-child(even) td{background:color-mix(in srgb,var(--dsw-alias-bg-layer-1) 52%,transparent)}',
|
|
3641
3752
|
'.rw-csv-note{padding:5px 9px;font-size:10.5px;color:var(--dsw-alias-label-tertiary);border-top:1px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-bg-layer-1)}',
|
|
3642
3753
|
'.rw-queue-row{display:flex;align-items:center;gap:8px;padding:5px 0;border-bottom:1px solid var(--dsw-alias-border-l1);font-size:12px}',
|
|
3754
|
+
'.rw-rename-preview{max-height:min(38vh,300px);overflow:auto;border:1px solid var(--dsw-alias-border-l1);border-radius:10px;padding:4px 8px;margin:2px 0 10px}',
|
|
3755
|
+
'.rw-rename-row{display:flex;align-items:center;gap:6px;padding:3px 0;font-size:12px;line-height:18px}',
|
|
3756
|
+
'.rw-rename-row.is-bad{color:var(--dsw-alias-state-error-primary)}',
|
|
3757
|
+
'.rw-rename-from{flex:1 1 0;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--dsw-alias-label-secondary)}',
|
|
3758
|
+
'.rw-rename-arrow{flex:none;color:var(--dsw-alias-label-tertiary)}',
|
|
3759
|
+
'.rw-rename-to{flex:1 1 0;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-weight:500}',
|
|
3643
3760
|
'.rw-queue-label{flex:1 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}',
|
|
3644
3761
|
'.rw-queue-state{flex:none;font-size:10.5px;color:var(--dsw-alias-label-tertiary)}',
|
|
3645
3762
|
].join('\n');
|
|
@@ -3814,13 +3931,16 @@ function attributeViolation(name, value, tagName) {
|
|
|
3814
3931
|
var remote = record.remotePath;
|
|
3815
3932
|
var local = record.localPath || '';
|
|
3816
3933
|
|
|
3817
|
-
|
|
3818
|
-
|
|
3819
|
-
|
|
3820
|
-
|
|
3934
|
+
// Second line: the SSH host that backs this workspace plus its live
|
|
3935
|
+
// connection state, e.g. "RTX-PRO-6000-1 · 已连接". Both pieces come from
|
|
3936
|
+
// the same record, so a host without a name still shows the state alone.
|
|
3937
|
+
var stateLine = document.createElement('div');
|
|
3938
|
+
stateLine.className = 'rw-hover-host' + (record.disconnected ? ' is-off' : record.connected ? ' is-on' : '');
|
|
3939
|
+
stateLine.setAttribute(HOVER_LINE_ATTR, '1');
|
|
3940
|
+
stateLine.textContent = record.host ? record.host + ' · ' + record.status : record.status;
|
|
3821
3941
|
var titleEl = card.querySelector('[class*="hoverTitle"]');
|
|
3822
3942
|
var anchor = titleEl || pathEl;
|
|
3823
|
-
anchor.parentNode.insertBefore(
|
|
3943
|
+
anchor.parentNode.insertBefore(stateLine, anchor.nextSibling);
|
|
3824
3944
|
|
|
3825
3945
|
if (record.kind === 'linked' && local !== '') {
|
|
3826
3946
|
pathEl.textContent = t('pathRemoteShort') + ' ' + remote;
|
|
@@ -3887,6 +4007,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
3887
4007
|
records[key] = {
|
|
3888
4008
|
kind: entry.kind,
|
|
3889
4009
|
name: item.name,
|
|
4010
|
+
host: item.hostName || item.host || '',
|
|
3890
4011
|
remotePath: item.remotePath || '',
|
|
3891
4012
|
localPath: linked ? (item.localPath || '') : '',
|
|
3892
4013
|
status: statusLabel(t, item),
|
|
@@ -4373,7 +4494,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
4373
4494
|
placeholder: t('filterPlaceholder'),
|
|
4374
4495
|
'aria-label': t('filterPlaceholder'),
|
|
4375
4496
|
spellCheck: false,
|
|
4376
|
-
onChange: function (event) { setLocal(function (previous) { return Object.assign({}, previous, { filter:
|
|
4497
|
+
onChange: function (event) { var value = event.currentTarget.value; setLocal(function (previous) { return Object.assign({}, previous, { filter: value }); }); },
|
|
4377
4498
|
})),
|
|
4378
4499
|
h('div', { className: 'rw-browser-list', role: 'list' },
|
|
4379
4500
|
local.error
|
|
@@ -4397,10 +4518,9 @@ function attributeViolation(name, value, tagName) {
|
|
|
4397
4518
|
className: 'rw-input rw-input-mono', style: { height: 28, fontSize: 11.5 },
|
|
4398
4519
|
value: local.input,
|
|
4399
4520
|
spellCheck: false,
|
|
4400
|
-
onChange: function (event) { setLocal(function (previous) { return Object.assign({}, previous, { input:
|
|
4521
|
+
onChange: function (event) { var value = event.currentTarget.value; setLocal(function (previous) { return Object.assign({}, previous, { input: value }); }); },
|
|
4401
4522
|
onKeyDown: function (event) { if (event.key === 'Enter') navigate(local.input); },
|
|
4402
4523
|
}),
|
|
4403
|
-
h('button', { type: 'button', className: 'rw-btn rw-btn-sm', onClick: function () { navigate(local.input); } }, t('open')),
|
|
4404
4524
|
typeof window !== 'undefined' && typeof window.__DSH_DESKTOP_PICK_DIRECTORY__ === 'function'
|
|
4405
4525
|
? h('button', { type: 'button', className: 'rw-btn rw-btn-sm', onClick: nativePick, title: t('nativePicker') }, t('nativePicker'))
|
|
4406
4526
|
: null,
|
|
@@ -4419,7 +4539,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
4419
4539
|
h('input', {
|
|
4420
4540
|
className: 'rw-input', style: { height: 28, fontSize: 12 }, placeholder: t('folderName'),
|
|
4421
4541
|
value: local.folderName, autoFocus: true,
|
|
4422
|
-
onChange: function (event) { setLocal(function (previous) { return Object.assign({}, previous, { folderName:
|
|
4542
|
+
onChange: function (event) { var value = event.currentTarget.value; setLocal(function (previous) { return Object.assign({}, previous, { folderName: value }); }); },
|
|
4423
4543
|
onKeyDown: function (event) { if (event.key === 'Enter') createFolder(); },
|
|
4424
4544
|
}),
|
|
4425
4545
|
h('button', { type: 'button', className: 'rw-btn rw-btn-sm rw-btn-primary', disabled: local.folderName.trim() === '', onClick: createFolder }, t('create')),
|
|
@@ -4434,7 +4554,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
4434
4554
|
var t = props.t;
|
|
4435
4555
|
var locale = props.locale;
|
|
4436
4556
|
var hostId = props.hostId;
|
|
4437
|
-
var state = useState({ loading: true, listing: null, error: '', input: props.initialPath || '', filter: '' });
|
|
4557
|
+
var state = useState({ loading: true, listing: null, error: '', input: props.initialPath || '', filter: '', creating: false, folderName: '', busy: false });
|
|
4438
4558
|
var remote = state[0];
|
|
4439
4559
|
var setRemote = state[1];
|
|
4440
4560
|
|
|
@@ -4460,6 +4580,20 @@ function attributeViolation(name, value, tagName) {
|
|
|
4460
4580
|
load(path);
|
|
4461
4581
|
}
|
|
4462
4582
|
|
|
4583
|
+
function createFolder() {
|
|
4584
|
+
var name = remote.folderName.trim();
|
|
4585
|
+
if (name === '' || !listing || remote.busy) return;
|
|
4586
|
+
setRemote(function (previous) { return Object.assign({}, previous, { busy: true, error: '' }); });
|
|
4587
|
+
apiCall('hosts.mkdir', { hostId: hostId, path: listing.path, name: name }).then(function (result) {
|
|
4588
|
+
setRemote(function (previous) { return Object.assign({}, previous, { busy: false, creating: false, folderName: '' }); });
|
|
4589
|
+
// Land inside the folder that was just made: it is almost always the
|
|
4590
|
+
// directory the user wants to pick.
|
|
4591
|
+
load(result && result.path ? result.path : listing.path);
|
|
4592
|
+
}).catch(function (error) {
|
|
4593
|
+
setRemote(function (previous) { return Object.assign({}, previous, { busy: false, error: messageOf(error, t, locale) }); });
|
|
4594
|
+
});
|
|
4595
|
+
}
|
|
4596
|
+
|
|
4463
4597
|
var listing = remote.listing;
|
|
4464
4598
|
var dirs = listing ? (listing.entries || []).filter(function (entry) { return entry.type === 'dir'; }) : [];
|
|
4465
4599
|
var PICKER_LIMIT = 500;
|
|
@@ -4502,7 +4636,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
4502
4636
|
placeholder: t('filterPlaceholder'),
|
|
4503
4637
|
'aria-label': t('filterPlaceholder'),
|
|
4504
4638
|
spellCheck: false,
|
|
4505
|
-
onChange: function (event) { setRemote(function (previous) { return Object.assign({}, previous, { filter:
|
|
4639
|
+
onChange: function (event) { var value = event.currentTarget.value; setRemote(function (previous) { return Object.assign({}, previous, { filter: value }); }); },
|
|
4506
4640
|
})),
|
|
4507
4641
|
h('div', { className: 'rw-browser-list', role: 'list' },
|
|
4508
4642
|
remote.error
|
|
@@ -4520,14 +4654,43 @@ function attributeViolation(name, value, tagName) {
|
|
|
4520
4654
|
pickerTruncated
|
|
4521
4655
|
? h('div', { className: 'rw-row-msg' }, t('pickerTruncated', { count: PICKER_LIMIT }))
|
|
4522
4656
|
: null),
|
|
4523
|
-
h('div', { className: 'rw-browser-actions', style: { padding: '8px' } },
|
|
4524
|
-
h('
|
|
4525
|
-
(
|
|
4526
|
-
|
|
4527
|
-
|
|
4528
|
-
|
|
4529
|
-
|
|
4530
|
-
|
|
4657
|
+
h('div', { className: 'rw-browser-actions', style: { padding: '8px', gap: 8 } },
|
|
4658
|
+
h('div', { className: 'rw-inline', style: { minWidth: 0, flex: '1 1 auto', flexWrap: 'nowrap' } },
|
|
4659
|
+
h('span', {
|
|
4660
|
+
className: 'rw-hint rw-input-mono rw-path-text',
|
|
4661
|
+
title: remote.input || (listing && listing.path) || '',
|
|
4662
|
+
}, (listing && listing.path) || (remote.input !== '' ? remote.input : t('home'))),
|
|
4663
|
+
h('button', {
|
|
4664
|
+
type: 'button', className: 'rw-btn rw-btn-sm',
|
|
4665
|
+
disabled: !listing || remote.loading,
|
|
4666
|
+
onClick: function () { setRemote(function (previous) { return Object.assign({}, previous, { creating: !previous.creating, folderName: '' }); }); },
|
|
4667
|
+
}, IconPlus(12), t('newFolder'))),
|
|
4668
|
+
h('div', { className: 'rw-actions', style: { flex: 'none' } },
|
|
4669
|
+
h('button', {
|
|
4670
|
+
type: 'button', className: 'rw-btn rw-btn-sm rw-btn-primary',
|
|
4671
|
+
disabled: !listing || remote.loading,
|
|
4672
|
+
onClick: function () { if (listing && props.onPick) props.onPick(listing.path); },
|
|
4673
|
+
}, IconCheck(12), t('useThisDir')))),
|
|
4674
|
+
remote.creating
|
|
4675
|
+
? h('div', { className: 'rw-browser-actions', style: { padding: '0 8px 8px', gap: 8 } },
|
|
4676
|
+
h('div', { className: 'rw-inline', style: { minWidth: 0, flex: '1 1 auto', flexWrap: 'nowrap' } },
|
|
4677
|
+
h('input', {
|
|
4678
|
+
className: 'rw-input', style: { height: 28, fontSize: 12 }, placeholder: t('folderName'),
|
|
4679
|
+
value: remote.folderName, autoFocus: true,
|
|
4680
|
+
onChange: function (event) { var value = event.currentTarget.value; setRemote(function (previous) { return Object.assign({}, previous, { folderName: value }); }); },
|
|
4681
|
+
onKeyDown: function (event) { if (event.key === 'Enter') createFolder(); },
|
|
4682
|
+
})),
|
|
4683
|
+
h('div', { className: 'rw-actions', style: { flex: 'none' } },
|
|
4684
|
+
h('button', {
|
|
4685
|
+
type: 'button', className: 'rw-btn rw-btn-sm rw-btn-primary',
|
|
4686
|
+
disabled: remote.busy || remote.folderName.trim() === '',
|
|
4687
|
+
onClick: createFolder,
|
|
4688
|
+
}, t('create')),
|
|
4689
|
+
h('button', {
|
|
4690
|
+
type: 'button', className: 'rw-btn rw-btn-sm',
|
|
4691
|
+
onClick: function () { setRemote(function (previous) { return Object.assign({}, previous, { creating: false, folderName: '' }); }); },
|
|
4692
|
+
}, t('cancel'))))
|
|
4693
|
+
: null);
|
|
4531
4694
|
}
|
|
4532
4695
|
|
|
4533
4696
|
function ScopePathPicker(props) {
|
|
@@ -4842,6 +5005,31 @@ function attributeViolation(name, value, tagName) {
|
|
|
4842
5005
|
return nodes;
|
|
4843
5006
|
}
|
|
4844
5007
|
|
|
5008
|
+
// Rows are plain buttons, so ↑/↓/Home/End only have to move focus; the
|
|
5009
|
+
// browser keeps the click and Enter behaviour for free.
|
|
5010
|
+
var LIST_KEY_STEP = { ArrowDown: 1, ArrowUp: -1 };
|
|
5011
|
+
|
|
5012
|
+
function handleListKeys(event, container, selector) {
|
|
5013
|
+
if (!container) return false;
|
|
5014
|
+
if (event.ctrlKey || event.metaKey || event.altKey) return false;
|
|
5015
|
+
var step = LIST_KEY_STEP[event.key];
|
|
5016
|
+
var isHome = event.key === 'Home';
|
|
5017
|
+
var isEnd = event.key === 'End';
|
|
5018
|
+
if (step === undefined && !isHome && !isEnd) return false;
|
|
5019
|
+
var rows = Array.prototype.slice.call(container.querySelectorAll(selector));
|
|
5020
|
+
if (rows.length === 0) return false;
|
|
5021
|
+
var index = rows.indexOf(document.activeElement);
|
|
5022
|
+
var next;
|
|
5023
|
+
if (isHome) next = 0;
|
|
5024
|
+
else if (isEnd) next = rows.length - 1;
|
|
5025
|
+
else if (index === -1) next = step > 0 ? 0 : rows.length - 1;
|
|
5026
|
+
else next = Math.min(rows.length - 1, Math.max(0, index + step));
|
|
5027
|
+
event.preventDefault();
|
|
5028
|
+
event.stopPropagation();
|
|
5029
|
+
rows[next].focus();
|
|
5030
|
+
return true;
|
|
5031
|
+
}
|
|
5032
|
+
|
|
4845
5033
|
function RemoteFileEditor(props) {
|
|
4846
5034
|
var ctx = props.ctx;
|
|
4847
5035
|
var t = props.t;
|
|
@@ -4901,6 +5089,45 @@ function attributeViolation(name, value, tagName) {
|
|
|
4901
5089
|
if (typeof props.onDirtyChange === 'function') props.onDirtyChange(dirty);
|
|
4902
5090
|
}, [dirty]);
|
|
4903
5091
|
|
|
5092
|
+
// A content-search hit opens the file at the matching line: place the
|
|
5093
|
+
// caret on it and centre the row, but only once per (file, line) pair so
|
|
5094
|
+
// typing and saving never yank the viewport back.
|
|
5095
|
+
var jumpedRef = useRef('');
|
|
5096
|
+
useEffect(function () {
|
|
5097
|
+
var target = Number(props.focusLine) || 0;
|
|
5098
|
+
if (target <= 0 || load.loading || load.error || content === '') return undefined;
|
|
5099
|
+
var stamp = filePath + '#' + target;
|
|
5100
|
+
if (jumpedRef.current === stamp) return undefined;
|
|
5101
|
+
// The textarea can mount one commit after the content arrives, so retry
|
|
5102
|
+
// for a few frames instead of giving up on the first pass.
|
|
5103
|
+
var tries = 0;
|
|
5104
|
+
var timers = [];
|
|
5105
|
+
function attempt() {
|
|
5106
|
+
if (jumpedRef.current === stamp) return;
|
|
5107
|
+
var area = textareaRef.current;
|
|
5108
|
+
if (!area) {
|
|
5109
|
+
if (tries < 12) { tries += 1; timers.push(setTimeout(attempt, 40)); }
|
|
5110
|
+
return;
|
|
5111
|
+
}
|
|
5112
|
+
jumpedRef.current = stamp;
|
|
5113
|
+
var lines = String(content).split('\n');
|
|
5114
|
+
var offset = 0;
|
|
5115
|
+
var last = Math.min(Math.max(target - 1, 0), Math.max(lines.length - 1, 0));
|
|
5116
|
+
for (var index = 0; index < last; index += 1) offset += lines[index].length + 1;
|
|
5117
|
+
var end = offset + (lines[last] ? lines[last].length : 0);
|
|
5118
|
+
try {
|
|
5119
|
+
area.focus();
|
|
5120
|
+
area.setSelectionRange(offset, end);
|
|
5121
|
+
} catch (error) { /* not focusable yet */ }
|
|
5122
|
+
var lineHeight = 18;
|
|
5123
|
+
area.scrollTop = Math.max(0, (last - 4) * lineHeight);
|
|
5124
|
+
if (highlightRef.current) highlightRef.current.scrollTop = area.scrollTop;
|
|
5125
|
+
if (gutterRef.current) gutterRef.current.scrollTop = area.scrollTop;
|
|
5126
|
+
}
|
|
5127
|
+
attempt();
|
|
5128
|
+
return function () { timers.forEach(function (timer) { clearTimeout(timer); }); };
|
|
5129
|
+
}, [filePath, props.focusLine, load.loading, load.error, content]);
|
|
5130
|
+
|
|
4904
5131
|
useEffect(function () {
|
|
4905
5132
|
if (!sidebar || typeof sidebar.updateTab !== 'function' || !props.tabId) return;
|
|
4906
5133
|
try {
|
|
@@ -5479,6 +5706,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
5479
5706
|
className: 'rw-tree',
|
|
5480
5707
|
role: 'tree',
|
|
5481
5708
|
'aria-label': t('allFiles'),
|
|
5709
|
+
onKeyDown: function (event) { handleListKeys(event, event.currentTarget, '[role="treeitem"]'); },
|
|
5482
5710
|
onDragOver: function (event) {
|
|
5483
5711
|
if (!props.onDropOnPath) return;
|
|
5484
5712
|
event.preventDefault();
|
|
@@ -5512,6 +5740,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
5512
5740
|
selectedPath: props.selectedPath || '',
|
|
5513
5741
|
selectedSet: props.selectedPaths && props.selectedPaths.length > 0 ? new Set(props.selectedPaths) : null,
|
|
5514
5742
|
siblings: rootSiblings,
|
|
5743
|
+
statSide: props.kind || 'remote',
|
|
5515
5744
|
}));
|
|
5516
5745
|
}
|
|
5517
5746
|
|
|
@@ -5641,6 +5870,8 @@ function attributeViolation(name, value, tagName) {
|
|
|
5641
5870
|
var t = props.t;
|
|
5642
5871
|
var locale = props.locale;
|
|
5643
5872
|
var state = props.state;
|
|
5873
|
+
var contentMode = props.mode === 'content';
|
|
5874
|
+
var resultsRef = useRef(null);
|
|
5644
5875
|
var groups = [
|
|
5645
5876
|
{ side: 'remote', label: t('remoteTree'), entries: state.remote || [] },
|
|
5646
5877
|
{ side: 'local', label: t('localTree'), entries: props.hasLocal ? state.local || [] : [] },
|
|
@@ -5658,26 +5889,46 @@ function attributeViolation(name, value, tagName) {
|
|
|
5658
5889
|
});
|
|
5659
5890
|
}
|
|
5660
5891
|
var total = groups.reduce(function (sum, group) { return sum + group.entries.length; }, 0);
|
|
5661
|
-
|
|
5892
|
+
// The Host reports *why* it stopped, because "too many results" and "the
|
|
5893
|
+
// search timed out" need different advice from the user.
|
|
5894
|
+
var reasonKey = state.truncatedReason === 'files' ? 'searchTruncatedFiles'
|
|
5895
|
+
: state.truncatedReason === 'bytes' ? 'searchTruncatedBytes'
|
|
5896
|
+
: state.truncatedReason === 'deadline' ? 'searchTruncatedDeadline'
|
|
5897
|
+
: 'searchTruncated';
|
|
5898
|
+
return h('div', {
|
|
5899
|
+
className: 'rw-search-results',
|
|
5900
|
+
ref: resultsRef,
|
|
5901
|
+
onKeyDown: function (event) { handleListKeys(event, resultsRef.current, '.rw-result-row'); },
|
|
5902
|
+
},
|
|
5662
5903
|
state.error ? h(Banner, { kind: 'error' }, state.error) : null,
|
|
5663
5904
|
state.loading ? h('div', { className: 'rw-hint-row' }, Spinner(12), t('loading')) : null,
|
|
5664
5905
|
!state.loading && total === 0 ? h('div', { className: 'rw-hint-row' }, t('searchEmpty')) : null,
|
|
5665
|
-
!state.loading && state.truncated ? h('div', { className: 'rw-hint-row' }, t(
|
|
5906
|
+
!state.loading && state.truncated ? h('div', { className: 'rw-hint-row' }, t(reasonKey)) : null,
|
|
5666
5907
|
groups.map(function (group) {
|
|
5667
5908
|
if (group.entries.length === 0) return null;
|
|
5668
5909
|
return h('div', { key: group.side, className: 'rw-change-group' },
|
|
5669
5910
|
h('div', { className: 'rw-change-group-title' }, group.label, h('span', { className: 'rw-change-meta' }, String(group.entries.length))),
|
|
5670
5911
|
group.entries.map(function (entry) {
|
|
5912
|
+
var line = Number(entry.line) || 0;
|
|
5671
5913
|
return h('button', {
|
|
5672
|
-
key: group.side + ':' + entry.path,
|
|
5914
|
+
key: group.side + ':' + entry.path + ':' + line,
|
|
5673
5915
|
type: 'button',
|
|
5674
|
-
className: 'rw-result-row',
|
|
5675
|
-
title: entry.path,
|
|
5916
|
+
className: 'rw-result-row' + (contentMode ? ' is-content' : ''),
|
|
5917
|
+
title: line > 0 ? entry.path + ':' + line : entry.path,
|
|
5676
5918
|
onClick: function () { props.onOpen(group.side, entry.path, entry); },
|
|
5677
5919
|
},
|
|
5678
|
-
|
|
5679
|
-
|
|
5680
|
-
|
|
5920
|
+
contentMode
|
|
5921
|
+
? h('span', { className: 'rw-result-head' },
|
|
5922
|
+
h(FileGlyph, { name: entry.relative || entry.path, size: 13 }),
|
|
5923
|
+
h('span', { className: 'rw-change-path' }, entry.relative || entry.path),
|
|
5924
|
+
line > 0 ? h('span', { className: 'rw-result-line' }, ':' + line) : null,
|
|
5925
|
+
h('span', { className: 'rw-change-meta' }, group.side === 'remote' ? t('sideRemote') : t('sideLocal')))
|
|
5926
|
+
: [
|
|
5927
|
+
h(FileGlyph, { name: entry.relative || entry.path, size: 13 }),
|
|
5928
|
+
h('span', { className: 'rw-change-path' }, entry.relative || entry.path),
|
|
5929
|
+
h('span', { className: 'rw-change-meta' }, group.side === 'remote' ? t('sideRemote') : t('sideLocal')),
|
|
5930
|
+
],
|
|
5931
|
+
contentMode && entry.preview ? h('span', { className: 'rw-result-preview' }, entry.preview) : null);
|
|
5681
5932
|
}));
|
|
5682
5933
|
}));
|
|
5683
5934
|
}
|
|
@@ -5822,6 +6073,98 @@ function attributeViolation(name, value, tagName) {
|
|
|
5822
6073
|
}, items.map(renderItem)));
|
|
5823
6074
|
}
|
|
5824
6075
|
|
|
6076
|
+
// ── first-run welcome card ──────────────────────────────────────────────
|
|
6077
|
+
|
|
6078
|
+
// Shown once per browser profile: the flag lives in localStorage so the
|
|
6079
|
+
// dialog never reopens on refresh, and a fresh DSH install opens it again.
|
|
6080
|
+
var WELCOME_KEY = 'dsh-linked-workspace:welcome';
|
|
6081
|
+
// F6: the settings page can replay the card, so the flag is cleared and an
|
|
6082
|
+
// event wakes the overlay instead of the user hunting for local storage.
|
|
6083
|
+
var WELCOME_EVENT = 'dsh-linked-workspace:welcome-open';
|
|
6084
|
+
|
|
6085
|
+
function welcomeSeen() {
|
|
6086
|
+
try {
|
|
6087
|
+
if (typeof window === 'undefined' || !window.localStorage) return true;
|
|
6088
|
+
return window.localStorage.getItem(WELCOME_KEY) === '1';
|
|
6089
|
+
} catch (error) {
|
|
6090
|
+
return true;
|
|
6091
|
+
}
|
|
6092
|
+
}
|
|
6093
|
+
|
|
6094
|
+
function welcomeRemember() {
|
|
6095
|
+
try {
|
|
6096
|
+
if (typeof window !== 'undefined' && window.localStorage) window.localStorage.setItem(WELCOME_KEY, '1');
|
|
6097
|
+
} catch (error) { /* storage unavailable: the card simply shows again */ }
|
|
6098
|
+
}
|
|
6099
|
+
|
|
6100
|
+
function WelcomeRow(props) {
|
|
6101
|
+
return h('div', { className: 'rw-welcome-row' },
|
|
6102
|
+
h('div', { className: 'rw-welcome-row-main' }, props.main),
|
|
6103
|
+
h('div', { className: 'rw-welcome-row-where' }, props.where));
|
|
6104
|
+
}
|
|
6105
|
+
|
|
6106
|
+
function WelcomeCard(props) {
|
|
6107
|
+
var locale = useLocale(props.ctx);
|
|
6108
|
+
var t = useMemo(function () { return makeT(locale); }, [locale]);
|
|
6109
|
+
var state = useState(function () { return !welcomeSeen(); });
|
|
6110
|
+
var open = state[0];
|
|
6111
|
+
var setOpen = state[1];
|
|
6112
|
+
function close() { welcomeRemember(); setOpen(false); }
|
|
6113
|
+
useEffect(function () {
|
|
6114
|
+
function onReplay() { setOpen(true); }
|
|
6115
|
+
window.addEventListener(WELCOME_EVENT, onReplay);
|
|
6116
|
+
return function () { window.removeEventListener(WELCOME_EVENT, onReplay); };
|
|
6117
|
+
}, []);
|
|
6118
|
+
useEffect(function () {
|
|
6119
|
+
if (!open) return undefined;
|
|
6120
|
+
function onKey(event) {
|
|
6121
|
+
if (event.key !== 'Escape') return;
|
|
6122
|
+
event.preventDefault();
|
|
6123
|
+
event.stopPropagation();
|
|
6124
|
+
welcomeRemember();
|
|
6125
|
+
setOpen(false);
|
|
6126
|
+
}
|
|
6127
|
+
window.addEventListener('keydown', onKey, true);
|
|
6128
|
+
return function () { window.removeEventListener('keydown', onKey, true); };
|
|
6129
|
+
}, [open]);
|
|
6130
|
+
if (!open) return null;
|
|
6131
|
+
var rows = [
|
|
6132
|
+
{ main: t('welcomeCreate'), where: t('welcomeCreateWhere') },
|
|
6133
|
+
{ main: t('welcomeBrowse'), where: t('welcomeBrowseWhere') },
|
|
6134
|
+
{ main: t('welcomeTools'), where: t('welcomeToolsWhere') },
|
|
6135
|
+
{ main: t('welcomePassword'), where: t('welcomePasswordWhere') },
|
|
6136
|
+
];
|
|
6137
|
+
return h('div', {
|
|
6138
|
+
className: 'rw-welcome-backdrop',
|
|
6139
|
+
onMouseDown: function (event) { if (event.target === event.currentTarget) close(); },
|
|
6140
|
+
}, h('div', {
|
|
6141
|
+
className: 'rw-welcome',
|
|
6142
|
+
role: 'dialog',
|
|
6143
|
+
'aria-modal': 'true',
|
|
6144
|
+
'aria-label': t('welcomeTitle'),
|
|
6145
|
+
},
|
|
6146
|
+
h('button', {
|
|
6147
|
+
type: 'button',
|
|
6148
|
+
className: 'rw-welcome-x',
|
|
6149
|
+
'aria-label': t('close'),
|
|
6150
|
+
onClick: close,
|
|
6151
|
+
}, IconClose(14)),
|
|
6152
|
+
h('div', { className: 'rw-welcome-eyebrow' }, h('span', { className: 'rw-welcome-dot' }), t('welcomeEyebrow')),
|
|
6153
|
+
h('div', { className: 'rw-welcome-title' }, t('welcomeTitle')),
|
|
6154
|
+
h('div', { className: 'rw-welcome-lead' }, t('welcomeLead')),
|
|
6155
|
+
h('div', { className: 'rw-welcome-rows' }, rows.map(function (row, index) {
|
|
6156
|
+
return h(WelcomeRow, { key: String(index), main: row.main, where: row.where });
|
|
6157
|
+
})),
|
|
6158
|
+
h('div', { className: 'rw-welcome-foot' },
|
|
6159
|
+
h('a', {
|
|
6160
|
+
className: 'rw-btn rw-btn-primary',
|
|
6161
|
+
href: 'https://github.com/jiahui-huang1/dsh-linked-workspace',
|
|
6162
|
+
target: '_blank',
|
|
6163
|
+
rel: 'noreferrer',
|
|
6164
|
+
}, t('welcomeStar')),
|
|
6165
|
+
h('button', { type: 'button', className: 'rw-btn', onClick: close }, t('welcomeDone')))));
|
|
6166
|
+
}
|
|
6167
|
+
|
|
5825
6168
|
function DialogShell(props) {
|
|
5826
6169
|
return h('div', {
|
|
5827
6170
|
className: 'rw-dialog-backdrop',
|
|
@@ -5888,6 +6231,129 @@ function attributeViolation(name, value, tagName) {
|
|
|
5888
6231
|
h('button', { type: 'button', className: 'rw-btn rw-btn-sm rw-btn-danger', onClick: props.onConfirm }, props.confirmLabel)));
|
|
5889
6232
|
}
|
|
5890
6233
|
|
|
6234
|
+
// F2: renaming a dozen files one by one is the slowest thing left in the
|
|
6235
|
+
// tree, so a multi-selection gets a single batch dialog with a live preview.
|
|
6236
|
+
function BatchRenameDialog(props) {
|
|
6237
|
+
var t = props.t;
|
|
6238
|
+
var entries = props.entries || [];
|
|
6239
|
+
var modeState = useState('pattern');
|
|
6240
|
+
var mode = modeState[0];
|
|
6241
|
+
var setMode = modeState[1];
|
|
6242
|
+
var prefixState = useState('');
|
|
6243
|
+
var prefix = prefixState[0];
|
|
6244
|
+
var setPrefix = prefixState[1];
|
|
6245
|
+
var startState = useState('1');
|
|
6246
|
+
var start = startState[0];
|
|
6247
|
+
var setStart = startState[1];
|
|
6248
|
+
var padState = useState('2');
|
|
6249
|
+
var pad = padState[0];
|
|
6250
|
+
var setPad = padState[1];
|
|
6251
|
+
var findState = useState('');
|
|
6252
|
+
var find = findState[0];
|
|
6253
|
+
var setFind = findState[1];
|
|
6254
|
+
var replaceState = useState('');
|
|
6255
|
+
var replaceWith = replaceState[0];
|
|
6256
|
+
var setReplaceWith = replaceState[1];
|
|
6257
|
+
var busyState = useState(false);
|
|
6258
|
+
var busy = busyState[0];
|
|
6259
|
+
var setBusy = busyState[1];
|
|
6260
|
+
|
|
6261
|
+
function splitName(name) {
|
|
6262
|
+
var dot = String(name).lastIndexOf('.');
|
|
6263
|
+
if (dot <= 0) return { base: String(name), ext: '' };
|
|
6264
|
+
return { base: String(name).slice(0, dot), ext: String(name).slice(dot) };
|
|
6265
|
+
}
|
|
6266
|
+
|
|
6267
|
+
var pairs = entries.map(function (entry, index) {
|
|
6268
|
+
var parts = splitName(entry.name);
|
|
6269
|
+
var next = '';
|
|
6270
|
+
if (mode === 'pattern') {
|
|
6271
|
+
var number = String(Number(start || 0) + index).padStart(Math.max(1, Number(pad) || 1), '0');
|
|
6272
|
+
next = prefix + number + (entry.isDir ? '' : parts.ext);
|
|
6273
|
+
} else {
|
|
6274
|
+
next = find === '' ? entry.name : String(entry.name).split(find).join(replaceWith);
|
|
6275
|
+
}
|
|
6276
|
+
return { entry: entry, from: entry.name, to: next };
|
|
6277
|
+
});
|
|
6278
|
+
var seen = {};
|
|
6279
|
+
var conflict = false;
|
|
6280
|
+
var invalid = false;
|
|
6281
|
+
pairs.forEach(function (pair) {
|
|
6282
|
+
if (pair.to === '') invalid = true;
|
|
6283
|
+
if (seen[pair.to]) conflict = true;
|
|
6284
|
+
seen[pair.to] = true;
|
|
6285
|
+
if (pair.to !== pair.from && pairs.some(function (other) { return other.entry.name === pair.to; })) conflict = true;
|
|
6286
|
+
});
|
|
6287
|
+
var changed = pairs.filter(function (pair) { return pair.to !== pair.from; }).length;
|
|
6288
|
+
|
|
6289
|
+
function apply() {
|
|
6290
|
+
if (busy || invalid || conflict || changed === 0) return;
|
|
6291
|
+
setBusy(true);
|
|
6292
|
+
props.onApply(pairs.filter(function (pair) { return pair.to !== pair.from; })).then(function () {
|
|
6293
|
+
setBusy(false);
|
|
6294
|
+
props.onClose();
|
|
6295
|
+
}).catch(function () { setBusy(false); });
|
|
6296
|
+
}
|
|
6297
|
+
|
|
6298
|
+
return h(DialogShell, { title: t('renameManyTitle', { count: entries.length }), onClose: props.onClose },
|
|
6299
|
+
h('div', { className: 'rw-inline', style: { gap: 6, marginBottom: 10 } },
|
|
6300
|
+
h('button', {
|
|
6301
|
+
type: 'button',
|
|
6302
|
+
className: 'rw-chip-btn' + (mode === 'pattern' ? ' is-on' : ''),
|
|
6303
|
+
'aria-pressed': mode === 'pattern',
|
|
6304
|
+
onClick: function () { setMode('pattern'); },
|
|
6305
|
+
}, t('renameManyPattern')),
|
|
6306
|
+
h('button', {
|
|
6307
|
+
type: 'button',
|
|
6308
|
+
className: 'rw-chip-btn' + (mode === 'replace' ? ' is-on' : ''),
|
|
6309
|
+
'aria-pressed': mode === 'replace',
|
|
6310
|
+
onClick: function () { setMode('replace'); },
|
|
6311
|
+
}, t('renameManyReplace'))),
|
|
6312
|
+
mode === 'pattern'
|
|
6313
|
+
? h('div', { className: 'rw-inline', style: { gap: 6, marginBottom: 10 } },
|
|
6314
|
+
h('input', {
|
|
6315
|
+
className: 'rw-input', style: { flex: '2 1 0', minWidth: 0 }, value: prefix,
|
|
6316
|
+
placeholder: t('renameManyPrefix'), 'aria-label': t('renameManyPrefix'),
|
|
6317
|
+
onChange: function (event) { var value = event.currentTarget.value; setPrefix(value); },
|
|
6318
|
+
}),
|
|
6319
|
+
h('input', {
|
|
6320
|
+
className: 'rw-input rw-input-mono', style: { flex: '1 1 0', minWidth: 0 }, value: start,
|
|
6321
|
+
placeholder: t('renameManyStart'), 'aria-label': t('renameManyStart'),
|
|
6322
|
+
onChange: function (event) { var value = event.currentTarget.value; setStart(value.replace(/[^0-9]/g, '')); },
|
|
6323
|
+
}),
|
|
6324
|
+
h('input', {
|
|
6325
|
+
className: 'rw-input rw-input-mono', style: { flex: '1 1 0', minWidth: 0 }, value: pad,
|
|
6326
|
+
placeholder: t('renameManyPad'), 'aria-label': t('renameManyPad'),
|
|
6327
|
+
onChange: function (event) { var value = event.currentTarget.value; setPad(value.replace(/[^0-9]/g, '')); },
|
|
6328
|
+
}))
|
|
6329
|
+
: h('div', { className: 'rw-inline', style: { gap: 6, marginBottom: 10 } },
|
|
6330
|
+
h('input', {
|
|
6331
|
+
className: 'rw-input', style: { flex: '1 1 0', minWidth: 0 }, value: find,
|
|
6332
|
+
placeholder: t('renameManyFind'), 'aria-label': t('renameManyFind'),
|
|
6333
|
+
onChange: function (event) { var value = event.currentTarget.value; setFind(value); },
|
|
6334
|
+
}),
|
|
6335
|
+
h('input', {
|
|
6336
|
+
className: 'rw-input', style: { flex: '1 1 0', minWidth: 0 }, value: replaceWith,
|
|
6337
|
+
placeholder: t('renameManyReplaceWith'), 'aria-label': t('renameManyReplaceWith'),
|
|
6338
|
+
onChange: function (event) { var value = event.currentTarget.value; setReplaceWith(value); },
|
|
6339
|
+
})),
|
|
6340
|
+
h('div', { className: 'rw-rename-preview' }, pairs.slice(0, 50).map(function (pair) {
|
|
6341
|
+
return h('div', { key: pair.entry.path, className: 'rw-rename-row' + (pair.to === '' || seen[pair.to] > 1 ? ' is-bad' : '') },
|
|
6342
|
+
h('span', { className: 'rw-rename-from', title: pair.entry.path }, pair.from),
|
|
6343
|
+
h('span', { className: 'rw-rename-arrow' }, '→'),
|
|
6344
|
+
h('span', { className: 'rw-rename-to' }, pair.to === '' ? t('renameManyEmpty') : pair.to));
|
|
6345
|
+
})),
|
|
6346
|
+
conflict ? h('div', { className: 'rw-dialog-message rw-dialog-error' }, t('renameManyConflict')) : null,
|
|
6347
|
+
h('div', { className: 'rw-dialog-actions' },
|
|
6348
|
+
h('button', { type: 'button', className: 'rw-btn rw-btn-sm', onClick: props.onClose }, t('cancel')),
|
|
6349
|
+
h('button', {
|
|
6350
|
+
type: 'button',
|
|
6351
|
+
className: 'rw-btn rw-btn-sm rw-btn-primary',
|
|
6352
|
+
disabled: busy || invalid || conflict || changed === 0,
|
|
6353
|
+
onClick: apply,
|
|
6354
|
+
}, t(busy ? 'loading' : 'renameManyApply', { count: changed }))));
|
|
6355
|
+
}
|
|
6356
|
+
|
|
5891
6357
|
function PropertiesDialog(props) {
|
|
5892
6358
|
return h(DialogShell, { title: props.title, onClose: props.onClose },
|
|
5893
6359
|
h('div', { className: 'rw-props' }, props.rows.map(function (row) {
|
|
@@ -5987,6 +6453,14 @@ function attributeViolation(name, value, tagName) {
|
|
|
5987
6453
|
return h('div', { key: entry.id, className: 'rw-queue-row' },
|
|
5988
6454
|
h('span', { className: 'rw-queue-label', title: entry.path }, entry.label),
|
|
5989
6455
|
h('span', { className: 'rw-queue-state' }, entry.message || entry.state),
|
|
6456
|
+
entry.state === 'running' && props.onCancel
|
|
6457
|
+
? h('button', {
|
|
6458
|
+
type: 'button',
|
|
6459
|
+
className: 'rw-btn rw-btn-sm',
|
|
6460
|
+
disabled: Boolean(entry.cancelling),
|
|
6461
|
+
onClick: function () { props.onCancel(entry); },
|
|
6462
|
+
}, props.t('queueCancel'))
|
|
6463
|
+
: null,
|
|
5990
6464
|
entry.state === 'error' && props.onRetry
|
|
5991
6465
|
? h('button', {
|
|
5992
6466
|
type: 'button',
|
|
@@ -6404,7 +6878,16 @@ function attributeViolation(name, value, tagName) {
|
|
|
6404
6878
|
var searchModeState = useState('name');
|
|
6405
6879
|
var searchMode = searchModeState[0];
|
|
6406
6880
|
var setSearchMode = searchModeState[1];
|
|
6407
|
-
var
|
|
6881
|
+
var searchCaseState = useState(false);
|
|
6882
|
+
var searchCase = searchCaseState[0];
|
|
6883
|
+
var setSearchCase = searchCaseState[1];
|
|
6884
|
+
var searchRegexState = useState(false);
|
|
6885
|
+
var searchRegex = searchRegexState[0];
|
|
6886
|
+
var setSearchRegex = searchRegexState[1];
|
|
6887
|
+
var searchHereState = useState(false);
|
|
6888
|
+
var searchHere = searchHereState[0];
|
|
6889
|
+
var setSearchHere = searchHereState[1];
|
|
6890
|
+
var searchState = useState({ loading: false, remote: [], local: [], truncated: false, truncatedReason: '', error: null });
|
|
6408
6891
|
var search = searchState[0];
|
|
6409
6892
|
var setSearch = searchState[1];
|
|
6410
6893
|
var gitState = useState({ loading: false, remote: null, local: null, error: null });
|
|
@@ -6704,6 +7187,12 @@ function attributeViolation(name, value, tagName) {
|
|
|
6704
7187
|
setOpenFiles(function (previous) {
|
|
6705
7188
|
var existing = previous.filter(function (file) { return file.key === key; })[0];
|
|
6706
7189
|
if (existing) {
|
|
7190
|
+
var wanted = Number(opts.line) || 0;
|
|
7191
|
+
if (wanted > 0 && existing.line !== wanted) {
|
|
7192
|
+
// Re-opening the same file from another hit must move the caret,
|
|
7193
|
+
// so the line travels with the tab instead of being dropped.
|
|
7194
|
+
return previous.map(function (file) { return file.key === key ? Object.assign({}, file, { line: wanted, pinned: Boolean(opts.pinned) || file.pinned }) : file; });
|
|
7195
|
+
}
|
|
6707
7196
|
if (opts.pinned && !existing.pinned) {
|
|
6708
7197
|
return previous.map(function (file) { return file.key === key ? Object.assign({}, file, { pinned: true }) : file; });
|
|
6709
7198
|
}
|
|
@@ -6716,13 +7205,13 @@ function attributeViolation(name, value, tagName) {
|
|
|
6716
7205
|
var active = previous[activeIndex];
|
|
6717
7206
|
if (!active.pinned && !fileDirty[active.key]) {
|
|
6718
7207
|
var replaced = previous.slice();
|
|
6719
|
-
replaced[activeIndex] = { key: key, side: side, path: filePath, name: basename(filePath), pinned: false };
|
|
7208
|
+
replaced[activeIndex] = { key: key, side: side, path: filePath, name: basename(filePath), pinned: false, line: Number(opts.line) || 0 };
|
|
6720
7209
|
setFileDirty(function (dirtyMap) { var copy = Object.assign({}, dirtyMap); delete copy[active.key]; return copy; });
|
|
6721
7210
|
return replaced;
|
|
6722
7211
|
}
|
|
6723
7212
|
}
|
|
6724
7213
|
}
|
|
6725
|
-
return previous.concat([{ key: key, side: side, path: filePath, name: basename(filePath), pinned: Boolean(opts.pinned) }]);
|
|
7214
|
+
return previous.concat([{ key: key, side: side, path: filePath, name: basename(filePath), pinned: Boolean(opts.pinned), line: Number(opts.line) || 0 }]);
|
|
6726
7215
|
});
|
|
6727
7216
|
setActiveFileKey(key);
|
|
6728
7217
|
setDirectoryOpen(true);
|
|
@@ -6886,10 +7375,13 @@ function attributeViolation(name, value, tagName) {
|
|
|
6886
7375
|
function enqueueTransfer(side, filePath, name) {
|
|
6887
7376
|
var entry = {
|
|
6888
7377
|
id: String(Date.now()) + Math.random().toString(16).slice(2),
|
|
7378
|
+
jobId: 'job-' + String(Date.now()) + '-' + Math.random().toString(16).slice(2, 8),
|
|
6889
7379
|
side: side || 'remote',
|
|
6890
7380
|
path: filePath,
|
|
6891
7381
|
label: name,
|
|
6892
7382
|
state: 'queued',
|
|
7383
|
+
files: 0,
|
|
7384
|
+
bytes: 0,
|
|
6893
7385
|
message: t('queueQueued'),
|
|
6894
7386
|
};
|
|
6895
7387
|
queueRef.current = queueRef.current.concat([entry]);
|
|
@@ -6897,23 +7389,49 @@ function attributeViolation(name, value, tagName) {
|
|
|
6897
7389
|
pumpQueue();
|
|
6898
7390
|
}
|
|
6899
7391
|
|
|
7392
|
+
/** Ask the Host to stop a running transfer after the current file. */
|
|
7393
|
+
function cancelTransfer(entry) {
|
|
7394
|
+
if (!entry || !entry.jobId) return;
|
|
7395
|
+
entry.cancelling = true;
|
|
7396
|
+
entry.message = t('queueCancelling');
|
|
7397
|
+
setQueueList(queueRef.current.slice());
|
|
7398
|
+
apiCall('fs.transferCancel', { jobId: entry.jobId }).catch(function () { /* the transfer may be over */ });
|
|
7399
|
+
}
|
|
7400
|
+
|
|
6900
7401
|
function pumpQueue() {
|
|
6901
7402
|
if (queueRunning.current) return;
|
|
6902
7403
|
var next = queueRef.current.filter(function (entry) { return entry.state === 'queued'; })[0];
|
|
6903
7404
|
if (!next) return;
|
|
6904
7405
|
queueRunning.current = true;
|
|
6905
7406
|
next.state = 'running';
|
|
7407
|
+
next.files = 0;
|
|
7408
|
+
next.bytes = 0;
|
|
6906
7409
|
next.message = t('queueRunning');
|
|
6907
7410
|
setQueueList(queueRef.current.slice());
|
|
6908
|
-
|
|
7411
|
+
// Poll the Host while the transfer runs: a folder can take minutes and
|
|
7412
|
+
// the row otherwise sits on “running” with no evidence of progress.
|
|
7413
|
+
var poll = setInterval(function () {
|
|
7414
|
+
apiCall('fs.transferProgress', { jobId: next.jobId }).then(function (result) {
|
|
7415
|
+
var job = result && result.job;
|
|
7416
|
+
if (!job || next.state !== 'running') return;
|
|
7417
|
+
next.files = job.files;
|
|
7418
|
+
next.bytes = job.bytes;
|
|
7419
|
+
next.message = t('queueProgress', { files: job.files, size: formatBytes(job.bytes) });
|
|
7420
|
+
setQueueList(queueRef.current.slice());
|
|
7421
|
+
}).catch(function () { /* progress is best-effort */ });
|
|
7422
|
+
}, 700);
|
|
7423
|
+
apiCall('fs.transfer', Object.assign({ side: next.side || 'remote', path: next.path, jobId: next.jobId }, scopeParams(scopeRef))).then(function (result) {
|
|
6909
7424
|
next.state = 'done';
|
|
6910
7425
|
next.message = t('transferDone', { files: result.files, size: formatBytes(result.bytes) }) + (result.truncated ? t('transferTruncated') : '');
|
|
6911
7426
|
showNotice('success', next.message);
|
|
6912
7427
|
refreshTree();
|
|
6913
7428
|
}).catch(function (error) {
|
|
6914
|
-
|
|
6915
|
-
next.
|
|
7429
|
+
var cancelled = error && error.code === 'CANCELLED';
|
|
7430
|
+
next.state = cancelled ? 'cancelled' : 'error';
|
|
7431
|
+
next.message = cancelled ? t('queueCancelled', { files: next.files }) : messageOf(error, t, locale);
|
|
6916
7432
|
}).then(function () {
|
|
7433
|
+
clearInterval(poll);
|
|
7434
|
+
next.cancelling = false;
|
|
6917
7435
|
setQueueList(queueRef.current.slice());
|
|
6918
7436
|
queueRunning.current = false;
|
|
6919
7437
|
pumpQueue();
|
|
@@ -7011,11 +7529,21 @@ function attributeViolation(name, value, tagName) {
|
|
|
7011
7529
|
|
|
7012
7530
|
function beginDragRow(side, event, info) {
|
|
7013
7531
|
if (!event.dataTransfer || !info) return;
|
|
7532
|
+
// Dragging one row of a multi-selection carries the whole selection, so
|
|
7533
|
+
// a single gesture can move or copy several entries at once.
|
|
7534
|
+
var picked = selectionFor(side).filter(function (item) {
|
|
7535
|
+
return item && typeof item.path === 'string';
|
|
7536
|
+
});
|
|
7537
|
+
var containsDragged = picked.some(function (item) { return item.path === info.path; });
|
|
7538
|
+
var entries = (containsDragged && picked.length > 1 ? picked : [{ path: info.path, name: info.name, isDir: Boolean(info.isDir) }])
|
|
7539
|
+
.map(function (item) {
|
|
7540
|
+
return { path: item.path, name: item.name, isDir: Boolean(item.isDir) };
|
|
7541
|
+
});
|
|
7014
7542
|
try {
|
|
7015
7543
|
event.dataTransfer.setData(DRAG_MIME, JSON.stringify({
|
|
7016
|
-
side: side, path: info.path, name: info.name, isDir: Boolean(info.isDir),
|
|
7544
|
+
side: side, path: info.path, name: info.name, isDir: Boolean(info.isDir), entries: entries,
|
|
7017
7545
|
}));
|
|
7018
|
-
event.dataTransfer.effectAllowed = '
|
|
7546
|
+
event.dataTransfer.effectAllowed = 'copyMove';
|
|
7019
7547
|
} catch (error) { /* drag payload unsupported */ }
|
|
7020
7548
|
}
|
|
7021
7549
|
|
|
@@ -7076,41 +7604,142 @@ function attributeViolation(name, value, tagName) {
|
|
|
7076
7604
|
var raw = '';
|
|
7077
7605
|
try { raw = transfer.getData(DRAG_MIME); } catch (error) { raw = ''; }
|
|
7078
7606
|
if (!raw) return;
|
|
7079
|
-
var
|
|
7080
|
-
try {
|
|
7081
|
-
if (!
|
|
7082
|
-
|
|
7083
|
-
|
|
7607
|
+
var payload;
|
|
7608
|
+
try { payload = JSON.parse(raw); } catch (error) { return; }
|
|
7609
|
+
if (!payload || typeof payload.path !== 'string') return;
|
|
7610
|
+
var entries = Array.isArray(payload.entries)
|
|
7611
|
+
? payload.entries.filter(function (item) { return item && typeof item.path === 'string'; })
|
|
7612
|
+
: [];
|
|
7613
|
+
if (entries.length === 0) entries = [{ path: payload.path, name: payload.name, isDir: Boolean(payload.isDir) }];
|
|
7614
|
+
if (payload.side === side) {
|
|
7615
|
+
moveEntries(side, entries, targetDir);
|
|
7084
7616
|
return;
|
|
7085
7617
|
}
|
|
7086
|
-
if (
|
|
7087
|
-
|
|
7088
|
-
|
|
7089
|
-
|
|
7618
|
+
if (payload.side === 'remote') {
|
|
7619
|
+
var files = entries.filter(function (item) { return !item.isDir; });
|
|
7620
|
+
if (files.length < entries.length) showNotice('error', t('dropDirUnsupported'));
|
|
7621
|
+
if (files.length > 0) pullEntries(files, targetDir);
|
|
7622
|
+
return;
|
|
7623
|
+
}
|
|
7624
|
+
var localFiles = entries.filter(function (item) { return !item.isDir; });
|
|
7625
|
+
if (localFiles.length < entries.length) showNotice('error', t('dropLocalDirUnsupported'));
|
|
7626
|
+
if (localFiles.length > 0) pushEntries(localFiles, targetDir);
|
|
7627
|
+
}
|
|
7628
|
+
|
|
7629
|
+
// Batch transfer: one request per entry, so a conflict is still answered
|
|
7630
|
+
// per file and a partial batch reports how many files actually landed.
|
|
7631
|
+
function pullEntries(entries, targetDir) {
|
|
7632
|
+
var done = 0;
|
|
7633
|
+
function settled() {
|
|
7634
|
+
if (done > 0) {
|
|
7635
|
+
showNotice('success', t('dropImported', { count: done }));
|
|
7636
|
+
refreshTree();
|
|
7090
7637
|
}
|
|
7091
|
-
|
|
7092
|
-
|
|
7093
|
-
|
|
7638
|
+
}
|
|
7639
|
+
function step(index) {
|
|
7640
|
+
if (index >= entries.length) { settled(); return; }
|
|
7641
|
+
var params = Object.assign({ path: entries[index].path, targetDir: targetDir }, scopeParams(scopeRef));
|
|
7642
|
+
apiCall('fs.pullToLocal', params).then(function () {
|
|
7643
|
+
done += 1;
|
|
7644
|
+
step(index + 1);
|
|
7645
|
+
}).catch(function (error) {
|
|
7646
|
+
if (openConflict(error, 'fs.pullToLocal', params)) return;
|
|
7647
|
+
settled();
|
|
7648
|
+
noticeError(error);
|
|
7649
|
+
});
|
|
7650
|
+
}
|
|
7651
|
+
step(0);
|
|
7652
|
+
}
|
|
7653
|
+
|
|
7654
|
+
function pushEntries(entries, targetDir) {
|
|
7655
|
+
var done = 0;
|
|
7656
|
+
var skipped = 0;
|
|
7657
|
+
function settled() {
|
|
7658
|
+
if (done > 0) {
|
|
7659
|
+
showNotice('success', t('dropImported', { count: done }));
|
|
7094
7660
|
refreshTree();
|
|
7661
|
+
}
|
|
7662
|
+
if (skipped > 0) showNotice('warn', t('dropSkipped', { count: skipped }));
|
|
7663
|
+
}
|
|
7664
|
+
function step(index) {
|
|
7665
|
+
if (index >= entries.length) { settled(); return; }
|
|
7666
|
+
var params = Object.assign({ path: targetDir, paths: [entries[index].path] }, scopeParams(scopeRef));
|
|
7667
|
+
apiCall('fs.upload', params).then(function (result) {
|
|
7668
|
+
if (Number(result && result.skipped) > 0) skipped += Number(result.skipped);
|
|
7669
|
+
else done += 1;
|
|
7670
|
+
step(index + 1);
|
|
7095
7671
|
}).catch(function (error) {
|
|
7096
|
-
if (openConflict(error, 'fs.
|
|
7672
|
+
if (openConflict(error, 'fs.upload', params)) return;
|
|
7673
|
+
settled();
|
|
7097
7674
|
noticeError(error);
|
|
7098
7675
|
});
|
|
7099
|
-
return;
|
|
7100
7676
|
}
|
|
7101
|
-
|
|
7102
|
-
|
|
7677
|
+
step(0);
|
|
7678
|
+
}
|
|
7679
|
+
|
|
7680
|
+
// Moves several entries into one directory (same side). Items already in
|
|
7681
|
+
// the target folder and folders dropped onto themselves are skipped.
|
|
7682
|
+
function moveEntries(side, entries, targetDir) {
|
|
7683
|
+
if (typeof targetDir !== 'string' || targetDir === '') return;
|
|
7684
|
+
var moving = entries.filter(function (entry) {
|
|
7685
|
+
if (!entry || typeof entry.path !== 'string' || entry.path === '') return false;
|
|
7686
|
+
if (entry.path === targetDir) return false;
|
|
7687
|
+
if (entry.isDir && pathUnder(targetDir, entry.path)) return false;
|
|
7688
|
+
return parentPathOf(entry.path, side) !== targetDir;
|
|
7689
|
+
});
|
|
7690
|
+
if (moving.length === 0) return;
|
|
7691
|
+
var blocked = openFiles.some(function (file) {
|
|
7692
|
+
if (file.side !== side || !fileDirty[file.key]) return false;
|
|
7693
|
+
return moving.some(function (entry) { return pathUnder(file.path, entry.path); });
|
|
7694
|
+
});
|
|
7695
|
+
if (blocked) {
|
|
7696
|
+
showNotice('error', t('moveDirty'));
|
|
7103
7697
|
return;
|
|
7104
7698
|
}
|
|
7105
|
-
var
|
|
7106
|
-
|
|
7107
|
-
|
|
7108
|
-
|
|
7109
|
-
|
|
7110
|
-
|
|
7111
|
-
|
|
7112
|
-
|
|
7113
|
-
|
|
7699
|
+
var movedPaths = [];
|
|
7700
|
+
var firstError = null;
|
|
7701
|
+
function finish() {
|
|
7702
|
+
if (movedPaths.length > 0) {
|
|
7703
|
+
var keep = openFiles.filter(function (file) {
|
|
7704
|
+
return !(file.side === side && movedPaths.some(function (moved) { return pathUnder(file.path, moved); }));
|
|
7705
|
+
});
|
|
7706
|
+
setOpenFiles(keep);
|
|
7707
|
+
setActiveFileKey(function (activeKey) {
|
|
7708
|
+
var stillOpen = keep.some(function (file) { return file.key === activeKey; });
|
|
7709
|
+
if (stillOpen) return activeKey;
|
|
7710
|
+
return keep.length > 0 ? keep[keep.length - 1].key : null;
|
|
7711
|
+
});
|
|
7712
|
+
setFileDirty(function (previous) {
|
|
7713
|
+
var next = Object.assign({}, previous);
|
|
7714
|
+
openFiles.forEach(function (file) {
|
|
7715
|
+
if (file.side !== side) return;
|
|
7716
|
+
if (movedPaths.some(function (moved) { return pathUnder(file.path, moved); })) delete next[file.key];
|
|
7717
|
+
});
|
|
7718
|
+
return next;
|
|
7719
|
+
});
|
|
7720
|
+
setMulti([]);
|
|
7721
|
+
setDialog(null);
|
|
7722
|
+
refreshTree();
|
|
7723
|
+
showNotice('success', movedPaths.length === 1 ? t('moveDone') : t('moveDoneCount', { count: movedPaths.length }));
|
|
7724
|
+
}
|
|
7725
|
+
if (firstError) noticeError(firstError);
|
|
7726
|
+
}
|
|
7727
|
+
function step(index) {
|
|
7728
|
+
if (index >= moving.length) { finish(); return; }
|
|
7729
|
+
var entry = moving[index];
|
|
7730
|
+
var method = side === 'remote' ? 'fs.move' : 'local.move';
|
|
7731
|
+
var params = side === 'remote'
|
|
7732
|
+
? Object.assign({ path: entry.path, targetDir: targetDir }, scopeParams(scopeRef))
|
|
7733
|
+
: { path: entry.path, targetDir: targetDir, root: selected.localPath };
|
|
7734
|
+
apiCall(method, params).then(function (result) {
|
|
7735
|
+
movedPaths.push(result && result.path ? result.path : entry.path);
|
|
7736
|
+
step(index + 1);
|
|
7737
|
+
}).catch(function (error) {
|
|
7738
|
+
if (!firstError) firstError = error;
|
|
7739
|
+
step(index + 1);
|
|
7740
|
+
});
|
|
7741
|
+
}
|
|
7742
|
+
step(0);
|
|
7114
7743
|
}
|
|
7115
7744
|
|
|
7116
7745
|
function submitRenamed(side, oldPath, name) {
|
|
@@ -7126,6 +7755,32 @@ function attributeViolation(name, value, tagName) {
|
|
|
7126
7755
|
}).catch(noticeError);
|
|
7127
7756
|
}
|
|
7128
7757
|
|
|
7758
|
+
/**
|
|
7759
|
+
* F2: rename sequentially so one failure (a clash on disk) does not leave
|
|
7760
|
+
* the rest half-applied without a word.
|
|
7761
|
+
*/
|
|
7762
|
+
function renameManyEntries(side, pairs) {
|
|
7763
|
+
var method = side === 'remote' ? 'fs.rename' : 'local.rename';
|
|
7764
|
+
var done = 0;
|
|
7765
|
+
return pairs.reduce(function (chain, pair) {
|
|
7766
|
+
return chain.then(function () {
|
|
7767
|
+
var target = joinChildPath(parentPathOf(pair.entry.path, side), pair.to, side);
|
|
7768
|
+
var params = side === 'remote'
|
|
7769
|
+
? Object.assign({ from: pair.entry.path, to: target }, scopeParams(scopeRef))
|
|
7770
|
+
: { from: pair.entry.path, to: target };
|
|
7771
|
+
return apiCall(method, params).then(function () { done += 1; });
|
|
7772
|
+
});
|
|
7773
|
+
}, Promise.resolve()).then(function () {
|
|
7774
|
+
showNotice('success', t('renameManyDone', { count: done }));
|
|
7775
|
+
refreshTree();
|
|
7776
|
+
return done;
|
|
7777
|
+
}).catch(function (error) {
|
|
7778
|
+
if (done > 0) showNotice('success', t('renameManyDone', { count: done }));
|
|
7779
|
+
noticeError(error);
|
|
7780
|
+
throw error;
|
|
7781
|
+
});
|
|
7782
|
+
}
|
|
7783
|
+
|
|
7129
7784
|
function pathUnder(filePath, parentPath) {
|
|
7130
7785
|
if (!filePath || !parentPath) return false;
|
|
7131
7786
|
var normalized = String(filePath).replace(/\\/g, '/').replace(/\/+$/, '');
|
|
@@ -7133,49 +7788,6 @@ function attributeViolation(name, value, tagName) {
|
|
|
7133
7788
|
return normalized === parent || normalized.indexOf(parent + '/') === 0 || normalized.indexOf(parent + '\\') === 0;
|
|
7134
7789
|
}
|
|
7135
7790
|
|
|
7136
|
-
function moveEntry(side, oldPath, targetDir) {
|
|
7137
|
-
var blocked = openFiles.some(function (file) {
|
|
7138
|
-
return file.side === side && pathUnder(file.path, oldPath) && fileDirty[file.key];
|
|
7139
|
-
});
|
|
7140
|
-
if (blocked) {
|
|
7141
|
-
showNotice('error', t('moveDirty'));
|
|
7142
|
-
return;
|
|
7143
|
-
}
|
|
7144
|
-
var method = side === 'remote' ? 'fs.move' : 'local.move';
|
|
7145
|
-
var params = side === 'remote'
|
|
7146
|
-
? Object.assign({ path: oldPath, targetDir: targetDir }, scopeParams(scopeRef))
|
|
7147
|
-
: { path: oldPath, targetDir: targetDir, root: selected.localPath };
|
|
7148
|
-
apiCall(method, params).then(function (result) {
|
|
7149
|
-
var nextPath = result && result.path ? result.path : oldPath;
|
|
7150
|
-
setOpenFiles(function (previous) {
|
|
7151
|
-
return previous.filter(function (file) {
|
|
7152
|
-
return !(file.side === side && pathUnder(file.path, oldPath));
|
|
7153
|
-
});
|
|
7154
|
-
});
|
|
7155
|
-
setActiveFileKey(function (activeKey) {
|
|
7156
|
-
var stillOpen = openFiles.filter(function (file) {
|
|
7157
|
-
return file.key === activeKey && !(file.side === side && pathUnder(file.path, oldPath));
|
|
7158
|
-
});
|
|
7159
|
-
if (stillOpen.length > 0) return activeKey;
|
|
7160
|
-
var remaining = openFiles.filter(function (file) {
|
|
7161
|
-
return !(file.side === side && pathUnder(file.path, oldPath));
|
|
7162
|
-
});
|
|
7163
|
-
return remaining.length > 0 ? remaining[remaining.length - 1].key : null;
|
|
7164
|
-
});
|
|
7165
|
-
setFileDirty(function (previous) {
|
|
7166
|
-
var next = Object.assign({}, previous);
|
|
7167
|
-
openFiles.forEach(function (file) {
|
|
7168
|
-
if (file.side === side && pathUnder(file.path, oldPath)) delete next[file.key];
|
|
7169
|
-
});
|
|
7170
|
-
return next;
|
|
7171
|
-
});
|
|
7172
|
-
setDialog(null);
|
|
7173
|
-
showNotice('success', t('moveDone'));
|
|
7174
|
-
refreshTree();
|
|
7175
|
-
if (nextPath !== oldPath) refreshTree();
|
|
7176
|
-
}).catch(noticeError);
|
|
7177
|
-
}
|
|
7178
|
-
|
|
7179
7791
|
function submitNew(side, dirPath, name, isDir) {
|
|
7180
7792
|
var request = newEntryRequest(side, dirPath, name, isDir, scopeParams(scopeRef));
|
|
7181
7793
|
return apiCall(request.method, request.params).then(function () {
|
|
@@ -7224,6 +7836,17 @@ function attributeViolation(name, value, tagName) {
|
|
|
7224
7836
|
batch.forEach(function (item) { enqueueTransfer(item.side, item.path, item.name); });
|
|
7225
7837
|
} });
|
|
7226
7838
|
items.push({ label: t('ctxDeleteSelected', { count: batch.length }), onSelect: deleteSelection });
|
|
7839
|
+
if (batch.some(function (item) { return item.path === menu.path; })) {
|
|
7840
|
+
items.push({ label: t('ctxMoveSelected', { count: batch.length }), onSelect: function () {
|
|
7841
|
+
setDialog({
|
|
7842
|
+
kind: 'move', side: menu.side, entries: batch, name: menu.name, isDir: true,
|
|
7843
|
+
initialPath: parentPathOf(menu.path, menu.side),
|
|
7844
|
+
});
|
|
7845
|
+
} });
|
|
7846
|
+
items.push({ label: t('ctxRenameSelected', { count: batch.length }), onSelect: function () {
|
|
7847
|
+
setDialog({ kind: 'renameMany', side: menu.side, entries: batch });
|
|
7848
|
+
} });
|
|
7849
|
+
}
|
|
7227
7850
|
items.push({ separator: true });
|
|
7228
7851
|
}
|
|
7229
7852
|
if (isRemote) {
|
|
@@ -7335,6 +7958,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
7335
7958
|
setQueueList(queueRef.current.slice());
|
|
7336
7959
|
},
|
|
7337
7960
|
onRetry: function (entry) { enqueueTransfer(entry.side, entry.path, entry.label); },
|
|
7961
|
+
onCancel: cancelTransfer,
|
|
7338
7962
|
});
|
|
7339
7963
|
}
|
|
7340
7964
|
if (dialog.kind === 'delete') {
|
|
@@ -7366,16 +7990,29 @@ function attributeViolation(name, value, tagName) {
|
|
|
7366
7990
|
h('button', { type: 'button', className: 'rw-btn rw-btn-sm rw-btn-danger', onClick: function () { resolveConflict('overwrite'); } }, t('conflictOverwrite'))));
|
|
7367
7991
|
}
|
|
7368
7992
|
if (dialog.kind === 'move') {
|
|
7993
|
+
var moveTargets = Array.isArray(dialog.entries) && dialog.entries.length > 0
|
|
7994
|
+
? dialog.entries
|
|
7995
|
+
: [{ path: dialog.path, name: dialog.name, isDir: dialog.isDir }];
|
|
7369
7996
|
return h(MoveDialog, {
|
|
7370
7997
|
t: t, locale: locale,
|
|
7371
7998
|
title: t('moveTitle'),
|
|
7372
|
-
message:
|
|
7999
|
+
message: moveTargets.length > 1
|
|
8000
|
+
? t('moveMessageMany', { count: moveTargets.length })
|
|
8001
|
+
: t('moveMessage', { name: dialog.name }),
|
|
7373
8002
|
side: dialog.side,
|
|
7374
8003
|
scope: dialog.side === 'remote' ? sourceScopeOf(selected) : null,
|
|
7375
8004
|
root: dialog.side === 'remote' ? selected.remotePath : selected.localPath,
|
|
7376
8005
|
initialPath: dialog.initialPath,
|
|
7377
8006
|
onClose: function () { setDialog(null); },
|
|
7378
|
-
onPick: function (targetDir) {
|
|
8007
|
+
onPick: function (targetDir) { moveEntries(dialog.side, moveTargets, targetDir); },
|
|
8008
|
+
});
|
|
8009
|
+
}
|
|
8010
|
+
if (dialog.kind === 'renameMany') {
|
|
8011
|
+
return h(BatchRenameDialog, {
|
|
8012
|
+
t: t,
|
|
8013
|
+
entries: dialog.entries,
|
|
8014
|
+
onClose: function () { setDialog(null); },
|
|
8015
|
+
onApply: function (pairs) { return renameManyEntries(dialog.side, pairs); },
|
|
7379
8016
|
});
|
|
7380
8017
|
}
|
|
7381
8018
|
if (dialog.kind === 'closeDirty') {
|
|
@@ -7424,26 +8061,50 @@ function attributeViolation(name, value, tagName) {
|
|
|
7424
8061
|
return function () { alive = false; };
|
|
7425
8062
|
}, [mode, selectedKey, version]);
|
|
7426
8063
|
|
|
8064
|
+
// F3: when the user ticks “current folder only”, the sweep starts from the
|
|
8065
|
+
// row they have selected (its parent when the row is a file).
|
|
8066
|
+
var searchRootPath = '';
|
|
8067
|
+
if (selected && selected.kind !== 'workspace' && selectedEntry && selectedEntry.side === 'remote' && selected.remotePath) {
|
|
8068
|
+
var entryPath = String(selectedEntry.path || '');
|
|
8069
|
+
var rootPrefix = String(selected.remotePath).replace(/\/+$/, '');
|
|
8070
|
+
if (entryPath === rootPrefix) {
|
|
8071
|
+
searchRootPath = '';
|
|
8072
|
+
} else if (entryPath.indexOf(rootPrefix + '/') === 0) {
|
|
8073
|
+
var inside = entryPath.slice(rootPrefix.length + 1);
|
|
8074
|
+
searchRootPath = selectedEntry.isDir === false ? parentPathOf(inside, 'remote') : inside;
|
|
8075
|
+
}
|
|
8076
|
+
}
|
|
8077
|
+
|
|
7427
8078
|
useEffect(function () {
|
|
7428
8079
|
if (!searchOpen) {
|
|
7429
|
-
setSearch({ loading: false, remote: [], local: [], error: null });
|
|
8080
|
+
setSearch({ loading: false, remote: [], local: [], truncated: false, truncatedReason: '', error: null });
|
|
7430
8081
|
return undefined;
|
|
7431
8082
|
}
|
|
7432
8083
|
var query = searchQuery.trim();
|
|
7433
8084
|
if (query.length < 2 || !selected) {
|
|
7434
|
-
setSearch({ loading: false, remote: [], local: [], error: null });
|
|
8085
|
+
setSearch({ loading: false, remote: [], local: [], truncated: false, truncatedReason: '', error: null });
|
|
7435
8086
|
return undefined;
|
|
7436
8087
|
}
|
|
7437
8088
|
var alive = true;
|
|
7438
8089
|
var timer = setTimeout(function () {
|
|
7439
|
-
setSearch(function (previous) { return { loading: true, remote: previous.remote, local: previous.local, truncated: false, error: null }; });
|
|
8090
|
+
setSearch(function (previous) { return { loading: true, remote: previous.remote, local: previous.local, truncated: false, truncatedReason: '', error: null }; });
|
|
7440
8091
|
var scopeNow = sourceScopeOf(selected);
|
|
7441
|
-
var
|
|
7442
|
-
var
|
|
8092
|
+
var contentMode = searchMode === 'content';
|
|
8093
|
+
var method = contentMode ? 'fs.grep' : 'fs.search';
|
|
8094
|
+
var extra = { side: 'remote', query: query, maxResults: 200 };
|
|
8095
|
+
if (contentMode) {
|
|
8096
|
+
// F3: narrow the sweep to the folder the user is standing in.
|
|
8097
|
+
if (searchHere && searchRootPath !== '') extra.path = searchRootPath;
|
|
8098
|
+
extra.ignoreCase = !searchCase;
|
|
8099
|
+
extra.regex = searchRegex;
|
|
8100
|
+
}
|
|
8101
|
+
var jobs = [apiCall(method, Object.assign(extra, scopeParams(scopeNow))).catch(function (error) {
|
|
7443
8102
|
return { ok: false, entries: [], error: messageOf(error, t, locale) };
|
|
7444
8103
|
})];
|
|
7445
8104
|
if (selected.kind === 'linked') {
|
|
7446
|
-
|
|
8105
|
+
var localExtra = Object.assign({}, extra, { side: 'local' });
|
|
8106
|
+
if (contentMode) localExtra.ignoreCase = !searchCase;
|
|
8107
|
+
jobs.push(apiCall(method, Object.assign(localExtra, scopeParams(scopeNow))).catch(function (error) {
|
|
7447
8108
|
return { ok: false, entries: [], error: messageOf(error, t, locale) };
|
|
7448
8109
|
}));
|
|
7449
8110
|
} else {
|
|
@@ -7456,12 +8117,13 @@ function attributeViolation(name, value, tagName) {
|
|
|
7456
8117
|
remote: results[0] && results[0].entries ? results[0].entries : [],
|
|
7457
8118
|
local: results[1] && results[1].entries ? results[1].entries : [],
|
|
7458
8119
|
truncated: Boolean((results[0] && results[0].truncated) || (results[1] && results[1].truncated)),
|
|
8120
|
+
truncatedReason: (results[0] && results[0].truncatedReason) || (results[1] && results[1].truncatedReason) || '',
|
|
7459
8121
|
error: (results[0] && results[0].error) || (results[1] && results[1].error) || null,
|
|
7460
8122
|
});
|
|
7461
8123
|
});
|
|
7462
8124
|
}, 320);
|
|
7463
8125
|
return function () { alive = false; clearTimeout(timer); };
|
|
7464
|
-
}, [searchOpen, searchQuery, selectedKey, version, searchMode]);
|
|
8126
|
+
}, [searchOpen, searchQuery, selectedKey, version, searchMode, searchCase, searchRegex, searchHere]);
|
|
7465
8127
|
|
|
7466
8128
|
if (!selected) {
|
|
7467
8129
|
return h('div', { className: 'rw-workbench rw-workspace', ref: workbenchRef },
|
|
@@ -7481,9 +8143,13 @@ function attributeViolation(name, value, tagName) {
|
|
|
7481
8143
|
if (searchOpen && searchQuery.trim().length >= 2) {
|
|
7482
8144
|
body = h(SearchResults, {
|
|
7483
8145
|
t: t, locale: locale, state: search,
|
|
8146
|
+
mode: searchMode,
|
|
7484
8147
|
hasLocal: selected.kind === 'linked',
|
|
7485
8148
|
showHidden: showHidden,
|
|
7486
|
-
onOpen:
|
|
8149
|
+
onOpen: function (side, filePath, entry) {
|
|
8150
|
+
var line = entry && Number(entry.line) ? Number(entry.line) : 0;
|
|
8151
|
+
openByMode(side, filePath, line > 0 ? { pinned: true, line: line } : undefined);
|
|
8152
|
+
},
|
|
7487
8153
|
});
|
|
7488
8154
|
} else if (mode !== 'files') {
|
|
7489
8155
|
body = h(GitChangesView, {
|
|
@@ -7543,6 +8209,10 @@ function attributeViolation(name, value, tagName) {
|
|
|
7543
8209
|
|
|
7544
8210
|
var activeFile = openFiles.filter(function (file) { return file.key === activeFileKey; })[0] || null;
|
|
7545
8211
|
var activeDocKind = activeFile ? documentKindOf(activeFile.name) : '';
|
|
8212
|
+
// A hit that carries a line number needs the code view: the document pane
|
|
8213
|
+
// has no caret, so the jump would be lost on Markdown/HTML files.
|
|
8214
|
+
var activeForceCode = Boolean(activeFile && Number(activeFile.line) > 0);
|
|
8215
|
+
if (activeForceCode) activeDocKind = '';
|
|
7546
8216
|
var contentArea = activeFile
|
|
7547
8217
|
? (activeDocKind === 'image'
|
|
7548
8218
|
? h(ImagePreview, {
|
|
@@ -7585,6 +8255,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
7585
8255
|
local: activeFile.side === 'local',
|
|
7586
8256
|
readOnly: remoteOnly,
|
|
7587
8257
|
hideHeader: true,
|
|
8258
|
+
focusLine: activeFile.line || 0,
|
|
7588
8259
|
onSaveReady: function (handler) {
|
|
7589
8260
|
if (handler) saveHandlersRef.current[activeFile.key] = handler;
|
|
7590
8261
|
else delete saveHandlersRef.current[activeFile.key];
|
|
@@ -7651,7 +8322,42 @@ function attributeViolation(name, value, tagName) {
|
|
|
7651
8322
|
spellCheck: false,
|
|
7652
8323
|
autoFocus: true,
|
|
7653
8324
|
onChange: function (event) { setSearchQuery(event.currentTarget.value); },
|
|
8325
|
+
onKeyDown: function (event) {
|
|
8326
|
+
if (event.key !== 'ArrowDown') return;
|
|
8327
|
+
// Landing on the first hit without leaving the keyboard is the
|
|
8328
|
+
// whole point of the list shortcuts.
|
|
8329
|
+
var list = document.querySelector('.rw-search-results');
|
|
8330
|
+
var first = list && list.querySelector('.rw-result-row');
|
|
8331
|
+
if (!first) return;
|
|
8332
|
+
event.preventDefault();
|
|
8333
|
+
first.focus();
|
|
8334
|
+
},
|
|
7654
8335
|
}),
|
|
8336
|
+
searchMode === 'content'
|
|
8337
|
+
? h('span', { className: 'rw-search-flags' },
|
|
8338
|
+
h('button', {
|
|
8339
|
+
type: 'button',
|
|
8340
|
+
className: 'rw-chip-btn' + (searchCase ? ' is-on' : ''),
|
|
8341
|
+
title: t('searchCase'),
|
|
8342
|
+
'aria-pressed': searchCase ? 'true' : 'false',
|
|
8343
|
+
onClick: function () { setSearchCase(!searchCase); },
|
|
8344
|
+
}, 'Aa'),
|
|
8345
|
+
h('button', {
|
|
8346
|
+
type: 'button',
|
|
8347
|
+
className: 'rw-chip-btn' + (searchRegex ? ' is-on' : ''),
|
|
8348
|
+
title: t('searchRegex'),
|
|
8349
|
+
'aria-pressed': searchRegex ? 'true' : 'false',
|
|
8350
|
+
onClick: function () { setSearchRegex(!searchRegex); },
|
|
8351
|
+
}, '.*'),
|
|
8352
|
+
h('button', {
|
|
8353
|
+
type: 'button',
|
|
8354
|
+
className: 'rw-chip-btn' + (searchHere ? ' is-on' : ''),
|
|
8355
|
+
title: searchHere ? t('searchScopeHere') : t('searchScopeAll'),
|
|
8356
|
+
'aria-pressed': searchHere ? 'true' : 'false',
|
|
8357
|
+
disabled: searchRootPath === '',
|
|
8358
|
+
onClick: function () { setSearchHere(!searchHere); },
|
|
8359
|
+
}, IconFolderTree(11)))
|
|
8360
|
+
: null,
|
|
7655
8361
|
h('button', {
|
|
7656
8362
|
type: 'button', className: 'rw-icon-btn', title: t('cancel'),
|
|
7657
8363
|
onClick: function () { setSearchOpen(false); setSearchQuery(''); },
|
|
@@ -7737,6 +8443,39 @@ function attributeViolation(name, value, tagName) {
|
|
|
7737
8443
|
|
|
7738
8444
|
// ── tree ───────────────────────────────────────────────────────────────
|
|
7739
8445
|
|
|
8446
|
+
// F5: the row tooltip shows where a file lives, which is the one thing a
|
|
8447
|
+
// hover cannot tell you about time. One stat per row per 5 s is cheap and
|
|
8448
|
+
// keeps the tree quiet otherwise.
|
|
8449
|
+
var ROW_STAT_TTL_MS = 5000;
|
|
8450
|
+
var rowStatCache = new Map();
|
|
8451
|
+
|
|
8452
|
+
function rowStatKey(side, filePath) {
|
|
8453
|
+
return (side === 'remote' ? 'r:' : 'l:') + filePath;
|
|
8454
|
+
}
|
|
8455
|
+
|
|
8456
|
+
function decorateRowStat(row, side, filePath, scope, t, locale) {
|
|
8457
|
+
if (!row || !filePath) return;
|
|
8458
|
+
var key = rowStatKey(side, filePath);
|
|
8459
|
+
var cached = rowStatCache.get(key);
|
|
8460
|
+
if (cached && Date.now() - cached.at < ROW_STAT_TTL_MS) {
|
|
8461
|
+
row.title = cached.text;
|
|
8462
|
+
return;
|
|
8463
|
+
}
|
|
8464
|
+
row.title = filePath;
|
|
8465
|
+
var method = side === 'remote' ? 'fs.stat' : 'local.stat';
|
|
8466
|
+
var params = side === 'remote'
|
|
8467
|
+
? Object.assign({ path: filePath }, scopeParams(scope))
|
|
8468
|
+
: { path: filePath };
|
|
8469
|
+
apiCall(method, params).then(function (result) {
|
|
8470
|
+
var stamp = Number(result && result.mtime);
|
|
8471
|
+
var when = stamp > 0 ? new Date(stamp).toLocaleString() : '-';
|
|
8472
|
+
var text = filePath + '\n' + t('rowModifiedAt', { when: when })
|
|
8473
|
+
+ (result && result.type === 'dir' ? '' : ' · ' + formatBytes(result && result.size));
|
|
8474
|
+
rowStatCache.set(key, { at: Date.now(), text: text });
|
|
8475
|
+
if (row.isConnected) row.title = text;
|
|
8476
|
+
}).catch(function () { /* a tooltip is not worth a notice */ });
|
|
8477
|
+
}
|
|
8478
|
+
|
|
7740
8479
|
function TreeDirectory(props) {
|
|
7741
8480
|
var path = props.path;
|
|
7742
8481
|
var name = props.name;
|
|
@@ -7807,6 +8546,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
7807
8546
|
selectedPath: selectedPath,
|
|
7808
8547
|
selectedSet: props.selectedSet,
|
|
7809
8548
|
siblings: childSiblings,
|
|
8549
|
+
statSide: props.statSide || 'remote',
|
|
7810
8550
|
}));
|
|
7811
8551
|
} else if (child.type === 'file' || child.type === 'symlink') {
|
|
7812
8552
|
var active = selectedPath === child.path || Boolean(props.selectedSet && props.selectedSet.has(child.path));
|
|
@@ -7828,6 +8568,25 @@ function attributeViolation(name, value, tagName) {
|
|
|
7828
8568
|
if (event.detail !== 2) onSelect(child.path);
|
|
7829
8569
|
},
|
|
7830
8570
|
onDoubleClick: function () { if (onPin) onPin(child.path); },
|
|
8571
|
+
onMouseEnter: function (event) {
|
|
8572
|
+
decorateRowStat(event.currentTarget, props.statSide || 'remote', child.path, source, t, locale);
|
|
8573
|
+
},
|
|
8574
|
+
onKeyDown: function (event) {
|
|
8575
|
+
// ← on a file folds the focus back onto its parent folder,
|
|
8576
|
+
// which is what a file tree is expected to do.
|
|
8577
|
+
if (event.key !== 'ArrowLeft') return;
|
|
8578
|
+
var owner = event.currentTarget.closest('[data-dir-path]');
|
|
8579
|
+
// The folder header is the wrapper's previous sibling, not a
|
|
8580
|
+
// child of it, so look sideways first and fall back inside.
|
|
8581
|
+
var header = owner ? owner.previousElementSibling : null;
|
|
8582
|
+
if (!header || String(header.getAttribute('role')) !== 'treeitem') {
|
|
8583
|
+
header = owner ? owner.querySelector('[data-dir-path]') : null;
|
|
8584
|
+
}
|
|
8585
|
+
if (!header) return;
|
|
8586
|
+
event.preventDefault();
|
|
8587
|
+
event.stopPropagation();
|
|
8588
|
+
header.focus();
|
|
8589
|
+
},
|
|
7831
8590
|
onContextMenu: function (event) {
|
|
7832
8591
|
if (!onContextMenu) return;
|
|
7833
8592
|
event.preventDefault();
|
|
@@ -7863,6 +8622,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
7863
8622
|
role: 'treeitem',
|
|
7864
8623
|
'aria-level': depth + 1,
|
|
7865
8624
|
'aria-expanded': isOpen,
|
|
8625
|
+
'data-dir-path': path,
|
|
7866
8626
|
className: 'rw-row' + (selectedPath === path || (props.selectedSet && props.selectedSet.has(path)) ? ' is-active' : ''),
|
|
7867
8627
|
style: { paddingLeft: 6 + depth * 12 },
|
|
7868
8628
|
title: path,
|
|
@@ -7874,6 +8634,9 @@ function attributeViolation(name, value, tagName) {
|
|
|
7874
8634
|
if (onSelectPath) onSelectPath({ path: path, name: name, isDir: true, siblings: props.siblings || [], event: event });
|
|
7875
8635
|
if (event.detail !== 2) toggle(path);
|
|
7876
8636
|
},
|
|
8637
|
+
onMouseEnter: function (event) {
|
|
8638
|
+
decorateRowStat(event.currentTarget, props.statSide || 'remote', path, source, t, locale);
|
|
8639
|
+
},
|
|
7877
8640
|
onKeyDown: function (event) {
|
|
7878
8641
|
if (event.key === 'ArrowRight' && !isOpen) { event.preventDefault(); toggle(path); }
|
|
7879
8642
|
else if (event.key === 'ArrowLeft' && isOpen) { event.preventDefault(); toggle(path); }
|
|
@@ -7916,7 +8679,9 @@ function attributeViolation(name, value, tagName) {
|
|
|
7916
8679
|
h('span', { className: 'rw-chevron' + (isOpen ? ' is-open' : '') }, IconChevron(12)),
|
|
7917
8680
|
h(FileGlyph, { name: name, dir: true, open: isOpen, size: 13 }),
|
|
7918
8681
|
h('span', { className: 'rw-row-name' }, name)),
|
|
7919
|
-
|
|
8682
|
+
// The wrapper carries the folder path so a child row can walk back up
|
|
8683
|
+
// to the folder that owns it (← from a file focuses its folder).
|
|
8684
|
+
children.length > 0 ? h('div', { className: 'rw-tree-children', 'data-dir-path': path }, children) : null);
|
|
7920
8685
|
}
|
|
7921
8686
|
|
|
7922
8687
|
function WorkspaceTreeSource(props) {
|
|
@@ -8051,7 +8816,14 @@ function attributeViolation(name, value, tagName) {
|
|
|
8051
8816
|
+ (source.kind === 'linked' ? ' · ' + t('linkedChip') : source.kind === 'remote' ? ' · ' + t('remoteChip') : ''))),
|
|
8052
8817
|
h(StatusPill, { status: source.status, t: t })),
|
|
8053
8818
|
open
|
|
8054
|
-
? h('div', {
|
|
8819
|
+
? h('div', {
|
|
8820
|
+
className: 'rw-tree-body',
|
|
8821
|
+
role: 'tree',
|
|
8822
|
+
'aria-label': source.name,
|
|
8823
|
+
// D3: ↑/↓/Home/End walk the visible rows; ←/→ are handled per row
|
|
8824
|
+
// (expand/collapse a folder, fold back up from a file).
|
|
8825
|
+
onKeyDown: function (event) { handleListKeys(event, event.currentTarget, '[role="treeitem"]'); },
|
|
8826
|
+
},
|
|
8055
8827
|
h(TreeDirectory, {
|
|
8056
8828
|
path: source.remotePath,
|
|
8057
8829
|
name: '/',
|
|
@@ -8066,6 +8838,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
8066
8838
|
loadMore: loadMore,
|
|
8067
8839
|
onSelect: props.onSelect,
|
|
8068
8840
|
selectedPath: props.selectedPath,
|
|
8841
|
+
statSide: 'remote',
|
|
8069
8842
|
}))
|
|
8070
8843
|
: null);
|
|
8071
8844
|
}
|
|
@@ -9253,7 +10026,20 @@ function attributeViolation(name, value, tagName) {
|
|
|
9253
10026
|
h('button', {
|
|
9254
10027
|
type: 'button', className: 'rw-btn' + (adding === 'remote' ? '' : ' rw-btn-primary'),
|
|
9255
10028
|
onClick: function () { toggleAdding('remote'); },
|
|
9256
|
-
}, adding === 'remote' ? IconClose(13) : IconRemoteWorkspace(13), t('createRemote'))
|
|
10029
|
+
}, adding === 'remote' ? IconClose(13) : IconRemoteWorkspace(13), t('createRemote')),
|
|
10030
|
+
// F6: the welcome card only shows once, so offer a way back to it.
|
|
10031
|
+
h('button', {
|
|
10032
|
+
type: 'button', className: 'rw-btn rw-btn-sm',
|
|
10033
|
+
title: t('welcomeReplay'),
|
|
10034
|
+
onClick: function () {
|
|
10035
|
+
try { if (window.localStorage) window.localStorage.removeItem(WELCOME_KEY); } catch (error) { /* ignore */ }
|
|
10036
|
+
// The card sits under the settings overlay, so close it first.
|
|
10037
|
+
dismissSettingsOverlay();
|
|
10038
|
+
setTimeout(function () {
|
|
10039
|
+
try { window.dispatchEvent(new CustomEvent(WELCOME_EVENT)); } catch (error) { /* ignore */ }
|
|
10040
|
+
}, 60);
|
|
10041
|
+
},
|
|
10042
|
+
}, IconAlert(13), t('welcomeReplay')))),
|
|
9257
10043
|
!sidebarAvailable ? h(Banner, { kind: 'warn' }, t('needsSidebar')) : null,
|
|
9258
10044
|
h(ThemeGroup, { t: t, locale: locale }),
|
|
9259
10045
|
h(EditorSettingsGroup, { t: t, locale: locale }),
|
|
@@ -9375,6 +10161,23 @@ function attributeViolation(name, value, tagName) {
|
|
|
9375
10161
|
console.error('[dsh-linked-workspace] settings icon registration failed', error && error.message ? error.message : error);
|
|
9376
10162
|
}
|
|
9377
10163
|
|
|
10164
|
+
// First-run welcome card: shell.overlay is the frame-wide floating layer,
|
|
10165
|
+
// so the card lands above every column without touching any panel.
|
|
10166
|
+
try {
|
|
10167
|
+
ctx.slots.inject('shell.overlay', function () {
|
|
10168
|
+
return ctx.slots.register({
|
|
10169
|
+
name: 'shell.overlay',
|
|
10170
|
+
id: 'linked-workspace-welcome',
|
|
10171
|
+
order: 80,
|
|
10172
|
+
label: function () { return makeT(readLocale(ctx))('welcomeTitle'); },
|
|
10173
|
+
}, function (props) {
|
|
10174
|
+
return h(WelcomeCard, Object.assign({}, props, { ctx: ctx }));
|
|
10175
|
+
});
|
|
10176
|
+
});
|
|
10177
|
+
} catch (error) {
|
|
10178
|
+
console.error('[dsh-linked-workspace] welcome card registration failed', error && error.message ? error.message : error);
|
|
10179
|
+
}
|
|
10180
|
+
|
|
9378
10181
|
try {
|
|
9379
10182
|
ctx.slots.inject('settings.section', function () {
|
|
9380
10183
|
return ctx.slots.register({
|