dsh-linked-workspace 0.24.1 → 0.26.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/client.js CHANGED
@@ -295,6 +295,150 @@ const EDITOR_THEMES = [
295
295
  punctuation: '#1f1f1f',
296
296
  plain: '#1f1f1f'
297
297
  }
298
+ },
299
+ {
300
+ id: 'tokyo-night',
301
+ label: { zh: 'Tokyo Night 深色', en: 'Tokyo Night' },
302
+ kind: 'dark',
303
+ colors: {
304
+ bg: '#1a1b26',
305
+ fg: '#c0caf5',
306
+ gutterBg: '#16161e',
307
+ gutterFg: '#4c5470',
308
+ border: '#232433',
309
+ selection: '#33467c',
310
+ lineHighlight: '#1f2030',
311
+ caret: '#c0caf5',
312
+ keyword: '#bb9af7',
313
+ string: '#9ece6a',
314
+ comment: '#646e9c',
315
+ number: '#ff9e64',
316
+ functionName: '#7aa2f7',
317
+ typeName: '#2ac3de',
318
+ operator: '#89ddff',
319
+ punctuation: '#a9b1d6',
320
+ plain: '#c0caf5'
321
+ }
322
+ },
323
+ {
324
+ id: 'tokyo-night-light',
325
+ label: { zh: 'Tokyo Night 浅色', en: 'Tokyo Night Light' },
326
+ kind: 'light',
327
+ colors: {
328
+ bg: '#e1e2e7',
329
+ fg: '#3760bf',
330
+ gutterBg: '#d6d8de',
331
+ gutterFg: '#848cb5',
332
+ border: '#c4c8da',
333
+ selection: '#b7c1e3',
334
+ lineHighlight: '#d9dbe4',
335
+ caret: '#3760bf',
336
+ keyword: '#9854f1',
337
+ string: '#587539',
338
+ comment: '#848cb5',
339
+ number: '#b15c00',
340
+ functionName: '#2e7de9',
341
+ typeName: '#007197',
342
+ operator: '#007197',
343
+ punctuation: '#6172b0',
344
+ plain: '#3760bf'
345
+ }
346
+ },
347
+ {
348
+ id: 'gruvbox-dark',
349
+ label: { zh: 'Gruvbox 深色', en: 'Gruvbox Dark' },
350
+ kind: 'dark',
351
+ colors: {
352
+ bg: '#282828',
353
+ fg: '#ebdbb2',
354
+ gutterBg: '#1d2021',
355
+ gutterFg: '#7c6f64',
356
+ border: '#3c3836',
357
+ selection: '#504945',
358
+ lineHighlight: '#32302f',
359
+ caret: '#ebdbb2',
360
+ keyword: '#fb4934',
361
+ string: '#b8bb26',
362
+ comment: '#928374',
363
+ number: '#d3869b',
364
+ functionName: '#fabd2f',
365
+ typeName: '#83a598',
366
+ operator: '#fe8019',
367
+ punctuation: '#a89984',
368
+ plain: '#ebdbb2'
369
+ }
370
+ },
371
+ {
372
+ id: 'gruvbox-light',
373
+ label: { zh: 'Gruvbox 浅色', en: 'Gruvbox Light' },
374
+ kind: 'light',
375
+ colors: {
376
+ bg: '#fbf1c7',
377
+ fg: '#3c3836',
378
+ gutterBg: '#f2e5bc',
379
+ gutterFg: '#a89984',
380
+ border: '#ebdbb2',
381
+ selection: '#d5c4a1',
382
+ lineHighlight: '#f2e5bc',
383
+ caret: '#3c3836',
384
+ keyword: '#9d0006',
385
+ string: '#79740e',
386
+ comment: '#928374',
387
+ number: '#8f3f71',
388
+ functionName: '#b57614',
389
+ typeName: '#076678',
390
+ operator: '#af3a03',
391
+ punctuation: '#7c6f64',
392
+ plain: '#3c3836'
393
+ }
394
+ },
395
+ {
396
+ id: 'ayu-dark',
397
+ label: { zh: 'Ayu 深色', en: 'Ayu Dark' },
398
+ kind: 'dark',
399
+ colors: {
400
+ bg: '#0b0e14',
401
+ fg: '#bfbdb6',
402
+ gutterBg: '#0d1017',
403
+ gutterFg: '#475266',
404
+ border: '#1b1f29',
405
+ selection: '#273747',
406
+ lineHighlight: '#131721',
407
+ caret: '#e6b450',
408
+ keyword: '#ff8f40',
409
+ string: '#aad94c',
410
+ comment: '#626a73',
411
+ number: '#d2a6ff',
412
+ functionName: '#ffb454',
413
+ typeName: '#39bae6',
414
+ operator: '#f29668',
415
+ punctuation: '#bfbdb6',
416
+ plain: '#bfbdb6'
417
+ }
418
+ },
419
+ {
420
+ id: 'ayu-light',
421
+ label: { zh: 'Ayu 浅色', en: 'Ayu Light' },
422
+ kind: 'light',
423
+ colors: {
424
+ bg: '#fafafa',
425
+ fg: '#5c6166',
426
+ gutterBg: '#f3f4f4',
427
+ gutterFg: '#a0a6ab',
428
+ border: '#e7e8e9',
429
+ selection: '#d1e4f4',
430
+ lineHighlight: '#f0f1f1',
431
+ caret: '#ff6a00',
432
+ keyword: '#fa8d3e',
433
+ string: '#86b300',
434
+ comment: '#787b80',
435
+ number: '#a37acc',
436
+ functionName: '#f2ae49',
437
+ typeName: '#55b4d4',
438
+ operator: '#ed9366',
439
+ punctuation: '#5c6166',
440
+ plain: '#5c6166'
441
+ }
298
442
  }
299
443
  ]
300
444
 
@@ -310,6 +454,9 @@ const EDITOR_THEME_FAMILIES = [
310
454
  { id: 'vscode', label: { zh: 'VS Code Dark+ / Light+', en: 'VS Code Dark+ / Light+' }, light: 'vs-light', dark: 'vs-dark' },
311
455
  { id: 'xcode', label: { zh: 'Xcode Light / Dark', en: 'Xcode Light / Dark' }, light: 'xcode-light', dark: 'xcode-dark' },
312
456
  { id: 'catppuccin', label: { zh: 'Catppuccin Latte / Mocha', en: 'Catppuccin Latte / Mocha' }, light: 'catppuccin-latte', dark: 'catppuccin-mocha' },
457
+ { id: 'tokyo', label: { zh: 'Tokyo Night', en: 'Tokyo Night' }, light: 'tokyo-night-light', dark: 'tokyo-night' },
458
+ { id: 'gruvbox', label: { zh: 'Gruvbox', en: 'Gruvbox' }, light: 'gruvbox-light', dark: 'gruvbox-dark' },
459
+ { id: 'ayu', label: { zh: 'Ayu', en: 'Ayu' }, light: 'ayu-light', dark: 'ayu-dark' },
313
460
  ]
314
461
 
315
462
  // 0.5.3: every family needs both a light and a dark variant. The extra
@@ -1954,7 +2101,10 @@ function attributeViolation(name, value, tagName) {
1954
2101
  // Remote workspaces get their own page kind: the two modes show different
1955
2102
  // trees (local ⇄ remote pair vs. a plain remote root), so a session must be
1956
2103
  // able to hold both, and each one filters its own workspace list.
1957
- var REMOTE_TREE_TAB_TYPE = 'dsh-remote-workspace';
2104
+ var REMOTE_TREE_TAB_TYPE = 'dsh-remote-workspace'
2105
+ // The DSH settings dialog only exists in the desktop shell, so the web build
2106
+ // had no way to reach these switches. This tab is our own surface for them.
2107
+ var SETTINGS_TAB_TYPE = 'dsh-linked-workspace:settings';
1958
2108
  // One tree page; a folder with 20k entries must not render 20k rows.
1959
2109
  var TREE_PAGE_SIZE = 500;
1960
2110
  var TREE_PAGE_MAX = 5000;
@@ -1978,7 +2128,8 @@ function attributeViolation(name, value, tagName) {
1978
2128
  var remotePlaceholderKeys = new Set();
1979
2129
  var remoteWorkspaceKeys = new Set();
1980
2130
  var linkedTabDisposer = null;
1981
- var remoteTabDisposer = null;
2131
+ var remoteTabDisposer = null
2132
+ var settingsTabDisposer = null;
1982
2133
  var syncDirectoryTabsRef = null;
1983
2134
  // Set by the sidebar registration block so the availability refresh can ask
1984
2135
  // the sidebar to rebuild its "+" entries after the workspace lists change.
@@ -2276,7 +2427,7 @@ function attributeViolation(name, value, tagName) {
2276
2427
  searchStop: '停止',
2277
2428
  searchStats: '扫描 {{files}} 个文件 · {{size}}',
2278
2429
  searchStatsSkipped: '跳过 {{count}} 个',
2279
- ctxCopyReference: '复制为 @ 引用',
2430
+ ctxCopyReference: '复制相对地址',
2280
2431
  referenceCopied: '已复制 {{reference}}',
2281
2432
  searchScopeLabel: '范围:{{scope}}',
2282
2433
  findPlaceholder: '查找…',
@@ -2384,6 +2535,9 @@ function attributeViolation(name, value, tagName) {
2384
2535
  themeDark: '深色',
2385
2536
  themeLight: '浅色',
2386
2537
  themeSaved: '主题已保存',
2538
+ themeActiveNow: '当前生效',
2539
+ settingsTabTitle: '联动工作区设置',
2540
+ settingsTabDesc: '主题、远端命令执行、SSH 信任、额外根目录与端口转发,浏览器里也能改。',
2387
2541
  themeModeTitle: '显示模式',
2388
2542
  themeModeHint: '系统模式跟随 DSH 当前的浅色/深色主题;浅色/深色模式强制使用对应配色。',
2389
2543
  themeModeSystem: '系统',
@@ -2521,7 +2675,7 @@ function attributeViolation(name, value, tagName) {
2521
2675
  syncPushing: '正在推送…',
2522
2676
  syncPushed: '已推送 {{pushed}} 个文件',
2523
2677
  syncConflictLeft: '{{count}} 个冲突未处理',
2524
- ctxPushThis: '把这个推送到远端',
2678
+ ctxPushThis: '推送到远端',
2525
2679
  ctxPushSelected: '推送所选的 {{count}} 项到远端',
2526
2680
  syncOnlyConflict: '只看冲突',
2527
2681
  syncLocalTime: '本地 {{when}}',
@@ -2544,6 +2698,9 @@ function attributeViolation(name, value, tagName) {
2544
2698
  autoPushOff: '已关闭:本工作区的改动不会自动推回远端',
2545
2699
  execWorkspacesShow: '展开(已选 {{count}} 个)',
2546
2700
  execWorkspacesHide: '收起',
2701
+ knownKeysShow: '展开({{count}} 条)',
2702
+ knownKeysHide: '收起',
2703
+ knownKeysCount: '{{count}} 条已知主机密钥',
2547
2704
  reconnect: '重新连接',
2548
2705
  reconnecting: '正在连接…',
2549
2706
  reconnectOk: '已重新连接',
@@ -2582,6 +2739,8 @@ function attributeViolation(name, value, tagName) {
2582
2739
  forwardAdd: '开一条隧道',
2583
2740
  forwardStop: '停止',
2584
2741
  forwardOpen: '打开',
2742
+ forwardStuck: '端口被占用,未监听',
2743
+ forwardStuckHint: '本机端口被占用,重启 Host 时没能恢复;点「停止」删掉它,再重新开一条即可。',
2585
2744
  forwardEmpty: '还没有隧道。',
2586
2745
  forwardAdded: '隧道已开启:{{url}}',
2587
2746
  forwardStopped: '隧道已停止',
@@ -2623,6 +2782,7 @@ function attributeViolation(name, value, tagName) {
2623
2782
  localTree: '本地目录',
2624
2783
  openFailed: '打开失败',
2625
2784
  copyPathDone: '已复制路径',
2785
+ addressCopied: '已复制:{{address}}',
2626
2786
  mirrorAutoHint: '开启后每 5 分钟自动检查远端与 .remote 的差异并修复。',
2627
2787
  ctxTransfer: '传输(下载到 .remote)',
2628
2788
  ctxTransferLocal: '传输(到远程目录)',
@@ -2632,7 +2792,8 @@ function attributeViolation(name, value, tagName) {
2632
2792
  ctxNotepad: '用记事本打开副本(不回写)',
2633
2793
  ctxCopy: '复制',
2634
2794
  ctxPaste: '粘贴',
2635
- ctxCopyPath: '复制路径',
2795
+ ctxCopyPath: '复制绝对地址',
2796
+ remoteRefSection: '远程文件与文件夹',
2636
2797
  ctxRename: '重命名',
2637
2798
  ctxDelete: '删除',
2638
2799
  ctxChmod: '更改权限',
@@ -2853,7 +3014,7 @@ function attributeViolation(name, value, tagName) {
2853
3014
  searchStop: 'Stop',
2854
3015
  searchStats: 'Scanned {{files}} files · {{size}}',
2855
3016
  searchStatsSkipped: '{{count}} skipped',
2856
- ctxCopyReference: 'Copy as @ reference',
3017
+ ctxCopyReference: 'Copy relative address',
2857
3018
  referenceCopied: 'Copied {{reference}}',
2858
3019
  searchScopeLabel: 'Scope: {{scope}}',
2859
3020
  findPlaceholder: 'Find…',
@@ -2961,6 +3122,9 @@ function attributeViolation(name, value, tagName) {
2961
3122
  themeDark: 'Dark',
2962
3123
  themeLight: 'Light',
2963
3124
  themeSaved: 'Theme saved',
3125
+ themeActiveNow: 'Active now',
3126
+ settingsTabTitle: 'Linked workspace settings',
3127
+ settingsTabDesc: 'Themes, remote exec, SSH trust, extra roots and port forwarding — editable in the browser too.',
2964
3128
  themeModeTitle: 'Appearance',
2965
3129
  themeModeHint: 'System follows the current DSH light/dark theme; Light and Dark force the matching palette.',
2966
3130
  themeModeSystem: 'System',
@@ -3098,7 +3262,7 @@ function attributeViolation(name, value, tagName) {
3098
3262
  syncPushing: 'Pushing…',
3099
3263
  syncPushed: 'Pushed {{pushed}} file(s)',
3100
3264
  syncConflictLeft: '{{count}} conflict(s) left',
3101
- ctxPushThis: 'Push this to the remote side',
3265
+ ctxPushThis: 'Push to the remote',
3102
3266
  ctxPushSelected: 'Push the {{count}} selected to the remote',
3103
3267
  syncOnlyConflict: 'Conflicts only',
3104
3268
  syncLocalTime: 'local {{when}}',
@@ -3121,6 +3285,9 @@ function attributeViolation(name, value, tagName) {
3121
3285
  autoPushOff: 'off: local edits in this workspace stay local',
3122
3286
  execWorkspacesShow: 'Show ({{count}} ticked)',
3123
3287
  execWorkspacesHide: 'Hide',
3288
+ knownKeysShow: 'Show ({{count}})',
3289
+ knownKeysHide: 'Hide',
3290
+ knownKeysCount: '{{count}} known host keys',
3124
3291
  reconnect: 'Reconnect',
3125
3292
  reconnecting: 'Connecting…',
3126
3293
  reconnectOk: 'Reconnected',
@@ -3159,6 +3326,8 @@ function attributeViolation(name, value, tagName) {
3159
3326
  forwardAdd: 'Open a tunnel',
3160
3327
  forwardStop: 'Stop',
3161
3328
  forwardOpen: 'Open',
3329
+ forwardStuck: 'Port busy, not listening',
3330
+ forwardStuckHint: 'Another program held the local port when the Host restarted; stop this entry and open a new one.',
3162
3331
  forwardEmpty: 'No tunnels yet.',
3163
3332
  forwardAdded: 'Tunnel open: {{url}}',
3164
3333
  forwardStopped: 'Tunnel stopped',
@@ -3200,6 +3369,7 @@ function attributeViolation(name, value, tagName) {
3200
3369
  localTree: 'Local directory',
3201
3370
  openFailed: 'Could not open',
3202
3371
  copyPathDone: 'Path copied',
3372
+ addressCopied: 'Copied: {{address}}',
3203
3373
  mirrorAutoHint: 'When enabled, differences between the remote tree and .remote are checked and repaired every 5 minutes.',
3204
3374
  ctxTransfer: 'Transfer (download to .remote)',
3205
3375
  ctxTransferLocal: 'Transfer (to remote directory)',
@@ -3209,7 +3379,8 @@ function attributeViolation(name, value, tagName) {
3209
3379
  ctxNotepad: 'Open a copy in Notepad (edits are not written back)',
3210
3380
  ctxCopy: 'Copy',
3211
3381
  ctxPaste: 'Paste',
3212
- ctxCopyPath: 'Copy path',
3382
+ ctxCopyPath: 'Copy absolute address',
3383
+ remoteRefSection: 'Remote files & folders',
3213
3384
  ctxRename: 'Rename',
3214
3385
  ctxDelete: 'Delete',
3215
3386
  ctxChmod: 'Change permissions',
@@ -3366,7 +3537,7 @@ function attributeViolation(name, value, tagName) {
3366
3537
  * Host methods the running DSH process does not have yet, the directory
3367
3538
  * pane says so instead of surfacing an unrelated error.
3368
3539
  */
3369
- var HOST_API_REVISION = 9;
3540
+ var HOST_API_REVISION = 11;
3370
3541
  var hostInfoProbe = null;
3371
3542
 
3372
3543
  function probeHostInfo() {
@@ -3687,7 +3858,7 @@ function attributeViolation(name, value, tagName) {
3687
3858
  '.rw-btn-danger{color:var(--dsw-alias-state-error-primary);border-color:color-mix(in srgb,var(--dsw-alias-state-error-primary) 40%,transparent)}',
3688
3859
  '.rw-btn-sm{height:26px;padding:0 9px;font-size:12px;border-radius:7px}',
3689
3860
  '.rw-group{display:flex;flex-direction:column;gap:10px;padding:16px;border:1px solid var(--dsw-alias-border-l2);border-radius:14px;background:var(--dsw-alias-bg-layer-2)}',
3690
- '.rw-group-head{display:flex;align-items:baseline;gap:8px;flex-wrap:wrap}',
3861
+ '.rw-group-head{display:flex;align-items:center;gap:8px;flex-wrap:wrap}',
3691
3862
  '.rw-group-title{font-size:14px;line-height:22px;font-weight:600;color:var(--dsw-alias-label-primary)}',
3692
3863
  '.rw-group-hint{font-size:12px;line-height:18px;color:var(--dsw-alias-label-tertiary)}',
3693
3864
  '.rw-list{display:flex;flex-direction:column;gap:10px}',
@@ -3764,6 +3935,8 @@ function attributeViolation(name, value, tagName) {
3764
3935
  '.rw-editor-pane{display:flex;flex-direction:column;flex:1 1 auto;min-width:0;min-height:0;border-left:1px solid var(--dsw-alias-border-l1)}',
3765
3936
  '.rw-tree-scroll{flex:1 1 auto;min-height:0;overflow:auto;padding:8px}',
3766
3937
  '.rw-tree-toolbar{display:flex;align-items:center;gap:6px;padding:8px 10px;border-bottom:1px solid var(--dsw-alias-border-l1);min-width:0}',
3938
+ '.rw-settings-tab{height:100%;overflow:auto;padding:16px;box-sizing:border-box}',
3939
+ '.rw-settings-tab .rw-root{max-width:none}',
3767
3940
  '.rw-tree-toolbar-title{font-size:12px;line-height:18px;font-weight:600;color:var(--dsw-alias-label-secondary);flex:1 1 auto;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}',
3768
3941
  '.rw-icon-btn{display:inline-flex;align-items:center;justify-content:center;flex:none;width:24px;height:24px;border-radius:6px;border:0;background:transparent;color:var(--dsw-alias-label-secondary);cursor:pointer}',
3769
3942
  '.rw-icon-btn:hover{background:var(--dsw-alias-interactive-bg-hover,rgba(127,127,127,.12));color:var(--dsw-alias-label-primary)}',
@@ -3826,7 +3999,14 @@ function attributeViolation(name, value, tagName) {
3826
3999
  '.rw-theme-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(168px,1fr));gap:10px}',
3827
4000
  '.rw-theme-card{display:flex;flex-direction:column;gap:6px;padding:8px;border:1px solid var(--dsw-alias-border-l2);border-radius:10px;background:var(--dsw-alias-bg-layer-1);cursor:pointer;font:inherit;color:inherit;text-align:left}',
3828
4001
  '.rw-theme-card.is-on{border-color:var(--dsw-alias-brand-primary);box-shadow:0 0 0 1px color-mix(in srgb,var(--dsw-alias-brand-primary) 45%,transparent)}',
3829
- '.rw-theme-preview{display:flex;align-items:center;justify-content:space-between;gap:6px;height:44px;padding:0 10px;border-radius:7px;font-family:ui-monospace,"Cascadia Code",Consolas,monospace;font-size:11px;overflow:hidden}',
4002
+ '.rw-theme-preview{display:flex;flex-direction:column;gap:3px;height:52px}',
4003
+ '.rw-theme-band{display:flex;align-items:center;gap:5px;flex:1;min-height:0;padding:0 8px;border:1px solid transparent;border-radius:6px;font-family:ui-monospace,"Cascadia Code",Consolas,monospace;font-size:11px;line-height:1;overflow:hidden}',
4004
+ '.rw-theme-aa{font-weight:600;margin-right:auto;letter-spacing:.02em}',
4005
+ '.rw-theme-dot{width:7px;height:7px;border-radius:50%;flex:none;opacity:.9}',
4006
+ '.rw-theme-name{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}',
4007
+ '.rw-theme-check{color:var(--dsw-alias-brand-primary);font-weight:700;flex:none}',
4008
+ '.rw-theme-card:hover{border-color:var(--dsw-alias-border-l3,rgba(127,127,127,.4));background:var(--dsw-alias-bg-layer-1)}',
4009
+ '.rw-theme-card.is-on:hover{border-color:var(--dsw-alias-brand-primary)}',
3830
4010
  '.rw-theme-label{display:flex;align-items:center;justify-content:space-between;gap:6px;font-size:12px;line-height:18px}',
3831
4011
  '.rw-theme-kind{font-size:10px;line-height:14px;padding:0 4px;border-radius:3px;border:1px solid currentColor;color:var(--dsw-alias-label-tertiary)}',
3832
4012
  '.rw-tabs{display:flex;gap:4px;padding:3px;border-radius:9px;background:var(--dsw-alias-bg-layer-1);border:1px solid var(--dsw-alias-border-l1)}',
@@ -3857,7 +4037,9 @@ function attributeViolation(name, value, tagName) {
3857
4037
  '.rw-sync-tag{flex:none;min-width:52px;color:rgb(150,150,152)}',
3858
4038
  '.rw-sync-path{flex:1 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-family:var(--dsw-font-mono,monospace)}',
3859
4039
  '.rw-autopush-list{width:100%;resize:vertical;font-family:var(--dsw-font-mono,monospace);font-size:12px}',
3860
- '.rw-autopush-card{margin-top:8px;padding-top:8px;border-top:1px solid var(--dsw-alias-separator,rgba(127,127,127,0.18))}',
4040
+ '.rw-setting-label{font-size:12px;line-height:18px;color:var(--dsw-alias-label-secondary,#8b949e);flex:none;white-space:nowrap}',
4041
+ '.rw-autopush-card{margin-top:2px;padding-top:12px;border-top:1px solid var(--dsw-alias-separator,rgba(127,127,127,0.18))}',
4042
+ '.rw-autopush-head{display:flex;align-items:center;gap:8px;min-width:0}',
3861
4043
  '.rw-autopush-row{display:flex;align-items:center;gap:8px;margin-top:8px}',
3862
4044
  '.rw-known-keys{display:flex;flex-direction:column;gap:6px;margin-top:8px}',
3863
4045
  '.rw-known-key{display:flex;align-items:center;gap:10px}',
@@ -4005,9 +4187,10 @@ function attributeViolation(name, value, tagName) {
4005
4187
  '.rw-placeholder-hint{font-size:11.5px;line-height:17px}',
4006
4188
  '.rw-tree-toolbar-title{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}',
4007
4189
  '.rw-mode-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:7px}',
4008
- '.rw-mode-card{display:flex;flex-direction:column;align-items:flex-start;gap:2px;padding:8px 10px;border:1px solid var(--dsw-alias-border-l2);border-radius:8px;background:var(--dsw-alias-bg-layer-1);color:var(--dsw-alias-label-primary);font:inherit;cursor:pointer;text-align:left}',
4190
+ '.rw-mode-card{display:flex;flex-direction:column;align-items:flex-start;justify-content:center;gap:3px;min-height:58px;padding:8px 10px;border:1px solid var(--dsw-alias-border-l2);border-radius:8px;background:var(--dsw-alias-bg-layer-1);color:var(--dsw-alias-label-primary);font:inherit;cursor:pointer;text-align:left}',
4009
4191
  '.rw-mode-card:hover{border-color:var(--dsw-alias-border-l3,rgba(127,127,127,.4))}',
4010
4192
  '.rw-mode-card.is-on{border-color:var(--dsw-alias-brand-primary);background:color-mix(in srgb,var(--dsw-alias-brand-primary) 9%,transparent)}',
4193
+ '.rw-mode-card.is-on .rw-mode-name{color:var(--dsw-alias-brand-primary)}',
4011
4194
  '.rw-mode-name{font-size:12px;font-weight:600;line-height:17px}',
4012
4195
  '.rw-mode-desc{font-size:10.5px;line-height:14px;color:var(--dsw-alias-label-tertiary)}',
4013
4196
  '.rw-ctx-menu{position:fixed;min-width:214px;max-height:min(70vh,520px);overflow:auto;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);z-index:71;font-size:12px;user-select:none}',
@@ -4218,6 +4401,88 @@ function attributeViolation(name, value, tagName) {
4218
4401
  var HOVER_LINE_ATTR = 'data-lw-hover-line';
4219
4402
  var hoverCardObserver = null;
4220
4403
  var hoverCardState = typeof WeakMap === 'function' ? new WeakMap() : null;
4404
+ // Document panes unmount whenever another tab becomes active, so the view mode
4405
+ // (preview or edit) and the reading position have to live outside the component.
4406
+ var viewMemory = typeof Map === 'function' ? new Map() : null;
4407
+
4408
+ function recallView(key) {
4409
+ if (!viewMemory || !key) return null;
4410
+ return viewMemory.get(key) || null;
4411
+ }
4412
+
4413
+ function rememberView(key, next) {
4414
+ if (!viewMemory || !key || !next) return;
4415
+ viewMemory.set(key, Object.assign({}, viewMemory.get(key) || {}, next));
4416
+ }
4417
+
4418
+ // The directory tab is torn down whenever another session takes focus, so the
4419
+ // open file tabs and the two trees (expansion + already listed entries) are
4420
+ // kept per session here: switching sessions and coming back must look untouched.
4421
+ var panelMemory = typeof Map === 'function' ? new Map() : null;
4422
+
4423
+ function recallPanel(key) {
4424
+ if (!panelMemory || !key) return null;
4425
+ return panelMemory.get(key) || null;
4426
+ }
4427
+
4428
+ function rememberPanel(key, next) {
4429
+ if (!panelMemory || !key || !next) return;
4430
+ panelMemory.set(key, Object.assign({}, panelMemory.get(key) || {}, next));
4431
+ }
4432
+
4433
+ // The panel memory dies with the page: keep the open file tabs in
4434
+ // localStorage too, one entry per pane key (session + mode + pinned
4435
+ // workspace), so a reload or a Host restart reopens what was open.
4436
+ var PANE_TABS_KEY = 'dsh-linked-workspace:pane-tabs';
4437
+ var PANE_TABS_LIMIT = 12;
4438
+ var PANE_FILES_LIMIT = 24;
4439
+
4440
+ function readPaneTabs() {
4441
+ try {
4442
+ var raw = window.localStorage.getItem(PANE_TABS_KEY);
4443
+ if (!raw) return {};
4444
+ var parsed = JSON.parse(raw);
4445
+ return parsed && typeof parsed === 'object' && !Array.isArray(parsed) ? parsed : {};
4446
+ } catch (error) { return {}; }
4447
+ }
4448
+
4449
+ function storedFile(file) {
4450
+ if (!file || typeof file !== 'object') return null;
4451
+ if (typeof file.key !== 'string' || file.key === '') return null;
4452
+ if (file.side !== 'local' && file.side !== 'remote') return null;
4453
+ if (typeof file.path !== 'string' || file.path === '') return null;
4454
+ var name = typeof file.name === 'string' && file.name !== '' ? file.name : file.path.split('/').pop();
4455
+ return { key: file.key, side: file.side, path: file.path, name: name, pinned: file.pinned !== false, line: 0 };
4456
+ }
4457
+
4458
+ function recallPaneTabs(key) {
4459
+ if (!key) return null;
4460
+ var saved = readPaneTabs()[key];
4461
+ if (!saved || typeof saved !== 'object') return null;
4462
+ var files = (Array.isArray(saved.files) ? saved.files : [])
4463
+ .map(storedFile).filter(Boolean).slice(0, PANE_FILES_LIMIT);
4464
+ if (files.length === 0) return null;
4465
+ var activeKey = typeof saved.activeFileKey === 'string' ? saved.activeFileKey : '';
4466
+ var known = false;
4467
+ files.forEach(function (file) { if (file.key === activeKey) known = true; });
4468
+ if (!known) activeKey = files[files.length - 1].key;
4469
+ return { openFiles: files, activeFileKey: activeKey };
4470
+ }
4471
+
4472
+ function rememberPaneTabs(key, openFiles, activeFileKey) {
4473
+ if (!key) return;
4474
+ try {
4475
+ var store = readPaneTabs();
4476
+ var files = (Array.isArray(openFiles) ? openFiles : []).map(storedFile).filter(Boolean).slice(0, PANE_FILES_LIMIT);
4477
+ if (files.length === 0) delete store[key];
4478
+ else store[key] = { files: files, activeFileKey: typeof activeFileKey === 'string' ? activeFileKey : '' };
4479
+ var keys = Object.keys(store);
4480
+ if (keys.length > PANE_TABS_LIMIT) {
4481
+ keys.slice(0, keys.length - PANE_TABS_LIMIT).forEach(function (stale) { delete store[stale]; });
4482
+ }
4483
+ window.localStorage.setItem(PANE_TABS_KEY, JSON.stringify(store));
4484
+ } catch (error) { /* a full or blocked localStorage must not break the panel */ }
4485
+ }
4221
4486
 
4222
4487
  function clearHoverLines(card) {
4223
4488
  var injected = card.querySelectorAll('[' + HOVER_LINE_ATTR + ']');
@@ -4746,15 +5011,25 @@ function attributeViolation(name, value, tagName) {
4746
5011
  props.text ? h('span', null, props.text) : null);
4747
5012
  }
4748
5013
 
5014
+ // Each card previews both halves of the pair, so a light theme and its dark
5015
+ // companion are recognisable without switching the app mode first.
4749
5016
  function ThemeSwatch(props) {
4750
- var theme = props.theme;
4751
- var c = theme.colors;
4752
- return h('div', {
4753
- className: 'rw-theme-preview',
4754
- style: { background: c.bg, color: c.fg, border: '1px solid ' + c.border },
4755
- },
4756
- h('span', { style: { color: c.comment } }, '// remote'),
4757
- h('span', { style: { color: c.keyword, fontWeight: 600 } }, '✓'));
5017
+ function band(theme, key) {
5018
+ var c = theme.colors;
5019
+ return h('span', {
5020
+ key: key,
5021
+ className: 'rw-theme-band',
5022
+ style: { background: c.bg, color: c.fg, borderColor: c.border },
5023
+ },
5024
+ h('span', { className: 'rw-theme-aa', style: { color: c.fg } }, 'Aa'),
5025
+ h('span', { className: 'rw-theme-dot', style: { background: c.keyword } }),
5026
+ h('span', { className: 'rw-theme-dot', style: { background: c.string } }),
5027
+ h('span', { className: 'rw-theme-dot', style: { background: c.functionName } }),
5028
+ h('span', { className: 'rw-theme-dot', style: { background: c.comment } }));
5029
+ }
5030
+ return h('span', { className: 'rw-theme-preview' },
5031
+ band(props.light, 'light'),
5032
+ band(props.dark, 'dark'));
4758
5033
  }
4759
5034
 
4760
5035
  // ── local / remote path pickers ────────────────────────────────────────
@@ -5969,16 +6244,35 @@ function attributeViolation(name, value, tagName) {
5969
6244
  var t = props.t;
5970
6245
  var locale = props.locale;
5971
6246
  var rootPath = props.rootPath;
6247
+ var rememberedTree = recallPanel(props.memoryKey);
5972
6248
  var expandedState = useState(function () {
5973
6249
  var set = new Set();
5974
6250
  set.add(rootPath);
6251
+ if (rememberedTree && Array.isArray(rememberedTree.expanded)) {
6252
+ rememberedTree.expanded.forEach(function (item) { if (item) set.add(item); });
6253
+ }
5975
6254
  return set;
5976
6255
  });
5977
6256
  var expanded = expandedState[0];
5978
6257
  var setExpanded = expandedState[1];
5979
- var cacheState = useState({ entries: new Map() });
6258
+ var cacheState = useState(function () {
6259
+ var entries = new Map();
6260
+ if (rememberedTree && Array.isArray(rememberedTree.entries)) {
6261
+ rememberedTree.entries.forEach(function (pair) {
6262
+ if (pair && pair.length === 2) entries.set(pair[0], pair[1]);
6263
+ });
6264
+ }
6265
+ return { entries: entries };
6266
+ });
5980
6267
  var cache = cacheState[0];
5981
6268
  var setCache = cacheState[1];
6269
+
6270
+ useEffect(function () {
6271
+ rememberPanel(props.memoryKey, {
6272
+ expanded: Array.from(expanded),
6273
+ entries: Array.from(cache.entries.entries()),
6274
+ });
6275
+ }, [expanded, cache]);
5982
6276
  var pending = useRef(new Set());
5983
6277
  var lastRefreshAt = useRef(new Map());
5984
6278
 
@@ -6180,6 +6474,22 @@ function attributeViolation(name, value, tagName) {
6180
6474
  props.on ? h('span', { style: { display: 'inline-flex' } }, IconCheck(12)) : null);
6181
6475
  }
6182
6476
 
6477
+ function openPluginSettings(ctx) {
6478
+ var sidebar = sidebarService(ctx);
6479
+ if (!sidebar || typeof sidebar.openTab !== 'function') return;
6480
+ sidebar.openTab({
6481
+ type: SETTINGS_TAB_TYPE,
6482
+ id: SETTINGS_TAB_TYPE,
6483
+ title: makeT(readLocale(ctx))('settingsTabTitle'),
6484
+ path: '/',
6485
+ meta: {},
6486
+ });
6487
+ }
6488
+
6489
+ function PluginSettingsTab(props) {
6490
+ return h('div', { className: 'rw-settings-tab' }, h(ConnectionsPage, { ctx: props.ctx }));
6491
+ }
6492
+
6183
6493
  function LinkedDirectoryToolbar(props) {
6184
6494
  var t = props.t;
6185
6495
  var menuState = useState(null);
@@ -6193,6 +6503,12 @@ function attributeViolation(name, value, tagName) {
6193
6503
  return h('div', { className: 'rw-linked-toolbar' },
6194
6504
  h('span', { className: 'rw-tree-toolbar-title' }, props.title || t('tabTitle')),
6195
6505
  h('div', { className: 'rw-actions', style: { marginLeft: 'auto', gap: 2 } },
6506
+ h('button', {
6507
+ type: 'button',
6508
+ className: 'rw-icon-btn',
6509
+ title: t('settingsTabTitle'),
6510
+ onClick: function () { if (props.onSettings) props.onSettings(); },
6511
+ }, IconSettingsNav(14)),
6196
6512
  h('div', { className: 'rw-menu-wrap' },
6197
6513
  h('button', {
6198
6514
  type: 'button',
@@ -6462,10 +6778,41 @@ function attributeViolation(name, value, tagName) {
6462
6778
  function ContextMenu(props) {
6463
6779
  var menu = props.menu;
6464
6780
  var items = props.items;
6465
- var style = {
6466
- left: Math.max(8, Math.min(menu.x, window.innerWidth - 260)),
6467
- top: Math.max(8, Math.min(menu.y, window.innerHeight - Math.min(420, items.length * 28 + 40))),
6468
- };
6781
+ // The old clamp guessed the height from the item count, so a long menu on a
6782
+ // short window ran past the bottom edge and lost its last entries. Measure
6783
+ // the real box instead: flip above the pointer when there is more room up
6784
+ // there, otherwise cap the height and scroll inside.
6785
+ var boxRef = useRef(null);
6786
+ var placedState = useState(null);
6787
+ var placed = placedState[0];
6788
+ var setPlaced = placedState[1];
6789
+ var style = placed
6790
+ ? { left: placed.left, top: placed.top, maxHeight: placed.maxHeight }
6791
+ : { left: Math.max(8, Math.min(menu.x, window.innerWidth - 260)), top: menu.y, visibility: 'hidden' };
6792
+ useEffect(function () {
6793
+ var node = boxRef.current;
6794
+ if (!node) return;
6795
+ var margin = 8;
6796
+ var width = node.offsetWidth;
6797
+ var height = node.offsetHeight;
6798
+ var vw = window.innerWidth;
6799
+ var vh = window.innerHeight;
6800
+ var left = Math.max(margin, Math.min(menu.x, vw - width - margin));
6801
+ var spaceBelow = vh - menu.y - margin;
6802
+ var spaceAbove = menu.y - margin;
6803
+ var top = menu.y;
6804
+ var maxHeight = height;
6805
+ if (height > spaceBelow) {
6806
+ if (spaceAbove > spaceBelow) {
6807
+ maxHeight = Math.min(height, spaceAbove);
6808
+ top = Math.max(margin, menu.y - maxHeight);
6809
+ } else {
6810
+ maxHeight = Math.max(160, spaceBelow);
6811
+ top = menu.y;
6812
+ }
6813
+ }
6814
+ setPlaced({ left: left, top: top, maxHeight: maxHeight });
6815
+ }, [menu.x, menu.y, items.length]);
6469
6816
  useEffect(function () {
6470
6817
  function onKey(event) { if (event.key === 'Escape') props.onClose(); }
6471
6818
  window.addEventListener('keydown', onKey);
@@ -6499,6 +6846,7 @@ function attributeViolation(name, value, tagName) {
6499
6846
  onContextMenu: function (event) { event.preventDefault(); props.onClose(); },
6500
6847
  }, h('div', {
6501
6848
  className: 'rw-ctx-menu',
6849
+ ref: boxRef,
6502
6850
  style: style,
6503
6851
  onMouseDown: function (event) { event.stopPropagation(); },
6504
6852
  }, items.map(renderItem)));
@@ -7212,15 +7560,23 @@ function rememberShowHidden(value) {
7212
7560
  var onSaved = props.onSaved;
7213
7561
  var settings = useRuntimeSettings();
7214
7562
  var kind = documentKindOf(path);
7563
+ var viewKey = (local ? 'local' : ((scope && scope.kind ? scope.kind : 'remote') + ':' + ((scope && scope.id) || ''))) + '|' + path;
7564
+ var rememberedView = recallView(viewKey);
7215
7565
  var stateRef = useState({
7216
7566
  loading: true, error: '', data: null, text: '', dirty: false, saving: false,
7217
- preview: false, html: '', previewLoading: false, page: 0, sheet: 0, slide: 0,
7567
+ preview: rememberedView ? rememberedView.preview === true : kind === 'markdown',
7568
+ html: '', previewLoading: false,
7569
+ page: rememberedView ? Number(rememberedView.page) || 0 : 0,
7570
+ sheet: rememberedView ? Number(rememberedView.sheet) || 0 : 0,
7571
+ slide: rememberedView ? Number(rememberedView.slide) || 0 : 0,
7218
7572
  updates: {}, pptxUpdates: {}, rotations: {}, deleted: {}, pdfLoading: false, notice: '',
7219
7573
  findOpen: false, findQuery: '', findIndex: 0,
7220
7574
  });
7221
7575
  var state = stateRef[0];
7222
7576
  var setState = stateRef[1];
7223
7577
  var docTextareaRef = useRef(null);
7578
+ var docBodyRef = useRef(null);
7579
+ var docPreviewRef = useRef(null);
7224
7580
 
7225
7581
  function patch(next) {
7226
7582
  setState(function (previous) { return Object.assign({}, previous, next); });
@@ -7234,10 +7590,15 @@ function rememberShowHidden(value) {
7234
7590
  function load() {
7235
7591
  patch({ loading: true, error: '', notice: '' });
7236
7592
  apiCall('docs.read', params()).then(function (result) {
7593
+ var remembered = recallView(viewKey);
7237
7594
  patch({
7238
7595
  loading: false, error: '', data: result,
7239
7596
  text: result.kind === 'markdown' ? String(result.text || '') : '',
7240
- preview: false, html: '', page: 0, sheet: 0, slide: 0,
7597
+ preview: remembered ? remembered.preview === true : kind === 'markdown',
7598
+ html: '', previewLoading: false,
7599
+ page: remembered ? Number(remembered.page) || 0 : 0,
7600
+ sheet: remembered ? Number(remembered.sheet) || 0 : 0,
7601
+ slide: remembered ? Number(remembered.slide) || 0 : 0,
7241
7602
  updates: {}, pptxUpdates: {}, rotations: {}, deleted: {}, pdfLoading: false, dirty: false,
7242
7603
  });
7243
7604
  }).catch(function (error) {
@@ -7247,6 +7608,39 @@ function rememberShowHidden(value) {
7247
7608
 
7248
7609
  useEffect(function () { load(); }, [path, local, scope && scope.kind, scope && scope.id]);
7249
7610
 
7611
+ useEffect(function () {
7612
+ if (state.loading) return;
7613
+ rememberView(viewKey, { preview: state.preview === true, page: state.page, sheet: state.sheet, slide: state.slide });
7614
+ }, [state.loading, state.preview, state.page, state.sheet, state.slide]);
7615
+
7616
+ useEffect(function () {
7617
+ if (state.loading) return;
7618
+ var remembered = recallView(viewKey);
7619
+ var top = remembered ? Number(remembered.scrollTop) || 0 : 0;
7620
+ var body = docBodyRef.current;
7621
+ if (body) body.scrollTop = top;
7622
+ var preview = docPreviewRef.current;
7623
+ if (preview) preview.scrollTop = top;
7624
+ var area = docTextareaRef.current;
7625
+ if (area) area.scrollTop = top;
7626
+ }, [state.loading, state.preview, state.html, state.previewLoading]);
7627
+
7628
+ function rememberScroll(event) {
7629
+ var node = event && event.currentTarget;
7630
+ if (!node) return;
7631
+ rememberView(viewKey, { scrollTop: node.scrollTop });
7632
+ }
7633
+
7634
+ useEffect(function () {
7635
+ if (state.loading || !state.preview || kind !== 'markdown' || state.html || state.previewLoading) return;
7636
+ patch({ previewLoading: true });
7637
+ apiCall('docs.mdPreview', params({ text: state.text })).then(function (result) {
7638
+ patch({ previewLoading: false, html: sanitizeDocumentHtml(result.html) });
7639
+ }).catch(function (error) {
7640
+ patch({ previewLoading: false, error: messageOf(error, t, locale) });
7641
+ });
7642
+ }, [state.loading, state.preview, state.html, state.previewLoading]);
7643
+
7250
7644
  useEffect(function () {
7251
7645
  if (typeof props.onDirtyChange === 'function') props.onDirtyChange(state.dirty);
7252
7646
  }, [state.dirty]);
@@ -7452,10 +7846,10 @@ function rememberShowHidden(value) {
7452
7846
  var body = null;
7453
7847
  if (kind === 'markdown') {
7454
7848
  body = state.preview
7455
- ? h('div', { className: 'rw-doc-body' },
7849
+ ? h('div', { className: 'rw-doc-body', ref: docBodyRef, onScroll: rememberScroll },
7456
7850
  state.previewLoading ? h('div', { className: 'rw-editor-message' }, Spinner(14), t('loading')) : null,
7457
- state.html ? h('div', { className: 'rw-doc-preview', dangerouslySetInnerHTML: { __html: state.html } }) : null)
7458
- : h('div', { className: 'rw-doc-body' },
7851
+ state.html ? h('div', { ref: docPreviewRef, className: 'rw-doc-preview', onScroll: rememberScroll, dangerouslySetInnerHTML: { __html: state.html } }) : null)
7852
+ : h('div', { className: 'rw-doc-body', ref: docBodyRef, onScroll: rememberScroll },
7459
7853
  state.findOpen ? h('div', { className: 'rw-find-bar rw-doc-find' },
7460
7854
  h('input', {
7461
7855
  className: 'rw-input',
@@ -7482,7 +7876,7 @@ function rememberShowHidden(value) {
7482
7876
  : null,
7483
7877
  h('textarea', {
7484
7878
  ref: docTextareaRef,
7485
- className: 'rw-doc-textarea', value: state.text, spellCheck: false,
7879
+ className: 'rw-doc-textarea', value: state.text, spellCheck: false, onScroll: rememberScroll,
7486
7880
  onChange: function (event) { patch({ text: event.currentTarget.value, dirty: true, html: '' }); },
7487
7881
  }));
7488
7882
  } else if (kind === 'pdf' && state.data) {
@@ -7825,12 +8219,27 @@ function rememberShowHidden(value) {
7825
8219
  return function () { alive = false; clearInterval(timer); };
7826
8220
  }, [selected && selected.key, selected && selected.autoPush]);
7827
8221
 
7828
- var openFilesState = useState([]);
8222
+ // Same idea as the trees: the tab strip outlives this component only if it
8223
+ // is remembered per session.
8224
+ var paneSessionKey = String(props.sessionId || '').replace(/^session-/, '')
8225
+ || String(pinnedLinkedId || pinnedRemoteId || '') || 'pane';
8226
+ var paneMemoryKey = [paneSessionKey, remoteOnly ? 'remote' : 'linked', pinnedLinkedId, pinnedRemoteId].join('|');
8227
+ var rememberedPane = recallPanel(paneMemoryKey) || recallPaneTabs(paneMemoryKey) || {};
8228
+ var openFilesState = useState(function () {
8229
+ return Array.isArray(rememberedPane.openFiles) ? rememberedPane.openFiles.slice() : [];
8230
+ });
7829
8231
  var openFiles = openFilesState[0];
7830
8232
  var setOpenFiles = openFilesState[1];
7831
- var activeFileKeyState = useState('');
8233
+ var activeFileKeyState = useState(function () {
8234
+ return typeof rememberedPane.activeFileKey === 'string' ? rememberedPane.activeFileKey : '';
8235
+ });
7832
8236
  var activeFileKey = activeFileKeyState[0];
7833
8237
  var setActiveFileKey = activeFileKeyState[1];
8238
+
8239
+ useEffect(function () {
8240
+ rememberPanel(paneMemoryKey, { openFiles: openFiles, activeFileKey: activeFileKey });
8241
+ rememberPaneTabs(paneMemoryKey, openFiles, activeFileKey);
8242
+ }, [openFiles, activeFileKey]);
7834
8243
  var directoryOpenState = useState(true);
7835
8244
  var directoryOpen = directoryOpenState[0];
7836
8245
  var setDirectoryOpen = directoryOpenState[1];
@@ -8199,15 +8608,17 @@ function rememberShowHidden(value) {
8199
8608
  }
8200
8609
 
8201
8610
  function copyPathToClipboard(text) {
8611
+ var value = String(text == null ? '' : text);
8202
8612
  try {
8203
8613
  if (navigator.clipboard && navigator.clipboard.writeText) {
8204
- navigator.clipboard.writeText(text).then(function () { showNotice('success', t('copyPathDone')); }).catch(function () {});
8614
+ navigator.clipboard.writeText(value).then(function () {
8615
+ showNotice('success', t('addressCopied', { address: value }));
8616
+ }).catch(function () {});
8205
8617
  return;
8206
8618
  }
8207
8619
  } catch (error) { /* clipboard unavailable */ }
8208
8620
  }
8209
8621
 
8210
- /** Copy the `@relative/path` form the model understands for a workspace path. */
8211
8622
  /** Turn an absolute remote path into a workspace-relative one (for linked.plan). */
8212
8623
  function relativeToRemote(filePath) {
8213
8624
  var root = (selected && selected.remotePath) || '';
@@ -8216,24 +8627,27 @@ function rememberShowHidden(value) {
8216
8627
  return relative.replace(/^\/+/, '');
8217
8628
  }
8218
8629
 
8219
- function copyReference(filePath) {
8220
- var scope = sourceScopeOf(selected);
8221
- var root = selected && selected.kind === 'remote' ? selected.remotePath : (selected && selected.remotePath) || '';
8222
- var relative = String(filePath || '');
8223
- if (root && relative.indexOf(root) === 0) {
8224
- relative = relative.slice(root.length);
8225
- if (relative.charAt(0) !== '/') relative = '/' + relative;
8630
+ /**
8631
+ * The row's address relative to the root of the tree it lives in: the local
8632
+ * root for the left tree, the remote root for the right one.
8633
+ */
8634
+ function relativeAddressOf(side, filePath) {
8635
+ var record = selected || {};
8636
+ var root = side === 'local' ? record.localPath : record.remotePath;
8637
+ var text = String(filePath == null ? '' : filePath).replace(/\\/g, '/');
8638
+ var base = String(root == null ? '' : root).replace(/\\/g, '/').replace(/\/+$/, '');
8639
+ if (base !== '' && (text === base || text.indexOf(base + '/') === 0)) {
8640
+ return text.slice(base.length).replace(/^\/+/, '');
8226
8641
  }
8227
- var reference = '@' + relative.replace(/^\/+/, '');
8228
- try {
8229
- if (navigator.clipboard && navigator.clipboard.writeText) {
8230
- navigator.clipboard.writeText(reference).then(function () {
8231
- showNotice('success', t('referenceCopied', { reference: reference }));
8232
- }).catch(function () {});
8233
- return;
8234
- }
8235
- } catch (error) { /* clipboard unavailable */ }
8236
- void scope
8642
+ return text.replace(/^\/+/, '');
8643
+ }
8644
+
8645
+ function copyRelativeAddress(side, filePath) {
8646
+ copyPathToClipboard(relativeAddressOf(side, filePath));
8647
+ }
8648
+
8649
+ function copyAbsoluteAddress(filePath) {
8650
+ copyPathToClipboard(String(filePath == null ? '' : filePath));
8237
8651
  }
8238
8652
 
8239
8653
  /** Copy a ready-made ssh command that lands in the given remote directory. */
@@ -8918,18 +9332,18 @@ function rememberShowHidden(value) {
8918
9332
  } });
8919
9333
  items.push({ label: t('ctxPaste'), disabled: !canPaste, onSelect: function () { pasteEntry(menu); } });
8920
9334
  items.push({ separator: true });
8921
- items.push({ label: t('ctxCopyPath'), onSelect: function () { copyPathToClipboard(menu.path); } });
8922
- items.push({ label: t('ctxCopyReference'), onSelect: function () { copyReference(menu.path); } });
9335
+ items.push({ label: t('ctxCopyPath'), onSelect: function () { copyAbsoluteAddress(menu.path); } });
9336
+ items.push({ label: t('ctxCopyReference'), onSelect: function () { copyRelativeAddress(menu.side, menu.path); } });
8923
9337
  if (menu.side === 'remote' && menu.isDir) {
8924
9338
  items.push({ label: t('ctxCopySsh'), onSelect: function () { copySshCommand(menu.path); } });
8925
9339
  }
8926
- if (selected.kind === 'linked' && menu.side === 'remote') {
8927
- var remoteRoot = selected.remotePath;
8928
- var relativePath = menu.path.indexOf(remoteRoot) === 0
8929
- ? menu.path.slice(remoteRoot.length).replace(/^\/+/, '')
8930
- : '';
8931
- if (relativePath !== '') {
8932
- items.push({ label: t('ctxPushThis'), onSelect: function () { openSyncPlan([relativePath]); } });
9340
+ // Pushing walks the LOCAL tree (linked.plan reports paths relative to the
9341
+ // local root), so the entry belongs on the local side: a remote row would
9342
+ // have to strip the remote root just to rebuild the same string.
9343
+ if (selected.kind === 'linked' && menu.side === 'local') {
9344
+ var localRelative = relativeAddressOf('local', menu.path);
9345
+ if (localRelative !== '') {
9346
+ items.push({ label: t('ctxPushThis'), onSelect: function () { openSyncPlan([localRelative]); } });
8933
9347
  }
8934
9348
  }
8935
9349
  items.push({ separator: true });
@@ -9289,6 +9703,7 @@ function rememberShowHidden(value) {
9289
9703
  scope: scopeRef,
9290
9704
  rootPath: selected.remotePath,
9291
9705
  rootName: t('allFiles'),
9706
+ memoryKey: paneMemoryKey + ':remote',
9292
9707
  t: t,
9293
9708
  locale: locale,
9294
9709
  showHidden: showHidden,
@@ -9313,6 +9728,7 @@ function rememberShowHidden(value) {
9313
9728
  scope: null,
9314
9729
  rootPath: selected.localPath,
9315
9730
  rootName: t('allFiles'),
9731
+ memoryKey: paneMemoryKey + ':local',
9316
9732
  t: t,
9317
9733
  locale: locale,
9318
9734
  showHidden: showHidden,
@@ -9422,6 +9838,7 @@ function rememberShowHidden(value) {
9422
9838
  }
9423
9839
  transferSelection();
9424
9840
  },
9841
+ onSettings: function () { openPluginSettings(props.ctx); },
9425
9842
  onMode: function (next) { setMode(next); },
9426
9843
  onToggleSearch: function () { setSearchOpen(!searchOpen); },
9427
9844
  onOpenMode: updateOpenMode,
@@ -11184,20 +11601,23 @@ function rememberShowHidden(value) {
11184
11601
  })),
11185
11602
  h('div', { className: 'rw-group-head', style: { marginTop: 12 } },
11186
11603
  h('span', { className: 'rw-group-title' }, t('themeSpecific')),
11604
+ h('span', { className: 'rw-chip' }, String(EDITOR_THEME_FAMILIES.length)),
11187
11605
  h('span', { className: 'rw-group-hint' }, t('themeSpecificHint'))),
11188
11606
  h('div', { className: 'rw-theme-grid' },
11189
11607
  EDITOR_THEME_FAMILIES.map(function (family) {
11190
11608
  var active = (settings.editorThemeFamily || 'github') === family.id;
11191
- var variant = getTheme(mode === 'dark' ? family.dark : mode === 'light' ? family.light : (settings.appThemeDark ? family.dark : family.light));
11192
11609
  return h('button', {
11193
11610
  key: family.id,
11194
11611
  type: 'button',
11195
11612
  className: 'rw-theme-card' + (active ? ' is-on' : ''),
11196
11613
  onClick: function () { chooseFamily(family.id); },
11197
11614
  'aria-pressed': active,
11615
+ title: locale === 'zh' ? family.label.zh : family.label.en,
11198
11616
  },
11199
- h(ThemeSwatch, { theme: variant }),
11200
- h('span', { className: 'rw-theme-label' }, h('span', null, locale === 'zh' ? family.label.zh : family.label.en)));
11617
+ h(ThemeSwatch, { light: getTheme(family.light), dark: getTheme(family.dark) }),
11618
+ h('span', { className: 'rw-theme-label' },
11619
+ h('span', { className: 'rw-theme-name' }, locale === 'zh' ? family.label.zh : family.label.en),
11620
+ active ? h('span', { className: 'rw-theme-check', title: t('themeActiveNow') }, '✓') : null));
11201
11621
  })),
11202
11622
  local.message
11203
11623
  ? h(Banner, {
@@ -11530,21 +11950,22 @@ function rememberShowHidden(value) {
11530
11950
  }
11531
11951
 
11532
11952
  var children = [
11533
- h('div', { className: 'rw-meta' },
11534
- h('span', { className: 'rw-chip' }, t('autoPushTitle')),
11535
- h('span', { className: 'rw-hint', style: { flex: '1 1 auto', margin: 0 } }, config.enabled ? t('autoPushOn') : t('autoPushOff')),
11953
+ h('div', { className: 'rw-autopush-head' },
11954
+ h('span', { className: 'rw-setting-label' }, t('autoPushTitle')),
11536
11955
  local.saving ? Spinner(12) : null,
11537
- h(Switch, {
11538
- checked: config.enabled === true,
11539
- onChange: toggle,
11540
- label: t('autoPushLabel'),
11541
- text: t('autoPushLabel'),
11542
- })),
11956
+ h('div', { style: { marginLeft: 'auto', display: 'flex' } },
11957
+ h(Switch, {
11958
+ checked: config.enabled === true,
11959
+ onChange: toggle,
11960
+ label: t('autoPushLabel'),
11961
+ text: t('autoPushLabel'),
11962
+ }))),
11963
+ h('div', { className: 'rw-hint', style: { marginTop: 4 } }, config.enabled ? t('autoPushOn') : t('autoPushOff')),
11543
11964
  ];
11544
11965
 
11545
11966
  if (local.asking && config.enabled !== true) {
11546
11967
  children.push(h('div', { className: 'rw-hint', style: { color: 'rgb(210,153,34)' } }, t('autoPushWarn')));
11547
- children.push(h('div', { className: 'rw-actions', style: { marginTop: 6 } },
11968
+ children.push(h('div', { className: 'rw-actions', style: { marginTop: 6, justifyContent: 'flex-end' } },
11548
11969
  h('button', {
11549
11970
  type: 'button', className: 'rw-btn rw-btn-sm',
11550
11971
  onClick: function () { patchLocal({ asking: false }); },
@@ -11571,10 +11992,11 @@ function rememberShowHidden(value) {
11571
11992
  },
11572
11993
  onBlur: function () { save({ debounceMs: Math.round(Number(local.debounceMs) || 1500) }, t('autoPushSaved')); },
11573
11994
  })));
11574
- children.push(h('div', { className: 'rw-group-head', style: { marginTop: 8 } },
11995
+ children.push(h('div', { className: 'rw-autopush-row' },
11575
11996
  h('span', { className: 'rw-setting-label' }, t('autoPushIncludeLabel'))));
11576
11997
  children.push(h('textarea', {
11577
11998
  className: 'rw-input rw-input-mono rw-autopush-list',
11999
+ style: { marginTop: 6 },
11578
12000
  rows: 2,
11579
12001
  value: local.include,
11580
12002
  placeholder: 'src/**\ndocs/*.md',
@@ -11584,10 +12006,11 @@ function rememberShowHidden(value) {
11584
12006
  },
11585
12007
  onBlur: function () { save({ include: lines(local.include) }, t('autoPushSaved')); },
11586
12008
  }));
11587
- children.push(h('div', { className: 'rw-group-head', style: { marginTop: 8 } },
12009
+ children.push(h('div', { className: 'rw-autopush-row' },
11588
12010
  h('span', { className: 'rw-setting-label' }, t('autoPushExcludeLabel'))));
11589
12011
  children.push(h('textarea', {
11590
12012
  className: 'rw-input rw-input-mono rw-autopush-list',
12013
+ style: { marginTop: 6 },
11591
12014
  rows: 2,
11592
12015
  value: local.exclude,
11593
12016
  placeholder: '*.log\n.remote/**',
@@ -11627,6 +12050,10 @@ function rememberShowHidden(value) {
11627
12050
  var keysState = useState([]);
11628
12051
  var keys = keysState[0];
11629
12052
  var setKeys = keysState[1];
12053
+ // The list is long and rarely needed: keep it folded unless asked for.
12054
+ var keysOpenState = useState(false);
12055
+ var keysOpen = keysOpenState[0];
12056
+ var setKeysOpen = keysOpenState[1];
11630
12057
 
11631
12058
  function refreshKeys() {
11632
12059
  apiCall('hosts.hostKeys', {}).then(function (result) {
@@ -11712,10 +12139,19 @@ function rememberShowHidden(value) {
11712
12139
  h('option', { value: 'utf8' }, t('outputEncodingUtf8')),
11713
12140
  h('option', { value: 'gbk' }, t('outputEncodingGbk')))),
11714
12141
  h('div', { className: 'rw-group-head', style: { marginTop: 14 } },
11715
- h('span', { className: 'rw-group-title' }, t('knownKeysTitle'))),
12142
+ h('span', { className: 'rw-group-title' }, t('knownKeysTitle')),
12143
+ h('button', {
12144
+ type: 'button',
12145
+ className: 'rw-btn rw-btn-ghost rw-btn-sm',
12146
+ onClick: function () { setKeysOpen(function (open) { return !open; }); },
12147
+ }, t(keysOpen ? 'knownKeysHide' : 'knownKeysShow', { count: String(keys.length) }))),
11716
12148
  ];
11717
12149
 
11718
- if (keys.length === 0) {
12150
+ if (!keysOpen) {
12151
+ // Folded: one line that says how many are remembered.
12152
+ children.push(h('div', { className: 'rw-group-hint' },
12153
+ keys.length === 0 ? t('knownKeysEmpty') : t('knownKeysCount', { count: String(keys.length) })));
12154
+ } else if (keys.length === 0) {
11719
12155
  children.push(h('div', { className: 'rw-group-hint' }, t('knownKeysEmpty')));
11720
12156
  } else {
11721
12157
  children.push(h('div', { className: 'rw-known-keys' }, keys.map(function (entry) {
@@ -11913,12 +12349,18 @@ function rememberShowHidden(value) {
11913
12349
  children.push(h('div', { className: 'rw-group-hint', style: { marginTop: 10 } }, t('forwardEmpty')));
11914
12350
  } else {
11915
12351
  children.push(h('div', { className: 'rw-known-keys', style: { marginTop: 10 } }, forwards.map(function (entry) {
12352
+ // A tunnel restored after a Host restart whose port was taken has no
12353
+ // URL: say why instead of offering a dead link.
12354
+ var stuck = entry.url === '';
12355
+ var detail = stuck ? (entry.error || t('forwardStuck')) : entry.url;
11916
12356
  return h('div', { className: 'rw-known-key', key: entry.id },
11917
12357
  h('div', { className: 'rw-known-key-main' },
11918
12358
  h('span', { className: 'rw-known-key-host' }, entry.hostName + ' → ' + entry.remoteHost + ':' + entry.remotePort),
11919
- h('span', { className: 'rw-known-key-fp', title: entry.url }, entry.url)),
12359
+ h('span', { className: 'rw-known-key-fp', title: detail, style: stuck ? { color: 'var(--dsw-alias-state-error-primary, #ff7b72)' } : null }, detail)),
11920
12360
  h('div', { className: 'rw-actions' },
11921
- h('a', { className: 'rw-btn rw-btn-sm', href: entry.url, target: '_blank', rel: 'noreferrer' }, t('forwardOpen')),
12361
+ stuck
12362
+ ? h('span', { className: 'rw-group-hint' }, t('forwardStuckHint'))
12363
+ : h('a', { className: 'rw-btn rw-btn-sm', href: entry.url, target: '_blank', rel: 'noreferrer' }, t('forwardOpen')),
11922
12364
  h('button', { type: 'button', className: 'rw-btn rw-btn-sm', disabled: local.busy, onClick: function () { stop(entry); } }, t('forwardStop'))));
11923
12365
  })));
11924
12366
  }
@@ -12059,15 +12501,188 @@ function rememberShowHidden(value) {
12059
12501
  h('button', { type: 'button', className: 'rw-btn rw-btn-ghost rw-btn-sm', onClick: remote.reload }, IconRefresh(12), t('refresh'))));
12060
12502
  }
12061
12503
 
12504
+ // ── @ references ───────────────────────────────────────────────────────
12505
+
12506
+ // The composer's own @ menu can only list what the host's fileReferences
12507
+ // service knows about, and it has no provider seat. The client does expose
12508
+ // an input-trigger seat though, so this source widens the same menu: a
12509
+ // leading "@" in the query (the user typed "@@") lists the remote tree, and
12510
+ // a query that looks like a path is offered as a reference for that path.
12511
+ function sessionCwdOf(session) {
12512
+ if (!session) return '';
12513
+ if (typeof session.cwd === 'string') return session.cwd;
12514
+ if (session.snapshot && typeof session.snapshot.cwd === 'string') return session.snapshot.cwd;
12515
+ if (session.meta && typeof session.meta.cwd === 'string') return session.meta.cwd;
12516
+ return '';
12517
+ }
12518
+
12519
+ function sessionWorkspaceIdOf(session) {
12520
+ if (!session) return '';
12521
+ if (typeof session.workspaceId === 'string') return session.workspaceId;
12522
+ if (session.snapshot && typeof session.snapshot.workspaceId === 'string') return session.snapshot.workspaceId;
12523
+ if (session.meta && typeof session.meta.workspaceId === 'string') return session.meta.workspaceId;
12524
+ return '';
12525
+ }
12526
+
12527
+ function samePath(left, right) {
12528
+ function norm(value) {
12529
+ return String(value == null ? '' : value).replace(/\\/g, '/').replace(/\/+$/, '').toLowerCase();
12530
+ }
12531
+ var a = norm(left);
12532
+ var b = norm(right);
12533
+ return a !== '' && a === b;
12534
+ }
12535
+
12536
+ function referenceScopeFor(session) {
12537
+ var cwd = sessionCwdOf(session);
12538
+ var workspaceId = sessionWorkspaceIdOf(session);
12539
+ var sessionId = String((session && (session.sessionId || session.id)) || '');
12540
+ // The session object handed to a trigger source only carries its id, so ask
12541
+ // the Host which workspace owns it; fall back to the local scan below.
12542
+ if (sessionId !== '') {
12543
+ return apiCall('linked.sessionScope', { sessionId: sessionId }).then(function (resolved) {
12544
+ var scope = resolved && resolved.scope;
12545
+ if (scope && (scope.linkedId || scope.remoteId)) {
12546
+ return { linkedId: scope.linkedId, remoteId: scope.remoteId, root: scope.root || '' };
12547
+ }
12548
+ return scanReferenceScope(cwd, workspaceId);
12549
+ }).catch(function () { return scanReferenceScope(cwd, workspaceId); });
12550
+ }
12551
+ return scanReferenceScope(cwd, workspaceId);
12552
+ }
12553
+
12554
+ function scanReferenceScope(cwd, workspaceId) {
12555
+ return apiCall('linked.list').catch(function () { return { links: [] }; }).then(function (linked) {
12556
+ var links = (linked && linked.links) || [];
12557
+ for (var index = 0; index < links.length; index += 1) {
12558
+ if (workspaceId && links[index].workspaceId === workspaceId) return { linkedId: links[index].id, root: links[index].remotePath || '' };
12559
+ if (cwd && links[index].localPath && samePath(cwd, links[index].localPath)) return { linkedId: links[index].id, root: links[index].remotePath || '' };
12560
+ }
12561
+ return apiCall('remote_workspaces.list').catch(function () { return { workspaces: [] }; }).then(function (remote) {
12562
+ var list = (remote && remote.workspaces) || [];
12563
+ for (var cursor = 0; cursor < list.length; cursor += 1) {
12564
+ if (workspaceId && list[cursor].workspaceId === workspaceId) return { remoteId: list[cursor].id, root: list[cursor].remotePath || '' };
12565
+ if (cwd && list[cursor].placeholderPath && samePath(cwd, list[cursor].placeholderPath)) return { remoteId: list[cursor].id, root: list[cursor].remotePath || '' };
12566
+ }
12567
+ return null;
12568
+ });
12569
+ });
12570
+ }
12571
+
12572
+ function mentionRefFor(path, isDir) {
12573
+ var text = String(path == null ? '' : path);
12574
+ if (isDir && text.slice(-1) !== '/') text += '/';
12575
+ if (/[\u0000-\u001f\u007f-\u009f"]/u.test(text)) return null;
12576
+ if (!/\s/u.test(text)) return '@' + text;
12577
+ return isDir ? '@"' + text : '@"' + text + '"';
12578
+ }
12579
+
12580
+ function installReferenceTriggers(ctx) {
12581
+ var service = null;
12582
+ try { service = ctx.get('inputTriggers'); } catch (error) { service = null; }
12583
+ if (!service || typeof service.registerSource !== 'function') return;
12584
+ var t = makeT(readLocale(ctx));
12585
+
12586
+ // One "@" lists the remote tree next to DSH's own local suggestions; the
12587
+ // section title keeps the two groups apart. Sessions that are not backed
12588
+ // by a linked/remote workspace return nothing, leaving the stock menu as
12589
+ // it is.
12590
+ //
12591
+ // Only ONE directory is listed per keystroke: "dir/prefix" is split and the
12592
+ // folder is listed, so the menu answers immediately. A fuzzy scan of the
12593
+ // whole tree (fs.references) takes 5–20 s over SSH and always lost the race
12594
+ // with the menu.
12595
+ function candidates(session, request) {
12596
+ var query = String((request && request.query) || '');
12597
+ var signal = request && request.signal;
12598
+ if (signal && signal.aborted) return Promise.resolve([]);
12599
+ return referenceScopeFor(session).then(function (scope) {
12600
+ if (!scope) return [];
12601
+ var slash = query.lastIndexOf('/');
12602
+ var dirPart = slash >= 0 ? query.slice(0, slash) : '';
12603
+ var namePart = slash >= 0 ? query.slice(slash + 1) : query;
12604
+ var params = { path: dirPart === '' ? '.' : dirPart, limit: 500 };
12605
+ if (scope.linkedId) params.linkedId = scope.linkedId;
12606
+ if (scope.remoteId) params.remoteId = scope.remoteId;
12607
+ return apiCall('fs.list', params).catch(function () { return { entries: [] }; }).then(function (result) {
12608
+ if (signal && signal.aborted) return [];
12609
+ var needle = namePart.toLowerCase();
12610
+ var entries = (result && result.entries) || [];
12611
+ var out = [];
12612
+ for (var index = 0; index < entries.length && out.length < 30; index += 1) {
12613
+ var entry = entries[index] || {};
12614
+ var name = String(entry.name || '');
12615
+ if (name === '') continue;
12616
+ if (needle !== '' && name.toLowerCase().indexOf(needle) < 0) continue;
12617
+ var isDir = entry.type === 'dir';
12618
+ var relative = String(entry.relative || (dirPart === '' ? name : dirPart.replace(/\/+$/, '') + '/' + name));
12619
+ out.push({
12620
+ name: relative,
12621
+ label: name + (isDir ? '/' : ''),
12622
+ description: relative,
12623
+ icon: isDir ? 'folder' : 'file',
12624
+ section: t('remoteRefSection'),
12625
+ });
12626
+ }
12627
+ return out;
12628
+ });
12629
+ });
12630
+ }
12631
+
12632
+ function onPick(pick) {
12633
+ var candidate = (pick && pick.candidate) || {};
12634
+ var path = String(candidate.name || '');
12635
+ if (path === '') return undefined;
12636
+ var isDir = candidate.icon === 'folder';
12637
+ var ref = mentionRefFor(path, isDir);
12638
+ if (!ref) return undefined;
12639
+ var label = isDir ? String(path).replace(/\/+$/, '').split('/').pop() : String(path).split('/').pop();
12640
+ return {
12641
+ insert: {
12642
+ source: 'linked-workspace',
12643
+ ref: ref,
12644
+ label: label || ref,
12645
+ appearance: isDir ? 'folder' : 'file',
12646
+ clipboardText: path,
12647
+ },
12648
+ };
12649
+ }
12650
+
12651
+ var source = {
12652
+ trigger: '@',
12653
+ name: 'linked-workspace',
12654
+ // DSH's own @ sources leave `order` at 0 (see dsh-client-ui-reference:
12655
+ // `{ trigger: '@', name: 'reference' }`), and the menu sorts sources by
12656
+ // that number, so a negative value puts the remote group first.
12657
+ order: -1,
12658
+ showGroupTitle: true,
12659
+ candidates: candidates,
12660
+ onPick: onPick,
12661
+ codec: {
12662
+ clipboardText: function (ref) { return String(ref == null ? '' : ref).replace(/^@/, ''); },
12663
+ serialize: function (ref) { return Promise.resolve(String(ref == null ? '' : ref).replace(/^@/, '')); },
12664
+ },
12665
+ };
12666
+
12667
+ ctx.effect(function () {
12668
+ try {
12669
+ return service.registerSource(source);
12670
+ } catch (error) {
12671
+ return undefined;
12672
+ }
12673
+ }, 'dsh-linked-workspace: @ reference source');
12674
+ }
12675
+
12062
12676
  // ── apply ──────────────────────────────────────────────────────────────
12063
12677
 
12064
12678
  // `sessions` is a core client service (the sidebar shell injects it too):
12065
12679
  // the directory entries need the focused session's cwd/workspaceId to
12066
12680
  // decide whether they belong in the "+" menu.
12067
- var inject = ['slots', 'locale', 'sessions'];
12681
+ var inject = ['slots', 'locale', 'sessions', 'inputTriggers'];
12068
12682
 
12069
12683
  function apply(ctx) {
12070
12684
  ctx.effect(installStyles, 'dsh-linked-workspace: styles');
12685
+ installReferenceTriggers(ctx);
12071
12686
  ctx.effect(function () {
12072
12687
  var lastDark = null;
12073
12688
  var sync = function () {
@@ -12234,13 +12849,23 @@ function rememberShowHidden(value) {
12234
12849
  // notifies without touching the stored tabs, so open pages survive.
12235
12850
  var visibilitySignature = '';
12236
12851
 
12852
+ // '' means "the session store has not caught up yet" — a poll can hand us
12853
+ // a snapshot without the session on screen for a moment, and tearing the
12854
+ // entries down then would close the pages open inside them.
12237
12855
  function currentVisibilitySignature() {
12856
+ var scope = readActiveScope();
12857
+ if (!scope.cwd && !scope.workspaceId) return '';
12858
+ activeScopeCache = scope;
12238
12859
  return (linkedTabHidden() ? '0' : '1') + (remoteTabHidden() ? '0' : '1');
12239
12860
  }
12240
12861
 
12241
- function syncTabVisibility() {
12242
- var next = currentVisibilitySignature();
12243
- if (next === visibilitySignature) return;
12862
+ // Re-registering is what makes the sidebar rebuild its "+" entries, and it
12863
+ // is only safe while the answer is stable: a page keeps its open files and
12864
+ // its scroll position as long as the descriptor stays put, so a short quiet
12865
+ // period is required before the descriptors are swapped.
12866
+ var visibilityTimer = null;
12867
+
12868
+ function applyVisibilitySignature(next) {
12244
12869
  visibilitySignature = next;
12245
12870
  if (linkedTabDisposer === null && remoteTabDisposer === null) return;
12246
12871
  disposeLinkedTab();
@@ -12249,6 +12874,25 @@ function rememberShowHidden(value) {
12249
12874
  installRemoteTab(false);
12250
12875
  }
12251
12876
 
12877
+ function syncTabVisibility() {
12878
+ var next = currentVisibilitySignature();
12879
+ if (next === '') return;
12880
+ if (next === visibilitySignature) {
12881
+ if (visibilityTimer !== null) {
12882
+ clearTimeout(visibilityTimer);
12883
+ visibilityTimer = null;
12884
+ }
12885
+ return;
12886
+ }
12887
+ if (visibilityTimer !== null) clearTimeout(visibilityTimer);
12888
+ visibilityTimer = setTimeout(function () {
12889
+ visibilityTimer = null;
12890
+ var settled = currentVisibilitySignature();
12891
+ if (settled === '' || settled === visibilitySignature) return;
12892
+ applyVisibilitySignature(settled);
12893
+ }, 900);
12894
+ }
12895
+
12252
12896
  function watchSessionScope() {
12253
12897
  visibilitySignature = currentVisibilitySignature();
12254
12898
  try {
@@ -12312,6 +12956,29 @@ function rememberShowHidden(value) {
12312
12956
  remoteTabDisposer = null;
12313
12957
  }
12314
12958
 
12959
+ function installSettingsTab(track) {
12960
+ if (settingsTabDisposer !== null) return;
12961
+ settingsTabDisposer = sidebar.registerTab({
12962
+ id: SETTINGS_TAB_TYPE,
12963
+ title: function () { return makeT(readLocale(ctx))('settingsTabTitle'); },
12964
+ description: function () { return makeT(readLocale(ctx))('settingsTabDesc'); },
12965
+ icon: function (size) { return IconSettingsNav(size); },
12966
+ order: 60,
12967
+ single: true,
12968
+ available: function () { return true; },
12969
+ component: function (props) {
12970
+ return h(PluginSettingsTab, Object.assign({}, props, { ctx: ctx }));
12971
+ },
12972
+ });
12973
+ if (track !== false) tabDisposers.push(function () { disposeSettingsTab(); });
12974
+ }
12975
+
12976
+ function disposeSettingsTab() {
12977
+ if (settingsTabDisposer === null) return;
12978
+ try { settingsTabDisposer(); } catch (error) { /* ignore */ }
12979
+ settingsTabDisposer = null;
12980
+ }
12981
+
12315
12982
  // Both page kinds stay registered for the whole session: `available`
12316
12983
  // only greys out the "+" entry for a mismatched session, while
12317
12984
  // `openTab` refuses a kind it has never seen. Registering lazily per
@@ -12329,8 +12996,16 @@ function rememberShowHidden(value) {
12329
12996
  refreshTabVisibilityRef = syncTabVisibility;
12330
12997
  installLinkedTab();
12331
12998
  installRemoteTab();
12999
+ installSettingsTab();
12332
13000
  watchSessionScope();
12333
- syncTabVisibility();
13001
+ var initialSignature = currentVisibilitySignature();
13002
+ if (initialSignature !== '') applyVisibilitySignature(initialSignature);
13003
+ tabDisposers.push(function () {
13004
+ if (visibilityTimer !== null) {
13005
+ clearTimeout(visibilityTimer);
13006
+ visibilityTimer = null;
13007
+ }
13008
+ });
12334
13009
  try {
12335
13010
  tabDisposers.push(sidebar.subscribeState(function () { syncDirectoryTabs(); }));
12336
13011
  } catch (error) { /* state subscription is optional */ }