oc-flight-deck 0.20.4 → 0.20.5

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.
@@ -144,6 +144,12 @@
144
144
  // same value instead of resetting, it cannot step backwards
145
145
  // while the host still reports those turns, and it is NOT
146
146
  // wall-clock since the session began
147
+ // updated the newest action the host recorded, as an absolute
148
+ // timestamp: the latest message's completed, else streamed,
149
+ // else created stamp, written in the host locale and time zone
150
+ // by default. `format.timestamp` below picks the date and time
151
+ // styles, the 12-hour or 24-hour clock, and an IANA zone.
152
+ // Available, off by default.
147
153
  // tps mean speed over `sidebar.tps.scope` below: generation
148
154
  // tokens (output + reasoning) over the settled turns' own
149
155
  // generating time. Draws the average by default — an idle
@@ -176,8 +182,10 @@
176
182
  // Every named row renders persistently, so the rail keeps a stable shape:
177
183
  // a row with no data yet draws a real-looking zero — `$0.000` for money
178
184
  // rows, `0 in · 0 out` for tokens, `0 tok/s` for tps — in the same label
179
- // column as a live row, never a placeholder symbol. (`caution` is the one
180
- // exception: the annunciator stays silent until it has something to say.)
185
+ // column as a live row, never a placeholder symbol. Two rows are the
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.
181
189
  // The fixed lines and live rows share the maxLines budget below, and
182
190
  // anything past it is dropped.
183
191
  "rows": [
@@ -195,6 +203,7 @@
195
203
  // ,"go" Zen Go account usage (needs the active opencode-go credential)
196
204
  // ,"caution" — the annunciator
197
205
  // ,"branch" — current git branch
206
+ // ,"updated" — absolute timestamp of the newest recorded action
198
207
  // ,"ses" - session id preview (labelled `session`); click to copy the full id
199
208
  ],
200
209
 
@@ -233,9 +242,9 @@
233
242
  "persist": true,
234
243
 
235
244
  // Fallback for a persistent row with no data that has no skeleton. Any
236
- // non-empty string. Every shipped field has a skeleton, so this dash is
237
- // unreachable in practice — it only covers a field with nothing to draw
238
- // a zero from.
245
+ // non-empty string. `caution` never draws it (its silence is the design),
246
+ // and `updated` draws it until the host records an action: there is no
247
+ // honest zero timestamp, so this dash is reachable for that one row.
239
248
  "placeholder": "—",
240
249
 
241
250
  // Maximum total height, including fixed lines and live rows. Defaults to 24.
@@ -360,7 +369,30 @@
360
369
  // "compact" no space between units: 2h14m37s
361
370
  // Zero-padding is the same either way: minutes pad when hours are present,
362
371
  // seconds pad when minutes are present, so 2h 14m 07s never reads 2h 14m 7s.
363
- "duration": "spaced"
372
+ "duration": "spaced",
373
+
374
+ // The `updated` row's absolute timestamp. Every key here is optional;
375
+ // `locale`, `hour12` and `timeZone` are omitted when you leave them out, and
376
+ // an omitted value means the host's own: the host locale, the locale's own
377
+ // 12/24-hour cycle, and the host time zone. There is no zone table to keep
378
+ // in sync — the runtime's own ECMA-402 data is the source of truth, so a
379
+ // daylight-saving change is the host's business.
380
+ "timestamp": {
381
+ // A BCP-47 locale for the stamp; "" uses the host locale.
382
+ "locale": "",
383
+ // Date half: "short" (numeric), "medium" (spelled month), or "none".
384
+ "dateStyle": "short",
385
+ // Time half: "medium" (with seconds), "short" (no seconds), or "none".
386
+ // Setting both halves to "none" is reported and the defaults come back.
387
+ "timeStyle": "medium"
388
+ // Omit to follow the locale's clock; true forces 12-hour, false 24-hour.
389
+ // ,"hour12": false
390
+ //
391
+ // An IANA zone (Asia/Tokyo) or UTC offset (+05:30); "" uses the host
392
+ // zone. A Windows zone id such as "Pacific Standard Time" is not valid
393
+ // and falls back to the host zone with a reported warning.
394
+ // ,"timeZone": "UTC"
395
+ }
364
396
  },
365
397
 
366
398
  // -- Glyphs ----------------------------------------------------------------
@@ -145,10 +145,10 @@
145
145
  },
146
146
  "rows": {
147
147
  "type": "array",
148
- "items": { "enum": ["caution", "status", "agent", "model", "branch", "cost", "total", "project", "tokens", "cache", "context", "perms", "elapsed", "tps", "spark", "reasoning", "turns", "guard", "go", "ses", "session"] },
148
+ "items": { "enum": ["caution", "status", "agent", "model", "branch", "cost", "total", "project", "tokens", "cache", "context", "perms", "elapsed", "updated", "tps", "spark", "reasoning", "turns", "guard", "go", "ses", "session"] },
149
149
  "default": ["status", "agent", "model", "cost", "project", "tokens", "cache", "context", "perms", "elapsed", "tps"],
150
150
  "maxItems": 24,
151
- "description": "Which live fields to draw, top to bottom. Any subset, any order - this is the single most useful thing to change. With `sidebar.persist` (the default) every named row always renders, drawing its zero skeleton until the host has data; with `persist: false` rows with no data are omitted entirely. Counted together with `sidebar.lines` against a 24-line cap on the whole rail. The opt-in `ses` row shows a clipped preview of the session id under the `session` label - budget 18 cells, reduced by however much the label overflows `layout.labelWidth`, floored at 8 - and a mouse click on that row copies the full id to the OS clipboard: a host write reporting `written` or an exact clipboard read-back after the OSC52 dispatch verifies it, only a verified copy counts as success, a verified copy stays silent, and an unverified or failed outcome surfaces a toast gated by `notifications.copy`. `session` is accepted as an alias for `ses` and is normalized to it."
151
+ "description": "Which live fields to draw, top to bottom. Any subset, any order - this is the single most useful thing to change. With `sidebar.persist` (the default) every named row always renders, drawing its zero skeleton until the host has data (the opt-in `updated` row has no skeleton and draws `sidebar.placeholder` instead, because there is no honest zero timestamp); with `persist: false` rows with no data are omitted entirely. Counted together with `sidebar.lines` against a 24-line cap on the whole rail. The opt-in `ses` row shows a clipped preview of the session id under the `session` label - budget 18 cells, reduced by however much the label overflows `layout.labelWidth`, floored at 8 - and a mouse click on that row copies the full id to the OS clipboard: a host write reporting `written` or an exact clipboard read-back after the OSC52 dispatch verifies it, only a verified copy counts as success, a verified copy stays silent, and an unverified or failed outcome surfaces a toast gated by `notifications.copy`. `session` is accepted as an alias for `ses` and is normalized to it."
152
152
  },
153
153
  "tps": {
154
154
  "type": "object",
@@ -173,13 +173,13 @@
173
173
  "persist": {
174
174
  "type": "boolean",
175
175
  "default": true,
176
- "description": "Render every field named in `sidebar.rows` as a persistent row, drawing its zero skeleton when the host has no data yet (`$0.000` for money rows, `0 in · 0 out` for tokens, `0 tok/s` for tps — `0 live · 0 avg` when `sidebar.tps.display` is `both` — and so on; `caution` is the one row that never draws a skeleton and stays silent until it has something to announce). True keeps the rail a stable shape that fills in as the session produces data; false restores the old behavior of omitting rows with no data."
176
+ "description": "Render every field named in `sidebar.rows` as a persistent row, drawing its zero skeleton when the host has no data yet (`$0.000` for money rows, `0 in · 0 out` for tokens, `0 tok/s` for tps — `0 live · 0 avg` when `sidebar.tps.display` is `both` — and so on; `caution` never draws a skeleton and stays silent until it has something to announce, and `updated` draws `sidebar.placeholder` until the host records an action because there is no honest zero timestamp). True keeps the rail a stable shape that fills in as the session produces data; false restores the old behavior of omitting rows with no data."
177
177
  },
178
178
  "placeholder": {
179
179
  "type": "string",
180
180
  "minLength": 1,
181
181
  "default": "—",
182
- "description": "Fallback value for a persistent row with no data that has no skeleton. Used only when `sidebar.persist` is true. Must be a non-empty string; anything else falls back to the default em dash. Every shipped field has a skeleton, so this dash is unreachable in practice."
182
+ "description": "Fallback value for a persistent row with no data that has no skeleton. Used only when `sidebar.persist` is true. Must be a non-empty string; anything else falls back to the default em dash. `caution` never draws it because its silence is the design, and `updated` uses it until the host records an action — there is no honest zero timestamp."
183
183
  },
184
184
  "maxLines": {
185
185
  "type": "integer",
@@ -327,13 +327,49 @@
327
327
  "format": {
328
328
  "type": "object",
329
329
  "additionalProperties": false,
330
- "description": "How values are written on the rail. Display only: these options change how a number is drawn, never what is measured.",
330
+ "description": "How values are written on the rail. Display only: these options change how a value is drawn, never what is measured.",
331
331
  "properties": {
332
332
  "duration": {
333
333
  "type": "string",
334
334
  "enum": ["spaced", "compact"],
335
335
  "default": "spaced",
336
336
  "description": "How the `elapsed` row joins its segments. `spaced` puts one space between them (`2h 14m 37s`, the default); `compact` runs them together (`2h14m37s`). Zero-padding is identical either way: minutes pad when hours are present, seconds pad when minutes are present (`14m 07s`, never `14m 7s`). An invalid value falls back to `spaced` and is reported."
337
+ },
338
+ "timestamp": {
339
+ "type": "object",
340
+ "additionalProperties": false,
341
+ "default": { "dateStyle": "short", "timeStyle": "medium" },
342
+ "description": "How the opt-in `updated` row writes its absolute timestamp. Every key is optional: leaving `locale`, `hour12` and `timeZone` out follows the host locale, the locale's own 12/24-hour cycle, and the host time zone, so no zone table ships here. `dateStyle` and `timeStyle` map straight onto Intl's own style options, which are never combined with component options.",
343
+ "properties": {
344
+ "locale": {
345
+ "type": "string",
346
+ "maxLength": 64,
347
+ "default": "",
348
+ "description": "A BCP-47 locale for the timestamp, for example `en-US` or `en-GB`. An empty or absent value uses the host's locale. A malformed locale is reported and falls back to the host locale; a well-formed locale the runtime does not carry falls back inside Intl, as ECMA-402 requires."
349
+ },
350
+ "dateStyle": {
351
+ "type": "string",
352
+ "enum": ["none", "short", "medium"],
353
+ "default": "short",
354
+ "description": "The date half of the timestamp. `short` (the default) is the locale's numeric date (`10/27/26` in en-US); `medium` spells the month (`Oct 27, 2026`), which is wider on the rail; `none` omits the date and leaves a time-only row. The deliberately short ladder keeps a wide `long`/`full` date off a thirty-odd-column sidebar. An invalid value falls back to `short` and is reported."
355
+ },
356
+ "timeStyle": {
357
+ "type": "string",
358
+ "enum": ["none", "short", "medium"],
359
+ "default": "medium",
360
+ "description": "The time half of the timestamp. `medium` (the default) keeps the seconds (`2:32:07 PM` in en-US, so recency is readable); `short` drops them (`2:32 PM`); `none` omits the time and leaves a date-only row. `dateStyle` and `timeStyle` cannot both be `none`, because that can only draw a blank: the pair then falls back to the defaults and is reported."
361
+ },
362
+ "hour12": {
363
+ "type": "boolean",
364
+ "description": "Force a 12-hour clock (`true`) or a 24-hour clock (`false`). Omit the key to follow the locale's own preference. An invalid value is reported and the locale decides. This is Intl's own `hour12` option, so it overrides any hour-cycle extension on `locale`."
365
+ },
366
+ "timeZone": {
367
+ "type": "string",
368
+ "maxLength": 64,
369
+ "default": "",
370
+ "description": "An IANA time-zone identifier (`Asia/Tokyo`, `Europe/Paris`) or a UTC offset identifier (`+05:30`). An empty or absent value uses the host's time zone — ECMA-402's default when `timeZone` is omitted — so daylight-saving changes stay the host's business. A Windows zone id such as `Pacific Standard Time` is not a valid input: it is rejected, reported, and the host zone is used. No Windows-to-IANA mapping is hardcoded here; that data is versioned and belongs to the system's ICU."
371
+ }
372
+ }
337
373
  }
338
374
  }
339
375
  },
@@ -414,7 +450,7 @@
414
450
  }
415
451
  },
416
452
  "propertyNames": {
417
- "enum": ["*", "caution", "status", "agent", "model", "branch", "cost", "total", "project", "tokens", "cache", "context", "perms", "elapsed", "tps", "spark", "reasoning", "turns", "guard", "go", "ses", "session"]
453
+ "enum": ["*", "caution", "status", "agent", "model", "branch", "cost", "total", "project", "tokens", "cache", "context", "perms", "elapsed", "updated", "tps", "spark", "reasoning", "turns", "guard", "go", "ses", "session"]
418
454
  },
419
455
  "default": { "*": { "color": "subdued", "attributes": [] } },
420
456
  "description": "Style all live rows under `*`, then optionally override any known row name such as `cost`. A row can change one field and inherit the other from `*`; unknown row names are reported and ignored. `session` is accepted as an alias for `ses` and is normalized to it."
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oc-flight-deck",
3
- "version": "0.20.4",
3
+ "version": "0.20.5",
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",
@@ -60,7 +60,7 @@
60
60
  "access": "public"
61
61
  },
62
62
  "devDependencies": {
63
- "@opencode/plugin": "2.1.3",
63
+ "@opencode/plugin": "2.2.0",
64
64
  "@opentui/core": "0.6.6",
65
65
  "@opentui/solid": "0.6.6",
66
66
  "@types/bun": "^1.4.2",
package/src/tui/config.ts CHANGED
@@ -10,7 +10,7 @@
10
10
 
11
11
  import { DEFAULT_PLACEHOLDER, canonicalField, isStatField, STAT_FIELDS } from "./stats.js";
12
12
  import type { CautionThresholds } from "./caution.js";
13
- import type { DurationStyle } from "./format.js";
13
+ import type { DurationStyle, TimestampDateStyle, TimestampTimeStyle } from "./format.js";
14
14
  import {
15
15
  DEFAULT_STYLE,
16
16
  STYLE_ATTRIBUTES,
@@ -330,6 +330,27 @@ interface GlyphConfig {
330
330
  readonly clear: string;
331
331
  }
332
332
 
333
+ /**
334
+ * Presentation for the `updated` row's absolute timestamp.
335
+ *
336
+ * Every key is optional and every default is the host's own: `locale`,
337
+ * `hour12` and `timeZone` are omitted from the formatter unless set, so the
338
+ * host locale's date order and 12/24-hour cycle and the host's zone apply
339
+ * without a table of our own to drift from the runtime's ICU data.
340
+ */
341
+ export interface TimestampConfig {
342
+ /** A BCP-47 locale for the stamp; absent means the host's locale. */
343
+ readonly locale?: string;
344
+ /** Date presentation. Default `"short"`. */
345
+ readonly dateStyle: TimestampDateStyle;
346
+ /** Time presentation. Default `"medium"`. */
347
+ readonly timeStyle: TimestampTimeStyle;
348
+ /** Force 12-hour (`true`) or 24-hour (`false`); absent follows the locale. */
349
+ readonly hour12?: boolean;
350
+ /** An IANA zone or UTC offset; absent means the host's zone. */
351
+ readonly timeZone?: string;
352
+ }
353
+
333
354
  /**
334
355
  * How values are written on the rail.
335
356
  *
@@ -343,6 +364,8 @@ interface FormatConfig {
343
364
  * (`2h14m37s`). Zero-padding is identical either way.
344
365
  */
345
366
  readonly duration: DurationStyle;
367
+ /** How the `updated` row writes its absolute timestamp. */
368
+ readonly timestamp: TimestampConfig;
346
369
  }
347
370
 
348
371
  const DEFAULT_LAYOUT: LayoutConfig = {
@@ -351,7 +374,16 @@ const DEFAULT_LAYOUT: LayoutConfig = {
351
374
  sparkWidth: 12,
352
375
  };
353
376
 
354
- const DEFAULT_FORMAT: FormatConfig = { duration: "spaced" };
377
+ /**
378
+ * A short date and a time with seconds: enough to tell when the last action
379
+ * was and how recent it is, in the host locale and zone.
380
+ */
381
+ export const DEFAULT_TIMESTAMP: TimestampConfig = { dateStyle: "short", timeStyle: "medium" };
382
+
383
+ const DEFAULT_FORMAT: FormatConfig = {
384
+ duration: "spaced",
385
+ timestamp: DEFAULT_TIMESTAMP,
386
+ };
355
387
 
356
388
  const DEFAULT_GLYPHS: GlyphConfig = {
357
389
  watch: "▲",
@@ -865,10 +897,11 @@ function mergeSection(
865
897
  if (hostValue !== undefined && !isRecord(hostValue)) return hostValue;
866
898
  if (fileValue !== undefined && !isRecord(fileValue) && hostValue === undefined) return fileValue;
867
899
  const merged: Record<string, unknown> = { ...sectionOf(file, key), ...sectionOf(host, key) };
868
- // A nested `sidebar.footer` / `sidebar.tps` object from the host replaces
869
- // only the leaf keys it names: a host `{ footer: { lines } }` must not drop
870
- // a file `{ footer: { go } }`, and vice versa. Either side malformed (or
871
- // absent) keeps the shallow winner above so resolveConfig still reports it.
900
+ // A nested `sidebar.footer` / `sidebar.tps` / `format.timestamp` object from
901
+ // the host replaces only the leaf keys it names: a host `{ footer: { lines } }`
902
+ // must not drop a file `{ footer: { go } }`, and vice versa. Either side
903
+ // malformed (or absent) keeps the shallow winner above so resolveConfig still
904
+ // reports it.
872
905
  if (key === "sidebar") {
873
906
  const fileSidebar = sectionOf(file, key);
874
907
  const hostSidebar = sectionOf(host, key);
@@ -883,6 +916,13 @@ function mergeSection(
883
916
  merged["tps"] = { ...fileTps, ...hostTps };
884
917
  }
885
918
  }
919
+ if (key === "format") {
920
+ const fileTimestamp = sectionOf(file, key)["timestamp"];
921
+ const hostTimestamp = sectionOf(host, key)["timestamp"];
922
+ if (isRecord(fileTimestamp) && isRecord(hostTimestamp)) {
923
+ merged["timestamp"] = { ...fileTimestamp, ...hostTimestamp };
924
+ }
925
+ }
886
926
  return merged;
887
927
  }
888
928
 
@@ -1003,8 +1043,148 @@ function readDurationStyle(value: unknown, issues: string[]): DurationStyle {
1003
1043
  return DEFAULT_FORMAT.duration;
1004
1044
  }
1005
1045
 
1046
+ /** One presentation rung, from a fixed vocabulary. */
1047
+ function readTimestampStyle<T extends string>(
1048
+ value: unknown,
1049
+ allowed: readonly T[],
1050
+ fallback: T,
1051
+ path: string,
1052
+ issues: string[],
1053
+ ): T {
1054
+ if (value === undefined) return fallback;
1055
+ const text = typeof value === "string" ? value.trim() : "";
1056
+ if ((allowed as readonly string[]).includes(text)) return text as T;
1057
+ issues.push(`${path} must be one of ${allowed.join(", ")}; using "${fallback}"`);
1058
+ return fallback;
1059
+ }
1060
+
1061
+ /**
1062
+ * The optional 12/24-hour switch.
1063
+ *
1064
+ * Absent is a real value here, not a missing one: leaving it out is how the
1065
+ * host locale's own clock style is followed. A malformed value therefore falls
1066
+ * back to absent, loudly, rather than to an arbitrary boolean.
1067
+ */
1068
+ function readHour12(value: unknown, issues: string[]): boolean | undefined {
1069
+ if (value === undefined) return undefined;
1070
+ if (typeof value === "boolean") return value;
1071
+ issues.push("format.timestamp.hour12 must be true or false; using the host locale");
1072
+ return undefined;
1073
+ }
1074
+
1075
+ /**
1076
+ * The optional locale for the stamp.
1077
+ *
1078
+ * Validated structurally with `Intl.getCanonicalLocales`, which is the same
1079
+ * runtime data the formatter uses; a locale it accepts but does not carry
1080
+ * falls back inside Intl on its own, as ECMA-402 requires. Empty means "host
1081
+ * locale" and is silent, so an explicit blank in a copied config is not a
1082
+ * warning.
1083
+ */
1084
+ function readTimestampLocale(value: unknown, issues: string[]): string | undefined {
1085
+ if (value === undefined) return undefined;
1086
+ if (typeof value !== "string") {
1087
+ issues.push("format.timestamp.locale must be a BCP-47 locale string; using the host locale");
1088
+ return undefined;
1089
+ }
1090
+ const path = "format.timestamp.locale";
1091
+ const text = normalizeText(value, path, issues).trim();
1092
+ if (text.length === 0) return undefined;
1093
+ if (text.length > 64) {
1094
+ issues.push(`${path} was longer than 64 characters; using the host locale`);
1095
+ return undefined;
1096
+ }
1097
+ try {
1098
+ Intl.getCanonicalLocales(text);
1099
+ } catch {
1100
+ issues.push(`${path} is not a valid BCP-47 locale; using the host locale`);
1101
+ return undefined;
1102
+ }
1103
+ return text;
1104
+ }
1105
+
1106
+ /**
1107
+ * The optional time-zone override.
1108
+ *
1109
+ * The only accepted names are the ones ECMA-402 accepts: IANA Zone/Link
1110
+ * identifiers and offset identifiers (`+05:30`). Validation is a probe
1111
+ * formatter, never a lookup table — Windows zone ids are explicitly not valid
1112
+ * `timeZone` inputs and go through a versioned, territory-sensitive ICU
1113
+ * mapping, so a hardcoded map here would be exactly the drift the runtime's
1114
+ * own data avoids. The host zone is the default: an omitted or empty value
1115
+ * passes no `timeZone` at all.
1116
+ */
1117
+ function readTimestampZone(value: unknown, issues: string[]): string | undefined {
1118
+ if (value === undefined) return undefined;
1119
+ if (typeof value !== "string") {
1120
+ issues.push("format.timestamp.timeZone must be an IANA zone or UTC offset; using the host zone");
1121
+ return undefined;
1122
+ }
1123
+ const path = "format.timestamp.timeZone";
1124
+ const text = normalizeText(value, path, issues).trim();
1125
+ if (text.length === 0) return undefined;
1126
+ if (text.length > 64) {
1127
+ issues.push(`${path} was longer than 64 characters; using the host zone`);
1128
+ return undefined;
1129
+ }
1130
+ try {
1131
+ new Intl.DateTimeFormat(undefined, { timeZone: text });
1132
+ } catch {
1133
+ issues.push(`${path} is not a valid IANA zone or UTC offset; using the host zone`);
1134
+ return undefined;
1135
+ }
1136
+ return text;
1137
+ }
1138
+
1139
+ /**
1140
+ * The `updated` row's presentation.
1141
+ *
1142
+ * A malformed section falls back whole and is reported, like `sidebar.tps`; a
1143
+ * bad leaf falls back alone. Both halves `"none"` is a config that can only
1144
+ * draw a blank row, so it is reported and the default pair is restored rather
1145
+ * than rendering nothing.
1146
+ */
1147
+ function readTimestamp(value: unknown, issues: string[]): TimestampConfig {
1148
+ if (value !== undefined && !isRecord(value)) {
1149
+ issues.push("format.timestamp must be an object; using the defaults");
1150
+ return DEFAULT_TIMESTAMP;
1151
+ }
1152
+ const section = isRecord(value) ? value : {};
1153
+ let dateStyle = readTimestampStyle(
1154
+ section["dateStyle"],
1155
+ ["none", "short", "medium"] as const,
1156
+ DEFAULT_TIMESTAMP.dateStyle,
1157
+ "format.timestamp.dateStyle",
1158
+ issues,
1159
+ );
1160
+ let timeStyle = readTimestampStyle(
1161
+ section["timeStyle"],
1162
+ ["none", "short", "medium"] as const,
1163
+ DEFAULT_TIMESTAMP.timeStyle,
1164
+ "format.timestamp.timeStyle",
1165
+ issues,
1166
+ );
1167
+ if (dateStyle === "none" && timeStyle === "none") {
1168
+ issues.push('format.timestamp.dateStyle and timeStyle are both "none"; using the default presentation');
1169
+ dateStyle = DEFAULT_TIMESTAMP.dateStyle;
1170
+ timeStyle = DEFAULT_TIMESTAMP.timeStyle;
1171
+ }
1172
+
1173
+ const timestamp: { -readonly [K in keyof TimestampConfig]: TimestampConfig[K] } = { dateStyle, timeStyle };
1174
+ const locale = readTimestampLocale(section["locale"], issues);
1175
+ if (locale !== undefined) timestamp.locale = locale;
1176
+ const hour12 = readHour12(section["hour12"], issues);
1177
+ if (hour12 !== undefined) timestamp.hour12 = hour12;
1178
+ const timeZone = readTimestampZone(section["timeZone"], issues);
1179
+ if (timeZone !== undefined) timestamp.timeZone = timeZone;
1180
+ return timestamp;
1181
+ }
1182
+
1006
1183
  function readFormat(section: Record<string, unknown>, issues: string[]): FormatConfig {
1007
- return { duration: readDurationStyle(section["duration"], issues) };
1184
+ return {
1185
+ duration: readDurationStyle(section["duration"], issues),
1186
+ timestamp: readTimestamp(section["timestamp"], issues),
1187
+ };
1008
1188
  }
1009
1189
 
1010
1190
  /**
package/src/tui/format.ts CHANGED
@@ -69,6 +69,83 @@ export function formatDuration(ms: number, style: DurationStyle = "compact"): st
69
69
  return minutes > 0 ? `${minutes}m${join}${ss}s` : `${seconds}s`;
70
70
  }
71
71
 
72
+ /**
73
+ * How the absolute timestamp's date half is presented: `"none"` omits it,
74
+ * `"short"` and `"medium"` map straight onto Intl's `dateStyle`.
75
+ *
76
+ * A deliberately short ladder: this is one sidebar row, and `long`/`full`
77
+ * dates spend the panel on a date the reader can open elsewhere. `"none"` is
78
+ * never passed to Intl — it is the absence of `dateStyle`, because Intl
79
+ * rejects the name with a `RangeError`.
80
+ */
81
+ export type TimestampDateStyle = "none" | "short" | "medium";
82
+
83
+ /**
84
+ * How the timestamp's time half is presented: `"none"` omits it, `"short"`
85
+ * drops the seconds, `"medium"` keeps them so the row shows how recent the
86
+ * action is.
87
+ */
88
+ export type TimestampTimeStyle = "none" | "short" | "medium";
89
+
90
+ /**
91
+ * Presentation for an absolute timestamp.
92
+ *
93
+ * Every field is optional and every default is the host's own: `locale`,
94
+ * `hour12` and `timeZone` are omitted from the formatter unless set, so the
95
+ * host locale's date order and 12/24-hour cycle and the host's zone apply with
96
+ * no table of ours to drift from the runtime's own ICU data.
97
+ */
98
+ export interface TimestampFormat {
99
+ /** A BCP-47 locale; absent means the host's locale. */
100
+ readonly locale?: string;
101
+ /** Date presentation. Default `"short"`. */
102
+ readonly dateStyle?: TimestampDateStyle;
103
+ /** Time presentation. Default `"medium"`. */
104
+ readonly timeStyle?: TimestampTimeStyle;
105
+ /** `true` forces a 12-hour clock, `false` a 24-hour one; absent follows the locale. */
106
+ readonly hour12?: boolean;
107
+ /** An IANA zone name or UTC offset; absent means the host's zone. */
108
+ readonly timeZone?: string;
109
+ }
110
+
111
+ /**
112
+ * An absolute timestamp, or `undefined` when the presentation draws nothing or
113
+ * the runtime rejects it.
114
+ *
115
+ * The styles are Intl's own `dateStyle`/`timeStyle`, never combined with
116
+ * component options (ECMA-402 forbids that combination). `hour12` is not a
117
+ * component option and is allowed beside the styles; when it is absent the
118
+ * locale decides. Omitting `timeZone` is the documented way to ask for the host
119
+ * environment's zone, and an explicit zone is only ever an IANA identifier or
120
+ * offset identifier — a Windows zone id is rejected by Intl, which is why the
121
+ * config boundary validates it and this function still catches the
122
+ * `RangeError`, so one bad clock setting can never take the rail down. The
123
+ * catch also covers a structurally invalid locale passed straight to this
124
+ * function.
125
+ */
126
+ export function formatTimestamp(ms: number, format: TimestampFormat = {}): string | undefined {
127
+ const dateStyle = format.dateStyle ?? "short";
128
+ const timeStyle = format.timeStyle ?? "medium";
129
+ // Both halves off draws nothing: no timestamp exists to show.
130
+ if (dateStyle === "none" && timeStyle === "none") return undefined;
131
+
132
+ const options: Intl.DateTimeFormatOptions = {};
133
+ if (dateStyle !== "none") options.dateStyle = dateStyle;
134
+ if (timeStyle !== "none") options.timeStyle = timeStyle;
135
+ if (format.hour12 !== undefined) options.hour12 = format.hour12;
136
+ const timeZone = format.timeZone?.trim();
137
+ if (timeZone !== undefined && timeZone.length > 0) options.timeZone = timeZone;
138
+
139
+ const locale = format.locale?.trim();
140
+ try {
141
+ return new Intl.DateTimeFormat(locale === undefined || locale.length === 0 ? undefined : locale, options).format(ms);
142
+ } catch {
143
+ // `RangeError` for an unknown zone or malformed locale. Presentation is a
144
+ // display concern: the row hides rather than failing the rail.
145
+ return undefined;
146
+ }
147
+ }
148
+
72
149
  /** Fuel-gauge width in cells when the caller does not override it. */
73
150
  export const DEFAULT_BAR_WIDTH = 10;
74
151
 
package/src/tui/index.tsx CHANGED
@@ -161,6 +161,7 @@ export default Plugin.define({
161
161
  const {
162
162
  messagesOf,
163
163
  treeTotals,
164
+ sessionCost,
164
165
  contextUsage,
165
166
  sessionElapsed,
166
167
  statusOf,
@@ -302,13 +303,19 @@ export default Plugin.define({
302
303
  // share its scope: when the tree is on record its rolled-up tokens
303
304
  // replace the session's own, and the cost/total rows read `tree` itself.
304
305
  // The tree is derived only when a row that needs it is on the rail.
305
- const tree =
306
- wants("cost") || wants("total") || wants("tokens") || wants("cache") || wants("reasoning")
307
- ? treeTotals(sessionID, session?.cost)
308
- : undefined;
306
+ //
307
+ // `cost` is the current model's spend; `total` is the host's family
308
+ // roll-up. Neither reads the other's source, so no hand-off can make the
309
+ // lifetime figure inherit a per-model one.
310
+ const wantsUsage =
311
+ wants("cost") || wants("total") || wants("tokens") || wants("cache") || wants("reasoning");
312
+ const ownCost = wantsUsage ? sessionCost(sessionID, session as SessionLike | undefined) : undefined;
313
+ const tree = wantsUsage ? treeTotals(sessionID) : undefined;
309
314
 
310
315
  return {
311
316
  ...session,
317
+ cost: ownCost?.cost,
318
+ costKind: ownCost?.kind,
312
319
  tokens: tree?.tokens ?? session?.tokens,
313
320
  caution: wants("caution") ? announce(sessionID) : undefined,
314
321
  branch: wants("branch") ? branchOf(location) : undefined,
@@ -321,6 +328,9 @@ export default Plugin.define({
321
328
  tps: wants("tps") ? sessionTps(sessionID, session) : undefined,
322
329
  spark: wants("spark") ? sparkValues(sessionID) : undefined,
323
330
  elapsedMs: wants("elapsed") ? sessionElapsed(sessionID) : undefined,
331
+ // The newest action the host recorded, read only when the row asked for
332
+ // it: a default install does no extra message walk.
333
+ lastActionMs: wants("updated") ? lastActivity(sessionID) : undefined,
324
334
  turns,
325
335
  guard: bridge?.status,
326
336
  // Read the go store inside the render too, so a poll re-runs the rail
@@ -50,6 +50,7 @@ export function railLines(config: FlightDeckConfig, source: StatSource = {}): re
50
50
  persist: config.sidebar.persist,
51
51
  placeholder: config.sidebar.placeholder,
52
52
  durationStyle: config.format.duration,
53
+ timestamp: config.format.timestamp,
53
54
  tpsDisplay: config.sidebar.tps.display,
54
55
  // Decided from the whole row list, the way `statRows` decides it: `cost`
55
56
  // folds the subagent total into itself only when no `total` row was asked
package/src/tui/rows.ts CHANGED
@@ -6,7 +6,7 @@
6
6
  // character in a host-supplied string cannot move the cursor. Pure, so the
7
7
  // rendering is trivial to test.
8
8
 
9
- import { DEFAULT_BAR_WIDTH, clip, formatCost, formatCount, formatDuration, fuelBar, sparkline } from "./format.js";
9
+ import { DEFAULT_BAR_WIDTH, clip, formatCost, formatCount, formatDuration, formatTimestamp, fuelBar, sparkline } from "./format.js";
10
10
  import { asCount, asRecord, asText } from "./coerce.js";
11
11
  import { goResetSuffix, goTone, type GoWindow } from "./go-usage.js";
12
12
  import { guardToken } from "./guard-tokens.js";
@@ -26,6 +26,21 @@ import {
26
26
  /** Braille frames, advanced by the ticker, shown only while the session runs. */
27
27
  const SPINNER = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] as const;
28
28
 
29
+ // How a money figure introduces itself. A bare figure is the host's recorded
30
+ // charge. `~` says at least one part of it was priced from the model catalog
31
+ // rather than charged, and the floor mark says it counts only the history the
32
+ // host still holds. Built from code points so this file stays ASCII, the same
33
+ // way the other non-ASCII glyphs here are.
34
+ const ESTIMATE_MARK = "~";
35
+ const FLOOR_MARK = String.fromCharCode(0x2265);
36
+
37
+ /** The mark a money figure carries, from the strength of its claim. */
38
+ function feeMark(kind: unknown): string {
39
+ if (kind === "estimated") return ESTIMATE_MARK;
40
+ if (kind === "bounded") return FLOOR_MARK;
41
+ return "";
42
+ }
43
+
29
44
  /**
30
45
  * Value-column design budget for the `ses` row's preview, in cells.
31
46
  *
@@ -341,8 +356,11 @@ export function statLine(
341
356
  treeCost > cost;
342
357
 
343
358
  if (!merge) {
344
- const value = layout.hasTotalRow === true ? (cost ?? treeCost) : (treeCost ?? cost);
345
- return value === undefined ? undefined : row("cost", formatCost(value));
359
+ // `cost` is the current model's spend and nothing else: when it is not
360
+ // known the row stays absent rather than borrowing the family figure
361
+ // under a label that promises one model.
362
+ if (cost === undefined) return undefined;
363
+ return row("cost", `${feeMark(source.costKind)}${formatCost(cost)}`);
346
364
  }
347
365
 
348
366
  // The delta (`+$0.020`) used to be here and pushed the row to 40 columns,
@@ -350,7 +368,10 @@ export function statLine(
350
368
  // did not earn its width: the count already explains why the figure is
351
369
  // higher, and this form is the same width as the old `total` row.
352
370
  const plural = family === 1 ? "subagent" : "subagents";
353
- return row("cost", `${formatCost(treeCost as number)} · ${family} ${plural}`);
371
+ return row(
372
+ "cost",
373
+ `${feeMark(tree?.kind)}${formatCost(treeCost as number)} · ${family} ${plural}`,
374
+ );
354
375
  }
355
376
  case "total": {
356
377
  // The family figure: this session plus its subagent sessions. Since 0.20.0
@@ -365,7 +386,7 @@ export function statLine(
365
386
  if (cost === undefined) return undefined;
366
387
  const count = asCount(tree.count) ?? 0;
367
388
  const plural = count === 1 ? "subagent" : "subagents";
368
- return row("total", `${formatCost(cost)} · ${count} ${plural}`);
389
+ return row("total", `${feeMark(tree.kind)}${formatCost(cost)} · ${count} ${plural}`);
369
390
  }
370
391
  case "project": {
371
392
  const project = asRecord(source.project);
@@ -447,6 +468,19 @@ export function statLine(
447
468
  if (ms === undefined || ms <= 0) return undefined;
448
469
  return row("elapsed", formatDuration(ms, layout.durationStyle));
449
470
  }
471
+ case "updated": {
472
+ // An absolute instant, not a relative age: the row answers "when did the
473
+ // host last record something here", and a wall-clock stamp stays
474
+ // meaningful after the panel has been idle for a while. A zero or
475
+ // negative stamp is not a real action time (1970 is a missing value that
476
+ // coerced to a number), so it hides like every other no-data row; the
477
+ // formatter owns the presentation and returns `undefined` when the
478
+ // configured styles or zone cannot draw anything.
479
+ const ms = asCount(source.lastActionMs);
480
+ if (ms === undefined || ms <= 0) return undefined;
481
+ const value = formatTimestamp(ms, layout.timestamp);
482
+ return value === undefined ? undefined : row("updated", value);
483
+ }
450
484
  case "tps": {
451
485
  // The triple the reader hands over: `rt` the realtime estimate from
452
486
  // the host's streaming delta events, `avg` the settled-turn average,