oc-flight-deck 0.24.0 → 0.25.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/CHANGELOG.md +15 -0
- package/README.md +42 -24
- package/dist/tui/index.js +285 -115
- package/docs/GUIDE.md +12 -8
- package/flight-deck.example.jsonc +49 -31
- package/flight-deck.schema.json +35 -11
- package/package.json +6 -6
- package/src/tui/caution.ts +15 -6
- package/src/tui/config.ts +125 -12
- package/src/tui/go-panel.ts +5 -3
- package/src/tui/index.tsx +48 -6
- package/src/tui/lifetime-totals.ts +92 -0
- package/src/tui/presentation.ts +12 -5
- package/src/tui/rows.ts +84 -76
- package/src/tui/session-reads.ts +55 -12
- package/src/tui/stat-fields.ts +59 -22
package/dist/tui/index.js
CHANGED
|
@@ -159,7 +159,7 @@ function detectCautions(input) {
|
|
|
159
159
|
}
|
|
160
160
|
}
|
|
161
161
|
const hasLiveWork = calls.some((call) => !SETTLED_TOOL.has(call.status)) || shells.some((raw) => asRecord(raw)?.["status"] === "running");
|
|
162
|
-
if (sessionRunning && !hasLiveWork) {
|
|
162
|
+
if (input.openTurn === true && sessionRunning && !hasLiveWork) {
|
|
163
163
|
const settledAt = newestActivity(calls) ?? input.lastMessageAt;
|
|
164
164
|
if (settledAt !== undefined) {
|
|
165
165
|
const elapsedMs = now - settledAt;
|
|
@@ -722,8 +722,8 @@ var STAT_FIELDS = [
|
|
|
722
722
|
"agent",
|
|
723
723
|
"model",
|
|
724
724
|
"branch",
|
|
725
|
-
"
|
|
726
|
-
"
|
|
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
|
-
|
|
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 = "
|
|
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 "
|
|
762
|
-
case "
|
|
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
|
-
|
|
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":
|
|
@@ -939,10 +947,14 @@ function statLine(field, source, layout = {}) {
|
|
|
939
947
|
}
|
|
940
948
|
case "status": {
|
|
941
949
|
const status = asText2(source.status);
|
|
942
|
-
|
|
950
|
+
const paused = source.paused === true;
|
|
951
|
+
if (status === undefined && source.busy === undefined && !paused)
|
|
943
952
|
return;
|
|
944
|
-
if (
|
|
953
|
+
if (paused)
|
|
954
|
+
return row("status", `${layout.pausedGlyph ?? "\u2016"} paused`);
|
|
955
|
+
if (source.busy === false || source.busy !== true && status !== "running") {
|
|
945
956
|
return row("status", "\u25CB idle");
|
|
957
|
+
}
|
|
946
958
|
const frame = Math.floor(asCount2(source.frame) ?? 0);
|
|
947
959
|
return row("status", `${SPINNER[frame % SPINNER.length]} running`);
|
|
948
960
|
}
|
|
@@ -962,37 +974,30 @@ function statLine(field, source, layout = {}) {
|
|
|
962
974
|
const branch = asText2(source.branch);
|
|
963
975
|
return branch === undefined ? undefined : row("branch", branch);
|
|
964
976
|
}
|
|
965
|
-
case "
|
|
977
|
+
case "spend": {
|
|
966
978
|
const cost = asCount2(source.cost);
|
|
967
979
|
const tree = asRecord2(source.tree);
|
|
968
980
|
const treeCost = asCount2(tree?.cost);
|
|
969
981
|
const count = asCount2(tree?.count);
|
|
970
982
|
const family = count !== undefined && count > 0 ? count : 0;
|
|
971
|
-
const merge = layout.
|
|
983
|
+
const merge = layout.hasLifetimeRow !== true && cost !== undefined && treeCost !== undefined && family > 0 && treeCost > cost;
|
|
972
984
|
if (!merge) {
|
|
973
|
-
|
|
974
|
-
return;
|
|
975
|
-
return row("cost", `${feeMark(source.costKind)}${formatCost(cost)}`);
|
|
985
|
+
return row(field, `${feeMark(source.costKind)}${formatCost(cost ?? 0)}`);
|
|
976
986
|
}
|
|
977
987
|
const plural = family === 1 ? "subagent" : "subagents";
|
|
978
|
-
return row(
|
|
988
|
+
return row(field, `${feeMark(tree?.kind)}${formatCost(treeCost)} \xB7 ${family} ${plural}`);
|
|
979
989
|
}
|
|
980
|
-
case "
|
|
981
|
-
const
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
const
|
|
985
|
-
if (cost === undefined)
|
|
986
|
-
return;
|
|
987
|
-
const count = asCount2(tree.count) ?? 0;
|
|
990
|
+
case "lifetime": {
|
|
991
|
+
const live = asRecord2(source.tree);
|
|
992
|
+
const durable = asRecord2(source.lifetime);
|
|
993
|
+
const cost = asCount2(durable?.cost) ?? asCount2(live?.cost) ?? 0;
|
|
994
|
+
const count = asCount2(live?.count) ?? 0;
|
|
988
995
|
const plural = count === 1 ? "subagent" : "subagents";
|
|
989
|
-
return row(
|
|
996
|
+
return row(field, `${feeMark(durable?.kind ?? live?.kind)}${formatCost(cost)} \xB7 ${count} ${plural}`);
|
|
990
997
|
}
|
|
991
998
|
case "project": {
|
|
992
999
|
const project = asRecord2(source.project);
|
|
993
|
-
const cost = asCount2(project?.cost);
|
|
994
|
-
if (cost === undefined)
|
|
995
|
-
return;
|
|
1000
|
+
const cost = asCount2(project?.cost) ?? 0;
|
|
996
1001
|
const count = asCount2(project?.count);
|
|
997
1002
|
return row("project", `${formatCost(cost)}${count !== undefined && count > 1 ? ` \xB7 ${count} sessions` : ""}`);
|
|
998
1003
|
}
|
|
@@ -1000,18 +1005,12 @@ function statLine(field, source, layout = {}) {
|
|
|
1000
1005
|
const tokens = asRecord2(source.tokens);
|
|
1001
1006
|
const input = asCount2(tokens?.input);
|
|
1002
1007
|
const output = asCount2(tokens?.output);
|
|
1003
|
-
if (input === undefined && output === undefined)
|
|
1004
|
-
return;
|
|
1005
1008
|
return row("tokens", `${formatCount(input ?? 0)} in \xB7 ${formatCount(output ?? 0)} out`);
|
|
1006
1009
|
}
|
|
1007
1010
|
case "cache": {
|
|
1008
1011
|
const tokens = asRecord2(source.tokens);
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
const cache = asRecord2(tokens.cache);
|
|
1012
|
-
const read = asCount2(cache?.read);
|
|
1013
|
-
if (read === undefined)
|
|
1014
|
-
return;
|
|
1012
|
+
const cache = asRecord2(tokens?.cache);
|
|
1013
|
+
const read = asCount2(cache?.read) ?? 0;
|
|
1015
1014
|
const input = asCount2(tokens?.input);
|
|
1016
1015
|
const total = input === undefined ? undefined : read + input;
|
|
1017
1016
|
if (read === 0) {
|
|
@@ -1023,9 +1022,9 @@ function statLine(field, source, layout = {}) {
|
|
|
1023
1022
|
case "context": {
|
|
1024
1023
|
const context = asRecord2(source.context);
|
|
1025
1024
|
const used = asCount2(context?.used);
|
|
1026
|
-
if (used === undefined || used === 0)
|
|
1027
|
-
return;
|
|
1028
1025
|
const limit = asCount2(context?.limit);
|
|
1026
|
+
if (used === undefined || used === 0)
|
|
1027
|
+
return row("context", "~0 used");
|
|
1029
1028
|
if (limit === undefined || limit === 0)
|
|
1030
1029
|
return row("context", `~${formatCount(used)} used`);
|
|
1031
1030
|
const ratio = used / limit;
|
|
@@ -1046,9 +1045,7 @@ function statLine(field, source, layout = {}) {
|
|
|
1046
1045
|
return row("perms", resource === undefined ? action : `${action} \xB7 ${clip(resource, 18)}`);
|
|
1047
1046
|
}
|
|
1048
1047
|
case "elapsed": {
|
|
1049
|
-
const ms = asCount2(source.elapsedMs);
|
|
1050
|
-
if (ms === undefined || ms <= 0)
|
|
1051
|
-
return;
|
|
1048
|
+
const ms = asCount2(source.elapsedMs) ?? 0;
|
|
1052
1049
|
return row("elapsed", formatDuration(ms, layout.durationStyle));
|
|
1053
1050
|
}
|
|
1054
1051
|
case "updated": {
|
|
@@ -1063,29 +1060,24 @@ function statLine(field, source, layout = {}) {
|
|
|
1063
1060
|
const rt = asCount2(pair?.["rt"]);
|
|
1064
1061
|
const avg = asCount2(pair?.["avg"]);
|
|
1065
1062
|
const ttft = asCount2(pair?.["ttft"]);
|
|
1063
|
+
const shownTtft = layout.tpsTtft ?? true ? ttft : undefined;
|
|
1066
1064
|
const display = layout.tpsDisplay ?? "rt";
|
|
1065
|
+
const label = layout.tpsLabel ?? "tok/s";
|
|
1066
|
+
const rounded = (value) => {
|
|
1067
|
+
const value_ = value === undefined ? 0 : Math.round(value);
|
|
1068
|
+
return value_ > 0 ? value_ : 0;
|
|
1069
|
+
};
|
|
1070
|
+
const current = rounded(rt);
|
|
1071
|
+
const settled = rounded(avg);
|
|
1072
|
+
const suffix = shownTtft === undefined ? "" : ` \xB7 ${shownTtft.toFixed(1)}s ttft`;
|
|
1067
1073
|
if (display === "rt") {
|
|
1068
|
-
|
|
1069
|
-
if (rounded === undefined || rounded <= 0) {
|
|
1070
|
-
return ttft === undefined ? undefined : row("tps", `${ttft.toFixed(1)}s ttft`);
|
|
1071
|
-
}
|
|
1072
|
-
const rate = `${rounded} tok/s`;
|
|
1073
|
-
return row("tps", ttft === undefined ? rate : `${rate} \xB7 ${ttft.toFixed(1)}s ttft`);
|
|
1074
|
+
return row("tps", current > 0 ? `${current} ${label}${suffix}` : `0 ${label}`);
|
|
1074
1075
|
}
|
|
1075
1076
|
if (display === "both") {
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
return;
|
|
1079
|
-
const head = `${rt === undefined ? 0 : Math.round(rt)} rt \xB7 ${Math.round(avg)} avg`;
|
|
1080
|
-
return ttft === undefined ? row("tps", head) : row("tps", `${head} \xB7 ${ttft.toFixed(1)}s ttft`);
|
|
1081
|
-
}
|
|
1082
|
-
if (rt !== undefined && Math.round(rt) > 0)
|
|
1083
|
-
return row("tps", `${Math.round(rt)} rt`);
|
|
1084
|
-
return;
|
|
1077
|
+
const head = `${current} rt \xB7 ${settled} avg`;
|
|
1078
|
+
return row("tps", settled > 0 ? head + suffix : head);
|
|
1085
1079
|
}
|
|
1086
|
-
|
|
1087
|
-
return;
|
|
1088
|
-
return row("tps", `${Math.round(avg)} tok/s`);
|
|
1080
|
+
return row("tps", `${settled} ${label}`);
|
|
1089
1081
|
}
|
|
1090
1082
|
case "spark": {
|
|
1091
1083
|
const values = Array.isArray(source.spark) ? source.spark.map((value) => asCount2(value) ?? 0) : [];
|
|
@@ -1095,9 +1087,7 @@ function statLine(field, source, layout = {}) {
|
|
|
1095
1087
|
return row("spark", sparkline(windowed));
|
|
1096
1088
|
}
|
|
1097
1089
|
case "reasoning": {
|
|
1098
|
-
const reasoning = asCount2(asRecord2(source.tokens)?.reasoning);
|
|
1099
|
-
if (reasoning === undefined || reasoning === 0)
|
|
1100
|
-
return;
|
|
1090
|
+
const reasoning = asCount2(asRecord2(source.tokens)?.reasoning) ?? 0;
|
|
1101
1091
|
return row("reasoning", formatCount(reasoning));
|
|
1102
1092
|
}
|
|
1103
1093
|
case "turns": {
|
|
@@ -1146,14 +1136,17 @@ function statSegments(field, source, layout = {}) {
|
|
|
1146
1136
|
return [{ text: labelPrefix(fieldLabel(name, layout.labels), layout.labelWidth ?? DEFAULT_LABEL_WIDTH) }, ...value];
|
|
1147
1137
|
}
|
|
1148
1138
|
function statRows(fields, source, layout = {}) {
|
|
1149
|
-
const hint = {
|
|
1139
|
+
const hint = {
|
|
1140
|
+
...layout,
|
|
1141
|
+
hasLifetimeRow: fields.some((field) => canonicalField(field) === "lifetime")
|
|
1142
|
+
};
|
|
1150
1143
|
const persist = hint.persist === true;
|
|
1151
1144
|
const placeholder = hint.placeholder ?? DEFAULT_PLACEHOLDER;
|
|
1152
1145
|
const labelWidth = hint.labelWidth ?? DEFAULT_LABEL_WIDTH;
|
|
1153
1146
|
const rows = [];
|
|
1154
1147
|
for (const field of fields) {
|
|
1155
1148
|
const name = canonicalField(field);
|
|
1156
|
-
const line = statLine(
|
|
1149
|
+
const line = statLine(field, source, hint);
|
|
1157
1150
|
if (line !== undefined) {
|
|
1158
1151
|
rows.push(line);
|
|
1159
1152
|
continue;
|
|
@@ -1521,6 +1514,63 @@ function createRealtimeTps(context, opts) {
|
|
|
1521
1514
|
return active && !disposed;
|
|
1522
1515
|
}, rate, ttft, dispose };
|
|
1523
1516
|
}
|
|
1517
|
+
// src/tui/lifetime-totals.ts
|
|
1518
|
+
import { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from "fs";
|
|
1519
|
+
import { homedir } from "os";
|
|
1520
|
+
import { dirname, join } from "path";
|
|
1521
|
+
function defaultLifetimeTotalsPath() {
|
|
1522
|
+
return join(homedir(), ".local", "share", "opencode", "flight-deck", "totals.json");
|
|
1523
|
+
}
|
|
1524
|
+
function createLifetimeTotals(options = {}) {
|
|
1525
|
+
const path = options.path ?? defaultLifetimeTotalsPath();
|
|
1526
|
+
const held = new Map;
|
|
1527
|
+
const storedValues = () => {
|
|
1528
|
+
try {
|
|
1529
|
+
if (!existsSync(path))
|
|
1530
|
+
return {};
|
|
1531
|
+
const parsed = JSON.parse(readFileSync(path, "utf8"));
|
|
1532
|
+
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed))
|
|
1533
|
+
return {};
|
|
1534
|
+
const values = {};
|
|
1535
|
+
for (const [id, value] of Object.entries(parsed)) {
|
|
1536
|
+
if (typeof value === "number" && Number.isFinite(value) && value > 0)
|
|
1537
|
+
values[id] = value;
|
|
1538
|
+
}
|
|
1539
|
+
return values;
|
|
1540
|
+
} catch {
|
|
1541
|
+
return {};
|
|
1542
|
+
}
|
|
1543
|
+
};
|
|
1544
|
+
const writeAll = (values) => {
|
|
1545
|
+
try {
|
|
1546
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
1547
|
+
const temporary = `${path}.${process.pid}.tmp`;
|
|
1548
|
+
writeFileSync(temporary, JSON.stringify(values));
|
|
1549
|
+
renameSync(temporary, path);
|
|
1550
|
+
} catch {}
|
|
1551
|
+
};
|
|
1552
|
+
return {
|
|
1553
|
+
read(id) {
|
|
1554
|
+
const stored = storedValues()[id];
|
|
1555
|
+
const memory = held.get(id);
|
|
1556
|
+
if (stored === undefined && memory === undefined)
|
|
1557
|
+
return;
|
|
1558
|
+
return Math.max(stored ?? 0, memory ?? 0);
|
|
1559
|
+
},
|
|
1560
|
+
record(id, value) {
|
|
1561
|
+
if (!Number.isFinite(value) || value <= 0)
|
|
1562
|
+
return;
|
|
1563
|
+
const previous = Math.max(held.get(id) ?? 0, storedValues()[id] ?? 0);
|
|
1564
|
+
if (value <= previous)
|
|
1565
|
+
return;
|
|
1566
|
+
held.set(id, value);
|
|
1567
|
+
const values = storedValues();
|
|
1568
|
+
values[id] = value;
|
|
1569
|
+
writeAll(values);
|
|
1570
|
+
}
|
|
1571
|
+
};
|
|
1572
|
+
}
|
|
1573
|
+
|
|
1524
1574
|
// src/tui/style.ts
|
|
1525
1575
|
var TextAttributes = {
|
|
1526
1576
|
NONE: 0,
|
|
@@ -1598,6 +1648,8 @@ var DEFAULT_GO_PANEL_LOOK = {
|
|
|
1598
1648
|
};
|
|
1599
1649
|
var DEFAULT_TPS_SCOPE = "family";
|
|
1600
1650
|
var DEFAULT_TPS_DISPLAY = "rt";
|
|
1651
|
+
var DEFAULT_TPS_TTFT = true;
|
|
1652
|
+
var DEFAULT_TPS_LABEL = "tok/s";
|
|
1601
1653
|
function cautionThresholds(config) {
|
|
1602
1654
|
return {
|
|
1603
1655
|
toolWatchMs: config.toolWatchSeconds * 1000,
|
|
@@ -1621,7 +1673,8 @@ var DEFAULT_FORMAT = {
|
|
|
1621
1673
|
var DEFAULT_GLYPHS = {
|
|
1622
1674
|
watch: "\u25B2",
|
|
1623
1675
|
caution: "\u25CF",
|
|
1624
|
-
clear: "\u25CB"
|
|
1676
|
+
clear: "\u25CB",
|
|
1677
|
+
paused: "\u2016"
|
|
1625
1678
|
};
|
|
1626
1679
|
var DEFAULT_NOTIFICATIONS = {
|
|
1627
1680
|
enabled: true,
|
|
@@ -1645,7 +1698,7 @@ var DEFAULT_SIDEBAR_ROWS = [
|
|
|
1645
1698
|
"status",
|
|
1646
1699
|
"agent",
|
|
1647
1700
|
"model",
|
|
1648
|
-
"
|
|
1701
|
+
"spend",
|
|
1649
1702
|
"project",
|
|
1650
1703
|
"tokens",
|
|
1651
1704
|
"cache",
|
|
@@ -1665,7 +1718,12 @@ var DEFAULT_CONFIG = {
|
|
|
1665
1718
|
lines: DEFAULT_SIDEBAR_LINES,
|
|
1666
1719
|
footer: { lines: DEFAULT_SIDEBAR_FOOTER_LINES, go: false },
|
|
1667
1720
|
rows: DEFAULT_SIDEBAR_ROWS,
|
|
1668
|
-
tps: {
|
|
1721
|
+
tps: {
|
|
1722
|
+
scope: DEFAULT_TPS_SCOPE,
|
|
1723
|
+
display: DEFAULT_TPS_DISPLAY,
|
|
1724
|
+
label: DEFAULT_TPS_LABEL,
|
|
1725
|
+
ttft: DEFAULT_TPS_TTFT
|
|
1726
|
+
},
|
|
1669
1727
|
persist: true,
|
|
1670
1728
|
placeholder: DEFAULT_PLACEHOLDER,
|
|
1671
1729
|
maxLines: MAX_LINES
|
|
@@ -1677,7 +1735,8 @@ var DEFAULT_CONFIG = {
|
|
|
1677
1735
|
format: DEFAULT_FORMAT,
|
|
1678
1736
|
glyphs: DEFAULT_GLYPHS,
|
|
1679
1737
|
style: DEFAULT_STYLE,
|
|
1680
|
-
refresh: DEFAULT_REFRESH_MS
|
|
1738
|
+
refresh: DEFAULT_REFRESH_MS,
|
|
1739
|
+
lifetimeTotalsPath: defaultLifetimeTotalsPath()
|
|
1681
1740
|
};
|
|
1682
1741
|
var MAX_LINE_LENGTH = 120;
|
|
1683
1742
|
var CONTROL_CHAR = /[\u0000-\u001F\u007F-\u009F]/;
|
|
@@ -1846,7 +1905,13 @@ function readRows(value, issues, maxLines) {
|
|
|
1846
1905
|
issues.push(`${path} is not a known field (${STAT_FIELDS.join(", ")}); skipping it`);
|
|
1847
1906
|
return;
|
|
1848
1907
|
}
|
|
1849
|
-
|
|
1908
|
+
const canonical = canonicalField(name);
|
|
1909
|
+
const duplicateOf = rows.find((entry) => canonicalField(entry) === canonical);
|
|
1910
|
+
if (duplicateOf !== undefined) {
|
|
1911
|
+
issues.push(`${path} duplicates ${duplicateOf}; rendering the row once`);
|
|
1912
|
+
return;
|
|
1913
|
+
}
|
|
1914
|
+
rows.push(name === "session" ? "ses" : name);
|
|
1850
1915
|
});
|
|
1851
1916
|
if (rows.length === 0) {
|
|
1852
1917
|
issues.push("sidebar.rows had no usable entries; using the default rows");
|
|
@@ -1870,14 +1935,46 @@ function readTpsDisplay(value, issues) {
|
|
|
1870
1935
|
issues.push(`sidebar.tps.display must be "avg", "rt" or "both"; using "${DEFAULT_TPS_DISPLAY}"`);
|
|
1871
1936
|
return DEFAULT_TPS_DISPLAY;
|
|
1872
1937
|
}
|
|
1938
|
+
function readTpsTtft(value, issues) {
|
|
1939
|
+
return readBoolean(value, DEFAULT_TPS_TTFT, "sidebar.tps.ttft", issues);
|
|
1940
|
+
}
|
|
1941
|
+
var TPS_LABEL_MAX_LENGTH = 16;
|
|
1942
|
+
function readTpsLabel(value, issues) {
|
|
1943
|
+
if (value === undefined)
|
|
1944
|
+
return DEFAULT_TPS_LABEL;
|
|
1945
|
+
if (typeof value !== "string") {
|
|
1946
|
+
issues.push("sidebar.tps.label must be a string; using the default");
|
|
1947
|
+
return DEFAULT_TPS_LABEL;
|
|
1948
|
+
}
|
|
1949
|
+
const text = normalizeText(value, "sidebar.tps.label", issues);
|
|
1950
|
+
if (text.length === 0) {
|
|
1951
|
+
issues.push("sidebar.tps.label must not be empty; using the default");
|
|
1952
|
+
return DEFAULT_TPS_LABEL;
|
|
1953
|
+
}
|
|
1954
|
+
if (text.length > TPS_LABEL_MAX_LENGTH) {
|
|
1955
|
+
issues.push(`sidebar.tps.label was longer than ${TPS_LABEL_MAX_LENGTH} characters; using the default`);
|
|
1956
|
+
return DEFAULT_TPS_LABEL;
|
|
1957
|
+
}
|
|
1958
|
+
return text;
|
|
1959
|
+
}
|
|
1873
1960
|
function readTps(section, issues) {
|
|
1874
1961
|
const raw = section["tps"];
|
|
1875
1962
|
if (raw !== undefined && !isRecord(raw)) {
|
|
1876
1963
|
issues.push("sidebar.tps must be an object; using defaults");
|
|
1877
|
-
return {
|
|
1964
|
+
return {
|
|
1965
|
+
scope: DEFAULT_TPS_SCOPE,
|
|
1966
|
+
display: DEFAULT_TPS_DISPLAY,
|
|
1967
|
+
label: DEFAULT_TPS_LABEL,
|
|
1968
|
+
ttft: DEFAULT_TPS_TTFT
|
|
1969
|
+
};
|
|
1878
1970
|
}
|
|
1879
1971
|
const tps = isRecord(raw) ? raw : {};
|
|
1880
|
-
return {
|
|
1972
|
+
return {
|
|
1973
|
+
scope: readTpsScope(tps["scope"], issues),
|
|
1974
|
+
display: readTpsDisplay(tps["display"], issues),
|
|
1975
|
+
label: readTpsLabel(tps["label"], issues),
|
|
1976
|
+
ttft: readTpsTtft(tps["ttft"], issues)
|
|
1977
|
+
};
|
|
1881
1978
|
}
|
|
1882
1979
|
function readMaxLines(value, issues) {
|
|
1883
1980
|
return readNumber(value, MAX_LINES, "sidebar.maxLines", issues, 1, MAX_LINES);
|
|
@@ -1886,6 +1983,15 @@ function sectionOf(options, key) {
|
|
|
1886
1983
|
const value = options[key];
|
|
1887
1984
|
return isRecord(value) ? value : {};
|
|
1888
1985
|
}
|
|
1986
|
+
function readLifetimeTotalsPath(value, issues) {
|
|
1987
|
+
if (value === undefined)
|
|
1988
|
+
return DEFAULT_CONFIG.lifetimeTotalsPath;
|
|
1989
|
+
if (typeof value !== "string" || value.trim().length === 0) {
|
|
1990
|
+
issues.push("lifetimeTotalsPath must be a non-empty string; using the default path");
|
|
1991
|
+
return DEFAULT_CONFIG.lifetimeTotalsPath;
|
|
1992
|
+
}
|
|
1993
|
+
return value.trim();
|
|
1994
|
+
}
|
|
1889
1995
|
function readRefresh(value, issues) {
|
|
1890
1996
|
if (value === undefined)
|
|
1891
1997
|
return DEFAULT_REFRESH_MS;
|
|
@@ -2129,7 +2235,8 @@ function readGlyphs(section, issues) {
|
|
|
2129
2235
|
return {
|
|
2130
2236
|
watch: readGlyph(section["watch"], DEFAULT_GLYPHS.watch, "glyphs.watch", issues),
|
|
2131
2237
|
caution: readGlyph(section["caution"], DEFAULT_GLYPHS.caution, "glyphs.caution", issues),
|
|
2132
|
-
clear: readGlyph(section["clear"], DEFAULT_GLYPHS.clear, "glyphs.clear", issues)
|
|
2238
|
+
clear: readGlyph(section["clear"], DEFAULT_GLYPHS.clear, "glyphs.clear", issues),
|
|
2239
|
+
paused: readGlyph(section["paused"], DEFAULT_GLYPHS.paused, "glyphs.paused", issues)
|
|
2133
2240
|
};
|
|
2134
2241
|
}
|
|
2135
2242
|
function readStyleColor(value, fallback, path, issues) {
|
|
@@ -2330,7 +2437,8 @@ function resolveConfig(options) {
|
|
|
2330
2437
|
format: readFormat(format, issues),
|
|
2331
2438
|
glyphs: readGlyphs(glyphs, issues),
|
|
2332
2439
|
style: readStyle(style, issues),
|
|
2333
|
-
refresh: readRefresh(options.refresh, issues)
|
|
2440
|
+
refresh: readRefresh(options.refresh, issues),
|
|
2441
|
+
lifetimeTotalsPath: readLifetimeTotalsPath(options.lifetimeTotalsPath, issues)
|
|
2334
2442
|
},
|
|
2335
2443
|
issues
|
|
2336
2444
|
};
|
|
@@ -2342,19 +2450,19 @@ function shouldNotify(config, kind) {
|
|
|
2342
2450
|
}
|
|
2343
2451
|
|
|
2344
2452
|
// src/tui/file-config.ts
|
|
2345
|
-
import { existsSync, readFileSync, statSync } from "fs";
|
|
2346
|
-
import { homedir } from "os";
|
|
2347
|
-
import { isAbsolute, join } from "path";
|
|
2453
|
+
import { existsSync as existsSync2, readFileSync as readFileSync2, statSync } from "fs";
|
|
2454
|
+
import { homedir as homedir2 } from "os";
|
|
2455
|
+
import { isAbsolute, join as join2 } from "path";
|
|
2348
2456
|
var CONFIG_FILE_CANDIDATES = ["flight-deck.jsonc", "flight-deck.json"];
|
|
2349
2457
|
function globalConfigDirectory() {
|
|
2350
2458
|
const xdg = process.env["XDG_CONFIG_HOME"]?.trim();
|
|
2351
|
-
return xdg !== undefined && xdg.length > 0 && isAbsolute(xdg) ?
|
|
2459
|
+
return xdg !== undefined && xdg.length > 0 && isAbsolute(xdg) ? join2(xdg, "opencode") : join2(homedir2(), ".config", "opencode");
|
|
2352
2460
|
}
|
|
2353
2461
|
var MAX_CONFIG_BYTES = 64 * 1024;
|
|
2354
2462
|
function findConfigFile(directory = globalConfigDirectory()) {
|
|
2355
2463
|
for (const candidate of CONFIG_FILE_CANDIDATES) {
|
|
2356
|
-
const path =
|
|
2357
|
-
if (
|
|
2464
|
+
const path = join2(directory, candidate);
|
|
2465
|
+
if (existsSync2(path))
|
|
2358
2466
|
return path;
|
|
2359
2467
|
}
|
|
2360
2468
|
return;
|
|
@@ -2378,7 +2486,7 @@ function loadConfigFile(directory = globalConfigDirectory()) {
|
|
|
2378
2486
|
const limit = Math.floor(MAX_CONFIG_BYTES / 1024);
|
|
2379
2487
|
return { options: undefined, source, issue: `${source} is larger than ${limit} KiB; using defaults` };
|
|
2380
2488
|
}
|
|
2381
|
-
const text =
|
|
2489
|
+
const text = readFileSync2(source, "utf8");
|
|
2382
2490
|
if (text.trim().length === 0) {
|
|
2383
2491
|
return { options: undefined, source, issue: `${source} is empty; using defaults` };
|
|
2384
2492
|
}
|
|
@@ -2394,12 +2502,12 @@ function loadConfigFile(directory = globalConfigDirectory()) {
|
|
|
2394
2502
|
}
|
|
2395
2503
|
|
|
2396
2504
|
// src/tui/go-look.ts
|
|
2397
|
-
import { existsSync as
|
|
2398
|
-
import { join as
|
|
2505
|
+
import { existsSync as existsSync3, statSync as statSync2 } from "fs";
|
|
2506
|
+
import { join as join3 } from "path";
|
|
2399
2507
|
function findCandidate(directory) {
|
|
2400
2508
|
for (const candidate of CONFIG_FILE_CANDIDATES) {
|
|
2401
|
-
const path =
|
|
2402
|
-
if (
|
|
2509
|
+
const path = join3(directory, candidate);
|
|
2510
|
+
if (existsSync3(path))
|
|
2403
2511
|
return path;
|
|
2404
2512
|
}
|
|
2405
2513
|
return;
|
|
@@ -2468,7 +2576,10 @@ function railLines(config, source = {}) {
|
|
|
2468
2576
|
durationStyle: config.format.duration,
|
|
2469
2577
|
timestamp: config.format.timestamp,
|
|
2470
2578
|
tpsDisplay: config.sidebar.tps.display,
|
|
2471
|
-
|
|
2579
|
+
tpsLabel: config.sidebar.tps.label,
|
|
2580
|
+
tpsTtft: config.sidebar.tps.ttft,
|
|
2581
|
+
pausedGlyph: config.glyphs.paused,
|
|
2582
|
+
hasLifetimeRow: config.sidebar.rows.some((field) => canonicalField(field) === "lifetime")
|
|
2472
2583
|
};
|
|
2473
2584
|
const lines = config.sidebar.lines.map((text) => ({ text }));
|
|
2474
2585
|
for (const field of config.sidebar.rows) {
|
|
@@ -2497,7 +2608,9 @@ function railLineSpans(line, style) {
|
|
|
2497
2608
|
function footerLine(config) {
|
|
2498
2609
|
return config.footer.enabled ? config.footer.text : undefined;
|
|
2499
2610
|
}
|
|
2611
|
+
|
|
2500
2612
|
// src/tui/go-panel.ts
|
|
2613
|
+
var NO_READING = "\u2014";
|
|
2501
2614
|
var PANEL_WINDOWS = ["5h", "1w", "1m"];
|
|
2502
2615
|
var PANEL_DEFAULT_LABELS = {
|
|
2503
2616
|
rolling: "rolling",
|
|
@@ -2699,7 +2812,7 @@ function restingLine(label, look, reason, nowMs, isFirst) {
|
|
|
2699
2812
|
segments.push({ text: `${reason} `, tone: "subdued" });
|
|
2700
2813
|
trackCells = Math.max(0, cells - reason.length - 1);
|
|
2701
2814
|
}
|
|
2702
|
-
const tail = CELL.repeat(trackCells) + (look.showPercent ? ` ${alignCell(
|
|
2815
|
+
const tail = CELL.repeat(trackCells) + (look.showPercent ? ` ${alignCell(NO_READING, PANEL_PERCENT_WIDTH, look.align)}` : "");
|
|
2703
2816
|
segments.push({ text: tail, tone: "subdued" });
|
|
2704
2817
|
return { field: "go", text: segments.map((segment) => segment.text).join(""), segments };
|
|
2705
2818
|
}
|
|
@@ -2718,7 +2831,7 @@ function valueLine(label, look, window, nowMs, frame, isFirst) {
|
|
|
2718
2831
|
appendRun(runs, CELL, "subdued");
|
|
2719
2832
|
}
|
|
2720
2833
|
if (look.showPercent) {
|
|
2721
|
-
const percent = ratio === undefined ?
|
|
2834
|
+
const percent = ratio === undefined ? NO_READING : `${Math.round(ratio * 100)}%`;
|
|
2722
2835
|
appendRun(runs, ` ${alignCell(percent, PANEL_PERCENT_WIDTH, look.align)}`, tone);
|
|
2723
2836
|
}
|
|
2724
2837
|
const segments = [];
|
|
@@ -3000,9 +3113,9 @@ function startGuardBridge(host, deps, intervalMs = GUARD_POLL_MS) {
|
|
|
3000
3113
|
}
|
|
3001
3114
|
|
|
3002
3115
|
// src/tui/go.ts
|
|
3003
|
-
import { appendFileSync, existsSync as
|
|
3116
|
+
import { appendFileSync, existsSync as existsSync4, mkdirSync as mkdirSync2, readFileSync as readFileSync3, writeFileSync as writeFileSync2 } from "fs";
|
|
3004
3117
|
import { tmpdir } from "os";
|
|
3005
|
-
import { join as
|
|
3118
|
+
import { join as join4 } from "path";
|
|
3006
3119
|
var GO_KEY = "flight-deck.go";
|
|
3007
3120
|
var GO_POLL_MS = 60000;
|
|
3008
3121
|
var GO_USAGE_URL = "https://opencode.ai/zen/go/v1/usage";
|
|
@@ -3368,22 +3481,22 @@ function logPoll(entry) {
|
|
|
3368
3481
|
if (!goLogEnabled())
|
|
3369
3482
|
return;
|
|
3370
3483
|
try {
|
|
3371
|
-
const directory =
|
|
3372
|
-
const path =
|
|
3484
|
+
const directory = join4(tmpdir(), GO_LOG_DIR);
|
|
3485
|
+
const path = join4(directory, GO_LOG_FILE);
|
|
3373
3486
|
const line = `ts=${new Date().toISOString()} src=${entry.src} key=${entry.key ? "yes" : "no"} http=${entry.http} parse=${entry.parse} reason=${entry.reason}
|
|
3374
3487
|
`;
|
|
3375
3488
|
let prior = "";
|
|
3376
3489
|
try {
|
|
3377
|
-
if (
|
|
3378
|
-
prior =
|
|
3490
|
+
if (existsSync4(path))
|
|
3491
|
+
prior = readFileSync3(path, "utf8");
|
|
3379
3492
|
} catch {
|
|
3380
3493
|
prior = "";
|
|
3381
3494
|
}
|
|
3382
3495
|
const lines = prior.length === 0 ? 0 : prior.split(`
|
|
3383
3496
|
`).filter((row) => row.length > 0).length;
|
|
3384
|
-
|
|
3497
|
+
mkdirSync2(directory, { recursive: true });
|
|
3385
3498
|
if (lines >= GO_LOG_MAX_LINES)
|
|
3386
|
-
|
|
3499
|
+
writeFileSync2(path, line);
|
|
3387
3500
|
else
|
|
3388
3501
|
appendFileSync(path, line);
|
|
3389
3502
|
} catch {}
|
|
@@ -3526,12 +3639,12 @@ function startGoBridge(host, deps, intervalMs = GO_POLL_MS) {
|
|
|
3526
3639
|
|
|
3527
3640
|
// src/tui/codex-quota.ts
|
|
3528
3641
|
import { spawn } from "child_process";
|
|
3529
|
-
import { existsSync as
|
|
3530
|
-
import { isAbsolute as isAbsolute2, join as
|
|
3642
|
+
import { existsSync as existsSync5, readFileSync as readFileSync4 } from "fs";
|
|
3643
|
+
import { isAbsolute as isAbsolute2, join as join6 } from "path";
|
|
3531
3644
|
import { createInterface } from "readline";
|
|
3532
3645
|
|
|
3533
3646
|
// src/tui/owned-process.ts
|
|
3534
|
-
import { join as
|
|
3647
|
+
import { join as join5 } from "path";
|
|
3535
3648
|
var supervisor = String.raw`
|
|
3536
3649
|
using System;
|
|
3537
3650
|
using System.ComponentModel;
|
|
@@ -3651,7 +3764,7 @@ ${supervisor}
|
|
|
3651
3764
|
$argsList=${decode(JSON.stringify(args))}|ConvertFrom-Json
|
|
3652
3765
|
` + `exit [FlightDeckOwned]::Run($command,[string[]]$argsList,${ownerPid})`;
|
|
3653
3766
|
return {
|
|
3654
|
-
command:
|
|
3767
|
+
command: join5(process.env.SystemRoot ?? "C:\\Windows", "System32", "WindowsPowerShell", "v1.0", "powershell.exe"),
|
|
3655
3768
|
args: ["-NoLogo", "-NoProfile", "-NonInteractive", "-EncodedCommand", Buffer.from(script, "utf16le").toString("base64")]
|
|
3656
3769
|
};
|
|
3657
3770
|
}
|
|
@@ -3683,15 +3796,15 @@ function executable(pathValue = process.env.PATH ?? "") {
|
|
|
3683
3796
|
for (const directory of pathValue.split(process.platform === "win32" ? ";" : ":")) {
|
|
3684
3797
|
if (!isAbsolute2(directory))
|
|
3685
3798
|
continue;
|
|
3686
|
-
const path =
|
|
3687
|
-
if (!
|
|
3799
|
+
const path = join6(directory, process.platform === "win32" ? "codex.exe" : "codex");
|
|
3800
|
+
if (!existsSync5(path))
|
|
3688
3801
|
continue;
|
|
3689
3802
|
if (process.platform === "win32") {
|
|
3690
3803
|
const shim = path.replace(/\.exe$/i, ".shim");
|
|
3691
|
-
if (
|
|
3804
|
+
if (existsSync5(shim)) {
|
|
3692
3805
|
try {
|
|
3693
|
-
const target = /^path\s*=\s*"([^"\r\n]+)"\s*$/m.exec(
|
|
3694
|
-
if (target && isAbsolute2(target) && /[\\/]codex\.exe$/i.test(target) &&
|
|
3806
|
+
const target = /^path\s*=\s*"([^"\r\n]+)"\s*$/m.exec(readFileSync4(shim, "utf8"))?.[1];
|
|
3807
|
+
if (target && isAbsolute2(target) && /[\\/]codex\.exe$/i.test(target) && existsSync5(target))
|
|
3695
3808
|
return target;
|
|
3696
3809
|
} catch {}
|
|
3697
3810
|
return;
|
|
@@ -4327,10 +4440,42 @@ function createSessionReads(context) {
|
|
|
4327
4440
|
return;
|
|
4328
4441
|
}
|
|
4329
4442
|
};
|
|
4443
|
+
const openTurnOf = (sessionID) => {
|
|
4444
|
+
const messages = messagesOf(sessionID);
|
|
4445
|
+
for (let index = messages.length - 1;index >= 0; index -= 1) {
|
|
4446
|
+
const message = asRecord2(messages[index]);
|
|
4447
|
+
const type = asText2(message?.["type"]);
|
|
4448
|
+
if (type !== "user" && type !== "assistant")
|
|
4449
|
+
continue;
|
|
4450
|
+
if (type === "user")
|
|
4451
|
+
return true;
|
|
4452
|
+
return asCount2(asRecord2(message?.["time"])?.["completed"]) === undefined;
|
|
4453
|
+
}
|
|
4454
|
+
return false;
|
|
4455
|
+
};
|
|
4456
|
+
const pausedOf = (sessionID) => {
|
|
4457
|
+
if (permsOf(sessionID) !== undefined)
|
|
4458
|
+
return true;
|
|
4459
|
+
for (const part of recentParts(sessionID)) {
|
|
4460
|
+
const call = readToolCall(part);
|
|
4461
|
+
if (call !== undefined && call.name === "question" && !SETTLED_TOOL.has(call.status))
|
|
4462
|
+
return true;
|
|
4463
|
+
}
|
|
4464
|
+
return false;
|
|
4465
|
+
};
|
|
4330
4466
|
const busy = (sessionID) => {
|
|
4331
4467
|
const status = statusOf(sessionID);
|
|
4332
|
-
|
|
4333
|
-
|
|
4468
|
+
try {
|
|
4469
|
+
for (const part of recentParts(sessionID)) {
|
|
4470
|
+
const call = readToolCall(part);
|
|
4471
|
+
if (call !== undefined && !SETTLED_TOOL.has(call.status))
|
|
4472
|
+
return true;
|
|
4473
|
+
}
|
|
4474
|
+
} catch {}
|
|
4475
|
+
try {
|
|
4476
|
+
if (shellsOf(sessionID).some((entry) => asRecord2(entry)?.["status"] === "running"))
|
|
4477
|
+
return true;
|
|
4478
|
+
} catch {}
|
|
4334
4479
|
try {
|
|
4335
4480
|
for (const id of context.data.session.family(sessionID) ?? []) {
|
|
4336
4481
|
if (id === sessionID)
|
|
@@ -4341,10 +4486,8 @@ function createSessionReads(context) {
|
|
|
4341
4486
|
} catch {}
|
|
4342
4487
|
}
|
|
4343
4488
|
} catch {}
|
|
4344
|
-
|
|
4345
|
-
|
|
4346
|
-
return true;
|
|
4347
|
-
} catch {}
|
|
4489
|
+
if (openTurnOf(sessionID))
|
|
4490
|
+
return true;
|
|
4348
4491
|
return status === undefined ? undefined : false;
|
|
4349
4492
|
};
|
|
4350
4493
|
const spansOf = (sessionID, now) => {
|
|
@@ -4408,6 +4551,8 @@ function createSessionReads(context) {
|
|
|
4408
4551
|
shellsOf,
|
|
4409
4552
|
lastActivity,
|
|
4410
4553
|
permsOf,
|
|
4554
|
+
openTurnOf,
|
|
4555
|
+
pausedOf,
|
|
4411
4556
|
busy
|
|
4412
4557
|
};
|
|
4413
4558
|
}
|
|
@@ -4568,7 +4713,7 @@ var tui_default = Plugin.define({
|
|
|
4568
4713
|
setup(context) {
|
|
4569
4714
|
const file = loadConfigFile();
|
|
4570
4715
|
const { config, issues } = resolveConfig(mergeOptions(file.options, context.options));
|
|
4571
|
-
const rows = config.sidebar.enabled ? new Set(config.sidebar.rows) : new Set;
|
|
4716
|
+
const rows = config.sidebar.enabled ? new Set(config.sidebar.rows.map(canonicalField)) : new Set;
|
|
4572
4717
|
const wants = (name) => rows.has(name);
|
|
4573
4718
|
if (file.issue !== undefined && file.source !== undefined) {
|
|
4574
4719
|
console.warn(`[flight-deck] ${file.issue}`);
|
|
@@ -4633,15 +4778,19 @@ var tui_default = Plugin.define({
|
|
|
4633
4778
|
shellsOf,
|
|
4634
4779
|
lastActivity,
|
|
4635
4780
|
permsOf,
|
|
4781
|
+
openTurnOf,
|
|
4782
|
+
pausedOf,
|
|
4636
4783
|
busy
|
|
4637
4784
|
} = reads;
|
|
4638
4785
|
const { projectTotals } = createProjectTotals(context);
|
|
4786
|
+
const lifetimeTotals = createLifetimeTotals({ path: config.lifetimeTotalsPath });
|
|
4639
4787
|
const cautionThreshold = cautionThresholds(config.caution);
|
|
4640
4788
|
const cautionsOf = (sessionID, now) => detectCautions({
|
|
4641
4789
|
parts: recentParts(sessionID),
|
|
4642
4790
|
shells: shellsOf(sessionID),
|
|
4643
4791
|
now,
|
|
4644
4792
|
sessionRunning: statusOf(sessionID) === "running",
|
|
4793
|
+
openTurn: openTurnOf(sessionID),
|
|
4645
4794
|
lastMessageAt: lastActivity(sessionID),
|
|
4646
4795
|
thresholds: cautionThreshold
|
|
4647
4796
|
});
|
|
@@ -4691,11 +4840,30 @@ var tui_default = Plugin.define({
|
|
|
4691
4840
|
const location = locationOf(context);
|
|
4692
4841
|
const session = context.data.session.get(sessionID);
|
|
4693
4842
|
const isBusy = busy(sessionID);
|
|
4694
|
-
|
|
4843
|
+
const paused = wants("status") ? pausedOf(sessionID) : false;
|
|
4844
|
+
spinnerNeeded = wants("status") && isBusy === true && !paused;
|
|
4695
4845
|
const turns = wants("turns") ? messagesOf(sessionID).filter((entry) => asRecord2(entry)?.["type"] === "user").length : undefined;
|
|
4696
|
-
const wantsUsage = wants("
|
|
4846
|
+
const wantsUsage = wants("spend") || wants("lifetime") || wants("tokens") || wants("cache") || wants("reasoning");
|
|
4697
4847
|
const ownCost = wantsUsage ? sessionCost(sessionID, session) : undefined;
|
|
4698
4848
|
const tree = wantsUsage ? treeTotals(sessionID) : undefined;
|
|
4849
|
+
let lifetime;
|
|
4850
|
+
if (wantsUsage) {
|
|
4851
|
+
let root = sessionID;
|
|
4852
|
+
try {
|
|
4853
|
+
root = context.data.session.root(sessionID) ?? sessionID;
|
|
4854
|
+
} catch {
|
|
4855
|
+
root = sessionID;
|
|
4856
|
+
}
|
|
4857
|
+
const stored = lifetimeTotals.read(root);
|
|
4858
|
+
const live = tree?.cost;
|
|
4859
|
+
if (live !== undefined && (stored === undefined || live > stored)) {
|
|
4860
|
+
lifetimeTotals.record(root, live);
|
|
4861
|
+
}
|
|
4862
|
+
const high = Math.max(live ?? 0, stored ?? 0);
|
|
4863
|
+
if (live !== undefined || stored !== undefined) {
|
|
4864
|
+
lifetime = { cost: high, count: tree?.count ?? 0, kind: tree?.kind ?? "bounded" };
|
|
4865
|
+
}
|
|
4866
|
+
}
|
|
4699
4867
|
return {
|
|
4700
4868
|
...session,
|
|
4701
4869
|
cost: ownCost?.cost,
|
|
@@ -4704,10 +4872,12 @@ var tui_default = Plugin.define({
|
|
|
4704
4872
|
caution: wants("caution") ? announce(sessionID) : undefined,
|
|
4705
4873
|
branch: wants("branch") ? branchOf(location) : undefined,
|
|
4706
4874
|
tree,
|
|
4875
|
+
lifetime,
|
|
4707
4876
|
context: wants("context") ? contextUsage(sessionID, session?.model) : undefined,
|
|
4708
4877
|
project: wants("project") ? projectTotals(sessionID) : undefined,
|
|
4709
4878
|
status: wants("status") ? statusOf(sessionID) : undefined,
|
|
4710
4879
|
busy: isBusy,
|
|
4880
|
+
paused,
|
|
4711
4881
|
perms: wants("perms") ? permsOf(sessionID) : undefined,
|
|
4712
4882
|
tps: wants("tps") ? sessionTps(sessionID, session) : undefined,
|
|
4713
4883
|
spark: wants("spark") ? sparkValues(sessionID) : undefined,
|