dsh-ris-ide 1.8.0 → 1.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/README.md +5 -3
  2. package/bin/risd.mjs +14 -17
  3. package/lib/client.js +400 -93
  4. package/lib/debug/vendor/README.md +14 -0
  5. package/lib/debug/vendor/jdwp/client.js +9 -4
  6. package/lib/debug/vendor/src/jdwp/client.ts +12 -5
  7. package/lib/index.js +794 -48
  8. package/lib/proxybridge-bundle.js +1 -1
  9. package/lib/proxybridge-health.js +206 -0
  10. package/lib/redirector.js +1181 -90
  11. package/lib/risd/lifecycle.js +9 -3
  12. package/lib/risd/server.js +762 -26
  13. package/lib/risd/ui.js +419 -98
  14. package/lib/risd-client.js +4 -1
  15. package/lib/startup.js +27 -7
  16. package/package.json +2 -2
  17. package/test/client-viewer.test.mjs +299 -120
  18. package/test/clipboard.test.mjs +259 -0
  19. package/test/debug-engine.test.mjs +3 -1
  20. package/test/dsh-origin.test.mjs +4 -11
  21. package/test/dsh-window-refresh.test.mjs +166 -1
  22. package/test/harness.test.mjs +1 -1
  23. package/test/helpers/cmd.mjs +29 -0
  24. package/test/helpers/tgz.mjs +71 -0
  25. package/test/host-search.test.mjs +18 -11
  26. package/test/host-tail.test.mjs +119 -24
  27. package/test/proxy-route.test.mjs +61 -0
  28. package/test/proxy-window.test.mjs +5 -0
  29. package/test/proxy.test.mjs +13 -1
  30. package/test/proxybridge-bundle.test.mjs +1 -59
  31. package/test/proxybridge-health.test.mjs +116 -0
  32. package/test/redirector-bundle.test.mjs +21 -67
  33. package/test/redirector.test.mjs +395 -5
  34. package/test/risd-api.test.mjs +114 -17
  35. package/test/risd-bridge-degrade.test.mjs +3 -29
  36. package/test/risd-engine.test.mjs +13 -50
  37. package/test/risd-entry.test.mjs +0 -37
  38. package/test/risd-follow-start.test.mjs +101 -0
  39. package/test/risd-git.test.mjs +7 -5
  40. package/test/risd-handoff.test.mjs +6 -50
  41. package/test/risd-helpers.mjs +150 -3
  42. package/test/risd-host-p2.test.mjs +2 -30
  43. package/test/risd-lifecycle.test.mjs +25 -0
  44. package/test/risd-programs.test.mjs +4 -34
  45. package/test/risd-restart.test.mjs +104 -0
  46. package/test/risd-review-p2.test.mjs +0 -13
  47. package/test/risd-shutdown.test.mjs +5 -38
  48. package/test/risd-teardown.test.mjs +8 -27
  49. package/test/risd-ui.test.mjs +322 -4
  50. package/test/risd-write.test.mjs +2 -1
  51. package/test/startup-reconcile.test.mjs +44 -8
  52. package/test/proxy-restart.test.mjs +0 -37
package/lib/risd/ui.js CHANGED
@@ -5,7 +5,7 @@
5
5
  // Phase 2-lite follow-up: the page now has three top tabs —
6
6
  // 概览 · proxy state + running programs grouped by workspace + debug sessions
7
7
  // 代理 · the machine-wide rule table (independent of dsh: CAS save via /v1/proxy,
8
- // engine start/stop, bridge restart, proxy log tail)
8
+ // engine start/stop, one enforcement button, auto-start policy, log tail)
9
9
  // IDE · embeds the dsh IDE window when a dsh window is answering, greyed out
10
10
  // with the reason otherwise (GET /v1/dsh reads dsh-window.json)
11
11
  //
@@ -68,6 +68,9 @@ export function risdUiHtml(options) {
68
68
  /* 「页面代码变了但 daemon 还是旧模块」提示:纯静态页面本身没有热更新,daemon
69
69
  import 过的模块也不会再读盘,只能重启 daemon;这条横幅把「为什么刷新没用」
70
70
  说出来,而不是让用户反复强刷。 */
71
+ #bridge-health-more { font-size:13px; }
72
+ #bridge-health-more summary { color:var(--muted); cursor:pointer; }
73
+ #bridge-health-detail { font-size:13px; line-height:1.5; }
71
74
  .ui-drift { display:flex; align-items:center; gap:8px; padding:6px 12px; background:#eef4ff; border-bottom:1px solid #d7e4ff; color:#1d4ed8; font-size:12px; }
72
75
  .ui-drift[hidden] { display:none; }
73
76
  .ui-drift span { flex:1; }
@@ -206,21 +209,21 @@ export function risdUiHtml(options) {
206
209
  <h2>生命周期 <span class="sub">只配置是否跟随 dsh;所有资源强制跟随 daemon(停止 daemon 时一并停止)</span></h2>
207
210
  <div id="lifecycle-rows">
208
211
  <label class="life"><b>守护进程</b><input type="checkbox" data-life="daemon.followDsh"><span class="muted">跟随 dsh:最后一个 dsh 窗口退出后,空闲 10 分钟自动退出;关掉则一直运行到手动停止</span></label>
209
- <label class="life"><b>代理引擎</b><input type="checkbox" data-life="proxy.followDsh"><span class="muted">跟随 dsh:没有 dsh 租约时拆除隧道(含系统层拦截)</span></label>
212
+ <label class="life"><b>代理引擎</b><input type="checkbox" data-life="proxy.followDsh"><span class="muted">跟随 dsh:dsh 接入时启动引擎,没有 dsh 租约时拆除隧道(含系统层拦截);拦截需要 root 时不会自动弹窗</span></label>
210
213
  <label class="life"><b>程序(JVM)</b><input type="checkbox" data-life="programs.followDsh"><span class="muted">跟随 dsh:最后一个窗口退出后停止程序</span></label>
211
214
  <label class="life"><b>调试会话</b><input type="checkbox" data-life="debug.followDsh"><span class="muted">跟随 dsh:最后一个窗口退出后断开调试</span></label>
212
215
  </div>
213
216
  <div class="row" style="margin-top:10px">
217
+ <span class="muted">勾选即自动保存,不用点按钮</span>
214
218
  <span class="grow"></span>
215
219
  <span class="muted" id="lifecycle-note"></span>
216
- <button id="lifecycle-save">保存生命周期</button>
217
220
  </div>
218
221
  </section>
219
222
  </div>
220
223
 
221
224
  <div class="view" id="view-proxy" hidden>
222
225
  <section>
223
- <h2>ProxyBridge 组件 <span class="sub">系统层拦截所需;按需下载,缓存复用,不随插件打包</span></h2>
226
+ <h2>ProxyBridge 组件 <span class="sub">系统层拦截所需;按需下载,缓存复用</span></h2>
224
227
  <div class="row">
225
228
  <span id="bridge-pill" class="pill off">未知</span>
226
229
  <span class="muted grow" id="bridge-detail"></span>
@@ -228,33 +231,43 @@ export function risdUiHtml(options) {
228
231
  <button id="bridge-upload">选择 tgz 上传</button>
229
232
  <input id="bridge-file" type="file" accept=".tgz,.tar.gz,application/gzip" hidden>
230
233
  </div>
234
+ <div class="row" style="margin-top:8px">
235
+ <span id="bridge-health-pill" class="pill off">未检查</span>
236
+ <span class="muted grow" id="bridge-health-text"></span>
237
+ <button id="bridge-fix" hidden>启动系统层拦截(可能提权)</button>
238
+ <button id="bridge-health-stop" hidden>停止拦截</button>
239
+ </div>
240
+ <div id="bridge-elevate-note" hidden></div>
241
+ <details id="bridge-health-more" style="margin-top:6px" hidden>
242
+ <summary class="muted" style="cursor:pointer">说明</summary>
243
+ <div class="muted" id="bridge-health-detail" style="margin-top:4px;white-space:pre-line"></div>
244
+ </details>
231
245
  <div class="muted" id="bridge-hint" style="margin-top:6px"></div>
232
246
  </section>
233
247
  <section>
234
- <h2>规则表 <span class="sub">全局规则:按机器生效、不区分工作区;保存经 daemon 的 CAS,多窗口同时改不会互相覆盖</span></h2>
248
+ <h2>规则表 <span class="sub">全局规则:按机器生效、不区分工作区</span></h2>
235
249
  <div class="row" style="margin-bottom:10px">
236
250
  <span class="pill off" id="proxy-engine-pill">未知</span>
237
251
  <span class="grow"></span>
238
- <button id="proxy-engine-toggle" disabled>启动</button>
239
252
  <span class="muted" id="proxy-revision"></span>
253
+ <button id="proxy-engine-toggle" disabled>启动</button>
240
254
  </div>
241
255
  <div class="row" style="margin-bottom:10px">
242
256
  <label class="muted">SOCKS 主机</label><input id="proxy-socks-host" class="narrow" placeholder="host">
243
257
  <label class="muted">端口</label><input id="proxy-socks-port" class="narrow" placeholder="1080">
244
- <span id="proxy-ping" class="pill off" role="status" title="">检测中…</span>
245
258
  <label class="muted">监听端口</label><input id="proxy-listen" class="narrow" placeholder="11081">
259
+ <span id="proxy-ping" class="pill off" role="status" title="">检测中…</span>
246
260
  </div>
247
261
  <div id="proxy-banner"></div>
248
262
  <table>
249
263
  <thead>
250
- <tr><th style="width:56px">启用</th><th style="width:170px">程序 / IP</th><th>目标主机</th><th style="width:120px">端口</th><th style="width:88px">状态</th><th style="width:90px">来源</th><th></th></tr>
264
+ <tr><th style="width:56px">启用</th><th style="width:170px">程序名称/路径</th><th>目标主机</th><th style="width:120px">端口</th><th style="width:88px">状态</th><th style="width:90px">来源</th><th></th></tr>
251
265
  </thead>
252
266
  <tbody id="proxy-rules"></tbody>
253
267
  </table>
254
268
  <div class="row" style="margin-top:10px">
255
269
  <button id="proxy-add">+ 添加规则</button>
256
270
  <span class="grow"></span>
257
- <button id="bridge-restart" hidden>重启系统层拦截(可能提权)</button>
258
271
  <button id="proxy-log-toggle">代理日志</button>
259
272
  </div>
260
273
  <pre id="proxy-log" hidden></pre>
@@ -299,7 +312,7 @@ export function risdUiHtml(options) {
299
312
  var PAGE_INSTANCE = ${uiInstance};
300
313
  var initialCwd = '';
301
314
  try { initialCwd = new URLSearchParams(location.search).get('cwd') || ''; } catch { /* no URL API */ }
302
- var state = { tab: 'overview', cwd: initialCwd || localStorage.getItem('risd.cwd') || '', view: null, logOn: false, logTimer: null, pollTimer: null, pingTimer: null, pingSeq: 0, dsh: null, dshAvailable: null, lifecycleDirty: false, proxyDirty: false, proxyRunning: false, summary: { proxyRunning: false, programs: 0, debugs: 0 }, staleDismissed: {},
315
+ var state = { tab: 'overview', cwd: initialCwd || localStorage.getItem('risd.cwd') || '', view: null, logOn: false, logTimer: null, pollTimer: null, pingTimer: null, pingSeq: 0, healthTimer: null, elevateNote: null, dsh: null, dshAvailable: null, lifecycleDirty: false, proxyDirty: false, proxyRunning: false, stopBusy: false, fixBusy: false, bridgeStaleReason: '', bridgeMissing: [], bridgeEngineRunning: false, bridgeStray: false, summary: { proxyRunning: false, programs: 0, debugs: 0 }, staleDismissed: {},
303
316
  };
304
317
  // The drift banner's current message and the message the user closed: a closed
305
318
  // hint must not pop back every 5 s, but a NEW kind of drift still has to warn.
@@ -510,15 +523,49 @@ export function risdUiHtml(options) {
510
523
  return policy;
511
524
  }
512
525
 
513
- function saveLifecycle() {
526
+ // 勾选即保存(没有保存按钮):一次勾选就是一次配置修改,不该再多一步确认。
527
+ // 300 ms 防抖合并连点;请求在飞时只记一个「还有一次」,避免两个 POST 互相覆盖。
528
+ var lifecycleTimer = null;
529
+ var lifecycleSave = null;
530
+ var lifecycleQueued = false;
531
+
532
+ function scheduleLifecycleSave() {
533
+ // Mark it dirty right away: the 4 s refresh must not refill the boxes from the
534
+ // daemon while the save is still being debounced (review C-P2-3).
535
+ state.lifecycleDirty = true;
536
+ if (lifecycleTimer !== null) clearTimeout(lifecycleTimer);
537
+ lifecycleTimer = setTimeout(function () { lifecycleTimer = null; saveLifecycle(true); }, 300);
538
+ }
539
+
540
+ function saveLifecycle(auto) {
541
+ if (lifecycleSave !== null) { lifecycleQueued = true; return lifecycleSave; }
514
542
  var policy = lifecycleFromBoxes();
515
- return api('/v1/config', { method: 'POST', body: { lifecycle: policy } }).then(function (body) {
543
+ var run = api('/v1/config', { method: 'POST', body: { lifecycle: policy } }).then(function (body) {
516
544
  state.lifecycle = body.lifecycle || policy;
517
- state.lifecycleDirty = false;
518
- el('lifecycle-note').textContent = '已保存';
519
- setTimeout(function () { if (el('lifecycle-note')) el('lifecycle-note').textContent = ''; }, 2500);
520
- return loadLifecycle();
521
- }).catch(function (error) { el('lifecycle-note').textContent = '保存失败:' + error.message; });
545
+ // Another toggle landed while this POST was in flight: keep the form as the
546
+ // user left it (refilling from the daemon would undo that toggle) and let the
547
+ // queued save carry it; dirty stays set so the 4 s refresh leaves it alone.
548
+ var queued = lifecycleQueued === true;
549
+ if (queued !== true) state.lifecycleDirty = false;
550
+ return (queued === true ? Promise.resolve() : loadLifecycle()).then(function () {
551
+ el('lifecycle-note').textContent = auto === true ? '已自动保存' : '已保存';
552
+ setTimeout(function () { if (el('lifecycle-note')) el('lifecycle-note').textContent = ''; }, 2500);
553
+ });
554
+ }).catch(function (error) {
555
+ // Keep lifecycleDirty so the refresh loop cannot silently revert the toggle;
556
+ // the next click retries the whole form.
557
+ el('lifecycle-note').textContent = '保存失败:' + error.message + '(再勾一次重试)';
558
+ });
559
+ lifecycleSave = run.then(function (value) {
560
+ lifecycleSave = null;
561
+ if (lifecycleQueued === true) { lifecycleQueued = false; scheduleLifecycleSave(); }
562
+ return value;
563
+ }, function (error) {
564
+ lifecycleSave = null;
565
+ if (lifecycleQueued === true) { lifecycleQueued = false; scheduleLifecycleSave(); }
566
+ throw error;
567
+ });
568
+ return lifecycleSave;
522
569
  }
523
570
 
524
571
  function refreshOverview() {
@@ -586,17 +633,14 @@ export function risdUiHtml(options) {
586
633
  }
587
634
 
588
635
  /**
589
- * The restart button is noise when nothing is stale, and the whole point when
590
- * something is: show it only for a failed/incomplete reload and put the reason in
591
- * the tooltip (a click costs a UAC prompt on Windows and sudo on this side).
636
+ * Remember whether the last save left a stale enforcement behind. The reason is
637
+ * only trusted when it names a real failure; a normal "reloading in the
638
+ * background" note must not light the button up.
592
639
  */
593
640
  function setBridgeStale(reason) {
594
641
  var stale = /未重载|旧规则|需要提权|未能重载|未重启|未能停止/.test(String(reason || ''));
595
- var button = el('bridge-restart');
596
- button.hidden = !stale;
597
- button.title = stale
598
- ? '为什么要重启:' + reason + '(点一下会停止系统层拦截并按当前规则表重新启动;Windows 会弹一次 UAC,本侧需要 sudo)'
599
- : '';
642
+ state.bridgeStaleReason = stale ? String(reason) : '';
643
+ paintBridgeFix();
600
644
  }
601
645
 
602
646
  function renderProxyTab(view) {
@@ -672,17 +716,11 @@ export function risdUiHtml(options) {
672
716
  }
673
717
 
674
718
  /** A complete, enabled row is what makes starting the engine worth doing. */
675
- function hasActionableRule(view) {
676
- return (view && view.rules || []).some(function (rule) {
677
- return rule.enabled !== false && String(rule.program || '').trim() !== '' &&
678
- String(rule.hosts || '').trim() !== '' && portSpecOk(rule.ports);
679
- });
680
- }
681
-
682
719
  /**
683
- * 「勾选的配置不为空、有效就自动保存并启动」:editing is the save. A partially
684
- * filled row is not an error the user must dismiss, so the banner explains what is
685
- * still missing and the save happens once it is complete.
720
+ * 「勾选的配置不为空、有效就自动保存」:editing is the save. A partially filled row
721
+ * is not an error the user must dismiss, so the banner explains what is still
722
+ * missing and the save happens once it is complete. Saving never starts the engine
723
+ * (m13920) — only the button, or the dsh-start policy, does.
686
724
  */
687
725
  var autoSaveTimer = null;
688
726
  // Rapid edits can outrun a POST: the second write would carry the revision of the
@@ -708,35 +746,6 @@ export function risdUiHtml(options) {
708
746
  saveRules({ auto: true });
709
747
  }
710
748
 
711
- /**
712
- * After a successful save, bring the tunnel up — that is the 「并启动」 half. A
713
- * bridge that needs elevation is reported as a note (the restart button appears
714
- * from setBridgeStale), never as a silent failure.
715
- */
716
- function maybeStartProxy(view) {
717
- if (!view || view.running === true || hasActionableRule(view) === false) return Promise.resolve(null);
718
- var version = state.editVersion || 0;
719
- el('proxy-banner').innerHTML = banner('ok', '规则已保存,正在启动代理…');
720
- return api('/v1/action', { method: 'POST', body: { action: 'start', cwd: state.cwd } }).then(function (response) {
721
- var result = (response && response.result) || {};
722
- var redirector = result.redirector || {};
723
- var skipped = Array.isArray(redirector.skipped) ? redirector.skipped : [];
724
- var note = skipped.length > 0
725
- ? '系统层拦截需要提权:' + skipped.map(function (item) { return item.side + ':' + item.reason; }).join(';')
726
- : (typeof result.reloadNote === 'string' ? result.reloadNote : '');
727
- state.lastReloadNote = note;
728
- if ((state.editVersion || 0) !== version) return null;
729
- return loadProxyTab().then(function () {
730
- el('proxy-banner').innerHTML = note
731
- ? banner('warn', '规则已保存;' + note + '(可点「重启系统层拦截」重试)')
732
- : banner('ok', '规则已保存并已启动代理');
733
- });
734
- }).catch(function (error) {
735
- el('proxy-banner').innerHTML = banner('warn', '规则已保存,但代理启动失败:' + error.message);
736
- return null;
737
- });
738
- }
739
-
740
749
  function loadProxyTab() {
741
750
  // The rule table is machine-wide: no workspace picker. The workspace only tags
742
751
  // rows for bookkeeping, so the daemon falls back to its own home when omitted.
@@ -796,10 +805,17 @@ export function risdUiHtml(options) {
796
805
  state.proxyDirty = false;
797
806
  // Reload first, then show the outcome: loadProxyTab clears the banner itself.
798
807
  return loadProxyTab().then(function () {
799
- el('proxy-banner').innerHTML = banner(result.reloadNote ? 'warn' : 'ok',
808
+ // Saving is not starting (m13920): editing the table used to bring the engine
809
+ // up as a side effect, so 「保存即启动」 came as a surprise and the policy
810
+ // checkbox was not the only way to end up with a running engine. A save now
811
+ // only reloads an engine that is already up (switchEnforcement) and names the
812
+ // button that starts one.
813
+ var engineDown = !state.view || state.view.running !== true;
814
+ var hint = engineDown ? ';引擎未启动(保存不会启动它,点「启动」或组件区的「启动系统层拦截」)' : '';
815
+ el('proxy-banner').innerHTML = banner(result.reloadNote ? 'warn' : (engineDown ? 'warn' : 'ok'),
800
816
  (auto ? '已自动保存' : '已保存') + '(revision ' + result.revision + ')' +
801
- (result.reloadNote ? ' · ' + result.reloadNote : ''));
802
- return maybeStartProxy(state.view);
817
+ (result.reloadNote ? ' · ' + result.reloadNote : '') + hint);
818
+ return null;
803
819
  });
804
820
  });
805
821
  saveInFlight = run.then(function (value) {
@@ -837,6 +853,20 @@ export function risdUiHtml(options) {
837
853
  el('proxy-log-toggle').textContent = state.logOn ? '停止日志' : '代理日志';
838
854
  syncLogTimer();
839
855
  }
856
+ // m12313: the component card is timer-driven — no manual re-check. Two caches sit
857
+ // behind the route: the component snapshot (file + version probes) for 30 s, and
858
+ // the interception status for 5 s — so a 10 s poll re-detects the bridge each
859
+ // tick but does not probe the component files every time (评审 20261109-2326
860
+ // 客户端 P2).
861
+ function syncHealthTimer() {
862
+ var wanted = state.tab === 'proxy' && document.hidden !== true
863
+ if (wanted && state.healthTimer === null) {
864
+ state.healthTimer = setInterval(function () { void loadHealth(false) }, 10000)
865
+ } else if (!wanted && state.healthTimer !== null) {
866
+ clearInterval(state.healthTimer)
867
+ state.healthTimer = null
868
+ }
869
+ }
840
870
  // The tail costs up to 40 KB every 2 s: poll only while the pane is actually on
841
871
  // screen (proxy tab, page visible) and pause on a hidden tab instead of keeping
842
872
  // the timer alive off-screen (review C-P2-3).
@@ -910,10 +940,268 @@ export function risdUiHtml(options) {
910
940
  hint.textContent = lines.join('\\n');
911
941
  hint.style.whiteSpace = 'pre-line';
912
942
  }
943
+ // m12313/m12508: one short line at a glance; the long explanation (sudo command,
944
+ // degraded JVM/env plan) lives in a collapsed <details> under it.
945
+ // m12923: the elevation note is card-owned. A terminal note lives until the helper
946
+ // script removes its state file (or the side starts intercepting); other outcomes
947
+ // fade out on their own, so the card never keeps a stale sentence.
948
+ function renderElevateNote(health) {
949
+ var box = el('bridge-elevate-note')
950
+ if (!box) return
951
+ var note = state.elevateNote
952
+ if (!note) { box.hidden = true; box.innerHTML = ''; return }
953
+ var interception = (health && health.interception) || {}
954
+ var elevations = (health && health.elevations) || {}
955
+ var side = note.side
956
+ var active = !!(side && elevations[side] && elevations[side].active === true)
957
+ if (active) note.seenActive = true
958
+ if (side && interception[side] === true) {
959
+ state.elevateNote = null
960
+ } else if (note.terminal === true) {
961
+ // Seen open once and now gone = the window closed after the password.
962
+ if (note.seenActive === true && active === false) state.elevateNote = null
963
+ // Never seen open within 8 s: the script or the terminal failed silently.
964
+ else if (note.seenActive !== true && Date.now() - note.at > 8000) state.elevateNote = null
965
+ } else if (Date.now() - note.at > 12000) {
966
+ state.elevateNote = null
967
+ }
968
+ note = state.elevateNote
969
+ if (!note) { box.hidden = true; box.innerHTML = ''; return }
970
+ box.hidden = false
971
+ box.innerHTML = banner(note.kind, note.text)
972
+ }
973
+
974
+ function renderHealth(health) {
975
+ var pill = el('bridge-health-pill')
976
+ var text = el('bridge-health-text')
977
+ var stop = el('bridge-health-stop')
978
+ var more = el('bridge-health-more')
979
+ var detail = el('bridge-health-detail')
980
+ if (!pill || !text) return
981
+ var engineRunning = health && health.engineRunning === true
982
+ var stray = (health && health.stray) || { linux: false, windows: false }
983
+ var isStray = stray.linux === true || stray.windows === true
984
+ var sides = (health && health.sides) || {}
985
+ var interception = (health && health.interception) || { linux: false, windows: false }
986
+ var names = { linux: 'Linux', windows: 'Windows' }
987
+ stop.hidden = !isStray
988
+ // A request in flight owns its button: the 10 s health poll must not re-enable
989
+ // it, or a second click fires another stop/elevation while the first is still
990
+ // waiting (评审 20261109-2326 客户端 P2).
991
+ stop.disabled = state.stopBusy === true
992
+ var missingNow = ['linux', 'windows'].filter(function (key) {
993
+ return sides[key] && sides[key].applicable !== false && interception[key] !== true
994
+ })
995
+ state.bridgeEngineRunning = engineRunning === true
996
+ state.bridgeStray = isStray
997
+ state.bridgeMissing = missingNow
998
+ paintBridgeFix()
999
+ var lines = []
1000
+ function notes(message) { if (message) lines.push(message) }
1001
+ function planNotes() {
1002
+ var commands = []
1003
+ var lastStart = health && health.lastStart
1004
+ if (lastStart && Array.isArray(lastStart.skipped)) {
1005
+ lastStart.skipped.forEach(function (item) {
1006
+ if (item && typeof item.command === 'string' && item.command !== '') commands.push(item.command)
1007
+ })
1008
+ }
1009
+ var degrade = health && health.degrade
1010
+ var missing = ['linux', 'windows'].filter(function (key) {
1011
+ return sides[key] && sides[key].applicable !== false && interception[key] !== true
1012
+ })
1013
+ if (missing.length === 0) return
1014
+ var command = commands[0] || (degrade && degrade.command)
1015
+ if (command) notes(missing.map(function (key) { return names[key] }).join('、') + ' 侧系统层拦截需要 root:点「启动系统层拦截」弹终端输密码,或自行打开终端执行:' + command)
1016
+ if (degrade && degrade.jvmArgs) {
1017
+ notes('降级可用(不经系统层拦截):')
1018
+ notes(' JVM 程序:' + degrade.jvmArgs.join(' '))
1019
+ notes(' 环境变量:ALL_PROXY=' + degrade.httpProxyUrl + ' HTTP_PROXY=' + degrade.httpProxyUrl + ' HTTPS_PROXY=' + degrade.httpProxyUrl)
1020
+ if (degrade.git && degrade.git.host) {
1021
+ notes(' git:已写入 ' + degrade.git.key + ' = ' + degrade.git.value + '(git config --global --get-regexp proxy 可查)')
1022
+ } else if (degrade.socksUrl) {
1023
+ notes(' git:也可执行 git config --global http.<仓库主机>.proxy ' + degrade.socksUrl)
1024
+ }
1025
+ notes(' ' + degrade.note)
1026
+ }
1027
+ }
1028
+ var shortText = ''
1029
+ if (isStray) {
1030
+ pill.className = 'pill err'
1031
+ pill.textContent = '组件不应运行'
1032
+ shortText = '代理引擎已停止,系统层拦截仍在运行'
1033
+ notes('连接会被转发到已关闭的端口;daemon 正在停止它,也可点右侧「停止拦截」。')
1034
+ } else if (!engineRunning) {
1035
+ pill.className = 'pill off'
1036
+ pill.textContent = '代理引擎未启动'
1037
+ shortText = ''
1038
+ } else if (health && health.ok !== true) {
1039
+ var broken = ['linux', 'windows'].filter(function (key) {
1040
+ return sides[key] && sides[key].applicable !== false && sides[key].ok !== true
1041
+ })
1042
+ pill.className = 'pill err'
1043
+ pill.textContent = '组件异常'
1044
+ shortText = broken.length === 0 ? '组件不完整或无法启动' : broken.map(function (key) { return names[key] }).join('、') + ' 侧组件不可用'
1045
+ broken.forEach(function (key) { notes(names[key] + ':' + (sides[key].error || '组件不完整或无法启动')) })
1046
+ } else if (interception.linux !== true && interception.windows !== true) {
1047
+ pill.className = 'pill warn'
1048
+ pill.textContent = '拦截未启动'
1049
+ var idle = ['linux', 'windows'].filter(function (key) {
1050
+ return sides[key] && sides[key].applicable !== false && interception[key] !== true
1051
+ })
1052
+ shortText = idle.length === 0 ? '正在拉起组件' : idle.map(function (key) { return names[key] }).join('、') + ' 侧未运行 · 已降级'
1053
+ planNotes()
1054
+ } else {
1055
+ pill.className = 'pill on'
1056
+ pill.textContent = '拦截运行中'
1057
+ var runningNames = ['linux', 'windows'].filter(function (key) { return interception[key] === true })
1058
+ var idleSides = ['linux', 'windows'].filter(function (key) {
1059
+ return sides[key] && sides[key].applicable !== false && interception[key] !== true
1060
+ })
1061
+ shortText = runningNames.map(function (key) { return names[key] }).join('、') + ' 侧正在拦截'
1062
+ + (idleSides.length === 0 ? '' : '(' + idleSides.map(function (key) { return names[key] }).join('、') + ' 侧未运行 · 已降级)')
1063
+ planNotes()
1064
+ }
1065
+ text.textContent = shortText
1066
+ if (more && detail) {
1067
+ detail.textContent = lines.join('\\n')
1068
+ more.hidden = lines.length === 0
1069
+ }
1070
+ renderElevateNote(health)
1071
+ }
1072
+ /**
1073
+ * The component card owns ONE recovery button (m13910). After a failed reload the
1074
+ * old design showed 「重启系统层拦截」 next to 「提权启动」, but revoke() had already
1075
+ * stopped the bridge, so both did stop+start and both asked for the same password:
1076
+ * two buttons for one action. Visibility is exclusive now — the stale reload wins
1077
+ * (it needs the stop first), otherwise a missing side means 「启动」.
1078
+ */
1079
+ function paintBridgeFix() {
1080
+ var button = el('bridge-fix')
1081
+ if (!button) return
1082
+ var missing = state.bridgeMissing || []
1083
+ var stale = state.bridgeStaleReason !== ''
1084
+ var show = state.bridgeEngineRunning === true && state.bridgeStray !== true && (stale || missing.length > 0)
1085
+ button.hidden = !show
1086
+ button.disabled = state.fixBusy === true
1087
+ if (state.fixBusy === true) { button.textContent = stale ? '重启中…' : '启动中…'; return }
1088
+ button.textContent = stale ? '重启系统层拦截(可能提权)' : '启动系统层拦截(可能提权)'
1089
+ button.title = stale
1090
+ ? '为什么要重启:' + state.bridgeStaleReason + '(点一下会停止系统层拦截并按当前规则表重新启动;Windows 会弹一次 UAC,本侧可能需要 sudo)'
1091
+ : missing.map(function (key) { return key === 'linux' ? 'Linux' : 'Windows' }).join('、') +
1092
+ ' 侧系统层拦截未启动(点一下会尝试提权启动;Windows 会弹一次 UAC,本侧可能需要 sudo)'
1093
+ }
1094
+
1095
+ // m12606: ask for elevation from the page. sudo is tried first (passwordless),
1096
+ // then pkexec (a real polkit dialog where the desktop has an agent); when neither
1097
+ // can, the banner names the command from 说明 so it can be pasted into a terminal.
1098
+ function fixBridge() {
1099
+ var button = el('bridge-fix')
1100
+ if (state.fixBusy === true) return
1101
+ state.fixBusy = true
1102
+ // A stale reload must stop the old profile before starting the new one; a
1103
+ // purely missing side is enough with a plain start. Only this click sets interactive.
1104
+ var action = state.bridgeStaleReason !== '' ? 'redirector-restart' : 'start'
1105
+ paintBridgeFix()
1106
+ var outcome = { kind: 'warn', text: '' }
1107
+ api('/v1/action', { method: 'POST', body: { action: action, cwd: state.cwd, interactive: true } }).then(function (response) {
1108
+ // /v1/action answers {ok, action, result}; the payload is one level down for
1109
+ // the start action, while redirector-restart answers {stopped,started,skipped}.
1110
+ var result = (response && response.result) || {};
1111
+ var redirector = result.redirector || result;
1112
+ var started = Array.isArray(redirector.started) ? redirector.started : [];
1113
+ var skipped = Array.isArray(redirector.skipped) ? redirector.skipped : [];
1114
+ if (started.length > 0) {
1115
+ outcome = {
1116
+ kind: 'ok',
1117
+ text: '系统层拦截已启动' + (started[0].method === 'pkexec' ? '(经提权窗口)' : ''),
1118
+ side: started[0].side === 'local' ? 'linux' : (started[0].side || ''),
1119
+ }
1120
+ return
1121
+ }
1122
+ // Report the side we were trying to bring up, not a "already running" note
1123
+ // from the side that needed nothing (m12606).
1124
+ var wanted = skipped.filter(function (entry) {
1125
+ return entry && typeof entry.reason === 'string' && entry.reason.indexOf('已在运行') !== 0
1126
+ })
1127
+ var choice = wanted.length > 0 ? wanted[0] : null
1128
+ outcome = {
1129
+ kind: choice !== null && choice.method === 'terminal' ? 'ok' : 'warn',
1130
+ text: choice !== null && typeof choice.reason === 'string'
1131
+ ? choice.reason
1132
+ : '提权没有完成:把「说明」里的命令粘到终端执行,或给 sudo 配置免密',
1133
+ side: choice !== null && choice.side === 'local' ? 'linux' : (choice !== null ? (choice.side || '') : ''),
1134
+ terminal: choice !== null && choice.method === 'terminal',
1135
+ }
1136
+ }).catch(function (error) {
1137
+ outcome = { kind: 'err', text: '提权启动失败:' + error.message }
1138
+ }).then(function () {
1139
+ state.fixBusy = false
1140
+ if (outcome.kind === 'ok') state.bridgeStaleReason = ''
1141
+ paintBridgeFix()
1142
+ // The note belongs to the component card, not the rule-table banner (m12923):
1143
+ // a terminal may still be waiting for a password, so the message has to live
1144
+ // next to the component it is about.
1145
+ state.elevateNote = {
1146
+ kind: outcome.kind,
1147
+ text: outcome.text,
1148
+ side: outcome.side || '',
1149
+ at: Date.now(),
1150
+ // A terminal note stays until the helper script removes its state file.
1151
+ terminal: outcome.terminal === true,
1152
+ seenActive: false,
1153
+ }
1154
+ renderElevateNote()
1155
+ Promise.resolve(loadProxyTab())
1156
+ void loadHealth(true)
1157
+ })
1158
+ renderElevateNote()
1159
+ }
1160
+
1161
+ function loadHealth(force) {
1162
+ return api('/v1/proxybridge/health' + (force === true ? '?force=1' : ''))
1163
+ .then(function (health) { renderHealth(health); return health; })
1164
+ .catch(function (error) {
1165
+ var pill = el('bridge-health-pill');
1166
+ if (pill) { pill.className = 'pill warn'; pill.textContent = '检查失败'; }
1167
+ var text = el('bridge-health-text');
1168
+ if (text) text.textContent = error.message;
1169
+ });
1170
+ }
1171
+ function stopStrayBridge() {
1172
+ var stop = el('bridge-health-stop');
1173
+ if (state.stopBusy === true) return;
1174
+ state.stopBusy = true;
1175
+ if (stop) { stop.disabled = true; stop.textContent = '停止中…'; }
1176
+ // api() stringifies body itself; passing a pre-stringified value made the
1177
+ // daemon answer 400, and banner() only RETURNS markup (it is not a setter),
1178
+ // so the failure was silent — the stray-interception self-rescue button did
1179
+ // nothing at all (review C P1-1).
1180
+ api('/v1/action', { method: 'POST', body: { action: 'stop', cwd: state.cwd } })
1181
+ .then(function (response) {
1182
+ var result = (response && response.result) || {}
1183
+ var redirector = result.redirector || {}
1184
+ if (redirector.stopped === false) {
1185
+ var text = el('bridge-health-text')
1186
+ if (text) {
1187
+ text.textContent = '停止拦截未完成:' + (redirector.reason || '未知原因') +
1188
+ (redirector.command ? ';请执行:' + redirector.command : '')
1189
+ }
1190
+ }
1191
+ return loadHealth(true)
1192
+ })
1193
+ .then(function () { return loadProxyTab(); })
1194
+ .catch(function (error) {
1195
+ var text = el('bridge-health-text');
1196
+ if (text) text.textContent = '停止拦截失败:' + error.message;
1197
+ })
1198
+ .finally(function () { state.stopBusy = false; if (stop) { stop.disabled = false; stop.textContent = '停止拦截'; } });
1199
+ }
913
1200
  function loadBundle() {
914
1201
  return api('/v1/proxybridge').then(function (status) {
915
1202
  renderBundle(status);
916
1203
  if (status.downloading === true) startBundlePoll();
1204
+ void loadHealth(false);
917
1205
  return status;
918
1206
  }).catch(function (error) { el('bridge-hint').textContent = error.message; });
919
1207
  }
@@ -1042,14 +1330,25 @@ export function risdUiHtml(options) {
1042
1330
  var parts = String(cwd || '').split('/').filter(Boolean);
1043
1331
  return parts.length > 0 ? parts[parts.length - 1] : String(cwd || '');
1044
1332
  }
1045
- /** A short, stable label: the folder name, with the parent when two collide. */
1046
- function workspaceLabel(cwd, windows) {
1333
+ /** Folder-name label (parent folder when two collide) — the fallback for a host
1334
+ * that has no workspace registry to give us the sidebar title. */
1335
+ function workspacePathLabel(cwd, windows) {
1047
1336
  var base = workspaceBase(cwd);
1048
1337
  var same = windows.filter(function (win) { return workspaceBase(win.cwd) === base; }).length;
1049
1338
  if (same <= 1) return base || '(未知工作区)';
1050
1339
  var parts = String(cwd || '').split('/').filter(Boolean);
1051
1340
  return parts.slice(-2).join('/');
1052
1341
  }
1342
+ /**
1343
+ * The dsh sidebar's label, when the plugin could resolve one (m13800): a rename
1344
+ * changes the title and nothing else, so the panel must re-label the SAME row.
1345
+ * Missing title (older host) falls back to the folder name.
1346
+ */
1347
+ function workspaceLabel(win, windows) {
1348
+ var title = typeof win.title === 'string' ? win.title : '';
1349
+ if (title !== '') return title;
1350
+ return workspacePathLabel(win.cwd, windows);
1351
+ }
1053
1352
 
1054
1353
  function focusIdeFrame() {
1055
1354
  var frame = el('ide-frame');
@@ -1112,10 +1411,13 @@ export function risdUiHtml(options) {
1112
1411
  function renderIde(windows, current) {
1113
1412
  var selected = current || windows[0];
1114
1413
  el('ide-ws-list').innerHTML = windows.map(function (win) {
1115
- var label = workspaceLabel(win.cwd, windows);
1414
+ var label = workspaceLabel(win, windows);
1116
1415
  // Non-live entries stay clickable: dsh may still have the session, the iframe
1117
1416
  // shows the real result (m08268).
1118
- var suffix = win.live === false ? '(未活跃)' : '';
1417
+ // Two different hints: "未活跃" is a remembered window nobody touched for a
1418
+ // while, "无会话" is a workspace with no live dsh session at all. Both stay
1419
+ // clickable — the window page boots on the cwd when the session is gone (m00186).
1420
+ var suffix = win.live === false ? '(未活跃)' : (win.active === false ? '(无会话)' : '');
1119
1421
  return '<li><button type="button" data-cwd="' + esc(win.cwd || '') + '" title="' + esc((win.cwd || '') + (suffix ? ' ' + suffix : '')) + '">' +
1120
1422
  esc(label + suffix) + '</button></li>';
1121
1423
  }).join('');
@@ -1142,8 +1444,11 @@ export function risdUiHtml(options) {
1142
1444
  el('ide-ws-list').innerHTML = '';
1143
1445
  var frame = el('ide-frame');
1144
1446
  if (frame) frame.hidden = true;
1145
- ideMessage('warn', 'IDE 不可用:' + (body.reason || 'dsh 未运行'),
1146
- 'IDE 界面由 dsh 提供;启动 dsh 并打开一次 RIS-IDE 面板后,这里会自动可用。');
1447
+ var note = 'IDE 界面由 dsh 提供;启动 dsh(工作区在 dsh 侧栏里)后,这里会自动可用。';
1448
+ // dsh may be alive and yet unreachable (still starting, no origin yet): naming the
1449
+ // workspaces it did report separates that from "dsh is not running" (m00186).
1450
+ if (body.knownWorkspaces > 0) note += '(已发现 ' + body.knownWorkspaces + ' 个 dsh 工作区)';
1451
+ ideMessage('warn', 'IDE 不可用:' + (body.reason || 'dsh 未运行'), note);
1147
1452
  applySide();
1148
1453
  }
1149
1454
 
@@ -1195,8 +1500,12 @@ export function risdUiHtml(options) {
1195
1500
  function dshWindowSignature(body) {
1196
1501
  // Liveness is part of the rendering state: a window going 未活跃 must repaint
1197
1502
  // the hint bar even though cwd/sessionId did not change.
1503
+ // The title belongs to the signature: a rename must repaint the labels even
1504
+ // though cwd and sessionId did not move (m13800).
1198
1505
  return (body.windows || []).map(function (win) {
1199
- return (win.cwd || '') + '|' + (win.sessionId || '') + '|' + (win.live === false ? 'stale' : 'live');
1506
+ return (win.cwd || '') + '|' + (win.sessionId || '') + '|' + (win.live === false ? 'stale' : 'live') +
1507
+ '|' + (typeof win.title === 'string' ? win.title : '') +
1508
+ '|' + (win.active === false ? 'idle' : 'active');
1200
1509
  }).sort().join('\\n');
1201
1510
  }
1202
1511
 
@@ -1256,6 +1565,7 @@ export function risdUiHtml(options) {
1256
1565
  syncLogTimer();
1257
1566
  // Same lifecycle for the reachability chip: never probe while another tab shows.
1258
1567
  syncPingTimer();
1568
+ syncHealthTimer();
1259
1569
  // The header toggle only applies to the IDE pane: disable it (with its title
1260
1570
  // explaining why) while another tab is showing.
1261
1571
  applySide();
@@ -1343,17 +1653,35 @@ export function risdUiHtml(options) {
1343
1653
  engineBusy = true;
1344
1654
  engineBusyAction = action;
1345
1655
  paintEngineButtons();
1346
- api('/v1/action', { method: 'POST', body: { action: action, cwd: state.cwd } })
1656
+ // A click is the one place allowed to ask for elevation (m13910); the
1657
+ // save-triggered auto-start calls the same route without the flag.
1658
+ var body = { action: action, cwd: state.cwd };
1659
+ if (action === 'start') body.interactive = true;
1660
+ api('/v1/action', { method: 'POST', body: body })
1347
1661
  .then(function (response) {
1348
1662
  var result = (response && response.result) || {};
1349
1663
  var redirector = result.redirector || {};
1350
1664
  var skipped = Array.isArray(redirector.skipped) ? redirector.skipped : [];
1351
- if (skipped.length > 0) {
1352
- host.innerHTML = banner('warn', '本机引擎已启动;系统层拦截需要提权:' + skipped.map(function (item) { return item.side + ':' + item.reason; }).join(';'));
1353
- }
1354
1665
  engineBusy = false;
1355
1666
  paintEngineButtons();
1356
- return state.tab === 'proxy' ? loadProxyTab() : refreshOverview();
1667
+ // Write the elevation warning AFTER the refresh: loadProxyTab empties
1668
+ // #proxy-banner, so a message written before it vanished in the same frame
1669
+ // (评审 20261109-2326 客户端 P2).
1670
+ // A stop that the OS refused (root-owned CLI) or that lost a race with
1671
+ // an in-flight start must not look like a clean stop (review B-P1-2/B-P1-5).
1672
+ var stopBlocked = action === 'stop' && redirector.stopped === false
1673
+ var warn = stopBlocked
1674
+ ? '系统层拦截未完全停止:' + (redirector.reason || '未知原因') +
1675
+ (redirector.command ? ';请执行:' + redirector.command : '')
1676
+ : skipped.length > 0
1677
+ ? '本机引擎已启动;系统层拦截需要提权:' + skipped.map(function (item) { return item.side + ':' + item.reason; }).join(';')
1678
+ : '';
1679
+ return (state.tab === 'proxy'
1680
+ ? loadProxyTab().then(function () { return loadHealth(true); })
1681
+ : refreshOverview().then(function () { return loadHealth(true); })
1682
+ ).then(function () {
1683
+ if (warn !== '') host.innerHTML = banner('warn', warn);
1684
+ });
1357
1685
  })
1358
1686
  .catch(function (error) {
1359
1687
  engineBusy = false;
@@ -1364,10 +1692,11 @@ export function risdUiHtml(options) {
1364
1692
  }
1365
1693
  el('engine-toggle').onclick = toggleProxyEngine;
1366
1694
  el('proxy-engine-toggle').onclick = toggleProxyEngine;
1367
- el('lifecycle-save').onclick = saveLifecycle;
1695
+ el('bridge-health-stop').onclick = stopStrayBridge;
1696
+ el('bridge-fix').onclick = fixBridge;
1368
1697
  // Any toggle means "this form is mine now": the 4 s refresh stops refilling it
1369
- // until the save succeeds (review C-P2-3).
1370
- el('lifecycle-rows').addEventListener('change', function () { state.lifecycleDirty = true; });
1698
+ // until the save succeeds (review C-P2-3). Toggling is the save (m13960).
1699
+ el('lifecycle-rows').addEventListener('change', scheduleLifecycleSave);
1371
1700
 
1372
1701
  // Re-probe while the user edits host/port: 800 ms after the last keystroke, and
1373
1702
  // only on the proxy tab (the inputs are hidden elsewhere).
@@ -1394,21 +1723,6 @@ export function risdUiHtml(options) {
1394
1723
  renderProxyTab(Object.assign({}, state.view || {}, { rules: rules }));
1395
1724
  scheduleProxySave();
1396
1725
  };
1397
- el('bridge-restart').onclick = function () {
1398
- api('/v1/action', { method: 'POST', body: { action: 'redirector-restart', cwd: state.cwd } })
1399
- .then(function (response) {
1400
- // The action result lives under result: reading response.started always
1401
- // found nothing and reported "需要提权" even after a successful restart
1402
- // (review C-P1-3).
1403
- var result = (response && response.result) || {};
1404
- var skipped = Array.isArray(result.skipped) ? result.skipped : [];
1405
- var started = Array.isArray(result.started) ? result.started : [];
1406
- var text = started.length > 0
1407
- ? '已按新规则重启(' + started.join(',') + ')'
1408
- : '需要提权:' + JSON.stringify(skipped.length > 0 ? skipped : (result.stopped || {}));
1409
- el('proxy-banner').innerHTML = banner(started.length > 0 ? 'ok' : 'warn', text);
1410
- }).catch(function (error) { el('proxy-banner').innerHTML = banner('err', error.message); });
1411
- };
1412
1726
  el('bridge-download').onclick = downloadBundle;
1413
1727
  el('bridge-upload').onclick = function () { el('bridge-file').click(); };
1414
1728
  el('bridge-file').onchange = function (event) {
@@ -1488,7 +1802,7 @@ export function risdUiHtml(options) {
1488
1802
  applySide();
1489
1803
  // Coming back to the tab must resume the log tail immediately, and hiding the
1490
1804
  // page must stop it (review C-P2-3).
1491
- document.addEventListener('visibilitychange', function () { syncLogTimer(); syncPingTimer(); });
1805
+ document.addEventListener('visibilitychange', function () { syncLogTimer(); syncPingTimer(); syncHealthTimer(); });
1492
1806
 
1493
1807
  // ---- 页面代码漂移 / 令牌漂移(m09693、review C3-P1-3)----
1494
1808
  // 以前 loaded 变化直接 location.reload():代理规则表正在编辑时刷新会丢失输入,
@@ -1588,6 +1902,12 @@ export function risdUiHtml(options) {
1588
1902
  button.textContent = '保存所有文件';
1589
1903
  }
1590
1904
  function driftSaveThenReload() {
1905
+ // The drift bar reloads on behalf of a newer bundle: it needs the same
1906
+ // unsaved-work checks as the ordinary refresh button, otherwise the rule table
1907
+ // or the lifecycle checkboxes are silently thrown away (评审 20261109-2326
1908
+ // 客户端 P2).
1909
+ if (state.proxyDirty === true && window.confirm('代理规则还没保存,刷新会丢失') !== true) return
1910
+ if (state.lifecycleDirty === true && window.confirm('生命周期设置还没保存,刷新会丢失') !== true) return
1591
1911
  var button = el('ui-drift-save');
1592
1912
  if (button) { button.disabled = true; button.textContent = '保存中…'; }
1593
1913
  askIdeSaveAll().then(function (saved) {
@@ -1630,6 +1950,7 @@ export function risdUiHtml(options) {
1630
1950
  }
1631
1951
  function restartDaemonThenReload() {
1632
1952
  if (state.proxyDirty === true && window.confirm('代理规则还没保存,重启并刷新会丢失') !== true) return;
1953
+ if (state.lifecycleDirty === true && window.confirm('生命周期设置还没保存,重启并刷新会丢失') !== true) return;
1633
1954
  askIdeDirty().then(function (count) {
1634
1955
  if (count === 0) { restartDaemon(); return; }
1635
1956
  setDriftSave(count);