dsh-ris-ide 1.8.0 → 1.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/bin/risd.mjs +14 -17
- package/lib/client.js +94 -26
- package/lib/proxybridge-bundle.js +1 -1
- package/lib/proxybridge-health.js +206 -0
- package/lib/redirector.js +1139 -88
- package/lib/risd/server.js +456 -15
- package/lib/risd/ui.js +291 -7
- package/package.json +1 -1
- package/test/client-viewer.test.mjs +114 -28
- package/test/proxy-restart.test.mjs +3 -1
- package/test/proxybridge-health.test.mjs +116 -0
- package/test/redirector.test.mjs +354 -1
- package/test/risd-api.test.mjs +47 -3
- package/test/risd-restart.test.mjs +104 -0
- package/test/risd-ui.test.mjs +163 -1
package/lib/risd/ui.js
CHANGED
|
@@ -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; }
|
|
@@ -228,6 +231,17 @@ 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-health-elevate" 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>
|
|
@@ -247,7 +261,7 @@ export function risdUiHtml(options) {
|
|
|
247
261
|
<div id="proxy-banner"></div>
|
|
248
262
|
<table>
|
|
249
263
|
<thead>
|
|
250
|
-
<tr><th style="width:56px">启用</th><th style="width:170px"
|
|
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>
|
|
@@ -299,7 +313,7 @@ export function risdUiHtml(options) {
|
|
|
299
313
|
var PAGE_INSTANCE = ${uiInstance};
|
|
300
314
|
var initialCwd = '';
|
|
301
315
|
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: {},
|
|
316
|
+
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, elevateBusy: false, summary: { proxyRunning: false, programs: 0, debugs: 0 }, staleDismissed: {},
|
|
303
317
|
};
|
|
304
318
|
// The drift banner's current message and the message the user closed: a closed
|
|
305
319
|
// hint must not pop back every 5 s, but a NEW kind of drift still has to warn.
|
|
@@ -837,6 +851,20 @@ export function risdUiHtml(options) {
|
|
|
837
851
|
el('proxy-log-toggle').textContent = state.logOn ? '停止日志' : '代理日志';
|
|
838
852
|
syncLogTimer();
|
|
839
853
|
}
|
|
854
|
+
// m12313: the component card is timer-driven — no manual re-check. Two caches sit
|
|
855
|
+
// behind the route: the component snapshot (file + version probes) for 30 s, and
|
|
856
|
+
// the interception status for 5 s — so a 10 s poll re-detects the bridge each
|
|
857
|
+
// tick but does not probe the component files every time (评审 20261109-2326
|
|
858
|
+
// 客户端 P2).
|
|
859
|
+
function syncHealthTimer() {
|
|
860
|
+
var wanted = state.tab === 'proxy' && document.hidden !== true
|
|
861
|
+
if (wanted && state.healthTimer === null) {
|
|
862
|
+
state.healthTimer = setInterval(function () { void loadHealth(false) }, 10000)
|
|
863
|
+
} else if (!wanted && state.healthTimer !== null) {
|
|
864
|
+
clearInterval(state.healthTimer)
|
|
865
|
+
state.healthTimer = null
|
|
866
|
+
}
|
|
867
|
+
}
|
|
840
868
|
// The tail costs up to 40 KB every 2 s: poll only while the pane is actually on
|
|
841
869
|
// screen (proxy tab, page visible) and pause on a hidden tab instead of keeping
|
|
842
870
|
// the timer alive off-screen (review C-P2-3).
|
|
@@ -910,10 +938,242 @@ export function risdUiHtml(options) {
|
|
|
910
938
|
hint.textContent = lines.join('\\n');
|
|
911
939
|
hint.style.whiteSpace = 'pre-line';
|
|
912
940
|
}
|
|
941
|
+
// m12313/m12508: one short line at a glance; the long explanation (sudo command,
|
|
942
|
+
// degraded JVM/env plan) lives in a collapsed <details> under it.
|
|
943
|
+
// m12923: the elevation note is card-owned. A terminal note lives until the helper
|
|
944
|
+
// script removes its state file (or the side starts intercepting); other outcomes
|
|
945
|
+
// fade out on their own, so the card never keeps a stale sentence.
|
|
946
|
+
function renderElevateNote(health) {
|
|
947
|
+
var box = el('bridge-elevate-note')
|
|
948
|
+
if (!box) return
|
|
949
|
+
var note = state.elevateNote
|
|
950
|
+
if (!note) { box.hidden = true; box.innerHTML = ''; return }
|
|
951
|
+
var interception = (health && health.interception) || {}
|
|
952
|
+
var elevations = (health && health.elevations) || {}
|
|
953
|
+
var side = note.side
|
|
954
|
+
var active = !!(side && elevations[side] && elevations[side].active === true)
|
|
955
|
+
if (active) note.seenActive = true
|
|
956
|
+
if (side && interception[side] === true) {
|
|
957
|
+
state.elevateNote = null
|
|
958
|
+
} else if (note.terminal === true) {
|
|
959
|
+
// Seen open once and now gone = the window closed after the password.
|
|
960
|
+
if (note.seenActive === true && active === false) state.elevateNote = null
|
|
961
|
+
// Never seen open within 8 s: the script or the terminal failed silently.
|
|
962
|
+
else if (note.seenActive !== true && Date.now() - note.at > 8000) state.elevateNote = null
|
|
963
|
+
} else if (Date.now() - note.at > 12000) {
|
|
964
|
+
state.elevateNote = null
|
|
965
|
+
}
|
|
966
|
+
note = state.elevateNote
|
|
967
|
+
if (!note) { box.hidden = true; box.innerHTML = ''; return }
|
|
968
|
+
box.hidden = false
|
|
969
|
+
box.innerHTML = banner(note.kind, note.text)
|
|
970
|
+
}
|
|
971
|
+
|
|
972
|
+
function renderHealth(health) {
|
|
973
|
+
var pill = el('bridge-health-pill')
|
|
974
|
+
var text = el('bridge-health-text')
|
|
975
|
+
var stop = el('bridge-health-stop')
|
|
976
|
+
var more = el('bridge-health-more')
|
|
977
|
+
var detail = el('bridge-health-detail')
|
|
978
|
+
if (!pill || !text) return
|
|
979
|
+
var engineRunning = health && health.engineRunning === true
|
|
980
|
+
var stray = (health && health.stray) || { linux: false, windows: false }
|
|
981
|
+
var isStray = stray.linux === true || stray.windows === true
|
|
982
|
+
var sides = (health && health.sides) || {}
|
|
983
|
+
var interception = (health && health.interception) || { linux: false, windows: false }
|
|
984
|
+
var names = { linux: 'Linux', windows: 'Windows' }
|
|
985
|
+
var elevate = el('bridge-health-elevate')
|
|
986
|
+
stop.hidden = !isStray
|
|
987
|
+
// A request in flight owns its button: the 10 s health poll must not re-enable
|
|
988
|
+
// it, or a second click fires another stop/elevation while the first is still
|
|
989
|
+
// waiting (评审 20261109-2326 客户端 P2).
|
|
990
|
+
stop.disabled = state.stopBusy === true
|
|
991
|
+
var missingNow = ['linux', 'windows'].filter(function (key) {
|
|
992
|
+
return sides[key] && sides[key].applicable !== false && interception[key] !== true
|
|
993
|
+
})
|
|
994
|
+
if (elevate) {
|
|
995
|
+
elevate.hidden = !(engineRunning === true && isStray !== true && missingNow.length > 0)
|
|
996
|
+
elevate.disabled = state.elevateBusy === true
|
|
997
|
+
if (state.elevateBusy !== true) elevate.textContent = '提权启动'
|
|
998
|
+
}
|
|
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
|
+
// m12606: ask for elevation from the page. sudo is tried first (passwordless),
|
|
1073
|
+
// then pkexec (a real polkit dialog where the desktop has an agent); when neither
|
|
1074
|
+
// can, the banner names the command from 说明 so it can be pasted into a terminal.
|
|
1075
|
+
function elevateBridge() {
|
|
1076
|
+
var button = el('bridge-health-elevate')
|
|
1077
|
+
if (state.elevateBusy === true) return
|
|
1078
|
+
state.elevateBusy = true
|
|
1079
|
+
if (button) { button.disabled = true; button.textContent = '提权中…' }
|
|
1080
|
+
var outcome = { kind: 'warn', text: '' }
|
|
1081
|
+
api('/v1/action', { method: 'POST', body: { action: 'start', cwd: state.cwd } }).then(function (response) {
|
|
1082
|
+
// /v1/action answers {ok, action, result}; the payload is one level down.
|
|
1083
|
+
var result = (response && response.result) || {};
|
|
1084
|
+
var redirector = result.redirector || {};
|
|
1085
|
+
var started = Array.isArray(redirector.started) ? redirector.started : [];
|
|
1086
|
+
var skipped = Array.isArray(redirector.skipped) ? redirector.skipped : [];
|
|
1087
|
+
if (started.length > 0) {
|
|
1088
|
+
outcome = {
|
|
1089
|
+
kind: 'ok',
|
|
1090
|
+
text: '系统层拦截已启动' + (started[0].method === 'pkexec' ? '(经提权窗口)' : ''),
|
|
1091
|
+
side: started[0].side === 'local' ? 'linux' : (started[0].side || ''),
|
|
1092
|
+
}
|
|
1093
|
+
return
|
|
1094
|
+
}
|
|
1095
|
+
// Report the side we were trying to bring up, not a "already running" note
|
|
1096
|
+
// from the side that needed nothing (m12606).
|
|
1097
|
+
var wanted = skipped.filter(function (entry) {
|
|
1098
|
+
return entry && typeof entry.reason === 'string' && entry.reason.indexOf('已在运行') !== 0
|
|
1099
|
+
})
|
|
1100
|
+
var choice = wanted.length > 0 ? wanted[0] : null
|
|
1101
|
+
outcome = {
|
|
1102
|
+
kind: choice !== null && choice.method === 'terminal' ? 'ok' : 'warn',
|
|
1103
|
+
text: choice !== null && typeof choice.reason === 'string'
|
|
1104
|
+
? choice.reason
|
|
1105
|
+
: '提权没有完成:把「说明」里的命令粘到终端执行,或给 sudo 配置免密',
|
|
1106
|
+
side: choice !== null && choice.side === 'local' ? 'linux' : (choice !== null ? (choice.side || '') : ''),
|
|
1107
|
+
terminal: choice !== null && choice.method === 'terminal',
|
|
1108
|
+
}
|
|
1109
|
+
}).catch(function (error) {
|
|
1110
|
+
outcome = { kind: 'err', text: '提权启动失败:' + error.message }
|
|
1111
|
+
}).then(function () {
|
|
1112
|
+
state.elevateBusy = false
|
|
1113
|
+
if (button) { button.disabled = false; button.textContent = '提权启动' }
|
|
1114
|
+
// The note belongs to the component card, not the rule-table banner (m12923):
|
|
1115
|
+
// a terminal may still be waiting for a password, so the message has to live
|
|
1116
|
+
// next to the component it is about.
|
|
1117
|
+
state.elevateNote = {
|
|
1118
|
+
kind: outcome.kind,
|
|
1119
|
+
text: outcome.text,
|
|
1120
|
+
side: outcome.side || '',
|
|
1121
|
+
at: Date.now(),
|
|
1122
|
+
// A terminal note stays until the helper script removes its state file.
|
|
1123
|
+
terminal: outcome.terminal === true,
|
|
1124
|
+
seenActive: false,
|
|
1125
|
+
}
|
|
1126
|
+
renderElevateNote()
|
|
1127
|
+
Promise.resolve(loadProxyTab())
|
|
1128
|
+
void loadHealth(true)
|
|
1129
|
+
})
|
|
1130
|
+
renderElevateNote()
|
|
1131
|
+
}
|
|
1132
|
+
|
|
1133
|
+
function loadHealth(force) {
|
|
1134
|
+
return api('/v1/proxybridge/health' + (force === true ? '?force=1' : ''))
|
|
1135
|
+
.then(function (health) { renderHealth(health); return health; })
|
|
1136
|
+
.catch(function (error) {
|
|
1137
|
+
var pill = el('bridge-health-pill');
|
|
1138
|
+
if (pill) { pill.className = 'pill warn'; pill.textContent = '检查失败'; }
|
|
1139
|
+
var text = el('bridge-health-text');
|
|
1140
|
+
if (text) text.textContent = error.message;
|
|
1141
|
+
});
|
|
1142
|
+
}
|
|
1143
|
+
function stopStrayBridge() {
|
|
1144
|
+
var stop = el('bridge-health-stop');
|
|
1145
|
+
if (state.stopBusy === true) return;
|
|
1146
|
+
state.stopBusy = true;
|
|
1147
|
+
if (stop) { stop.disabled = true; stop.textContent = '停止中…'; }
|
|
1148
|
+
// api() stringifies body itself; passing a pre-stringified value made the
|
|
1149
|
+
// daemon answer 400, and banner() only RETURNS markup (it is not a setter),
|
|
1150
|
+
// so the failure was silent — the stray-interception self-rescue button did
|
|
1151
|
+
// nothing at all (review C P1-1).
|
|
1152
|
+
api('/v1/action', { method: 'POST', body: { action: 'stop', cwd: state.cwd } })
|
|
1153
|
+
.then(function (response) {
|
|
1154
|
+
var result = (response && response.result) || {}
|
|
1155
|
+
var redirector = result.redirector || {}
|
|
1156
|
+
if (redirector.stopped === false) {
|
|
1157
|
+
var text = el('bridge-health-text')
|
|
1158
|
+
if (text) {
|
|
1159
|
+
text.textContent = '停止拦截未完成:' + (redirector.reason || '未知原因') +
|
|
1160
|
+
(redirector.command ? ';请执行:' + redirector.command : '')
|
|
1161
|
+
}
|
|
1162
|
+
}
|
|
1163
|
+
return loadHealth(true)
|
|
1164
|
+
})
|
|
1165
|
+
.then(function () { return loadProxyTab(); })
|
|
1166
|
+
.catch(function (error) {
|
|
1167
|
+
var text = el('bridge-health-text');
|
|
1168
|
+
if (text) text.textContent = '停止拦截失败:' + error.message;
|
|
1169
|
+
})
|
|
1170
|
+
.finally(function () { state.stopBusy = false; if (stop) { stop.disabled = false; stop.textContent = '停止拦截'; } });
|
|
1171
|
+
}
|
|
913
1172
|
function loadBundle() {
|
|
914
1173
|
return api('/v1/proxybridge').then(function (status) {
|
|
915
1174
|
renderBundle(status);
|
|
916
1175
|
if (status.downloading === true) startBundlePoll();
|
|
1176
|
+
void loadHealth(false);
|
|
917
1177
|
return status;
|
|
918
1178
|
}).catch(function (error) { el('bridge-hint').textContent = error.message; });
|
|
919
1179
|
}
|
|
@@ -1256,6 +1516,7 @@ export function risdUiHtml(options) {
|
|
|
1256
1516
|
syncLogTimer();
|
|
1257
1517
|
// Same lifecycle for the reachability chip: never probe while another tab shows.
|
|
1258
1518
|
syncPingTimer();
|
|
1519
|
+
syncHealthTimer();
|
|
1259
1520
|
// The header toggle only applies to the IDE pane: disable it (with its title
|
|
1260
1521
|
// explaining why) while another tab is showing.
|
|
1261
1522
|
applySide();
|
|
@@ -1348,12 +1609,26 @@ export function risdUiHtml(options) {
|
|
|
1348
1609
|
var result = (response && response.result) || {};
|
|
1349
1610
|
var redirector = result.redirector || {};
|
|
1350
1611
|
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
1612
|
engineBusy = false;
|
|
1355
1613
|
paintEngineButtons();
|
|
1356
|
-
|
|
1614
|
+
// Write the elevation warning AFTER the refresh: loadProxyTab empties
|
|
1615
|
+
// #proxy-banner, so a message written before it vanished in the same frame
|
|
1616
|
+
// (评审 20261109-2326 客户端 P2). maybeStartProxy already orders it so.
|
|
1617
|
+
// A stop that the OS refused (root-owned CLI) or that lost a race with
|
|
1618
|
+
// an in-flight start must not look like a clean stop (review B-P1-2/B-P1-5).
|
|
1619
|
+
var stopBlocked = action === 'stop' && redirector.stopped === false
|
|
1620
|
+
var warn = stopBlocked
|
|
1621
|
+
? '系统层拦截未完全停止:' + (redirector.reason || '未知原因') +
|
|
1622
|
+
(redirector.command ? ';请执行:' + redirector.command : '')
|
|
1623
|
+
: skipped.length > 0
|
|
1624
|
+
? '本机引擎已启动;系统层拦截需要提权:' + skipped.map(function (item) { return item.side + ':' + item.reason; }).join(';')
|
|
1625
|
+
: '';
|
|
1626
|
+
return (state.tab === 'proxy'
|
|
1627
|
+
? loadProxyTab().then(function () { return loadHealth(true); })
|
|
1628
|
+
: refreshOverview().then(function () { return loadHealth(true); })
|
|
1629
|
+
).then(function () {
|
|
1630
|
+
if (warn !== '') host.innerHTML = banner('warn', warn);
|
|
1631
|
+
});
|
|
1357
1632
|
})
|
|
1358
1633
|
.catch(function (error) {
|
|
1359
1634
|
engineBusy = false;
|
|
@@ -1364,6 +1639,8 @@ export function risdUiHtml(options) {
|
|
|
1364
1639
|
}
|
|
1365
1640
|
el('engine-toggle').onclick = toggleProxyEngine;
|
|
1366
1641
|
el('proxy-engine-toggle').onclick = toggleProxyEngine;
|
|
1642
|
+
el('bridge-health-stop').onclick = stopStrayBridge;
|
|
1643
|
+
el('bridge-health-elevate').onclick = elevateBridge;
|
|
1367
1644
|
el('lifecycle-save').onclick = saveLifecycle;
|
|
1368
1645
|
// Any toggle means "this form is mine now": the 4 s refresh stops refilling it
|
|
1369
1646
|
// until the save succeeds (review C-P2-3).
|
|
@@ -1488,7 +1765,7 @@ export function risdUiHtml(options) {
|
|
|
1488
1765
|
applySide();
|
|
1489
1766
|
// Coming back to the tab must resume the log tail immediately, and hiding the
|
|
1490
1767
|
// page must stop it (review C-P2-3).
|
|
1491
|
-
document.addEventListener('visibilitychange', function () { syncLogTimer(); syncPingTimer(); });
|
|
1768
|
+
document.addEventListener('visibilitychange', function () { syncLogTimer(); syncPingTimer(); syncHealthTimer(); });
|
|
1492
1769
|
|
|
1493
1770
|
// ---- 页面代码漂移 / 令牌漂移(m09693、review C3-P1-3)----
|
|
1494
1771
|
// 以前 loaded 变化直接 location.reload():代理规则表正在编辑时刷新会丢失输入,
|
|
@@ -1588,6 +1865,12 @@ export function risdUiHtml(options) {
|
|
|
1588
1865
|
button.textContent = '保存所有文件';
|
|
1589
1866
|
}
|
|
1590
1867
|
function driftSaveThenReload() {
|
|
1868
|
+
// The drift bar reloads on behalf of a newer bundle: it needs the same
|
|
1869
|
+
// unsaved-work checks as the ordinary refresh button, otherwise the rule table
|
|
1870
|
+
// or the lifecycle checkboxes are silently thrown away (评审 20261109-2326
|
|
1871
|
+
// 客户端 P2).
|
|
1872
|
+
if (state.proxyDirty === true && window.confirm('代理规则还没保存,刷新会丢失') !== true) return
|
|
1873
|
+
if (state.lifecycleDirty === true && window.confirm('生命周期设置还没保存,刷新会丢失') !== true) return
|
|
1591
1874
|
var button = el('ui-drift-save');
|
|
1592
1875
|
if (button) { button.disabled = true; button.textContent = '保存中…'; }
|
|
1593
1876
|
askIdeSaveAll().then(function (saved) {
|
|
@@ -1630,6 +1913,7 @@ export function risdUiHtml(options) {
|
|
|
1630
1913
|
}
|
|
1631
1914
|
function restartDaemonThenReload() {
|
|
1632
1915
|
if (state.proxyDirty === true && window.confirm('代理规则还没保存,重启并刷新会丢失') !== true) return;
|
|
1916
|
+
if (state.lifecycleDirty === true && window.confirm('生命周期设置还没保存,重启并刷新会丢失') !== true) return;
|
|
1633
1917
|
askIdeDirty().then(function (count) {
|
|
1634
1918
|
if (count === 0) { restartDaemon(); return; }
|
|
1635
1919
|
setDriftSave(count);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-ris-ide",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "RIS-IDE local dev panel for the DSH web GUI: live log tail, one-click start/stop of workspace programs, JDWP debugging, file tree + editor, and a standalone IDE window that carries no session history. · DSH 右侧栏本地开发面板:日志实时跟随、一键启停本地程序、Java 断点调试、文件树与编辑器、独立 IDE 窗口。",
|
|
6
6
|
"keywords": [
|
|
@@ -2699,7 +2699,8 @@ test('the saved layout (maximised + theme + font + sizes) restores on init, even
|
|
|
2699
2699
|
const hadLocalStorage = Object.prototype.hasOwnProperty.call(globalThis, 'localStorage')
|
|
2700
2700
|
const previousLocalStorage = globalThis.localStorage
|
|
2701
2701
|
try {
|
|
2702
|
-
// A
|
|
2702
|
+
// A pre-m13444 blob for THIS tab: the panel used to key the layout without a
|
|
2703
|
+
// workspace suffix, and the first workspace to open the tab migrates it once.
|
|
2703
2704
|
const legacy = JSON.stringify({
|
|
2704
2705
|
ui: { maximized: 'editor', section: 'threads' },
|
|
2705
2706
|
theme: 'light',
|
|
@@ -2708,7 +2709,7 @@ test('the saved layout (maximised + theme + font + sizes) restores on init, even
|
|
|
2708
2709
|
files: [],
|
|
2709
2710
|
file: undefined,
|
|
2710
2711
|
})
|
|
2711
|
-
const store = new Map([['dsh-ris-ide:ui:
|
|
2712
|
+
const store = new Map([['dsh-ris-ide:ui:workspace', legacy]])
|
|
2712
2713
|
globalThis.localStorage = {
|
|
2713
2714
|
get length() { return store.size },
|
|
2714
2715
|
key: (index) => Array.from(store.keys())[index],
|
|
@@ -2727,33 +2728,49 @@ test('the saved layout (maximised + theme + font + sizes) restores on init, even
|
|
|
2727
2728
|
}
|
|
2728
2729
|
})
|
|
2729
2730
|
|
|
2730
|
-
test('readSavedUi prefers the exact key,
|
|
2731
|
+
test('readSavedUi prefers the exact key, migrates the legacy one ONCE, and survives junk', () => {
|
|
2731
2732
|
const hadLocalStorage = Object.prototype.hasOwnProperty.call(globalThis, 'localStorage')
|
|
2732
2733
|
const previousLocalStorage = globalThis.localStorage
|
|
2733
2734
|
try {
|
|
2734
2735
|
const store = new Map([
|
|
2735
|
-
['dsh-ris-ide:ui:workspace', JSON.stringify({ ui: { maximized: null }, font: 13 })],
|
|
2736
|
-
['dsh-ris-ide:ui:
|
|
2736
|
+
['dsh-ris-ide:ui:workspace@/w/a', JSON.stringify({ ui: { maximized: null }, font: 13 })],
|
|
2737
|
+
['dsh-ris-ide:ui:workspace', JSON.stringify({ ui: { maximized: 'tree' }, font: 18 })],
|
|
2737
2738
|
])
|
|
2738
2739
|
globalThis.localStorage = {
|
|
2739
2740
|
get length() { return store.size },
|
|
2740
2741
|
key: (index) => Array.from(store.keys())[index],
|
|
2741
2742
|
getItem: (key) => (store.has(key) ? store.get(key) : null),
|
|
2743
|
+
setItem: (key, value) => { store.set(key, value) },
|
|
2744
|
+
removeItem: (key) => { store.delete(key) },
|
|
2745
|
+
}
|
|
2746
|
+
assert.equal(T.readSavedUi('dsh-ris-ide:ui:workspace@/w/a', '/w/a').font, 13, 'the exact key wins')
|
|
2747
|
+
// The pre-m13444 global key is adopted once by the FIRST workspace and deleted,
|
|
2748
|
+
// so a second workspace does not inherit the same tabs again (C review P1-2).
|
|
2749
|
+
assert.equal(T.readSavedUi('dsh-ris-ide:ui:workspace@/w/b', '/w/b').font, 18, 'the legacy key is adopted')
|
|
2750
|
+
assert.equal(store.has('dsh-ris-ide:ui:workspace'), false, 'and removed after adoption')
|
|
2751
|
+
assert.equal(T.readSavedUi('dsh-ris-ide:ui:workspace@/w/c', '/w/c'), null, 'a second workspace gets nothing')
|
|
2752
|
+
|
|
2753
|
+
// Non-blob preferences share the `…:ui:` prefix; they must not abort the scan.
|
|
2754
|
+
const noisy = new Map([['dsh-ris-ide:ui:compact-max', 'log']])
|
|
2755
|
+
globalThis.localStorage = {
|
|
2756
|
+
get length() { return noisy.size },
|
|
2757
|
+
key: (index) => Array.from(noisy.keys())[index],
|
|
2758
|
+
getItem: (key) => (noisy.has(key) ? noisy.get(key) : null),
|
|
2742
2759
|
setItem: () => {},
|
|
2760
|
+
removeItem: () => {},
|
|
2743
2761
|
}
|
|
2744
|
-
assert.equal(T.readSavedUi('dsh-ris-ide:ui:
|
|
2762
|
+
assert.equal(T.readSavedUi('dsh-ris-ide:ui:nothing', 'nothing'), null, 'junk does not throw')
|
|
2745
2763
|
|
|
2746
|
-
|
|
2764
|
+
// Another workspace's tab is never adopted; a cwd containing `@` cannot spoof it.
|
|
2765
|
+
const other = new Map([['dsh-ris-ide:ui:workspace@/ws/x@/w/a', JSON.stringify({ font: 19 })]])
|
|
2747
2766
|
globalThis.localStorage = {
|
|
2748
|
-
get length() { return
|
|
2749
|
-
key: (index) => Array.from(
|
|
2750
|
-
getItem: (key) => (
|
|
2767
|
+
get length() { return other.size },
|
|
2768
|
+
key: (index) => Array.from(other.keys())[index],
|
|
2769
|
+
getItem: (key) => (other.has(key) ? other.get(key) : null),
|
|
2751
2770
|
setItem: () => {},
|
|
2771
|
+
removeItem: () => {},
|
|
2752
2772
|
}
|
|
2753
|
-
assert.equal(T.readSavedUi('dsh-ris-ide:ui:workspace')
|
|
2754
|
-
|
|
2755
|
-
withoutExact.set('dsh-ris-ide:ui:broken', '{not json')
|
|
2756
|
-
assert.ok(T.readSavedUi('dsh-ris-ide:ui:nothing') !== null, 'junk does not throw')
|
|
2773
|
+
assert.equal(T.readSavedUi('dsh-ris-ide:ui:workspace@/w/b', '/w/b'), null, 'cross-workspace adoption is refused')
|
|
2757
2774
|
} finally {
|
|
2758
2775
|
if (hadLocalStorage) globalThis.localStorage = previousLocalStorage
|
|
2759
2776
|
else globalThis.localStorage = undefined
|
|
@@ -3653,6 +3670,58 @@ test('capOpenFiles appends under the cap and evicts only the oldest clean tab',
|
|
|
3653
3670
|
|
|
3654
3671
|
|
|
3655
3672
|
|
|
3673
|
+
test('tabs, recent history and search cache are scoped to one workspace (m13444)', { skip: !reactIsReal ? 'React unavailable for SSR' : false }, () => {
|
|
3674
|
+
const hadLocalStorage = Object.prototype.hasOwnProperty.call(globalThis, 'localStorage')
|
|
3675
|
+
const previousLocalStorage = globalThis.localStorage
|
|
3676
|
+
try {
|
|
3677
|
+
const keys = []
|
|
3678
|
+
globalThis.localStorage = {
|
|
3679
|
+
getItem: (key) => { keys.push(String(key)); return null },
|
|
3680
|
+
setItem: () => {},
|
|
3681
|
+
}
|
|
3682
|
+
renderWorkbench({ scope: { sessionId: 's1', cwd: '/w/a' }, tab: { id: T.PROGRAM_TAB_ID, type: T.PROGRAM_TAB_ID, title: 'workspace' } })
|
|
3683
|
+
renderWorkbench({ scope: { sessionId: 's1', cwd: '/w/b' }, tab: { id: T.PROGRAM_TAB_ID, type: T.PROGRAM_TAB_ID, title: 'workspace' } })
|
|
3684
|
+
assert.ok(keys.includes('dsh-ris-ide:ui:workspace@/w/a'), `workspace A key missing: ${keys.join(', ')}`)
|
|
3685
|
+
assert.ok(keys.includes('dsh-ris-ide:ui:workspace@/w/b'), `workspace B key missing: ${keys.join(', ')}`)
|
|
3686
|
+
|
|
3687
|
+
// Adopting a legacy blob must stay inside the current workspace.
|
|
3688
|
+
const store = new Map([
|
|
3689
|
+
['dsh-ris-ide:ui:workspace@/w/a', JSON.stringify({ files: ['/w/a/x.java'], file: '/w/a/x.java' })],
|
|
3690
|
+
])
|
|
3691
|
+
globalThis.localStorage = {
|
|
3692
|
+
getItem: (key) => store.get(key) ?? null,
|
|
3693
|
+
setItem: () => {},
|
|
3694
|
+
get length() { return store.size },
|
|
3695
|
+
key: (index) => [...store.keys()][index] ?? null,
|
|
3696
|
+
}
|
|
3697
|
+
assert.equal(T.readSavedUi('dsh-ris-ide:ui:workspace@/w/b', '/w/b'), null, "another workspace's tabs are not adopted")
|
|
3698
|
+
assert.deepEqual(T.readSavedUi('dsh-ris-ide:ui:workspace@/w/a', '/w/a').files, ['/w/a/x.java'])
|
|
3699
|
+
// A migrated legacy blob is consumed once: another FILE tab of the same
|
|
3700
|
+
// workspace must not inherit the pre-m13444 tabs again (20261109-2326 review).
|
|
3701
|
+
const legacyStore = new Map([['dsh-ris-ide:ui:workspace', JSON.stringify({ files: ['/w/a/x.java'] })]]);
|
|
3702
|
+
const removedKeys = []
|
|
3703
|
+
globalThis.localStorage = {
|
|
3704
|
+
getItem: (key) => (legacyStore.has(key) ? legacyStore.get(key) : null),
|
|
3705
|
+
setItem: (key, value) => { legacyStore.set(key, String(value)) },
|
|
3706
|
+
removeItem: (key) => { removedKeys.push(key); legacyStore.delete(key) },
|
|
3707
|
+
get length() { return legacyStore.size },
|
|
3708
|
+
key: (index) => [...legacyStore.keys()][index] ?? null,
|
|
3709
|
+
}
|
|
3710
|
+
assert.deepEqual(T.readSavedUi('dsh-ris-ide:ui:workspace@/w/a', '/w/a').files, ['/w/a/x.java'], 'the first opener migrates the legacy blob')
|
|
3711
|
+
assert.deepEqual(removedKeys, ['dsh-ris-ide:ui:workspace'], 'the legacy key is consumed exactly once')
|
|
3712
|
+
assert.equal(T.readSavedUi('dsh-ris-ide:ui:demo@/w/a', '/w/a'), null, 'switching to another file tab does not re-migrate')
|
|
3713
|
+
} finally {
|
|
3714
|
+
if (hadLocalStorage) globalThis.localStorage = previousLocalStorage
|
|
3715
|
+
else globalThis.localStorage = undefined
|
|
3716
|
+
}
|
|
3717
|
+
})
|
|
3718
|
+
|
|
3719
|
+
test('the elevation terminal never opens during a test run (m13621)', async () => {
|
|
3720
|
+
const source = await readFile(new URL('../lib/redirector.js', import.meta.url), 'utf8')
|
|
3721
|
+
assert.match(source, /NODE_TEST_CONTEXT !== undefined && process\.env\.DSH_RIS_IDE_ALLOW_TERMINAL !== '1'/)
|
|
3722
|
+
assert.match(source, /if \(process\.env\.NODE_TEST_CONTEXT !== undefined && process\.env\.DSH_RIS_IDE_ALLOW_TERMINAL !== '1'\) return false/)
|
|
3723
|
+
})
|
|
3724
|
+
|
|
3656
3725
|
test('the workbench restores open source tabs from localStorage and shows the workspace path', { skip: !reactIsReal ? 'React unavailable for SSR' : false }, () => {
|
|
3657
3726
|
const hadLocalStorage = Object.prototype.hasOwnProperty.call(globalThis, 'localStorage')
|
|
3658
3727
|
const previousLocalStorage = globalThis.localStorage
|
|
@@ -3660,7 +3729,7 @@ test('the workbench restores open source tabs from localStorage and shows the wo
|
|
|
3660
3729
|
globalThis.localStorage = {
|
|
3661
3730
|
getItem: (key) => {
|
|
3662
3731
|
keys.push(key)
|
|
3663
|
-
return key
|
|
3732
|
+
return String(key).startsWith('dsh-ris-ide:ui:workspace@')
|
|
3664
3733
|
? JSON.stringify({ ui: {}, files: ['/w/a.java', '/w/b.java'], file: '/w/a.java', sizes: {} })
|
|
3665
3734
|
: null
|
|
3666
3735
|
},
|
|
@@ -3672,7 +3741,7 @@ test('the workbench restores open source tabs from localStorage and shows the wo
|
|
|
3672
3741
|
// No program meta → the WORKSPACE storage key, the one this test restores.
|
|
3673
3742
|
tab: { id: T.PROGRAM_TAB_ID, type: T.PROGRAM_TAB_ID, title: 'workspace' },
|
|
3674
3743
|
})
|
|
3675
|
-
assert.ok(keys.
|
|
3744
|
+
assert.ok(keys.some((key) => key.startsWith('dsh-ris-ide:ui:workspace@')), `unexpected storage key ${keys.join(', ')}`)
|
|
3676
3745
|
assert.match(markup, /data-workbench-path="1">\/w\/work</, 'the top bar shows the workspace path')
|
|
3677
3746
|
assert.equal((markup.match(/data-tab-close="source"/g) || []).length, 2, 'both restored files get a tab')
|
|
3678
3747
|
assert.match(markup, /a\.java/)
|
|
@@ -3792,7 +3861,7 @@ test('a stored font size scales the IDE blocks through the style proxy', { skip:
|
|
|
3792
3861
|
globalThis.localStorage = {
|
|
3793
3862
|
getItem: (key) => {
|
|
3794
3863
|
keys.push(key)
|
|
3795
|
-
return key
|
|
3864
|
+
return String(key).startsWith('dsh-ris-ide:ui:workspace@')
|
|
3796
3865
|
? JSON.stringify({ font: 15, files: [], ui: {}, sizes: {} })
|
|
3797
3866
|
: null
|
|
3798
3867
|
},
|
|
@@ -3801,7 +3870,7 @@ test('a stored font size scales the IDE blocks through the style proxy', { skip:
|
|
|
3801
3870
|
try {
|
|
3802
3871
|
// Meta-less tab → the workspace key (a program meta would use its own key).
|
|
3803
3872
|
const markup = renderWorkbench({ tab: { id: T.PROGRAM_TAB_ID, type: T.PROGRAM_TAB_ID, title: 'workspace' } })
|
|
3804
|
-
assert.ok(keys.
|
|
3873
|
+
assert.ok(keys.some((key) => key.startsWith('dsh-ris-ide:ui:workspace@')), `unexpected storage keys ${keys.join(', ')}`)
|
|
3805
3874
|
assert.match(workbenchRootTagOf(markup), /font-size:15px/, 'the stored size reaches the workbench root')
|
|
3806
3875
|
assert.match(styleChildOf(markup), /\.cm-editor\{font-size:15px !important\}/, 'the stored size reaches CodeMirror')
|
|
3807
3876
|
// 12px authored × (15 / 12.5) = 14.4 → nearest 0.5px = 14.5
|
|
@@ -3863,7 +3932,7 @@ function stubWorkspaceUi(patch, keys) {
|
|
|
3863
3932
|
globalThis.localStorage = {
|
|
3864
3933
|
getItem: (key) => {
|
|
3865
3934
|
if (keys !== undefined) keys.push(key)
|
|
3866
|
-
return key
|
|
3935
|
+
return String(key).startsWith('dsh-ris-ide:ui:workspace@')
|
|
3867
3936
|
? JSON.stringify(Object.assign({ files: [], ui: {}, sizes: {} }, patch))
|
|
3868
3937
|
: null
|
|
3869
3938
|
},
|
|
@@ -4620,15 +4689,17 @@ test('the find box accepts more than one character while it has matches', async
|
|
|
4620
4689
|
test('Ctrl+R re-reads the workspace instead of replaying the search cache', async () => {
|
|
4621
4690
|
const source = await readFile(new URL('../lib/client.js', import.meta.url), 'utf8')
|
|
4622
4691
|
|
|
4623
|
-
// The cache is keyed by
|
|
4624
|
-
//
|
|
4692
|
+
// The cache is keyed by kind + WORKSPACE + query (m13444), so an explicit
|
|
4693
|
+
// re-search must drop this workspace's entries and re-run both effects.
|
|
4625
4694
|
assert.match(source, /var \[searchReload, setSearchReload\] = useState\(0\)/)
|
|
4695
|
+
assert.match(source, /function searchKey\(kind, text\) \{/)
|
|
4696
|
+
assert.match(source, /return kind \+ ':' \+ workspaceKey \+ '\\u0000' \+ text/)
|
|
4626
4697
|
assert.match(source, /function reloadWorkspaceSearch\(text\) \{/)
|
|
4627
|
-
assert.match(source, /searchCacheRef\.current\.delete\('content
|
|
4628
|
-
assert.match(source, /searchCacheRef\.current\.delete\('name
|
|
4629
|
-
const effects = source.split("var cached = searchCacheRef.current.get('name
|
|
4698
|
+
assert.match(source, /searchCacheRef\.current\.delete\(searchKey\('content', query\)\)/)
|
|
4699
|
+
assert.match(source, /searchCacheRef\.current\.delete\(searchKey\('name', query\)\)/)
|
|
4700
|
+
const effects = source.split("var cached = searchCacheRef.current.get(searchKey('name', text))")
|
|
4630
4701
|
assert.equal(effects.length, 2)
|
|
4631
|
-
const contentStart = effects[1].indexOf("var cached = searchCacheRef.current.get('content
|
|
4702
|
+
const contentStart = effects[1].indexOf("var cached = searchCacheRef.current.get(searchKey('content', text))")
|
|
4632
4703
|
assert.ok(contentStart !== -1)
|
|
4633
4704
|
assert.match(effects[1].slice(contentStart, contentStart + 5000), /\}, \[treeQuery, cwd, searchReload\]\)/)
|
|
4634
4705
|
|
|
@@ -4888,9 +4959,9 @@ test('search hits survive a pick and the shortcut selects the query', async () =
|
|
|
4888
4959
|
assert.doesNotMatch(pick, /setSearchHits\(null\)/, 'the result set stays after a pick')
|
|
4889
4960
|
const contentPick = source.slice(source.indexOf('function openContentHit('), source.indexOf('// No auto-pick on first load'))
|
|
4890
4961
|
assert.doesNotMatch(contentPick, /setTreeQuery\(''\)/, 'a content pick keeps the query too')
|
|
4891
|
-
// Both searches cache their payloads keyed by
|
|
4892
|
-
assert.match(source, /searchCacheRef\.current\.get\('name
|
|
4893
|
-
assert.match(source, /rememberSearchEntry\(searchCacheRef\.current, 'content
|
|
4962
|
+
// Both searches cache their payloads keyed by kind + workspace + query.
|
|
4963
|
+
assert.match(source, /searchCacheRef\.current\.get\(searchKey\('name', text\)\)/)
|
|
4964
|
+
assert.match(source, /rememberSearchEntry\(searchCacheRef\.current, searchKey\('content', text\)/)
|
|
4894
4965
|
// The shortcut focuses THROUGH an effect so select() survives the repaint.
|
|
4895
4966
|
assert.match(source, /searchFocusPendingRef\.current = true/)
|
|
4896
4967
|
// The dropdown is focus-owned: a pick blurs the box, so re-clicking it fires
|
|
@@ -5069,3 +5140,18 @@ test('no ProxyDialog component is shipped any more (m07355 / D4)', async () => {
|
|
|
5069
5140
|
// The page itself is served by the daemon: /ui owns the rule editor now.
|
|
5070
5141
|
assert.ok(source.includes("routeUrl('dsh-ris-ide/proxy')"), 'the entry still asks the host where the page is')
|
|
5071
5142
|
})
|
|
5143
|
+
|
|
5144
|
+
test('the workbench reads its saved blob once per mount and remounts per workspace', async () => {
|
|
5145
|
+
const source = await readFile(new URL('../lib/client.js', import.meta.url), 'utf8')
|
|
5146
|
+
// One read per mount, from a lazy useState initialiser: readSavedUi also runs
|
|
5147
|
+
// the one-shot legacy migration (it removes the adopted key), so calling it on
|
|
5148
|
+
// every render re-probed localStorage per keystroke.
|
|
5149
|
+
assert.match(source, /var \[savedUi\] = useState\(function \(\) \{ return readSavedUi\(storageKey, workspaceKey\) \}\)/)
|
|
5150
|
+
assert.doesNotMatch(source, /var savedUi = readSavedUi\(storageKey, workspaceKey\)/)
|
|
5151
|
+
// Tabs/recent/layout are seeded from that blob at mount, so a workspace switch
|
|
5152
|
+
// must remount the workbench instead of keeping the previous workspace's state.
|
|
5153
|
+
const mount = source.slice(source.indexOf('return h(ProgramWorkbench, {'), source.indexOf('return h(ProgramWorkbench, {') + 600)
|
|
5154
|
+
assert.match(mount, /key: typeof cwd === 'string' && cwd !== '' \? cwd : 'default'/)
|
|
5155
|
+
// The compact panel layout is a machine-wide preference on purpose.
|
|
5156
|
+
assert.match(source, /Deliberately NOT workspace-scoped/)
|
|
5157
|
+
})
|
|
@@ -23,7 +23,9 @@ test('the daemon restarts the bridge: stop, settle, start from the new profile',
|
|
|
23
23
|
const block = server.slice(at, at + 600)
|
|
24
24
|
assert.match(block, /await stopRedirector\(\)/)
|
|
25
25
|
assert.match(block, /setTimeout\(resolve, 300\)/)
|
|
26
|
-
|
|
26
|
+
// A page-triggered restart may prompt (it is the user asking); background
|
|
27
|
+
// reconcilers must not (review B-P0-2).
|
|
28
|
+
assert.match(block, /await startRedirectors\(\{ interactive: true \}\)/)
|
|
27
29
|
})
|
|
28
30
|
|
|
29
31
|
test('the plugin forwards the restart action to the daemon and can run it itself', () => {
|