oc-flight-deck 0.23.0 → 0.24.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 +10 -1
- package/dist/tui/index.js +20 -31
- package/docs/GUIDE.md +3 -3
- package/flight-deck.example.jsonc +10 -14
- package/flight-deck.schema.json +5 -5
- package/package.json +2 -2
- package/src/tui/config.ts +3 -10
- package/src/tui/go-panel.ts +2 -33
- package/src/tui/go-usage.ts +12 -5
- package/src/tui/rows.ts +7 -4
- package/src/tui/stat-fields.ts +4 -6
package/CHANGELOG.md
CHANGED
|
@@ -7,12 +7,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
-
## [0.
|
|
10
|
+
## [0.24.0] - 2026-11-17
|
|
11
11
|
|
|
12
12
|
### Added
|
|
13
13
|
|
|
14
14
|
- Opt-in `dex` sidebar row: compact 5h and 1w Codex account dials match the Go row. Windows uses a private authenticated stdio server enclosed in an owned Job Object; no shared daemon, OAuth credential-file access or process-tree kills.
|
|
15
15
|
|
|
16
|
+
### Changed
|
|
17
|
+
|
|
18
|
+
- The TPS row defaults to the realtime estimate and includes observed time to first token when available. The settled-turn average remains opt-in.
|
|
19
|
+
- Missing TPS uses the configured placeholder instead of a misleading zero; observed TTFT remains visible between streams.
|
|
20
|
+
|
|
21
|
+
### Fixed
|
|
22
|
+
|
|
23
|
+
- The compact Go row shows reset countdowns with the same two-unit precision as the Go panel instead of rounding hours or days up to a single unit.
|
|
24
|
+
|
|
16
25
|
## [0.22.0] - 2026-11-10
|
|
17
26
|
|
|
18
27
|
### Changed
|
package/dist/tui/index.js
CHANGED
|
@@ -645,10 +645,16 @@ function formatRemaining(ms) {
|
|
|
645
645
|
const minutes = Math.ceil(ms / 60000);
|
|
646
646
|
if (minutes < 60)
|
|
647
647
|
return `${minutes}m`;
|
|
648
|
-
const hours = Math.
|
|
649
|
-
if (hours < 24)
|
|
650
|
-
|
|
651
|
-
|
|
648
|
+
const hours = Math.floor(ms / 3600000);
|
|
649
|
+
if (hours < 24) {
|
|
650
|
+
if (hours === 0)
|
|
651
|
+
return `${minutes}m`;
|
|
652
|
+
const rest = Math.floor((ms - hours * 3600000) / 60000);
|
|
653
|
+
return rest > 0 ? `${hours}h${rest}m` : `${hours}h`;
|
|
654
|
+
}
|
|
655
|
+
const days = Math.floor(ms / 86400000);
|
|
656
|
+
const rest = Math.floor((ms - days * 86400000) / 3600000);
|
|
657
|
+
return rest > 0 ? `${days}d${rest}h` : `${days}d`;
|
|
652
658
|
}
|
|
653
659
|
function goResetSuffix(window, nowMs) {
|
|
654
660
|
if (goTone(window) !== "error")
|
|
@@ -767,7 +773,7 @@ function skeletonValue(field, layout) {
|
|
|
767
773
|
case "elapsed":
|
|
768
774
|
return formatDuration(0, layout.durationStyle);
|
|
769
775
|
case "tps":
|
|
770
|
-
return
|
|
776
|
+
return;
|
|
771
777
|
case "spark":
|
|
772
778
|
return "\u2581".repeat(Math.max(0, Math.floor(layout.sparkWidth ?? DEFAULT_SPARK_WIDTH)));
|
|
773
779
|
case "reasoning":
|
|
@@ -1057,12 +1063,14 @@ function statLine(field, source, layout = {}) {
|
|
|
1057
1063
|
const rt = asCount2(pair?.["rt"]);
|
|
1058
1064
|
const avg = asCount2(pair?.["avg"]);
|
|
1059
1065
|
const ttft = asCount2(pair?.["ttft"]);
|
|
1060
|
-
const display = layout.tpsDisplay ?? "
|
|
1066
|
+
const display = layout.tpsDisplay ?? "rt";
|
|
1061
1067
|
if (display === "rt") {
|
|
1062
1068
|
const rounded = rt === undefined ? undefined : Math.round(rt);
|
|
1063
|
-
if (rounded === undefined || rounded <= 0)
|
|
1064
|
-
return;
|
|
1065
|
-
|
|
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`);
|
|
1066
1074
|
}
|
|
1067
1075
|
if (display === "both") {
|
|
1068
1076
|
if (avg !== undefined) {
|
|
@@ -1589,7 +1597,7 @@ var DEFAULT_GO_PANEL_LOOK = {
|
|
|
1589
1597
|
blinkMs: 700
|
|
1590
1598
|
};
|
|
1591
1599
|
var DEFAULT_TPS_SCOPE = "family";
|
|
1592
|
-
var DEFAULT_TPS_DISPLAY = "
|
|
1600
|
+
var DEFAULT_TPS_DISPLAY = "rt";
|
|
1593
1601
|
function cautionThresholds(config) {
|
|
1594
1602
|
return {
|
|
1595
1603
|
toolWatchMs: config.toolWatchSeconds * 1000,
|
|
@@ -1859,7 +1867,7 @@ function readTpsDisplay(value, issues) {
|
|
|
1859
1867
|
return DEFAULT_TPS_DISPLAY;
|
|
1860
1868
|
if (value === "avg" || value === "rt" || value === "both")
|
|
1861
1869
|
return value;
|
|
1862
|
-
issues.push(`sidebar.tps.display must be "avg", "rt" or "both"; using "
|
|
1870
|
+
issues.push(`sidebar.tps.display must be "avg", "rt" or "both"; using "${DEFAULT_TPS_DISPLAY}"`);
|
|
1863
1871
|
return DEFAULT_TPS_DISPLAY;
|
|
1864
1872
|
}
|
|
1865
1873
|
function readTps(section, issues) {
|
|
@@ -2489,7 +2497,6 @@ function railLineSpans(line, style) {
|
|
|
2489
2497
|
function footerLine(config) {
|
|
2490
2498
|
return config.footer.enabled ? config.footer.text : undefined;
|
|
2491
2499
|
}
|
|
2492
|
-
|
|
2493
2500
|
// src/tui/go-panel.ts
|
|
2494
2501
|
var PANEL_WINDOWS = ["5h", "1w", "1m"];
|
|
2495
2502
|
var PANEL_DEFAULT_LABELS = {
|
|
@@ -2628,24 +2635,6 @@ function windowById(usage) {
|
|
|
2628
2635
|
}
|
|
2629
2636
|
return byId;
|
|
2630
2637
|
}
|
|
2631
|
-
function formatCompactRemaining(ms) {
|
|
2632
|
-
const totalSeconds = Math.ceil(ms / 1000);
|
|
2633
|
-
if (totalSeconds < 60)
|
|
2634
|
-
return `${totalSeconds}s`;
|
|
2635
|
-
const totalMinutes = Math.ceil(ms / 60000);
|
|
2636
|
-
if (totalMinutes < 60)
|
|
2637
|
-
return `${totalMinutes}m`;
|
|
2638
|
-
const totalHours = Math.floor(ms / 3600000);
|
|
2639
|
-
if (totalHours < 24) {
|
|
2640
|
-
if (totalHours === 0)
|
|
2641
|
-
return `${totalMinutes}m`;
|
|
2642
|
-
const minutes = Math.floor((ms - totalHours * 3600000) / 60000);
|
|
2643
|
-
return minutes > 0 ? `${totalHours}h${minutes}m` : `${totalHours}h`;
|
|
2644
|
-
}
|
|
2645
|
-
const totalDays = Math.floor(ms / 86400000);
|
|
2646
|
-
const hours = Math.floor((ms - totalDays * 86400000) / 3600000);
|
|
2647
|
-
return hours > 0 ? `${totalDays}d${hours}h` : `${totalDays}d`;
|
|
2648
|
-
}
|
|
2649
2638
|
function resetCountdown(window, nowMs) {
|
|
2650
2639
|
const resetAtMs = window.resetAtMs;
|
|
2651
2640
|
if (resetAtMs === undefined || !Number.isFinite(resetAtMs) || !Number.isFinite(nowMs))
|
|
@@ -2653,7 +2642,7 @@ function resetCountdown(window, nowMs) {
|
|
|
2653
2642
|
const remaining = resetAtMs - nowMs;
|
|
2654
2643
|
if (remaining <= 0)
|
|
2655
2644
|
return;
|
|
2656
|
-
return
|
|
2645
|
+
return formatRemaining(remaining);
|
|
2657
2646
|
}
|
|
2658
2647
|
function panelTone(window) {
|
|
2659
2648
|
if (goTone(window) === "error")
|
package/docs/GUIDE.md
CHANGED
|
@@ -98,7 +98,7 @@ One global file: `~/.config/opencode/flight-deck.jsonc`. The `.json` name is als
|
|
|
98
98
|
| **`sidebar.placeholder`** | `"—"` | Non-empty string; only for a data-less row with no skeleton. `caution` never draws it, and `updated` draws it until the host records an action. |
|
|
99
99
|
| **`sidebar.maxLines`** | `24` | Whole rail, fixed lines plus rows, 1–24. |
|
|
100
100
|
| **`sidebar.tps.scope`** | `"family"` | `"family"` paces the open session plus subagents; `"session"` paces the open session alone. |
|
|
101
|
-
| **`sidebar.tps.display`** | `"
|
|
101
|
+
| **`sidebar.tps.display`** | `"rt"` | `"rt"` estimated realtime throughput plus observed TTFT, `"avg"` settled-turn average, `"both"` both figures plus TTFT. |
|
|
102
102
|
|
|
103
103
|
**Footer**
|
|
104
104
|
|
|
@@ -184,7 +184,7 @@ Every name `sidebar.rows` accepts, what its number means, and whether it draws b
|
|
|
184
184
|
| `perms` | Pending approvals. One names the action plus an 18-cell clipped resource (`bash · src/tui…`); several lead with the count (`3 waiting · bash`). | yes |
|
|
185
185
|
| `elapsed` | Active generation time, recomputed from the assistant-turn spans the host recorded for this session and its subagents. Survives a restart, never steps backwards while the host reports those turns, and is not wall-clock since the session began. | yes |
|
|
186
186
|
| `updated` | Absolute timestamp of the newest action the host recorded: the latest message's `completed`, else `streamed`, else `created` stamp. The host locale and time zone apply by default; `format.timestamp` sets the locale, date and time styles, the 12/24-hour clock, and an IANA zone or UTC offset. A Windows zone id is rejected and the host zone is used. | opt-in |
|
|
187
|
-
| `tps` | Session speed. Default `
|
|
187
|
+
| `tps` | Session speed. Default `rt`: estimated realtime throughput from streaming delta bytes and observed mean TTFT after steps settle; TTFT remains visible when no rate is available. `avg` selects the settled-turn average; `both` shows both rates. Scope `family` includes subagents; `session` covers the open session. With neither a rate nor TTFT, `persist: true` draws the placeholder and `persist: false` omits the row. | yes |
|
|
188
188
|
| `spark` | Recent turn sizes as a sparkline; the newest samples are kept. | opt-in |
|
|
189
189
|
| `reasoning` | Reasoning tokens, family scope. | opt-in |
|
|
190
190
|
| `turns` | Prompts sent this session. | opt-in |
|
|
@@ -194,7 +194,7 @@ Every name `sidebar.rows` accepts, what its number means, and whether it draws b
|
|
|
194
194
|
| `ses` | Clipped 18-cell preview of the session id (less when the label column is narrow, floored at 8), labelled `session`. Click copies the full id. A verified copy is silent: the host write reports `written`, or an exact clipboard read-back confirms an OSC52 dispatch. An unconfirmed dispatch is an advisory warning (paste to verify). Gate the failure toast with `notifications.copy`. | opt-in |
|
|
195
195
|
| `session` | Alias for `ses`; accepted in `sidebar.rows` and folded to it. | opt-in |
|
|
196
196
|
|
|
197
|
-
With `sidebar.persist` (the default)
|
|
197
|
+
With `sidebar.persist` (the default) named rows render even without data. Most draw a zero skeleton: `$0.000` money rows, `0 in · 0 out`, `0 read`, empty gauge plus `~0%`, `0 waiting`, `0s`, flat `▁` spark, `0` reasoning and turns, `○ 0 ○ 0 ○ 0` go, `○ idle`, `none` agent, model, and ses, `no branch`, `unknown` guard. `caution` stays silent; `tps` and `updated` draw `sidebar.placeholder` (`—`) when unavailable. Set `persist: false` to omit rows with no data instead.
|
|
198
198
|
|
|
199
199
|
### Recipes
|
|
200
200
|
|
|
@@ -181,11 +181,8 @@
|
|
|
181
181
|
//
|
|
182
182
|
// Every named row renders persistently, so the rail keeps a stable shape:
|
|
183
183
|
// a row with no data yet draws a real-looking zero — `$0.000` for money
|
|
184
|
-
// rows
|
|
185
|
-
//
|
|
186
|
-
// exceptions: `caution` stays silent until it has something to say, and
|
|
187
|
-
// `updated` draws `sidebar.placeholder` (`—`) until the host records an
|
|
188
|
-
// action, because there is no honest zero timestamp.
|
|
184
|
+
// rows and `0 in · 0 out` for tokens. `caution` stays silent; `tps` and
|
|
185
|
+
// `updated` draw `sidebar.placeholder` (`—`) when data is unavailable.
|
|
189
186
|
// The fixed lines and live rows share the maxLines budget below, and
|
|
190
187
|
// anything past it is dropped.
|
|
191
188
|
"rows": [
|
|
@@ -219,33 +216,32 @@
|
|
|
219
216
|
// while it is idle even when a child is still running). An unknown value
|
|
220
217
|
// falls back to `"family"` and is reported.
|
|
221
218
|
//
|
|
222
|
-
// `"display"` is what draws. `"avg"`
|
|
219
|
+
// `"display"` is what draws. `"avg"` is the settled-turn
|
|
223
220
|
// average: generation tokens over assistant turns that recorded
|
|
224
221
|
// `streamed`, divided by the union of their `streamed - created` spans —
|
|
225
222
|
// in-flight turns excluded, idle gaps never billed. `"rt"` is the
|
|
226
|
-
// realtime estimate from the host's streaming delta events
|
|
227
|
-
//
|
|
228
|
-
// or before the first delta). `"both"` draws both on one line
|
|
223
|
+
// realtime estimate (the default) from the host's streaming delta events.
|
|
224
|
+
// Without a rate, observed TTFT remains visible. `"both"` draws both on one line
|
|
229
225
|
// (`106 rt · 41 avg`), plus the mean time to first token over settled
|
|
230
226
|
// steps (`83 rt · 38 avg · 1.2s ttft`): per step, the earliest
|
|
231
227
|
// text/reasoning delta's event time minus the step's `started` dispatch
|
|
232
228
|
// stamp (request dispatch time, before waiting for provider output),
|
|
233
229
|
// pushed into the scope's ring when the step ends. The mean covers the
|
|
234
230
|
// most recent finalized steps observed while the plugin ran — in-memory,
|
|
235
|
-
// so a restart forgets them.
|
|
231
|
+
// so a restart forgets them. `rt` also shows TTFT when available.
|
|
232
|
+
// An unknown value falls back to `"rt"` and
|
|
236
233
|
// is reported.
|
|
237
|
-
"tps": { "scope": "family", "display": "
|
|
234
|
+
"tps": { "scope": "family", "display": "rt" },
|
|
238
235
|
|
|
239
236
|
// Every named row renders persistently: with no data yet it draws its
|
|
240
|
-
// zero skeleton
|
|
237
|
+
// zero skeleton or placeholder, in the
|
|
241
238
|
// same label column as a live row. Set to false to omit rows with no data
|
|
242
239
|
// instead.
|
|
243
240
|
"persist": true,
|
|
244
241
|
|
|
245
242
|
// Fallback for a persistent row with no data that has no skeleton. Any
|
|
246
243
|
// non-empty string. `caution` never draws it (its silence is the design),
|
|
247
|
-
// and `updated`
|
|
248
|
-
// honest zero timestamp, so this dash is reachable for that one row.
|
|
244
|
+
// and `tps` and `updated` draw it until data is available.
|
|
249
245
|
"placeholder": "—",
|
|
250
246
|
|
|
251
247
|
// Maximum total height, including fixed lines and live rows. Defaults to 24.
|
package/flight-deck.schema.json
CHANGED
|
@@ -153,8 +153,8 @@
|
|
|
153
153
|
"tps": {
|
|
154
154
|
"type": "object",
|
|
155
155
|
"additionalProperties": false,
|
|
156
|
-
"default": { "scope": "family", "display": "
|
|
157
|
-
"description": "The `tps` row: which sessions it paces (`scope`) and which figure it draws (`display`).
|
|
156
|
+
"default": { "scope": "family", "display": "rt" },
|
|
157
|
+
"description": "The `tps` row: which sessions it paces (`scope`) and which figure it draws (`display`). When selected it shows the settled-turn average over the whole family: on hosts that record turn timestamps, generation tokens (output plus reasoning) over assistant turns that recorded `streamed`, divided by the union of their `streamed − created` spans — in-flight turns excluded, idle gaps never billed; on hosts without turn timestamps, generation tokens over the borrowed active clock instead. `display: \"rt\"` draws the realtime figure from the host's streaming events instead — an estimate from delta bytes while a turn streams, reading zero while nothing generates; `\"both\"` draws both figures on one line, plus the mean time to first token over settled steps (`1.2s ttft`) — per step, the earliest delta's event time minus the step's `started` dispatch stamp, pushed into the scope's ring when the step ends and kept in memory for the plugin's lifetime.",
|
|
158
158
|
"properties": {
|
|
159
159
|
"scope": {
|
|
160
160
|
"type": "string",
|
|
@@ -165,15 +165,15 @@
|
|
|
165
165
|
"display": {
|
|
166
166
|
"type": "string",
|
|
167
167
|
"enum": ["avg", "rt", "both"],
|
|
168
|
-
"default": "
|
|
169
|
-
"description": "Which figure the `tps` row draws. `avg`
|
|
168
|
+
"default": "rt",
|
|
169
|
+
"description": "Which figure the `tps` row draws. `avg` is the settled-turn average: on hosts that record turn timestamps, generation tokens over assistant turns with `streamed` recorded, divided by the union of their `streamed - created` spans, in the row's scope; on hosts without them, generation tokens over the borrowed active clock. `rt` is the realtime figure from the host's streaming events — an estimate from delta bytes while a turn streams, reading zero while nothing generates. `both` draws `rt` and `avg` on one line (`106 rt · 41 avg`), plus the mean time to first token over settled steps (`83 rt · 38 avg · 1.2s ttft`): per step, the earliest text/reasoning delta's event time minus the step's `started` dispatch stamp (request dispatch time, before waiting for provider output), pushed into the scope's ring when the step ends — the mean covers the most recent finalized steps observed while the plugin ran (in-memory; a restart forgets them). An unknown value falls back to `rt` and is reported."
|
|
170
170
|
}
|
|
171
171
|
}
|
|
172
172
|
},
|
|
173
173
|
"persist": {
|
|
174
174
|
"type": "boolean",
|
|
175
175
|
"default": true,
|
|
176
|
-
"description": "Render
|
|
176
|
+
"description": "Render named fields persistently. Most show zero skeletons before data arrives; `tps` and `updated` use `sidebar.placeholder` when unavailable, while `caution` stays silent. False omits fields without data."
|
|
177
177
|
},
|
|
178
178
|
"placeholder": {
|
|
179
179
|
"type": "string",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oc-flight-deck",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.24.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",
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"@types/bun": "^1.4.4",
|
|
70
70
|
"solid-js": "1.9.18",
|
|
71
71
|
"string-width": "7.2.0",
|
|
72
|
-
"typescript": "^
|
|
72
|
+
"typescript": "^7.0.2"
|
|
73
73
|
},
|
|
74
74
|
"peerDependencies": {
|
|
75
75
|
"@opentui/core": ">=0.8.0",
|
package/src/tui/config.ts
CHANGED
|
@@ -153,16 +153,9 @@ export type TpsDisplay = "avg" | "rt" | "both";
|
|
|
153
153
|
export const DEFAULT_TPS_SCOPE: TpsScope = "family";
|
|
154
154
|
|
|
155
155
|
/**
|
|
156
|
-
* The shipped `tps` figure: `"
|
|
157
|
-
*
|
|
158
|
-
* The one default for this knob, so flipping the shipped behaviour is one
|
|
159
|
-
* line here. The average ships because it answers the question the row is
|
|
160
|
-
* really asked — how fast is this session producing — instead of what the
|
|
161
|
-
* decoder is doing in this exact poll: an idle gap between turns reads as a
|
|
162
|
-
* steady figure rather than as zero, while `rt` stays one edit away for
|
|
163
|
-
* the moment-to-moment view.
|
|
156
|
+
* The shipped `tps` figure: `"rt"`, an estimate of current throughput.
|
|
164
157
|
*/
|
|
165
|
-
export const DEFAULT_TPS_DISPLAY: TpsDisplay = "
|
|
158
|
+
export const DEFAULT_TPS_DISPLAY: TpsDisplay = "rt";
|
|
166
159
|
|
|
167
160
|
interface TpsConfig {
|
|
168
161
|
/** Which sessions the `tps` row paces. Default `DEFAULT_TPS_SCOPE`. */
|
|
@@ -821,7 +814,7 @@ function readTpsScope(value: unknown, issues: string[]): TpsScope {
|
|
|
821
814
|
function readTpsDisplay(value: unknown, issues: string[]): TpsDisplay {
|
|
822
815
|
if (value === undefined) return DEFAULT_TPS_DISPLAY;
|
|
823
816
|
if (value === "avg" || value === "rt" || value === "both") return value;
|
|
824
|
-
issues.push(`sidebar.tps.display must be "avg", "rt" or "both"; using "
|
|
817
|
+
issues.push(`sidebar.tps.display must be "avg", "rt" or "both"; using "${DEFAULT_TPS_DISPLAY}"`);
|
|
825
818
|
return DEFAULT_TPS_DISPLAY;
|
|
826
819
|
}
|
|
827
820
|
|
package/src/tui/go-panel.ts
CHANGED
|
@@ -26,7 +26,8 @@
|
|
|
26
26
|
// can never overflow or wrap.
|
|
27
27
|
|
|
28
28
|
import { asCount, asRecord } from "./coerce.js";
|
|
29
|
-
import { goTone, type GoUsage, type GoWindow } from "./go-usage.js";
|
|
29
|
+
import { formatRemaining as formatCompactRemaining, goTone, type GoUsage, type GoWindow } from "./go-usage.js";
|
|
30
|
+
export { formatRemaining as formatCompactRemaining } from "./go-usage.js";
|
|
30
31
|
import type { RailLine } from "./presentation.js";
|
|
31
32
|
import type { StatSegment } from "./rows.js";
|
|
32
33
|
import { DEFAULT_PLACEHOLDER } from "./stat-fields.js";
|
|
@@ -333,38 +334,6 @@ function windowById(usage: GoUsage | undefined): Map<GoWindow["id"], GoWindow> {
|
|
|
333
334
|
return byId;
|
|
334
335
|
}
|
|
335
336
|
|
|
336
|
-
/**
|
|
337
|
-
* A duration as one or two compact units: `45s`, `12m`, `2h`, `4h44m`, `1d6h`,
|
|
338
|
-
* `30d23h`.
|
|
339
|
-
*
|
|
340
|
-
* Deliberately not ./go-usage.js's `formatRemaining`: that one is the one-line
|
|
341
|
-
* `go` row's hint and stays single-unit. The panel has the columns for the
|
|
342
|
-
* next unit down, and the next unit is what turns "4h" into something an agent
|
|
343
|
-
* can plan against. Seconds are dropped once hours are on the clock - two
|
|
344
|
-
* units is the whole budget - and a unit is omitted when it is zero, so an
|
|
345
|
-
* exact `2h` reads `2h` rather than `2h0m`.
|
|
346
|
-
*
|
|
347
|
-
* The sub-hour branches round up (as the row's hint does), so a countdown
|
|
348
|
-
* never understates the wait: 90s reads `2m`, not `1m30s`.
|
|
349
|
-
*/
|
|
350
|
-
export function formatCompactRemaining(ms: number): string {
|
|
351
|
-
const totalSeconds = Math.ceil(ms / 1_000);
|
|
352
|
-
if (totalSeconds < 60) return `${totalSeconds}s`;
|
|
353
|
-
const totalMinutes = Math.ceil(ms / 60_000);
|
|
354
|
-
if (totalMinutes < 60) return `${totalMinutes}m`;
|
|
355
|
-
const totalHours = Math.floor(ms / 3_600_000);
|
|
356
|
-
if (totalHours < 24) {
|
|
357
|
-
// Just under the hour: `totalMinutes` is 60 and the hours place is empty,
|
|
358
|
-
// so name the minutes rather than print a hollow `0h59m`.
|
|
359
|
-
if (totalHours === 0) return `${totalMinutes}m`;
|
|
360
|
-
const minutes = Math.floor((ms - totalHours * 3_600_000) / 60_000);
|
|
361
|
-
return minutes > 0 ? `${totalHours}h${minutes}m` : `${totalHours}h`;
|
|
362
|
-
}
|
|
363
|
-
const totalDays = Math.floor(ms / 86_400_000);
|
|
364
|
-
const hours = Math.floor((ms - totalDays * 86_400_000) / 3_600_000);
|
|
365
|
-
return hours > 0 ? `${totalDays}d${hours}h` : `${totalDays}d`;
|
|
366
|
-
}
|
|
367
|
-
|
|
368
337
|
/**
|
|
369
338
|
* The reset countdown for one window, or `undefined` when the reset is unknown
|
|
370
339
|
* or already past.
|
package/src/tui/go-usage.ts
CHANGED
|
@@ -289,20 +289,27 @@ export function goTone(window: GoWindow): "error" | "normal" {
|
|
|
289
289
|
}
|
|
290
290
|
|
|
291
291
|
/**
|
|
292
|
-
* A duration as one
|
|
292
|
+
* A duration as one or two compact units: `45s`, `12m`, `4h44m`, `26d20h`.
|
|
293
293
|
*
|
|
294
294
|
* Exported because the footer's Go panel (./go-panel.ts) draws a countdown for
|
|
295
295
|
* every known future reset, while {@link goResetSuffix} draws one only under the
|
|
296
|
-
* error tone.
|
|
296
|
+
* error tone. Sub-hour waits round up; longer waits truncate smaller units,
|
|
297
|
+
* matching the panel's compact display.
|
|
297
298
|
*/
|
|
298
299
|
export function formatRemaining(ms: number): string {
|
|
299
300
|
const seconds = Math.ceil(ms / 1000);
|
|
300
301
|
if (seconds < 60) return `${seconds}s`;
|
|
301
302
|
const minutes = Math.ceil(ms / 60_000);
|
|
302
303
|
if (minutes < 60) return `${minutes}m`;
|
|
303
|
-
const hours = Math.
|
|
304
|
-
if (hours < 24)
|
|
305
|
-
|
|
304
|
+
const hours = Math.floor(ms / 3_600_000);
|
|
305
|
+
if (hours < 24) {
|
|
306
|
+
if (hours === 0) return `${minutes}m`;
|
|
307
|
+
const rest = Math.floor((ms - hours * 3_600_000) / 60_000);
|
|
308
|
+
return rest > 0 ? `${hours}h${rest}m` : `${hours}h`;
|
|
309
|
+
}
|
|
310
|
+
const days = Math.floor(ms / 86_400_000);
|
|
311
|
+
const rest = Math.floor((ms - days * 86_400_000) / 3_600_000);
|
|
312
|
+
return rest > 0 ? `${days}d${rest}h` : `${days}d`;
|
|
306
313
|
}
|
|
307
314
|
|
|
308
315
|
/**
|
package/src/tui/rows.ts
CHANGED
|
@@ -490,20 +490,23 @@ export function statLine(
|
|
|
490
490
|
// `ttft` the mean time to first token in seconds — all unknown at this
|
|
491
491
|
// boundary, so all re-coerced like every other field. Which one draws
|
|
492
492
|
// is `layout.tpsDisplay` (the row's view of `sidebar.tps.display`,
|
|
493
|
-
// default `"
|
|
493
|
+
// default `"rt"`); presentation.ts feeds it from the resolved config.
|
|
494
494
|
const pair = asRecord(source.tps);
|
|
495
495
|
const rt = asCount(pair?.["rt"]);
|
|
496
496
|
const avg = asCount(pair?.["avg"]);
|
|
497
497
|
const ttft = asCount(pair?.["ttft"]);
|
|
498
|
-
const display = layout.tpsDisplay ?? "
|
|
498
|
+
const display = layout.tpsDisplay ?? "rt";
|
|
499
499
|
if (display === "rt") {
|
|
500
500
|
// Whole tokens/second, honestly rounded — the value is already an
|
|
501
501
|
// EWMA over estimated delta samples, so a decimal would fake a
|
|
502
502
|
// precision the samples never had. Anything below half a
|
|
503
503
|
// token/second hides rather than printing "0 tok/s".
|
|
504
504
|
const rounded = rt === undefined ? undefined : Math.round(rt);
|
|
505
|
-
if (rounded === undefined || rounded <= 0)
|
|
506
|
-
|
|
505
|
+
if (rounded === undefined || rounded <= 0) {
|
|
506
|
+
return ttft === undefined ? undefined : row("tps", `${ttft.toFixed(1)}s ttft`);
|
|
507
|
+
}
|
|
508
|
+
const rate = `${rounded} tok/s`;
|
|
509
|
+
return row("tps", ttft === undefined ? rate : `${rate} · ${ttft.toFixed(1)}s ttft`);
|
|
507
510
|
}
|
|
508
511
|
if (display === "both") {
|
|
509
512
|
// Both figures on one line when the average stands — the realtime
|
package/src/tui/stat-fields.ts
CHANGED
|
@@ -204,8 +204,8 @@ export interface LayoutHint {
|
|
|
204
204
|
*/
|
|
205
205
|
readonly labels?: Readonly<Record<string, string>>;
|
|
206
206
|
/**
|
|
207
|
-
* Which figure the `tps` row draws: the settled-turn average (`"avg"
|
|
208
|
-
* default
|
|
207
|
+
* Which figure the `tps` row draws: the settled-turn average (`"avg"`),
|
|
208
|
+
* the default realtime estimate from the host's streaming delta events
|
|
209
209
|
* (`"rt"`), or both on one line (`"both"`). Carried here rather than read
|
|
210
210
|
* from config directly so the row stays a pure function of its inputs,
|
|
211
211
|
* exactly like `labels` above.
|
|
@@ -271,10 +271,8 @@ export function skeletonValue(field: string, layout: LayoutHint): string | undef
|
|
|
271
271
|
case "elapsed":
|
|
272
272
|
return formatDuration(0, layout.durationStyle);
|
|
273
273
|
case "tps":
|
|
274
|
-
//
|
|
275
|
-
|
|
276
|
-
// read as a zero.
|
|
277
|
-
return layout.tpsDisplay === "both" ? "0 rt · 0 avg" : "0 tok/s";
|
|
274
|
+
// An absent rate is not a measured zero.
|
|
275
|
+
return undefined;
|
|
278
276
|
case "spark":
|
|
279
277
|
return "▁".repeat(Math.max(0, Math.floor(layout.sparkWidth ?? DEFAULT_SPARK_WIDTH)));
|
|
280
278
|
case "reasoning":
|