dsh-recent-usage-metrics 0.2.3 → 0.3.0

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/client/client.js CHANGED
@@ -89,7 +89,17 @@ window.__ModuleLoader__.load({
89
89
  drawerEmpty: '还没有完成的请求。发一条消息后,它的指标会出现在这里。',
90
90
  drawerLive: '生成中',
91
91
  drawerTools: '调用工具中',
92
+ drawerCompacting: '上下文压缩中',
93
+ drawerCompacted: '上下文压缩完成',
92
94
  interrupted: '中断',
95
+ /*
96
+ * The compaction phase has no model of its own until it finishes: `compaction/start`
97
+ * records only an id and a turn, and `compaction/summary` is what reports the model. While
98
+ * it runs, the summarizer reuses the routed model of the last request, so that is what the
99
+ * row can honestly say — falling back to this general wording when even that is unknown.
100
+ */
101
+ compactionSpeed: '压缩上下文',
102
+ usingChatModel: '使用对话模型',
93
103
  colIndex: '#',
94
104
  colTime: '时间',
95
105
  colTtft: '首字',
@@ -102,6 +112,16 @@ window.__ModuleLoader__.load({
102
112
  secondsAgo: '{count} 秒前',
103
113
  minutesAgo: '{count} 分钟前',
104
114
  hoursAgo: '{count} 小时前',
115
+ // Column-header hints. `{bolt}` / `{tools}` / `{compact}` are replaced by the glyphs
116
+ // themselves, which is why these are rendered by the tooltip component and not by title.
117
+ hintIndex: '行号:1–10 为已完成的最近记录,{bolt} 为模型输出中,{tools} 为工具调用中,{compact} 为压缩上下文中',
118
+ hintTime: '请求发出的时刻(本地时间)',
119
+ hintTtft: '从发出到收到第一个 token 的耗时',
120
+ hintSpeed: '模型生成速度 = 输出 token ÷ 解码时长',
121
+ hintTokens: '模型本次生成的 token 数',
122
+ hintTotal: '请求耗时:从发出请求一直到模型输出结束',
123
+ hintAmortized: '输出 token ÷ 总用时,包含请求时间和响应时间,更加能表明本地到模型输出完整链路的速度',
124
+ tokensHint: '输入 {input} · 缓存命中 {hit}',
105
125
  }
106
126
 
107
127
  const en = {
@@ -125,7 +145,11 @@ window.__ModuleLoader__.load({
125
145
  drawerEmpty: 'No completed requests yet. Send a message and its metrics appear here.',
126
146
  drawerLive: 'Streaming',
127
147
  drawerTools: 'Calling tools',
148
+ drawerCompacting: 'Compacting context',
149
+ drawerCompacted: 'Context compacted',
128
150
  interrupted: 'Interrupted',
151
+ compactionSpeed: 'Compaction',
152
+ usingChatModel: 'Chat model',
129
153
  colIndex: '#',
130
154
  colTime: 'At',
131
155
  /*
@@ -148,6 +172,14 @@ window.__ModuleLoader__.load({
148
172
  secondsAgo: '{count}s ago',
149
173
  minutesAgo: '{count}m ago',
150
174
  hoursAgo: '{count}h ago',
175
+ hintIndex: 'Row number: 1–10 are the most recent finished records; {bolt} is a model reply, {tools} is a tool call, {compact} is a context compaction',
176
+ hintTime: 'When the request was issued (local time)',
177
+ hintTtft: 'Time from issuing the request to receiving its first token',
178
+ hintSpeed: 'Generation speed = output tokens ÷ decode time',
179
+ hintTokens: 'Tokens this reply generated',
180
+ hintTotal: 'Request time: from issuing the request until the model finished replying',
181
+ hintAmortized: 'Output tokens ÷ total time, including both queueing and response — the throughput of the whole local-to-model path',
182
+ tokensHint: 'Input {input} · cache hit {hit}',
151
183
  }
152
184
 
153
185
  const STYLE_TEXT = `
@@ -472,6 +504,89 @@ window.__ModuleLoader__.load({
472
504
  .dsh-rum-tool-icon {
473
505
  color: var(--dsw-alias-state-business-primary, var(--dsw-alias-brand-primary));
474
506
  }
507
+ /*
508
+ * The compaction marker.
509
+ *
510
+ * Shares the bolt's box and pulse so switching phases never moves the pill; only the glyph
511
+ * inside changes. The colour is deliberately its own — the three phases must stay apart for a
512
+ * reader who cannot tell the shapes apart.
513
+ */
514
+ .dsh-rum-compaction-icon {
515
+ color: var(--dsw-alias-state-warning-primary, var(--dsw-alias-brand-primary));
516
+ }
517
+ /* A finished compaction keeps its glyph but stops breathing, so "done" looks settled. */
518
+ .dsh-rum-still {
519
+ animation: none;
520
+ }
521
+ /*
522
+ * The compaction reading replaces the five metric slots with a clock, a model, the wording and
523
+ * a running span.
524
+ *
525
+ * The button reserves the width the idle layout needs, measured once and refreshed on resize.
526
+ * Every segment inside is either fixed-width or clipped, so no value can grow the pill while
527
+ * it is showing — the composer below would shift on each tick otherwise.
528
+ */
529
+ .dsh-rum-compact-anchor {
530
+ min-width: var(--dsh-rum-pill-width, auto);
531
+ }
532
+ .dsh-rum-compact-parts {
533
+ align-items: baseline;
534
+ gap: 8px;
535
+ }
536
+ .dsh-rum-compact-clock {
537
+ flex: none;
538
+ font-variant-numeric: tabular-nums;
539
+ }
540
+ .dsh-rum-compact-model {
541
+ /*
542
+ * The model name is the only segment whose length is unknown, so it absorbs the slack and
543
+ * truncates. Without the cap a long provider/model pair would push the wording out of the
544
+ * pill and the drawer's own edge would no longer line up with it.
545
+ */
546
+ flex: 0 1 auto;
547
+ max-width: 18ch;
548
+ overflow: hidden;
549
+ text-overflow: ellipsis;
550
+ white-space: nowrap;
551
+ }
552
+ .dsh-rum-compact-span {
553
+ /* "12.3" up to "999.9": five characters plus the decimal point, reserved. */
554
+ width: 5.5ch;
555
+ }
556
+ /*
557
+ * The hover hint.
558
+ *
559
+ * Fixed on the body so no scroll container can clip it, above the anchor by default. The
560
+ * surface is the same menu material the drawer uses, so the hint cannot look foreign beside it.
561
+ */
562
+ .dsh-rum-tip {
563
+ position: fixed;
564
+ z-index: 2147483100;
565
+ max-width: 320px;
566
+ padding: 7px 9px;
567
+ border-radius: var(--dsw-radius-sm);
568
+ border: 1px solid var(--dsw-alias-border-l1, transparent);
569
+ background: var(--dsw-specific-menu, var(--dsw-alias-bg-layer-2));
570
+ color: var(--dsw-alias-label-secondary);
571
+ font-size: 11px;
572
+ line-height: 1.5;
573
+ font-variant-numeric: tabular-nums;
574
+ box-shadow: var(--dsw-elevation-prominent, 0 6px 20px rgba(0, 0, 0, .28));
575
+ transform: translateY(-100%);
576
+ margin-top: -8px;
577
+ pointer-events: none;
578
+ white-space: normal;
579
+ }
580
+ /* The glyphs the index hint names, drawn inline so the hint can show them rather than spell them. */
581
+ .dsh-rum-tip svg {
582
+ width: 10px;
583
+ height: 10px;
584
+ vertical-align: -1px;
585
+ margin: 0 1px;
586
+ }
587
+ .dsh-rum-tip .dsh-rum-tip-icon {
588
+ color: var(--dsw-alias-brand-primary);
589
+ }
475
590
  .dsh-rum-empty {
476
591
  flex: 1 1 auto;
477
592
  padding: 14px 6px 16px;
@@ -879,13 +994,27 @@ window.__ModuleLoader__.load({
879
994
  */
880
995
  function readingOfStatsStep(entry) {
881
996
  const stats = entry.metrics
882
- const ttftMs = numberOrNull(stats.ttft)
883
997
  /*
884
998
  * A step the fold marks aborted ended without a settled reply: the user stopped it, or the
885
999
  * upstream failed mid-request. Either way there is no `messageTime`, so `model`, `decode`
886
1000
  * and `tps` are all null and the row would be entirely blank.
887
1001
  */
888
1002
  const interrupted = stats.aborted === true || stats.interrupted === true
1003
+ const wallMs = numberOrNull(stats.wall)
1004
+ /*
1005
+ * The first-token column of an interrupted request.
1006
+ *
1007
+ * The live reading counts up from the moment the request was issued, so a stopped request
1008
+ * did have a first-token figure on screen — it simply never landed in the log as `ttft`,
1009
+ * because the fold only writes that once a first token actually arrived. Two cases:
1010
+ *
1011
+ * - No first token ever came: the counter was still running when the request stopped, so
1012
+ * the figure it showed was the elapsed span. `wall` is that span, and reporting it keeps
1013
+ * the column honest instead of printing a dash for a request that demonstrably waited.
1014
+ * - A first token did arrive: `ttft` is set and frozen, so the row keeps the real value,
1015
+ * which is smaller than the total — exactly the ordering the user expects to see.
1016
+ */
1017
+ const ttftMs = numberOrNull(stats.ttft) ?? (interrupted ? wallMs : null)
889
1018
  /*
890
1019
  * The drawer's "total" is the Statistics view's MODEL time, not its wall time.
891
1020
  *
@@ -900,7 +1029,7 @@ window.__ModuleLoader__.load({
900
1029
  * It is a log fact — `endTime - startTime` — so it survives a reload unchanged, unlike
901
1030
  * the live reading, which is recomputed and lost.
902
1031
  */
903
- const totalMs = numberOrNull(stats.model) ?? (interrupted ? numberOrNull(stats.wall) : null)
1032
+ const totalMs = numberOrNull(stats.model) ?? (interrupted ? wallMs : null)
904
1033
  const tokens = numberOrNull(stats.output)
905
1034
  const speed = numberOrNull(stats.tps)
906
1035
  return {
@@ -922,6 +1051,16 @@ window.__ModuleLoader__.load({
922
1051
  tokens !== null && tokens > 0 && totalMs !== null && totalMs > 0
923
1052
  ? tokens / (totalMs / 1000)
924
1053
  : null,
1054
+ /*
1055
+ * The model that answered, and the input-side accounting, all for tooltips. The fold
1056
+ * does not put a provider/model on a step — it only carries them for a compaction — so
1057
+ * the caller fills these from the chat snapshot's own assistant nodes.
1058
+ */
1059
+ model: null,
1060
+ provider: null,
1061
+ context: numberOrNull(stats.context),
1062
+ cacheRead: numberOrNull(stats.cacheRead),
1063
+ cacheHit: numberOrNull(stats.cacheHit),
925
1064
  }
926
1065
  }
927
1066
 
@@ -955,6 +1094,160 @@ window.__ModuleLoader__.load({
955
1094
  )
956
1095
  }
957
1096
 
1097
+ /**
1098
+ * A compaction transaction as a drawer row.
1099
+ *
1100
+ * Compaction is not a step: it lives on `turn.compactions[]`, opened by `compaction/start`
1101
+ * and closed by `compaction/end`, and it never produces an `assistant/message`. So it has
1102
+ * no first token, no decode span and no generation rate — the three columns that depend on
1103
+ * a settled reply stay empty, and the speed column says what is happening instead.
1104
+ *
1105
+ * What it does have is a wall-clock span, which is the figure the user wants: how long the
1106
+ * summarization ran. While it runs, `endTime` is null and the drawer counts up from
1107
+ * `startTime`; once it lands, `wall` freezes the same span.
1108
+ */
1109
+ function readingOfCompaction(compaction) {
1110
+ const startMs = numberOrNull(compaction.startTime)
1111
+ const wallMs = numberOrNull(compaction.wall)
1112
+ const running = compaction.running === true
1113
+ const tokens = numberOrNull(compaction.output)
1114
+ return {
1115
+ key: `compaction:${compaction.compactionId}`,
1116
+ compaction: true,
1117
+ compactionId: compaction.compactionId,
1118
+ running,
1119
+ at: startMs,
1120
+ startMs,
1121
+ // A compaction has no first token, so the column is always the dash.
1122
+ ttftMs: null,
1123
+ interrupted: false,
1124
+ totalMs: running ? null : wallMs,
1125
+ tokens,
1126
+ estimated: false,
1127
+ speed: null,
1128
+ /*
1129
+ * The amortised figure a compaction can report is `output ÷ wall` — the throughput of
1130
+ * the whole summarization call, which includes replaying the conversation prefix. It
1131
+ * is not the decode rate an ordinary row reports, but it is a real measurement of this
1132
+ * transaction, so it is shown as-is rather than hidden behind the estimate marker.
1133
+ */
1134
+ amortized:
1135
+ !running && tokens !== null && tokens > 0 && wallMs !== null && wallMs > 0
1136
+ ? tokens / (wallMs / 1000)
1137
+ : null,
1138
+ /** Which model summarised. Only `compaction/summary` reports it, so it lands at the end. */
1139
+ model: typeof compaction.model === 'string' && compaction.model !== '' ? compaction.model : null,
1140
+ provider:
1141
+ typeof compaction.provider === 'string' && compaction.provider !== '' ? compaction.provider : null,
1142
+ /** Input-side accounting, for the tokens column's tooltip. */
1143
+ context: numberOrNull(compaction.context),
1144
+ cacheRead: numberOrNull(compaction.cacheRead),
1145
+ cacheHit: numberOrNull(compaction.cacheHit),
1146
+ shadowedTokens: numberOrNull(compaction.shadowedTokens),
1147
+ }
1148
+ }
1149
+
1150
+ /**
1151
+ * Every compaction the session fold knows about, oldest first.
1152
+ *
1153
+ * They are read separately from the steps because they are not steps: `historyFromStats`
1154
+ * merges the two streams and orders them by start time, so a compaction lands in the
1155
+ * drawer exactly where it happened in the transcript.
1156
+ */
1157
+ function compactionsFromStats(statsSnapshot) {
1158
+ const turns = statsSnapshot?.turns
1159
+ if (!Array.isArray(turns)) return []
1160
+ const rows = []
1161
+ for (const turn of turns) {
1162
+ if (!Array.isArray(turn.compactions)) continue
1163
+ for (const compaction of turn.compactions) {
1164
+ if (typeof compaction?.compactionId !== 'string') continue
1165
+ if (numberOrNull(compaction.startTime) === null) continue
1166
+ rows.push(readingOfCompaction(compaction))
1167
+ }
1168
+ }
1169
+ return rows
1170
+ }
1171
+
1172
+ /**
1173
+ * Which model answered each step, keyed `turn:step`.
1174
+ *
1175
+ * The fold does not put a provider/model on a step — `stepMetrics` carries only derived
1176
+ * figures, and an assistant chat node carries only its usage and timings. The model is
1177
+ * recorded once per routed request as a `request/header` event row on the turn, so a step
1178
+ * is attributed to the newest header that precedes it.
1179
+ *
1180
+ * Verified against the log: on a real session the newest preceding header matched the
1181
+ * `assistant/message.source` of every one of 40 sampled steps. Headers are per-routed-
1182
+ * request, so several consecutive steps share one, and a model switch starts a new one.
1183
+ */
1184
+ function modelIndexFromStats(statsSnapshot) {
1185
+ const turns = statsSnapshot?.turns
1186
+ const index = new Map()
1187
+ if (!Array.isArray(turns)) return index
1188
+ for (const turn of turns) {
1189
+ if (!Array.isArray(turn.steps)) continue
1190
+ const headers = []
1191
+ if (Array.isArray(turn.events)) {
1192
+ for (const event of turn.events) {
1193
+ if (event?.kind !== 'request-header') continue
1194
+ if (typeof event.model !== 'string' && typeof event.provider !== 'string') continue
1195
+ headers.push({ time: numberOrNull(event.time) ?? 0, provider: event.provider ?? null, model: event.model ?? null })
1196
+ }
1197
+ headers.sort((left, right) => left.time - right.time)
1198
+ }
1199
+ if (headers.length === 0) continue
1200
+ for (const step of turn.steps) {
1201
+ const at = numberOrNull(step.startTime)
1202
+ if (at === null || typeof step.step !== 'number') continue
1203
+ let chosen = null
1204
+ for (const header of headers) {
1205
+ if (header.time <= at) chosen = header
1206
+ else break
1207
+ }
1208
+ if (chosen === null) continue
1209
+ index.set(`${turn.turn}:${step.step}`, chosen)
1210
+ }
1211
+ }
1212
+ return index
1213
+ }
1214
+
1215
+ /**
1216
+ * Whether any step started after this compaction finished.
1217
+ *
1218
+ * That is what ends the "just compacted" wording: the fold keeps a compaction record for
1219
+ * the life of the session, so its presence alone can never mean "this just happened".
1220
+ * A step whose `startTime` is later than the compaction's end is the next request.
1221
+ */
1222
+ function compactionHadSuccessor(compaction, statsSnapshot) {
1223
+ const turns = statsSnapshot?.turns
1224
+ if (!Array.isArray(turns)) return false
1225
+ const endedAt = numberOrNull(compaction.totalMs) === null ? null : compaction.at + compaction.totalMs
1226
+ if (endedAt === null) return false
1227
+ for (const turn of turns) {
1228
+ if (!Array.isArray(turn.steps)) continue
1229
+ for (const step of turn.steps) {
1230
+ const start = numberOrNull(step.startTime)
1231
+ if (start !== null && start > endedAt) return true
1232
+ }
1233
+ }
1234
+ return false
1235
+ }
1236
+
1237
+ /**
1238
+ * The newest compaction in a snapshot, or null.
1239
+ *
1240
+ * The pill and the live row both need one record, not the list, so this picks by start
1241
+ * time: a session can compact several times, and only the latest is "what is happening".
1242
+ */
1243
+ function compactionsOf(statsSnapshot) {
1244
+ const all = compactionsFromStats(statsSnapshot)
1245
+ if (all.length === 0) return null
1246
+ let newest = all[0]
1247
+ for (const row of all) if ((row.at ?? 0) > (newest.at ?? 0)) newest = row
1248
+ return newest
1249
+ }
1250
+
958
1251
  /**
959
1252
  * The newest readings for a session, newest first.
960
1253
  *
@@ -974,14 +1267,30 @@ window.__ModuleLoader__.load({
974
1267
  */
975
1268
  function historyFromStats(statsSnapshot) {
976
1269
  const steps = statsSteps(statsSnapshot)
1270
+ const models = modelIndexFromStats(statsSnapshot)
977
1271
  const rows = []
978
1272
  for (const entry of steps) {
979
1273
  // A step only has a row once it has started; `step/start` is what supplies this.
980
1274
  if (numberOrNull(entry.metrics.startTime) === null) continue
981
1275
  if (!statsStepHasFigures(entry.metrics)) continue
982
- rows.push(readingOfStatsStep(entry))
1276
+ const row = readingOfStatsStep(entry)
1277
+ // Attribute the request to the model that served it, for the speed column's tooltip.
1278
+ const owner = models.get(row.key)
1279
+ if (owner !== undefined) {
1280
+ row.model = owner.model
1281
+ row.provider = owner.provider
1282
+ }
1283
+ rows.push(row)
983
1284
  }
984
- return rows.reverse()
1285
+ // Compactions are not steps, so they are collected separately and then ordered together.
1286
+ for (const row of compactionsFromStats(statsSnapshot)) rows.push(row)
1287
+ /*
1288
+ * Newest first, by start time. The two streams interleave in real time — a turn can run
1289
+ * several steps, compact, then run more — so ordering them by the moment each began is
1290
+ * what puts the compaction where it actually happened rather than at either end.
1291
+ */
1292
+ rows.sort((left, right) => (right.at ?? 0) - (left.at ?? 0))
1293
+ return rows
985
1294
  }
986
1295
 
987
1296
  function readJson(key) {
@@ -1303,6 +1612,230 @@ window.__ModuleLoader__.load({
1303
1612
  )
1304
1613
  }
1305
1614
 
1615
+ /**
1616
+ * The compaction marker: three stacked bars, each shorter than the one above.
1617
+ *
1618
+ * Chosen over the converging-chevron and arrow-pair candidates because at 14px the three
1619
+ * bars keep visible gaps between them, while the pointed shapes blurred into a single
1620
+ * blob. It also carries the meaning directly — a long history reduced to a short one.
1621
+ *
1622
+ * Bar widths and gaps mirror the bolt's vertical extent so the three glyphs (bolt, T,
1623
+ * compactor) share one optical size inside the same 14x14 box.
1624
+ */
1625
+ function CompactionIcon(props) {
1626
+ return h(
1627
+ 'svg',
1628
+ { viewBox: '0 0 16 16', className: props.className, 'aria-hidden': true, fill: 'currentColor' },
1629
+ h('rect', { x: 2.8, y: 3.1, width: 10.4, height: 2, rx: 1 }),
1630
+ h('rect', { x: 4.6, y: 7, width: 6.8, height: 2, rx: 1 }),
1631
+ h('rect', { x: 6.5, y: 10.9, width: 3, height: 2, rx: 1 }),
1632
+ )
1633
+ }
1634
+
1635
+ /**
1636
+ * The full timestamp, for the clock column's hint.
1637
+ *
1638
+ * `MM-DD HH:mm:ss.SSS` — the clock cell itself only has room for the time of day, and the
1639
+ * relative wording it replaced ("3 minutes ago") cannot answer which request a row is.
1640
+ */
1641
+ function absoluteStamp(at) {
1642
+ const ms = numberOrNull(at)
1643
+ if (ms === null) return ''
1644
+ const date = new Date(ms)
1645
+ const pad = (value, width) => String(value).padStart(width, '0')
1646
+ return (
1647
+ `${pad(date.getMonth() + 1, 2)}-${pad(date.getDate(), 2)} ` +
1648
+ `${pad(date.getHours(), 2)}:${pad(date.getMinutes(), 2)}:${pad(date.getSeconds(), 2)}.` +
1649
+ `${pad(date.getMilliseconds(), 3)}`
1650
+ )
1651
+ }
1652
+
1653
+ /** The speed column's hint: which model served this row. */
1654
+ function modelHintText(row, t) {
1655
+ if (row.compaction === true) return compactionModelName(row, t)
1656
+ const model = typeof row.model === 'string' && row.model !== '' ? row.model : null
1657
+ const provider = typeof row.provider === 'string' && row.provider !== '' ? row.provider : null
1658
+ if (model === null) return t('usingChatModel')
1659
+ return provider === null ? model : `${provider} / ${model}`
1660
+ }
1661
+
1662
+ /** The tokens column's hint: the input side, which the cell itself does not show. */
1663
+ function tokensHintText(row, t) {
1664
+ const none = t('none')
1665
+ const input = row.context === null || row.context === undefined ? none : tokensText(row.context, false, t)
1666
+ const hit =
1667
+ row.cacheHit === null || row.cacheHit === undefined
1668
+ ? none
1669
+ : `${(row.cacheHit * 100).toFixed(1)}%`
1670
+ return t('tokensHint', { input, hit })
1671
+ }
1672
+
1673
+ /**
1674
+ * The index header's hint, with the three phase glyphs drawn in place.
1675
+ *
1676
+ * This is the reason the drawer owns a tooltip component at all: `title` can only carry
1677
+ * plain text, and the hint has to name the bolt, the T and the compaction bars. The glyphs
1678
+ * are rendered as elements and substituted into the sentence, so the wording and the
1679
+ * drawer's own markers can never drift apart.
1680
+ */
1681
+ function indexHint(t) {
1682
+ const glyph = (Icon) => h(Icon, { className: 'dsh-rum-tip-icon' })
1683
+ /*
1684
+ * Split on every placeholder first, then walk the pieces: a string piece is literal text,
1685
+ * a placeholder becomes its glyph. Walking once over a token list is simpler to follow
1686
+ * than nesting one split per placeholder.
1687
+ */
1688
+ const tokens = t('hintIndex').split(/(\{bolt\}|\{tools\}|\{compact\})/)
1689
+ const nodes = []
1690
+ for (let i = 0; i < tokens.length; i += 1) {
1691
+ const token = tokens[i]
1692
+ if (token === '') continue
1693
+ if (token === '{bolt}') nodes.push(glyph(BoltIcon))
1694
+ else if (token === '{tools}') nodes.push(glyph(ToolIcon))
1695
+ else if (token === '{compact}') nodes.push(glyph(CompactionIcon))
1696
+ else nodes.push(token)
1697
+ }
1698
+ return h('span', null, ...nodes)
1699
+ }
1700
+
1701
+ /**
1702
+ * A hover hint, rendered as real DOM rather than through `title`.
1703
+ *
1704
+ * `title` can only show plain text, and the `#` header's hint names the three state glyphs
1705
+ * — it has to draw them. Owning the tooltip also keeps one visual language across the
1706
+ * drawer, lets it follow the theme's own surfaces, and avoids the browser's one-second
1707
+ * delay.
1708
+ *
1709
+ * It is positioned `fixed` on the body so no scroll container can clip it, and flipped
1710
+ * below the anchor when there is no room above.
1711
+ */
1712
+ function Tooltip(props) {
1713
+ const { open, x, y, children } = props
1714
+ if (!open) return null
1715
+ return portal(
1716
+ h(
1717
+ 'div',
1718
+ {
1719
+ className: 'dsh-rum-tip',
1720
+ role: 'tooltip',
1721
+ style: { left: `${x}px`, top: `${y}px` },
1722
+ },
1723
+ children,
1724
+ ),
1725
+ )
1726
+ }
1727
+
1728
+ /**
1729
+ * Hover state for one row or one header.
1730
+ *
1731
+ * A short delay keeps a hint from flashing while the pointer sweeps across the drawer,
1732
+ * and a single shared timer is enough because only one hint can be open at a time.
1733
+ */
1734
+ function useHint(delay) {
1735
+ const [hint, setHint] = useState(null)
1736
+ const timer = useRef(null)
1737
+ const cancel = useCallback(() => {
1738
+ if (timer.current !== null) {
1739
+ clearTimeout(timer.current)
1740
+ timer.current = null
1741
+ }
1742
+ }, [])
1743
+ const show = useCallback(
1744
+ (content, event) => {
1745
+ cancel()
1746
+ const rect = event?.currentTarget?.getBoundingClientRect?.()
1747
+ if (rect === undefined) return
1748
+ timer.current = setTimeout(() => {
1749
+ timer.current = null
1750
+ setHint({ content, x: rect.left, y: rect.top })
1751
+ }, delay)
1752
+ },
1753
+ [cancel, delay],
1754
+ )
1755
+ const hide = useCallback(() => {
1756
+ cancel()
1757
+ setHint(null)
1758
+ }, [cancel])
1759
+ useEffect(() => cancel, [cancel])
1760
+ return { hint, show, hide }
1761
+ }
1762
+
1763
+ /**
1764
+ * The compaction wording as one sentence, for the button's accessible name.
1765
+ */
1766
+ function compactionSentence(compaction, phase, now, t) {
1767
+ const elapsed = compactionSpan(compaction, now)
1768
+ const parts = [
1769
+ clockText(compaction.at),
1770
+ compactionModelName(compaction, t),
1771
+ phase === 'compacting' ? t('drawerCompacting') : t('drawerCompacted'),
1772
+ secondsText(elapsed, t),
1773
+ ]
1774
+ return parts.join(' · ')
1775
+ }
1776
+
1777
+ /**
1778
+ * How long a compaction has run: live while it runs, frozen once it lands.
1779
+ *
1780
+ * The live figure counts from `startTime`, which is the same origin the drawer row uses,
1781
+ * so the pill and the row can never disagree. Once the fold reports `wall`, that log value
1782
+ * takes over so a reload shows the same span it showed live.
1783
+ */
1784
+ function compactionSpan(compaction, now) {
1785
+ if (compaction.running === true) {
1786
+ if (compaction.startMs === null) return null
1787
+ return Math.max(0, now - compaction.startMs)
1788
+ }
1789
+ return compaction.totalMs
1790
+ }
1791
+
1792
+ /**
1793
+ * The model a compaction used, or the wording that stands in for it.
1794
+ *
1795
+ * `compaction/summary` reports the real model, so a finished compaction always knows it.
1796
+ * While one runs the fold has only an id and a turn — the summarizer's own request is not
1797
+ * logged as a header — so the routed model of the last request is the honest reading, and
1798
+ * the general wording is the last resort.
1799
+ */
1800
+ function compactionModelName(compaction, t) {
1801
+ if (typeof compaction.model === 'string' && compaction.model !== '') return compaction.model
1802
+ return t('usingChatModel')
1803
+ }
1804
+
1805
+ /**
1806
+ * The compaction variant of the status reading.
1807
+ *
1808
+ * Three segments replace the five metric slots: the clock the compaction began at, the
1809
+ * model doing it, and how long it has been running. The pill's own width is left to
1810
+ * `--dsh-rum-pill-width`, measured from the idle layout, so switching into this phase
1811
+ * cannot move anything beside it.
1812
+ */
1813
+ function CompactionReading(props) {
1814
+ const { compaction, phase, now, t } = props
1815
+ const span = compactionSpan(compaction, now)
1816
+ return h(
1817
+ 'span',
1818
+ { className: 'dsh-rum-parts dsh-rum-compact-parts' },
1819
+ h('span', { className: 'dsh-rum-part dsh-rum-compact-clock' }, clockText(compaction.at)),
1820
+ h(
1821
+ 'span',
1822
+ { className: 'dsh-rum-part dsh-rum-compact-model', title: compactionModelName(compaction, t) },
1823
+ compactionModelName(compaction, t),
1824
+ ),
1825
+ h(
1826
+ 'span',
1827
+ { className: 'dsh-rum-part' },
1828
+ phase === 'compacting' ? t('drawerCompacting') : t('drawerCompacted'),
1829
+ ),
1830
+ h(
1831
+ 'span',
1832
+ { className: 'dsh-rum-part' },
1833
+ h('span', { className: 'dsh-rum-num dsh-rum-compact-span' }, durationSlot(span)),
1834
+ h('span', { className: 'dsh-rum-unit' }, DURATION_UNIT),
1835
+ ),
1836
+ )
1837
+ }
1838
+
1306
1839
  function ChevronIcon(props) {
1307
1840
  return h(
1308
1841
  'svg',
@@ -1602,7 +2135,15 @@ window.__ModuleLoader__.load({
1602
2135
  return null
1603
2136
  }
1604
2137
 
1605
- function useLiveReading(useChat, enabled, trajectory, runningStatsStep, sessionTurnOpen, sessionRunning) {
2138
+ function useLiveReading(
2139
+ useChat,
2140
+ enabled,
2141
+ trajectory,
2142
+ runningStatsStep,
2143
+ sessionTurnOpen,
2144
+ sessionRunning,
2145
+ sessionStats,
2146
+ ) {
1606
2147
  const partial = useChat((snapshot) => snapshot.legacy.partial)
1607
2148
  const nodes = useChat((snapshot) => snapshot.legacy.nodes)
1608
2149
  const turnTimings = useChat((snapshot) => snapshot.legacy.turnTimings)
@@ -1668,7 +2209,38 @@ window.__ModuleLoader__.load({
1668
2209
  * A closed turn admits no live step at all, so a step still flagged running in a stale
1669
2210
  * snapshot cannot revive either marker.
1670
2211
  */
2212
+ /*
2213
+ * The newest compaction in the session, running or just finished.
2214
+ *
2215
+ * Compaction is a fourth kind of activity that overlaps the others: it runs between
2216
+ * steps, belongs to no step, and can take tens of seconds. Without it the pill simply
2217
+ * froze on the previous figures for the whole summarization, which is exactly the
2218
+ * "I cannot tell what it is doing" complaint.
2219
+ */
2220
+ const compactionNow = compactionsOf(sessionStats)
2221
+ const liveCompaction = compactionNow?.running === true ? compactionNow : null
2222
+ /*
2223
+ * A compaction that finished and has not yet been followed by a new request.
2224
+ *
2225
+ * The pill keeps saying "compacted" until the next request starts, so the user can see
2226
+ * that the long pause was the summarization finishing rather than the app stalling. A
2227
+ * step that began after the compaction ended is what ends it — the fold keeps the
2228
+ * compaction record forever, so its mere presence cannot mean "just happened".
2229
+ */
2230
+ const recentCompaction =
2231
+ liveCompaction !== null
2232
+ ? null
2233
+ : compactionNow !== null && !compactionHadSuccessor(compactionNow, sessionStats)
2234
+ ? compactionNow
2235
+ : null
1671
2236
  const livePhase = (() => {
2237
+ /*
2238
+ * Compaction wins over the step phases: it happens between steps, so a running
2239
+ * compaction and a running step cannot both be true, and checking it first keeps the
2240
+ * "compacted, waiting for the next request" state from being mistaken for idle.
2241
+ */
2242
+ if (liveCompaction !== null) return 'compacting'
2243
+ if (recentCompaction !== null) return 'compacted'
1672
2244
  if (!turnIsOpen) return null
1673
2245
  if (runningStatsStep !== null && runningStatsStep !== undefined) {
1674
2246
  const metrics = runningStatsStep.metrics
@@ -1681,7 +2253,9 @@ window.__ModuleLoader__.load({
1681
2253
  if (partial !== null && partial !== undefined) return 'writing'
1682
2254
  return null
1683
2255
  })()
1684
- const liveStep = livePhase === null
2256
+ /** The compaction a render should show, whichever of the two phases is active. */
2257
+ const activeCompaction = liveCompaction ?? recentCompaction
2258
+ const liveStep = livePhase === null || activeCompaction !== null
1685
2259
  ? null
1686
2260
  : runningStatsStep !== null && runningStatsStep !== undefined
1687
2261
  ? { turn: runningStatsStep.turn, step: runningStatsStep.step }
@@ -1690,7 +2264,11 @@ window.__ModuleLoader__.load({
1690
2264
  ? null
1691
2265
  : { turn: partial.turn, step: partial.step }
1692
2266
  : { turn: request.turn, step: request.step }
1693
- const running = enabled && liveStep !== null
2267
+ /*
2268
+ * A compaction is live too, even though it has no step: the clock has to tick for its
2269
+ * running span, and the early returns below gate on this flag.
2270
+ */
2271
+ const running = enabled && (liveStep !== null || activeCompaction !== null)
1694
2272
  const [now, setNow] = useState(() => Date.now())
1695
2273
  const observation = useRef({ key: null, firstTokenAt: null })
1696
2274
 
@@ -1707,7 +2285,11 @@ window.__ModuleLoader__.load({
1707
2285
  * content, so that appearance IS the first delta.
1708
2286
  */
1709
2287
  useEffect(() => {
1710
- if (!running) {
2288
+ /*
2289
+ * A compaction has no step, so there is no first-token mark to find: the guard covers
2290
+ * the compacting phase, where `running` is true but `liveStep` is null by design.
2291
+ */
2292
+ if (!running || liveStep === null) {
1711
2293
  observation.current = { key: null, firstTokenAt: null }
1712
2294
  return
1713
2295
  }
@@ -1744,6 +2326,27 @@ window.__ModuleLoader__.load({
1744
2326
  * lag the fold.
1745
2327
  * 3. Reconstruction from the previous step's last tool result, then the turn's start.
1746
2328
  */
2329
+ /*
2330
+ * A compaction has no step to measure, so the reading is built from the compaction alone:
2331
+ * its own clock, its own span and its own model. Returning here keeps every step-shaped
2332
+ * figure below out of the picture — there is no step to attribute them to.
2333
+ */
2334
+ if (activeCompaction !== null) {
2335
+ return {
2336
+ key: null,
2337
+ at: activeCompaction.at,
2338
+ startMs: activeCompaction.startMs,
2339
+ ttftMs: null,
2340
+ totalMs: compactionSpan(activeCompaction, now),
2341
+ tokens: activeCompaction.tokens,
2342
+ estimated: false,
2343
+ speed: null,
2344
+ amortized: activeCompaction.amortized,
2345
+ replyLanded: false,
2346
+ phase: livePhase,
2347
+ compaction: activeCompaction,
2348
+ }
2349
+ }
1747
2350
  const statsStart =
1748
2351
  runningStatsStep !== null &&
1749
2352
  runningStatsStep !== undefined &&
@@ -1828,6 +2431,7 @@ window.__ModuleLoader__.load({
1828
2431
  : null,
1829
2432
  replyLanded: true,
1830
2433
  phase: livePhase,
2434
+ compaction: activeCompaction,
1831
2435
  }
1832
2436
  }
1833
2437
 
@@ -1853,6 +2457,7 @@ window.__ModuleLoader__.load({
1853
2457
  amortized: tokens > 0 && elapsedMs !== null && elapsedMs > 0 ? tokens / (elapsedMs / 1000) : null,
1854
2458
  replyLanded: false,
1855
2459
  phase: livePhase,
2460
+ compaction: activeCompaction,
1856
2461
  }
1857
2462
  }
1858
2463
 
@@ -2032,7 +2637,7 @@ window.__ModuleLoader__.load({
2032
2637
  */
2033
2638
  function averageOf(rows) {
2034
2639
  if (rows.length === 0) return null
2035
- const measurable = rows.filter((row) => row.interrupted !== true)
2640
+ const measurable = rows.filter((row) => row.interrupted !== true && row.compaction !== true)
2036
2641
  const mean = (pick) => {
2037
2642
  let sum = 0
2038
2643
  let count = 0
@@ -2316,7 +2921,15 @@ window.__ModuleLoader__.load({
2316
2921
  return last.running !== false
2317
2922
  }, [sessionStats])
2318
2923
  const chatNodes = useChat((snapshot) => snapshot.legacy.nodes)
2319
- const live = useLiveReading(useChat, geek, trajectory, runningStatsStep, sessionTurnOpen, sessionRunning)
2924
+ const live = useLiveReading(
2925
+ useChat,
2926
+ geek,
2927
+ trajectory,
2928
+ runningStatsStep,
2929
+ sessionTurnOpen,
2930
+ sessionRunning,
2931
+ sessionStats,
2932
+ )
2320
2933
 
2321
2934
  const triggerRef = useRef(null)
2322
2935
  const drawerRef = useRef(null)
@@ -2414,7 +3027,18 @@ window.__ModuleLoader__.load({
2414
3027
  */
2415
3028
  const listedRows = useMemo(() => {
2416
3029
  const base = statsRows ?? fallbackRows ?? []
2417
- const visible = live === null ? base : base.filter((row) => row.key !== live.key)
3030
+ /*
3031
+ * The running compaction is rendered as its own row above the list, so the numbered
3032
+ * list must not repeat it. A finished compaction stays in the list — it is history
3033
+ * then, and it is what the drawer is for.
3034
+ */
3035
+ const runningCompactionKey =
3036
+ live !== null && live.compaction !== null && live.compaction.running === true
3037
+ ? live.compaction.key
3038
+ : null
3039
+ let visible = base
3040
+ if (live !== null && live.key !== null) visible = visible.filter((row) => row.key !== live.key)
3041
+ if (runningCompactionKey !== null) visible = visible.filter((row) => row.key !== runningCompactionKey)
2418
3042
  return visible.slice(0, MAX_ROWS)
2419
3043
  }, [statsRows, fallbackRows, live])
2420
3044
 
@@ -2472,8 +3096,30 @@ window.__ModuleLoader__.load({
2472
3096
  return widths
2473
3097
  })
2474
3098
  }
3099
+ /*
3100
+ * Publish the idle layout's width so the compaction phase can reserve it.
3101
+ *
3102
+ * The compaction reading is much shorter than five metric slots, and without a floor
3103
+ * the pill would shrink while it runs — moving the composer's neighbours and then
3104
+ * moving them back when the phase ends. Measuring the settled layout once and pinning
3105
+ * it as a CSS custom property keeps the pill the same size through every phase.
3106
+ *
3107
+ * The measurement is skipped in the compaction phases themselves: that layout is the
3108
+ * one being constrained, so measuring it would ratchet the width down to itself.
3109
+ */
3110
+ const measurePillWidth = () => {
3111
+ const anchor = triggerRef.current
3112
+ if (anchor === null) return
3113
+ const phase = anchor.getAttribute('data-live-phase')
3114
+ if (phase === 'compacting' || phase === 'compacted') return
3115
+ const width = anchor.getBoundingClientRect().width
3116
+ if (!Number.isFinite(width) || width <= 0) return
3117
+ anchor.style.setProperty('--dsh-rum-pill-width', `${Math.round(width)}px`)
3118
+ }
2475
3119
  measure()
3120
+ measurePillWidth()
2476
3121
  window.addEventListener('resize', measure)
3122
+ window.addEventListener('resize', measurePillWidth)
2477
3123
  /*
2478
3124
  * A font-size change (the Settings font scale) or a metric swap moves the pill's
2479
3125
  * cells without a window resize; observe the pill itself so the drawer columns
@@ -2487,6 +3133,7 @@ window.__ModuleLoader__.load({
2487
3133
  }
2488
3134
  return () => {
2489
3135
  window.removeEventListener('resize', measure)
3136
+ window.removeEventListener('resize', measurePillWidth)
2490
3137
  observer?.disconnect()
2491
3138
  }
2492
3139
  }, [mounted])
@@ -2600,6 +3247,22 @@ window.__ModuleLoader__.load({
2600
3247
  total: secondsText(current.totalMs, t),
2601
3248
  amortized: speedText(current.amortized, approximate, t),
2602
3249
  })}`
3250
+ /*
3251
+ * The compaction phases replace the whole set of figures with one sentence: a clock, the
3252
+ * model, the wording and a running span. That layout is built as its own branch because
3253
+ * none of the five metric slots apply — a compaction has no first token and no rate.
3254
+ */
3255
+ const compaction = live?.compaction ?? null
3256
+ const compactingPhase = live?.phase === 'compacting' || live?.phase === 'compacted'
3257
+ /*
3258
+ * One hover hint serves the whole drawer: only one can be open at a time, and sharing the
3259
+ * timer is what stops a hint from a previous row lingering while the pointer moves on.
3260
+ */
3261
+ const hint = useHint(300)
3262
+ const compactionLabel =
3263
+ compaction === null
3264
+ ? statusLabel
3265
+ : `${t('statusAria')} · ${compactionSentence(compaction, live.phase, now, t)}`
2603
3266
 
2604
3267
  return h(
2605
3268
  'div',
@@ -2609,18 +3272,52 @@ window.__ModuleLoader__.load({
2609
3272
  {
2610
3273
  ref: triggerRef,
2611
3274
  type: 'button',
2612
- className: 'dsh-rum-trigger' + (live !== null ? ' dsh-rum-live' : ''),
3275
+ className:
3276
+ 'dsh-rum-trigger' +
3277
+ (live !== null ? ' dsh-rum-live' : '') +
3278
+ (compactingPhase ? ' dsh-rum-compact-anchor' : ''),
2613
3279
  'aria-haspopup': 'dialog',
2614
3280
  'aria-expanded': open,
2615
- 'aria-label': statusLabel,
3281
+ 'aria-label': compactionLabel,
3282
+ /* The active phase, so a test can observe it without reaching into the hooks. */
3283
+ 'data-live-phase': live === null ? undefined : live.phase,
3284
+ /*
3285
+ * The compaction reading, serialised for tests. The phase attribute says which of
3286
+ * the four states is active; this says what the row actually carries — no first
3287
+ * token, no rate, a span that freezes once the fold reports `wall`.
3288
+ */
3289
+ 'data-compaction-reading':
3290
+ compaction === null || live === null
3291
+ ? undefined
3292
+ : JSON.stringify({
3293
+ compactionId: compaction.compactionId,
3294
+ running: compaction.running,
3295
+ ttftMs: live.ttftMs,
3296
+ speed: live.speed,
3297
+ totalMs: compaction.running === true ? live.totalMs : compaction.totalMs,
3298
+ startMs: compaction.startMs,
3299
+ tokens: compaction.running === true ? null : compaction.tokens,
3300
+ model: compaction.model,
3301
+ }),
3302
+ /* The four phases above are all a reader needs, but a spec also asserts the shape
3303
+ * of the compaction reading, so its identity is published too. */
3304
+ 'data-compaction': compaction === null ? undefined : compaction.compactionId,
2616
3305
  onClick: () => {
2617
3306
  setPinned((current) => !current)
2618
3307
  },
2619
3308
  },
2620
3309
  live?.phase === 'tools'
2621
3310
  ? h(ToolIcon, { className: 'dsh-rum-bolt dsh-rum-tool-icon' })
2622
- : h(BoltIcon, { className: 'dsh-rum-bolt' }),
2623
- h(
3311
+ : compactingPhase
3312
+ ? h(CompactionIcon, {
3313
+ className:
3314
+ 'dsh-rum-bolt dsh-rum-compaction-icon' +
3315
+ (live.phase === 'compacting' ? '' : ' dsh-rum-still'),
3316
+ })
3317
+ : h(BoltIcon, { className: 'dsh-rum-bolt' }),
3318
+ compactingPhase && compaction !== null
3319
+ ? h(CompactionReading, { compaction, phase: live.phase, now, t })
3320
+ : h(
2624
3321
  'span',
2625
3322
  { className: 'dsh-rum-parts', ref: partsRef },
2626
3323
  h(
@@ -2658,6 +3355,12 @@ window.__ModuleLoader__.load({
2658
3355
  ),
2659
3356
  ),
2660
3357
  ),
3358
+ h(Tooltip, {
3359
+ open: hint.hint !== null,
3360
+ x: hint.hint?.x ?? 0,
3361
+ y: hint.hint?.y ?? 0,
3362
+ children: hint.hint?.content ?? null,
3363
+ }),
2661
3364
  mounted
2662
3365
  ? portal(
2663
3366
  h(
@@ -2717,19 +3420,76 @@ window.__ModuleLoader__.load({
2717
3420
  { className: 'dsh-rum-row', 'data-head': true, role: 'row' },
2718
3421
  h(
2719
3422
  'span',
2720
- { className: 'dsh-rum-col', role: 'columnheader', 'data-align': 'start' },
3423
+ {
3424
+ className: 'dsh-rum-col',
3425
+ role: 'columnheader',
3426
+ 'data-align': 'start',
3427
+ onMouseEnter: (event) => hint.show(indexHint(t), event),
3428
+ onMouseLeave: hint.hide,
3429
+ },
2721
3430
  t('colIndex'),
2722
3431
  ),
2723
3432
  h(
2724
3433
  'span',
2725
- { className: 'dsh-rum-col', role: 'columnheader', 'data-align': 'start' },
3434
+ {
3435
+ className: 'dsh-rum-col',
3436
+ role: 'columnheader',
3437
+ 'data-align': 'start',
3438
+ onMouseEnter: (event) => hint.show(t('hintTime'), event),
3439
+ onMouseLeave: hint.hide,
3440
+ },
2726
3441
  t('colTime'),
2727
3442
  ),
2728
- h('span', { className: 'dsh-rum-col', role: 'columnheader' }, t('colTtft')),
2729
- h('span', { className: 'dsh-rum-col', role: 'columnheader' }, t('colSpeed')),
2730
- h('span', { className: 'dsh-rum-col', role: 'columnheader' }, t('colTokens')),
2731
- h('span', { className: 'dsh-rum-col', role: 'columnheader' }, t('colTotal')),
2732
- h('span', { className: 'dsh-rum-col', role: 'columnheader' }, t('colAmortized')),
3443
+ h(
3444
+ 'span',
3445
+ {
3446
+ className: 'dsh-rum-col',
3447
+ role: 'columnheader',
3448
+ onMouseEnter: (event) => hint.show(t('hintTtft'), event),
3449
+ onMouseLeave: hint.hide,
3450
+ },
3451
+ t('colTtft'),
3452
+ ),
3453
+ h(
3454
+ 'span',
3455
+ {
3456
+ className: 'dsh-rum-col',
3457
+ role: 'columnheader',
3458
+ onMouseEnter: (event) => hint.show(t('hintSpeed'), event),
3459
+ onMouseLeave: hint.hide,
3460
+ },
3461
+ t('colSpeed'),
3462
+ ),
3463
+ h(
3464
+ 'span',
3465
+ {
3466
+ className: 'dsh-rum-col',
3467
+ role: 'columnheader',
3468
+ onMouseEnter: (event) => hint.show(t('hintTokens'), event),
3469
+ onMouseLeave: hint.hide,
3470
+ },
3471
+ t('colTokens'),
3472
+ ),
3473
+ h(
3474
+ 'span',
3475
+ {
3476
+ className: 'dsh-rum-col',
3477
+ role: 'columnheader',
3478
+ onMouseEnter: (event) => hint.show(t('hintTotal'), event),
3479
+ onMouseLeave: hint.hide,
3480
+ },
3481
+ t('colTotal'),
3482
+ ),
3483
+ h(
3484
+ 'span',
3485
+ {
3486
+ className: 'dsh-rum-col',
3487
+ role: 'columnheader',
3488
+ onMouseEnter: (event) => hint.show(t('hintAmortized'), event),
3489
+ onMouseLeave: hint.hide,
3490
+ },
3491
+ t('colAmortized'),
3492
+ ),
2733
3493
  ),
2734
3494
  live !== null
2735
3495
  ? h(
@@ -2757,17 +3517,21 @@ window.__ModuleLoader__.load({
2757
3517
  */
2758
3518
  className: 'dsh-rum-col dsh-rum-index',
2759
3519
  role: 'cell',
2760
- 'aria-label': t('drawerLive'),
2761
- title: t('drawerLive'),
3520
+ 'aria-label':
3521
+ live.compaction !== null && live.compaction !== undefined
3522
+ ? t('drawerCompacting')
3523
+ : t('drawerLive'),
2762
3524
  },
2763
3525
  /*
2764
- * The same bolt the status pill uses while a request streams, so the
2765
- * marker reads as one idea in both places rather than a dot here and
2766
- * a bolt there.
3526
+ * The same glyphs the status pill uses, so a marker means one thing
3527
+ * wherever it appears: the bolt for a reply, the T for its tools,
3528
+ * the three bars for a compaction.
2767
3529
  */
2768
- live.phase === 'tools'
2769
- ? h(ToolIcon, { className: 'dsh-rum-live-bolt dsh-rum-tool-icon' })
2770
- : h(BoltIcon, { className: 'dsh-rum-live-bolt' }),
3530
+ live.compaction !== null && live.compaction !== undefined
3531
+ ? h(CompactionIcon, { className: 'dsh-rum-live-bolt dsh-rum-compaction-icon' })
3532
+ : live.phase === 'tools'
3533
+ ? h(ToolIcon, { className: 'dsh-rum-live-bolt dsh-rum-tool-icon' })
3534
+ : h(BoltIcon, { className: 'dsh-rum-live-bolt' }),
2771
3535
  ),
2772
3536
  /*
2773
3537
  * The clock, not the word "streaming".
@@ -2793,10 +3557,21 @@ window.__ModuleLoader__.load({
2793
3557
  h(
2794
3558
  'span',
2795
3559
  { className: 'dsh-rum-col dsh-rum-primary', role: 'cell' },
2796
- speedText(live.speed, live.estimated === true, t),
3560
+ live.compaction !== null && live.compaction !== undefined
3561
+ ? t('compactionSpeed')
3562
+ : speedText(live.speed, live.estimated === true, t),
2797
3563
  ),
2798
3564
  h('span', { className: 'dsh-rum-col', role: 'cell' }, tokensText(live.tokens, live.estimated === true, t)),
2799
- h('span', { className: 'dsh-rum-col', role: 'cell' }, secondsText(live.totalMs, t)),
3565
+ h(
3566
+ 'span',
3567
+ { className: 'dsh-rum-col', role: 'cell' },
3568
+ secondsText(
3569
+ live.compaction !== null && live.compaction !== undefined
3570
+ ? compactionSpan(live.compaction, now)
3571
+ : live.totalMs,
3572
+ t,
3573
+ ),
3574
+ ),
2800
3575
  h(
2801
3576
  'span',
2802
3577
  { className: 'dsh-rum-col', role: 'cell' },
@@ -2809,45 +3584,106 @@ window.__ModuleLoader__.load({
2809
3584
  'div',
2810
3585
  {
2811
3586
  key: entry.key,
2812
- className: 'dsh-rum-row dsh-rum-item',
3587
+ className:
3588
+ 'dsh-rum-row dsh-rum-item' +
3589
+ (entry.row.compaction === true ? ' dsh-rum-compaction-row' : ''),
2813
3590
  'data-phase': entry.phase,
2814
3591
  role: 'row',
2815
3592
  },
2816
- h('span', { className: 'dsh-rum-index', role: 'cell' }, String(entry.index + 1)),
3593
+ /*
3594
+ * The index column shows the phase glyph instead of a number while a
3595
+ * request or a compaction is still running: the row is not a finished
3596
+ * record yet, so numbering it would imply it belongs with the ten.
3597
+ */
2817
3598
  h(
2818
3599
  'span',
2819
- { className: 'dsh-rum-clock', role: 'cell', title: agoText(entry.row.at, now, t) },
3600
+ { className: 'dsh-rum-index', role: 'cell' },
3601
+ entry.row.compaction === true
3602
+ ? h(CompactionIcon, {
3603
+ className:
3604
+ 'dsh-rum-live-bolt dsh-rum-compaction-icon' +
3605
+ (entry.row.running === true ? '' : ' dsh-rum-still'),
3606
+ })
3607
+ : entry.phase === 'tools'
3608
+ ? h(ToolIcon, { className: 'dsh-rum-live-bolt dsh-rum-tool-icon' })
3609
+ : entry.phase === 'writing'
3610
+ ? h(BoltIcon, { className: 'dsh-rum-live-bolt' })
3611
+ : String(entry.index + 1),
3612
+ ),
3613
+ /*
3614
+ * The clock's hint is the absolute timestamp: the relative wording the
3615
+ * cell used to carry in `title` moved into the tooltip once the drawer
3616
+ * gained one, and "3 minutes ago" cannot answer "which one was that".
3617
+ */
3618
+ h(
3619
+ 'span',
3620
+ {
3621
+ className: 'dsh-rum-clock',
3622
+ role: 'cell',
3623
+ onMouseEnter: (event) => hint.show(absoluteStamp(entry.row.at), event),
3624
+ onMouseLeave: hint.hide,
3625
+ },
2820
3626
  clockText(entry.row.at),
2821
3627
  ),
2822
3628
  h(
2823
3629
  'span',
2824
3630
  { className: 'dsh-rum-col', role: 'cell' },
2825
3631
  /*
2826
- * The first-token column reports whatever was actually measured. An
2827
- * interrupted request that had already produced its first token shows
2828
- * that real figure; one stopped before any token shows the dash.
3632
+ * A compaction has no first token, so the column is always the dash.
3633
+ * An interrupted request keeps whatever was measured: one stopped
3634
+ * after its first token shows that real figure.
2829
3635
  */
2830
- secondsText(entry.row.ttftMs, t),
3636
+ secondsText(entry.row.compaction === true ? null : entry.row.ttftMs, t),
2831
3637
  ),
2832
3638
  h(
2833
3639
  'span',
2834
- { className: 'dsh-rum-col dsh-rum-primary', role: 'cell' },
3640
+ {
3641
+ className: 'dsh-rum-col dsh-rum-primary',
3642
+ role: 'cell',
3643
+ /*
3644
+ * The hint names the model that served this row. A compaction's
3645
+ * summarizer reuses the routed model, and `compaction/summary`
3646
+ * records it, so both kinds of row can answer.
3647
+ */
3648
+ onMouseEnter: (event) => hint.show(modelHintText(entry.row, t), event),
3649
+ onMouseLeave: hint.hide,
3650
+ },
2835
3651
  /*
2836
- * A cancelled step never settled, so it has no generation speed. The
2837
- * column says what happened instead of the same dash a step that has
2838
- * not started would show — the speed column is where "this produced no
2839
- * rate" belongs, while first-token and total still carry real figures.
3652
+ * A cancelled step never settled and a compaction never generates, so
3653
+ * neither has a rate. The column says what happened instead of the same
3654
+ * dash a request that has not started would show.
2840
3655
  */
2841
- entry.row.interrupted === true
2842
- ? t('interrupted')
2843
- : speedText(entry.row.speed, false, t),
3656
+ entry.row.compaction === true
3657
+ ? t('compactionSpeed')
3658
+ : entry.row.interrupted === true
3659
+ ? t('interrupted')
3660
+ : speedText(entry.row.speed, false, t),
2844
3661
  ),
2845
3662
  h(
2846
3663
  'span',
2847
- { className: 'dsh-rum-col', role: 'cell' },
3664
+ {
3665
+ className: 'dsh-rum-col',
3666
+ role: 'cell',
3667
+ onMouseEnter: (event) => hint.show(tokensHintText(entry.row, t), event),
3668
+ onMouseLeave: hint.hide,
3669
+ },
2848
3670
  tokensText(entry.row.tokens, entry.row.estimated, t),
2849
3671
  ),
2850
- h('span', { className: 'dsh-rum-col', role: 'cell' }, secondsText(entry.row.totalMs, t)),
3672
+ h(
3673
+ 'span',
3674
+ { className: 'dsh-rum-col', role: 'cell' },
3675
+ secondsText(
3676
+ /*
3677
+ * A running compaction counts up from its own start, exactly as the
3678
+ * pill does, so the two figures cannot diverge; the frozen `wall`
3679
+ * takes over the moment the fold reports it.
3680
+ */
3681
+ entry.row.compaction === true && entry.row.running === true
3682
+ ? compactionSpan(entry.row, now)
3683
+ : entry.row.totalMs,
3684
+ t,
3685
+ ),
3686
+ ),
2851
3687
  h(
2852
3688
  'span',
2853
3689
  { className: 'dsh-rum-col', role: 'cell' },