feat(panel): add worker hot-reload, sticky bridge lease, custom token combos, trimmed model IDs, and adaptive popover width

- Isolate SidecarApp /api/* backend runtime inside a hot-swappable Worker thread (sidecar-worker.mjs) with 3s disk-drift detection and queued request handoff so live plugin updates never drop the host-assigned SidecarApp port
- Persist and reuse sticky loopback bridge port/token leases across bridge-daemon and worker reloads, pre-bind the bridge server on boot, allow /api/cache/rebuild on the bridge, and self-heal poisoned CDP fallback states back to HTTP
- Add billing-aligned In / Out / Cache (tokens_io_cache) preset with per-segment USD hover breakdown and custom format DSL (tokens_custom + stepTokenComboFormat, e.g. context:new:cache, in:out:cache)
- Add 3-way model name format (short / upstream / upstream_compact) stripping gemini-, claude-, and gpt- prefixes while protecting compaction suffixes from ellipsis truncation
- Add adaptive content-fit popover width (auto up to viewport bounds on wide step tables) alongside custom fixed width (440-1080 px)
This commit is contained in:
fish
2026-11-16 16:55:56 +09:00
parent cd841b55cf
commit 3b36ade911
33 changed files with 3124 additions and 381 deletions
+26 -2
View File
@@ -72,15 +72,39 @@ function runExecFile(cmd, args, opts = {}) {
});
}
let customSidecarRestartHandler = null;
/**
* 更新完成后调度 Sidecar 进程平滑退出,让宿主进程监督器自动重启新代码。
* 注册自定义运行时热重载回调(例如 `main.mjs` 的 `Worker` 热替换或 `bridge-daemon.mjs` 的平滑退出),
* 避免直接调用 `process.exit(0)` 导致宿主 `SidecarApp` 固定端口失联。
*
* @param {(() => void)|null} handler
*/
export function setSidecarRestartHandler(handler) {
customSidecarRestartHandler = typeof handler === 'function' ? handler : null;
}
/**
* 更新完成后调度 Sidecar 运行时热重载(若未注册自定义处理器,则回退平滑退出供父监督器拉起)。
* 在单元测试环境(`!LS_ADDR || LS_ADDR === 'test.invalid'`)下自动跳过。
*
* @param {number} [delayMs=350] 延迟毫秒数,确保当前 HTTP 响应先发回前端
*/
export function scheduleSidecarRestart(delayMs = 350) {
const activeAddr = lsRuntimeEndpoint.addr || LS_ADDR;
if (!activeAddr || activeAddr === 'test.invalid' || typeof process?.exit !== 'function') return;
if (!activeAddr || activeAddr === 'test.invalid') return;
if (typeof customSidecarRestartHandler === 'function') {
const fn = customSidecarRestartHandler;
setTimeout(() => {
try {
fn();
} catch {
// 忽略自定义热重载回调异常
}
}, delayMs);
return;
}
if (typeof process?.exit !== 'function') return;
setTimeout(() => {
try {
process.exit(0);