@twinsearth/dsh-fang 3.3.2 → 3.7.7
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 +5 -5
- package/client.js +674 -60
- package/cordis.patch.yml +26 -20
- package/docs/APPROVAL-DRILL.md +42 -0
- package/docs/AUTO-WATCHDOG.md +46 -0
- package/docs/DECISION-LOSSLESS.md +36 -0
- package/docs/ESSENCE-AUTO-SYNC.md +32 -0
- package/docs/INBOX-SCROLL.md +33 -0
- package/docs/PACKAGE-RENAME-v3.3.3.md +40 -0
- package/docs/RESTART-CONFIRMATION.md +29 -0
- package/docs/TEST-STABILITY-v3.4.0.md +30 -0
- package/package.json +11 -7
- package/src/compose.mjs +4 -1
- package/src/contract/VENDOR.json +6 -5
- package/src/contract/constants.js +16 -1
- package/src/contract/relay.js +12 -6
- package/src/kernel/types.mjs +3 -1
- package/src/lib/accelerated-fork.mjs +813 -0
- package/src/lib/accelerated-install.mjs +295 -0
- package/src/lib/accelerated-web.mjs +103 -0
- package/src/lib/approval-drill.mjs +111 -0
- package/src/lib/boot-guard.mjs +6 -2
- package/src/lib/chat-import-delegation.mjs +47 -0
- package/src/lib/compat.mjs +5 -1
- package/src/lib/contract-delegation.mjs +161 -0
- package/src/lib/default-essence.mjs +7 -4
- package/src/lib/essence.mjs +113 -7
- package/src/lib/fork-config-lock.mjs +2 -2
- package/src/lib/fork-core-settings.mjs +95 -0
- package/src/lib/fork-export.mjs +85 -0
- package/src/lib/global-redline.mjs +164 -0
- package/src/lib/http-auth.mjs +36 -0
- package/src/lib/install-snapshot.mjs +77 -0
- package/src/lib/lsp-delegation.mjs +70 -0
- package/src/lib/lsp-provider.mjs +250 -0
- package/src/lib/main-gate.mjs +33 -28
- package/src/lib/mirror.mjs +115 -4
- package/src/lib/node-compat.mjs +24 -0
- package/src/lib/pro-delegation.mjs +185 -0
- package/src/lib/runtime-capture.mjs +11 -3
- package/src/lib/watch-guard.mjs +51 -0
- package/src/plugins/approver.mjs +5 -2
- package/src/plugins/auditor.mjs +125 -18
- package/src/plugins/decision-center.mjs +77 -34
- package/src/plugins/forker.mjs +258 -33
- package/src/plugins/orchestrator.mjs +1508 -65
- package/src/plugins/restart-guard.mjs +79 -2
- package/src/plugins/session-catalog.mjs +127 -40
- package/tools/approval-drill.mjs +21 -0
- package/tools/fangctl.mjs +21 -4
- package/tools/gate/main-city.mjs +1 -1
- package/tools/restart-supervisor.mjs +425 -0
- package/tools/restart-watchdog.mjs +568 -0
- package/vault/client.js +49 -0
- package/vault/cordis.patch.yml +3 -0
- package/vault/lib/vault.mjs +219 -0
- package/vault/package.json +29 -0
package/client.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
// * 不新增依赖:仅宿主插槽契约要求 factory 返回 React 元素,故保留一个 15 行的
|
|
9
9
|
// 挂载壳(DomMount);它不做布局、不持有状态,UI 本身与 React 无关。
|
|
10
10
|
// 如果宿主未来允许插槽返回 DOM 节点,直接去掉 DomMount 即可。
|
|
11
|
-
// * 视觉:顶部 Header(品牌 / Stats / 动作)→
|
|
11
|
+
// * 视觉:顶部 Header(品牌 / Stats / 动作)→ v3.5.4 三块:左列「母体&元主」,右列上「分身」/ 下「决策中心」(水平分隔条调比例);
|
|
12
12
|
// 白卡、圆角、柔和阴影、毛玻璃浮窗(Mother / 确认 / 输入)。
|
|
13
13
|
// * 颜色语义:绿 = 派生/健康,蓝 = 运行/母体身份,红 = 派发/破坏性,橘 = 配置/警告。
|
|
14
14
|
//
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
|
|
33
33
|
if (typeof window !== 'undefined' && window.__ModuleLoader__) {
|
|
34
34
|
window.__ModuleLoader__.load({
|
|
35
|
-
id: '@twinsearth/dsh-
|
|
35
|
+
id: '@twinsearth/fang-dsh-plugin',
|
|
36
36
|
factory(require) {
|
|
37
37
|
// React 只用于宿主插槽返回值(slots 契约),UI 不依赖它。见文件头说明。
|
|
38
38
|
const React = require('react')
|
|
@@ -249,6 +249,40 @@ window.__ModuleLoader__.load({
|
|
|
249
249
|
}
|
|
250
250
|
return { active, archived, temporary }
|
|
251
251
|
}
|
|
252
|
+
|
|
253
|
+
// 2026-11-21:会话统一分类(母体面板与会话选择弹窗共用):
|
|
254
|
+
// 1) 活跃中(7 天内、未归档)
|
|
255
|
+
// 2) 已归档(归档优先于时间,一律归此组)
|
|
256
|
+
// 3) 旧会话(超过 7 天且未归档)
|
|
257
|
+
// 组内一律按「最后活跃时间」(updatedAt)从新到旧排序。
|
|
258
|
+
const SESSION_ACTIVE_WINDOW_MS = 7 * 24 * 60 * 60 * 1000
|
|
259
|
+
const SESSION_GROUP_ORDER = ['active', 'archived', 'older']
|
|
260
|
+
const SESSION_GROUP_LABELS = {
|
|
261
|
+
active: '活跃中(7 天内)',
|
|
262
|
+
archived: '已归档',
|
|
263
|
+
older: '旧会话(超过 7 天)',
|
|
264
|
+
}
|
|
265
|
+
const byLastActiveDesc = (a, b) => (Number(b?.updatedAt) || 0) - (Number(a?.updatedAt) || 0)
|
|
266
|
+
function classifySessionsByRecency(items, now = Date.now()) {
|
|
267
|
+
const active = []
|
|
268
|
+
const archived = []
|
|
269
|
+
const older = []
|
|
270
|
+
for (const item of Array.isArray(items) ? items : []) {
|
|
271
|
+
if (item?.archived === true) { archived.push(item); continue }
|
|
272
|
+
const updatedAt = Number(item?.updatedAt)
|
|
273
|
+
if (Number.isFinite(updatedAt) && now - updatedAt <= SESSION_ACTIVE_WINDOW_MS) active.push(item)
|
|
274
|
+
else older.push(item)
|
|
275
|
+
}
|
|
276
|
+
active.sort(byLastActiveDesc)
|
|
277
|
+
archived.sort(byLastActiveDesc)
|
|
278
|
+
older.sort(byLastActiveDesc)
|
|
279
|
+
return { active, archived, older }
|
|
280
|
+
}
|
|
281
|
+
function sessionCategoryOf(session, now = Date.now()) {
|
|
282
|
+
if (session?.archived === true) return 'archived'
|
|
283
|
+
const updatedAt = Number(session?.updatedAt)
|
|
284
|
+
return Number.isFinite(updatedAt) && now - updatedAt <= SESSION_ACTIVE_WINDOW_MS ? 'active' : 'older'
|
|
285
|
+
}
|
|
252
286
|
function classifyTasks(items) {
|
|
253
287
|
const active = []
|
|
254
288
|
const archived = []
|
|
@@ -314,7 +348,8 @@ window.__ModuleLoader__.load({
|
|
|
314
348
|
const base = TASK_PROJECTION[status] || { label: '状态未知', tone: 'neutral' }
|
|
315
349
|
let tone = base.tone
|
|
316
350
|
let label = base.label
|
|
317
|
-
if (phase === 'failed'
|
|
351
|
+
if (phase === 'failed') { tone = 'warn'; label = '等待启动' }
|
|
352
|
+
else if (phase === 'crashed') { tone = 'bad'; label = '已崩溃' }
|
|
318
353
|
else if (anomaly) { tone = 'bad'; label = '运行中 · 适配器失联' }
|
|
319
354
|
else if (phase === 'archived') { tone = 'info'; label = '已归档' }
|
|
320
355
|
else if (phase === 'paused' || phase === 'stopping' || phase === 'pausing' || phase === 'completed') { tone = 'info'; label = phase === 'paused' ? '已暂停' : phase === 'stopping' ? '停止中' : phase === 'completed' ? '已完成' : '暂停中' }
|
|
@@ -333,6 +368,24 @@ window.__ModuleLoader__.load({
|
|
|
333
368
|
}
|
|
334
369
|
const taskHealth = projectTask;
|
|
335
370
|
|
|
371
|
+
/**
|
|
372
|
+
* 2026-11-22:分身状态栏(4 态 + 2 操作)。
|
|
373
|
+
* 运行中 / 等待启动 / 已停止 / 故障;故障优先于「进程在跑」(适配器失联也算故障)。
|
|
374
|
+
* @returns {{key:'running'|'starting'|'stopped'|'failed', label:string, tone:'ok'|'warn'|'bad'|'info', hint:string}}
|
|
375
|
+
*/
|
|
376
|
+
function forkStateOf(task) {
|
|
377
|
+
const status = String(task?.status ?? '')
|
|
378
|
+
const adapter = String(task?.health?.adapter ?? (task?.adapter?.ok ? 'ok' : ''))
|
|
379
|
+
if (status === 'failed') return { key: 'failed', label: '故障', tone: 'bad', hint: '启动失败或进程崩溃,可一键修复' }
|
|
380
|
+
if (status === 'provisioning' || status === 'starting' || status === 'resuming') return { key: 'starting', label: '等待启动', tone: 'warn', hint: '正在分配端口并拉起进程' }
|
|
381
|
+
if (status === 'running' || status === 'ready') {
|
|
382
|
+
if (adapter === 'error') return { key: 'failed', label: '故障', tone: 'bad', hint: '进程在跑但适配器失联,可一键修复' }
|
|
383
|
+
if (adapter === 'pending') return { key: 'starting', label: '等待启动', tone: 'warn', hint: '进程已就绪,正在握手适配器' }
|
|
384
|
+
return { key: 'running', label: '运行中', tone: 'ok', hint: task?.port ? `端口 ${task.port}` : '' }
|
|
385
|
+
}
|
|
386
|
+
return { key: 'stopped', label: '已停止', tone: 'info', hint: status === 'archived' ? '存档保留,可启动或还原' : '进程未运行' }
|
|
387
|
+
}
|
|
388
|
+
|
|
336
389
|
/** 容量投影:slots=7 硬上限,limit=5 默认配额;v3.0.5 用 tasks 数兜底并显式标注“估算”。 */
|
|
337
390
|
function projectCapacity(statusData, tasks) {
|
|
338
391
|
const items = Array.isArray(tasks) ? tasks : []
|
|
@@ -749,6 +802,7 @@ window.__ModuleLoader__.load({
|
|
|
749
802
|
inbox: (size = 14) => glyph(['M4 5h16v14H4z', 'M4 13h4l2 3h4l2-3h4'], size),
|
|
750
803
|
eye: (size = 14) => glyph(['M2.5 12s3.5-6 9.5-6 9.5 6 9.5 6-3.5 6-9.5 6-9.5-6-9.5-6Z', 'M12 9.2a2.8 2.8 0 1 0 0 5.6a2.8 2.8 0 0 0 0-5.6'], size),
|
|
751
804
|
eyeOff: (size = 14) => glyph(['M3 3l18 18', 'M10.6 10.7a2 2 0 0 0 2.7 2.7', 'M9.9 5.2A10.6 10.6 0 0 1 12 5c6 0 9.5 7 9.5 7a17 17 0 0 1-3.3 4.1', 'M6.6 6.7C4.2 8.6 2.5 12 2.5 12s3.5 7 9.5 7c1.5 0 2.9-.4 4.1-1'], size),
|
|
805
|
+
power: (size = 14) => glyph(['M12 3v8', 'M6.3 6.3a8 8 0 1 0 11.4 0'], size, 2),
|
|
752
806
|
spinner: (size = 14) => {
|
|
753
807
|
const node = svg('svg', { width: size, height: size, viewBox: '0 0 24 24', fill: 'none', class: 'fang-icon fang-spin', 'aria-hidden': 'true', focusable: 'false' })
|
|
754
808
|
node.appendChild(svg('circle', { cx: 12, cy: 12, r: 8.5, stroke: 'currentColor', 'stroke-width': 2, 'stroke-linecap': 'round', 'stroke-dasharray': '38 12' }))
|
|
@@ -917,11 +971,20 @@ window.__ModuleLoader__.load({
|
|
|
917
971
|
.fang-body{position:relative;display:grid;grid-template-columns:minmax(320px,50fr) minmax(0,50fr);gap:16px;align-items:stretch;height:100%;min-height:0;flex:1 1 auto;overflow:hidden}
|
|
918
972
|
.fang-body.is-resizing{cursor:col-resize;user-select:none}
|
|
919
973
|
.fang-body.is-resizing *{user-select:none}
|
|
974
|
+
.fang-body.is-resizing-y{cursor:row-resize;user-select:none}
|
|
975
|
+
.fang-body.is-resizing-y *{user-select:none}
|
|
976
|
+
/* v3.5.4 三块布局:左列 = 母体&元主;右列 = 上「分身」/ 下「决策中心」(中间水平分隔条可调比例) */
|
|
977
|
+
.fang-col{display:flex;flex-direction:column;min-height:0;min-width:0}
|
|
978
|
+
.fang-col--right{display:grid;grid-template-rows:minmax(160px,1fr) 12px minmax(120px,1fr);gap:0;min-height:0}
|
|
979
|
+
.fang-vsplit-handle{position:relative;cursor:row-resize;z-index:5;border-radius:6px;background:transparent;touch-action:none}
|
|
980
|
+
.fang-vsplit-handle::after{content:"";position:absolute;top:50%;left:50%;width:52px;height:3px;transform:translate(-50%,-50%);border-radius:3px;background:var(--f-border-strong,var(--f-border));opacity:.55;transition:opacity .15s,background .15s}
|
|
981
|
+
.fang-vsplit-handle:hover::after,.fang-vsplit-handle:focus-visible::after,.fang-body.is-resizing-y .fang-vsplit-handle::after{opacity:1;background:var(--f-blue,#3b82f6)}
|
|
982
|
+
.fang-vsplit-handle:focus-visible{outline:2px solid var(--f-blue,#3b82f6);outline-offset:2px}
|
|
920
983
|
.fang-split-handle{position:absolute;top:0;bottom:0;left:50%;width:10px;transform:translateX(-50%);cursor:col-resize;z-index:6;border-radius:6px;background:transparent;touch-action:none}
|
|
921
984
|
.fang-split-handle::after{content:"";position:absolute;top:50%;left:50%;width:3px;height:46px;transform:translate(-50%,-50%);border-radius:3px;background:var(--f-border-strong,var(--f-border));opacity:.55;transition:opacity .15s,background .15s}
|
|
922
985
|
.fang-split-handle:hover::after,.fang-split-handle:focus-visible::after,.fang-body.is-resizing .fang-split-handle::after{opacity:1;background:var(--f-blue,#3b82f6)}
|
|
923
986
|
.fang-split-handle:focus-visible{outline:2px solid var(--f-blue,#3b82f6);outline-offset:2px}
|
|
924
|
-
@media (max-width:1100px){.fang-console{overflow:auto}.fang-body{grid-template-columns:1fr;align-items:start;height:auto;flex:1 0 auto;overflow:visible}.fang-split-handle{display:none}}
|
|
987
|
+
@media (max-width:1100px){.fang-console{overflow:auto}.fang-body{grid-template-columns:1fr;align-items:start;height:auto;flex:1 0 auto;overflow:visible}.fang-col--right{display:block}.fang-split-handle,.fang-vsplit-handle{display:none}}
|
|
925
988
|
.panel{background:var(--f-surface);border:1px solid var(--f-border);border-radius:var(--f-radius-panel);
|
|
926
989
|
box-shadow:var(--f-shadow-card);display:flex;flex-direction:column;min-height:0;overflow:hidden;
|
|
927
990
|
height:100%;max-height:100%}
|
|
@@ -1004,6 +1067,12 @@ window.__ModuleLoader__.load({
|
|
|
1004
1067
|
.expand-btn[aria-expanded="true"] svg{transform:rotate(45deg)}
|
|
1005
1068
|
.expand-btn svg{transition:transform .16s ease}
|
|
1006
1069
|
.sessions{padding:0 10px 8px 31px;display:flex;flex-direction:column;gap:1px}
|
|
1070
|
+
.session-group-head{display:flex;align-items:center;gap:6px;margin:6px 0 2px;padding:0 2px;font-size:11px;line-height:15px;
|
|
1071
|
+
color:var(--f-text-4);white-space:nowrap}
|
|
1072
|
+
.session-group-head:first-child{margin-top:2px}
|
|
1073
|
+
.session-group-head::after{content:"";flex:1 1 auto;height:1px;background:var(--f-border)}
|
|
1074
|
+
.session-group-head[data-category="archived"]{opacity:.75}
|
|
1075
|
+
.session-group-count{font-variant-numeric:tabular-nums;color:var(--f-text-4);opacity:.85}
|
|
1007
1076
|
.session-row{display:flex;align-items:center;gap:8px;padding:7px 8px;border:1px solid transparent;border-radius:10px;
|
|
1008
1077
|
background:transparent;cursor:pointer;text-align:left;width:100%;font-family:inherit}
|
|
1009
1078
|
.session-row:hover{background:#fff;border-color:var(--f-border)}
|
|
@@ -1061,6 +1130,15 @@ window.__ModuleLoader__.load({
|
|
|
1061
1130
|
font-variant-numeric:tabular-nums;align-items:center}
|
|
1062
1131
|
.fork-meta code{font-family:var(--f-mono);font-size:11px;color:var(--f-text-3);background:var(--f-surface-3);
|
|
1063
1132
|
padding:1px 5px;border-radius:5px}
|
|
1133
|
+
.fork-status{display:flex;align-items:center;gap:8px;margin:8px 0 0 30px;padding:6px 10px;border:1px solid var(--f-border);border-radius:8px;background:var(--f-surface-3);font-size:12px;flex-wrap:wrap}
|
|
1134
|
+
.fork-status-dot{width:8px;height:8px;border-radius:50%;background:var(--f-text-3);flex:none}
|
|
1135
|
+
.fork-status[data-tone="ok"] .fork-status-dot{background:var(--f-green)}
|
|
1136
|
+
.fork-status[data-tone="warn"] .fork-status-dot{background:var(--f-orange)}
|
|
1137
|
+
.fork-status[data-tone="bad"] .fork-status-dot{background:var(--f-red)}
|
|
1138
|
+
.fork-status[data-tone="info"] .fork-status-dot{background:var(--f-blue)}
|
|
1139
|
+
.fork-status-label{font-weight:600}
|
|
1140
|
+
.fork-status-hint{color:var(--f-text-3)}
|
|
1141
|
+
.fork-status-actions{margin-left:auto;display:flex;gap:6px}
|
|
1064
1142
|
.fork-warn{margin-top:8px;font-size:11.5px;line-height:17px;color:var(--f-red);display:flex;gap:6px;align-items:flex-start}
|
|
1065
1143
|
.fork-sub{margin-top:10px;padding-top:8px;border-top:1px solid var(--f-border)}
|
|
1066
1144
|
.fork-sub-head{display:flex;align-items:center;gap:8px;font-size:12px;color:var(--f-text-3)}
|
|
@@ -1276,7 +1354,7 @@ window.__ModuleLoader__.load({
|
|
|
1276
1354
|
.fang-inbox-btn--primary{background:#0A6BE0;border-color:#0A6BE0;color:#fff}
|
|
1277
1355
|
.fang-inbox-btn--primary:hover{background:#0857B8}
|
|
1278
1356
|
.fang-inbox-btn--danger{color:#C8102E;border-color:rgba(200,16,46,.3)}
|
|
1279
|
-
.fang-inbox-ai{padding:8px 12px;border-bottom:1px solid var(--f-inbox-border);font-size:12px;color:var(--f-inbox-text2);flex:0 0 auto}
|
|
1357
|
+
.fang-inbox-ai{padding:8px 12px;border-bottom:1px solid var(--f-inbox-border);font-size:12px;color:var(--f-inbox-text2);flex:0 0 auto;max-height:32vh;overflow:auto;overscroll-behavior:contain}
|
|
1280
1358
|
.fang-inbox-ai summary{cursor:pointer;color:var(--f-inbox-text2)}
|
|
1281
1359
|
.fang-inbox-ai-row{display:flex;flex-wrap:wrap;gap:6px;margin-top:6px;align-items:center}
|
|
1282
1360
|
.fang-inbox-ai input,.fang-inbox-ai select{height:26px;padding:0 6px;border-radius:7px;border:1px solid rgba(16,17,20,.14);font:inherit;font-size:12px;background:#fff;color:#1D1D1F}
|
|
@@ -1298,7 +1376,11 @@ window.__ModuleLoader__.load({
|
|
|
1298
1376
|
.fang-inbox-exec--running{color:#0857B8}
|
|
1299
1377
|
.fang-inbox-toolbar{display:flex;align-items:center;gap:6px;padding:8px 12px;border-bottom:1px solid var(--f-inbox-border);flex-wrap:wrap;flex:0 0 auto}
|
|
1300
1378
|
.fang-inbox-hint{font-size:11.5px;color:#86868B}
|
|
1301
|
-
.fang-inbox-body{flex:1 1
|
|
1379
|
+
.fang-inbox-body{flex:1 1 0;height:0;min-height:0;overflow-y:scroll;overflow-x:hidden;overscroll-behavior:contain;touch-action:pan-y;scrollbar-gutter:stable;scrollbar-width:thin;scrollbar-color:rgba(16,17,20,.32) rgba(16,17,20,.06);padding:8px 10px 16px;display:flex;flex-direction:column;gap:8px}
|
|
1380
|
+
.fang-inbox-body::-webkit-scrollbar{width:12px;height:12px}
|
|
1381
|
+
.fang-inbox-body::-webkit-scrollbar-track{background:rgba(16,17,20,.05);border-radius:999px}
|
|
1382
|
+
.fang-inbox-body::-webkit-scrollbar-thumb{background:rgba(16,17,20,.30);border:3px solid #fff;border-radius:999px;background-clip:padding-box}
|
|
1383
|
+
.fang-inbox-body::-webkit-scrollbar-thumb:hover{background:rgba(16,17,20,.46);border:2px solid #fff;background-clip:padding-box}
|
|
1302
1384
|
.fang-inbox-group{border:1px solid var(--f-inbox-border);border-radius:12px;overflow:hidden;background:#fff}
|
|
1303
1385
|
.fang-inbox-group-head{display:flex;align-items:center;gap:8px;width:100%;padding:8px 10px;border:0;background:var(--f-inbox-surface2);cursor:pointer;font:inherit;text-align:left;color:inherit}
|
|
1304
1386
|
.fang-inbox-group-toggle{display:flex;align-items:center;gap:8px;flex:1;min-width:0;border:0;background:transparent;color:inherit;font:inherit;text-align:left;padding:0;cursor:pointer}
|
|
@@ -1352,7 +1434,11 @@ window.__ModuleLoader__.load({
|
|
|
1352
1434
|
.fang-decision-mini-context{font-size:11px;color:var(--f-text-2,#5F6368);margin-top:2px;overflow-wrap:anywhere}
|
|
1353
1435
|
.fang-decision-mini-actions{display:flex;flex-wrap:wrap;gap:4px;margin-top:4px}
|
|
1354
1436
|
.fang-decision-mini-actions .fang-inbox-btn{height:22px;font-size:11px;padding:0 7px}
|
|
1355
|
-
.
|
|
1437
|
+
/* v3.5.3:决策中心成为独立面板块(左列上),mini 组件填满并自行滚动 */
|
|
1438
|
+
.fang-decision-panel{padding:0}
|
|
1439
|
+
.fang-decision-panel .fang-decision-mini{margin:0;border:0;border-radius:var(--f-radius-panel);height:100%;min-height:0;display:flex;flex-direction:column;background:transparent;overflow:hidden}
|
|
1440
|
+
.fang-decision-panel .fang-decision-mini-body{max-height:none;flex:1 1 auto;min-height:0;overflow-y:auto;scrollbar-gutter:stable}
|
|
1441
|
+
.fang-inbox-drawer{position:fixed;top:0;right:0;bottom:0;width:min(420px,92vw);height:100vh;height:100dvh;max-height:100vh;min-height:0;overflow:hidden;z-index:2147483001;background:#fff;border-left:1px solid rgba(16,17,20,.12);box-shadow:-18px 0 48px rgba(0,0,0,.18);transform:translateX(100%);transition:transform .18s ease;display:flex;flex-direction:column}
|
|
1356
1442
|
.fang-inbox-drawer.is-open{transform:none}
|
|
1357
1443
|
.fang-inbox-backdrop{position:fixed;inset:0;background:rgba(0,0,0,.26);z-index:2147483000;animation:fang-fade .15s ease}
|
|
1358
1444
|
.fang-inbox-stream{font-size:11px;color:#17803D;white-space:nowrap}
|
|
@@ -1549,6 +1635,11 @@ html[data-fang-overlays="hidden"] .fang-console .toast{display:none!important}
|
|
|
1549
1635
|
const n = readNumberPref('fang.panel.split', 0.5)
|
|
1550
1636
|
return Math.min(0.75, Math.max(0.25, Number.isFinite(n) ? n : 0.5))
|
|
1551
1637
|
})(),
|
|
1638
|
+
// v3.5.3:左列内「决策中心 / 分身」垂直比例,默认 50:50,可拖动分隔条调整。
|
|
1639
|
+
decisionSplit: (() => {
|
|
1640
|
+
const n = readNumberPref('fang.panel.decision.split', 0.5)
|
|
1641
|
+
return Math.min(0.8, Math.max(0.2, Number.isFinite(n) ? n : 0.5))
|
|
1642
|
+
})(),
|
|
1552
1643
|
showTemporary: readPref('fang.panel.showTemporary', true),
|
|
1553
1644
|
// 母体会话只读投影:默认只看最近 20 条,可切 50 / 全部(偏好存本机)。
|
|
1554
1645
|
sessionWindow: (() => {
|
|
@@ -1729,13 +1820,14 @@ html[data-fang-overlays="hidden"] .fang-console .toast{display:none!important}
|
|
|
1729
1820
|
const seq = ++refreshSeq
|
|
1730
1821
|
if (options.manual) { S.refreshing = true; schedule() }
|
|
1731
1822
|
try {
|
|
1732
|
-
const [statusRes, tasksRes, sessionsRes, essenceRes, approvalsRes, supervisionRes] = await Promise.all([
|
|
1823
|
+
const [statusRes, tasksRes, sessionsRes, essenceRes, approvalsRes, supervisionRes, forkCoreRes] = await Promise.all([
|
|
1733
1824
|
api('/fang/api/status').catch((error) => ({ status: 0, body: null, diagnostic: { message: String(error?.message ?? error) } })),
|
|
1734
1825
|
api('/fang/api/tasks').catch((error) => ({ status: 0, body: null, diagnostic: { message: String(error?.message ?? error) } })),
|
|
1735
1826
|
api(`/fang/api/sessions?limit=${S.sessionWindow === 'all' ? 1000 : S.sessionWindow}`).catch((error) => ({ status: 0, body: null, diagnostic: { message: String(error?.message ?? error) } })),
|
|
1736
1827
|
api('/fang/api/essence/list').catch((error) => ({ status: 0, body: null, diagnostic: { message: String(error?.message ?? error) } })),
|
|
1737
1828
|
api('/fang/api/approvals').catch((error) => ({ status: 0, body: null, diagnostic: { message: String(error?.message ?? error) } })),
|
|
1738
1829
|
api('/fang/api/forks/supervision').catch((error) => ({ status: 0, body: null, diagnostic: { message: String(error?.message ?? error) } })),
|
|
1830
|
+
api('/fang/api/fork-core').catch((error) => ({ status: 0, body: null, diagnostic: { message: String(error?.message ?? error) } })),
|
|
1739
1831
|
])
|
|
1740
1832
|
if (!alive || seq !== refreshSeq) return
|
|
1741
1833
|
if (supervisionRes.status === 200 && supervisionRes.body?.ok) {
|
|
@@ -1786,6 +1878,12 @@ html[data-fang-overlays="hidden"] .fang-console .toast{display:none!important}
|
|
|
1786
1878
|
S.tasks = { ...S.tasks, state: 'error', error: code, diagnostic: tasksRes.diagnostic || null }
|
|
1787
1879
|
}
|
|
1788
1880
|
|
|
1881
|
+
if (forkCoreRes.status === 200 && forkCoreRes.body && forkCoreRes.body.ok !== false) {
|
|
1882
|
+
S.forkCore = { state: 'ready', data: forkCoreRes.body, error: '', at: Date.now() }
|
|
1883
|
+
} else {
|
|
1884
|
+
S.forkCore = { ...S.forkCore, state: 'error', error: forkCoreRes.body?.error || (forkCoreRes.status ? 'http-' + forkCoreRes.status : 'network') }
|
|
1885
|
+
}
|
|
1886
|
+
|
|
1789
1887
|
if (sessionsRes.status === 200 && sessionsRes.body && sessionsRes.body.ok !== false) {
|
|
1790
1888
|
const body = sessionsRes.body
|
|
1791
1889
|
const items = Array.isArray(body.sessions) ? body.sessions : []
|
|
@@ -1946,6 +2044,74 @@ html[data-fang-overlays="hidden"] .fang-console .toast{display:none!important}
|
|
|
1946
2044
|
})
|
|
1947
2045
|
}
|
|
1948
2046
|
|
|
2047
|
+
/**
|
|
2048
|
+
* 2026-11-22:「启动」= 从 stopped/failed 直接拉起(低风险、可回退,不再二次确认);
|
|
2049
|
+
* 只有 archived 才走「还原存档」确认。此前启动按钮直接复用 restoreTask,
|
|
2050
|
+
* 导致 failed 分身也弹「还原存档?」。
|
|
2051
|
+
*/
|
|
2052
|
+
async function startTask(task) {
|
|
2053
|
+
if (isBusy()) return
|
|
2054
|
+
if (String(task?.status ?? '') === 'archived') { await restoreTask(task); return }
|
|
2055
|
+
S.busy = 'start:' + task.taskId
|
|
2056
|
+
setNotice(null)
|
|
2057
|
+
const result = await api('/fang/api/tasks/restore', { method: 'POST', body: JSON.stringify({ taskId: task.taskId }) })
|
|
2058
|
+
S.busy = ''
|
|
2059
|
+
const body = result.body
|
|
2060
|
+
if (result.status === 200 && body?.ok) {
|
|
2061
|
+
S.view = 'console'
|
|
2062
|
+
setNotice({ tone: 'ok', title: '分身已启动', message: `${task.title || task.taskId} 已启动 · 端口 ${body.port ?? '—'}`, actions: [{ label: '打开分身', onClick: () => void openTask({ taskId: task.taskId }) }] })
|
|
2063
|
+
} else {
|
|
2064
|
+
const code = body?.error || (result.status ? 'http-' + result.status : 'network')
|
|
2065
|
+
setNotice({ tone: 'bad', title: '启动分身失败', message: failureHint(code), detail: body?.detail || diagnosticText(result.diagnostic) })
|
|
2066
|
+
}
|
|
2067
|
+
await refresh()
|
|
2068
|
+
}
|
|
2069
|
+
|
|
2070
|
+
/**
|
|
2071
|
+
* 2026-11-22:一键修复。服务端按 停残留 → 清加速别名桩 → 重置 profile → 重新拉起
|
|
2072
|
+
* 的顺序处理,不删除 home/会话/存档;运行中的分身会被重启。
|
|
2073
|
+
*/
|
|
2074
|
+
async function repairTask(task) {
|
|
2075
|
+
if (isBusy()) return
|
|
2076
|
+
askConfirm({
|
|
2077
|
+
tone: 'warn',
|
|
2078
|
+
title: '一键修复这个分身?',
|
|
2079
|
+
confirm: 'repair',
|
|
2080
|
+
message: `「${task.title || task.taskId}」\n\n将依次:停掉残留进程 → 清理加速别名桩 → 按来源原身重置 profile 配置 → 修复 node_modules → 重新分配端口并拉起。\n不会删除 home、会话或存档;运行中的分身会被重启。`,
|
|
2081
|
+
confirmLabel: '开始修复',
|
|
2082
|
+
onConfirm: async () => {
|
|
2083
|
+
S.busy = 'repair:' + task.taskId
|
|
2084
|
+
setNotice(null)
|
|
2085
|
+
const result = await api('/fang/api/tasks/repair', { method: 'POST', body: JSON.stringify({ taskId: task.taskId }) })
|
|
2086
|
+
S.busy = ''
|
|
2087
|
+
const body = result.body
|
|
2088
|
+
const steps = Array.isArray(body?.steps) ? body.steps : []
|
|
2089
|
+
const stepText = steps
|
|
2090
|
+
.map((step) => `${step?.step ?? '?'}: ${step?.ok === false ? (step?.error || 'failed') : 'ok'}`)
|
|
2091
|
+
.join(' · ')
|
|
2092
|
+
if (result.status === 200 && body?.ok) {
|
|
2093
|
+
S.view = 'console'
|
|
2094
|
+
setNotice({
|
|
2095
|
+
tone: 'ok',
|
|
2096
|
+
title: '一键修复完成',
|
|
2097
|
+
message: `${task.title || task.taskId} 已重新启动 · 端口 ${body.port ?? '—'}`,
|
|
2098
|
+
detail: stepText,
|
|
2099
|
+
actions: [{ label: '打开分身', onClick: () => void openTask({ taskId: task.taskId }) }],
|
|
2100
|
+
})
|
|
2101
|
+
} else {
|
|
2102
|
+
const code = body?.error || (result.status ? 'http-' + result.status : 'network')
|
|
2103
|
+
setNotice({
|
|
2104
|
+
tone: 'bad',
|
|
2105
|
+
title: '一键修复失败',
|
|
2106
|
+
message: failureHint(code),
|
|
2107
|
+
detail: [stepText, body?.detail].filter(Boolean).join(' · ') || diagnosticText(result.diagnostic),
|
|
2108
|
+
})
|
|
2109
|
+
}
|
|
2110
|
+
await refresh()
|
|
2111
|
+
},
|
|
2112
|
+
})
|
|
2113
|
+
}
|
|
2114
|
+
|
|
1949
2115
|
async function deleteArchive(task) {
|
|
1950
2116
|
if (isBusy()) return
|
|
1951
2117
|
askConfirm({
|
|
@@ -2160,19 +2326,60 @@ html[data-fang-overlays="hidden"] .fang-console .toast{display:none!important}
|
|
|
2160
2326
|
doc.body.appendChild(backdrop)
|
|
2161
2327
|
}
|
|
2162
2328
|
|
|
2163
|
-
//
|
|
2164
|
-
|
|
2329
|
+
// 派生弹窗的自动兜底时长(毫秒)。超时未选择 → 默认新建空会话。
|
|
2330
|
+
// 2026-11-21:按用户要求由 5000 调为 7000(5 秒太紧,7 秒足够看清列表)。
|
|
2331
|
+
const DERIVE_PICKER_TIMEOUT_MS = 7000
|
|
2332
|
+
|
|
2333
|
+
// 派生列表复用统一分类:活跃中(7 天内)→ 已归档 → 旧会话(>7 天);
|
|
2334
|
+
// 组内一律按最后活跃时间从新到旧(与母体面板会话列表一致)。
|
|
2335
|
+
function splitSessionsForDerive(sessions, now = Date.now()) {
|
|
2336
|
+
const { active, archived, older } = classifySessionsByRecency(sessions, now)
|
|
2337
|
+
return { recent: active, archived, older }
|
|
2338
|
+
}
|
|
2339
|
+
|
|
2340
|
+
function sessionOption(session) {
|
|
2341
|
+
return h('option', { value: session.sessionId },
|
|
2342
|
+
`${session.title || session.sessionId}${session.workspaceTitle ? ' · ' + session.workspaceTitle : ''}`)
|
|
2343
|
+
}
|
|
2165
2344
|
|
|
2166
2345
|
function showDerivePicker(sessions, essenceName, onPick) {
|
|
2167
2346
|
const doc = document
|
|
2347
|
+
const { recent, archived, older } = splitSessionsForDerive(sessions)
|
|
2348
|
+
// 第 1 组:最近 7 天活跃(未归档)→ 默认展开、可选。
|
|
2168
2349
|
const select = h('select', {
|
|
2169
|
-
size: Math.min(8, Math.max(4,
|
|
2350
|
+
size: Math.min(8, Math.max(4, recent.length)),
|
|
2170
2351
|
style: { width: '100%', minHeight: 150, marginTop: 10, font: '12px/1.4 inherit', borderRadius: 8, padding: 6 },
|
|
2171
|
-
}, ...
|
|
2172
|
-
|
|
2352
|
+
}, ...(recent.length
|
|
2353
|
+
? recent.map(sessionOption)
|
|
2354
|
+
: [h('option', { value: '', disabled: true }, '最近 7 天没有活跃会话(可展开下方分组查看)')]))
|
|
2355
|
+
// 第 2 组:已归档(归档优先于时间)→ 单独折叠、灰色、不可选。
|
|
2356
|
+
const archivedDetails = archived.length
|
|
2357
|
+
? h('details', { 'data-role': 'derive-archived-sessions', style: { marginTop: 8 } },
|
|
2358
|
+
h('summary', { style: { cursor: 'pointer', fontSize: 12, opacity: .55, userSelect: 'none' } },
|
|
2359
|
+
`已归档会话(${archived.length} 个,灰色显示,不可选择)`),
|
|
2360
|
+
h('select', {
|
|
2361
|
+
size: Math.min(6, Math.max(3, archived.length)),
|
|
2362
|
+
disabled: true,
|
|
2363
|
+
'aria-label': '已归档会话(不可选择)',
|
|
2364
|
+
style: { width: '100%', minHeight: 100, marginTop: 8, font: '12px/1.4 inherit', borderRadius: 8, padding: 6, opacity: .55 },
|
|
2365
|
+
}, ...archived.map((session) => h('option', { value: session.sessionId },
|
|
2366
|
+
`${session.title || session.sessionId}${session.workspaceTitle ? ' · ' + session.workspaceTitle : ''} · 已归档`))))
|
|
2367
|
+
: null
|
|
2368
|
+
// 第 3 组:更早(超过 7 天且未归档)→ 折叠、可选。
|
|
2369
|
+
let olderSelect = null
|
|
2370
|
+
const olderDetails = older.length
|
|
2371
|
+
? h('details', { 'data-role': 'derive-older-sessions', style: { marginTop: 8 } },
|
|
2372
|
+
h('summary', { style: { cursor: 'pointer', fontSize: 12, opacity: .75, userSelect: 'none' } },
|
|
2373
|
+
`更早的会话(${older.length} 个,超过 7 天,已折叠)`),
|
|
2374
|
+
(olderSelect = h('select', {
|
|
2375
|
+
size: Math.min(8, Math.max(4, older.length)),
|
|
2376
|
+
'aria-label': '更早的会话(超过 7 天)',
|
|
2377
|
+
style: { width: '100%', minHeight: 120, marginTop: 8, font: '12px/1.4 inherit', borderRadius: 8, padding: 6 },
|
|
2378
|
+
}, ...older.map(sessionOption))))
|
|
2379
|
+
: null
|
|
2173
2380
|
const hint = h('div', { style: { fontSize: 12, opacity: .7, marginTop: 6 } },
|
|
2174
|
-
'
|
|
2175
|
-
//
|
|
2381
|
+
'三分组互斥:最近 7 天活跃(可选)→ 已归档(灰色只读)→ 更早(超过 7 天,折叠)。整目录复制进新分身的沙箱。')
|
|
2382
|
+
// 2026-11-21:7 秒内不选择 → 默认新建空会话继续派生(不再卡住或报 session-required)。
|
|
2176
2383
|
const countdown = h('div', {
|
|
2177
2384
|
style: { fontSize: 12, color: '#F5A623', marginTop: 4 },
|
|
2178
2385
|
'data-role': 'derive-countdown',
|
|
@@ -2196,6 +2403,8 @@ html[data-fang-overlays="hidden"] .fang-console .toast{display:none!important}
|
|
|
2196
2403
|
hint,
|
|
2197
2404
|
countdown,
|
|
2198
2405
|
select,
|
|
2406
|
+
archivedDetails,
|
|
2407
|
+
olderDetails,
|
|
2199
2408
|
h('div', { style: { display: 'flex', gap: 8, marginTop: 14 } }, startBtn, newSessionBtn, cancelBtn))
|
|
2200
2409
|
const backdrop = h('div', {
|
|
2201
2410
|
style: {
|
|
@@ -2231,8 +2440,13 @@ html[data-fang-overlays="hidden"] .fang-console .toast{display:none!important}
|
|
|
2231
2440
|
}
|
|
2232
2441
|
countdown.textContent = `${remaining} 秒内不选择将默认新建空会话`
|
|
2233
2442
|
timer = setInterval(tick, 1000)
|
|
2443
|
+
// 最近列表与「更早的会话」互斥:选一边就清掉另一边的选择。
|
|
2444
|
+
if (olderSelect) {
|
|
2445
|
+
select.addEventListener('change', () => { if (String(select.value || '') !== '') olderSelect.value = '' })
|
|
2446
|
+
olderSelect.addEventListener('change', () => { if (String(olderSelect.value || '') !== '') select.value = '' })
|
|
2447
|
+
}
|
|
2234
2448
|
startBtn.addEventListener('click', () => {
|
|
2235
|
-
const picked = String(select.value || '')
|
|
2449
|
+
const picked = String((olderSelect && olderSelect.value) || select.value || '')
|
|
2236
2450
|
if (!picked) { hint.textContent = '请选择一个会话(或等倒计时结束自动新建空会话)'; return }
|
|
2237
2451
|
settle(picked)
|
|
2238
2452
|
})
|
|
@@ -2269,11 +2483,11 @@ html[data-fang-overlays="hidden"] .fang-console .toast{display:none!important}
|
|
|
2269
2483
|
return
|
|
2270
2484
|
}
|
|
2271
2485
|
S.busy = 'derive:quick:sessions'
|
|
2272
|
-
|
|
2486
|
+
// includeArchived=1:第 2 组「已归档」也要展示(灰色只读),分类在弹窗内完成。
|
|
2487
|
+
const res = await api('/fang/api/sessions?limit=500&includeArchived=1')
|
|
2273
2488
|
S.busy = ''
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
: []
|
|
2489
|
+
// 空会话(无用户消息,宿主侧栏也不显示)不进派生列表。
|
|
2490
|
+
const sessions = Array.isArray(res.body?.sessions) ? res.body.sessions.filter((session) => session?.empty !== true) : []
|
|
2277
2491
|
if (sessions.length === 0) {
|
|
2278
2492
|
setNotice({ tone: 'warn', title: '没有可导入的会话', message: '先在 DSH 里开一个对话,再派生分身。' })
|
|
2279
2493
|
return
|
|
@@ -2313,11 +2527,10 @@ html[data-fang-overlays="hidden"] .fang-console .toast{display:none!important}
|
|
|
2313
2527
|
async function deriveFromEssence(essence) {
|
|
2314
2528
|
if (isBusy()) return
|
|
2315
2529
|
S.busy = 'essence:derive:' + essence.id
|
|
2316
|
-
|
|
2530
|
+
// includeArchived=1:弹窗内三分组(最近活跃/已归档/更早),归档灰色只读;空会话不列。
|
|
2531
|
+
const res = await api('/fang/api/sessions?limit=500&includeArchived=1')
|
|
2317
2532
|
S.busy = ''
|
|
2318
|
-
const sessions = Array.isArray(res.body?.sessions)
|
|
2319
|
-
? res.body.sessions.filter((session) => session.archived !== true)
|
|
2320
|
-
: []
|
|
2533
|
+
const sessions = Array.isArray(res.body?.sessions) ? res.body.sessions.filter((session) => session?.empty !== true) : []
|
|
2321
2534
|
if (sessions.length === 0) {
|
|
2322
2535
|
setNotice({ tone: 'warn', title: '没有可复制的会话', message: '先在 DSH 里有一个进行中的会话,再派生。' })
|
|
2323
2536
|
return
|
|
@@ -2616,25 +2829,126 @@ html[data-fang-overlays="hidden"] .fang-console .toast{display:none!important}
|
|
|
2616
2829
|
void loadEssenceDetail()
|
|
2617
2830
|
}
|
|
2618
2831
|
|
|
2832
|
+
/**
|
|
2833
|
+
* Electron webview does not implement the native prompt(); using it makes
|
|
2834
|
+
* 导出/导入 look completely dead. Use an in-app dialog instead.
|
|
2835
|
+
*/
|
|
2836
|
+
function vaultDialog({ title, label, defaultValue = '', withWorkspace = false }) {
|
|
2837
|
+
return new Promise((resolve) => {
|
|
2838
|
+
const overlay = document.createElement('div')
|
|
2839
|
+
overlay.style.cssText = 'position:fixed;inset:0;z-index:9999;background:rgba(0,0,0,.45);display:flex;align-items:center;justify-content:center;padding:20px'
|
|
2840
|
+
const box = document.createElement('div')
|
|
2841
|
+
box.style.cssText = 'width:min(560px,100%);background:var(--f-surface,#fff);color:var(--f-text,#111);border:1px solid var(--f-line,#d0d7de);border-radius:12px;padding:18px;box-shadow:0 18px 60px rgba(0,0,0,.25);font:14px/1.5 system-ui,sans-serif'
|
|
2842
|
+
const heading = document.createElement('div')
|
|
2843
|
+
heading.textContent = title
|
|
2844
|
+
heading.style.cssText = 'font-weight:700;font-size:16px;margin-bottom:12px'
|
|
2845
|
+
const hint = document.createElement('div')
|
|
2846
|
+
hint.textContent = label
|
|
2847
|
+
hint.style.cssText = 'font-size:12.5px;opacity:.8;margin-bottom:8px'
|
|
2848
|
+
const input = document.createElement('input')
|
|
2849
|
+
input.type = 'text'
|
|
2850
|
+
input.value = defaultValue
|
|
2851
|
+
input.placeholder = 'D:\\backup\\fang'
|
|
2852
|
+
input.style.cssText = 'width:100%;box-sizing:border-box;padding:9px 10px;border:1px solid var(--f-line,#d0d7de);border-radius:8px;background:transparent;color:inherit;font:inherit'
|
|
2853
|
+
const workspaceLine = document.createElement('label')
|
|
2854
|
+
workspaceLine.style.cssText = 'display:flex;gap:8px;align-items:flex-start;margin-top:12px;font-size:12.5px'
|
|
2855
|
+
const workspace = document.createElement('input')
|
|
2856
|
+
workspace.type = 'checkbox'
|
|
2857
|
+
workspace.checked = false
|
|
2858
|
+
const workspaceText = document.createElement('span')
|
|
2859
|
+
workspaceText.textContent = '同时打包工作区项目文件(默认不勾选;项目很大时会明显变慢)'
|
|
2860
|
+
workspaceLine.append(workspace, workspaceText)
|
|
2861
|
+
const actions = document.createElement('div')
|
|
2862
|
+
actions.style.cssText = 'display:flex;justify-content:flex-end;gap:8px;margin-top:16px'
|
|
2863
|
+
const cancel = document.createElement('button')
|
|
2864
|
+
cancel.type = 'button'
|
|
2865
|
+
cancel.textContent = '取消'
|
|
2866
|
+
cancel.style.cssText = 'padding:7px 14px;border:1px solid var(--f-line,#d0d7de);border-radius:7px;background:transparent;color:inherit;cursor:pointer'
|
|
2867
|
+
const ok = document.createElement('button')
|
|
2868
|
+
ok.type = 'button'
|
|
2869
|
+
ok.textContent = '确定'
|
|
2870
|
+
ok.style.cssText = 'padding:7px 14px;border:0;border-radius:7px;background:#2563eb;color:#fff;cursor:pointer'
|
|
2871
|
+
actions.append(cancel, ok)
|
|
2872
|
+
box.append(heading, hint, input)
|
|
2873
|
+
if (withWorkspace) box.append(workspaceLine)
|
|
2874
|
+
box.append(actions)
|
|
2875
|
+
overlay.append(box)
|
|
2876
|
+
const close = (value) => {
|
|
2877
|
+
overlay.remove()
|
|
2878
|
+
document.removeEventListener('keydown', onKey)
|
|
2879
|
+
resolve(value)
|
|
2880
|
+
}
|
|
2881
|
+
const onKey = (event) => {
|
|
2882
|
+
if (event.key === 'Escape') close(null)
|
|
2883
|
+
if (event.key === 'Enter' && document.activeElement === input) close({ value: input.value.trim(), workspace: workspace.checked })
|
|
2884
|
+
}
|
|
2885
|
+
cancel.addEventListener('click', () => close(null))
|
|
2886
|
+
ok.addEventListener('click', () => close({ value: input.value.trim(), workspace: workspace.checked }))
|
|
2887
|
+
overlay.addEventListener('click', (event) => { if (event.target === overlay) close(null) })
|
|
2888
|
+
document.addEventListener('keydown', onKey)
|
|
2889
|
+
document.body.appendChild(overlay)
|
|
2890
|
+
input.focus()
|
|
2891
|
+
input.select()
|
|
2892
|
+
})
|
|
2893
|
+
}
|
|
2894
|
+
|
|
2895
|
+
async function exportTask(task) {
|
|
2896
|
+
const taskId = String(task?.taskId ?? '')
|
|
2897
|
+
if (!taskId) return
|
|
2898
|
+
const fallback = localStorage.getItem('fang.exportDir') || ''
|
|
2899
|
+
const answer = await vaultDialog({
|
|
2900
|
+
title: '导出分身',
|
|
2901
|
+
label: '导出到文件夹(绝对路径;不存在会自动创建)',
|
|
2902
|
+
defaultValue: fallback,
|
|
2903
|
+
withWorkspace: true,
|
|
2904
|
+
})
|
|
2905
|
+
if (!answer?.value) return
|
|
2906
|
+
const destDir = answer.value
|
|
2907
|
+
const workspace = answer.workspace === true
|
|
2908
|
+
localStorage.setItem('fang.exportDir', destDir)
|
|
2909
|
+
const result = await api('/fang/api/vault/export', { method: 'POST', body: JSON.stringify({ taskId, destDir, options: { workspace, workspaceSnapshot: workspace } }) })
|
|
2910
|
+
if (result.status === 200 && result.body?.ok) {
|
|
2911
|
+
notify('ok', `已导出到 ${result.body.dir}`, `文件 ${result.body.files} 个 · ${result.body.bytes} 字节`)
|
|
2912
|
+
} else {
|
|
2913
|
+
notify('bad', `导出失败:${result.body?.error || 'export-failed'}`, result.body?.detail || '')
|
|
2914
|
+
}
|
|
2915
|
+
}
|
|
2916
|
+
|
|
2917
|
+
async function importTask() {
|
|
2918
|
+
const answer = await vaultDialog({
|
|
2919
|
+
title: '导入分身',
|
|
2920
|
+
label: '选择导出包文件夹(包含 manifest.json 的那一层)',
|
|
2921
|
+
defaultValue: localStorage.getItem('fang.importDir') || '',
|
|
2922
|
+
})
|
|
2923
|
+
if (!answer?.value) return
|
|
2924
|
+
const sourceDir = answer.value
|
|
2925
|
+
localStorage.setItem('fang.importDir', sourceDir)
|
|
2926
|
+
const result = await api('/fang/api/vault/import', { method: 'POST', body: JSON.stringify({ sourceDir }) })
|
|
2927
|
+
if (result.status === 200 && result.body?.ok) {
|
|
2928
|
+
notify('ok', `已导入分身 ${result.body.title || result.body.taskId}`, `端口 ${result.body.restored?.port ?? '—'}`)
|
|
2929
|
+
await refresh()
|
|
2930
|
+
} else {
|
|
2931
|
+
notify('bad', `导入失败:${result.body?.error || 'import-failed'}`, result.body?.detail || '')
|
|
2932
|
+
}
|
|
2933
|
+
}
|
|
2934
|
+
|
|
2935
|
+
// 独立 Vault 子插件通过此桥触发导出/导入(按钮由 vault/client.js 注入)。
|
|
2936
|
+
try { window.__fangVaultBridge = { exportTask, importTask } } catch { /* ignore */ }
|
|
2937
|
+
|
|
2619
2938
|
async function openTask(task) {
|
|
2620
2939
|
const taskId = String(task?.taskId ?? '')
|
|
2621
2940
|
if (!taskId) { notify('warn', '该分身没有 taskId,无法打开。'); return }
|
|
2622
|
-
|
|
2941
|
+
// v3.7.4:打开是显式用户动作,用 POST 触发同步;GET 只读,避免副作用。
|
|
2942
|
+
const result = await api('/fang/api/tasks/open', { method: 'POST', body: JSON.stringify({ taskId }) })
|
|
2623
2943
|
if (result.status === 200 && result.body?.url) {
|
|
2624
2944
|
try { window.open(result.body.url, '_blank', 'noopener'); return } catch { /* 弹层被拦 */ }
|
|
2625
2945
|
}
|
|
2626
2946
|
const code = result.body?.error || (result.status ? 'http-' + result.status : 'network')
|
|
2627
2947
|
if (code === 'not-running') {
|
|
2628
2948
|
notify('warn', '分身已停止,正在启动…')
|
|
2629
|
-
|
|
2630
|
-
//
|
|
2631
|
-
|
|
2632
|
-
if (restored.body?.error === 'not-archived' && String(task?.status || '') !== 'running') {
|
|
2633
|
-
const archived = await api('/fang/api/tasks/archive', { method: 'POST', body: JSON.stringify({ taskId }) })
|
|
2634
|
-
if (archived.status === 200 && archived.body?.ok !== false) {
|
|
2635
|
-
restored = await api('/fang/api/tasks/restore', { method: 'POST', body: JSON.stringify({ taskId }) })
|
|
2636
|
-
}
|
|
2637
|
-
}
|
|
2949
|
+
// 2026-11-22:服务端 restoreTask 直接接受 failed/archived 任务;不再“先归档再还原”。
|
|
2950
|
+
// 旧逻辑会把启动失败的任务强制归档(用户报告:无法还原 + 被自动归档)。
|
|
2951
|
+
const restored = await api('/fang/api/tasks/restore', { method: 'POST', body: JSON.stringify({ taskId }) })
|
|
2638
2952
|
if (restored.status !== 200 || restored.body?.ok === false) {
|
|
2639
2953
|
notify('bad', `启动分身失败:${restored.body?.error || 'restore-failed'}`)
|
|
2640
2954
|
return
|
|
@@ -2796,6 +3110,67 @@ html[data-fang-overlays="hidden"] .fang-console .toast{display:none!important}
|
|
|
2796
3110
|
if (S.link.state === 'idle') void loadLink()
|
|
2797
3111
|
}
|
|
2798
3112
|
|
|
3113
|
+
// v3.3.6:重启母体 = 红色风险 + 分身预确认 + 二次点击,缺一不放行。
|
|
3114
|
+
async function openRestartDialog() {
|
|
3115
|
+
lockScroll()
|
|
3116
|
+
S.modal = {
|
|
3117
|
+
kind: 'restart', loading: true, view: null, impact: null, forkChecked: false, busy: false, error: '',
|
|
3118
|
+
forkId: null, returnFk: document.activeElement?.getAttribute?.('data-fk') || '',
|
|
3119
|
+
}
|
|
3120
|
+
render(true)
|
|
3121
|
+
const [view, impact] = await Promise.all([
|
|
3122
|
+
api('/fang/api/restart'),
|
|
3123
|
+
api('/fang/api/restart/impact'),
|
|
3124
|
+
])
|
|
3125
|
+
if (!S.modal || S.modal.kind !== 'restart') return
|
|
3126
|
+
S.modal.loading = false
|
|
3127
|
+
S.modal.view = view.body ?? null
|
|
3128
|
+
S.modal.impact = impact.body ?? null
|
|
3129
|
+
S.modal.error = view.status === 200 ? '' : (view.body?.error || 'restart-unavailable')
|
|
3130
|
+
const live = (S.status?.data?.tasks?.list || []).filter((t) => String(t.status) === 'running' || String(t.status) === 'ready')
|
|
3131
|
+
S.modal.forkId = live[0]?.taskId ?? null
|
|
3132
|
+
render(true)
|
|
3133
|
+
}
|
|
3134
|
+
|
|
3135
|
+
async function submitRestart() {
|
|
3136
|
+
const modal = S.modal
|
|
3137
|
+
if (!modal || modal.kind !== 'restart' || modal.busy) return
|
|
3138
|
+
if (modal.forkChecked !== true) {
|
|
3139
|
+
modal.error = '请先在分身确认影响,再点击二次确认。'
|
|
3140
|
+
render(true)
|
|
3141
|
+
return
|
|
3142
|
+
}
|
|
3143
|
+
modal.busy = true
|
|
3144
|
+
modal.error = ''
|
|
3145
|
+
render(true)
|
|
3146
|
+
const res = await api('/fang/api/restart/request', {
|
|
3147
|
+
method: 'POST',
|
|
3148
|
+
body: JSON.stringify({
|
|
3149
|
+
reason: 'fang-panel-manual',
|
|
3150
|
+
confirmation: { forkChecked: true, finalConfirm: true, forkId: modal.forkId, at: Date.now() },
|
|
3151
|
+
}),
|
|
3152
|
+
})
|
|
3153
|
+
modal.busy = false
|
|
3154
|
+
if (res.status !== 200 || res.body?.ok === false) {
|
|
3155
|
+
modal.error = res.body?.detail || res.body?.error || ('http-' + res.status)
|
|
3156
|
+
render(true)
|
|
3157
|
+
return
|
|
3158
|
+
}
|
|
3159
|
+
const out = res.body ?? {}
|
|
3160
|
+
closeModal()
|
|
3161
|
+
const handoff = out.execution?.handoff?.requested === true
|
|
3162
|
+
const executed = out.execution?.executed === true
|
|
3163
|
+
setNotice({
|
|
3164
|
+
tone: handoff ? 'bad' : 'warn',
|
|
3165
|
+
title: handoff ? '已放行:等待 supervisor 重启宿主' : '已红色审批放行(未武装)',
|
|
3166
|
+
message: handoff
|
|
3167
|
+
? '守卫已写授权清单并准备退出 75;外部 supervisor 会拉起新宿主。'
|
|
3168
|
+
: `当前 guardMode=${out.execution?.guardMode ?? 'observe'}、allowProcessRestart=${out.execution?.allowProcessRestart === true}。不会自动退出/重启宿主;先启动 supervisor 再武装。`,
|
|
3169
|
+
detail: executed ? 'execution.executed=true' : (out.authorization?.manifestPath ? 'manifest: ' + out.authorization.manifestPath : ''),
|
|
3170
|
+
})
|
|
3171
|
+
await refresh()
|
|
3172
|
+
}
|
|
3173
|
+
|
|
2799
3174
|
// ── 键盘:浮窗 Esc / Tab 焦点陷阱;编辑 Enter/Esc 在输入元素上处理 ──────
|
|
2800
3175
|
function onRootKeydown(event) {
|
|
2801
3176
|
if (!S.modal) return
|
|
@@ -2954,7 +3329,8 @@ html[data-fang-overlays="hidden"] .fang-console .toast{display:none!important}
|
|
|
2954
3329
|
|
|
2955
3330
|
const app = {
|
|
2956
3331
|
state: S, view, render, schedule, refresh, deriveTask, openMother, closeModal,
|
|
2957
|
-
|
|
3332
|
+
openRestartDialog, submitRestart,
|
|
3333
|
+
archiveTask, restoreTask, startTask, repairTask, deleteArchive, promoteTask, openTask, copyText, captureEssence,
|
|
2958
3334
|
cloneMotherProfile, syncEssence, syncEssences, setSessionWindow, essenceRuntime,
|
|
2959
3335
|
decideApproval,
|
|
2960
3336
|
setForkSupervision,
|
|
@@ -3274,6 +3650,42 @@ html[data-fang-overlays="hidden"] .fang-console .toast{display:none!important}
|
|
|
3274
3650
|
fk: 'overlay-toggle', dataBtnId: 'M-07',
|
|
3275
3651
|
})
|
|
3276
3652
|
})(),
|
|
3653
|
+
(() => {
|
|
3654
|
+
const fc = S.forkCore?.data ?? null
|
|
3655
|
+
const mode = fc?.mode === 'accelerated' ? 'accelerated' : 'stock'
|
|
3656
|
+
const next = mode === 'accelerated' ? 'stock' : 'accelerated'
|
|
3657
|
+
const installed = fc?.accelerated?.installed === true
|
|
3658
|
+
return button(mode === 'accelerated' ? '分身Core核心加速引擎:一键加速' : '分身Core核心加速引擎:官方', {
|
|
3659
|
+
variant: mode === 'accelerated' ? 'primary' : 'quiet', size: 'sm', icon: icon('power', 14),
|
|
3660
|
+
title: installed
|
|
3661
|
+
? '当前:' + (mode === 'accelerated' ? '一键加速' : '官方') + '。非热更新:切换后需重新打开分身 Web(或重新派生)才生效;母体与元主始终官方 core。'
|
|
3662
|
+
: '加速核未安装:' + (fc?.accelerated?.error ?? 'accelerated-cli-missing'),
|
|
3663
|
+
onClick: async () => {
|
|
3664
|
+
if (next === 'accelerated' && !installed) {
|
|
3665
|
+
app.notify('warn', '分身Core核心加速引擎:加速核未安装(' + (fc?.accelerated?.error ?? 'accelerated-cli-missing') + '),设置未改变')
|
|
3666
|
+
return
|
|
3667
|
+
}
|
|
3668
|
+
try {
|
|
3669
|
+
const res = await api('/fang/api/fork-core', { method: 'POST', body: JSON.stringify({ mode: next }) })
|
|
3670
|
+
if (res.status === 200 && res.body?.ok !== false) {
|
|
3671
|
+
S.forkCore = { state: 'ready', data: res.body, error: '', at: Date.now() }
|
|
3672
|
+
app.notify('ok', '分身Core核心加速引擎:已切换为「' + (next === 'accelerated' ? '一键加速' : '官方') + '」· 重新打开分身 Web 生效')
|
|
3673
|
+
app.render(true)
|
|
3674
|
+
} else {
|
|
3675
|
+
app.notify('warn', '分身Core核心加速引擎:' + (res.body?.error ?? '切换失败'))
|
|
3676
|
+
}
|
|
3677
|
+
} catch (error) { app.notify('warn', '分身Core核心加速引擎:' + String(error?.message ?? error)) }
|
|
3678
|
+
},
|
|
3679
|
+
fk: 'fork-core', dataBtnId: 'M-09',
|
|
3680
|
+
})
|
|
3681
|
+
})(),
|
|
3682
|
+
restart?.available
|
|
3683
|
+
? button('重启母体', {
|
|
3684
|
+
variant: 'danger-quiet', size: 'sm', icon: icon('power', 14),
|
|
3685
|
+
title: '红色风险:先看影响 → 在分身确认 → 二次确认后放行(不会在无 supervisor 时偷偷退出)',
|
|
3686
|
+
onClick: () => void app.openRestartDialog(), fk: 'restart', dataBtnId: 'M-08',
|
|
3687
|
+
})
|
|
3688
|
+
: null,
|
|
3277
3689
|
button('收件箱', {
|
|
3278
3690
|
variant: 'ghost', size: 'sm', icon: icon('inbox', 14),
|
|
3279
3691
|
title: '决策收件箱:独立抽屉;红/黄/蓝/绿/灰分组、未读计数、键盘导航与批量处理',
|
|
@@ -3322,7 +3734,16 @@ html[data-fang-overlays="hidden"] .fang-console .toast{display:none!important}
|
|
|
3322
3734
|
// ── 全局提示(派生结果 / 动作结果 / 接口错误)───────────────────────────
|
|
3323
3735
|
// 待批区:只读母体聚合接口;不直接跨 fork adapter
|
|
3324
3736
|
// 瓮城·决策中心:注意力分级面板。红色置顶;绿/灰默认折叠;所有操作等接口返回。
|
|
3737
|
+
// v3.3.3:子插件能力门控。status.services 是宿主实际提供的服务快照;
|
|
3738
|
+
// 缺失/未激活时对应 UI 不绘制(功能路由也会由 orchestrator fail-closed)。
|
|
3739
|
+
function serviceEnabled(S, key) {
|
|
3740
|
+
const services = S?.status?.data?.services
|
|
3741
|
+
if (!services || typeof services !== 'object') return true // 状态未返回时不误隐藏
|
|
3742
|
+
return services[key] !== false
|
|
3743
|
+
}
|
|
3744
|
+
|
|
3325
3745
|
function renderApprovals(S, app) {
|
|
3746
|
+
if (!serviceEnabled(S, 'approver')) return []
|
|
3326
3747
|
const state = S.approvals || { state: 'idle', items: [], failed: [], degraded: false, error: '' }
|
|
3327
3748
|
if (state.state === 'error' && state.items.length === 0) {
|
|
3328
3749
|
return [h('div', { class: 'notice notice--warn', role: 'status' },
|
|
@@ -3506,6 +3927,7 @@ html[data-fang-overlays="hidden"] .fang-console .toast{display:none!important}
|
|
|
3506
3927
|
const visible = filtered.filter((session) => session?.empty !== true)
|
|
3507
3928
|
const groups = groupMotherWorkspaces(visible, S.aliases)
|
|
3508
3929
|
const split = classifyMotherSessions(visible)
|
|
3930
|
+
const sessionGroups = classifySessionsByRecency(visible)
|
|
3509
3931
|
const selected = all.find((session) => String(session.sessionId) === S.selectedSessionId) || null
|
|
3510
3932
|
const countText = query
|
|
3511
3933
|
? `${visible.length}/${all.length}`
|
|
@@ -3571,7 +3993,7 @@ html[data-fang-overlays="hidden"] .fang-console .toast{display:none!important}
|
|
|
3571
3993
|
onkeydown: (event) => { if (event.key === 'Escape' && S.query) { event.preventDefault(); S.query = ''; app.schedule(true) } },
|
|
3572
3994
|
})),
|
|
3573
3995
|
h('div', { class: 'panel-tools' },
|
|
3574
|
-
h('span', null,
|
|
3996
|
+
h('span', null, `活跃中(7 天) ${sessionGroups.active.length}`),
|
|
3575
3997
|
h('span', { class: 'spacer' }),
|
|
3576
3998
|
h('span', { class: 'session-window', 'data-zone': 'session-window', style: { display: 'inline-flex', alignItems: 'center', gap: 4 } },
|
|
3577
3999
|
h('span', { class: 'hint' }, '显示'),
|
|
@@ -3592,7 +4014,7 @@ html[data-fang-overlays="hidden"] .fang-console .toast{display:none!important}
|
|
|
3592
4014
|
}, label)
|
|
3593
4015
|
})),
|
|
3594
4016
|
h('span', { class: 'spacer' }),
|
|
3595
|
-
h('span', null,
|
|
4017
|
+
h('span', null, `已归档 ${sessionGroups.archived.length} · 旧会话 ${sessionGroups.older.length}`),
|
|
3596
4018
|
h('span', { title: '没有写接口的动作会明确禁用并说明原因,不会假装成功' }, '只读')))
|
|
3597
4019
|
|
|
3598
4020
|
const scroll = h('div', { class: 'panel-scroll', 'data-sk': 'left' })
|
|
@@ -3692,12 +4114,14 @@ html[data-fang-overlays="hidden"] .fang-console .toast{display:none!important}
|
|
|
3692
4114
|
onClick: () => app.toggleSet('mother:' + group.key),
|
|
3693
4115
|
}, icon('chevron', !open, 16)))
|
|
3694
4116
|
|
|
4117
|
+
// 2026-11-21:分类先于排序(活跃中 7 天 / 已归档 / 旧会话),分类内按最后活跃时间倒序。
|
|
4118
|
+
const categories = classifySessionsByRecency(sessions)
|
|
3695
4119
|
const meta = h('div', { class: 'mother-meta' },
|
|
3696
4120
|
h('span', null, `${group.count} 个会话`),
|
|
3697
4121
|
h('span', { 'aria-hidden': 'true' }, '·'),
|
|
3698
|
-
h('span', null,
|
|
3699
|
-
|
|
3700
|
-
|
|
4122
|
+
h('span', null, `活跃 ${categories.active.length} · 归档 ${categories.archived.length} · 旧 ${categories.older.length}`),
|
|
4123
|
+
h('span', { 'aria-hidden': 'true' }, '·'),
|
|
4124
|
+
h('span', null, `更新 ${fmtShortClock(group.latestAt)}`))
|
|
3701
4125
|
|
|
3702
4126
|
const row = h('div', { class: 'mother-row' + (open ? ' is-open' : ''), role: 'listitem', 'data-mother': group.key },
|
|
3703
4127
|
h('div', { class: 'mother-main' },
|
|
@@ -3712,8 +4136,21 @@ html[data-fang-overlays="hidden"] .fang-console .toast{display:none!important}
|
|
|
3712
4136
|
function renderMotherSessions(S, app, group, selectedSession) {
|
|
3713
4137
|
const wrap = h('div', { class: 'sessions', id: 'mother-sessions-' + group.key, role: 'group', 'aria-label': `元主 ${group.title} 的会话` })
|
|
3714
4138
|
const allOpen = S.expanded.has('mother-all:' + group.key)
|
|
3715
|
-
|
|
3716
|
-
|
|
4139
|
+
// 2026-11-21:先分类(活跃中 7 天 / 已归档 / 旧会话 >7 天),分类内按最后活跃时间从新到旧。
|
|
4140
|
+
const grouped = classifySessionsByRecency(group.sessions)
|
|
4141
|
+
const ordered = []
|
|
4142
|
+
for (const category of SESSION_GROUP_ORDER) {
|
|
4143
|
+
for (const session of grouped[category]) ordered.push({ session, category })
|
|
4144
|
+
}
|
|
4145
|
+
const limit = allOpen ? ordered.length : Math.min(ACTIVE_SESSION_LIMIT, ordered.length)
|
|
4146
|
+
let lastCategory = ''
|
|
4147
|
+
for (const { session, category } of ordered.slice(0, limit)) {
|
|
4148
|
+
if (category !== lastCategory) {
|
|
4149
|
+
lastCategory = category
|
|
4150
|
+
wrap.append(h('div', { class: 'session-group-head', 'data-category': category, role: 'presentation' },
|
|
4151
|
+
h('span', null, SESSION_GROUP_LABELS[category]),
|
|
4152
|
+
h('span', { class: 'session-group-count' }, `${grouped[category].length}`)))
|
|
4153
|
+
}
|
|
3717
4154
|
const info = sessionTitleInfo(session)
|
|
3718
4155
|
const isSelected = String(session.sessionId) === String(selectedSession?.sessionId ?? '')
|
|
3719
4156
|
wrap.append(h('button', {
|
|
@@ -3721,6 +4158,7 @@ html[data-fang-overlays="hidden"] .fang-console .toast{display:none!important}
|
|
|
3721
4158
|
class: 'session-row' + (isSelected ? ' is-selected' : ''),
|
|
3722
4159
|
title: sessionTooltip(session),
|
|
3723
4160
|
'data-fk': 'session:' + session.sessionId,
|
|
4161
|
+
'data-category': category,
|
|
3724
4162
|
'aria-pressed': isSelected ? 'true' : 'false',
|
|
3725
4163
|
onClick: () => app.selectSession(session),
|
|
3726
4164
|
},
|
|
@@ -3735,11 +4173,11 @@ html[data-fang-overlays="hidden"] .fang-console .toast{display:none!important}
|
|
|
3735
4173
|
isSelected ? chip('info', '已选', { dot: false }) : null)))
|
|
3736
4174
|
}
|
|
3737
4175
|
|
|
3738
|
-
if (!allOpen &&
|
|
4176
|
+
if (!allOpen && ordered.length > limit) {
|
|
3739
4177
|
wrap.append(h('button', {
|
|
3740
4178
|
type: 'button', class: 'text-action session-more',
|
|
3741
4179
|
onClick: () => app.toggleSet('mother-all:' + group.key),
|
|
3742
|
-
}, `显示其余 ${
|
|
4180
|
+
}, `显示其余 ${ordered.length - limit} 条会话`))
|
|
3743
4181
|
}
|
|
3744
4182
|
|
|
3745
4183
|
if (selectedSession && group.sessions.some((session) => session.sessionId === selectedSession.sessionId)) {
|
|
@@ -3951,7 +4389,7 @@ html[data-fang-overlays="hidden"] .fang-console .toast{display:none!important}
|
|
|
3951
4389
|
},
|
|
3952
4390
|
}, icon('arrowUp', 15))),
|
|
3953
4391
|
h('div', { class: 'panel-tools' },
|
|
3954
|
-
h('span', null, `进行中 ${active.length}`),
|
|
4392
|
+
h('span', null, `进行中 ${active.filter((item) => !['failed', 'stopped', 'archived'].includes(String(item.status))).length}`),
|
|
3955
4393
|
h('span', { class: 'spacer' }),
|
|
3956
4394
|
h('span', null, `临时 ${temporary.length} · 存档 ${archived.length}`),
|
|
3957
4395
|
h('span', { class: 'spacer' }),
|
|
@@ -3959,7 +4397,6 @@ html[data-fang-overlays="hidden"] .fang-console .toast{display:none!important}
|
|
|
3959
4397
|
renderCapacityStrip(cap))
|
|
3960
4398
|
|
|
3961
4399
|
const scroll = h('div', { class: 'panel-scroll', 'data-sk': 'right' })
|
|
3962
|
-
scroll.append(renderDecisionMini())
|
|
3963
4400
|
|
|
3964
4401
|
if (S.tasks.state === 'loading' && all.length === 0) {
|
|
3965
4402
|
scroll.append(h('div', { class: 'loading-line' }, icon('spinner', 14), '正在读取分身任务…'))
|
|
@@ -4038,6 +4475,8 @@ html[data-fang-overlays="hidden"] .fang-console .toast{display:none!important}
|
|
|
4038
4475
|
const sessionsState = S.forkSessions.get(taskId)
|
|
4039
4476
|
const busyArchive = S.busy === 'archive:' + taskId
|
|
4040
4477
|
const busyRestore = S.busy === 'restore:' + taskId
|
|
4478
|
+
const busyStart = S.busy === 'start:' + taskId
|
|
4479
|
+
const busyRepair = S.busy === 'repair:' + taskId
|
|
4041
4480
|
const busyDelete = S.busy === 'delete:' + taskId
|
|
4042
4481
|
const busyPromote = S.busy === 'promote:' + taskId
|
|
4043
4482
|
const barTone = health.tone
|
|
@@ -4086,6 +4525,7 @@ html[data-fang-overlays="hidden"] .fang-console .toast{display:none!important}
|
|
|
4086
4525
|
chip(health.tone, health.label, { state: health.phase, danger: health.tone === 'bad' && health.anomaly }),
|
|
4087
4526
|
archived ? null : chip(health.adapterTone, health.adapterLabel, { health: health.adapter }),
|
|
4088
4527
|
task.importedSession ? chip('info', '已导入会话', { title: '派生时导入了母体会话历史/摘要' }) : null,
|
|
4528
|
+
task.sessions?.violation ? chip('warn', `会话 ${task.sessions.count}/${task.sessions.max} 超限`, { title: '分身会话超过上限;打开/修复不会再自动搬移,需手动归档或 enforce' }) : null,
|
|
4089
4529
|
task.essenceDeleted ? chip('warn', '原身已删除(仅运行/归档)', { title: '来源原身已删除:不能再从该原身派生,但本分身可继续运行/归档/还原/删除' }) : null)),
|
|
4090
4530
|
h('div', { class: 'fork-actions' },
|
|
4091
4531
|
archived
|
|
@@ -4111,6 +4551,18 @@ html[data-fang-overlays="hidden"] .fang-console .toast{display:none!important}
|
|
|
4111
4551
|
onClick: () => void app.openBranches(task),
|
|
4112
4552
|
fk: 'branches:' + taskId,
|
|
4113
4553
|
}),
|
|
4554
|
+
button('导出', {
|
|
4555
|
+
size: 'sm', variant: 'ghost', dataBtnId: 'C-08',
|
|
4556
|
+
title: '导出该分身为 Vault 文件夹(可选工作区快照)',
|
|
4557
|
+
onClick: () => void exportTask(task),
|
|
4558
|
+
fk: 'export:' + taskId,
|
|
4559
|
+
}),
|
|
4560
|
+
button('导入', {
|
|
4561
|
+
size: 'sm', variant: 'ghost', dataBtnId: 'C-09',
|
|
4562
|
+
title: '从 Vault 文件夹导入为新分身,并重新移植依赖',
|
|
4563
|
+
onClick: () => void importTask(),
|
|
4564
|
+
fk: 'import:' + taskId,
|
|
4565
|
+
}),
|
|
4114
4566
|
textAction('提升插件', { title: '把分身里验证过的插件目录提升到母体(需目录名)', dataBtnId: 'C-02',
|
|
4115
4567
|
softDisabled: busyPromote, busy: busyPromote,
|
|
4116
4568
|
onClick: () => app.promoteTask(task),
|
|
@@ -4124,10 +4576,39 @@ html[data-fang-overlays="hidden"] .fang-console .toast{display:none!important}
|
|
|
4124
4576
|
const meta = h('div', { class: 'fork-meta' },
|
|
4125
4577
|
h('code', { title: '任务 ID:' + taskId }, short(taskId, 12)),
|
|
4126
4578
|
h('span', null, '端口 ' + (task.port ? String(task.port) : '—')),
|
|
4579
|
+
task.coreMode === 'accelerated'
|
|
4580
|
+
? h('span', { 'data-core': 'accelerated', title: '该分身运行在加速核(@twinsearth/dsh)上', style: { color: 'var(--f-blue, #2563eb)', fontWeight: '600' } }, '加速核')
|
|
4581
|
+
: null,
|
|
4127
4582
|
task.pid ? h('span', null, 'PID ' + String(task.pid)) : null,
|
|
4128
4583
|
h('span', null, '创建 ' + fmtShortClock(task.createdAt)),
|
|
4129
4584
|
health.adapter === 'error' ? h('span', { style: { color: 'var(--f-red)' }, 'data-danger': '1' }, '适配器失联') : null)
|
|
4130
4585
|
|
|
4586
|
+
// 2026-11-22:分身状态栏(4 态 + 2 操作)——折叠时也可见。
|
|
4587
|
+
const stateView = forkStateOf(task)
|
|
4588
|
+
const statusBar = h('div', {
|
|
4589
|
+
class: 'fork-status',
|
|
4590
|
+
'data-state': stateView.key,
|
|
4591
|
+
'data-tone': stateView.tone,
|
|
4592
|
+
role: 'status',
|
|
4593
|
+
'aria-label': `分身状态:${stateView.label}`,
|
|
4594
|
+
},
|
|
4595
|
+
h('span', { class: 'fork-status-dot', 'aria-hidden': 'true' }),
|
|
4596
|
+
h('span', { class: 'fork-status-label' }, stateView.label),
|
|
4597
|
+
stateView.hint ? h('span', { class: 'fork-status-hint' }, stateView.hint) : null,
|
|
4598
|
+
h('div', { class: 'fork-status-actions' },
|
|
4599
|
+
stateView.key === 'running' ? null : button('启动', {
|
|
4600
|
+
size: 'sm', variant: 'ghost', icon: icon('play', 12), busy: busyStart, dataBtnId: 'C-08',
|
|
4601
|
+
title: '启动这个分身(新端口、新 token;不丢会话)',
|
|
4602
|
+
onClick: () => void app.startTask(task),
|
|
4603
|
+
fk: 'start:' + taskId,
|
|
4604
|
+
}),
|
|
4605
|
+
button('一键修复', {
|
|
4606
|
+
size: 'sm', variant: 'ghost', icon: icon('refresh', 12), busy: busyRepair, dataBtnId: 'C-09',
|
|
4607
|
+
title: '停残留 → 清加速别名桩 → 按来源重置配置 → 重新拉起;不删除 home/会话',
|
|
4608
|
+
onClick: () => void app.repairTask(task),
|
|
4609
|
+
fk: 'repair:' + taskId,
|
|
4610
|
+
})))
|
|
4611
|
+
|
|
4131
4612
|
const bodyWrap = h('div', { id: 'task-body-' + taskId, hidden: folded })
|
|
4132
4613
|
bodyWrap.append(h('div', { class: 'fork-info', 'data-zone': 'task-info', style: { display: 'flex', gap: '10px', flexWrap: 'wrap', fontSize: '12px', opacity: '.85' } },
|
|
4133
4614
|
h('span', null, '对话 ' + (task.sessionTitle || '—')),
|
|
@@ -4135,7 +4616,7 @@ html[data-fang-overlays="hidden"] .fang-console .toast{display:none!important}
|
|
|
4135
4616
|
h('span', null, '更新 ' + fmtShortClock(task.updatedAt)),
|
|
4136
4617
|
h('span', null, '体积 ' + formatBytes(task.projectBytes))))
|
|
4137
4618
|
bodyWrap.append(meta)
|
|
4138
|
-
card.append(head, bodyWrap)
|
|
4619
|
+
card.append(head, statusBar, bodyWrap)
|
|
4139
4620
|
|
|
4140
4621
|
if (health.anomaly) {
|
|
4141
4622
|
bodyWrap.append(h('div', { class: 'fork-warn', role: 'note' },
|
|
@@ -4507,6 +4988,67 @@ html[data-fang-overlays="hidden"] .fang-console .toast{display:none!important}
|
|
|
4507
4988
|
}
|
|
4508
4989
|
|
|
4509
4990
|
// ── 确认 / 输入 浮窗 ─────────────────────────────────────────────────
|
|
4991
|
+
// v3.3.6: 红色重启风险 + 分身预确认 + 二次点击。
|
|
4992
|
+
function renderRestartModal(S, app) {
|
|
4993
|
+
const modal = S.modal
|
|
4994
|
+
const state = modal.view?.state || {}
|
|
4995
|
+
const impact = modal.impact?.impact || {}
|
|
4996
|
+
const tasks = Array.isArray(S.status?.data?.tasks?.list) ? S.status.data.tasks.list : []
|
|
4997
|
+
const liveForks = tasks.filter((task) => String(task.status) === 'running' || String(task.status) === 'ready')
|
|
4998
|
+
const armed = state.executionArmed === true || modal.impact?.executionArmed === true
|
|
4999
|
+
const supervisor = state.supervisorPresent === true || modal.impact?.supervisorPresent === true
|
|
5000
|
+
const canConfirm = modal.forkChecked === true && liveForks.length > 0 && !modal.busy && !modal.loading
|
|
5001
|
+
return h('div', { class: 'overlay', 'data-overlay': '1', onClick: (event) => { if (event.target === event.currentTarget) app.closeModal() } },
|
|
5002
|
+
h('div', { class: 'glass', role: 'alertdialog', 'aria-modal': 'true', 'aria-labelledby': 'fang-restart-title', 'data-restart-confirm': '1' },
|
|
5003
|
+
h('div', { class: 'glass-head' },
|
|
5004
|
+
h('div', { class: 'glass-head-main' },
|
|
5005
|
+
h('div', { class: 'glass-title', id: 'fang-restart-title' }, icon('power', 18), '重启母体 · 红色风险'),
|
|
5006
|
+
h('div', { class: 'glass-sub' }, '第一步:在分身确认影响;第二步:二次点击才放行。')),
|
|
5007
|
+
button('', { variant: 'quiet', size: 'sm', iconOnly: true, icon: icon('close', 15), ariaLabel: '取消', onClick: () => app.closeModal() })),
|
|
5008
|
+
h('div', { class: 'glass-body' },
|
|
5009
|
+
modal.loading ? h('div', { class: 'loading-line' }, icon('spinner', 14), '读取重启守卫与影响范围…') : null,
|
|
5010
|
+
modal.error ? h('div', { class: 'notice notice--warn', role: 'alert' }, h('div', { class: 'notice-main' }, h('div', { class: 'notice-title' }, '不能重启'), h('div', { class: 'notice-text' }, modal.error))) : null,
|
|
5011
|
+
h('div', { class: 'notice', style: { borderLeft: '5px solid var(--f-red)', background: 'var(--f-red-wash, #FFF5F7)' } },
|
|
5012
|
+
h('div', { class: 'notice-main' },
|
|
5013
|
+
h('div', { class: 'notice-title', style: { color: 'var(--f-red, #C8102E)' } }, icon('alert', 15), '红色重启风险'),
|
|
5014
|
+
h('div', { class: 'notice-text' },
|
|
5015
|
+
'重启会中断当前所有会话、工具调用和未完成的 Agent Loop;运行中的分身可能成为孤儿或被 supervisor 回收;未保存的输入/队列可能丢失。已写入 staging 的插件只有重启后才生效。'))),
|
|
5016
|
+
h('div', { class: 'kv', style: { marginTop: '8px' } },
|
|
5017
|
+
h('span', null, '执行模式'), h('b', null, String(state.mode ?? modal.impact?.mode ?? '—')),
|
|
5018
|
+
h('span', null, 'allowProcessRestart'), h('b', null, String(state.allowProcessRestart === true || modal.impact?.allowProcessRestart === true)),
|
|
5019
|
+
h('span', null, 'supervisor'), h('b', null, supervisor ? '在位' : '不在位'),
|
|
5020
|
+
h('span', null, '执行武装'), h('b', null, armed ? '已武装' : '未武装(只记录审批)'),
|
|
5021
|
+
h('span', null, '活跃分身'), h('b', null, `${impact.activeForks?.length ?? 0} 个`),
|
|
5022
|
+
h('span', null, '待批提升'), h('b', null, `${impact.pendingPromotes?.length ?? 0} 个`),
|
|
5023
|
+
h('span', null, '脏缓冲'), h('b', null, `${impact.dirtyBuffers?.length ?? 0} 个`)),
|
|
5024
|
+
liveForks.length === 0
|
|
5025
|
+
? h('div', { class: 'notice notice--info', style: { marginTop: '10px' } },
|
|
5026
|
+
h('div', { class: 'notice-main' }, h('div', { class: 'notice-title' }, '没有运行中的分身'), h('div', { class: 'notice-text' }, '先派生或打开一个分身,在里面确认影响后,才能进行第二次重启确认。')))
|
|
5027
|
+
: h('div', { style: { marginTop: '10px', display: 'flex', gap: '8px', alignItems: 'center', flexWrap: 'wrap' } },
|
|
5028
|
+
button('打开分身检查', { size: 'sm', variant: 'ghost', icon: icon('external', 12), onClick: () => liveForks[0] && void app.openTask(liveForks[0]) }),
|
|
5029
|
+
button(modal.forkChecked ? '已在分身确认 ✓' : '我已在分身确认', {
|
|
5030
|
+
size: 'sm', variant: modal.forkChecked ? 'primary' : 'info', disabled: modal.forkChecked || modal.busy,
|
|
5031
|
+
onClick: () => {
|
|
5032
|
+
const first = liveForks[0]
|
|
5033
|
+
if (!first) return
|
|
5034
|
+
modal.forkId = first.taskId
|
|
5035
|
+
modal.forkChecked = true
|
|
5036
|
+
app.render(true)
|
|
5037
|
+
},
|
|
5038
|
+
}),
|
|
5039
|
+
h('span', { class: 'hint' }, `分身:${short(liveForks[0].taskId, 12)}`)),
|
|
5040
|
+
h('div', { style: { marginTop: '10px', fontSize: '12px', color: armed ? 'var(--f-text-3)' : 'var(--f-red, #C8102E)' } },
|
|
5041
|
+
armed
|
|
5042
|
+
? '已武装:二次确认后守卫会写授权清单并退出 75,由外部 supervisor 拉起新宿主。'
|
|
5043
|
+
: '未武装:二次确认只会记录红色审批,不会自动退出/重启宿主。需要先启动 supervisor 并开启 enforce + allowProcessRestart。')),
|
|
5044
|
+
h('div', { class: 'glass-foot' },
|
|
5045
|
+
button('取消', { size: 'sm', variant: 'ghost', onClick: () => app.closeModal() }),
|
|
5046
|
+
button(modal.busy ? '提交中…' : '二次确认:放行重启', {
|
|
5047
|
+
size: 'sm', variant: 'danger', disabled: !canConfirm, busy: modal.busy, fk: 'restart-confirm',
|
|
5048
|
+
onClick: () => void app.submitRestart(),
|
|
5049
|
+
}))))
|
|
5050
|
+
}
|
|
5051
|
+
|
|
4510
5052
|
function renderConfirmModal(S, app) {
|
|
4511
5053
|
const modal = S.modal
|
|
4512
5054
|
const expected = String(modal.expected || '')
|
|
@@ -4693,17 +5235,11 @@ html[data-fang-overlays="hidden"] .fang-console .toast{display:none!important}
|
|
|
4693
5235
|
}
|
|
4694
5236
|
|
|
4695
5237
|
// ── 页面装配 ─────────────────────────────────────────────────────────
|
|
4696
|
-
|
|
4697
|
-
|
|
4698
|
-
return h('footer', { class: 'fang-foot' },
|
|
4699
|
-
h('span', { class: 'hint' }, '双击「瓮城」图标或输入框徽标 = 快速派生;单击 = 打开本面板。两栏各自滚动;元主重命名只写本地别名。'),
|
|
4700
|
-
h('span', { class: 'fang-foot-right' },
|
|
4701
|
-
h('span', { class: 'hint' }, S.lastRefreshAt ? `刷新于 ${fmtClock(S.lastRefreshAt)}` : '等待首次刷新'),
|
|
4702
|
-
h('span', { class: 'fh-version', title: '母体版本' }, version),
|
|
4703
|
-
h('a', { class: 'fang-portal-link', href: '/fang/panel', target: '_blank', rel: 'noopener' }, '独立门户', icon('external', 11))))
|
|
4704
|
-
}
|
|
5238
|
+
// 2026-11-21:按用户要求删除底部提示行(提示语 + 刷新时间 + 版本 + 独立门户链接),
|
|
5239
|
+
// 让两栏内容独占纵向空间;独立门户入口保留在顶部工具区(title=在新窗口打开 /fang/panel 独立门户)。
|
|
4705
5240
|
|
|
4706
5241
|
function renderForkSupervision(S, app) {
|
|
5242
|
+
if (!serviceEnabled(S, 'forker')) return null
|
|
4707
5243
|
const sv = S.forkSupervision || { state: 'idle' }
|
|
4708
5244
|
if (sv.state === 'idle') return null
|
|
4709
5245
|
if (sv.state === 'error') {
|
|
@@ -4749,17 +5285,77 @@ html[data-fang-overlays="hidden"] .fang-console .toast{display:none!important}
|
|
|
4749
5285
|
|
|
4750
5286
|
if (S.role.value === 'mother') {
|
|
4751
5287
|
const body = h('div', { class: 'fang-body', 'aria-busy': S.refreshing ? 'true' : undefined })
|
|
4752
|
-
|
|
5288
|
+
// v3.5.4 三块:左列「母体&元主」;右列上「分身」/ 下「决策中心」(中间水平分隔条可调比例)。
|
|
5289
|
+
const rightCol = h('div', { class: 'fang-col fang-col--right', 'data-zone': 'right-column' })
|
|
5290
|
+
const decisionPanel = h('section', { class: 'panel fang-decision-panel', 'data-zone': 'decision', 'aria-label': '决策中心' }, renderDecisionMini())
|
|
5291
|
+
const forkPanel = renderForkPanel(S, app)
|
|
5292
|
+
const motherPanel = renderMotherPanel(S, app)
|
|
5293
|
+
const vsplit = h('div', {
|
|
5294
|
+
class: 'fang-vsplit-handle',
|
|
5295
|
+
role: 'separator',
|
|
5296
|
+
'aria-orientation': 'horizontal',
|
|
5297
|
+
'aria-label': '调整分身与决策中心工作区比例',
|
|
5298
|
+
'aria-valuemin': '20',
|
|
5299
|
+
'aria-valuemax': '80',
|
|
5300
|
+
tabindex: '0',
|
|
5301
|
+
title: '拖动调整分身/决策中心高度;双击恢复 50:50',
|
|
5302
|
+
})
|
|
5303
|
+
rightCol.append(forkPanel, vsplit, decisionPanel)
|
|
5304
|
+
body.append(motherPanel, rightCol)
|
|
5305
|
+
// 右列内部(上分身 / 下决策中心)比例:S.decisionSplit 始终表示“决策中心占比”(在下方),
|
|
5306
|
+
// 默认 50:50;拖动/键盘上下键调整,双击恢复(偏好存本机,沿用同一 key,语义向后兼容)。
|
|
5307
|
+
const applyDecisionSplit = (ratio, persist = false) => {
|
|
5308
|
+
const clamped = Math.min(0.8, Math.max(0.2, Number.isFinite(ratio) ? ratio : 0.5))
|
|
5309
|
+
S.decisionSplit = clamped
|
|
5310
|
+
const forks = ((1 - clamped) * 100).toFixed(2)
|
|
5311
|
+
const decision = (clamped * 100).toFixed(2)
|
|
5312
|
+
rightCol.style.gridTemplateRows = `minmax(160px, ${forks}fr) 12px minmax(120px, ${decision}fr)`
|
|
5313
|
+
vsplit.setAttribute('aria-valuenow', String(Math.round(clamped * 100)))
|
|
5314
|
+
if (persist) writeNumberPref('fang.panel.decision.split', clamped)
|
|
5315
|
+
}
|
|
5316
|
+
applyDecisionSplit(S.decisionSplit)
|
|
5317
|
+
const onVMove = (event) => {
|
|
5318
|
+
const y = event.touches ? event.touches[0]?.clientY : event.clientY
|
|
5319
|
+
if (typeof y !== 'number') return
|
|
5320
|
+
const rect = rightCol.getBoundingClientRect()
|
|
5321
|
+
// 决策中心在下方:鼠标越往下 → 决策中心占比越大。
|
|
5322
|
+
if (rect.height > 0) applyDecisionSplit(1 - (y - rect.top) / rect.height)
|
|
5323
|
+
}
|
|
5324
|
+
const stopV = () => {
|
|
5325
|
+
body.classList.remove('is-resizing-y')
|
|
5326
|
+
document.removeEventListener('mousemove', onVMove)
|
|
5327
|
+
document.removeEventListener('touchmove', onVMove)
|
|
5328
|
+
document.removeEventListener('mouseup', stopV)
|
|
5329
|
+
document.removeEventListener('touchend', stopV)
|
|
5330
|
+
writeNumberPref('fang.panel.decision.split', S.decisionSplit)
|
|
5331
|
+
}
|
|
5332
|
+
const startV = (event) => {
|
|
5333
|
+
event.preventDefault()
|
|
5334
|
+
body.classList.add('is-resizing-y')
|
|
5335
|
+
document.addEventListener('mousemove', onVMove)
|
|
5336
|
+
document.addEventListener('touchmove', onVMove, { passive: false })
|
|
5337
|
+
document.addEventListener('mouseup', stopV, { once: true })
|
|
5338
|
+
document.addEventListener('touchend', stopV, { once: true })
|
|
5339
|
+
}
|
|
5340
|
+
vsplit.addEventListener('mousedown', startV)
|
|
5341
|
+
vsplit.addEventListener('touchstart', startV, { passive: false })
|
|
5342
|
+
vsplit.addEventListener('dblclick', () => applyDecisionSplit(0.5, true))
|
|
5343
|
+
vsplit.addEventListener('keydown', (event) => {
|
|
5344
|
+
if (event.key !== 'ArrowUp' && event.key !== 'ArrowDown') return
|
|
5345
|
+
event.preventDefault()
|
|
5346
|
+
// 决策中心在下方:↑ 收缩决策中心(放大分身),↓ 放大决策中心。
|
|
5347
|
+
applyDecisionSplit(S.decisionSplit + (event.key === 'ArrowUp' ? -0.02 : 0.02), true)
|
|
5348
|
+
})
|
|
4753
5349
|
// 中间拖动手柄:默认 50:50,可拖动/键盘方向键调整,双击恢复 50:50(偏好存本机)。
|
|
4754
5350
|
const handle = h('div', {
|
|
4755
5351
|
class: 'fang-split-handle',
|
|
4756
5352
|
role: 'separator',
|
|
4757
5353
|
'aria-orientation': 'vertical',
|
|
4758
|
-
'aria-label': '
|
|
5354
|
+
'aria-label': '调整母体&元主与右侧(分身 + 决策中心)比例',
|
|
4759
5355
|
'aria-valuemin': '25',
|
|
4760
5356
|
'aria-valuemax': '75',
|
|
4761
5357
|
tabindex: '0',
|
|
4762
|
-
title: '
|
|
5358
|
+
title: '拖动调整母体&元主与右侧比例;双击恢复 50:50',
|
|
4763
5359
|
})
|
|
4764
5360
|
const applyRatio = (ratio, persist = false) => {
|
|
4765
5361
|
const clamped = Math.min(0.75, Math.max(0.25, Number.isFinite(ratio) ? ratio : 0.5))
|
|
@@ -4805,7 +5401,6 @@ html[data-fang-overlays="hidden"] .fang-console .toast{display:none!important}
|
|
|
4805
5401
|
})
|
|
4806
5402
|
body.append(handle)
|
|
4807
5403
|
frag.append(body)
|
|
4808
|
-
frag.append(renderFooter(S, app))
|
|
4809
5404
|
} else if (S.role.value === 'fork') {
|
|
4810
5405
|
frag.append(renderHostNotice(S, app))
|
|
4811
5406
|
} else {
|
|
@@ -4824,6 +5419,7 @@ html[data-fang-overlays="hidden"] .fang-console .toast{display:none!important}
|
|
|
4824
5419
|
if (S.modal.kind === 'mother') frag.append(renderMotherModal(S, app))
|
|
4825
5420
|
else if (S.modal.kind === 'essence') frag.append(renderEssenceModal(S, app))
|
|
4826
5421
|
else if (S.modal.kind === 'branches') frag.append(renderBranchModal(S, app))
|
|
5422
|
+
else if (S.modal.kind === 'restart') frag.append(renderRestartModal(S, app))
|
|
4827
5423
|
else if (S.modal.kind === 'confirm') frag.append(renderConfirmModal(S, app))
|
|
4828
5424
|
else if (S.modal.kind === 'prompt') frag.append(renderPromptModal(S, app))
|
|
4829
5425
|
}
|
|
@@ -6250,6 +6846,23 @@ html[data-fang-overlays="hidden"] .fang-console .toast{display:none!important}
|
|
|
6250
6846
|
else if (options.drawer) options.onClose?.()
|
|
6251
6847
|
}
|
|
6252
6848
|
}
|
|
6849
|
+
// v3.3.10: Electron wheel 事件在收件箱里可能落到底层(body overflow 被宿主锁住),
|
|
6850
|
+
// 显式把滚轮转给当前 .fang-inbox-body,保证鼠标滚轮可用。
|
|
6851
|
+
const onInboxWheel = (event) => {
|
|
6852
|
+
if (event.ctrlKey || event.defaultPrevented) return
|
|
6853
|
+
const target = event.target
|
|
6854
|
+
if (target?.closest?.('.fang-inbox-ai, textarea, select, .fang-inbox-item-context, .fang-inbox-confirm')) return
|
|
6855
|
+
const body = root.querySelector('.fang-inbox-body')
|
|
6856
|
+
if (!body) return
|
|
6857
|
+
const max = body.scrollHeight - body.clientHeight
|
|
6858
|
+
if (max <= 0) return
|
|
6859
|
+
const unit = event.deltaMode === 1 ? 16 : event.deltaMode === 2 ? body.clientHeight : 1
|
|
6860
|
+
const delta = Number(event.deltaY) * unit
|
|
6861
|
+
if (!Number.isFinite(delta) || delta === 0) return
|
|
6862
|
+
event.preventDefault()
|
|
6863
|
+
body.scrollTop = Math.max(0, Math.min(max, body.scrollTop + delta))
|
|
6864
|
+
}
|
|
6865
|
+
root.addEventListener('wheel', onInboxWheel, { passive: false })
|
|
6253
6866
|
root.addEventListener('keydown', onKeyDown)
|
|
6254
6867
|
root.addEventListener('click', () => { focusRoot(); store.markSeen() })
|
|
6255
6868
|
root.addEventListener('focus', () => store.markSeen())
|
|
@@ -6261,6 +6874,7 @@ html[data-fang-overlays="hidden"] .fang-console .toast{display:none!important}
|
|
|
6261
6874
|
return () => {
|
|
6262
6875
|
disposed = true
|
|
6263
6876
|
try { unsubscribe() } catch { /* ignore */ }
|
|
6877
|
+
try { root.removeEventListener('wheel', onInboxWheel) } catch { /* ignore */ }
|
|
6264
6878
|
try { root.removeEventListener('keydown', onKeyDown) } catch { /* ignore */ }
|
|
6265
6879
|
host.replaceChildren()
|
|
6266
6880
|
}
|