oc-flight-deck 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -93,13 +93,21 @@ them. On the session this was built against, the parent reported `$0.2246` while
93
93
  the true spend was `$0.2447` - **9% low on money, and 54% low on input tokens**.
94
94
 
95
95
  Rather than spend two rows on a number and its own superset, `cost` shows the
96
- family total and the delta that produced it:
96
+ family total and the count that explains it:
97
97
 
98
98
  ```
99
- cost $0.245 · +$0.020 · 2 subagents
99
+ cost $0.245 · 2 subagents
100
100
  ```
101
101
 
102
- `total` is still available if you prefer the two figures on separate rows.
102
+ **Add `total` to `sidebar.rows` and `cost` goes back to the session figure
103
+ alone** — the merge only happens when nothing else on the rail already shows it.
104
+ So "one money row or two" is decided by your rows list, not by another setting to
105
+ find.
106
+
107
+ The row is deliberately short. An earlier version also printed the delta
108
+ (`+ $0.020`), which pushed the row to 40 columns and made it **wrap** in a normal
109
+ sidebar. It was true information that did not earn its width, and a row that
110
+ wraps costs more than a row that says less.
103
111
 
104
112
  ### `cache` is the row that surprises people
105
113
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oc-flight-deck",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
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",
package/src/tui/stats.ts CHANGED
@@ -109,6 +109,14 @@ export interface LayoutHint {
109
109
  readonly labelWidth?: number;
110
110
  readonly barWidth?: number;
111
111
  readonly sparkWidth?: number;
112
+ /**
113
+ * True when the rail already draws a `total` row.
114
+ *
115
+ * The `cost` row merges the subagent total into itself only when nothing else
116
+ * on the rail already shows it — which makes "do I want one money row or two"
117
+ * a property of `sidebar.rows`, not a separate setting to find.
118
+ */
119
+ readonly hasTotalRow?: boolean;
112
120
  }
113
121
 
114
122
  const DEFAULT_LABEL_WIDTH = 10;
@@ -260,23 +268,30 @@ export function statLine(
260
268
  const tree = asRecord(source.tree);
261
269
  const treeCost = asCount(tree?.cost);
262
270
  const count = asCount(tree?.count);
271
+ const family = count !== undefined && count > 0 ? count : 0;
263
272
 
264
- // When subagents ran, this session's own cost understates the bill. Show
265
- // the family total and the delta that produced it, rather than spending a
266
- // second row on a number that contains the first. `total` still exists for
267
- // anyone who wants the two figures on separate rows.
268
- if (
273
+ // Merge only when subagents actually ran, and only when the rail is not
274
+ // already showing a `total` row. Two rows holding a number and its own
275
+ // superset was the thing worth fixing; a setting to choose between them
276
+ // would just be that duplication with extra steps.
277
+ const merge =
278
+ layout.hasTotalRow !== true &&
269
279
  cost !== undefined &&
270
280
  treeCost !== undefined &&
271
- count !== undefined &&
272
- count > 0 &&
273
- treeCost > cost
274
- ) {
275
- const plural = count === 1 ? "subagent" : "subagents";
276
- return row("cost", `${formatCost(treeCost)} · +${formatCost(treeCost - cost)} · ${count} ${plural}`);
281
+ family > 0 &&
282
+ treeCost > cost;
283
+
284
+ if (!merge) {
285
+ const value = layout.hasTotalRow === true ? (cost ?? treeCost) : (treeCost ?? cost);
286
+ return value === undefined ? undefined : row("cost", formatCost(value));
277
287
  }
278
- const value = cost ?? treeCost;
279
- return value === undefined ? undefined : row("cost", formatCost(value));
288
+
289
+ // The delta (`+$0.020`) used to be here and pushed the row to 40 columns,
290
+ // wide enough to wrap in a normal sidebar. It was real information that
291
+ // did not earn its width: the count already explains why the figure is
292
+ // higher, and this form is the same width as the old `total` row.
293
+ const plural = family === 1 ? "subagent" : "subagents";
294
+ return row("cost", `${formatCost(treeCost as number)} · ${family} ${plural}`);
280
295
  }
281
296
  case "total": {
282
297
  // Only worth a row once a subagent has actually run: subagent sessions are
@@ -342,7 +357,9 @@ export function statLine(
342
357
  return row("perms", action === undefined ? `${count} waiting` : `${count} waiting · ${action}`);
343
358
  }
344
359
  if (action === undefined) return row("perms", "1 waiting");
345
- return row("perms", resource === undefined ? action : `${action} · ${clip(resource, 22)}`);
360
+ // Clipped hard: a row that wraps costs the reader more than a row that
361
+ // shortens a path, and there is no way to ask the host how wide it is.
362
+ return row("perms", resource === undefined ? action : `${action} · ${clip(resource, 18)}`);
346
363
  }
347
364
  case "elapsed": {
348
365
  const ms = asCount(source.elapsedMs);
@@ -383,9 +400,13 @@ export function statRows(
383
400
  source: StatSource,
384
401
  layout: LayoutHint = {},
385
402
  ): readonly string[] {
403
+ // The rows list decides whether `cost` merges the subagent total into itself.
404
+ // Passing that down means the choice lives in `sidebar.rows`, where someone
405
+ // is already deciding what the rail shows.
406
+ const hint: LayoutHint = { ...layout, hasTotalRow: fields.includes("total") };
386
407
  const rows: string[] = [];
387
408
  for (const field of fields) {
388
- const line = statLine(field, source, layout);
409
+ const line = statLine(field, source, hint);
389
410
  if (line !== undefined) rows.push(line);
390
411
  }
391
412
  return rows;