oc-flight-deck 0.6.6 → 0.7.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/README.md +9 -6
- package/flight-deck.example.jsonc +16 -7
- package/flight-deck.schema.json +5 -5
- package/package.json +1 -1
- package/src/tui/active-elapsed.ts +32 -5
- package/src/tui/config.ts +7 -6
- package/src/tui/go-usage.ts +315 -0
- package/src/tui/go.ts +266 -0
- package/src/tui/index.tsx +25 -6
- package/src/tui/presentation.ts +47 -2
- package/src/tui/rows.ts +168 -1
- package/src/tui/session-reads.ts +52 -1
- package/src/tui/stat-fields.ts +15 -0
- package/src/tui/stats.ts +10 -2
- package/src/tui/throughput.ts +62 -21
package/src/tui/stat-fields.ts
CHANGED
|
@@ -46,6 +46,12 @@ export interface StatSource {
|
|
|
46
46
|
readonly frame?: unknown;
|
|
47
47
|
/** Harness status from oc-harness-guard's RPC, via the guard bridge. Untrusted. */
|
|
48
48
|
readonly guard?: unknown;
|
|
49
|
+
/**
|
|
50
|
+
* Zen Go account usage, read from the go bridge's host store. Untrusted on
|
|
51
|
+
* principle: the row re-validates the window shape rather than trusting the
|
|
52
|
+
* type across the module boundary.
|
|
53
|
+
*/
|
|
54
|
+
readonly go?: unknown;
|
|
49
55
|
}
|
|
50
56
|
|
|
51
57
|
/** Fields a user may name in `sidebar.rows`, in the order they are documented. */
|
|
@@ -68,6 +74,7 @@ export const STAT_FIELDS = [
|
|
|
68
74
|
"reasoning",
|
|
69
75
|
"turns",
|
|
70
76
|
"guard",
|
|
77
|
+
"go",
|
|
71
78
|
] as const;
|
|
72
79
|
|
|
73
80
|
type StatField = (typeof STAT_FIELDS)[number];
|
|
@@ -122,6 +129,14 @@ export interface LayoutHint {
|
|
|
122
129
|
readonly persist?: boolean;
|
|
123
130
|
/** Value shown for a row with no data when `persist` is on. Default `"—"`. */
|
|
124
131
|
readonly placeholder?: string;
|
|
132
|
+
/**
|
|
133
|
+
* The clock the `go` row reads its relative reset hint against.
|
|
134
|
+
*
|
|
135
|
+
* An explicit instant rather than a hidden `Date.now()` inside the renderer,
|
|
136
|
+
* so a flagged window's "resets in 41m" is a pure function of its inputs and
|
|
137
|
+
* the row stays testable without freezing time. Absent means `Date.now()`.
|
|
138
|
+
*/
|
|
139
|
+
readonly nowMs?: number;
|
|
125
140
|
}
|
|
126
141
|
|
|
127
142
|
/** Placeholder value for a persistent row with no data yet. */
|
package/src/tui/stats.ts
CHANGED
|
@@ -11,8 +11,16 @@
|
|
|
11
11
|
// public surface it has always had.
|
|
12
12
|
|
|
13
13
|
export { clip, formatCost, formatCount, formatDuration, fuelBar, sparkline } from "./format.js";
|
|
14
|
-
export { statLine, statRows } from "./rows.js";
|
|
14
|
+
export { statLine, statRows, statSegments } from "./rows.js";
|
|
15
|
+
export type { StatSegment } from "./rows.js";
|
|
15
16
|
export { ANIMATED_FIELDS, DEFAULT_PLACEHOLDER, STAT_FIELDS, isStatField } from "./stat-fields.js";
|
|
16
17
|
export type { StatSource } from "./stat-fields.js";
|
|
17
|
-
export {
|
|
18
|
+
export {
|
|
19
|
+
sessionThroughput,
|
|
20
|
+
turnKey,
|
|
21
|
+
turnSpan,
|
|
22
|
+
unionSpanMs,
|
|
23
|
+
unionSpanThroughput,
|
|
24
|
+
unionSpanTotals,
|
|
25
|
+
} from "./throughput.js";
|
|
18
26
|
export type { SpanTotals, ThroughputSpan } from "./throughput.js";
|
package/src/tui/throughput.ts
CHANGED
|
@@ -82,6 +82,41 @@ export interface SpanTotals {
|
|
|
82
82
|
readonly unionMs: number;
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
+
/**
|
|
86
|
+
* The merged length of already-accepted spans.
|
|
87
|
+
*
|
|
88
|
+
* The shared second half of both unions: it pre-sorts so the result cannot
|
|
89
|
+
* depend on the order the host returned the spans, then merges overlapping and
|
|
90
|
+
* touching spans (`next.start <= openEnd`, so a span that starts exactly when
|
|
91
|
+
* another ends is continuous work) into one. `0` when nothing was accepted.
|
|
92
|
+
*/
|
|
93
|
+
function mergedSpanMs(accepted: Array<{ start: number; end: number }>): number {
|
|
94
|
+
// Pre-sort so the merge cannot depend on the order the host returned them.
|
|
95
|
+
accepted.sort((a, b) => a.start - b.start || a.end - b.end);
|
|
96
|
+
const first = accepted[0];
|
|
97
|
+
if (first === undefined) return 0;
|
|
98
|
+
|
|
99
|
+
let unionMs = 0;
|
|
100
|
+
let openStart = first.start;
|
|
101
|
+
let openEnd = first.end;
|
|
102
|
+
for (let index = 1; index < accepted.length; index += 1) {
|
|
103
|
+
const next = accepted[index];
|
|
104
|
+
if (next === undefined) continue;
|
|
105
|
+
// Touching spans (`next.start === openEnd`) merge as well as overlapping
|
|
106
|
+
// ones: a turn that starts exactly when another ends is continuous work.
|
|
107
|
+
if (next.start <= openEnd) {
|
|
108
|
+
if (next.end > openEnd) openEnd = next.end;
|
|
109
|
+
} else {
|
|
110
|
+
unionMs += openEnd - openStart;
|
|
111
|
+
openStart = next.start;
|
|
112
|
+
openEnd = next.end;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
unionMs += openEnd - openStart;
|
|
116
|
+
|
|
117
|
+
return unionMs;
|
|
118
|
+
}
|
|
119
|
+
|
|
85
120
|
/**
|
|
86
121
|
* Sum the tokens of distinct turns and the union length of their spans.
|
|
87
122
|
*
|
|
@@ -112,30 +147,36 @@ export function unionSpanTotals(spans: readonly ThroughputSpan[]): SpanTotals {
|
|
|
112
147
|
tokens += output;
|
|
113
148
|
}
|
|
114
149
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
const first = accepted[0];
|
|
118
|
-
if (first === undefined) return { tokens, unionMs: 0 };
|
|
150
|
+
return { tokens, unionMs: mergedSpanMs(accepted) };
|
|
151
|
+
}
|
|
119
152
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
153
|
+
/**
|
|
154
|
+
* The union length of distinct turn spans, with tokens ignored entirely.
|
|
155
|
+
*
|
|
156
|
+
* The same identity rule, clamp, pre-sort and merge as `unionSpanTotals`, but
|
|
157
|
+
* a turn's output count never enters the decision: a zero-output turn still
|
|
158
|
+
* took wall time and still contributes its span. This is what seeds `elapsed`,
|
|
159
|
+
* which must not undercount real work the way a token-gated union would.
|
|
160
|
+
* A missing key is skipped; the first-seen key wins; a span without a usable
|
|
161
|
+
* start and end is skipped; `0` when nothing is usable.
|
|
162
|
+
*/
|
|
163
|
+
export function unionSpanMs(spans: readonly ThroughputSpan[]): number {
|
|
164
|
+
const seen = new Set<string>();
|
|
165
|
+
const accepted: Array<{ start: number; end: number }> = [];
|
|
166
|
+
|
|
167
|
+
for (const span of spans) {
|
|
168
|
+
const key = asText(span.key);
|
|
169
|
+
if (key === undefined || seen.has(key)) continue;
|
|
170
|
+
|
|
171
|
+
const start = asCount(span.start);
|
|
172
|
+
const end = asCount(span.end);
|
|
173
|
+
if (start === undefined || end === undefined) continue;
|
|
174
|
+
|
|
175
|
+
seen.add(key);
|
|
176
|
+
accepted.push({ start, end: Math.max(start, end) });
|
|
135
177
|
}
|
|
136
|
-
unionMs += openEnd - openStart;
|
|
137
178
|
|
|
138
|
-
return
|
|
179
|
+
return mergedSpanMs(accepted);
|
|
139
180
|
}
|
|
140
181
|
|
|
141
182
|
/**
|