dsh-linked-workspace 0.22.0 → 0.24.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
@@ -2540,6 +2540,10 @@ function attributeViolation(name, value, tagName) {
2540
2540
  autoPushChip: '自动推送',
2541
2541
  autoPushChipTitle: '已开启:本地静止 {{debounce}} ms 后推送',
2542
2542
  autoPushChipLast: '最近一次 {{when}}',
2543
+ autoPushOn: '已开启:本工作区的本地改动会自动推回远端',
2544
+ autoPushOff: '已关闭:本工作区的改动不会自动推回远端',
2545
+ execWorkspacesShow: '展开(已选 {{count}} 个)',
2546
+ execWorkspacesHide: '收起',
2543
2547
  reconnect: '重新连接',
2544
2548
  reconnecting: '正在连接…',
2545
2549
  reconnectOk: '已重新连接',
@@ -2566,6 +2570,21 @@ function attributeViolation(name, value, tagName) {
2566
2570
  forgetHostKey: '忘记',
2567
2571
  forgotHostKey: '已忘记 {{authority}} 的主机密钥',
2568
2572
  sshTrustSaved: 'SSH 设置已保存',
2573
+ extraRootsTitle: '额外根目录',
2574
+ extraRootsHint: '每行一个绝对路径前缀。默认情况下,模型只能在当前工作区内读写;把共享盘之类的前缀加到这里,模型才能用 read_outside / write_outside / list_outside 访问,每次访问都会写进审计日志。',
2575
+ extraRootsPlaceholder: '/shared_data_ssd1/huangjh',
2576
+ extraRootsSaved: '已保存 {{count}} 个前缀',
2577
+ forwardTitle: '端口转发',
2578
+ forwardHint: '把远端服务(TensorBoard、Jupyter 等)映射到本机 127.0.0.1 的端口,开好后点开 URL 就能在浏览器里看。',
2579
+ forwardHostLabel: '主机',
2580
+ forwardRemoteLabel: '远端地址(host:port)',
2581
+ forwardLocalLabel: '本机端口(留空自动分配)',
2582
+ forwardAdd: '开一条隧道',
2583
+ forwardStop: '停止',
2584
+ forwardOpen: '打开',
2585
+ forwardEmpty: '还没有隧道。',
2586
+ forwardAdded: '隧道已开启:{{url}}',
2587
+ forwardStopped: '隧道已停止',
2569
2588
  execTitle: '远端命令执行',
2570
2589
  execHint: '默认关闭。开启后,会话里的模型可以通过 linked_workspace 的 exec 动作在远端跑命令;只对下面勾选的主机/工作区生效,每次尝试(含被拒)都记进审计日志。',
2571
2590
  execEnabledLabel: '允许在远端执行命令',
@@ -2713,7 +2732,6 @@ function attributeViolation(name, value, tagName) {
2713
2732
  welcomeReplay: 'Show the welcome card again',
2714
2733
  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.',
2715
2734
  addWorkspace: 'Add workspace',
2716
- addRemoteDir: 'Add remote directory',
2717
2735
  addLinked: 'Add linked workspace',
2718
2736
  createLinked: 'Create linked workspace',
2719
2737
  addShort: 'Add',
@@ -3099,6 +3117,10 @@ function attributeViolation(name, value, tagName) {
3099
3117
  autoPushChip: 'auto push',
3100
3118
  autoPushChipTitle: 'on · pushes after {{debounce}} ms of local quiet',
3101
3119
  autoPushChipLast: 'last {{when}}',
3120
+ autoPushOn: 'on: local edits in this workspace are pushed automatically',
3121
+ autoPushOff: 'off: local edits in this workspace stay local',
3122
+ execWorkspacesShow: 'Show ({{count}} ticked)',
3123
+ execWorkspacesHide: 'Hide',
3102
3124
  reconnect: 'Reconnect',
3103
3125
  reconnecting: 'Connecting…',
3104
3126
  reconnectOk: 'Reconnected',
@@ -3125,6 +3147,21 @@ function attributeViolation(name, value, tagName) {
3125
3147
  forgetHostKey: 'Forget',
3126
3148
  forgotHostKey: 'Forgot the host key for {{authority}}',
3127
3149
  sshTrustSaved: 'SSH settings saved',
3150
+ extraRootsTitle: 'Extra roots',
3151
+ extraRootsHint: 'One absolute path prefix per line. By default the model can only read and write inside the current workspace; add shared drives here to let it use read_outside / write_outside / list_outside. Every access is written to the audit log.',
3152
+ extraRootsPlaceholder: '/shared_data_ssd1/huangjh',
3153
+ extraRootsSaved: 'Saved {{count}} prefixes',
3154
+ forwardTitle: 'Port forwards',
3155
+ forwardHint: 'Map a remote service (TensorBoard, Jupyter, …) onto a local 127.0.0.1 port and open the URL in a browser.',
3156
+ forwardHostLabel: 'Host',
3157
+ forwardRemoteLabel: 'Remote address (host:port)',
3158
+ forwardLocalLabel: 'Local port (blank picks one)',
3159
+ forwardAdd: 'Open a tunnel',
3160
+ forwardStop: 'Stop',
3161
+ forwardOpen: 'Open',
3162
+ forwardEmpty: 'No tunnels yet.',
3163
+ forwardAdded: 'Tunnel open: {{url}}',
3164
+ forwardStopped: 'Tunnel stopped',
3128
3165
  execTitle: 'Remote command execution',
3129
3166
  execHint: 'Off by default. When on, the model can run commands on the remote host through the linked_workspace "exec" action — only for the hosts and workspaces ticked below, and every attempt (refusals included) is audited.',
3130
3167
  execEnabledLabel: 'Allow running commands remotely',
@@ -3329,7 +3366,7 @@ function attributeViolation(name, value, tagName) {
3329
3366
  * Host methods the running DSH process does not have yet, the directory
3330
3367
  * pane says so instead of surfacing an unrelated error.
3331
3368
  */
3332
- var HOST_API_REVISION = 7;
3369
+ var HOST_API_REVISION = 9;
3333
3370
  var hostInfoProbe = null;
3334
3371
 
3335
3372
  function probeHostInfo() {
@@ -3820,6 +3857,8 @@ function attributeViolation(name, value, tagName) {
3820
3857
  '.rw-sync-tag{flex:none;min-width:52px;color:rgb(150,150,152)}',
3821
3858
  '.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)}',
3822
3859
  '.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))}',
3861
+ '.rw-autopush-row{display:flex;align-items:center;gap:8px;margin-top:8px}',
3823
3862
  '.rw-known-keys{display:flex;flex-direction:column;gap:6px;margin-top:8px}',
3824
3863
  '.rw-known-key{display:flex;align-items:center;gap:10px}',
3825
3864
  '.rw-known-key-main{flex:1 1 auto;min-width:0;display:flex;flex-direction:column;gap:2px}',
@@ -7712,6 +7751,7 @@ function rememberShowHidden(value) {
7712
7751
  username: item.username,
7713
7752
  hostName: item.hostName,
7714
7753
  mirror: item.mirror,
7754
+ autoPush: item.autoPush,
7715
7755
  status: item.status,
7716
7756
  };
7717
7757
  }
@@ -7756,28 +7796,25 @@ function rememberShowHidden(value) {
7756
7796
  return function () { alive = false; };
7757
7797
  }, [diskHostId, diskPath]);
7758
7798
 
7759
- // autoPush is host-side and silent, so surface it here: the switch state
7760
- // plus the newest push from the transfer history.
7799
+ // autoPush is host-side and silent, so surface it here: the per-workspace
7800
+ // switch state (0.24.0) plus the newest push from the transfer history.
7761
7801
  var autoPushState = useState(null);
7762
7802
  var autoPush = autoPushState[0];
7763
7803
  var setAutoPush = autoPushState[1];
7764
7804
  useEffect(function () {
7765
7805
  var alive = true;
7766
7806
  function load() {
7767
- Promise.all([
7768
- apiCall('settings.get', {}),
7769
- apiCall('transfer.history', {}).catch(function () { return { entries: [] }; }),
7770
- ]).then(function (results) {
7807
+ apiCall('transfer.history', {}).catch(function () { return { entries: [] }; }).then(function (result) {
7771
7808
  if (!alive) return;
7772
- var settings = results[0] || {};
7773
- var entries = (results[1] && results[1].entries) || [];
7809
+ var entries = (result && result.entries) || [];
7774
7810
  var lastPush = null;
7775
7811
  for (var index = 0; index < entries.length; index += 1) {
7776
7812
  if (entries[index] && entries[index].kind === 'push') { lastPush = entries[index]; break; }
7777
7813
  }
7814
+ var config = (selected && selected.autoPush) || null;
7778
7815
  setAutoPush({
7779
- enabled: settings.autoPushEnabled === true,
7780
- debounceMs: settings.autoPushDebounceMs || 1500,
7816
+ enabled: Boolean(config && config.enabled === true),
7817
+ debounceMs: (config && config.debounceMs) || 1500,
7781
7818
  lastPushAt: lastPush ? lastPush.at : null,
7782
7819
  });
7783
7820
  }).catch(function () { if (alive) setAutoPush(null); });
@@ -7786,7 +7823,7 @@ function rememberShowHidden(value) {
7786
7823
  var timer = setInterval(load, 15000);
7787
7824
  if (timer && typeof timer.unref === 'function') timer.unref();
7788
7825
  return function () { alive = false; clearInterval(timer); };
7789
- }, [selected && selected.key]);
7826
+ }, [selected && selected.key, selected && selected.autoPush]);
7790
7827
 
7791
7828
  var openFilesState = useState([]);
7792
7829
  var openFiles = openFilesState[0];
@@ -10887,6 +10924,7 @@ function rememberShowHidden(value) {
10887
10924
  text: t('mirrorLabel'),
10888
10925
  })),
10889
10926
  h('div', { className: 'rw-hint' }, t('mirrorHint')),
10927
+ h(AutoPushCardSection, { t: t, locale: locale, link: link, refresh: refresh }),
10890
10928
  local.removing
10891
10929
  ? h('div', { className: 'rw-warn-box' },
10892
10930
  h('div', null, t('removeWorkspaceHint')),
@@ -11242,6 +11280,10 @@ function rememberShowHidden(value) {
11242
11280
  });
11243
11281
  var local = state[0];
11244
11282
  var setLocal = state[1];
11283
+ // The second-layer list is long and rarely touched: start collapsed.
11284
+ var workspaceListState = useState(false);
11285
+ var workspacesOpen = workspaceListState[0];
11286
+ var setWorkspacesOpen = workspaceListState[1];
11245
11287
 
11246
11288
  var adopt = function (settings, extra) {
11247
11289
  var value = settings || {};
@@ -11367,25 +11409,39 @@ function rememberShowHidden(value) {
11367
11409
  h('span', { className: 'rw-exec-name' }, host.name || host.host || host.id),
11368
11410
  h('span', { className: 'rw-exec-meta' }, (host.username ? host.username + '@' : '') + (host.host || '') + (host.port ? ':' + host.port : '')));
11369
11411
  })));
11412
+ var picked = local.execWorkspaceIds;
11370
11413
  children.push(h('div', { className: 'rw-group-head', style: { marginTop: 12 } },
11371
11414
  h('span', { className: 'rw-group-title' }, t('execWorkspacesTitle')),
11372
- h('span', { className: 'rw-group-hint' }, t('execWorkspacesHint'))));
11373
- children.push(workspaces.length === 0
11374
- ? h('div', { className: 'rw-hint' }, t('execHostsEmpty'))
11375
- : h('div', { className: 'rw-exec-list' }, workspaces.map(function (item) {
11376
- var checked = local.execWorkspaceIds.indexOf(item.id) >= 0;
11377
- return h('label', { key: item.id, className: 'rw-exec-item' },
11378
- h('input', {
11379
- type: 'checkbox',
11380
- checked: checked,
11381
- onChange: function (event) {
11382
- var on = event.currentTarget.checked;
11383
- save({ execWorkspaceIds: withId(local.execWorkspaceIds, item.id, on) }, t('execSaved'));
11384
- },
11385
- }),
11386
- h('span', { className: 'rw-exec-name' }, item.name || item.id),
11387
- h('span', { className: 'rw-exec-meta' }, item.remotePath || ''));
11388
- })));
11415
+ h('button', {
11416
+ type: 'button',
11417
+ className: 'rw-btn rw-btn-ghost rw-btn-sm',
11418
+ onClick: function () { setWorkspacesOpen(function (open) { return !open; }); },
11419
+ }, t(workspacesOpen ? 'execWorkspacesHide' : 'execWorkspacesShow', { count: String(picked.length) }))));
11420
+ if (workspacesOpen) {
11421
+ children.push(h('div', { className: 'rw-group-hint', style: { marginTop: 4 } }, t('execWorkspacesHint')));
11422
+ children.push(workspaces.length === 0
11423
+ ? h('div', { className: 'rw-hint' }, t('execHostsEmpty'))
11424
+ : h('div', { className: 'rw-exec-list' }, workspaces.map(function (item) {
11425
+ var checked = picked.indexOf(item.id) >= 0;
11426
+ return h('label', { key: item.id, className: 'rw-exec-item' },
11427
+ h('input', {
11428
+ type: 'checkbox',
11429
+ checked: checked,
11430
+ onChange: function (event) {
11431
+ var on = event.currentTarget.checked;
11432
+ save({ execWorkspaceIds: withId(local.execWorkspaceIds, item.id, on) }, t('execSaved'));
11433
+ },
11434
+ }),
11435
+ h('span', { className: 'rw-exec-name' }, item.name || item.id),
11436
+ h('span', { className: 'rw-exec-meta' }, item.remotePath || ''));
11437
+ })));
11438
+ } else if (picked.length > 0) {
11439
+ // Collapsed but not empty: spell out what is allowed, one line.
11440
+ var names = workspaces.filter(function (item) { return picked.indexOf(item.id) >= 0; })
11441
+ .map(function (item) { return item.name || item.id; });
11442
+ children.push(h('div', { className: 'rw-group-hint', style: { marginTop: 4 } },
11443
+ names.length > 0 ? names.join('、') : String(picked.length)));
11444
+ }
11389
11445
  children.push(h('div', { className: 'rw-inline', style: { marginTop: 12, flexWrap: 'wrap', gap: 12 } },
11390
11446
  numberRow(t('execTimeoutLabel'), local.execTimeoutSec, 1, 600, 1, {
11391
11447
  field: 'execTimeoutSec',
@@ -11418,161 +11474,139 @@ function rememberShowHidden(value) {
11418
11474
  return h('div', { className: 'rw-group' }, children);
11419
11475
  }
11420
11476
 
11421
- function AutoPushSettingsGroup(props) {
11477
+ /**
11478
+ * Auto push lives on the workspace card (0.24.0): every linked workspace has
11479
+ * its own switch, debounce and include/exclude globs, so "watch this repo"
11480
+ * never implies "watch all of them".
11481
+ */
11482
+ function AutoPushCardSection(props) {
11422
11483
  var t = props.t;
11423
11484
  var locale = props.locale;
11424
- var localState = useState({ loading: true, saving: false, message: null, asking: false });
11425
- var local = localState[0];
11426
- var setLocal = localState[1];
11427
- var valuesState = useState({
11428
- autoPushEnabled: false,
11429
- autoPushDebounceMs: 1500,
11430
- autoPushInclude: '',
11431
- autoPushExclude: '',
11485
+ var link = props.link;
11486
+ var config = link.autoPush || { enabled: false, debounceMs: 1500, include: [], exclude: [] };
11487
+ var statePack = useState({
11488
+ saving: false,
11489
+ asking: false,
11490
+ message: null,
11491
+ include: (config.include || []).join('\n'),
11492
+ exclude: (config.exclude || []).join('\n'),
11493
+ debounceMs: Number(config.debounceMs) || 1500,
11432
11494
  });
11433
- var values = valuesState[0];
11434
- var setValues = valuesState[1];
11495
+ var local = statePack[0];
11496
+ var setLocal = statePack[1];
11435
11497
 
11436
- useEffect(function () {
11437
- var alive = true;
11438
- apiCall('settings.get', {}).then(function (settings) {
11439
- if (!alive) return;
11440
- setValues({
11441
- autoPushEnabled: settings.autoPushEnabled === true,
11442
- autoPushDebounceMs: Number(settings.autoPushDebounceMs) || 1500,
11443
- autoPushInclude: (settings.autoPushInclude || []).join('\n'),
11444
- autoPushExclude: (settings.autoPushExclude || []).join('\n'),
11445
- });
11446
- setLocal(function (previous) { return Object.assign({}, previous, { loading: false }); });
11447
- }).catch(function () {
11448
- if (alive) setLocal(function (previous) { return Object.assign({}, previous, { loading: false }); });
11449
- });
11450
- return function () { alive = false; };
11451
- }, []);
11498
+ function patchLocal(patch) {
11499
+ setLocal(function (previous) { return Object.assign({}, previous, patch); });
11500
+ }
11501
+
11502
+ function lines(text) {
11503
+ return String(text || '').split('\n').map(function (line) { return line.trim(); }).filter(function (line) { return line !== ''; });
11504
+ }
11452
11505
 
11453
11506
  function save(patch, okText) {
11454
- setLocal(function (previous) { return Object.assign({}, previous, { saving: true, message: null }); });
11455
- apiCall('settings.update', patch).then(function (settings) {
11456
- setValues({
11457
- autoPushEnabled: settings.autoPushEnabled === true,
11458
- autoPushDebounceMs: Number(settings.autoPushDebounceMs) || 1500,
11459
- autoPushInclude: (settings.autoPushInclude || []).join('\n'),
11460
- autoPushExclude: (settings.autoPushExclude || []).join('\n'),
11461
- });
11462
- setLocal({ loading: false, saving: false, asking: false, message: { kind: 'success', text: okText } });
11507
+ var next = {
11508
+ enabled: patch.enabled !== undefined ? patch.enabled : config.enabled === true,
11509
+ debounceMs: patch.debounceMs !== undefined ? patch.debounceMs : Math.round(Number(local.debounceMs) || 1500),
11510
+ include: patch.include !== undefined ? patch.include : lines(local.include),
11511
+ exclude: patch.exclude !== undefined ? patch.exclude : lines(local.exclude),
11512
+ };
11513
+ patchLocal({ saving: true, message: null, asking: false });
11514
+ apiCall('linked.update', { id: link.id, autoPush: next }).then(function () {
11515
+ patchLocal({ saving: false, message: { kind: 'success', text: okText } });
11516
+ if (typeof props.refresh === 'function') props.refresh();
11463
11517
  }).catch(function (error) {
11464
- setLocal({
11465
- loading: false,
11466
- saving: false,
11467
- asking: false,
11468
- message: { kind: 'error', text: messageOf(error, t, locale) },
11469
- });
11518
+ patchLocal({ saving: false, message: { kind: 'error', text: messageOf(error, t, locale) } });
11470
11519
  });
11471
11520
  }
11472
11521
 
11473
11522
  function toggle(next) {
11474
- if (next === true && values.autoPushEnabled === false) {
11523
+ if (next === true && config.enabled !== true) {
11475
11524
  // Turning it on writes files behind the user's back: ask once, in
11476
11525
  // place, before the switch actually flips.
11477
- setLocal(function (previous) { return Object.assign({}, previous, { asking: true, message: null }); });
11526
+ patchLocal({ asking: true, message: null });
11478
11527
  return;
11479
11528
  }
11480
- save({ autoPushEnabled: Boolean(next) }, t('autoPushSaved'));
11481
- }
11482
-
11483
- function commitList(field, key) {
11484
- var lines = String(values[field] || '').split('\n').map(function (line) { return line.trim(); }).filter(function (line) { return line !== ''; });
11485
- var patch = {};
11486
- patch[key] = lines;
11487
- save(patch, t('autoPushSaved'));
11529
+ save({ enabled: Boolean(next) }, t('autoPushSaved'));
11488
11530
  }
11489
11531
 
11490
11532
  var children = [
11491
- h('div', { className: 'rw-group-head' },
11492
- h('span', { className: 'rw-group-title' }, t('autoPushTitle'))),
11493
- h('div', { className: 'rw-setting-row' },
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')),
11536
+ local.saving ? Spinner(12) : null,
11494
11537
  h(Switch, {
11495
- checked: values.autoPushEnabled,
11538
+ checked: config.enabled === true,
11496
11539
  onChange: toggle,
11497
11540
  label: t('autoPushLabel'),
11498
11541
  text: t('autoPushLabel'),
11499
- }),
11500
- local.saving ? Spinner(12) : null),
11542
+ })),
11501
11543
  ];
11502
11544
 
11503
- if (local.asking && !values.autoPushEnabled) {
11504
- children.push(h('div', { className: 'rw-group-hint', style: { marginTop: 8, color: 'rgb(210,153,34)' } }, t('autoPushWarn')));
11505
- children.push(h('div', { className: 'rw-dialog-actions', style: { marginTop: 10 } },
11545
+ if (local.asking && config.enabled !== true) {
11546
+ 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 } },
11506
11548
  h('button', {
11507
- type: 'button',
11508
- className: 'rw-btn rw-btn-sm',
11509
- onClick: function () { setLocal(function (previous) { return Object.assign({}, previous, { asking: false }); }); },
11549
+ type: 'button', className: 'rw-btn rw-btn-sm',
11550
+ onClick: function () { patchLocal({ asking: false }); },
11510
11551
  }, t('autoPushCancel')),
11511
11552
  h('button', {
11512
- type: 'button',
11513
- className: 'rw-btn rw-btn-sm rw-btn-primary',
11514
- onClick: function () { save({ autoPushEnabled: true }, t('autoPushSaved')); },
11553
+ type: 'button', className: 'rw-btn rw-btn-sm rw-btn-primary',
11554
+ onClick: function () { save({ enabled: true }, t('autoPushSaved')); },
11515
11555
  }, t('autoPushConfirm'))));
11516
11556
  }
11517
11557
 
11518
- if (values.autoPushEnabled) {
11519
- children.push(h('div', { className: 'rw-group-hint', style: { marginTop: 8 } }, t('autoPushWarn')));
11520
- children.push(h('div', { className: 'rw-group-head', style: { marginTop: 12 } },
11521
- h('span', { className: 'rw-group-title' }, t('autoPushIncludeLabel'))));
11558
+ if (config.enabled === true) {
11559
+ children.push(h('div', { className: 'rw-autopush-row' },
11560
+ h('span', { className: 'rw-setting-label' }, t('autoPushDebounceLabel')),
11561
+ h('input', {
11562
+ className: 'rw-input rw-input-num',
11563
+ type: 'number',
11564
+ min: 300,
11565
+ max: 60000,
11566
+ step: 100,
11567
+ value: local.debounceMs,
11568
+ onChange: function (event) {
11569
+ var value = event.currentTarget.value;
11570
+ patchLocal({ debounceMs: value });
11571
+ },
11572
+ onBlur: function () { save({ debounceMs: Math.round(Number(local.debounceMs) || 1500) }, t('autoPushSaved')); },
11573
+ })));
11574
+ children.push(h('div', { className: 'rw-group-head', style: { marginTop: 8 } },
11575
+ h('span', { className: 'rw-setting-label' }, t('autoPushIncludeLabel'))));
11522
11576
  children.push(h('textarea', {
11523
11577
  className: 'rw-input rw-input-mono rw-autopush-list',
11524
- rows: 3,
11525
- value: values.autoPushInclude,
11578
+ rows: 2,
11579
+ value: local.include,
11526
11580
  placeholder: 'src/**\ndocs/*.md',
11527
11581
  onChange: function (event) {
11528
11582
  var value = event.currentTarget.value;
11529
- setValues(function (previous) { return Object.assign({}, previous, { autoPushInclude: value }); });
11583
+ patchLocal({ include: value });
11530
11584
  },
11531
- onBlur: function () { commitList('autoPushInclude', 'autoPushInclude'); },
11585
+ onBlur: function () { save({ include: lines(local.include) }, t('autoPushSaved')); },
11532
11586
  }));
11533
- children.push(h('div', { className: 'rw-group-head', style: { marginTop: 12 } },
11534
- h('span', { className: 'rw-group-title' }, t('autoPushExcludeLabel'))));
11587
+ children.push(h('div', { className: 'rw-group-head', style: { marginTop: 8 } },
11588
+ h('span', { className: 'rw-setting-label' }, t('autoPushExcludeLabel'))));
11535
11589
  children.push(h('textarea', {
11536
11590
  className: 'rw-input rw-input-mono rw-autopush-list',
11537
- rows: 3,
11538
- value: values.autoPushExclude,
11591
+ rows: 2,
11592
+ value: local.exclude,
11539
11593
  placeholder: '*.log\n.remote/**',
11540
11594
  onChange: function (event) {
11541
11595
  var value = event.currentTarget.value;
11542
- setValues(function (previous) { return Object.assign({}, previous, { autoPushExclude: value }); });
11596
+ patchLocal({ exclude: value });
11543
11597
  },
11544
- onBlur: function () { commitList('autoPushExclude', 'autoPushExclude'); },
11598
+ onBlur: function () { save({ exclude: lines(local.exclude) }, t('autoPushSaved')); },
11545
11599
  }));
11546
- children.push(h('div', { className: 'rw-inline', style: { marginTop: 12, flexWrap: 'wrap', gap: 12 } },
11547
- h('span', { className: 'rw-setting-label' }, t('autoPushDebounceLabel')),
11548
- h('input', {
11549
- className: 'rw-input rw-input-num',
11550
- type: 'number',
11551
- min: 300,
11552
- max: 60000,
11553
- step: 100,
11554
- value: values.autoPushDebounceMs,
11555
- onChange: function (event) {
11556
- var value = event.currentTarget.value;
11557
- setValues(function (previous) { return Object.assign({}, previous, { autoPushDebounceMs: value }); });
11558
- },
11559
- onBlur: function () {
11560
- var ms = Math.round(Number(values.autoPushDebounceMs) || 1500);
11561
- save({ autoPushDebounceMs: ms }, t('autoPushSaved'));
11562
- },
11563
- })));
11564
11600
  }
11565
11601
 
11566
11602
  if (local.message) {
11567
11603
  children.push(h(Banner, {
11568
11604
  kind: local.message.kind === 'success' ? 'success' : 'error',
11569
- onClose: function () {
11570
- setLocal(function (previous) { return Object.assign({}, previous, { message: null }); });
11571
- },
11605
+ onClose: function () { patchLocal({ message: null }); },
11572
11606
  }, local.message.text));
11573
11607
  }
11574
11608
 
11575
- return h('div', { className: 'rw-group' }, children);
11609
+ return h('div', { className: 'rw-autopush-card' }, children);
11576
11610
  }
11577
11611
 
11578
11612
  /**
@@ -11709,6 +11743,196 @@ function rememberShowHidden(value) {
11709
11743
  return h('div', { className: 'rw-group' }, children);
11710
11744
  }
11711
11745
 
11746
+ function ExtraRootsSettingsGroup(props) {
11747
+ var t = props.t;
11748
+ var locale = props.locale;
11749
+ var localState = useState({ loading: true, saving: false, message: null });
11750
+ var local = localState[0];
11751
+ var setLocal = localState[1];
11752
+ var textState = useState('');
11753
+ var text = textState[0];
11754
+ var setText = textState[1];
11755
+
11756
+ useEffect(function () {
11757
+ var alive = true;
11758
+ apiCall('settings.get', {}).then(function (settings) {
11759
+ if (!alive) return;
11760
+ var roots = Array.isArray(settings.extraRoots) ? settings.extraRoots : [];
11761
+ setText(roots.join('\n'));
11762
+ setLocal({ loading: false, saving: false, message: null });
11763
+ }).catch(function () {
11764
+ if (alive) setLocal({ loading: false, saving: false, message: null });
11765
+ });
11766
+ return function () { alive = false; };
11767
+ }, []);
11768
+
11769
+ function save() {
11770
+ var roots = text.split('\n').map(function (line) { return line.trim(); })
11771
+ .filter(function (line) { return line !== ''; });
11772
+ setLocal(function (previous) { return Object.assign({}, previous, { saving: true, message: null }); });
11773
+ apiCall('settings.update', { extraRoots: roots }).then(function (settings) {
11774
+ var saved = Array.isArray(settings.extraRoots) ? settings.extraRoots : roots;
11775
+ setText(saved.join('\n'));
11776
+ setLocal({ loading: false, saving: false, message: { kind: 'success', text: t('extraRootsSaved', { count: String(saved.length) }) } });
11777
+ }).catch(function (error) {
11778
+ setLocal({ loading: false, saving: false, message: { kind: 'error', text: messageOf(error, t, locale) } });
11779
+ });
11780
+ }
11781
+
11782
+ var children = [
11783
+ h('div', { className: 'rw-group-head' },
11784
+ h('span', { className: 'rw-group-title' }, t('extraRootsTitle')),
11785
+ local.saving ? Spinner(12) : null),
11786
+ h('div', { className: 'rw-group-hint' }, t('extraRootsHint')),
11787
+ h('textarea', {
11788
+ className: 'rw-input rw-textarea-mono',
11789
+ style: { marginTop: 10, minHeight: 84, fontFamily: 'var(--dsw-font-mono, monospace)' },
11790
+ spellCheck: false,
11791
+ value: text,
11792
+ placeholder: t('extraRootsPlaceholder'),
11793
+ onChange: function (event) {
11794
+ var next = event.currentTarget.value;
11795
+ setText(next);
11796
+ },
11797
+ onBlur: save,
11798
+ }),
11799
+ ];
11800
+
11801
+ if (local.message) {
11802
+ children.push(h(Banner, {
11803
+ kind: local.message.kind === 'success' ? 'success' : 'error',
11804
+ onClose: function () { setLocal(function (previous) { return Object.assign({}, previous, { message: null }); }); },
11805
+ }, local.message.text));
11806
+ }
11807
+
11808
+ return h('div', { className: 'rw-group' }, children);
11809
+ }
11810
+
11811
+ function ForwardSettingsGroup(props) {
11812
+ var t = props.t;
11813
+ var locale = props.locale;
11814
+ var localState = useState({ busy: false, message: null });
11815
+ var local = localState[0];
11816
+ var setLocal = localState[1];
11817
+ var listState = useState([]);
11818
+ var forwards = listState[0];
11819
+ var setForwards = listState[1];
11820
+ var formState = useState({ hostId: '', remote: '127.0.0.1:6006', localPort: '' });
11821
+ var form = formState[0];
11822
+ var setForm = formState[1];
11823
+ var hosts = props.hosts || [];
11824
+
11825
+ function refresh() {
11826
+ apiCall('hosts.forwards', {}).then(function (result) {
11827
+ setForwards(Array.isArray(result.forwards) ? result.forwards : []);
11828
+ }).catch(function () { setForwards([]); });
11829
+ }
11830
+
11831
+ useEffect(function () {
11832
+ refresh();
11833
+ var timer = setInterval(refresh, 15000);
11834
+ return function () { clearInterval(timer); };
11835
+ }, []);
11836
+
11837
+ useEffect(function () {
11838
+ if (form.hostId === '' && hosts.length > 0) {
11839
+ setForm(function (previous) { return Object.assign({}, previous, { hostId: hosts[0].id }); });
11840
+ }
11841
+ }, [hosts.length]);
11842
+
11843
+ function open() {
11844
+ var text = String(form.remote || '').trim();
11845
+ var cut = text.lastIndexOf(':');
11846
+ var remoteHost = cut > 0 ? text.slice(0, cut) : '127.0.0.1';
11847
+ var remotePort = Number(cut > 0 ? text.slice(cut + 1) : text);
11848
+ if (!remotePort || form.hostId === '') return;
11849
+ var params = { hostId: form.hostId, remoteHost: remoteHost, remotePort: remotePort };
11850
+ var localPort = Number(form.localPort);
11851
+ if (localPort > 0) params.localPort = localPort;
11852
+ setLocal({ busy: true, message: null });
11853
+ apiCall('hosts.forward', params).then(function (result) {
11854
+ setLocal({ busy: false, message: { kind: 'success', text: t('forwardAdded', { url: result.forward.url }) } });
11855
+ refresh();
11856
+ }).catch(function (error) {
11857
+ setLocal({ busy: false, message: { kind: 'error', text: messageOf(error, t, locale) } });
11858
+ });
11859
+ }
11860
+
11861
+ function stop(entry) {
11862
+ setLocal({ busy: true, message: null });
11863
+ apiCall('hosts.unforward', { id: entry.id }).then(function () {
11864
+ setLocal({ busy: false, message: { kind: 'success', text: t('forwardStopped') } });
11865
+ refresh();
11866
+ }).catch(function (error) {
11867
+ setLocal({ busy: false, message: { kind: 'error', text: messageOf(error, t, locale) } });
11868
+ });
11869
+ }
11870
+
11871
+ var children = [
11872
+ h('div', { className: 'rw-group-head' },
11873
+ h('span', { className: 'rw-group-title' }, t('forwardTitle')),
11874
+ local.busy ? Spinner(12) : null),
11875
+ h('div', { className: 'rw-group-hint' }, t('forwardHint')),
11876
+ h('div', { className: 'rw-inline', style: { marginTop: 10, flexWrap: 'wrap', gap: 8 } },
11877
+ h('select', {
11878
+ className: 'rw-input',
11879
+ style: { maxWidth: 220 },
11880
+ value: form.hostId,
11881
+ onChange: function (event) {
11882
+ var next = event.currentTarget.value;
11883
+ setForm(function (previous) { return Object.assign({}, previous, { hostId: next }); });
11884
+ },
11885
+ title: t('forwardHostLabel'),
11886
+ }, hosts.map(function (host) {
11887
+ return h('option', { key: host.id, value: host.id }, host.name || host.id);
11888
+ })),
11889
+ h('input', {
11890
+ className: 'rw-input',
11891
+ style: { width: 190 },
11892
+ value: form.remote,
11893
+ placeholder: t('forwardRemoteLabel'),
11894
+ onChange: function (event) {
11895
+ var next = event.currentTarget.value;
11896
+ setForm(function (previous) { return Object.assign({}, previous, { remote: next }); });
11897
+ },
11898
+ }),
11899
+ h('input', {
11900
+ className: 'rw-input',
11901
+ style: { width: 150 },
11902
+ value: form.localPort,
11903
+ placeholder: t('forwardLocalLabel'),
11904
+ onChange: function (event) {
11905
+ var next = event.currentTarget.value;
11906
+ setForm(function (previous) { return Object.assign({}, previous, { localPort: next }); });
11907
+ },
11908
+ }),
11909
+ h('button', { type: 'button', className: 'rw-btn rw-btn-primary', disabled: local.busy, onClick: open }, t('forwardAdd'))),
11910
+ ];
11911
+
11912
+ if (forwards.length === 0) {
11913
+ children.push(h('div', { className: 'rw-group-hint', style: { marginTop: 10 } }, t('forwardEmpty')));
11914
+ } else {
11915
+ children.push(h('div', { className: 'rw-known-keys', style: { marginTop: 10 } }, forwards.map(function (entry) {
11916
+ return h('div', { className: 'rw-known-key', key: entry.id },
11917
+ h('div', { className: 'rw-known-key-main' },
11918
+ 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)),
11920
+ h('div', { className: 'rw-actions' },
11921
+ h('a', { className: 'rw-btn rw-btn-sm', href: entry.url, target: '_blank', rel: 'noreferrer' }, t('forwardOpen')),
11922
+ h('button', { type: 'button', className: 'rw-btn rw-btn-sm', disabled: local.busy, onClick: function () { stop(entry); } }, t('forwardStop'))));
11923
+ })));
11924
+ }
11925
+
11926
+ if (local.message) {
11927
+ children.push(h(Banner, {
11928
+ kind: local.message.kind === 'success' ? 'success' : 'error',
11929
+ onClose: function () { setLocal(function (previous) { return Object.assign({}, previous, { message: null }); }); },
11930
+ }, local.message.text));
11931
+ }
11932
+
11933
+ return h('div', { className: 'rw-group' }, children);
11934
+ }
11935
+
11712
11936
  function ConnectionsPage(props) {
11713
11937
  var ctx = props.ctx;
11714
11938
  var locale = useLocale(ctx);
@@ -11775,8 +11999,9 @@ function rememberShowHidden(value) {
11775
11999
  hosts: remote.data.hosts || [],
11776
12000
  workspaces: links.concat(remotes),
11777
12001
  }),
11778
- h(AutoPushSettingsGroup, { t: t, locale: locale }),
11779
12002
  h(SshTrustSettingsGroup, { t: t, locale: locale }),
12003
+ h(ExtraRootsSettingsGroup, { t: t, locale: locale }),
12004
+ h(ForwardSettingsGroup, { t: t, locale: locale, hosts: hosts }),
11780
12005
  adding === 'linked'
11781
12006
  ? h(AddWorkspaceFlow, {
11782
12007
  ctx: ctx, t: t, locale: locale,