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.
package/CHANGELOG.md CHANGED
@@ -22,8 +22,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
22
22
 
23
23
  ## [Unreleased]
24
24
 
25
+ ## [0.20.5] - 2026-10-28
26
+
27
+ ### Added
28
+
29
+ - Opt-in `updated` row: the absolute timestamp of the newest action the host recorded for the session — the latest message's `completed`, else `streamed`, else `created` stamp. Off the shipped rail, like `branch` and `go`: add `"updated"` to `sidebar.rows` to draw it. `format.timestamp` sets the presentation: `locale` (default the host locale), `dateStyle` (`"short"` default, `"medium"`, or `"none"`), `timeStyle` (`"medium"` default with seconds, `"short"`, or `"none"`), `hour12` (omit to follow the locale, or force 12/24-hour), and `timeZone` (omit for the host zone, or name an IANA zone or UTC offset). Omitted `timeZone` leaves Intl's own host-zone default in place, so no Windows-to-IANA table ships here; a Windows zone id or an unknown name is reported and falls back to the host zone without breaking the rail. A config that turns both style halves `"none"` is reported and restored to the defaults. With `sidebar.persist` the row draws `sidebar.placeholder` until the host records an action, since there is no honest zero timestamp.
30
+
25
31
  ### Fixed
26
32
 
33
+ - `cost` and `total` now read the host's own figures. `total` is the family roll-up (`data.session.cost(root(sessionID))`), resolved from the session's root because `cost()` answers a family only for a root. It is drawn as exact only when the host's family records are complete and consistent with the charges visible on the message lists - every listed member on record, and a roll-up that already covers them. Otherwise the host's figure is shown as a floor (`>=`) and is never raised above itself; when the host reports zero, the visible recorded sum is shown as a floor; `$0.000` is exact only for a complete family with nothing recorded or visible, and incomplete coverage with nothing visible is a floor at zero. a zero roll-up where the family still holds tokens on models the catalog prices is a catalog estimate across the whole family, marked `~`, never exact. `cost` is the current model's spend: the recorded cost of the assistant steps that ran on the selected model, excluding anything older than the session's own creation (the host's own fork guard, so copied parent history is not billed to the fork), and marked as a floor because the TUI surface exposes a window of history with no paging. A step whose charge was not recorded is catalog-priced and marked `~`. The session aggregate is never used as a per-model figure, and no price table ships in this package. `@opencode/plugin` moves to 2.2.0 for types.
27
34
  - The rail's count formatter now steps past millions: a 1,769,100,000 cache read draws as `1.8B` instead of `1769.1M`, and the 999,950,000 boundary draws as `1B` instead of `1000M`. The `B` and `T` steps carry the same one-decimal shape as `M`, and the round-before-unit rule holds at every boundary up to the deliberate `T` ceiling (a token count at ~999.95T would still read `1000T`).
28
35
 
29
36
  ## [0.20.1] - 2026-10-21
package/dist/tui/index.js CHANGED
@@ -400,6 +400,28 @@ function formatDuration(ms, style = "compact") {
400
400
  return `${hours}h${join}${String(minutes).padStart(2, "0")}m${join}${ss}s`;
401
401
  return minutes > 0 ? `${minutes}m${join}${ss}s` : `${seconds}s`;
402
402
  }
403
+ function formatTimestamp(ms, format = {}) {
404
+ const dateStyle = format.dateStyle ?? "short";
405
+ const timeStyle = format.timeStyle ?? "medium";
406
+ if (dateStyle === "none" && timeStyle === "none")
407
+ return;
408
+ const options = {};
409
+ if (dateStyle !== "none")
410
+ options.dateStyle = dateStyle;
411
+ if (timeStyle !== "none")
412
+ options.timeStyle = timeStyle;
413
+ if (format.hour12 !== undefined)
414
+ options.hour12 = format.hour12;
415
+ const timeZone = format.timeZone?.trim();
416
+ if (timeZone !== undefined && timeZone.length > 0)
417
+ options.timeZone = timeZone;
418
+ const locale = format.locale?.trim();
419
+ try {
420
+ return new Intl.DateTimeFormat(locale === undefined || locale.length === 0 ? undefined : locale, options).format(ms);
421
+ } catch {
422
+ return;
423
+ }
424
+ }
403
425
  var DEFAULT_BAR_WIDTH = 10;
404
426
  function fuelBar(ratio, width = DEFAULT_BAR_WIDTH) {
405
427
  const cells = Math.max(1, Math.floor(width));
@@ -702,6 +724,7 @@ var STAT_FIELDS = [
702
724
  "context",
703
725
  "perms",
704
726
  "elapsed",
727
+ "updated",
705
728
  "tps",
706
729
  "spark",
707
730
  "reasoning",
@@ -769,6 +792,15 @@ function skeletonValue(field, layout) {
769
792
 
770
793
  // src/tui/rows.ts
771
794
  var SPINNER = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
795
+ var ESTIMATE_MARK = "~";
796
+ var FLOOR_MARK = String.fromCharCode(8805);
797
+ function feeMark(kind) {
798
+ if (kind === "estimated")
799
+ return ESTIMATE_MARK;
800
+ if (kind === "bounded")
801
+ return FLOOR_MARK;
802
+ return "";
803
+ }
772
804
  var SES_PREVIEW_WIDTH = 18;
773
805
  var CONTROL_CHARS = /[\u0000-\u001F\u007F-\u009F]/g;
774
806
  function plain(value) {
@@ -924,11 +956,12 @@ function statLine(field, source, layout = {}) {
924
956
  const family = count !== undefined && count > 0 ? count : 0;
925
957
  const merge = layout.hasTotalRow !== true && cost !== undefined && treeCost !== undefined && family > 0 && treeCost > cost;
926
958
  if (!merge) {
927
- const value = layout.hasTotalRow === true ? cost ?? treeCost : treeCost ?? cost;
928
- return value === undefined ? undefined : row("cost", formatCost(value));
959
+ if (cost === undefined)
960
+ return;
961
+ return row("cost", `${feeMark(source.costKind)}${formatCost(cost)}`);
929
962
  }
930
963
  const plural = family === 1 ? "subagent" : "subagents";
931
- return row("cost", `${formatCost(treeCost)} \xB7 ${family} ${plural}`);
964
+ return row("cost", `${feeMark(tree?.kind)}${formatCost(treeCost)} \xB7 ${family} ${plural}`);
932
965
  }
933
966
  case "total": {
934
967
  const tree = asRecord2(source.tree);
@@ -939,7 +972,7 @@ function statLine(field, source, layout = {}) {
939
972
  return;
940
973
  const count = asCount2(tree.count) ?? 0;
941
974
  const plural = count === 1 ? "subagent" : "subagents";
942
- return row("total", `${formatCost(cost)} \xB7 ${count} ${plural}`);
975
+ return row("total", `${feeMark(tree.kind)}${formatCost(cost)} \xB7 ${count} ${plural}`);
943
976
  }
944
977
  case "project": {
945
978
  const project = asRecord2(source.project);
@@ -1004,6 +1037,13 @@ function statLine(field, source, layout = {}) {
1004
1037
  return;
1005
1038
  return row("elapsed", formatDuration(ms, layout.durationStyle));
1006
1039
  }
1040
+ case "updated": {
1041
+ const ms = asCount2(source.lastActionMs);
1042
+ if (ms === undefined || ms <= 0)
1043
+ return;
1044
+ const value = formatTimestamp(ms, layout.timestamp);
1045
+ return value === undefined ? undefined : row("updated", value);
1046
+ }
1007
1047
  case "tps": {
1008
1048
  const pair = asRecord2(source.tps);
1009
1049
  const rt = asCount2(pair?.["rt"]);
@@ -1553,7 +1593,11 @@ var DEFAULT_LAYOUT = {
1553
1593
  barWidth: 10,
1554
1594
  sparkWidth: 12
1555
1595
  };
1556
- var DEFAULT_FORMAT = { duration: "spaced" };
1596
+ var DEFAULT_TIMESTAMP = { dateStyle: "short", timeStyle: "medium" };
1597
+ var DEFAULT_FORMAT = {
1598
+ duration: "spaced",
1599
+ timestamp: DEFAULT_TIMESTAMP
1600
+ };
1557
1601
  var DEFAULT_GLYPHS = {
1558
1602
  watch: "\u25B2",
1559
1603
  caution: "\u25CF",
@@ -1861,6 +1905,13 @@ function mergeSection(file, host, key) {
1861
1905
  merged["tps"] = { ...fileTps, ...hostTps };
1862
1906
  }
1863
1907
  }
1908
+ if (key === "format") {
1909
+ const fileTimestamp = sectionOf(file, key)["timestamp"];
1910
+ const hostTimestamp = sectionOf(host, key)["timestamp"];
1911
+ if (isRecord(fileTimestamp) && isRecord(hostTimestamp)) {
1912
+ merged["timestamp"] = { ...fileTimestamp, ...hostTimestamp };
1913
+ }
1914
+ }
1864
1915
  return merged;
1865
1916
  }
1866
1917
  function mergeOptions(fileOptions, hostOptions) {
@@ -1942,8 +1993,99 @@ function readDurationStyle(value, issues) {
1942
1993
  issues.push('format.duration must be "compact" or "spaced"; using the default');
1943
1994
  return DEFAULT_FORMAT.duration;
1944
1995
  }
1996
+ function readTimestampStyle(value, allowed, fallback, path, issues) {
1997
+ if (value === undefined)
1998
+ return fallback;
1999
+ const text = typeof value === "string" ? value.trim() : "";
2000
+ if (allowed.includes(text))
2001
+ return text;
2002
+ issues.push(`${path} must be one of ${allowed.join(", ")}; using "${fallback}"`);
2003
+ return fallback;
2004
+ }
2005
+ function readHour12(value, issues) {
2006
+ if (value === undefined)
2007
+ return;
2008
+ if (typeof value === "boolean")
2009
+ return value;
2010
+ issues.push("format.timestamp.hour12 must be true or false; using the host locale");
2011
+ return;
2012
+ }
2013
+ function readTimestampLocale(value, issues) {
2014
+ if (value === undefined)
2015
+ return;
2016
+ if (typeof value !== "string") {
2017
+ issues.push("format.timestamp.locale must be a BCP-47 locale string; using the host locale");
2018
+ return;
2019
+ }
2020
+ const path = "format.timestamp.locale";
2021
+ const text = normalizeText(value, path, issues).trim();
2022
+ if (text.length === 0)
2023
+ return;
2024
+ if (text.length > 64) {
2025
+ issues.push(`${path} was longer than 64 characters; using the host locale`);
2026
+ return;
2027
+ }
2028
+ try {
2029
+ Intl.getCanonicalLocales(text);
2030
+ } catch {
2031
+ issues.push(`${path} is not a valid BCP-47 locale; using the host locale`);
2032
+ return;
2033
+ }
2034
+ return text;
2035
+ }
2036
+ function readTimestampZone(value, issues) {
2037
+ if (value === undefined)
2038
+ return;
2039
+ if (typeof value !== "string") {
2040
+ issues.push("format.timestamp.timeZone must be an IANA zone or UTC offset; using the host zone");
2041
+ return;
2042
+ }
2043
+ const path = "format.timestamp.timeZone";
2044
+ const text = normalizeText(value, path, issues).trim();
2045
+ if (text.length === 0)
2046
+ return;
2047
+ if (text.length > 64) {
2048
+ issues.push(`${path} was longer than 64 characters; using the host zone`);
2049
+ return;
2050
+ }
2051
+ try {
2052
+ new Intl.DateTimeFormat(undefined, { timeZone: text });
2053
+ } catch {
2054
+ issues.push(`${path} is not a valid IANA zone or UTC offset; using the host zone`);
2055
+ return;
2056
+ }
2057
+ return text;
2058
+ }
2059
+ function readTimestamp(value, issues) {
2060
+ if (value !== undefined && !isRecord(value)) {
2061
+ issues.push("format.timestamp must be an object; using the defaults");
2062
+ return DEFAULT_TIMESTAMP;
2063
+ }
2064
+ const section = isRecord(value) ? value : {};
2065
+ let dateStyle = readTimestampStyle(section["dateStyle"], ["none", "short", "medium"], DEFAULT_TIMESTAMP.dateStyle, "format.timestamp.dateStyle", issues);
2066
+ let timeStyle = readTimestampStyle(section["timeStyle"], ["none", "short", "medium"], DEFAULT_TIMESTAMP.timeStyle, "format.timestamp.timeStyle", issues);
2067
+ if (dateStyle === "none" && timeStyle === "none") {
2068
+ issues.push('format.timestamp.dateStyle and timeStyle are both "none"; using the default presentation');
2069
+ dateStyle = DEFAULT_TIMESTAMP.dateStyle;
2070
+ timeStyle = DEFAULT_TIMESTAMP.timeStyle;
2071
+ }
2072
+ const timestamp = { dateStyle, timeStyle };
2073
+ const locale = readTimestampLocale(section["locale"], issues);
2074
+ if (locale !== undefined)
2075
+ timestamp.locale = locale;
2076
+ const hour12 = readHour12(section["hour12"], issues);
2077
+ if (hour12 !== undefined)
2078
+ timestamp.hour12 = hour12;
2079
+ const timeZone = readTimestampZone(section["timeZone"], issues);
2080
+ if (timeZone !== undefined)
2081
+ timestamp.timeZone = timeZone;
2082
+ return timestamp;
2083
+ }
1945
2084
  function readFormat(section, issues) {
1946
- return { duration: readDurationStyle(section["duration"], issues) };
2085
+ return {
2086
+ duration: readDurationStyle(section["duration"], issues),
2087
+ timestamp: readTimestamp(section["timestamp"], issues)
2088
+ };
1947
2089
  }
1948
2090
  function readGlyph(value, fallback, path, issues) {
1949
2091
  if (value === undefined)
@@ -2304,6 +2446,7 @@ function railLines(config, source = {}) {
2304
2446
  persist: config.sidebar.persist,
2305
2447
  placeholder: config.sidebar.placeholder,
2306
2448
  durationStyle: config.format.duration,
2449
+ timestamp: config.format.timestamp,
2307
2450
  tpsDisplay: config.sidebar.tps.display,
2308
2451
  hasTotalRow: config.sidebar.rows.includes("total")
2309
2452
  };
@@ -3535,59 +3678,263 @@ function createSessionReads(context) {
3535
3678
  return [];
3536
3679
  }
3537
3680
  };
3538
- const isFamilyRoot = (sessionID) => {
3681
+ const emptyTokens = () => ({
3682
+ input: 0,
3683
+ output: 0,
3684
+ reasoning: 0,
3685
+ cache: { read: 0, write: 0 }
3686
+ });
3687
+ const readTokens = (source) => {
3688
+ const record = asRecord2(source);
3689
+ const tokens = emptyTokens();
3690
+ if (record === undefined)
3691
+ return tokens;
3692
+ tokens.input = asCount2(record["input"]) ?? 0;
3693
+ tokens.output = asCount2(record["output"]) ?? 0;
3694
+ tokens.reasoning = asCount2(record["reasoning"]) ?? 0;
3695
+ const cache = asRecord2(record["cache"]);
3696
+ tokens.cache.read = asCount2(cache?.["read"]) ?? 0;
3697
+ tokens.cache.write = asCount2(cache?.["write"]) ?? 0;
3698
+ return tokens;
3699
+ };
3700
+ const modelKeyOf = (model) => {
3701
+ const ref = asRecord2(model);
3702
+ const id = asText2(ref?.["id"]) ?? asText2(ref?.["modelID"]);
3703
+ if (id === undefined)
3704
+ return;
3705
+ const provider = asText2(ref?.["providerID"]);
3706
+ return provider === undefined ? id : `${provider}/${id}`;
3707
+ };
3708
+ const PRICE_PER_UNIT = 1e6;
3709
+ let pricedFrom;
3710
+ let priceIndex = new Map;
3711
+ const priceKey = (id, providerID) => providerID === undefined ? id : `${providerID}/${id}`;
3712
+ const readPrice = (source) => {
3713
+ const record = asRecord2(source);
3714
+ if (record === undefined)
3715
+ return;
3716
+ const input = asCount2(record["input"]);
3717
+ const output = asCount2(record["output"]);
3718
+ if (input === undefined || output === undefined)
3719
+ return;
3720
+ const cache = asRecord2(record["cache"]);
3721
+ return {
3722
+ input,
3723
+ output,
3724
+ reasoning: output,
3725
+ cache: {
3726
+ read: asCount2(cache?.["read"]) ?? input,
3727
+ write: asCount2(cache?.["write"]) ?? input
3728
+ }
3729
+ };
3730
+ };
3731
+ const prices = () => {
3732
+ let entries = [];
3539
3733
  try {
3540
- return context.data.session.root(sessionID) === sessionID;
3734
+ entries = context.data.location.model.list(locationOf(context)) ?? [];
3541
3735
  } catch {
3542
- return true;
3736
+ entries = [];
3737
+ }
3738
+ if (entries === pricedFrom)
3739
+ return priceIndex;
3740
+ pricedFrom = entries;
3741
+ priceIndex = new Map;
3742
+ for (const entry of entries) {
3743
+ const record = asRecord2(entry);
3744
+ if (record === undefined)
3745
+ continue;
3746
+ const id = asText2(record["id"]) ?? asText2(record["modelID"]);
3747
+ if (id === undefined)
3748
+ continue;
3749
+ const tiers = [];
3750
+ const cost = record["cost"];
3751
+ const rows = Array.isArray(cost) ? cost : [cost];
3752
+ for (const row of rows) {
3753
+ const price = readPrice(row);
3754
+ if (price === undefined)
3755
+ continue;
3756
+ const tier = asRecord2(asRecord2(row)?.["tier"]);
3757
+ tiers.push({ size: asCount2(tier?.["size"]) ?? 0, price });
3758
+ }
3759
+ if (tiers.length === 0)
3760
+ continue;
3761
+ tiers.sort((left, right) => left.size - right.size);
3762
+ priceIndex.set(priceKey(id, asText2(record["providerID"])), tiers);
3543
3763
  }
3764
+ return priceIndex;
3544
3765
  };
3545
- const treeTotals = (sessionID, ownCost) => {
3546
- if (!isFamilyRoot(sessionID))
3766
+ const catalogCost = (tokens, model) => {
3767
+ const ref = asRecord2(model);
3768
+ const id = asText2(ref?.["id"]) ?? asText2(ref?.["modelID"]);
3769
+ if (id === undefined)
3770
+ return 0;
3771
+ const index = prices();
3772
+ const tiers = index.get(priceKey(id, asText2(ref?.["providerID"]))) ?? index.get(id);
3773
+ if (tiers === undefined || tiers.length === 0)
3774
+ return 0;
3775
+ const prompt = tokens.input + tokens.cache.read + tokens.cache.write;
3776
+ let chosen = tiers[0];
3777
+ for (const tier of tiers)
3778
+ if (tier.size <= prompt)
3779
+ chosen = tier;
3780
+ const price = chosen?.price;
3781
+ if (price === undefined)
3782
+ return 0;
3783
+ const micro = tokens.input * price.input + tokens.output * price.output + tokens.reasoning * price.reasoning + tokens.cache.read * price.cache.read + tokens.cache.write * price.cache.write;
3784
+ return micro / PRICE_PER_UNIT;
3785
+ };
3786
+ const sessionCost = (sessionID, record) => {
3787
+ if (record === undefined)
3547
3788
  return;
3548
- let ids;
3789
+ const messages = messagesOf(sessionID);
3790
+ const model = modelKeyOf(record?.model);
3791
+ const created = asCount2(asRecord2(record?.time)?.["created"]) ?? 0;
3792
+ let cost = 0;
3793
+ let counted = 0;
3794
+ let estimated = false;
3795
+ for (const entry of messages) {
3796
+ const message = asRecord2(entry);
3797
+ if (message?.["type"] !== "assistant")
3798
+ continue;
3799
+ const stamp = asCount2(asRecord2(message["time"])?.["created"]);
3800
+ if (stamp !== undefined && stamp < created)
3801
+ continue;
3802
+ if (model !== undefined && modelKeyOf(message["model"]) !== model)
3803
+ continue;
3804
+ const recorded = asCount2(message["cost"]);
3805
+ const stepTokens = asRecord2(message["tokens"]);
3806
+ if (recorded === undefined && stepTokens === undefined)
3807
+ continue;
3808
+ counted += 1;
3809
+ if (recorded !== undefined && recorded > 0) {
3810
+ cost += recorded;
3811
+ } else {
3812
+ cost += catalogCost(readTokens(stepTokens), message["model"]);
3813
+ estimated = true;
3814
+ }
3815
+ }
3816
+ if (counted === 0)
3817
+ return;
3818
+ return { cost, kind: estimated ? "estimated" : "bounded" };
3819
+ };
3820
+ const hostFamilyCost = (sessionID) => {
3549
3821
  try {
3550
- ids = context.data.session.family(sessionID) ?? [sessionID];
3822
+ const accessor = context.data.session.cost;
3823
+ if (typeof accessor !== "function")
3824
+ return;
3825
+ return asCount2(accessor.call(context.data.session, sessionID));
3551
3826
  } catch {
3552
3827
  return;
3553
3828
  }
3554
- let own;
3829
+ };
3830
+ const treeTotals = (sessionID) => {
3831
+ let root = sessionID;
3555
3832
  try {
3556
- own = context.data.session.get(sessionID);
3833
+ root = context.data.session.root(sessionID) ?? sessionID;
3557
3834
  } catch {
3558
- own = undefined;
3559
- }
3560
- const tokens = { input: 0, output: 0, reasoning: 0, cache: { read: 0, write: 0 } };
3561
- const addTokens = (source) => {
3562
- const record = asRecord2(source?.tokens);
3563
- tokens.input += asCount2(record?.["input"]) ?? 0;
3564
- tokens.output += asCount2(record?.["output"]) ?? 0;
3565
- tokens.reasoning += asCount2(record?.["reasoning"]) ?? 0;
3566
- const cache = asRecord2(record?.["cache"]);
3567
- tokens.cache.read += asCount2(cache?.["read"]) ?? 0;
3568
- tokens.cache.write += asCount2(cache?.["write"]) ?? 0;
3835
+ root = sessionID;
3836
+ }
3837
+ let ids;
3838
+ try {
3839
+ ids = context.data.session.family(root) ?? [root];
3840
+ } catch {
3841
+ ids = [root];
3842
+ }
3843
+ const members = ids.includes(root) ? ids : [root, ...ids];
3844
+ const recordOf = (id) => {
3845
+ try {
3846
+ return context.data.session.get(id);
3847
+ } catch {
3848
+ return;
3849
+ }
3850
+ };
3851
+ const own = recordOf(root);
3852
+ if (own === undefined)
3853
+ return;
3854
+ const tokens = emptyTokens();
3855
+ const addTokens = (record) => {
3856
+ const read = readTokens(record?.tokens);
3857
+ tokens.input += read.input;
3858
+ tokens.output += read.output;
3859
+ tokens.reasoning += read.reasoning;
3860
+ tokens.cache.read += read.cache.read;
3861
+ tokens.cache.write += read.cache.write;
3569
3862
  };
3570
3863
  addTokens(own);
3571
- let cost = asCount2(ownCost) ?? 0;
3572
3864
  let count = 0;
3573
- for (const id of ids) {
3574
- if (id === sessionID)
3575
- continue;
3576
- let child;
3577
- try {
3578
- child = context.data.session.get(id);
3579
- } catch {
3865
+ for (const id of members) {
3866
+ if (id === root)
3580
3867
  continue;
3581
- }
3868
+ const child = recordOf(id);
3582
3869
  if (child === undefined)
3583
3870
  continue;
3584
3871
  count += 1;
3585
- cost += asCount2(child.cost) ?? 0;
3586
3872
  addTokens(child);
3587
3873
  }
3588
- if (ownCost === undefined && count === 0)
3589
- return;
3590
- return { cost, count, tokens };
3874
+ let visible = 0;
3875
+ let complete = true;
3876
+ for (const id of members) {
3877
+ const record = recordOf(id);
3878
+ if (record === undefined) {
3879
+ complete = false;
3880
+ continue;
3881
+ }
3882
+ const created = asCount2(asRecord2(record.time)?.["created"]) ?? 0;
3883
+ let charges = 0;
3884
+ for (const entry of messagesOf(id)) {
3885
+ const message = asRecord2(entry);
3886
+ if (message?.["type"] !== "assistant")
3887
+ continue;
3888
+ const stamp = asCount2(asRecord2(message["time"])?.["created"]);
3889
+ if (stamp !== undefined && stamp < created)
3890
+ continue;
3891
+ charges += asCount2(message["cost"]) ?? 0;
3892
+ }
3893
+ visible += Math.max(asCount2(record.cost) ?? 0, charges);
3894
+ }
3895
+ let rolled = hostFamilyCost(root);
3896
+ if (rolled === undefined) {
3897
+ let total = 0;
3898
+ for (const id of members)
3899
+ total += asCount2(recordOf(id)?.cost) ?? 0;
3900
+ rolled = total;
3901
+ }
3902
+ if (rolled > 0) {
3903
+ return {
3904
+ cost: rolled,
3905
+ count,
3906
+ tokens,
3907
+ kind: complete && rolled >= visible ? "exact" : "bounded"
3908
+ };
3909
+ }
3910
+ if (visible > 0)
3911
+ return { cost: visible, count, tokens, kind: "bounded" };
3912
+ if (!complete)
3913
+ return { cost: 0, count, tokens, kind: "bounded" };
3914
+ let priced = 0;
3915
+ for (const id of members) {
3916
+ const record = recordOf(id);
3917
+ if (record === undefined)
3918
+ continue;
3919
+ const created = asCount2(asRecord2(record.time)?.["created"]) ?? 0;
3920
+ const listed = messagesOf(id);
3921
+ let pricedHere = false;
3922
+ for (const entry of listed) {
3923
+ const message = asRecord2(entry);
3924
+ if (message?.["type"] !== "assistant")
3925
+ continue;
3926
+ const stamp = asCount2(asRecord2(message["time"])?.["created"]);
3927
+ if (stamp !== undefined && stamp < created)
3928
+ continue;
3929
+ priced += catalogCost(readTokens(message["tokens"]), message["model"]);
3930
+ pricedHere = true;
3931
+ }
3932
+ if (!pricedHere)
3933
+ priced += catalogCost(readTokens(record.tokens), record.model);
3934
+ }
3935
+ if (priced > 0)
3936
+ return { cost: priced, count, tokens, kind: "estimated" };
3937
+ return { cost: 0, count, tokens, kind: "exact" };
3591
3938
  };
3592
3939
  const contextUsage = (sessionID, model) => {
3593
3940
  const messages = messagesOf(sessionID);
@@ -3747,6 +4094,7 @@ function createSessionReads(context) {
3747
4094
  return {
3748
4095
  messagesOf,
3749
4096
  treeTotals,
4097
+ sessionCost,
3750
4098
  contextUsage,
3751
4099
  sessionElapsed,
3752
4100
  statusOf,
@@ -3971,6 +4319,7 @@ var tui_default = Plugin.define({
3971
4319
  const {
3972
4320
  messagesOf,
3973
4321
  treeTotals,
4322
+ sessionCost,
3974
4323
  contextUsage,
3975
4324
  sessionElapsed,
3976
4325
  statusOf,
@@ -4036,9 +4385,13 @@ var tui_default = Plugin.define({
4036
4385
  const isBusy = busy(sessionID);
4037
4386
  spinnerNeeded = wants("status") && isBusy === true;
4038
4387
  const turns = wants("turns") ? messagesOf(sessionID).filter((entry) => asRecord2(entry)?.["type"] === "user").length : undefined;
4039
- const tree = wants("cost") || wants("total") || wants("tokens") || wants("cache") || wants("reasoning") ? treeTotals(sessionID, session?.cost) : undefined;
4388
+ const wantsUsage = wants("cost") || wants("total") || wants("tokens") || wants("cache") || wants("reasoning");
4389
+ const ownCost = wantsUsage ? sessionCost(sessionID, session) : undefined;
4390
+ const tree = wantsUsage ? treeTotals(sessionID) : undefined;
4040
4391
  return {
4041
4392
  ...session,
4393
+ cost: ownCost?.cost,
4394
+ costKind: ownCost?.kind,
4042
4395
  tokens: tree?.tokens ?? session?.tokens,
4043
4396
  caution: wants("caution") ? announce(sessionID) : undefined,
4044
4397
  branch: wants("branch") ? branchOf(location) : undefined,
@@ -4051,6 +4404,7 @@ var tui_default = Plugin.define({
4051
4404
  tps: wants("tps") ? sessionTps(sessionID, session) : undefined,
4052
4405
  spark: wants("spark") ? sparkValues(sessionID) : undefined,
4053
4406
  elapsedMs: wants("elapsed") ? sessionElapsed(sessionID) : undefined,
4407
+ lastActionMs: wants("updated") ? lastActivity(sessionID) : undefined,
4054
4408
  turns,
4055
4409
  guard: bridge?.status,
4056
4410
  go: goBridge?.usage,
package/docs/GUIDE.md CHANGED
@@ -90,6 +90,7 @@ You configure one global file: `~/.config/opencode/flight-deck.jsonc`. The `.jso
90
90
  | `context` | Occupancy proxy (last request input plus cache read plus cache write), drawn as a `layout.barWidth`-cell gauge (10 by default) plus `~78%`, or `~N used` when no limit is known. The `~` is deliberate: this is an estimate. | yes |
91
91
  | `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 |
92
92
  | `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 |
93
+ | `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 |
93
94
  | `tps` | Session speed. Default `avg`: generation tokens (output plus reasoning) over the union of settled turns' `streamed − created` spans; idle gaps never billed. `rt`: realtime estimate from streaming deltas, zero while nothing generates. `both`: `106 rt · 41 avg`, plus `1.2s ttft` once a step settles. Scope `family` (default; open session plus subagents, overlapping spans merged) or `session`. Below half a token per second no figure is drawn; with `persist: true` the row falls back to its `0 tok/s` skeleton, and `persist: false` omits it. | yes |
94
95
  | `spark` | Recent turn sizes as a sparkline; the newest samples are kept. | opt-in |
95
96
  | `reasoning` | Reasoning tokens, family scope. | opt-in |
@@ -99,7 +100,7 @@ You configure one global file: `~/.config/opencode/flight-deck.jsonc`. The `.jso
99
100
  | `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 |
100
101
  | `session` | Alias for `ses`; accepted in `sidebar.rows` and folded to it. | opt-in |
101
102
 
102
- With `sidebar.persist` (the default) every named row renders, drawing its zero skeleton until data arrives: `$0.000` money rows, `0 in · 0 out`, `0 read`, empty gauge plus `~0%`, `0 waiting`, `0s`, `0 tok/s` (`0 rt · 0 avg` in both), flat `▁` spark, `0` reasoning and turns, `○ 0 ○ 0 ○ 0` go, `○ idle`, `none` agent, model, and ses, `no branch`, `unknown` guard. `caution` never draws a skeleton. Set `persist: false` to omit rows with no data instead.
103
+ With `sidebar.persist` (the default) every named row renders, drawing its zero skeleton until data arrives: `$0.000` money rows, `0 in · 0 out`, `0 read`, empty gauge plus `~0%`, `0 waiting`, `0s`, `0 tok/s` (`0 rt · 0 avg` in both), flat `▁` spark, `0` reasoning and turns, `○ 0 ○ 0 ○ 0` go, `○ idle`, `none` agent, model, and ses, `no branch`, `unknown` guard. `caution` never draws a skeleton, and `updated` has none either: it draws `sidebar.placeholder` (`—`) until the host records an action, because there is no honest zero timestamp. Set `persist: false` to omit rows with no data instead.
103
104
 
104
105
  ### Settings
105
106
 
@@ -115,7 +116,7 @@ With `sidebar.persist` (the default) every named row renders, drawing its zero s
115
116
  - **`sidebar.footer.lines`** (default `[]`) — fixed lines in the host footer slot, outside the rail cap; max 24. The documented branding pair is `["▸ FLIGHT DECK","─────────────────"]`.
116
117
  - **`sidebar.footer.go`** (default `false`) — `true` or an object draws the live Go usage panel: three fixed-width lines above the host location row, sharing one account-wide poll with the `go` row. Object keys: `header` (`false`), `barWidth` (`10`, 1–40), `labelWidth` (`6`, 5–24, auto-widens), `percent` (`true`), `reset` (`true`), `align` (`"right"`, left, right, or center), `sweep` (`false`), `labels` (`{rolling,weekly,monthly}`, each 1–24 chars), `blink` (`true`), `blinkMs` (`700`, 200–5000).
117
118
  - **`sidebar.persist`** (default `true`) — every named row renders, drawing its zero skeleton until data arrives; `false` omits rows with no data.
118
- - **`sidebar.placeholder`** (default `"—"`) — non-empty string; only for a data-less row with no skeleton, unreachable for shipped fields.
119
+ - **`sidebar.placeholder`** (default `"—"`) — 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.
119
120
  - **`sidebar.maxLines`** (default `24`) — whole rail, fixed lines plus rows, 1–24.
120
121
  - **`sidebar.tps.scope`** (default `"family"`) — `"family"` paces the open session plus subagents; `"session"` paces the open session alone.
121
122
  - **`sidebar.tps.display`** (default `"avg"`) — `"avg"` settled-turn average, `"rt"` realtime estimate, `"both"` both figures plus ttft.
@@ -153,6 +154,11 @@ With `sidebar.persist` (the default) every named row renders, drawing its zero s
153
154
  **Format**
154
155
 
155
156
  - **`format.duration`** (default `"spaced"`, `2h 14m 37s`) — or `"compact"` (`2h14m37s`). Zero-padding is the same either way (`14m 07s`, never `14m 7s`).
157
+ - **`format.timestamp.locale`** (default the host locale) — BCP-47 locale for the `updated` row, for example `"en-GB"`. A malformed locale is reported and the host locale is used.
158
+ - **`format.timestamp.dateStyle`** (default `"short"`) — `"short"` (locale numeric date), `"medium"` (spelled month, wider), or `"none"` (time only).
159
+ - **`format.timestamp.timeStyle`** (default `"medium"`) — `"medium"` keeps seconds, `"short"` drops them, `"none"` leaves a date-only row. Both halves cannot be `"none"`: the pair falls back to the defaults with a warning.
160
+ - **`format.timestamp.hour12`** (default: the locale's own clock) — `true` forces `2:32:07 PM`, `false` forces `14:32:07`.
161
+ - **`format.timestamp.timeZone`** (default the host zone) — an IANA name (`"Asia/Tokyo"`) or UTC offset (`"+05:30"`). Omit it to follow the host through daylight-saving changes; a Windows zone id is not valid and is reported, with the host zone used.
156
162
 
157
163
  **Glyphs**
158
164