oc-flight-deck 0.23.1 → 0.25.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/dist/tui/index.js CHANGED
@@ -722,8 +722,8 @@ var STAT_FIELDS = [
722
722
  "agent",
723
723
  "model",
724
724
  "branch",
725
- "cost",
726
- "total",
725
+ "spend",
726
+ "lifetime",
727
727
  "project",
728
728
  "tokens",
729
729
  "cache",
@@ -742,10 +742,16 @@ var STAT_FIELDS = [
742
742
  ];
743
743
  var ANIMATED_FIELDS = ["caution", "status", "elapsed", "tps"];
744
744
  function isStatField(value) {
745
- return value === "session" || STAT_FIELDS.some((field) => field === value);
745
+ return value === "session" || value === "cost" || value === "total" || STAT_FIELDS.some((field) => field === value);
746
746
  }
747
747
  function canonicalField(name) {
748
- return name === "session" ? "ses" : name;
748
+ if (name === "session")
749
+ return "ses";
750
+ if (name === "cost")
751
+ return "spend";
752
+ if (name === "total")
753
+ return "lifetime";
754
+ return name;
749
755
  }
750
756
  function fieldLabel(field, labels) {
751
757
  const override = labels?.[canonicalField(field)];
@@ -753,13 +759,13 @@ function fieldLabel(field, labels) {
753
759
  return override;
754
760
  return field === "ses" ? "session" : field;
755
761
  }
756
- var DEFAULT_PLACEHOLDER = "\u2014";
762
+ var DEFAULT_PLACEHOLDER = "0";
757
763
  var DEFAULT_LABEL_WIDTH = 10;
758
764
  var DEFAULT_SPARK_WIDTH = 12;
759
765
  function skeletonValue(field, layout) {
760
766
  switch (canonicalField(field)) {
761
- case "cost":
762
- case "total":
767
+ case "spend":
768
+ case "lifetime":
763
769
  case "project":
764
770
  return formatCost(0);
765
771
  case "tokens":
@@ -772,8 +778,10 @@ function skeletonValue(field, layout) {
772
778
  return "0 waiting";
773
779
  case "elapsed":
774
780
  return formatDuration(0, layout.durationStyle);
775
- case "tps":
776
- return layout.tpsDisplay === "both" ? "0 rt \xB7 0 avg" : "0 tok/s";
781
+ case "tps": {
782
+ const label = layout.tpsLabel ?? "tok/s";
783
+ return layout.tpsDisplay === "both" ? `0 rt \xB7 0 avg` : `0 ${label}`;
784
+ }
777
785
  case "spark":
778
786
  return "\u2581".repeat(Math.max(0, Math.floor(layout.sparkWidth ?? DEFAULT_SPARK_WIDTH)));
779
787
  case "reasoning":
@@ -962,37 +970,30 @@ function statLine(field, source, layout = {}) {
962
970
  const branch = asText2(source.branch);
963
971
  return branch === undefined ? undefined : row("branch", branch);
964
972
  }
965
- case "cost": {
973
+ case "spend": {
966
974
  const cost = asCount2(source.cost);
967
975
  const tree = asRecord2(source.tree);
968
976
  const treeCost = asCount2(tree?.cost);
969
977
  const count = asCount2(tree?.count);
970
978
  const family = count !== undefined && count > 0 ? count : 0;
971
- const merge = layout.hasTotalRow !== true && cost !== undefined && treeCost !== undefined && family > 0 && treeCost > cost;
979
+ const merge = layout.hasLifetimeRow !== true && cost !== undefined && treeCost !== undefined && family > 0 && treeCost > cost;
972
980
  if (!merge) {
973
- if (cost === undefined)
974
- return;
975
- return row("cost", `${feeMark(source.costKind)}${formatCost(cost)}`);
981
+ return row(field, `${feeMark(source.costKind)}${formatCost(cost ?? 0)}`);
976
982
  }
977
983
  const plural = family === 1 ? "subagent" : "subagents";
978
- return row("cost", `${feeMark(tree?.kind)}${formatCost(treeCost)} \xB7 ${family} ${plural}`);
984
+ return row(field, `${feeMark(tree?.kind)}${formatCost(treeCost)} \xB7 ${family} ${plural}`);
979
985
  }
980
- case "total": {
981
- const tree = asRecord2(source.tree);
982
- if (tree === undefined)
983
- return;
984
- const cost = asCount2(tree.cost);
985
- if (cost === undefined)
986
- return;
987
- const count = asCount2(tree.count) ?? 0;
986
+ case "lifetime": {
987
+ const live = asRecord2(source.tree);
988
+ const durable = asRecord2(source.lifetime);
989
+ const cost = asCount2(durable?.cost) ?? asCount2(live?.cost) ?? 0;
990
+ const count = asCount2(live?.count) ?? 0;
988
991
  const plural = count === 1 ? "subagent" : "subagents";
989
- return row("total", `${feeMark(tree.kind)}${formatCost(cost)} \xB7 ${count} ${plural}`);
992
+ return row(field, `${feeMark(durable?.kind ?? live?.kind)}${formatCost(cost)} \xB7 ${count} ${plural}`);
990
993
  }
991
994
  case "project": {
992
995
  const project = asRecord2(source.project);
993
- const cost = asCount2(project?.cost);
994
- if (cost === undefined)
995
- return;
996
+ const cost = asCount2(project?.cost) ?? 0;
996
997
  const count = asCount2(project?.count);
997
998
  return row("project", `${formatCost(cost)}${count !== undefined && count > 1 ? ` \xB7 ${count} sessions` : ""}`);
998
999
  }
@@ -1000,18 +1001,12 @@ function statLine(field, source, layout = {}) {
1000
1001
  const tokens = asRecord2(source.tokens);
1001
1002
  const input = asCount2(tokens?.input);
1002
1003
  const output = asCount2(tokens?.output);
1003
- if (input === undefined && output === undefined)
1004
- return;
1005
1004
  return row("tokens", `${formatCount(input ?? 0)} in \xB7 ${formatCount(output ?? 0)} out`);
1006
1005
  }
1007
1006
  case "cache": {
1008
1007
  const tokens = asRecord2(source.tokens);
1009
- if (tokens === undefined)
1010
- return;
1011
- const cache = asRecord2(tokens.cache);
1012
- const read = asCount2(cache?.read);
1013
- if (read === undefined)
1014
- return;
1008
+ const cache = asRecord2(tokens?.cache);
1009
+ const read = asCount2(cache?.read) ?? 0;
1015
1010
  const input = asCount2(tokens?.input);
1016
1011
  const total = input === undefined ? undefined : read + input;
1017
1012
  if (read === 0) {
@@ -1023,9 +1018,9 @@ function statLine(field, source, layout = {}) {
1023
1018
  case "context": {
1024
1019
  const context = asRecord2(source.context);
1025
1020
  const used = asCount2(context?.used);
1026
- if (used === undefined || used === 0)
1027
- return;
1028
1021
  const limit = asCount2(context?.limit);
1022
+ if (used === undefined || used === 0)
1023
+ return row("context", "~0 used");
1029
1024
  if (limit === undefined || limit === 0)
1030
1025
  return row("context", `~${formatCount(used)} used`);
1031
1026
  const ratio = used / limit;
@@ -1046,9 +1041,7 @@ function statLine(field, source, layout = {}) {
1046
1041
  return row("perms", resource === undefined ? action : `${action} \xB7 ${clip(resource, 18)}`);
1047
1042
  }
1048
1043
  case "elapsed": {
1049
- const ms = asCount2(source.elapsedMs);
1050
- if (ms === undefined || ms <= 0)
1051
- return;
1044
+ const ms = asCount2(source.elapsedMs) ?? 0;
1052
1045
  return row("elapsed", formatDuration(ms, layout.durationStyle));
1053
1046
  }
1054
1047
  case "updated": {
@@ -1063,27 +1056,24 @@ function statLine(field, source, layout = {}) {
1063
1056
  const rt = asCount2(pair?.["rt"]);
1064
1057
  const avg = asCount2(pair?.["avg"]);
1065
1058
  const ttft = asCount2(pair?.["ttft"]);
1066
- const display = layout.tpsDisplay ?? "avg";
1059
+ const shownTtft = layout.tpsTtft ?? true ? ttft : undefined;
1060
+ const display = layout.tpsDisplay ?? "rt";
1061
+ const label = layout.tpsLabel ?? "tok/s";
1062
+ const rounded = (value) => {
1063
+ const value_ = value === undefined ? 0 : Math.round(value);
1064
+ return value_ > 0 ? value_ : 0;
1065
+ };
1066
+ const current = rounded(rt);
1067
+ const settled = rounded(avg);
1068
+ const suffix = shownTtft === undefined ? "" : ` \xB7 ${shownTtft.toFixed(1)}s ttft`;
1067
1069
  if (display === "rt") {
1068
- const rounded = rt === undefined ? undefined : Math.round(rt);
1069
- if (rounded === undefined || rounded <= 0)
1070
- return;
1071
- return row("tps", `${rounded} tok/s`);
1070
+ return row("tps", current > 0 ? `${current} ${label}${suffix}` : `0 ${label}`);
1072
1071
  }
1073
1072
  if (display === "both") {
1074
- if (avg !== undefined) {
1075
- if (Math.round(avg) <= 0)
1076
- return;
1077
- const head = `${rt === undefined ? 0 : Math.round(rt)} rt \xB7 ${Math.round(avg)} avg`;
1078
- return ttft === undefined ? row("tps", head) : row("tps", `${head} \xB7 ${ttft.toFixed(1)}s ttft`);
1079
- }
1080
- if (rt !== undefined && Math.round(rt) > 0)
1081
- return row("tps", `${Math.round(rt)} rt`);
1082
- return;
1073
+ const head = `${current} rt \xB7 ${settled} avg`;
1074
+ return row("tps", settled > 0 ? head + suffix : head);
1083
1075
  }
1084
- if (avg === undefined || Math.round(avg) <= 0)
1085
- return;
1086
- return row("tps", `${Math.round(avg)} tok/s`);
1076
+ return row("tps", `${settled} ${label}`);
1087
1077
  }
1088
1078
  case "spark": {
1089
1079
  const values = Array.isArray(source.spark) ? source.spark.map((value) => asCount2(value) ?? 0) : [];
@@ -1093,9 +1083,7 @@ function statLine(field, source, layout = {}) {
1093
1083
  return row("spark", sparkline(windowed));
1094
1084
  }
1095
1085
  case "reasoning": {
1096
- const reasoning = asCount2(asRecord2(source.tokens)?.reasoning);
1097
- if (reasoning === undefined || reasoning === 0)
1098
- return;
1086
+ const reasoning = asCount2(asRecord2(source.tokens)?.reasoning) ?? 0;
1099
1087
  return row("reasoning", formatCount(reasoning));
1100
1088
  }
1101
1089
  case "turns": {
@@ -1144,14 +1132,17 @@ function statSegments(field, source, layout = {}) {
1144
1132
  return [{ text: labelPrefix(fieldLabel(name, layout.labels), layout.labelWidth ?? DEFAULT_LABEL_WIDTH) }, ...value];
1145
1133
  }
1146
1134
  function statRows(fields, source, layout = {}) {
1147
- const hint = { ...layout, hasTotalRow: fields.includes("total") };
1135
+ const hint = {
1136
+ ...layout,
1137
+ hasLifetimeRow: fields.some((field) => canonicalField(field) === "lifetime")
1138
+ };
1148
1139
  const persist = hint.persist === true;
1149
1140
  const placeholder = hint.placeholder ?? DEFAULT_PLACEHOLDER;
1150
1141
  const labelWidth = hint.labelWidth ?? DEFAULT_LABEL_WIDTH;
1151
1142
  const rows = [];
1152
1143
  for (const field of fields) {
1153
1144
  const name = canonicalField(field);
1154
- const line = statLine(name, source, hint);
1145
+ const line = statLine(field, source, hint);
1155
1146
  if (line !== undefined) {
1156
1147
  rows.push(line);
1157
1148
  continue;
@@ -1519,6 +1510,63 @@ function createRealtimeTps(context, opts) {
1519
1510
  return active && !disposed;
1520
1511
  }, rate, ttft, dispose };
1521
1512
  }
1513
+ // src/tui/lifetime-totals.ts
1514
+ import { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from "fs";
1515
+ import { homedir } from "os";
1516
+ import { dirname, join } from "path";
1517
+ function defaultLifetimeTotalsPath() {
1518
+ return join(homedir(), ".local", "share", "opencode", "flight-deck", "totals.json");
1519
+ }
1520
+ function createLifetimeTotals(options = {}) {
1521
+ const path = options.path ?? defaultLifetimeTotalsPath();
1522
+ const held = new Map;
1523
+ const storedValues = () => {
1524
+ try {
1525
+ if (!existsSync(path))
1526
+ return {};
1527
+ const parsed = JSON.parse(readFileSync(path, "utf8"));
1528
+ if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed))
1529
+ return {};
1530
+ const values = {};
1531
+ for (const [id, value] of Object.entries(parsed)) {
1532
+ if (typeof value === "number" && Number.isFinite(value) && value > 0)
1533
+ values[id] = value;
1534
+ }
1535
+ return values;
1536
+ } catch {
1537
+ return {};
1538
+ }
1539
+ };
1540
+ const writeAll = (values) => {
1541
+ try {
1542
+ mkdirSync(dirname(path), { recursive: true });
1543
+ const temporary = `${path}.${process.pid}.tmp`;
1544
+ writeFileSync(temporary, JSON.stringify(values));
1545
+ renameSync(temporary, path);
1546
+ } catch {}
1547
+ };
1548
+ return {
1549
+ read(id) {
1550
+ const stored = storedValues()[id];
1551
+ const memory = held.get(id);
1552
+ if (stored === undefined && memory === undefined)
1553
+ return;
1554
+ return Math.max(stored ?? 0, memory ?? 0);
1555
+ },
1556
+ record(id, value) {
1557
+ if (!Number.isFinite(value) || value <= 0)
1558
+ return;
1559
+ const previous = Math.max(held.get(id) ?? 0, storedValues()[id] ?? 0);
1560
+ if (value <= previous)
1561
+ return;
1562
+ held.set(id, value);
1563
+ const values = storedValues();
1564
+ values[id] = value;
1565
+ writeAll(values);
1566
+ }
1567
+ };
1568
+ }
1569
+
1522
1570
  // src/tui/style.ts
1523
1571
  var TextAttributes = {
1524
1572
  NONE: 0,
@@ -1595,7 +1643,9 @@ var DEFAULT_GO_PANEL_LOOK = {
1595
1643
  blinkMs: 700
1596
1644
  };
1597
1645
  var DEFAULT_TPS_SCOPE = "family";
1598
- var DEFAULT_TPS_DISPLAY = "avg";
1646
+ var DEFAULT_TPS_DISPLAY = "rt";
1647
+ var DEFAULT_TPS_TTFT = true;
1648
+ var DEFAULT_TPS_LABEL = "tok/s";
1599
1649
  function cautionThresholds(config) {
1600
1650
  return {
1601
1651
  toolWatchMs: config.toolWatchSeconds * 1000,
@@ -1643,7 +1693,7 @@ var DEFAULT_SIDEBAR_ROWS = [
1643
1693
  "status",
1644
1694
  "agent",
1645
1695
  "model",
1646
- "cost",
1696
+ "spend",
1647
1697
  "project",
1648
1698
  "tokens",
1649
1699
  "cache",
@@ -1663,7 +1713,12 @@ var DEFAULT_CONFIG = {
1663
1713
  lines: DEFAULT_SIDEBAR_LINES,
1664
1714
  footer: { lines: DEFAULT_SIDEBAR_FOOTER_LINES, go: false },
1665
1715
  rows: DEFAULT_SIDEBAR_ROWS,
1666
- tps: { scope: DEFAULT_TPS_SCOPE, display: DEFAULT_TPS_DISPLAY },
1716
+ tps: {
1717
+ scope: DEFAULT_TPS_SCOPE,
1718
+ display: DEFAULT_TPS_DISPLAY,
1719
+ label: DEFAULT_TPS_LABEL,
1720
+ ttft: DEFAULT_TPS_TTFT
1721
+ },
1667
1722
  persist: true,
1668
1723
  placeholder: DEFAULT_PLACEHOLDER,
1669
1724
  maxLines: MAX_LINES
@@ -1675,7 +1730,8 @@ var DEFAULT_CONFIG = {
1675
1730
  format: DEFAULT_FORMAT,
1676
1731
  glyphs: DEFAULT_GLYPHS,
1677
1732
  style: DEFAULT_STYLE,
1678
- refresh: DEFAULT_REFRESH_MS
1733
+ refresh: DEFAULT_REFRESH_MS,
1734
+ lifetimeTotalsPath: defaultLifetimeTotalsPath()
1679
1735
  };
1680
1736
  var MAX_LINE_LENGTH = 120;
1681
1737
  var CONTROL_CHAR = /[\u0000-\u001F\u007F-\u009F]/;
@@ -1844,7 +1900,13 @@ function readRows(value, issues, maxLines) {
1844
1900
  issues.push(`${path} is not a known field (${STAT_FIELDS.join(", ")}); skipping it`);
1845
1901
  return;
1846
1902
  }
1847
- rows.push(canonicalField(name));
1903
+ const canonical = canonicalField(name);
1904
+ const duplicateOf = rows.find((entry) => canonicalField(entry) === canonical);
1905
+ if (duplicateOf !== undefined) {
1906
+ issues.push(`${path} duplicates ${duplicateOf}; rendering the row once`);
1907
+ return;
1908
+ }
1909
+ rows.push(name === "session" ? "ses" : name);
1848
1910
  });
1849
1911
  if (rows.length === 0) {
1850
1912
  issues.push("sidebar.rows had no usable entries; using the default rows");
@@ -1865,17 +1927,49 @@ function readTpsDisplay(value, issues) {
1865
1927
  return DEFAULT_TPS_DISPLAY;
1866
1928
  if (value === "avg" || value === "rt" || value === "both")
1867
1929
  return value;
1868
- issues.push(`sidebar.tps.display must be "avg", "rt" or "both"; using "avg"`);
1930
+ issues.push(`sidebar.tps.display must be "avg", "rt" or "both"; using "${DEFAULT_TPS_DISPLAY}"`);
1869
1931
  return DEFAULT_TPS_DISPLAY;
1870
1932
  }
1933
+ function readTpsTtft(value, issues) {
1934
+ return readBoolean(value, DEFAULT_TPS_TTFT, "sidebar.tps.ttft", issues);
1935
+ }
1936
+ var TPS_LABEL_MAX_LENGTH = 16;
1937
+ function readTpsLabel(value, issues) {
1938
+ if (value === undefined)
1939
+ return DEFAULT_TPS_LABEL;
1940
+ if (typeof value !== "string") {
1941
+ issues.push("sidebar.tps.label must be a string; using the default");
1942
+ return DEFAULT_TPS_LABEL;
1943
+ }
1944
+ const text = normalizeText(value, "sidebar.tps.label", issues);
1945
+ if (text.length === 0) {
1946
+ issues.push("sidebar.tps.label must not be empty; using the default");
1947
+ return DEFAULT_TPS_LABEL;
1948
+ }
1949
+ if (text.length > TPS_LABEL_MAX_LENGTH) {
1950
+ issues.push(`sidebar.tps.label was longer than ${TPS_LABEL_MAX_LENGTH} characters; using the default`);
1951
+ return DEFAULT_TPS_LABEL;
1952
+ }
1953
+ return text;
1954
+ }
1871
1955
  function readTps(section, issues) {
1872
1956
  const raw = section["tps"];
1873
1957
  if (raw !== undefined && !isRecord(raw)) {
1874
1958
  issues.push("sidebar.tps must be an object; using defaults");
1875
- return { scope: DEFAULT_TPS_SCOPE, display: DEFAULT_TPS_DISPLAY };
1959
+ return {
1960
+ scope: DEFAULT_TPS_SCOPE,
1961
+ display: DEFAULT_TPS_DISPLAY,
1962
+ label: DEFAULT_TPS_LABEL,
1963
+ ttft: DEFAULT_TPS_TTFT
1964
+ };
1876
1965
  }
1877
1966
  const tps = isRecord(raw) ? raw : {};
1878
- return { scope: readTpsScope(tps["scope"], issues), display: readTpsDisplay(tps["display"], issues) };
1967
+ return {
1968
+ scope: readTpsScope(tps["scope"], issues),
1969
+ display: readTpsDisplay(tps["display"], issues),
1970
+ label: readTpsLabel(tps["label"], issues),
1971
+ ttft: readTpsTtft(tps["ttft"], issues)
1972
+ };
1879
1973
  }
1880
1974
  function readMaxLines(value, issues) {
1881
1975
  return readNumber(value, MAX_LINES, "sidebar.maxLines", issues, 1, MAX_LINES);
@@ -1884,6 +1978,15 @@ function sectionOf(options, key) {
1884
1978
  const value = options[key];
1885
1979
  return isRecord(value) ? value : {};
1886
1980
  }
1981
+ function readLifetimeTotalsPath(value, issues) {
1982
+ if (value === undefined)
1983
+ return DEFAULT_CONFIG.lifetimeTotalsPath;
1984
+ if (typeof value !== "string" || value.trim().length === 0) {
1985
+ issues.push("lifetimeTotalsPath must be a non-empty string; using the default path");
1986
+ return DEFAULT_CONFIG.lifetimeTotalsPath;
1987
+ }
1988
+ return value.trim();
1989
+ }
1887
1990
  function readRefresh(value, issues) {
1888
1991
  if (value === undefined)
1889
1992
  return DEFAULT_REFRESH_MS;
@@ -2328,7 +2431,8 @@ function resolveConfig(options) {
2328
2431
  format: readFormat(format, issues),
2329
2432
  glyphs: readGlyphs(glyphs, issues),
2330
2433
  style: readStyle(style, issues),
2331
- refresh: readRefresh(options.refresh, issues)
2434
+ refresh: readRefresh(options.refresh, issues),
2435
+ lifetimeTotalsPath: readLifetimeTotalsPath(options.lifetimeTotalsPath, issues)
2332
2436
  },
2333
2437
  issues
2334
2438
  };
@@ -2340,19 +2444,19 @@ function shouldNotify(config, kind) {
2340
2444
  }
2341
2445
 
2342
2446
  // src/tui/file-config.ts
2343
- import { existsSync, readFileSync, statSync } from "fs";
2344
- import { homedir } from "os";
2345
- import { isAbsolute, join } from "path";
2447
+ import { existsSync as existsSync2, readFileSync as readFileSync2, statSync } from "fs";
2448
+ import { homedir as homedir2 } from "os";
2449
+ import { isAbsolute, join as join2 } from "path";
2346
2450
  var CONFIG_FILE_CANDIDATES = ["flight-deck.jsonc", "flight-deck.json"];
2347
2451
  function globalConfigDirectory() {
2348
2452
  const xdg = process.env["XDG_CONFIG_HOME"]?.trim();
2349
- return xdg !== undefined && xdg.length > 0 && isAbsolute(xdg) ? join(xdg, "opencode") : join(homedir(), ".config", "opencode");
2453
+ return xdg !== undefined && xdg.length > 0 && isAbsolute(xdg) ? join2(xdg, "opencode") : join2(homedir2(), ".config", "opencode");
2350
2454
  }
2351
2455
  var MAX_CONFIG_BYTES = 64 * 1024;
2352
2456
  function findConfigFile(directory = globalConfigDirectory()) {
2353
2457
  for (const candidate of CONFIG_FILE_CANDIDATES) {
2354
- const path = join(directory, candidate);
2355
- if (existsSync(path))
2458
+ const path = join2(directory, candidate);
2459
+ if (existsSync2(path))
2356
2460
  return path;
2357
2461
  }
2358
2462
  return;
@@ -2376,7 +2480,7 @@ function loadConfigFile(directory = globalConfigDirectory()) {
2376
2480
  const limit = Math.floor(MAX_CONFIG_BYTES / 1024);
2377
2481
  return { options: undefined, source, issue: `${source} is larger than ${limit} KiB; using defaults` };
2378
2482
  }
2379
- const text = readFileSync(source, "utf8");
2483
+ const text = readFileSync2(source, "utf8");
2380
2484
  if (text.trim().length === 0) {
2381
2485
  return { options: undefined, source, issue: `${source} is empty; using defaults` };
2382
2486
  }
@@ -2392,12 +2496,12 @@ function loadConfigFile(directory = globalConfigDirectory()) {
2392
2496
  }
2393
2497
 
2394
2498
  // src/tui/go-look.ts
2395
- import { existsSync as existsSync2, statSync as statSync2 } from "fs";
2396
- import { join as join2 } from "path";
2499
+ import { existsSync as existsSync3, statSync as statSync2 } from "fs";
2500
+ import { join as join3 } from "path";
2397
2501
  function findCandidate(directory) {
2398
2502
  for (const candidate of CONFIG_FILE_CANDIDATES) {
2399
- const path = join2(directory, candidate);
2400
- if (existsSync2(path))
2503
+ const path = join3(directory, candidate);
2504
+ if (existsSync3(path))
2401
2505
  return path;
2402
2506
  }
2403
2507
  return;
@@ -2466,7 +2570,9 @@ function railLines(config, source = {}) {
2466
2570
  durationStyle: config.format.duration,
2467
2571
  timestamp: config.format.timestamp,
2468
2572
  tpsDisplay: config.sidebar.tps.display,
2469
- hasTotalRow: config.sidebar.rows.includes("total")
2573
+ tpsLabel: config.sidebar.tps.label,
2574
+ tpsTtft: config.sidebar.tps.ttft,
2575
+ hasLifetimeRow: config.sidebar.rows.some((field) => canonicalField(field) === "lifetime")
2470
2576
  };
2471
2577
  const lines = config.sidebar.lines.map((text) => ({ text }));
2472
2578
  for (const field of config.sidebar.rows) {
@@ -2495,7 +2601,9 @@ function railLineSpans(line, style) {
2495
2601
  function footerLine(config) {
2496
2602
  return config.footer.enabled ? config.footer.text : undefined;
2497
2603
  }
2604
+
2498
2605
  // src/tui/go-panel.ts
2606
+ var NO_READING = "\u2014";
2499
2607
  var PANEL_WINDOWS = ["5h", "1w", "1m"];
2500
2608
  var PANEL_DEFAULT_LABELS = {
2501
2609
  rolling: "rolling",
@@ -2697,7 +2805,7 @@ function restingLine(label, look, reason, nowMs, isFirst) {
2697
2805
  segments.push({ text: `${reason} `, tone: "subdued" });
2698
2806
  trackCells = Math.max(0, cells - reason.length - 1);
2699
2807
  }
2700
- const tail = CELL.repeat(trackCells) + (look.showPercent ? ` ${alignCell(DEFAULT_PLACEHOLDER, PANEL_PERCENT_WIDTH, look.align)}` : "");
2808
+ const tail = CELL.repeat(trackCells) + (look.showPercent ? ` ${alignCell(NO_READING, PANEL_PERCENT_WIDTH, look.align)}` : "");
2701
2809
  segments.push({ text: tail, tone: "subdued" });
2702
2810
  return { field: "go", text: segments.map((segment) => segment.text).join(""), segments };
2703
2811
  }
@@ -2716,7 +2824,7 @@ function valueLine(label, look, window, nowMs, frame, isFirst) {
2716
2824
  appendRun(runs, CELL, "subdued");
2717
2825
  }
2718
2826
  if (look.showPercent) {
2719
- const percent = ratio === undefined ? DEFAULT_PLACEHOLDER : `${Math.round(ratio * 100)}%`;
2827
+ const percent = ratio === undefined ? NO_READING : `${Math.round(ratio * 100)}%`;
2720
2828
  appendRun(runs, ` ${alignCell(percent, PANEL_PERCENT_WIDTH, look.align)}`, tone);
2721
2829
  }
2722
2830
  const segments = [];
@@ -2998,9 +3106,9 @@ function startGuardBridge(host, deps, intervalMs = GUARD_POLL_MS) {
2998
3106
  }
2999
3107
 
3000
3108
  // src/tui/go.ts
3001
- import { appendFileSync, existsSync as existsSync3, mkdirSync, readFileSync as readFileSync2, writeFileSync } from "fs";
3109
+ import { appendFileSync, existsSync as existsSync4, mkdirSync as mkdirSync2, readFileSync as readFileSync3, writeFileSync as writeFileSync2 } from "fs";
3002
3110
  import { tmpdir } from "os";
3003
- import { join as join3 } from "path";
3111
+ import { join as join4 } from "path";
3004
3112
  var GO_KEY = "flight-deck.go";
3005
3113
  var GO_POLL_MS = 60000;
3006
3114
  var GO_USAGE_URL = "https://opencode.ai/zen/go/v1/usage";
@@ -3366,22 +3474,22 @@ function logPoll(entry) {
3366
3474
  if (!goLogEnabled())
3367
3475
  return;
3368
3476
  try {
3369
- const directory = join3(tmpdir(), GO_LOG_DIR);
3370
- const path = join3(directory, GO_LOG_FILE);
3477
+ const directory = join4(tmpdir(), GO_LOG_DIR);
3478
+ const path = join4(directory, GO_LOG_FILE);
3371
3479
  const line = `ts=${new Date().toISOString()} src=${entry.src} key=${entry.key ? "yes" : "no"} http=${entry.http} parse=${entry.parse} reason=${entry.reason}
3372
3480
  `;
3373
3481
  let prior = "";
3374
3482
  try {
3375
- if (existsSync3(path))
3376
- prior = readFileSync2(path, "utf8");
3483
+ if (existsSync4(path))
3484
+ prior = readFileSync3(path, "utf8");
3377
3485
  } catch {
3378
3486
  prior = "";
3379
3487
  }
3380
3488
  const lines = prior.length === 0 ? 0 : prior.split(`
3381
3489
  `).filter((row) => row.length > 0).length;
3382
- mkdirSync(directory, { recursive: true });
3490
+ mkdirSync2(directory, { recursive: true });
3383
3491
  if (lines >= GO_LOG_MAX_LINES)
3384
- writeFileSync(path, line);
3492
+ writeFileSync2(path, line);
3385
3493
  else
3386
3494
  appendFileSync(path, line);
3387
3495
  } catch {}
@@ -3524,12 +3632,12 @@ function startGoBridge(host, deps, intervalMs = GO_POLL_MS) {
3524
3632
 
3525
3633
  // src/tui/codex-quota.ts
3526
3634
  import { spawn } from "child_process";
3527
- import { existsSync as existsSync4, readFileSync as readFileSync3 } from "fs";
3528
- import { isAbsolute as isAbsolute2, join as join5 } from "path";
3635
+ import { existsSync as existsSync5, readFileSync as readFileSync4 } from "fs";
3636
+ import { isAbsolute as isAbsolute2, join as join6 } from "path";
3529
3637
  import { createInterface } from "readline";
3530
3638
 
3531
3639
  // src/tui/owned-process.ts
3532
- import { join as join4 } from "path";
3640
+ import { join as join5 } from "path";
3533
3641
  var supervisor = String.raw`
3534
3642
  using System;
3535
3643
  using System.ComponentModel;
@@ -3649,7 +3757,7 @@ ${supervisor}
3649
3757
  $argsList=${decode(JSON.stringify(args))}|ConvertFrom-Json
3650
3758
  ` + `exit [FlightDeckOwned]::Run($command,[string[]]$argsList,${ownerPid})`;
3651
3759
  return {
3652
- command: join4(process.env.SystemRoot ?? "C:\\Windows", "System32", "WindowsPowerShell", "v1.0", "powershell.exe"),
3760
+ command: join5(process.env.SystemRoot ?? "C:\\Windows", "System32", "WindowsPowerShell", "v1.0", "powershell.exe"),
3653
3761
  args: ["-NoLogo", "-NoProfile", "-NonInteractive", "-EncodedCommand", Buffer.from(script, "utf16le").toString("base64")]
3654
3762
  };
3655
3763
  }
@@ -3681,15 +3789,15 @@ function executable(pathValue = process.env.PATH ?? "") {
3681
3789
  for (const directory of pathValue.split(process.platform === "win32" ? ";" : ":")) {
3682
3790
  if (!isAbsolute2(directory))
3683
3791
  continue;
3684
- const path = join5(directory, process.platform === "win32" ? "codex.exe" : "codex");
3685
- if (!existsSync4(path))
3792
+ const path = join6(directory, process.platform === "win32" ? "codex.exe" : "codex");
3793
+ if (!existsSync5(path))
3686
3794
  continue;
3687
3795
  if (process.platform === "win32") {
3688
3796
  const shim = path.replace(/\.exe$/i, ".shim");
3689
- if (existsSync4(shim)) {
3797
+ if (existsSync5(shim)) {
3690
3798
  try {
3691
- const target = /^path\s*=\s*"([^"\r\n]+)"\s*$/m.exec(readFileSync3(shim, "utf8"))?.[1];
3692
- if (target && isAbsolute2(target) && /[\\/]codex\.exe$/i.test(target) && existsSync4(target))
3799
+ const target = /^path\s*=\s*"([^"\r\n]+)"\s*$/m.exec(readFileSync4(shim, "utf8"))?.[1];
3800
+ if (target && isAbsolute2(target) && /[\\/]codex\.exe$/i.test(target) && existsSync5(target))
3693
3801
  return target;
3694
3802
  } catch {}
3695
3803
  return;
@@ -4566,7 +4674,7 @@ var tui_default = Plugin.define({
4566
4674
  setup(context) {
4567
4675
  const file = loadConfigFile();
4568
4676
  const { config, issues } = resolveConfig(mergeOptions(file.options, context.options));
4569
- const rows = config.sidebar.enabled ? new Set(config.sidebar.rows) : new Set;
4677
+ const rows = config.sidebar.enabled ? new Set(config.sidebar.rows.map(canonicalField)) : new Set;
4570
4678
  const wants = (name) => rows.has(name);
4571
4679
  if (file.issue !== undefined && file.source !== undefined) {
4572
4680
  console.warn(`[flight-deck] ${file.issue}`);
@@ -4634,6 +4742,7 @@ var tui_default = Plugin.define({
4634
4742
  busy
4635
4743
  } = reads;
4636
4744
  const { projectTotals } = createProjectTotals(context);
4745
+ const lifetimeTotals = createLifetimeTotals({ path: config.lifetimeTotalsPath });
4637
4746
  const cautionThreshold = cautionThresholds(config.caution);
4638
4747
  const cautionsOf = (sessionID, now) => detectCautions({
4639
4748
  parts: recentParts(sessionID),
@@ -4691,9 +4800,27 @@ var tui_default = Plugin.define({
4691
4800
  const isBusy = busy(sessionID);
4692
4801
  spinnerNeeded = wants("status") && isBusy === true;
4693
4802
  const turns = wants("turns") ? messagesOf(sessionID).filter((entry) => asRecord2(entry)?.["type"] === "user").length : undefined;
4694
- const wantsUsage = wants("cost") || wants("total") || wants("tokens") || wants("cache") || wants("reasoning");
4803
+ const wantsUsage = wants("spend") || wants("lifetime") || wants("tokens") || wants("cache") || wants("reasoning");
4695
4804
  const ownCost = wantsUsage ? sessionCost(sessionID, session) : undefined;
4696
4805
  const tree = wantsUsage ? treeTotals(sessionID) : undefined;
4806
+ let lifetime;
4807
+ if (wantsUsage) {
4808
+ let root = sessionID;
4809
+ try {
4810
+ root = context.data.session.root(sessionID) ?? sessionID;
4811
+ } catch {
4812
+ root = sessionID;
4813
+ }
4814
+ const stored = lifetimeTotals.read(root);
4815
+ const live = tree?.cost;
4816
+ if (live !== undefined && (stored === undefined || live > stored)) {
4817
+ lifetimeTotals.record(root, live);
4818
+ }
4819
+ const high = Math.max(live ?? 0, stored ?? 0);
4820
+ if (live !== undefined || stored !== undefined) {
4821
+ lifetime = { cost: high, count: tree?.count ?? 0, kind: tree?.kind ?? "bounded" };
4822
+ }
4823
+ }
4697
4824
  return {
4698
4825
  ...session,
4699
4826
  cost: ownCost?.cost,
@@ -4702,6 +4829,7 @@ var tui_default = Plugin.define({
4702
4829
  caution: wants("caution") ? announce(sessionID) : undefined,
4703
4830
  branch: wants("branch") ? branchOf(location) : undefined,
4704
4831
  tree,
4832
+ lifetime,
4705
4833
  context: wants("context") ? contextUsage(sessionID, session?.model) : undefined,
4706
4834
  project: wants("project") ? projectTotals(sessionID) : undefined,
4707
4835
  status: wants("status") ? statusOf(sessionID) : undefined,