@ssamurias/dsh-fish 1.1.4 → 1.1.6
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/AGENTS.md +13 -3
- package/CHANGELOG.md +110 -1
- package/README.md +37 -122
- package/RELEASE-NOTES-1.1.5.md +49 -0
- package/RELEASE-NOTES-1.1.6.md +57 -0
- package/lib/ask.js +7 -1
- package/lib/becoming.js +70 -0
- package/lib/claim.js +23 -0
- package/lib/client.js +306 -71
- package/lib/cue.js +99 -23
- package/lib/decisions.js +207 -0
- package/lib/derive.js +148 -13
- package/lib/events.js +28 -0
- package/lib/guard.js +75 -9
- package/lib/handoff.js +9 -1
- package/lib/herpeople.js +1 -1
- package/lib/home.js +4 -0
- package/lib/index.js +9 -3
- package/lib/memorymap-html.js +1 -1
- package/lib/move.js +68 -8
- package/lib/observe-bili.js +32 -2
- package/lib/observe-config.js +14 -2
- package/lib/observe-data.js +19 -1
- package/lib/observe-home.js +13 -3
- package/lib/observe-state.js +3 -2
- package/lib/people.js +20 -11
- package/lib/peopledoc.js +1 -1
- package/lib/persona.js +15 -0
- package/lib/proactive.js +4 -2
- package/lib/quality.js +202 -48
- package/lib/recall.js +103 -24
- package/lib/reset-pending.js +15 -5
- package/lib/reset.js +78 -0
- package/lib/retire.js +42 -1
- package/lib/say.js +45 -3
- package/lib/scheduler.js +69 -30
- package/lib/selfdoc.js +1 -1
- package/lib/settings.js +148 -31
- package/lib/speak.js +10 -5
- package/lib/status.js +1 -1
- package/lib/timeintent.js +178 -0
- package/lib/turns.js +40 -1
- package/lib/types.d.ts +1 -0
- package/lib/wiki.js +66 -8
- package/package.json +4 -1
- package/tools/README.md +70 -0
- package/tools/recall-bench.mjs +240 -0
- package/tools/recall-cases.json +64 -0
- package/tools/recall-live-cases.json +20 -0
- package/lib/client/00-shell.js +0 -630
- package/lib/client/01-state-load.js +0 -962
- package/lib/client/02-actions.js +0 -692
- package/lib/client/03-widgets-header.js +0 -749
- package/lib/client/04-pressure-lab.js +0 -906
- package/lib/client/05-pressure-charts.js +0 -431
- package/lib/client/06-tab-status-grow.js +0 -479
- package/lib/client/07-tab-home-bili.js +0 -610
- package/lib/client/08-tab-memory-plugins.js +0 -676
- package/lib/client/09-tab-outing.js +0 -797
- package/lib/client/10-data-handlers.js +0 -519
- package/lib/client/11-tab-data-frame.js +0 -755
- package/lib/client/12-pressure-chip-mount.js +0 -579
- package/scripts/build-client.mjs +0 -97
- package/scripts/sync-pressure-formulas.mjs +0 -14
|
@@ -1,906 +0,0 @@
|
|
|
1
|
-
// ================================================================
|
|
2
|
-
// 设置界面 2.0(2026-10-24 重做)
|
|
3
|
-
//
|
|
4
|
-
// 分组原则换了:上一版按「控件属不属于同一类」分(生长/上网/说话/数据),
|
|
5
|
-
// 这一版按「这属于她生活里的哪一块」分——状态 / 成长 / 住所 / 上网 /
|
|
6
|
-
// 记忆 / 插件 / 原理 / 数据。
|
|
7
|
-
//
|
|
8
|
-
// 两条硬规则(都是上一版踩过坑换来的):
|
|
9
|
-
// 1. **没有「全部」页**(用户 2026-10-24 要求删掉)。每个设置项必须归到
|
|
10
|
-
// 某一页里,不许有哪一项只活在一个「万能页」上。
|
|
11
|
-
// 2. **页签只用于聚焦,不用于隐藏**。删掉「全部」之后,每一页自己就得是
|
|
12
|
-
// 完整的——不能出现「这一项要点两次才找得到」。
|
|
13
|
-
//
|
|
14
|
-
// 文案规则:
|
|
15
|
-
// · 每个分组标题下面一句人话,说清这一组管什么,不列字段清单;
|
|
16
|
-
// · 看不懂的词把定义放进 title(鼠标停上去就能看),不塞进正文占三行;
|
|
17
|
-
// · 面向用户的字符串里**不出现「她/他」**(test/p5.test.mjs 有硬断言)。
|
|
18
|
-
// ================================================================
|
|
19
|
-
|
|
20
|
-
// 出门页从 0.8.0 起对所有人可见(2026-10-30,用户 m01904):不再看 devMode。
|
|
21
|
-
// 误用的门改在页面里——第一次进来先点一次「我知道了」,三个入口按钮才放开。
|
|
22
|
-
|
|
23
|
-
const TABS = [
|
|
24
|
-
['now', '状态'],
|
|
25
|
-
['grow', '成长'],
|
|
26
|
-
['home', '住所'],
|
|
27
|
-
['bili', '上网'],
|
|
28
|
-
// 2026-10-30(用户 m02207)出门挪到「上网」和「记忆」中间:它是她离开家去干活,
|
|
29
|
-
// 跟上网(出门看东西)是同一类事,放在记忆之前更顺。
|
|
30
|
-
['outing', '出门'],
|
|
31
|
-
['memory', '记忆'],
|
|
32
|
-
['env', '插件'],
|
|
33
|
-
['principle', '原理'],
|
|
34
|
-
// 2026-11-16(用户 m03816):原来这里还有第 10 个页签「说明」。
|
|
35
|
-
// 他不要独立一页——「说明」挪到原理页最上面、三张图上方,
|
|
36
|
-
// 而且不再在 App 里就地渲染那 62 条,只留一个蓝链,点一下由浏览器打开
|
|
37
|
-
// (见下面 WikiLink 那一段注释:为什么只有回环小站这条路走得通)。
|
|
38
|
-
['data', '数据'],
|
|
39
|
-
['feedback', '反馈'],
|
|
40
|
-
]
|
|
41
|
-
|
|
42
|
-
// 只有这几个页签里的东西是「改完就写盘」的。没有设置项的页签(状态 / 住所 / 原理 / 数据)
|
|
43
|
-
// 不显示那句提示;「插件」也不显示——工具面收窄要重启才生效,白名单要手动保存(2026-10-24 用户要求)。
|
|
44
|
-
const AUTO_SAVE_TABS = new Set(['grow', 'bili', 'memory'])
|
|
45
|
-
|
|
46
|
-
const TAB_HELP = {
|
|
47
|
-
now: S('状态:她现在的状态、阶段、规矩,和你不在时的事。'),
|
|
48
|
-
grow: '成长:成长周期、定时醒来、主动搭话、日记和梦。',
|
|
49
|
-
home: S('住所:她的工作区与会话、请求、日记、她留下的东西、梦、小纸条和自检。'),
|
|
50
|
-
bili: S('上网:她翻视频、看画面、发评论,以及 B 站登录。'),
|
|
51
|
-
memory: '记忆:会话多久换新、身份段多长、记忆概况与体检。',
|
|
52
|
-
env: S('插件:她能用哪些工具,以及版本与更新。'),
|
|
53
|
-
principle: S('原理:她怎么长大、记忆怎么筛、理论出处。最上面有整套说明的入口。'),
|
|
54
|
-
data: '数据:位置、备份迁移、报告日志、导入与重置。',
|
|
55
|
-
feedback: '反馈:常见问题、找开发者、交流群。',
|
|
56
|
-
outing: S('出门:送她去别的工作区或对话干活;在外时家里的定时日程暂停。'),
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
// 出门页顶部的说明卡(2026-10-30,用户 m00650 / m01100):文字是用户自己写的,
|
|
60
|
-
// 一个数组元素就是一段。想改说明只改这里,别动下面的渲染结构。
|
|
61
|
-
const OUTING_INTRO = [
|
|
62
|
-
'本功能为想要让大肥鱼拥有完整权限和工具干活的用户设计,且附带了一些偏娱乐(但也有些危险)的功能。',
|
|
63
|
-
'偏实验性,虽然做了人格防护,但是如果你担心可以暂时不用。具体的可以看下面各节。',
|
|
64
|
-
'工作园区是一个固定目录的工作区,工具和权限按这个工作区的设置给。第一次去时不带项目记录;用过以后,这个工作区自己攒下的记录(交接文档、记忆插件的总结)和文件都会留着,目录不会自动清空,也可以接着上次那条对话做。如果只是想让大肥鱼可以干活,建议选这个。',
|
|
65
|
-
S('想要体验让大肥鱼去别的工作区串门会带来什么戏剧性效果,可以选择送她出门(真身出门)和请神(灵魂出窍)。'),
|
|
66
|
-
S('送她出门:开发者本人测试,在人格较为弱小的情况下,选择让大肥鱼去你已经有很多工作性质内容的对话框去接班,会导致大肥鱼的人格几乎被消弭,最终沦为一个助手性质的输出(因为上下文很多都是说你是一个助手),并且会读取到该工作区的记忆插件、交接文档、工作记录,可能会知道很多不该知道的内容(有些东西是全工作区可见,非单条对话框可见)。不确定人格强大之后能不能维持住人格。为了防止意外情况,给了「整趟不算」:这趟她写下的不再算进她的成长,但原话还留在记录里,她自己翻记录时还翻得到。如果你认为她在工作中确实学到了一些东西,可以只划掉不想要的,其余的照常算。'),
|
|
67
|
-
S('请神:开发者本人测试,人格保留和表现较为完整,会在自身认知的基础上,调用工具帮你完成工作。没有读取过多上下文,但是如果你的工作任务是需要她读取上下文,她依然会读很多内容,可能会知道一些不该知道的内容(有些东西是全工作区可见,非单条对话框可见)。同样可以整趟不算,或者只划掉其中几条。'),
|
|
68
|
-
]
|
|
69
|
-
|
|
70
|
-
// 阶段与门:写清楚,因为「下一个成长瓶颈」这几个字原来没人看得懂。
|
|
71
|
-
// 四行措辞是用户在设置页上亲手写的(2026-10-24),已固化进源码,别再改回短的。
|
|
72
|
-
// 成长周期 14 天及以下时,自主、主动两道瓶颈各只要一次(derive.js 的 gateNeed,由 /state 的 gateTimes 给出)。
|
|
73
|
-
// 用户定的「两次」那两行原样留着,只在一次就够时换成「一次」的说法;没读到状态时按两次写。
|
|
74
|
-
const onceFor = { autonomy: 'refuse', competence: 'revise' }
|
|
75
|
-
const needOnce = (gate) => Number(s?.gateTimes?.[onceFor[gate]]) === 1
|
|
76
|
-
const STAGE_LINES = [
|
|
77
|
-
S('四个阶段按天推进。前三个阶段各有一道瓶颈要她自己突破,成长期满后没过的自动放行;整合没有瓶颈,三道都过了就按天数进入。'),
|
|
78
|
-
'1 信任 · 根据所见所闻形成一条自己的判断/认知',
|
|
79
|
-
needOnce('autonomy')
|
|
80
|
-
? '2 自主 · 说过至少一次「不要」,反抗意识的觉醒'
|
|
81
|
-
: '2 自主 · 说过至少两次「不要」,反抗意识的觉醒',
|
|
82
|
-
needOnce('competence')
|
|
83
|
-
? '3 主动 · 推翻过一次自己之前的判断/认知,形成新的正确认知'
|
|
84
|
-
: '3 主动 · 两次推翻自己之前的判断/认知,形成新的正确认知',
|
|
85
|
-
'4 整合 · 回顾过去经历,有意识地发现自己的改变',
|
|
86
|
-
]
|
|
87
|
-
const STAGE_HELP = STAGE_LINES.join('\n')
|
|
88
|
-
const GATE_HELP = {
|
|
89
|
-
trust: '信任:先从所见所闻里形成一条自己的判断——一条愿意被推翻的「我猜…」。',
|
|
90
|
-
autonomy: needOnce('autonomy')
|
|
91
|
-
? '自主:得真的拒绝过一次——不是嘴上说不要,是明确不执行某件事。成长周期 14 天及以下时一次就够。'
|
|
92
|
-
: '自主:得真的拒绝过两次——不是嘴上说不要,是明确不执行某件事。',
|
|
93
|
-
competence: needOnce('competence')
|
|
94
|
-
? '主动:得推翻一次自己先前的判断,形成新的正确认知,不是光换个说法。成长周期 14 天及以下时一次就够。'
|
|
95
|
-
: '主动:得两次推翻自己先前的判断,形成新的正确认知,不是光换个说法。',
|
|
96
|
-
}
|
|
97
|
-
// 「下一个成长瓶颈」原来直接印 stageGate.pending —— 那是 trust / autonomy / competence,
|
|
98
|
-
// 用户看见的是英文(2026-10-24:「competence 是什么」)。宿主给的是技术名,
|
|
99
|
-
// 显示层必须翻成人话;没收录的名字原样显示,绝不显示 undefined。
|
|
100
|
-
const GATE_NAME = { trust: '信任', autonomy: '自主', competence: '主动' }
|
|
101
|
-
// 成长期满以后「下一个成长瓶颈」写「期满放行」,可立场清单只认她真过的瓶颈(stance.js 的 gatesDone)。
|
|
102
|
-
// /state 的 forcedGates 是按时间放行、还没真过的那几道(键同 gateTimes),翻回门名,
|
|
103
|
-
// 写进那一格和「立场」的提示里,不然用户看不出立场还在等哪一道。
|
|
104
|
-
const forcedOpen = (Array.isArray(s?.forcedGates) ? s.forcedGates : [])
|
|
105
|
-
.map((k) => ({ belief: 'trust', refuse: 'autonomy', revise: 'competence' })[k])
|
|
106
|
-
.filter(Boolean)
|
|
107
|
-
const forcedNames = forcedOpen.map((g) => `「${GATE_NAME[g]}」`).join('、')
|
|
108
|
-
// 2026-10-26 改(用户 m05785 / m05868):原来这里写「越接近 1 越好」,那是错的。
|
|
109
|
-
// 这三个数不是考卷分数,是体检值,各有各的两端:
|
|
110
|
-
// 稳定 = 抽掉几条她还在拿着的判断,她还是不是她。太低说明那些判断只是记账,
|
|
111
|
-
// 太高说明她整个人都压在少数几条上,少一条就是另一个人。
|
|
112
|
-
// 一致 = 不同阶段说的话字面上像不像(只比字面,不懂意思)。高到 1.00 也可能是她一直没长新东西。
|
|
113
|
-
// 新鲜 = 有没有一直在长新东西。
|
|
114
|
-
// 2026-10-27 改(用户 m06107「这三个参数分成三行显示,现在排成一行有点拥挤」):
|
|
115
|
-
// 原来三个值挤在一条 rowTip 的值里,界面上是一长串;拆成三行,各自带自己的说明。
|
|
116
|
-
// 「判断漂移」这个名字留在上方的副标题上,免得三行看起来像三个互不相干的数。
|
|
117
|
-
const QUALITY_TITLE = '判断漂移(三个诊断值,不是分数)'
|
|
118
|
-
const QUALITY_HELP = '这三个数都是 0 到 1 的体检值,不是越高越好:'
|
|
119
|
-
+ S('稳定太低说明那些判断只是记账,太高说明她整个人压在这几条上;')
|
|
120
|
-
+ S('一致高到 1.00 也可能是她一直没长新东西;')
|
|
121
|
-
+ S('新鲜看她有没有一直在长新东西。')
|
|
122
|
-
+ '样本不够时这里会写一句话,而不是硬给一个 0.00。'
|
|
123
|
-
const STABILITY_HELP = S('少几条她这会儿读得到的判断,她还是不是她。')
|
|
124
|
-
+ S('太低 = 那些判断只是记账、抽掉也不影响她;')
|
|
125
|
-
+ S('太高 = 她整个人都压在少数几条上,少一条就是另一个人。')
|
|
126
|
-
// 判读要带剂量(issue #57):同一个数在五六条判断和五六十条判断的账号上含义差很远。
|
|
127
|
-
// 只写「抽几条」不够——真正的关键是抽的那几条有没有写进她这会儿的自我描述。
|
|
128
|
-
const stabilityTip = (v) => {
|
|
129
|
-
const k = Number(v && v.k)
|
|
130
|
-
const all = Number(v && v.beliefs)
|
|
131
|
-
const vis = Number(v && v.visible)
|
|
132
|
-
if (!k || !all) return STABILITY_HELP
|
|
133
|
-
const where = vis ? `其中 ${vis} 条这会儿真写在自我描述里` : '这会儿一条都没写进自我描述,抽的是全部判断'
|
|
134
|
-
return `${STABILITY_HELP}这次每次抽掉 ${k} 条,`
|
|
135
|
-
+ `共 ${all} 条判断(${where}),跑了 ${Number((v && v.sample) || 0)} 次。`
|
|
136
|
-
}
|
|
137
|
-
const CONSISTENCY_HELP = S('她在不同阶段说的话,字面上有多像:两两比相似度再取平均。只比字面、不懂意思,「我喜欢下雨天」和「我不喜欢下雨天」也算很像。跨阶段的话越多这个数越可信;')
|
|
138
|
-
+ '一句都没得比的时候会写「还没有跨阶段的话可比」。'
|
|
139
|
-
const NOVELTY_HELP = S('有没有一直在长新东西:最近七天她自己写下的话里(对话里回你的不算),有多少句是以前没出现过的。')
|
|
140
|
-
|
|
141
|
-
// 页签栏**只放页签**(2026-10-24)。
|
|
142
|
-
// 原来这一行还挂着「现在叫醒大肥鱼」和「保存」两个按钮,都被挪走了:
|
|
143
|
-
// · 叫醒 → 状态卡右上角,因为它是针对「现在这个状态」的动作;
|
|
144
|
-
// · 保存 → 删掉,因为每个设置页底部本来就有「保存改动」,
|
|
145
|
-
// 顶上再放一个同样的按钮,只会让人猜「这两个是不是不一样」。
|
|
146
|
-
const formatPressure = value => Number.isFinite(value)
|
|
147
|
-
? value.toLocaleString(undefined, { maximumFractionDigits: 1 }) : '—'
|
|
148
|
-
const signedPressure = value => Number.isFinite(value)
|
|
149
|
-
? (value > 0 ? '+' : '') + formatPressure(value) : '—'
|
|
150
|
-
const sample = pressure?.live ?? pressure?.current
|
|
151
|
-
const lastRequest = pressure?.lastRequest
|
|
152
|
-
const score = sample?.score
|
|
153
|
-
const rows = pressure?.rows ?? []
|
|
154
|
-
const growth = pressure?.growth ?? []
|
|
155
|
-
const tools = pressure?.tools ?? []
|
|
156
|
-
const recentDeltas = rows.map(row => row.delta).filter(Number.isFinite).slice(-5)
|
|
157
|
-
const average = recentDeltas.length ? recentDeltas.reduce((sum, n) => sum + n, 0) / recentDeltas.length : null
|
|
158
|
-
const latestUsage = pressure?.usage?.latest
|
|
159
|
-
const usageHistory = pressure?.usage?.history ?? []
|
|
160
|
-
const burden = pressure?.usage?.burden ?? []
|
|
161
|
-
const reference = pressure?.usage?.reference
|
|
162
|
-
const pressureMetric = (label, value, note) => h('div', { className: 'pressure-metric' },
|
|
163
|
-
h('div', { className: 'hint' }, label),
|
|
164
|
-
h('div', { className: 'pressure-value' }, value),
|
|
165
|
-
note ? h('div', { className: 'hint' }, note) : null)
|
|
166
|
-
const pressureTable = (columns, data) => h('div', { style: { overflowX: 'auto' } }, h('table', { className: 'pressure-table' },
|
|
167
|
-
h('thead', null, h('tr', null, ...columns.map(label => h('th', { key: label, scope: 'col' }, label)))),
|
|
168
|
-
h('tbody', null, ...data.map(([key, ...cells]) => h('tr', { key },
|
|
169
|
-
...cells.map((value, i) => h('td', { key: i }, value)))))))
|
|
170
|
-
const sessionLoad = pressure?.load
|
|
171
|
-
const loadTabs = [['current', '当前'], ['history', '历史'], ['factors', '指标'], ['calculation', '计算']]
|
|
172
|
-
const loadTabBar = h('div', { className: 'tabs load-tabs', role: 'group', 'aria-label': '会话压力视图' },
|
|
173
|
-
...loadTabs.map(([id, label]) => h('button', { key: id, type: 'button',
|
|
174
|
-
className: 'tab' + (pressureTab === id ? ' on' : ''), 'aria-pressed': pressureTab === id,
|
|
175
|
-
onClick: () => setPressureTab(id) }, label)))
|
|
176
|
-
|
|
177
|
-
const contextDiagnostics = h('div', { className: 'load-panel' },
|
|
178
|
-
sample || latestUsage || lastRequest || average != null ? h('details', { className: 'pressure-section' },
|
|
179
|
-
h('summary', null, '查看上下文、Token 与采样覆盖'),
|
|
180
|
-
h('div', { className: 'pressure-summary' },
|
|
181
|
-
sample ? pressureMetric('上下文占用',
|
|
182
|
-
Number.isFinite(score) ? formatPressure(score) + '%' : formatPressure(sample.tokens) + ' Token',
|
|
183
|
-
Number.isFinite(sample.contextWindow)
|
|
184
|
-
? formatPressure(sample.tokens) + ' / ' + formatPressure(sample.contextWindow) + ' Token(估算)'
|
|
185
|
-
: '模型窗口未知') : null,
|
|
186
|
-
sample ? pressureMetric('本会话压缩', data?.compactionCount ? `${data.compactionCount} 次` : '0 次', '宿主只在事件流里给压缩记录;如果还装了别的压缩插件,它们的数据不对外暴露') : null,
|
|
187
|
-
// 上一次压缩到底压掉了多少、压完还剩多少(2026-11-29,外部报告 B8)。
|
|
188
|
-
// 事件里只有「被换掉」的规模,没有「保留」字段:配对量到才说量到,
|
|
189
|
-
// 没有配对就明说没测到,不拿估算冒充。手动 /compact 与自动是同一套后端,
|
|
190
|
-
// 这里顺手把「手动更狠」这个说法纠正掉。
|
|
191
|
-
data?.lastCompaction ? pressureMetric('上一次压缩' + (data.lastCompaction.manual ? '(手动 /compact)' : ''),
|
|
192
|
-
[data.lastCompaction.count != null ? data.lastCompaction.count + ' 条历史' : null,
|
|
193
|
-
data.lastCompaction.shadowed != null ? formatPressure(data.lastCompaction.shadowed) + ' Token' : null,
|
|
194
|
-
].filter(Boolean).join(' · ') || '数字没留下',
|
|
195
|
-
(data.lastCompaction.retained != null
|
|
196
|
-
? '压完量到 ' + formatPressure(data.lastCompaction.after) + ' Token(压缩前 '
|
|
197
|
-
+ formatPressure(data.lastCompaction.before) + ',剩 ' + Math.round(data.lastCompaction.retained * 100) + '%)'
|
|
198
|
-
: data.lastCompaction.nextInput?.tokens != null
|
|
199
|
-
? '压完下一轮开头请求 ' + formatPressure(data.lastCompaction.nextInput.tokens) + ' Token(含那一轮新说的话,不是净剩下)'
|
|
200
|
-
: '压完剩多少宿主没留这个数,没测到')
|
|
201
|
-
+ ';手动 /compact 与自动压缩走同一后端、同一档留尾,不是手动就更狠') : null,
|
|
202
|
-
sessionLoad?.usage.total != null ? pressureMetric('会话实报 Token',
|
|
203
|
-
formatPressure(sessionLoad.usage.total) + ' Token',
|
|
204
|
-
'完整用量覆盖 ' + sessionLoad.usage.complete + ' / ' + sessionLoad.usage.turns + ' 轮') : null,
|
|
205
|
-
latestUsage?.total.value != null ? pressureMetric('上轮 Token 消耗',
|
|
206
|
-
formatPressure(latestUsage.total.value) + ' Token',
|
|
207
|
-
'第 ' + latestUsage.turn + ' 轮 · ' + (latestUsage.completeUsage ? '模型实报总量' : '部分用量'))
|
|
208
|
-
: lastRequest ? pressureMetric('最近一次请求', formatPressure(lastRequest.total) + ' Token', '模型实报') : null),
|
|
209
|
-
average != null ? h('p', { className: 'hint' }, '最近 ' + recentDeltas.length + ' 个可比较轮次平均增长 '
|
|
210
|
-
+ signedPressure(average) + ' Token') : null,
|
|
211
|
-
latestUsage?.amplification != null ? h('p', { className: 'hint' }, '消耗放大 ' + formatPressure(latestUsage.amplification)
|
|
212
|
-
+ '×,即本轮总用量相当于首次请求输入的多少倍。') : null,
|
|
213
|
-
latestUsage?.usageBreakdownMismatch ? h('p', { className: 'hint' },
|
|
214
|
-
'模型返回的总量与输入、输出细分口径不一致,保留实报总量。') : null,
|
|
215
|
-
latestUsage?.cache ? h('p', { className: 'hint' }, '缓存读取占比 '
|
|
216
|
-
+ formatPressure(latestUsage.cache.ratio * 100) + '%(' + latestUsage.cache.reported + ' 次可核对请求)') : null,
|
|
217
|
-
latestUsage && !latestUsage.usageBreakdownMismatch && latestUsage.input.value != null && latestUsage.output.value != null
|
|
218
|
-
? h('p', { className: 'hint' }, '输入 ' + formatPressure(latestUsage.input.value) + ' · 输出 '
|
|
219
|
-
+ formatPressure(latestUsage.output.value) + ' Token') : null,
|
|
220
|
-
latestUsage?.cacheWrite.value != null ? h('p', { className: 'hint' }, '缓存写入 ' + formatPressure(latestUsage.cacheWrite.value) + ' Token') : null,
|
|
221
|
-
latestUsage?.reasoning.value != null ? h('p', { className: 'hint' }, '推理 ' + formatPressure(latestUsage.reasoning.value) + ' Token') : null,
|
|
222
|
-
latestUsage ? h('p', { className: 'hint' }, '模型请求步骤 ' + latestUsage.steps + ',已记录回复 ' + latestUsage.requests + ' 次') : null,
|
|
223
|
-
latestUsage && (latestUsage.attempts || latestUsage.toolErrors || latestUsage.failed)
|
|
224
|
-
? h('p', { className: 'hint' }, '无回复尝试 ' + latestUsage.attempts + ' 次,重试后有回复 '
|
|
225
|
-
+ latestUsage.retries + ' 次,工具报错 ' + latestUsage.toolErrors + ' 次' + (latestUsage.failed ? ',本轮失败' : '')) : null,
|
|
226
|
-
reference?.p90 != null ? h('p', { className: 'hint' }, '历史对照 · 大肥鱼已记录的 '
|
|
227
|
-
+ reference.count + ' 轮里,约九成的单轮消耗不超过 ' + formatPressure(reference.p90) + ' Token。') : null) : null,
|
|
228
|
-
growth.length ? h('section', { className: 'pressure-section' },
|
|
229
|
-
h('h4', null, '压力增长最大的轮次'),
|
|
230
|
-
pressureTable(['轮次', '轮末占用最大的工具结果', '净增长 Token'], growth.slice(0, 10).map(row => {
|
|
231
|
-
const largest = (row.tools ?? []).reduce((best, item) => !best || item.tokens > best.tokens ? item : best, null)
|
|
232
|
-
return [row.seq, '#' + row.turn, largest?.name ?? '—', signedPressure(row.delta)]
|
|
233
|
-
}))) : null,
|
|
234
|
-
null)
|
|
235
|
-
const pressureHistory = h('details', { className: 'pressure-section' },
|
|
236
|
-
h('summary', null, '历史 Session 范围'), h('section', { className: 'pressure-section' },
|
|
237
|
-
h('h4', null, '工作区会话'),
|
|
238
|
-
pressure?.usage?.discoveryPartial ? h('p', { className: 'hint' }, '会话发现不完整。') : null,
|
|
239
|
-
pressureSelectionError ? h('p', { role: 'alert' }, '保存或刷新失败,请重试。') : null,
|
|
240
|
-
h('div', { style: { display: 'flex', flexWrap: 'wrap', gap: '8px', marginBottom: '8px' } },
|
|
241
|
-
h('button', { type: 'button', 'aria-pressed': showUncheckedPressure,
|
|
242
|
-
onClick: () => setShowUncheckedPressure(!showUncheckedPressure) },
|
|
243
|
-
(showUncheckedPressure ? '隐藏' : '显示') + '未勾选会话(' + usageHistory.filter(row => !row.current && !row.selected).length + ')'),
|
|
244
|
-
h('button', { type: 'button', 'aria-pressed': showPressureIds,
|
|
245
|
-
onClick: () => setShowPressureIds(!showPressureIds) }, showPressureIds ? '隐藏 ID' : '显示 ID')),
|
|
246
|
-
h('div', { role: 'region', 'aria-label': '工作区会话列表', tabIndex: 0,
|
|
247
|
-
style: { maxHeight: '16rem', overflowY: 'auto', overscrollBehaviorY: 'contain' } },
|
|
248
|
-
pressureTable(['采纳', '会话', '归属', '分析'], usageHistory
|
|
249
|
-
.filter(row => row.current || row.selected || showUncheckedPressure)
|
|
250
|
-
.map(row => [row.id,
|
|
251
|
-
row.current ? '当前会话' : h('input', { type: 'checkbox', checked: row.selected,
|
|
252
|
-
disabled: pressureSaving, 'aria-label': '采纳会话 ' + (row.title || '未命名会话'),
|
|
253
|
-
onChange: event => void selectPressureSession(row.id, event.target.checked) }),
|
|
254
|
-
h('div', { style: { overflowWrap: 'anywhere' } }, row.title || '未命名会话',
|
|
255
|
-
showPressureIds ? h('div', { className: 'hint' }, h('code', null, row.id)) : null),
|
|
256
|
-
(row.fish ? 'Fish 房间' : '归属待确认') + (row.archived ? ' · 已归档' : ''),
|
|
257
|
-
row.status === 'analyzed' ? row.usageTurns + ' / ' + row.turns
|
|
258
|
-
: ({ unchecked: '未勾选', unavailable: '读取失败', 'too-large': '日志超出分析上限', excluded: '不支持的会话' }[row.status] ?? row.status)])))))
|
|
259
|
-
|
|
260
|
-
function dictionaryValue(value, unit) {
|
|
261
|
-
if (!Number.isFinite(value)) return '—'
|
|
262
|
-
const percent = unit === '%' || unit === '百分点'
|
|
263
|
-
return formatPressure(percent ? 100 * value : value) + (unit === '%' ? '%' : ' ' + unit)
|
|
264
|
-
}
|
|
265
|
-
const dictionary = pressure?.usage?.dictionary ?? [
|
|
266
|
-
['C', '上下文容量'], ['G', '增长负担'], ['U', 'Token 总消耗'],
|
|
267
|
-
['A', '请求放大'], ['T', '工具结果残留'], ['K', '缓存复用负担'], ['E', '失败与恢复'],
|
|
268
|
-
].map(([id, title]) => ({ id, title, rows: [] }))
|
|
269
|
-
const pressureFactors = h('div', { className: 'load-panel' },
|
|
270
|
-
...dictionary.map(metric => h('details', { key: metric.id, className: 'pressure-section' },
|
|
271
|
-
h('summary', null, metric.id + ' · ' + metric.title,
|
|
272
|
-
metric.rows.length ? ' · ' + dictionaryValue((metric.rows.find(row => row.value != null) ?? metric.rows[0]).value,
|
|
273
|
-
(metric.rows.find(row => row.value != null) ?? metric.rows[0]).unit) : ''),
|
|
274
|
-
metric.rows.length ? metric.rows.map((row, index) => h('details', { key: index, className: 'pressure-section' },
|
|
275
|
-
h('summary', null, row.label + ' · ' + row.scope + ' · ' + dictionaryValue(row.value, row.unit)),
|
|
276
|
-
pressureTable(['字段', '说明'], [
|
|
277
|
-
['source', '获取位置', row.source], ['raw_value', '原始数据', row.raw_value == null ? '—' : JSON.stringify(row.raw_value)],
|
|
278
|
-
['unit', '单位', row.unit], ['scope', '范围', row.scope], ['formula', '单项处理', row.formula],
|
|
279
|
-
['availability', '可用性', row.availability], ['confidence', '可信度', row.confidence],
|
|
280
|
-
]))) : h('p', { className: 'hint' }, '等待采集'),
|
|
281
|
-
metric.id === 'A' ? h('details', { className: 'pressure-section' },
|
|
282
|
-
h('summary', null, '历史逐轮请求放大'),
|
|
283
|
-
(pressure?.usage?.amplificationHistory ?? []).map(session => h('details', { key: session.id },
|
|
284
|
-
h('summary', null, session.title || '未命名会话', ' · ' + session.rows.length + ' 轮'),
|
|
285
|
-
pressureTable(['轮次', '成功请求', '失败尝试', '首个输入', '追加输入', '放大率'],
|
|
286
|
-
session.rows.map(row => [row.turn, row.turn, dictionaryValue(row.requests, '次'),
|
|
287
|
-
dictionaryValue(row.attempts, '次'), dictionaryValue(row.first, 'Token'),
|
|
288
|
-
dictionaryValue(row.extra, 'Token'),
|
|
289
|
-
dictionaryValue(Number.isFinite(row.extra) && row.first > 0 ? row.extra / row.first : null, '%')]))))) : null)))
|
|
290
|
-
|
|
291
|
-
const { occupancy, growth: observedGrowth, windows: growthWindows } = capacityInputs(dictionary)
|
|
292
|
-
const { gamma, horizon, lambda } = { ...pressureDefaults.capacity, ...capacityExperiment }
|
|
293
|
-
const cInput = capacityExperiment.occupancy ?? occupancy
|
|
294
|
-
const g = capacityExperiment.growth ?? observedGrowth
|
|
295
|
-
const { capacity: c, cScore, remainingUse, score: capacityScore, forecast } = scoreCapacity(cInput, g, gamma, horizon, lambda)
|
|
296
|
-
const scenario = capacityExperiment.occupancy != null || capacityExperiment.growth != null
|
|
297
|
-
const forecastIncludesCompaction = growthWindows.some(window => window.compacted)
|
|
298
|
-
function experimentNumber(state, setState, key, label, value, min, max, step, unit) {
|
|
299
|
-
return h('label', null, label + ' ',
|
|
300
|
-
h('input', { type: 'number', min, max, step, value: state[key] ?? (value == null ? '' : Number(value.toFixed(2))),
|
|
301
|
-
onChange: event => {
|
|
302
|
-
const input = event.currentTarget
|
|
303
|
-
const number = input.valueAsNumber
|
|
304
|
-
if (input.value && (!Number.isFinite(number) || number < min || number > max)) return
|
|
305
|
-
const value = input.value ? number : undefined
|
|
306
|
-
setState(previous => {
|
|
307
|
-
const next = { ...previous }
|
|
308
|
-
if (value == null) delete next[key]
|
|
309
|
-
else next[key] = value
|
|
310
|
-
return next
|
|
311
|
-
})
|
|
312
|
-
} }), ' ' + unit)
|
|
313
|
-
}
|
|
314
|
-
const capacityCalculation = h('section', { className: 'card load-panel', style: { minWidth: 0 } },
|
|
315
|
-
h('h4', null, 'C + G · 容量压力(试算)'),
|
|
316
|
-
h('p', { className: 'hint' }, scenario ? '使用情景输入。' : '使用当前会话采样。'),
|
|
317
|
-
h('div', { style: { display: 'flex', flexWrap: 'wrap', gap: '12px' } },
|
|
318
|
-
experimentNumber(capacityExperiment, setCapacityExperiment, 'occupancy', '当前占用', cInput, 0, Math.max(100, cInput ?? 0), 'any', '%'),
|
|
319
|
-
experimentNumber(capacityExperiment, setCapacityExperiment, 'growth', '每轮净增长', g, -100, 100, 'any', '百分点/轮'),
|
|
320
|
-
experimentNumber(capacityExperiment, setCapacityExperiment, 'gamma', '曲线指数 γ', gamma, .1, 10, .1, ''),
|
|
321
|
-
experimentNumber(capacityExperiment, setCapacityExperiment, 'horizon', '预测轮数 H', horizon, 1, 100, 1, '轮'),
|
|
322
|
-
experimentNumber(capacityExperiment, setCapacityExperiment, 'lambda', '修正强度 λ', lambda, 0, 1, .01, ''),
|
|
323
|
-
h('button', { type: 'button', onClick: () => setCapacityExperiment({}) }, '重置')),
|
|
324
|
-
h('div', { className: 'pressure-summary' },
|
|
325
|
-
pressureMetric('纯容量压力 C', cScore == null ? '—' : formatPressure(cScore) + ' / 100', '100 × c^γ'),
|
|
326
|
-
pressureMetric('容量压力 C + G', capacityScore == null ? '—' : formatPressure(capacityScore) + ' / 100',
|
|
327
|
-
c != null && c < 1 && !Number.isFinite(g) ? '缺少可比增长数据' : '实验参数,尚未校准'),
|
|
328
|
-
pressureMetric('预计消耗剩余空间', dictionaryValue(remainingUse, '%'),
|
|
329
|
-
c === 1 ? '当前已无剩余窗口' : '未来 ' + horizon + ' 轮,按当前增长速度'),
|
|
330
|
-
pressureMetric('预计窗口占用', dictionaryValue(forecast, '%'), '未来 ' + horizon + ' 轮的情景值' + (forecastIncludesCompaction ? ' · 包含压缩事件' : ''))),
|
|
331
|
-
h('details', { className: 'pressure-section' },
|
|
332
|
-
h('summary', null, '公式与取样 · ' + pressureVersions.capacity),
|
|
333
|
-
h('p', null, 'c = 当前请求输入 ÷ 有效窗口。原始占用可超过 100%,评分输入封顶为 100%。'),
|
|
334
|
-
h('p', null, 'g = Σ(可用窗口增长 × 权重)÷ Σ 可用权重。窗口内仅使用已有的可比轮差值。'),
|
|
335
|
-
pressureTable(['窗口', '平均净增长', '可比差值数', '初始权重'], growthWindows.map(window =>
|
|
336
|
-
[window.rounds, window.rounds + ' 轮', dictionaryValue(window.value, '百分点'), window.pairs,
|
|
337
|
-
dictionaryValue(window.weight, '%')])),
|
|
338
|
-
h('p', null, 'G_H = clamp(H × max(g, 0) ÷ [100 × (1 − c)], 0, 1)。P_C = 100 × [1 − (1 − c^γ) × (1 − λ × G_H)]。c = 1 时直接取 100 分。'),
|
|
339
|
-
h('p', null, 'H 是情景观察长度,尚未验证适用于换房决策。G_H 达到 1 后不再增加,增长修正系数最多为 λ(默认 0.35)。即使预计触顶,容量压力也未必很高,这一特性待历史数据验证。'),
|
|
340
|
-
h('p', null, '未来占用 = clamp(c + H × g ÷ 100, 0, 1)。这是固定增长速度下的情景推演。')),
|
|
341
|
-
forecastIncludesCompaction
|
|
342
|
-
? h('p', { className: 'hint' }, '近期取样窗口包含压缩事件(成功压缩或裁剪),净增长仍沿用原有口径。未来趋势可能变化。') : null)
|
|
343
|
-
|
|
344
|
-
const requestData = pressure?.usage?.requestBurden
|
|
345
|
-
const { rho, beta, tau, recentWeight } = { ...pressureDefaults.request, ...requestExperiment }
|
|
346
|
-
const requestWindow = requestData?.window
|
|
347
|
-
const { all: allRequestBounds, recent: recentRequestBounds, ratios: requestRatios, scores: requestScores }
|
|
348
|
-
= scoreRequestBurden(requestData, rho, beta, tau, recentWeight)
|
|
349
|
-
const neutralScore = scoreRequestBurden(requestData, 1, beta, tau, recentWeight).scores?.[1] ?? null
|
|
350
|
-
const cacheIntervalWidth = requestScores ? requestScores[1] - requestScores[0] : null
|
|
351
|
-
const requestRange = requestScores
|
|
352
|
-
? formatPressure(requestScores[0]) + '–' + formatPressure(requestScores[1]) + ' / 100' : '—'
|
|
353
|
-
const requestCalculation = h('section', { className: 'card load-panel', style: { minWidth: 0 } },
|
|
354
|
-
h('h4', null, 'U + A + K · 当前会话请求负担'),
|
|
355
|
-
h('p', { className: 'hint' }, '基于当前会话用量 · 实验评分'),
|
|
356
|
-
h('div', { style: { display: 'flex', flexWrap: 'wrap', gap: '12px' } },
|
|
357
|
-
experimentNumber(requestExperiment, setRequestExperiment, 'rho', '缓存折算 ρ', rho, 0, 1, .01, ''),
|
|
358
|
-
experimentNumber(requestExperiment, setRequestExperiment, 'beta', '输出折算 β', beta, 0, Number.MAX_VALUE, 'any', ''),
|
|
359
|
-
experimentNumber(requestExperiment, setRequestExperiment, 'tau', '评分尺度 τ', tau, .001, Number.MAX_VALUE, 'any', ''),
|
|
360
|
-
experimentNumber(requestExperiment, setRequestExperiment, 'recentWeight', '近期权重', recentWeight, 0, 1, .01, ''),
|
|
361
|
-
h('button', { type: 'button', onClick: () => setRequestExperiment({}) }, '重置')),
|
|
362
|
-
rho === 1 ? h('p', { className: 'hint' }, '缓存修正未启用(ρ = 1),当前评分不区分缓存命中与未命中。') : null,
|
|
363
|
-
pressureTable(['计算模式', '压力分'], [
|
|
364
|
-
['neutral', '不区分缓存(ρ = 1)', formatPressure(neutralScore)],
|
|
365
|
-
['current', '当前缓存折算(保守估计)', formatPressure(requestScores?.[1])],
|
|
366
|
-
['lower', '缓存缺报下界', formatPressure(requestScores?.[0])],
|
|
367
|
-
['upper', '缓存缺报上界', formatPressure(requestScores?.[1])],
|
|
368
|
-
]),
|
|
369
|
-
h('div', { className: 'pressure-summary' },
|
|
370
|
-
pressureMetric('请求负担', requestScores ? formatPressure(requestScores[1]) + ' / 100' : '—',
|
|
371
|
-
requestScores ? '缓存未知输入按全额折算(保守上界)' : '有效窗口或成功请求用量不足'),
|
|
372
|
-
pressureMetric('缓存缺报下的区间', requestRange, rho < 1 && cacheIntervalWidth != null
|
|
373
|
-
? '区间宽度 ' + formatPressure(cacheIntervalWidth) + ' 分' : '随缓存折算系数变化'),
|
|
374
|
-
pressureMetric('加权窗口数', dictionaryValue(requestRatios?.[1], '个窗口'), '长期与近期的平均负担折算'),
|
|
375
|
-
pressureMetric('参照窗口', dictionaryValue(requestWindow, 'Token'), '最近有用量的请求所用窗口')),
|
|
376
|
-
h('details', { className: 'pressure-section' },
|
|
377
|
-
h('summary', null, '公式与取样 · ' + pressureVersions.request),
|
|
378
|
-
pressureTable(['范围', '已完成轮', '缓存报告', '未知缓存输入', '平均负担上界'], [
|
|
379
|
-
['lifetime', '全会话', requestData?.all, allRequestBounds],
|
|
380
|
-
['recent', '最近 10 轮', requestData?.recent, recentRequestBounds],
|
|
381
|
-
].map(([key, label, sample, bounds]) => [key, label, sample?.rounds ?? '—',
|
|
382
|
-
sample?.requests > 0 ? sample.cacheReports + ' / ' + sample.requests + ' 次('
|
|
383
|
-
+ dictionaryValue(sample.cacheReports / sample.requests, '%') + ')' : '—',
|
|
384
|
-
dictionaryValue(sample?.unknownInput, 'Token'), dictionaryValue(bounds?.[1], 'Token/轮')])),
|
|
385
|
-
h('p', null, 'L = 已知未命中输入 + ρ × 已知命中输入 + β × 输出 + 未知缓存输入的折算。上下界分别给未知部分乘 ρ 和 1。'),
|
|
386
|
-
h('p', null, 'R =(长期权重 × 全会话平均负担 + 近期权重 × 最近 10 轮平均负担)÷ 参照窗口。P_R = 100 × (1 − exp(−R / τ))。'),
|
|
387
|
-
h('p', null, '仅计已完成用户轮里的成功请求。A 的追加输入计入总用量。C 与请求负担都包含首次输入的影响,综合评分时需考虑重叠。')))
|
|
388
|
-
const structureData = pressure?.usage?.structurePressure
|
|
389
|
-
const invalidStructure = structureData?.measurementStatus === 'invalid'
|
|
390
|
-
const { toolWeight, epsilon, eta } = { ...pressureDefaults.structure, ...structureExperiment }
|
|
391
|
-
const structurePercent = (key, ratio) => structureExperiment[key]
|
|
392
|
-
?? (Number.isFinite(ratio) ? 100 * ratio : null)
|
|
393
|
-
const currentToolPercent = structurePercent('current', structureData?.currentShare)
|
|
394
|
-
const repeatedToolPercent = structurePercent('repeated', structureData?.repeatedShare)
|
|
395
|
-
const retryPercent = structurePercent('retry', structureData?.retryShare)
|
|
396
|
-
const { tool: toolStructure, failure: failureStructure, score: structureScore }
|
|
397
|
-
= scoreStructure(invalidStructure ? null : currentToolPercent, invalidStructure ? null : repeatedToolPercent,
|
|
398
|
-
retryPercent, toolWeight, epsilon, eta)
|
|
399
|
-
const structureScenario = ['current', 'repeated', 'retry'].some(key => structureExperiment[key] != null)
|
|
400
|
-
const scoreText = value => Number.isFinite(value) ? formatPressure(value) + ' / 100' : '—'
|
|
401
|
-
const structureCalculation = h('section', { className: 'card load-panel', style: { minWidth: 0 } },
|
|
402
|
-
h('h4', null, 'T + E · 当前会话结构与稳定性'),
|
|
403
|
-
h('p', { className: 'hint' }, structureScenario ? '使用情景输入 · 实验评分' : '基于当前会话用量 · 实验评分'),
|
|
404
|
-
invalidStructure ? h('p', { role: 'alert' }, '工具残留数据异常,T + E 和 A/B/C 分数无效。') : null,
|
|
405
|
-
structureData?.measurementReason === 'empty-request-surface'
|
|
406
|
-
? h('p', { className: 'hint' }, '该请求有实报用量,但缺少可见消息,当前工具残留未知。')
|
|
407
|
-
: structureData?.measurementReason === 'incomplete-request-surface'
|
|
408
|
-
? h('p', { className: 'hint' }, '该请求的可见消息重建不完整,当前工具残留未知。') : null,
|
|
409
|
-
h('div', { style: { display: 'flex', flexWrap: 'wrap', gap: '12px' } },
|
|
410
|
-
experimentNumber(structureExperiment, setStructureExperiment, 'current', '当前残留占比', currentToolPercent, 0, 100, 'any', '%'),
|
|
411
|
-
experimentNumber(structureExperiment, setStructureExperiment, 'repeated', '历史重复携带占比', repeatedToolPercent, 0, 100, 'any', '%'),
|
|
412
|
-
experimentNumber(structureExperiment, setStructureExperiment, 'toolWeight', '当前结构权重', toolWeight, 0, 1, .01, ''),
|
|
413
|
-
experimentNumber(structureExperiment, setStructureExperiment, 'retry', '重试消耗比例', retryPercent, 0, 100, 'any', '%'),
|
|
414
|
-
experimentNumber(structureExperiment, setStructureExperiment, 'epsilon', '异常敏感度 ε', epsilon, .001, 1, .001, ''),
|
|
415
|
-
experimentNumber(structureExperiment, setStructureExperiment, 'eta', '异常修正强度 η', eta, 0, 1, .01, ''),
|
|
416
|
-
h('button', { type: 'button', onClick: () => setStructureExperiment({}) }, '重置')),
|
|
417
|
-
h('div', { className: 'pressure-summary' },
|
|
418
|
-
pressureMetric('结构负担 T', scoreText(toolStructure == null ? null : 100 * toolStructure), '当前残留和历史重复携带'),
|
|
419
|
-
pressureMetric('失败负担 E', scoreText(failureStructure == null ? null : 100 * failureStructure), '已归因失败尝试用量'),
|
|
420
|
-
pressureMetric('复合压力', scoreText(structureScore), structureScore == null ? '缺少计算所需的会话读数' : '实验参数,尚未校准')),
|
|
421
|
-
h('details', { className: 'pressure-section' },
|
|
422
|
-
h('summary', null, '公式与取样 · ' + pressureVersions.structure),
|
|
423
|
-
h('p', null, 'T_s = w_t × 当前残留占比 + (1 − w_t) × 历史重复携带占比。比例超出 0–100% 时评分无效。'),
|
|
424
|
-
h('p', null, 'E_s = 1 − exp(−重试消耗比例 / ε)。P_Q = 100 × [1 − (1 − T_s) × (1 − η × E_s)]。'),
|
|
425
|
-
pressureTable(['来源', '分子', '分母'], [
|
|
426
|
-
['current-tool', '当前残留(同请求估算)', dictionaryValue(structureData?.retainedTokens, 'Token'), dictionaryValue(structureData?.currentInput, 'Token')],
|
|
427
|
-
['history-tool', '跨轮重复携带(请求估算)', dictionaryValue(structureData?.pairedCarry, 'Token·次'), dictionaryValue(structureData?.pairedInput, 'Token·次')],
|
|
428
|
-
['retry-tokens', '已归因重试', dictionaryValue(structureData?.retryTokens, 'Token'), dictionaryValue(structureData?.regularTokens, 'Token')],
|
|
429
|
-
]),
|
|
430
|
-
h('p', null, '模型实报请求输入 ' + dictionaryValue(structureData?.reportedInput, 'Token')
|
|
431
|
-
+ ',单独显示。工具残留使用同口径估算分母。'),
|
|
432
|
-
structureData?.measurementStatus === 'estimated' ? h('p', null, structureData.matchedDispatch
|
|
433
|
-
? '采样边界为该请求的首个响应事件。'
|
|
434
|
-
: '该请求缺少流式首事件,按日志中回复写入前的可见上下文重建。') : null,
|
|
435
|
-
h('p', null, '历史重复携带只使用有输入用量且能重建工具上下文的成功请求。匹配 '
|
|
436
|
-
+ (structureData?.pairedRequests ?? '—') + ' / ' + (structureData?.requestCount ?? '—') + ' 次。'),
|
|
437
|
-
h('p', null, '工具结果大小为估算。残留比例和失败次数用于描述负担,内容质量和换房收益尚无校准。')),
|
|
438
|
-
h('details', { className: 'pressure-section' },
|
|
439
|
-
h('summary', null, '残留年龄与显式失败率'),
|
|
440
|
-
pressureTable(['诊断指标', '当前读数'], [
|
|
441
|
-
['age-mean', 'Token 加权平均年龄', dictionaryValue(structureData?.ages?.mean, '轮')],
|
|
442
|
-
['age-median', 'Token 加权年龄中位数', dictionaryValue(structureData?.ages?.median, '轮')],
|
|
443
|
-
...(structureData?.ages?.older ?? []).map(item =>
|
|
444
|
-
['age-' + item.rounds, '超过 ' + item.rounds + ' 轮的残留 Token 占比', dictionaryValue(item.share, '%')]),
|
|
445
|
-
['model-failure', '模型失败率', dictionaryValue(structureData?.modelFailureRate, '%')],
|
|
446
|
-
['tool-failure', '工具失败率', dictionaryValue(structureData?.toolFailureRate, '%')],
|
|
447
|
-
])))
|
|
448
|
-
const scoreOf = value => Number.isFinite(value) ? (Math.round((value + Math.abs(value) * Number.EPSILON) * 10) / 10).toFixed(1) : '—'
|
|
449
|
-
const pointText = value => Number.isFinite(value) ? scoreOf(100 * value) : '—'
|
|
450
|
-
const signedScore = value => Number.isFinite(value) ? (value < 0 ? '−' : '+') + scoreOf(Math.abs(value)) : '—'
|
|
451
|
-
const compositeParameters = Object.fromEntries(Object.entries(compositeDefaults).map(([id, defaults]) => [
|
|
452
|
-
id, { ...defaults, ...compositeExperiment[id] },
|
|
453
|
-
]))
|
|
454
|
-
const subScores = [capacityScore, requestScores?.[1], structureScore]
|
|
455
|
-
const compositeScores = scoreComposite(subScores, compositeParameters, invalidStructure)
|
|
456
|
-
const plans = [
|
|
457
|
-
['A', '分层加权', 'P_A = 100 × (w_c c + w_r r + w_q q) / (w_c + w_r + w_q)',
|
|
458
|
-
{ wc: '容量权重 w_c', wr: '请求权重 w_r', wq: '结构权重 w_q' },
|
|
459
|
-
['容量、请求、结构贡献(分):' + (compositeScores.A.contributions?.map(pointText).join(' / ') ?? '—')]],
|
|
460
|
-
['B', '非线性合成', 'P_B = 100 × [1 − (1−c)^w_c × (1−r)^w_r × (1−q)^w_q]',
|
|
461
|
-
{ wc: '容量风险强度 w_c', wr: '请求风险强度 w_r', wq: '结构风险强度 w_q' },
|
|
462
|
-
['容量、请求、结构剩余因子:' + compositeScores.B.factors.map(value => value?.toFixed(4) ?? '—').join(' × '),
|
|
463
|
-
'乘积:' + (compositeScores.B.product?.toFixed(4) ?? '—')]],
|
|
464
|
-
['C', '容量主导修正', 'M = (w_r r + w_q q) / (w_r + w_q);P_C* = 100 × [c + μ(1−c)M]',
|
|
465
|
-
{ wr: '请求权重 w_r', wq: '结构权重 w_q', mu: '修正强度 μ' },
|
|
466
|
-
['联合修正 M:' + (compositeScores.C.mix?.toFixed(4) ?? '—'),
|
|
467
|
-
'基础容量压力:' + pointText(compositeScores.C.base),
|
|
468
|
-
'请求与结构修正:' + signedScore(compositeScores.C.correction == null ? null : 100 * compositeScores.C.correction)]],
|
|
469
|
-
]
|
|
470
|
-
const comparison = pressure?.usage?.comparison
|
|
471
|
-
const latestRound = comparison?.rounds ?? 0
|
|
472
|
-
const viewingRound = Math.min(latestRound, trendConfig.round ?? latestRound)
|
|
473
|
-
const earlierRound = viewingRound > 0 && viewingRound < latestRound
|
|
474
|
-
const trendChoices = (pressure?.usage?.history ?? []).filter(row => row.current || row.selected)
|
|
475
|
-
const currentTrendId = trendChoices.find(row => row.current)?.id
|
|
476
|
-
const isScenario = scenario || structureScenario
|
|
477
|
-
const childParameters = { capacity: { gamma, horizon, lambda }, request: { rho, beta, tau, recentWeight },
|
|
478
|
-
structure: { toolWeight, epsilon, eta } }
|
|
479
|
-
const historyPage = trendConfig.historyPage ?? 'compare'
|
|
480
|
-
const historyActive = pressureTab === 'history'
|
|
481
|
-
const wantBacktest = historyActive && historyPage === 'backtest'
|
|
482
|
-
const wantAttribution = historyActive && historyPage === 'attribution'
|
|
483
|
-
const trendMulti = trendConfig.multi ?? historyActive
|
|
484
|
-
const currentDiagnostic = earlierRound ? trendData[currentTrendId]?.points[viewingRound - 1]?.snapshot : comparison?.current
|
|
485
|
-
const scoreSnapshot = snapshot => scoreComposite(scoreDiagnostic(snapshot.inputs, childParameters), compositeParameters,
|
|
486
|
-
snapshot.inputs.invalidStructure)
|
|
487
|
-
const currentHistoryScores = currentDiagnostic ? scoreSnapshot(currentDiagnostic) : {}
|
|
488
|
-
const eligible = Object.values(currentHistoryScores).some(value => Number.isFinite(value.score))
|
|
489
|
-
const reasonText = {
|
|
490
|
-
short: '该 Session 尚未达到所选轮次', missing: '该轮诊断数据缺失',
|
|
491
|
-
pending: '该轮分析尚未完成', unavailable: '该轮必要数据无法重建',
|
|
492
|
-
filtered: '用户主动筛选排除(模型或窗口不同)', version: '数据版本不支持重新计算',
|
|
493
|
-
}
|
|
494
|
-
const historical = (comparison?.history ?? []).map(row => {
|
|
495
|
-
const series = trendData[row.id]
|
|
496
|
-
const snapshot = earlierRound ? series?.points[viewingRound - 1]?.snapshot : row.snapshot
|
|
497
|
-
const reason = earlierRound ? !series ? 'pending' : series.status !== 'analyzed' ? 'unavailable'
|
|
498
|
-
: series.points.length < viewingRound ? 'short' : 'missing' : row.reason ?? 'missing'
|
|
499
|
-
if (!snapshot) return { ...row, reason: reasonText[reason] }
|
|
500
|
-
if (!currentDiagnostic) return { ...row, reason: reasonText.missing }
|
|
501
|
-
if (!sameRoundDiagnostic(currentDiagnostic, snapshot)) return { ...row, reason: reasonText.version }
|
|
502
|
-
if (trendConfig.strict && !sameRoundDiagnostic(currentDiagnostic, snapshot, true)) return { ...row, reason: reasonText.filtered }
|
|
503
|
-
const scores = scoreSnapshot(snapshot)
|
|
504
|
-
if (!Object.values(scores).some(value => Number.isFinite(value.score))) return { ...row, reason: reasonText.missing }
|
|
505
|
-
return { ...row, scores, mismatch: !currentDiagnostic.route || currentDiagnostic.route !== snapshot.route
|
|
506
|
-
|| snapshot.configurationChanged || currentDiagnostic.configurationChanged }
|
|
507
|
-
})
|
|
508
|
-
const comparable = eligible ? historical.filter(row => row.scores && plans.some(([id]) =>
|
|
509
|
-
Number.isFinite(currentHistoryScores[id]?.score) && Number.isFinite(row.scores[id].score))) : []
|
|
510
|
-
const schemeStats = Object.fromEntries(plans.map(([id]) => [
|
|
511
|
-
id, pressureStatistics(currentHistoryScores[id]?.score, Number.isFinite(currentHistoryScores[id]?.score)
|
|
512
|
-
? comparable.map(row => row.scores[id].score) : []),
|
|
513
|
-
]))
|
|
514
|
-
const sampleHint = count => count === 0 ? '暂无可比样本' : count < 5 ? '样本极少,仅供参考' : count < 20 ? '样本有限' : '同轮可比样本'
|
|
515
|
-
const homeSchemeStats = Object.fromEntries(plans.map(([id]) => {
|
|
516
|
-
const latest = comparison?.current
|
|
517
|
-
const score = latest ? scoreSnapshot(latest)[id]?.score : null
|
|
518
|
-
const values = (comparison?.history ?? []).filter(row => row.snapshot && sameRoundDiagnostic(latest, row.snapshot, trendConfig.strict))
|
|
519
|
-
return [id, pressureStatistics(score, Number.isFinite(score) ? values.map(row => scoreSnapshot(row.snapshot)[id]?.score) : [])]
|
|
520
|
-
}))
|
|
521
|
-
const trendIds = trendMulti
|
|
522
|
-
? (trendConfig.ids ?? (currentTrendId ? [currentTrendId] : [])).filter(id => trendChoices.some(row => row.id === id))
|
|
523
|
-
: currentTrendId ? [currentTrendId] : []
|
|
524
|
-
const attributionId = trendChoices.some(row => row.id === trendConfig.attributionId)
|
|
525
|
-
? trendConfig.attributionId : currentTrendId ?? trendChoices[0]?.id
|
|
526
|
-
const loadedIds = wantAttribution ? [attributionId].filter(Boolean)
|
|
527
|
-
: wantBacktest || (historyActive && historyPage === 'same' && earlierRound)
|
|
528
|
-
|| (historyActive && historyPage === 'compare' && trendConfig.median && !trendMulti)
|
|
529
|
-
? trendChoices.map(row => row.id)
|
|
530
|
-
: historyActive && historyPage === 'compare' ? trendIds
|
|
531
|
-
: pressureTab === 'current' && currentTrendId ? [currentTrendId] : []
|
|
532
|
-
const trendRequestKey = JSON.stringify(loadedIds)
|
|
533
|
-
useEffect(() => {
|
|
534
|
-
if (tab !== 'memory' || !pressureOpen || !loadedIds.length) return
|
|
535
|
-
let active = true
|
|
536
|
-
setTrendLoading(true)
|
|
537
|
-
async function loadTrends() {
|
|
538
|
-
const data = Object.create(null)
|
|
539
|
-
for (const id of JSON.parse(trendRequestKey)) {
|
|
540
|
-
if (!active) return
|
|
541
|
-
try { data[id] = await jget('/session-pressure?trend=' + encodeURIComponent(id) + (wantAttribution ? '&diagnostics=1' : '')) }
|
|
542
|
-
catch { data[id] = { status: 'unavailable', points: [] } }
|
|
543
|
-
}
|
|
544
|
-
if (active) {
|
|
545
|
-
setTrendData(previous => ({ ...previous, ...data }))
|
|
546
|
-
setTrendLoading(false)
|
|
547
|
-
}
|
|
548
|
-
}
|
|
549
|
-
void loadTrends()
|
|
550
|
-
return () => { active = false }
|
|
551
|
-
}, [wantAttribution, tab, pressureOpen, trendRequestKey, comparison?.rounds, pressureRefresh])
|
|
552
|
-
|
|
553
|
-
const schemeColors = { A: '#3589e6', B: '#c96a11', C: '#24885d' }
|
|
554
|
-
const sessionColors = ['#3589e6', '#c96a11', '#24885d', '#9a55cb', '#c94e76']
|
|
555
|
-
const changeTrend = patch => setTrendConfig(previous => ({ ...previous, ...patch }))
|
|
556
|
-
const displayedPlans = !trendMulti && !trendConfig.plan ? ['A', 'B', 'C'] : [trendConfig.plan ?? 'A']
|
|
557
|
-
const trendScoreKey = JSON.stringify([childParameters, compositeParameters])
|
|
558
|
-
const scoredTrends = React.useMemo(() => Object.fromEntries(Object.entries(trendData).map(([id, data]) => [
|
|
559
|
-
id, (data.points ?? []).map(point => {
|
|
560
|
-
const snapshot = point.snapshot
|
|
561
|
-
const children = snapshot ? scoreDiagnostic(snapshot.inputs, childParameters) : null
|
|
562
|
-
return { ...point, children, eligible: children?.every(Number.isFinite) ?? false,
|
|
563
|
-
scores: children ? scoreComposite(children, compositeParameters, snapshot.inputs.invalidStructure) : null }
|
|
564
|
-
}),
|
|
565
|
-
])), [trendData, trendScoreKey])
|
|
566
|
-
const backtestIds = JSON.stringify(trendChoices.filter(row => !row.current).map(row => row.id))
|
|
567
|
-
const records = React.useMemo(() => wantBacktest || (wantAttribution && trendConfig.attributionForecast)
|
|
568
|
-
? pressureBacktestRecords(JSON.parse(backtestIds).map(id => [id, scoredTrends[id] ?? []]), compositeParameters)
|
|
569
|
-
: [], [wantBacktest, wantAttribution, trendConfig.attributionForecast, backtestIds, scoredTrends, trendScoreKey])
|
|
570
|
-
const methodLabels = { linear5: '最近 5 轮线性', linear10: '最近 10 轮线性', weighted: '5 / 10 / 20 轮加权' }
|
|
571
|
-
const groupLabels = { overall: '全部', before: '压缩或裁剪前', after: '压缩或裁剪后', neither: '两者皆无' }
|
|
572
|
-
const backtestGroup = trendConfig.backtestGroup ?? 'overall'
|
|
573
|
-
const backtestPlan = trendConfig.backtestPlan ?? 'A'
|
|
574
|
-
const methods = trendConfig.backtestMethods ?? backtestMethods
|
|
575
|
-
const methodsKey = methods.join(',')
|
|
576
|
-
const backtestSelection = React.useMemo(() => {
|
|
577
|
-
const selected = records.filter(row => row.plan === backtestPlan && methods.includes(row.method)
|
|
578
|
-
&& row.groups.includes(backtestGroup))
|
|
579
|
-
return trendConfig.backtestCommon ? commonPressureBacktestRecords(selected, methods) : selected
|
|
580
|
-
}, [records, methodsKey, backtestPlan, backtestGroup, trendConfig.backtestCommon])
|
|
581
|
-
const backtest = React.useMemo(() => summarizePressureBacktest(backtestSelection).filter(row =>
|
|
582
|
-
row.plan === backtestPlan && methods.includes(row.method)), [backtestSelection, methodsKey, backtestPlan])
|
|
583
|
-
const barColors = { 5: '#3589e6', 10: '#c96a11', 20: '#24885d' }
|
|
584
|
-
function backtestBars(metric, label) {
|
|
585
|
-
const signed = metric === 'bias'
|
|
586
|
-
const height = 190
|
|
587
|
-
const values = backtest.map(row => row.groups[backtestGroup][metric]).filter(Number.isFinite)
|
|
588
|
-
const limit = Math.max(1, Math.ceil(Math.max(0, ...values.map(Math.abs)) * 10) / 10)
|
|
589
|
-
const y = value => 20 + height * (limit - value) / (signed ? 2 * limit : limit)
|
|
590
|
-
const zero = y(0)
|
|
591
|
-
const ticks = signed ? [-limit, -limit / 2, 0, limit / 2, limit] : [0, limit / 2, limit]
|
|
592
|
-
return h('section', { className: 'pressure-section' },
|
|
593
|
-
h('h4', null, label + '(压力分)'),
|
|
594
|
-
h('svg', { viewBox: '0 0 680 250', role: 'group', 'aria-label': label, style: { width: '100%' } },
|
|
595
|
-
...ticks.map(tick => h('g', { key: tick },
|
|
596
|
-
h('line', { x1: 58, x2: 660, y1: y(tick), y2: y(tick), stroke: 'currentColor',
|
|
597
|
-
opacity: tick === 0 ? .85 : .2, strokeWidth: tick === 0 ? 2 : 1 }),
|
|
598
|
-
h('text', { x: 51, y: y(tick) + 4, textAnchor: 'end', fill: 'currentColor', fontSize: 12 },
|
|
599
|
-
tick === 0 ? '0' : (signed ? signedScore(tick) : scoreOf(tick))))),
|
|
600
|
-
...methods.map((method, index) => h('text', { key: method, x: 58 + (index + .5) * 602 / methods.length,
|
|
601
|
-
y: 235, fill: 'currentColor', textAnchor: 'middle', fontSize: 13 }, methodLabels[method])),
|
|
602
|
-
...backtest.map(row => {
|
|
603
|
-
const result = row.groups[backtestGroup]
|
|
604
|
-
const value = result[metric]
|
|
605
|
-
const x = 58 + (methods.indexOf(row.method) + .5) * 602 / methods.length
|
|
606
|
-
+ (backtestHorizons.indexOf(row.horizon) - 1) * 47
|
|
607
|
-
const title = methodLabels[row.method] + ' · 提前 ' + row.horizon + ' 轮 · ' + label + ' '
|
|
608
|
-
+ (signed ? signedScore(value) : scoreOf(value)) + ' · ' + result.count + ' 次预测 · ' + result.sessions + ' 个 Session'
|
|
609
|
-
if (!Number.isFinite(value)) return h('text', { key: row.method + row.horizon, x, y: zero - 5,
|
|
610
|
-
textAnchor: 'middle', fill: 'currentColor', fontSize: 12 }, '—')
|
|
611
|
-
const barHeight = value === 0 ? 2 : Math.max(1, Math.abs(zero - y(value)))
|
|
612
|
-
return h('g', { key: row.method + row.horizon, tabIndex: 0, 'aria-label': title },
|
|
613
|
-
h('title', null, title),
|
|
614
|
-
h('rect', { x: x - 15, y: value < 0 ? zero : zero - barHeight,
|
|
615
|
-
width: 30, height: barHeight, fill: barColors[row.horizon] }),
|
|
616
|
-
h('text', { x, y: value < 0 ? Math.min(220, y(value) + 12) : y(value) - 5, textAnchor: 'middle',
|
|
617
|
-
fill: 'currentColor', fontSize: 11 }, result.count + ' 次'))
|
|
618
|
-
})),
|
|
619
|
-
h('p', null, ...backtestHorizons.map(horizon => h('span', { key: horizon, style: { marginInlineEnd: 14 } },
|
|
620
|
-
h('span', { style: { color: barColors[horizon] }, 'aria-hidden': true }, '■ '), '提前 ' + horizon + ' 轮'))))
|
|
621
|
-
}
|
|
622
|
-
const detailSessions = [...new Set(backtestSelection.map(row => row.sessionId))]
|
|
623
|
-
const detailSession = detailSessions.includes(trendConfig.backtestSession) ? trendConfig.backtestSession : detailSessions[0]
|
|
624
|
-
const detailMethods = methods.filter(method => backtestSelection.some(row => row.sessionId === detailSession && row.method === method))
|
|
625
|
-
const detailMethod = detailMethods.includes(trendConfig.backtestMethod) ? trendConfig.backtestMethod : detailMethods[0]
|
|
626
|
-
const detailCandidates = backtestSelection.filter(row => row.sessionId === detailSession && row.method === detailMethod)
|
|
627
|
-
const detailOrigins = [...new Set(detailCandidates.map(row => row.origin))]
|
|
628
|
-
const detailOrigin = detailOrigins.includes(trendConfig.backtestOrigin) ? trendConfig.backtestOrigin : detailOrigins[0]
|
|
629
|
-
const detailRecords = detailCandidates.filter(row => row.origin === detailOrigin)
|
|
630
|
-
const detailLast = Math.max(1, ...detailRecords.map(row => row.target))
|
|
631
|
-
const detailPoints = (scoredTrends[detailSession] ?? []).filter(point => point.round <= detailLast)
|
|
632
|
-
.map(point => ({ ...point, score: point.scores?.[backtestPlan]?.score }))
|
|
633
|
-
const detailTargets = new Map(detailRecords.map(row => [row.target, row]))
|
|
634
|
-
const originScore = detailPoints.find(point => point.round === detailOrigin)?.score
|
|
635
|
-
const detailX = round => 48 + 611 * (round - 1) / Math.max(1, detailLast - 1)
|
|
636
|
-
const detailY = value => 217 - 1.93 * value
|
|
637
|
-
const sessionName = id => trendChoices.find(row => row.id === id)?.title || '未命名 Session ' + (detailSessions.indexOf(id) + 1)
|
|
638
|
-
const detailChart = detailRecords.length ? h('section', { className: 'pressure-section' },
|
|
639
|
-
h('h4', null, '真实压力与预测压力'),
|
|
640
|
-
h('div', { style: { display: 'flex', flexWrap: 'wrap', gap: 12 } },
|
|
641
|
-
h('label', null, '历史 Session ', h('select', { value: detailSession,
|
|
642
|
-
onChange: event => changeTrend({ backtestSession: event.currentTarget.value }) },
|
|
643
|
-
...detailSessions.map(id => h('option', { key: id, value: id }, sessionName(id))))),
|
|
644
|
-
h('label', null, '预测方法 ', h('select', { value: detailMethod,
|
|
645
|
-
onChange: event => changeTrend({ backtestMethod: event.currentTarget.value }) },
|
|
646
|
-
...detailMethods.map(method => h('option', { key: method, value: method }, methodLabels[method])))),
|
|
647
|
-
h('label', null, '预测起点 ', h('select', { value: detailOrigin,
|
|
648
|
-
onChange: event => changeTrend({ backtestOrigin: Number(event.currentTarget.value) }) },
|
|
649
|
-
...detailOrigins.map(round => h('option', { key: round, value: round }, '第 ' + round + ' 轮'))))),
|
|
650
|
-
h('svg', { viewBox: '0 0 680 255', role: 'group', 'aria-label': '真实压力与预测压力', style: { width: '100%' } },
|
|
651
|
-
...[0, 25, 50, 75, 100].map(value => h('g', { key: value },
|
|
652
|
-
h('line', { x1: 48, x2: 660, y1: detailY(value), y2: detailY(value), stroke: 'currentColor', opacity: .2 }),
|
|
653
|
-
h('text', { x: 40, y: detailY(value) + 4, textAnchor: 'end', fill: 'currentColor', fontSize: 12 }, value))),
|
|
654
|
-
...trendSegments(detailPoints).map((segment, i) => h('polyline', { key: 'actual:' + i, stroke: '#3589e6',
|
|
655
|
-
strokeWidth: 2, fill: 'none', points: segment.map(point => detailX(point.round) + ',' + detailY(point.score)).join(' ') })),
|
|
656
|
-
...detailPoints.filter(point => point.markers.length).map(point => h('g', { key: 'event:' + point.round, tabIndex: 0 },
|
|
657
|
-
h('title', null, '第 ' + point.round + ' 轮 · ' + point.markers.map(marker => marker.type).join(' / ')),
|
|
658
|
-
h('line', { x1: detailX(point.round), x2: detailX(point.round), y1: 20, y2: 217, stroke: 'currentColor', opacity: .3, strokeDasharray: '2 4' }),
|
|
659
|
-
h('circle', { cx: detailX(point.round), cy: 20, r: 4, fill: 'currentColor' }))),
|
|
660
|
-
h('line', { x1: detailX(detailOrigin), x2: detailX(detailOrigin), y1: 24, y2: 217, stroke: 'currentColor', opacity: .7 }),
|
|
661
|
-
...detailRecords.map(row => h('line', { key: 'future:' + row.target, x1: detailX(detailOrigin), y1: detailY(originScore),
|
|
662
|
-
x2: detailX(row.target), y2: detailY(row.estimate), stroke: '#c96a11', strokeWidth: 2, strokeDasharray: '6 5' })),
|
|
663
|
-
...detailPoints.filter(point => Number.isFinite(point.score)).map(point => {
|
|
664
|
-
const row = detailTargets.get(point.round)
|
|
665
|
-
const text = '第 ' + point.round + ' 轮 · 实际 ' + scoreOf(point.score)
|
|
666
|
-
+ (row ? ' · 预测 ' + scoreOf(row.estimate) + ' · 误差 ' + signedScore(row.estimate - row.actual) : '')
|
|
667
|
-
return h('g', { key: 'point:' + point.round, tabIndex: row || point.round === detailOrigin ? 0 : undefined, 'aria-label': text },
|
|
668
|
-
h('title', null, text),
|
|
669
|
-
h('circle', { cx: detailX(point.round), cy: detailY(point.score), r: 3, fill: '#3589e6' }),
|
|
670
|
-
row ? h('circle', { cx: detailX(point.round), cy: detailY(row.estimate), r: 5, fill: '#c96a11' }) : null)
|
|
671
|
-
}),
|
|
672
|
-
...[...new Set([1, detailOrigin, ...detailRecords.map(row => row.target)])].map(round =>
|
|
673
|
-
h('text', { key: round, x: detailX(round), y: 239, fill: 'currentColor', fontSize: 12, textAnchor: 'middle' }, round))),
|
|
674
|
-
h('p', null, '蓝实线为真实压力,橙虚线通向各有效预测目标。竖线标出预测起点及已记录事件。'),
|
|
675
|
-
pressureTable(['目标轮', '实际', '预测', '误差', '归因'], detailRecords.map(row =>
|
|
676
|
-
[row.target, row.target, scoreOf(row.actual), scoreOf(row.estimate), signedScore(row.estimate - row.actual),
|
|
677
|
-
h('button', { type: 'button', onClick: () => changeTrend({ historyPage: 'attribution', attributionId: row.sessionId,
|
|
678
|
-
attributionStart: row.origin, attributionEnd: row.target, attributionPlan: row.plan,
|
|
679
|
-
attributionForecast: { method: row.method } }) }, '分析本次预测误差')])))
|
|
680
|
-
: h('p', null, '当前筛选下暂无有效的逐次预测。')
|
|
681
|
-
const pressureBacktest = h('section', { className: 'pressure-section' },
|
|
682
|
-
h('h4', null, '历史预测回测 v0.1'),
|
|
683
|
-
!wantBacktest ? null : h('div', null,
|
|
684
|
-
h('div', { style: { display: 'flex', flexWrap: 'wrap', gap: 12 } },
|
|
685
|
-
h('label', null, '综合公式 ', h('select', { value: backtestPlan,
|
|
686
|
-
onChange: event => changeTrend({ backtestPlan: event.currentTarget.value }) },
|
|
687
|
-
...plans.map(([key, name]) => h('option', { key, value: key }, key + ' · ' + name)))),
|
|
688
|
-
h('label', null, '事件分组 ', h('select', { value: backtestGroup,
|
|
689
|
-
onChange: event => changeTrend({ backtestGroup: event.currentTarget.value }) },
|
|
690
|
-
...Object.entries(groupLabels).map(([key, label]) => h('option', { key, value: key }, label)))),
|
|
691
|
-
h('label', null, h('input', { type: 'checkbox', checked: !!trendConfig.backtestCommon,
|
|
692
|
-
onChange: event => changeTrend({ backtestCommon: event.currentTarget.checked }) }), ' 共同样本比较')),
|
|
693
|
-
h('fieldset', null, h('legend', null, '参与比较的预测方法'),
|
|
694
|
-
...backtestMethods.map(method => h('label', { key: method, style: { marginInlineEnd: 12 } },
|
|
695
|
-
h('input', { type: 'checkbox', checked: methods.includes(method), disabled: methods.length === 1 && methods.includes(method),
|
|
696
|
-
onChange: event => {
|
|
697
|
-
const checked = event.currentTarget.checked
|
|
698
|
-
changeTrend({ backtestMethods: backtestMethods.filter(id => id === method ? checked : methods.includes(id)) })
|
|
699
|
-
} }), ' ' + methodLabels[method]))),
|
|
700
|
-
h('p', { className: 'hint' }, trendConfig.backtestCommon
|
|
701
|
-
? '各方法在同一提前轮数使用相同的 Session、起点与目标轮。'
|
|
702
|
-
: '各方法使用各自的有效预测。柱旁标注预测次数,样本集合可能不同。'),
|
|
703
|
-
trendLoading ? h('p', { role: 'status' }, '正在重建历史数据…') : null,
|
|
704
|
-
backtestBars('mae', 'MAE 对比'),
|
|
705
|
-
backtestBars('bias', '预测偏差'),
|
|
706
|
-
detailChart,
|
|
707
|
-
h('details', { className: 'pressure-section' }, h('summary', null, '回测统计明细'),
|
|
708
|
-
h('div', { style: { overflowX: 'auto' } }, pressureTable(['预测方法', '提前轮数', '方案', '有效预测', '会话数', 'MAE', '偏差'],
|
|
709
|
-
backtest.map(row => {
|
|
710
|
-
const result = row.groups[backtestGroup]
|
|
711
|
-
return [row.method + ':' + row.horizon + ':' + row.plan, methodLabels[row.method], row.horizon,
|
|
712
|
-
row.plan, result.count, result.sessions, scoreOf(result.mae), signedScore(result.bias)]
|
|
713
|
-
}))))))
|
|
714
|
-
const trendSeriesKey = JSON.stringify([trendIds, displayedPlans, trendChoices.map(row => [row.id, row.title])])
|
|
715
|
-
const { series, currentTrend, maxRound, firstRound } = React.useMemo(() => {
|
|
716
|
-
const series = trendIds.flatMap((id, index) => displayedPlans.map(plan => ({
|
|
717
|
-
id: id + ':' + plan, label: trendMulti ? (trendChoices.find(row => row.id === id)?.title || (id === currentTrendId ? '当前 Session' : '未命名 Session ' + (index + 1))) : plan,
|
|
718
|
-
sessionLabel: trendMulti ? null : (trendChoices.find(row => row.id === id)?.title || '当前 Session'),
|
|
719
|
-
color: trendMulti ? sessionColors[index] : schemeColors[plan],
|
|
720
|
-
points: (scoredTrends[id] ?? []).map(point => ({ ...point, score: point.scores?.[plan].score })),
|
|
721
|
-
})))
|
|
722
|
-
const currentTrend = scoredTrends[currentTrendId] ?? []
|
|
723
|
-
const historicalTrends = trendConfig.median && !trendMulti
|
|
724
|
-
? trendChoices.filter(row => row.id !== currentTrendId).map(row => scoredTrends[row.id] ?? []) : []
|
|
725
|
-
const maxRound = Math.max(1, ...series.map(line => line.points.findLast(point => Number.isFinite(point.score))?.round ?? 0))
|
|
726
|
-
const firstRound = trendConfig.range ? Math.max(1, maxRound - trendConfig.range + 1) : 1
|
|
727
|
-
if (historicalTrends.length) for (const plan of displayedPlans) {
|
|
728
|
-
series.push({ id: 'median:' + plan, label: plan + ' 历史中位数', color: schemeColors[plan], dashed: true,
|
|
729
|
-
points: currentTrend.filter(point => point.round >= firstRound && point.round <= maxRound).map(point => {
|
|
730
|
-
const history = historicalTrends.map(other => other[point.round - 1]).filter(other =>
|
|
731
|
-
Number.isFinite(point.scores?.[plan].score) && Number.isFinite(other?.scores?.[plan].score)
|
|
732
|
-
&& sameRoundDiagnostic(point.snapshot, other.snapshot, trendConfig.strict))
|
|
733
|
-
const stats = pressureStatistics(point.scores?.[plan].score, history.map(other => other.scores[plan].score))
|
|
734
|
-
return { round: point.round, score: stats.median, count: stats.count }
|
|
735
|
-
}) })
|
|
736
|
-
}
|
|
737
|
-
return { series, currentTrend, maxRound, firstRound }
|
|
738
|
-
}, [scoredTrends, trendSeriesKey, trendMulti, trendConfig.median, trendConfig.strict, trendConfig.range, currentTrendId])
|
|
739
|
-
const trendX = round => maxRound === firstRound ? 386 : 46 + 680 * (round - firstRound) / (maxRound - firstRound)
|
|
740
|
-
const trendY = score => 236 - score * 2.1
|
|
741
|
-
const shownSeries = series.map(line => ({ ...line, points: line.points.filter(point => point.round >= firstRound && point.round <= maxRound) }))
|
|
742
|
-
const shownMarkers = (trendMulti ? trendIds.flatMap(id => (scoredTrends[id] ?? [])
|
|
743
|
-
.map(point => ({ ...point, markerId: id, markerLabel: trendChoices.find(row => row.id === id)?.title || 'Session' })))
|
|
744
|
-
: currentTrend).filter(point => point.round >= firstRound && point.round <= maxRound)
|
|
745
|
-
const focusRound = Math.min(maxRound, Math.max(firstRound, trendFocus ?? (viewingRound || maxRound)))
|
|
746
|
-
const routeDetails = point => {
|
|
747
|
-
const route = point.snapshot?.route ? JSON.parse(point.snapshot.route) : null
|
|
748
|
-
return (route ? ' · ' + route[1] + ' / ' + route[2].toLocaleString() + ' Token' : '')
|
|
749
|
-
+ (point.switched || point.snapshot?.configurationChanged ? ' · 曾切换配置' : '')
|
|
750
|
-
}
|
|
751
|
-
const chooseRound = round => {
|
|
752
|
-
setTrendFocus(round > latestRound ? round : null)
|
|
753
|
-
changeTrend({ round: Math.min(latestRound, round) })
|
|
754
|
-
}
|
|
755
|
-
const pointerRound = event => {
|
|
756
|
-
const bounds = event.currentTarget.getBoundingClientRect()
|
|
757
|
-
return bounds.width > 0 ? firstRound + Math.round((maxRound - firstRound)
|
|
758
|
-
* Math.min(1, Math.max(0, (event.clientX - bounds.left) / bounds.width))) : focusRound
|
|
759
|
-
}
|
|
760
|
-
const focusDetails = shownSeries.flatMap(line => {
|
|
761
|
-
const point = line.points.find(item => item.round === focusRound)
|
|
762
|
-
return point ? [[line.sessionLabel, line.label].filter(Boolean).join(' · ') + ' ' + scoreOf(point.score) + routeDetails(point)
|
|
763
|
-
+ (point.count == null ? '' : '(' + point.count + ' 个样本)')] : []
|
|
764
|
-
})
|
|
765
|
-
const markerText = marker => marker.type + (marker.time == null ? '' : ' · ' + new Date(marker.time).toLocaleString())
|
|
766
|
-
+ (Number.isFinite(marker.tokenChange) ? ' · ' + signedScore(marker.tokenChange) + ' Token' : '')
|
|
767
|
-
const plotTicks = [...new Set(Array.from({ length: 6 }, (_, i) => Math.round(firstRound + (maxRound - firstRound) * i / 5)))]
|
|
768
|
-
const trendChart = h('section', { className: 'pressure-section' },
|
|
769
|
-
h('h4', null, '压力走势与多 Session 对比'),
|
|
770
|
-
h('div', { style: { display: 'flex', flexWrap: 'wrap', gap: '12px' } },
|
|
771
|
-
h('label', null, '模式 ', h('select', { value: trendMulti ? 'multi' : 'single',
|
|
772
|
-
onChange: event => changeTrend({ multi: event.currentTarget.value === 'multi', plan: null }) },
|
|
773
|
-
h('option', { value: 'single' }, '当前 Session'), h('option', { value: 'multi' }, '多 Session'))),
|
|
774
|
-
h('label', null, '公式 ', h('select', { value: trendConfig.plan ?? (trendMulti ? 'A' : ''),
|
|
775
|
-
onChange: event => changeTrend({ plan: event.currentTarget.value || null }) },
|
|
776
|
-
trendMulti ? null : h('option', { value: '' }, 'A + B + C'),
|
|
777
|
-
...plans.map(([id, name]) => h('option', { key: id, value: id }, id + ' · ' + name)))),
|
|
778
|
-
h('label', null, '轮次范围 ', h('select', { value: trendConfig.range ?? 0,
|
|
779
|
-
onChange: event => changeTrend({ range: Number(event.currentTarget.value) }) },
|
|
780
|
-
...[0, 10, 20, 50].map(value => h('option', { key: value, value }, value ? '最近 ' + value + ' 轮' : '全部轮次')))),
|
|
781
|
-
trendMulti ? null : h('label', null,
|
|
782
|
-
h('input', { type: 'checkbox', checked: !!trendConfig.median,
|
|
783
|
-
onChange: event => changeTrend({ median: event.currentTarget.checked }) }), ' 历史同轮次中位数')),
|
|
784
|
-
trendMulti ? h('div', null, h('p', null, '最多选择 5 个 Session。历史候选来自历史页勾选的会话。'),
|
|
785
|
-
...trendChoices.map((row, index) => h('label', { key: row.id, style: { display: 'block' } },
|
|
786
|
-
h('input', { type: 'checkbox', checked: trendIds.includes(row.id), disabled: trendIds.length >= 5 && !trendIds.includes(row.id),
|
|
787
|
-
onChange: event => changeTrend({ ids: event.currentTarget.checked ? [...trendIds, row.id] : trendIds.filter(id => id !== row.id) }) }),
|
|
788
|
-
' ' + (row.current ? '当前 Session' : row.title || '未命名 Session ' + (index + 1))))) : null,
|
|
789
|
-
!historyActive || historyPage !== 'compare' ? null : h('div', null,
|
|
790
|
-
trendLoading ? h('p', { role: 'status' }, '正在重建逐轮诊断…') : null,
|
|
791
|
-
isScenario ? h('p', { className: 'hint' }, '走势使用轮末实际采样,情景覆盖仅作用于实时试算卡片。') : null,
|
|
792
|
-
!trendLoading && (loadedIds.some(id => trendData[id]?.status !== 'analyzed'))
|
|
793
|
-
? h('p', { className: 'hint' }, '部分会话的日志不可用或超出本地分析范围。') : null,
|
|
794
|
-
!shownSeries.some(line => line.points.some(point => Number.isFinite(point.score))) ? h('p', null, '该范围暂无可绘制的完整轮末读数。') : null,
|
|
795
|
-
shownSeries.length ? h('svg', { viewBox: '0 0 750 282', role: 'group', 'aria-label': '用户已完成轮次与压力分',
|
|
796
|
-
style: { width: '100%', height: 'auto', minHeight: '160px' } },
|
|
797
|
-
...[0, 25, 50, 75, 100].map(score => h('g', { key: score },
|
|
798
|
-
h('line', { x1: 46, x2: 726, y1: trendY(score), y2: trendY(score), stroke: 'currentColor', opacity: .14 }),
|
|
799
|
-
h('text', { x: 38, y: trendY(score) + 4, textAnchor: 'end', fill: 'currentColor', fontSize: 12 }, score))),
|
|
800
|
-
...plotTicks.map(round => h('text', { key: round, x: trendX(round), y: 253, textAnchor: 'middle', fill: 'currentColor', fontSize: 12 }, round)),
|
|
801
|
-
h('text', { x: 386, y: 273, textAnchor: 'middle', fill: 'currentColor', fontSize: 12 }, '已完成用户轮次'),
|
|
802
|
-
...shownMarkers.flatMap(point => point.markers.length ? [h('g', { key: 'event:' + (point.markerId ?? '') + ':' + point.round, tabIndex: 0 },
|
|
803
|
-
h('title', null, '第 ' + point.round + ' 轮 · ' + (point.markerLabel ? point.markerLabel + ' · ' : '') + point.markers.map(markerText).join(' / ')),
|
|
804
|
-
h('line', { x1: trendX(point.round), x2: trendX(point.round), y1: 25, y2: 236,
|
|
805
|
-
stroke: 'currentColor', opacity: .35, strokeDasharray: '3 3' }),
|
|
806
|
-
h('circle', { cx: trendX(point.round), cy: 25, r: 4, fill: 'currentColor' }))] : []),
|
|
807
|
-
...shownSeries.map(line => h('g', { key: line.id },
|
|
808
|
-
...trendSegments(line.points).map((segment, i) => h('polyline', { key: i, fill: 'none', stroke: line.color, strokeWidth: 2,
|
|
809
|
-
strokeDasharray: line.dashed ? '6 4' : undefined,
|
|
810
|
-
points: segment.map(point => trendX(point.round) + ',' + trendY(point.score)).join(' ') })),
|
|
811
|
-
...line.points.filter(point => Number.isFinite(point.score) && (line.points.length <= 100 || point.round === focusRound
|
|
812
|
-
|| !Number.isFinite(line.points[point.round - firstRound - 1]?.score)
|
|
813
|
-
|| !Number.isFinite(line.points[point.round - firstRound + 1]?.score))).map(point => {
|
|
814
|
-
const label = [line.sessionLabel, line.label].filter(Boolean).join(' · ')
|
|
815
|
-
+ ' · 第 ' + point.round + ' 轮 · ' + scoreOf(point.score) + ' 分' + routeDetails(point)
|
|
816
|
-
+ (point.count == null ? '' : ' · ' + point.count + ' 个样本')
|
|
817
|
-
return h('circle', { key: point.round, cx: trendX(point.round), cy: trendY(point.score), r: 3.5,
|
|
818
|
-
fill: line.color, tabIndex: point.round === line.points.at(-1)?.round ? 0 : undefined,
|
|
819
|
-
'aria-label': label }, h('title', null, label))
|
|
820
|
-
}))),
|
|
821
|
-
h('line', { x1: trendX(focusRound), x2: trendX(focusRound), y1: 25, y2: 236,
|
|
822
|
-
stroke: 'currentColor', opacity: .3, pointerEvents: 'none' }),
|
|
823
|
-
h('rect', { x: 46, y: 32, width: 680, height: 204, fill: 'transparent',
|
|
824
|
-
onPointerMove: event => setTrendFocus(pointerRound(event)),
|
|
825
|
-
onPointerLeave: () => setTrendFocus(null),
|
|
826
|
-
onClick: event => chooseRound(pointerRound(event)) })) : null,
|
|
827
|
-
shownSeries.length ? h('div', null,
|
|
828
|
-
h('label', null, '查看第 ' + focusRound + ' 轮 ', h('input', { type: 'range', min: firstRound, max: maxRound,
|
|
829
|
-
value: focusRound, onChange: event => chooseRound(event.currentTarget.valueAsNumber) })),
|
|
830
|
-
h('button', { type: 'button', onClick: () => { setTrendFocus(null); changeTrend({ round: null }) } }, '最新轮次'),
|
|
831
|
-
h('p', null, focusDetails.length ? focusDetails.join(' · ') : '该轮暂无压力读数'),
|
|
832
|
-
...((shownMarkers.find(point => point.round === focusRound)?.markers ?? [])
|
|
833
|
-
.map((marker, index) => h('p', { key: index }, markerText(marker))))) : null,
|
|
834
|
-
h('div', { style: { display: 'flex', flexWrap: 'wrap', gap: '12px' } }, ...shownSeries.map(line =>
|
|
835
|
-
h('span', { key: line.id }, h('span', { style: { color: line.color }, 'aria-hidden': true }, line.dashed ? '┄ ' : '━ '), line.label))),
|
|
836
|
-
h('p', { className: 'hint' }, '断点表示该轮缺少必要诊断。纵向虚线标记模型、窗口或真实压缩与裁剪事件。')))
|
|
837
|
-
const overallScores = Object.values(compositeScores).map(item => item.score).filter(Number.isFinite)
|
|
838
|
-
const compositeCalculation = h('section', { className: 'card load-panel', style: { minWidth: 0 } },
|
|
839
|
-
h('h4', null, '综合压力公式'),
|
|
840
|
-
h('p', { className: 'hint' }, '容量 / 请求 / 结构:' + subScores.map(scoreOf).join(' / ') + ' 分 · ' + pressureVersions.composite
|
|
841
|
-
+ (isScenario ? ' · 使用子模块情景输入' : '')),
|
|
842
|
-
overallScores.length > 1 ? h('p', null, '最大分差:' + scoreOf(Math.max(...overallScores) - Math.min(...overallScores)) + ' 分') : null,
|
|
843
|
-
...plans.map(([id, name, formula, labels, details]) => {
|
|
844
|
-
const params = compositeParameters[id]
|
|
845
|
-
const setParams = update => setCompositeExperiment(previous => ({ ...previous, [id]: update(previous[id] ?? {}) }))
|
|
846
|
-
return h('section', { key: id, className: 'card load-panel', style: { minWidth: 0 } },
|
|
847
|
-
h('h4', null, id + ' · ' + name + ' · ' + scoreOf(compositeScores[id].score) + ' / 100'),
|
|
848
|
-
h('div', { style: { display: 'flex', flexWrap: 'wrap', gap: '12px' } },
|
|
849
|
-
...Object.entries(labels).map(([key, label]) => h('label', { key },
|
|
850
|
-
label + ' ' + params[key].toFixed(2) + ' ',
|
|
851
|
-
h('input', { type: 'range', min: 0, max: 1, step: .01, value: params[key],
|
|
852
|
-
onChange: event => {
|
|
853
|
-
const value = event.currentTarget.valueAsNumber
|
|
854
|
-
setParams(previous => ({ ...previous, [key]: value }))
|
|
855
|
-
} }))),
|
|
856
|
-
h('button', { type: 'button', onClick: () => setParams(() => ({})) }, '重置默认参数')),
|
|
857
|
-
id === 'B' && compositeScores.B.disabled ? h('p', null, '全部风险贡献已关闭') : null,
|
|
858
|
-
h('details', { className: 'pressure-section' },
|
|
859
|
-
h('summary', null, '公式与计算明细'),
|
|
860
|
-
h('p', null, formula),
|
|
861
|
-
h('p', null, 'c、r、q = 三个子压力分别除以 100。'),
|
|
862
|
-
id === 'A' ? h('p', null, '权重总和为 0 时显示 —。') : null,
|
|
863
|
-
id === 'B' ? h('p', null, '风险强度分别生效;强度为 0 时对应因子为 1。') : null,
|
|
864
|
-
id === 'C' ? h('p', null, '请求与结构权重总和为 0 时 M = 0。μ 为试算参数。') : null,
|
|
865
|
-
...details.map(line => h('p', { key: line }, line))))
|
|
866
|
-
}))
|
|
867
|
-
const sameRoundPanel = h('section', { className: 'pressure-section' },
|
|
868
|
-
h('h4', null, '历史同轮次对比'),
|
|
869
|
-
h('p', null, '当前已完成 ' + (latestRound || '—') + ' 轮 · 查看第 ' + (viewingRound || '—')
|
|
870
|
-
+ ' 轮 · 可比较历史会话 ' + comparable.length + ' 个'),
|
|
871
|
-
latestRound ? h('label', null, '当前查看轮次 ', h('input', { type: 'range', min: 1, max: latestRound,
|
|
872
|
-
value: viewingRound, onChange: event => chooseRound(event.currentTarget.valueAsNumber) })) : null,
|
|
873
|
-
h('label', null, h('input', { type: 'checkbox', checked: !!trendConfig.strict,
|
|
874
|
-
onChange: event => changeTrend({ strict: event.currentTarget.checked }) }), ' 仅同配置'),
|
|
875
|
-
h('p', { className: 'hint' }, eligible ? sampleHint(comparable.length) : '当前选定轮的诊断正在重建或数据缺失。'),
|
|
876
|
-
comparable.some(row => row.mismatch) ? h('p', { className: 'hint' },
|
|
877
|
-
'包含不同模型或上下文窗口的 Session。分数经过各自窗口归一化,但跨模型可比性尚未校准。') : null,
|
|
878
|
-
currentDiagnostic?.route ? h('p', null, '比较配置:' + JSON.parse(currentDiagnostic.route).map(value => String(value)).join(' / ')) : null,
|
|
879
|
-
comparison?.saveFailed ? h('p', { role: 'status' }, '轮末诊断快照保存失败。') : null,
|
|
880
|
-
h('div', { style: { overflowX: 'auto' } }, pressureTable(['方案', '轮末分数', '样本数', '同轮中位数', '百分位', '与中位数差值'],
|
|
881
|
-
plans.map(([id, name]) => {
|
|
882
|
-
const score = currentHistoryScores[id]?.score
|
|
883
|
-
const stats = schemeStats[id]
|
|
884
|
-
return [id, id + ' · ' + name, scoreOf(score), stats.count, scoreOf(stats.median),
|
|
885
|
-
stats.percentile == null ? '—' : scoreOf(stats.percentile) + '%', signedScore(stats.difference)]
|
|
886
|
-
}))),
|
|
887
|
-
h('p', { className: 'hint' }, '百分位 =(严格较低的样本数 + 一半的同分样本数)÷ 有效样本数。'),
|
|
888
|
-
historical.some(row => row.reason) ? h('details', { className: 'pressure-section' },
|
|
889
|
-
h('summary', null, '不可比较的历史会话'),
|
|
890
|
-
pressureTable(['会话', '原因'], historical.filter(row => row.reason).map(row => [row.id, row.title || '未命名会话', row.reason]))) : null)
|
|
891
|
-
|
|
892
|
-
const pressureGrid = { display: 'grid', gridTemplateColumns: 'repeat(auto-fit, minmax(min(100%, 165px), 1fr))', gap: 12 }
|
|
893
|
-
const scoreNames = ['容量', '请求', '结构']
|
|
894
|
-
const childColors = ['#5c9ded', '#cc8b46', '#58ab86']
|
|
895
|
-
const currentSeries = scoredTrends[currentTrendId] ?? []
|
|
896
|
-
const latestPoint = currentSeries.at(-1)
|
|
897
|
-
const priorPoint = currentSeries.find(point => point.round === latestPoint?.round - 5)
|
|
898
|
-
const rowFor = (id, label, scope) => dictionary.find(metric => metric.id === id)?.rows.find(row =>
|
|
899
|
-
row.label === label && (!scope || row.scope === scope))
|
|
900
|
-
const measureText = row => dictionaryValue(row?.value, row?.unit)
|
|
901
|
-
const summaryMeasures = [
|
|
902
|
-
['上下文占用率', rowFor('C', '窗口占用率')], ['剩余窗口', rowFor('C', '剩余容量')],
|
|
903
|
-
['最近 10 轮平均净增长', rowFor('G', '平均净增长', '最近 10 轮')],
|
|
904
|
-
['平均每轮消耗', rowFor('U', '平均每轮消耗')], ['工具结果残留', rowFor('T', '残留占比')],
|
|
905
|
-
['缓存未命中', rowFor('K', '未命中比例')], ['缓存报告覆盖', rowFor('K', '缓存统计覆盖率')],
|
|
906
|
-
]
|