oc-flight-deck 0.11.0 → 0.12.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/CHANGELOG.md CHANGED
@@ -5,6 +5,12 @@ All notable changes to this project are documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.12.0] - 2026-10-09
9
+
10
+ ### Changed
11
+
12
+ - The `tps` numerator now counts generation tokens - output plus reasoning - over the same streaming-span union, so a thinking-heavy turn reads as speed instead of idle time with no output yet. Tool settlement is still excluded, the denominator still ends at `streamed`, and the `reasoning` row itself is unchanged.
13
+
8
14
  ## [0.11.0] - 2026-10-08
9
15
 
10
16
  ### Changed
@@ -52,6 +58,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
52
58
 
53
59
  - Opt-in `ses` sidebar row: shows the full session id (the rail wraps it), and a mouse click copies that same full id and reports the outcome - a confirmation naming the id when the copy was sent, a distinct failure message when the terminal cannot take it. Off by default, and degrades gracefully when the terminal cannot copy.
54
60
 
61
+ [0.12.0]: https://github.com/nathwn12/oc-flight-deck/compare/v0.11.0...v0.12.0
55
62
  [0.11.0]: https://github.com/nathwn12/oc-flight-deck/compare/v0.10.4...v0.11.0
56
63
  [0.10.4]: https://github.com/nathwn12/oc-flight-deck/compare/v0.10.3...v0.10.4
57
64
  [0.10.3]: https://github.com/nathwn12/oc-flight-deck/compare/v0.10.2...v0.10.3
package/README.md CHANGED
@@ -65,7 +65,7 @@ The panel's only fixed text — `▸ FLIGHT DECK` over a separator — is **opt-
65
65
  | `context` | An estimated (`~`) gauge of how full the window is - occupancy is a proxy from the last request's `input + cache.read + cache.write`, not a host-reported figure |
66
66
  | `perms` | What is waiting for approval, not just how many |
67
67
  | `elapsed` | Active time — the clock runs only while this session, a subagent in its tree, or one of its shells is working, and freezes when everything settles. It is seeded once from the assistant turn spans the host already recorded for that session, so it survives a restart instead of resetting to `—`; work observed live after that keeps counting in memory. It measures active time, not wall-clock since the session began |
68
- | `tps` | Live speed **while generating**: the output-token delta between polls over the generating-time delta (streaming spans, or the busy-gated active clock), smoothed and drawn whole - no decimals. Reasoning has its own row and is out of the numerator. Idle is never divided: the figure freezes when everything settles and hides until ~2 s of generating time and ~10 tokens are on record. Not configurable |
68
+ | `tps` | Live speed **while generating**: the generation-token (output + reasoning) delta between polls over the generating-time delta (streaming spans, or the busy-gated active clock), smoothed and drawn whole - no decimals. Reasoning keeps its own row too. Idle is never divided: the figure freezes when everything settles and hides until ~2 s of generating time and ~10 tokens are on record. Not configurable |
69
69
  | `spark` | Recent turn sizes as a shape · **off by default** |
70
70
  | `reasoning` | Reasoning tokens, when the model emits them · **off by default** |
71
71
  | `turns` | How many prompts you've sent this session · **off by default** |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oc-flight-deck",
3
- "version": "0.11.0",
3
+ "version": "0.12.0",
4
4
  "description": "Live OpenCode V2 session telemetry — agent, model, branch, cost, tokens, cache hit rate and context usage in your sidebar.",
5
5
  "keywords": [
6
6
  "opencode",
@@ -7,8 +7,9 @@
7
7
  // the rate is the DELTA between successive polls, smoothed (alpha 0.3) and
8
8
  // repainted only on a move of >= 1 tok/s or >= 10%, so the row tracks live
9
9
  // decoding instead of sagging behind everything the session ever did. The
10
- // numerator is output tokens only - reasoning keeps its own row - and the
11
- // denominator is generating time only: the union of the turns' own streaming
10
+ // numerator is generation tokens - output plus reasoning, which keeps its own
11
+ // row too - and the denominator is generating time only: the union of the
12
+ // turns' own streaming
12
13
  // spans on a stamped host, the busy-gated active clock on one without stamps.
13
14
  // Idle is never divided by; when nothing is busy the tracker freezes and the
14
15
  // row holds its last figure. The row hides until ~2 s of generating time and
@@ -37,7 +38,7 @@ import {
37
38
  createInstantTps,
38
39
  turnKey,
39
40
  turnSpan,
40
- unionOutputTotals,
41
+ unionGenerationTotals,
41
42
  unionSpanMs,
42
43
  type ThroughputSpan,
43
44
  } from "./stats.js";
@@ -130,42 +131,49 @@ export function createTpsReader(
130
131
  const span = turnSpan(created, completed, streamed, now, "streamed");
131
132
  if (span === undefined) continue;
132
133
  const tokens = asRecord(message["tokens"]);
133
- // Output only: reasoning has its own row and no longer inflates the rate.
134
+ // Generation: output plus reasoning, which keeps its own row too. A
135
+ // settled id-less turn keys on its final counts, so two settled records
136
+ // sharing a start but differing in reasoning stay distinct.
137
+ const output = tokens?.["output"];
138
+ const reasoning = tokens?.["reasoning"];
139
+ const settled = completed !== undefined || streamed !== undefined;
140
+ const key = turnKey(message["id"], created, completed, output, streamed);
134
141
  spans.push({
135
- key: turnKey(message["id"], created, completed, tokens?.["output"], streamed),
136
- tokens: tokens?.["output"],
142
+ key: settled ? `${key}:${asCount(reasoning) ?? "?"}` : key,
143
+ tokens: output,
144
+ reasoning,
137
145
  ...span,
138
146
  });
139
147
  }
140
148
  return { ok: true, assistant, stamped, spans };
141
149
  };
142
150
 
143
- // Output tokens on record for the scope, for a host with no message
144
- // timestamps: the session records' own `output` rung, summed over the family
145
- // from a root. A child asking `family()` gets its ancestors and siblings
146
- // too, so it keeps its own figure. Reasoning is deliberately excluded.
147
- const recordOutput = (sessionID: string, session: SessionLike | undefined): number => {
148
- const outputOf = (source: SessionLike | undefined): number => {
151
+ // Generation tokens on record for the scope, for a host with no message
152
+ // timestamps: the session records' own `output` and `reasoning` rungs,
153
+ // summed over the family from a root. A child asking `family()` gets its
154
+ // ancestors and siblings too, so it keeps its own figure.
155
+ const recordGeneration = (sessionID: string, session: SessionLike | undefined): number => {
156
+ const generationOf = (source: SessionLike | undefined): number => {
149
157
  const tokens = asRecord(source?.tokens);
150
- return asCount(tokens?.["output"]) ?? 0;
158
+ return (asCount(tokens?.["output"]) ?? 0) + (asCount(tokens?.["reasoning"]) ?? 0);
151
159
  };
152
- if (!isFamilyRoot(sessionID)) return outputOf(session);
160
+ if (!isFamilyRoot(sessionID)) return generationOf(session);
153
161
  try {
154
162
  const ids = context.data.session.family(sessionID) ?? [];
155
- if (ids.length <= 1) return outputOf(session);
163
+ if (ids.length <= 1) return generationOf(session);
156
164
  let total = 0;
157
165
  for (const id of ids) {
158
166
  if (id === sessionID) continue;
159
167
  try {
160
- total += outputOf(context.data.session.get(id) as SessionLike | undefined);
168
+ total += generationOf(context.data.session.get(id) as SessionLike | undefined);
161
169
  } catch {
162
170
  // One unreadable member must not hide the rest.
163
171
  }
164
172
  }
165
- return outputOf(session) + total;
173
+ return generationOf(session) + total;
166
174
  } catch {
167
175
  // No family on this host: the session's own tokens still stand.
168
- return outputOf(session);
176
+ return generationOf(session);
169
177
  }
170
178
  };
171
179
 
@@ -186,9 +194,9 @@ export function createTpsReader(
186
194
  const now = Date.now();
187
195
  const busy = busyOf(sessionID);
188
196
 
189
- // Timestamped assistant output this session has produced, plus - only from
190
- // a family root - every subagent session's. A child asking `family()` gets
191
- // its ancestors and siblings back, so it keeps its own spans.
197
+ // Timestamped assistant generation this session has produced, plus - only
198
+ // from a family root - every subagent session's. A child asking `family()`
199
+ // gets its ancestors and siblings back, so it keeps its own spans.
192
200
  const scans: TpsScan[] = hostStamps === false ? [] : [scanMessages(sessionID, now)];
193
201
  if (hostStamps !== false && isFamilyRoot(sessionID)) {
194
202
  try {
@@ -225,8 +233,9 @@ export function createTpsReader(
225
233
  // Generating time is the union of the turns' own streaming spans: idle
226
234
  // between turns was never recorded, so it can never enter the rate. An
227
235
  // in-flight turn ends at now, so the denominator keeps pace with the
228
- // decoder while work happens and freezes the instant it settles.
229
- const { tokens } = unionOutputTotals(spans);
236
+ // decoder while work happens and freezes the instant it settles. The
237
+ // numerator over it is generation: output plus reasoning.
238
+ const { tokens } = unionGenerationTotals(spans);
230
239
  const genMs = unionSpanMs(spans);
231
240
  return tracker(tokens, genMs, busy);
232
241
  }
@@ -235,14 +244,14 @@ export function createTpsReader(
235
244
  // clock, which runs only while the scope is actually working. Without that
236
245
  // clock there is no honest denominator - the row hides rather than falling
237
246
  // back to a lifetime average that bills idle as work.
238
- if (created === undefined) return tracker(recordOutput(sessionID, session), 0, busy);
247
+ if (created === undefined) return tracker(recordGeneration(sessionID, session), 0, busy);
239
248
  let genMs = 0;
240
249
  try {
241
250
  genMs = live?.elapsedMsOf?.(sessionID, now) ?? 0;
242
251
  } catch {
243
252
  genMs = 0;
244
253
  }
245
- return tracker(recordOutput(sessionID, session), genMs, busy);
254
+ return tracker(recordGeneration(sessionID, session), genMs, busy);
246
255
  };
247
256
 
248
257
  const sessionTps = (sessionID: string, session: SessionLike | undefined): number | undefined => {
package/src/tui/stats.ts CHANGED
@@ -28,6 +28,7 @@ export {
28
28
  tpsNeedsRepaint,
29
29
  turnKey,
30
30
  turnSpan,
31
+ unionGenerationTotals,
31
32
  unionOutputTotals,
32
33
  unionSpanMs,
33
34
  unionSpanThroughput,
@@ -11,7 +11,7 @@
11
11
  // reasoning tokens divided by the union of the assistant turns' own streaming
12
12
  // spans, so idle and tool-settlement time is never in the denominator and the
13
13
  // figure freezes once everything settles. `createInstantTps` is the live row's
14
- // tracker: output-only per-poll deltas over generating-time deltas, smoothed
14
+ // tracker: generation-token per-poll deltas over generating-time deltas, smoothed
15
15
  // with an EWMA and repainted through hysteresis, so the rail shows what the
16
16
  // decoder is doing now instead of everything the session ever did.
17
17
 
@@ -270,7 +270,7 @@ export const TPS_REPAINT_ABS = 1;
270
270
  export const TPS_REPAINT_RATIO = 0.1;
271
271
 
272
272
  /**
273
- * One per-poll instantaneous rate: output-token DELTA over generating-time
273
+ * One per-poll instantaneous rate: generation-token DELTA over generating-time
274
274
  * DELTA, never over idle time. The caller passes only what happened since the
275
275
  * previous poll; both deltas exclude idle by construction (the union of
276
276
  * streaming spans, or the busy-gated active clock), so a pause can never sag
@@ -310,12 +310,46 @@ export function tpsNeedsRepaint(displayed: number | undefined, smoothed: number)
310
310
  }
311
311
 
312
312
  /**
313
- * Output tokens and generating time for the TPS numerator's twin rule.
313
+ * Generation tokens and generating time for the TPS numerator: output plus
314
+ * reasoning, the same pair the official TUI divides.
315
+ *
316
+ * The same identity rule, clamp, pre-sort and merge as `unionSpanTotals`.
317
+ * Only the live TPS path uses this. `unionOutputTotals` below stays as the
318
+ * output-only twin, and `unionSpanTotals` (which feeds the other rows) is
319
+ * unchanged.
320
+ */
321
+ export function unionGenerationTotals(spans: readonly ThroughputSpan[]): SpanTotals {
322
+ const seen = new Set<string>();
323
+ const accepted: Array<{ start: number; end: number }> = [];
324
+ let tokens = 0;
325
+
326
+ for (const span of spans) {
327
+ const key = asText(span.key);
328
+ if (key === undefined || seen.has(key)) continue;
329
+
330
+ const start = asCount(span.start);
331
+ const end = asCount(span.end);
332
+ if (start === undefined || end === undefined) continue;
333
+ const output = asCount(span.tokens);
334
+ const reasoning = asCount(span.reasoning);
335
+
336
+ seen.add(key);
337
+ accepted.push({ start, end: Math.max(start, end) });
338
+ tokens += (output ?? 0) + (reasoning ?? 0);
339
+ }
340
+
341
+ return { tokens, unionMs: mergedSpanMs(accepted) };
342
+ }
343
+
344
+ /**
345
+ * Output tokens and generating time: the output-only twin of
346
+ * `unionGenerationTotals`.
314
347
  *
315
348
  * The same identity rule, clamp, pre-sort and merge as `unionSpanTotals`, but
316
- * the numerator counts OUTPUT tokens only: reasoning has its own row and no
317
- * longer inflates the rate. A thinking-heavy turn that emits nothing reads as
318
- * what it is - time spent with no output yet - rather than as speed.
349
+ * the numerator counts OUTPUT tokens only. The live TPS path no longer uses
350
+ * this - it divides generation tokens (`unionGenerationTotals`) - so a
351
+ * thinking-heavy turn reads as speed on that row rather than as time spent
352
+ * with no output yet.
319
353
  */
320
354
  export function unionOutputTotals(spans: readonly ThroughputSpan[]): SpanTotals {
321
355
  const seen = new Set<string>();
@@ -340,9 +374,9 @@ export function unionOutputTotals(spans: readonly ThroughputSpan[]): SpanTotals
340
374
  }
341
375
 
342
376
  /**
343
- * Near-instantaneous output rate for one displayed session scope.
377
+ * Near-instantaneous generation rate for one displayed session scope.
344
378
  *
345
- * The caller feeds each poll's cumulative output tokens and cumulative
379
+ * The caller feeds each poll's cumulative generation tokens and cumulative
346
380
  * generating milliseconds (streaming-span union, or the busy-gated active
347
381
  * clock - both exclude idle by construction) plus whether the scope is busy,
348
382
  * and gets back the figure to draw, or `undefined` while there is nothing