@linxiraos/pi-tui 1.4.7 → 1.4.9

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.
Files changed (172) hide show
  1. package/CHANGELOG.md +28 -109
  2. package/README.md +7 -1
  3. package/dist/types/app-keybindings.d.ts +5 -0
  4. package/dist/types/charts/table-data.d.ts +4 -2
  5. package/dist/types/chat/bash-execution.d.ts +4 -1
  6. package/dist/types/chat/eval-execution.d.ts +2 -0
  7. package/dist/types/chat/execution-shared.d.ts +14 -8
  8. package/dist/types/chat/figure-markdown.d.ts +2 -0
  9. package/dist/types/chat/svg-figure.d.ts +5 -0
  10. package/dist/types/chat/table-chart.d.ts +2 -0
  11. package/dist/types/chat/transcript-render-helpers.d.ts +11 -3
  12. package/dist/types/chrome/dynamic-border.d.ts +6 -0
  13. package/dist/types/chrome/transcript-status.d.ts +2 -2
  14. package/dist/types/components/editor.d.ts +15 -6
  15. package/dist/types/components/image.d.ts +6 -0
  16. package/dist/types/components/loader.d.ts +2 -0
  17. package/dist/types/keybinding-matchers.d.ts +7 -0
  18. package/dist/types/native/describe.d.ts +4 -2
  19. package/dist/types/native/node.d.ts +2 -3
  20. package/dist/types/native/overlay.d.ts +42 -2
  21. package/dist/types/native/state.d.ts +4 -0
  22. package/dist/types/overlays/btw-history-panel.d.ts +15 -0
  23. package/dist/types/overlays/btw-history.d.ts +24 -0
  24. package/dist/types/overlays/btw-inject.d.ts +22 -0
  25. package/dist/types/overlays/btw-panel.d.ts +7 -0
  26. package/dist/types/overlays/hook-editor.d.ts +2 -0
  27. package/dist/types/overlays/jobs-panel.d.ts +4 -0
  28. package/dist/types/overlays/model-browser.d.ts +1 -1
  29. package/dist/types/overlays/session-selector.d.ts +11 -2
  30. package/dist/types/prompt/composer.d.ts +13 -5
  31. package/dist/types/render/render-utils.d.ts +23 -1
  32. package/dist/types/status-line/startup.d.ts +0 -15
  33. package/dist/types/terminal-capabilities.d.ts +1 -1
  34. package/dist/types/theme/symbols.d.ts +3 -1
  35. package/dist/types/theme/theme-class.d.ts +1 -0
  36. package/dist/types/theme/theme.d.ts +1 -1
  37. package/dist/types/theme/tui-adapters.d.ts +2 -0
  38. package/dist/types/thinking.d.ts +8 -6
  39. package/dist/types/tools/ast-grep.d.ts +2 -0
  40. package/dist/types/tools/eval.d.ts +2 -0
  41. package/dist/types/tools/find.d.ts +1 -1
  42. package/dist/types/tools/grouped-file-output.d.ts +100 -19
  43. package/dist/types/tools/hashline-format.d.ts +5 -0
  44. package/dist/types/tools/native-view.d.ts +2 -0
  45. package/dist/types/tools/output-meta.d.ts +27 -0
  46. package/dist/types/tools/read.d.ts +14 -4
  47. package/dist/types/tools/task.d.ts +4 -3
  48. package/dist/types/tools/wait.d.ts +2 -0
  49. package/dist/types/tui.d.ts +12 -0
  50. package/dist/types/utils.d.ts +4 -0
  51. package/package.json +9 -9
  52. package/src/app-keybindings.d.ts +5 -0
  53. package/src/app-keybindings.ts +5 -0
  54. package/src/apps/git/git-tui.ts +10 -17
  55. package/src/apps/git/sidebar.ts +21 -35
  56. package/src/apps/ps-top.ts +4 -12
  57. package/src/charts/chart-plan.ts +0 -29
  58. package/src/charts/table-data.d.ts +4 -2
  59. package/src/charts/table-data.ts +55 -6
  60. package/src/chat/bash-execution.d.ts +4 -1
  61. package/src/chat/bash-execution.ts +20 -9
  62. package/src/chat/chat-transcript-builder.ts +5 -2
  63. package/src/chat/eval-execution.d.ts +2 -0
  64. package/src/chat/eval-execution.ts +14 -7
  65. package/src/chat/execution-shared.d.ts +14 -8
  66. package/src/chat/execution-shared.ts +39 -18
  67. package/src/chat/figure-markdown.d.ts +2 -0
  68. package/src/chat/figure-markdown.ts +6 -4
  69. package/src/chat/read-tool-group.ts +56 -36
  70. package/src/chat/svg-figure.d.ts +5 -0
  71. package/src/chat/svg-figure.ts +55 -16
  72. package/src/chat/table-chart.d.ts +2 -0
  73. package/src/chat/table-chart.ts +19 -2
  74. package/src/chat/transcript-render-helpers.d.ts +11 -3
  75. package/src/chat/transcript-render-helpers.ts +70 -22
  76. package/src/chrome/dynamic-border.d.ts +6 -0
  77. package/src/chrome/dynamic-border.ts +28 -2
  78. package/src/chrome/transcript-status.d.ts +2 -2
  79. package/src/chrome/transcript-status.ts +5 -3
  80. package/src/components/editor.d.ts +15 -6
  81. package/src/components/editor.ts +123 -24
  82. package/src/components/image.d.ts +6 -0
  83. package/src/components/image.ts +13 -0
  84. package/src/components/key-value-list.ts +9 -9
  85. package/src/components/loader.d.ts +2 -0
  86. package/src/components/loader.ts +7 -0
  87. package/src/components/section.ts +1 -9
  88. package/src/components/table.ts +1 -9
  89. package/src/keybinding-matchers.d.ts +7 -0
  90. package/src/keybinding-matchers.ts +13 -0
  91. package/src/native/backend.ts +7 -3
  92. package/src/native/describe.d.ts +4 -2
  93. package/src/native/describe.ts +9 -4
  94. package/src/native/node.d.ts +2 -3
  95. package/src/native/node.ts +2 -3
  96. package/src/native/overlay.d.ts +42 -2
  97. package/src/native/overlay.ts +124 -16
  98. package/src/native/state.d.ts +4 -0
  99. package/src/native/state.ts +25 -5
  100. package/src/overlays/btw-history-panel.ts +106 -14
  101. package/src/overlays/btw-history.ts +65 -0
  102. package/src/overlays/btw-inject.ts +91 -0
  103. package/src/overlays/btw-panel.ts +53 -12
  104. package/src/overlays/extensions/extension-dashboard.ts +7 -8
  105. package/src/overlays/hook-editor.ts +6 -0
  106. package/src/overlays/jobs-panel.ts +82 -22
  107. package/src/overlays/login-dialog.ts +8 -26
  108. package/src/overlays/model-browser.ts +69 -10
  109. package/src/overlays/session-selector.ts +25 -5
  110. package/src/overlays/settings-defs.ts +2 -2
  111. package/src/overlays/tree-selector.ts +83 -27
  112. package/src/overlays/usage-dashboard.ts +4 -6
  113. package/src/prompt/composer.ts +17 -5
  114. package/src/render/code-cell.ts +1 -1
  115. package/src/render/file-list.ts +4 -7
  116. package/src/render/render-utils.d.ts +23 -1
  117. package/src/render/render-utils.ts +38 -6
  118. package/src/setup/scenes/glyph.ts +1 -1
  119. package/src/status-line/startup.ts +36 -70
  120. package/src/terminal-capabilities.d.ts +1 -1
  121. package/src/terminal-capabilities.ts +5 -0
  122. package/src/theme/symbols.d.ts +3 -1
  123. package/src/theme/symbols.ts +16 -9
  124. package/src/theme/theme-class.d.ts +1 -0
  125. package/src/theme/theme-class.ts +15 -3
  126. package/src/theme/theme.d.ts +1 -1
  127. package/src/theme/theme.ts +1 -0
  128. package/src/theme/tui-adapters.d.ts +2 -0
  129. package/src/theme/tui-adapters.ts +8 -3
  130. package/src/thinking.d.ts +8 -6
  131. package/src/thinking.ts +17 -11
  132. package/src/tmux.ts +1 -0
  133. package/src/tools/agent-tree.ts +13 -11
  134. package/src/tools/ask.ts +24 -37
  135. package/src/tools/ast-edit.ts +48 -93
  136. package/src/tools/ast-grep.d.ts +2 -0
  137. package/src/tools/ast-grep.ts +31 -67
  138. package/src/tools/bash.ts +7 -0
  139. package/src/tools/default-renderer.ts +1 -1
  140. package/src/tools/edit.ts +50 -43
  141. package/src/tools/eval.d.ts +2 -0
  142. package/src/tools/eval.ts +2 -0
  143. package/src/tools/fetch.ts +2 -1
  144. package/src/tools/find.d.ts +1 -1
  145. package/src/tools/find.ts +13 -5
  146. package/src/tools/github.ts +14 -46
  147. package/src/tools/glob.ts +2 -1
  148. package/src/tools/grep.ts +47 -277
  149. package/src/tools/grouped-file-output.d.ts +100 -19
  150. package/src/tools/grouped-file-output.ts +414 -103
  151. package/src/tools/hashline-format.d.ts +5 -0
  152. package/src/tools/hashline-format.ts +5 -0
  153. package/src/tools/json-tree.ts +1 -5
  154. package/src/tools/lsp.ts +210 -32
  155. package/src/tools/native-view.d.ts +2 -0
  156. package/src/tools/native-view.ts +11 -5
  157. package/src/tools/output-meta.d.ts +27 -0
  158. package/src/tools/output-meta.ts +68 -4
  159. package/src/tools/proc-render.ts +3 -3
  160. package/src/tools/read.d.ts +14 -4
  161. package/src/tools/read.ts +20 -5
  162. package/src/tools/task.d.ts +4 -3
  163. package/src/tools/task.ts +41 -81
  164. package/src/tools/vibe.ts +4 -4
  165. package/src/tools/wait.d.ts +2 -0
  166. package/src/tools/wait.ts +8 -5
  167. package/src/tools/write.ts +17 -27
  168. package/src/tools/yield.ts +1 -1
  169. package/src/tui.d.ts +12 -0
  170. package/src/tui.ts +91 -9
  171. package/src/utils.d.ts +4 -0
  172. package/src/utils.ts +10 -0
@@ -10,7 +10,12 @@
10
10
  import { ThinkingLevel } from "@linxiraos/pi-agent-core";
11
11
  import type { Model } from "@linxiraos/pi-ai";
12
12
  import { buildModel } from "@linxiraos/pi-catalog/build";
13
- import { getEffectiveTokenCost, getModelPricingStatus, modelsAreEqual } from "@linxiraos/pi-catalog/models";
13
+ import {
14
+ getEffectiveTokenCost,
15
+ getFactoryDroidCreditRate,
16
+ getModelPricingStatus,
17
+ modelsAreEqual,
18
+ } from "@linxiraos/pi-catalog/models";
14
19
  import { modelKind, type ModelKind, type ModelPricingStatus } from "@linxiraos/pi-catalog/types";
15
20
  import type { Component } from "../tui";
16
21
  import { FuzzyCorpus, fuzzyRank } from "../fuzzy";
@@ -69,7 +74,8 @@ export type ModelRole =
69
74
  | "web"
70
75
  | "speech"
71
76
  | "dictation"
72
- | "judge";
77
+ | "judge"
78
+ | "taste";
73
79
  export const MODEL_ROLE_IDS: ModelRole[] = [
74
80
  "default",
75
81
  "smol",
@@ -87,6 +93,7 @@ export const MODEL_ROLE_IDS: ModelRole[] = [
87
93
  "speech",
88
94
  "dictation",
89
95
  "judge",
96
+ "taste",
90
97
  ];
91
98
  export const CHAT_MODEL_ROLE_IDS: ModelRole[] = [
92
99
  "default",
@@ -101,7 +108,7 @@ export const CHAT_MODEL_ROLE_IDS: ModelRole[] = [
101
108
  "advisor",
102
109
  "widget",
103
110
  ];
104
- export const KIND_ROLE_IDS: ModelRole[] = ["image", "web", "speech", "dictation", "judge"];
111
+ export const KIND_ROLE_IDS: ModelRole[] = ["image", "web", "speech", "dictation", "judge", "taste"];
105
112
 
106
113
  /** Measured model performance shown in browser rows. */
107
114
  export interface ModelBrowserPerf {
@@ -747,7 +754,7 @@ function isFreeModel(model: Model): boolean {
747
754
  const declared = declaredPricingStatus(model);
748
755
  if (declared !== undefined) return declared === "free";
749
756
  const cost = model.cost ? getEffectiveTokenCost(model.cost) : undefined;
750
- const credits = model.factoryDroidCredits;
757
+ const credits = getFactoryDroidCreditRate(model)?.rate;
751
758
  return (!cost || (cost.input === 0 && cost.output === 0)) && (credits === undefined || credits === 0);
752
759
  }
753
760
 
@@ -761,15 +768,22 @@ function formatCostLeg(n: number): string {
761
768
  return s.includes(".") ? s.replace(/\.?0+$/, "") : s;
762
769
  }
763
770
 
771
+ /** `2× from 2026-11-22` when a dated Factory Droid credit card changes the rate in force now; undefined otherwise. */
772
+ function nextCreditRateNote(model: Model): string | undefined {
773
+ const next = getFactoryDroidCreditRate(model)?.next;
774
+ return next ? `${formatCostLeg(next.rate)}× from ${new Date(next.at).toISOString().slice(0, 10)}` : undefined;
775
+ }
776
+
764
777
  /**
765
- * Adds Factory Droid's `N×` base Standard Credits rate to a dollar price,
766
- * replacing the price when the model has no dollar reference. Neither the
767
- * reference price nor the base credit rate includes live promotions.
778
+ * Adds Factory Droid's `N×` Standard Credits rate in force now (its dated
779
+ * `credit-rates` card applied) to a dollar price, replacing the price when the
780
+ * model has no dollar reference. The dollar reference never includes vendor
781
+ * promotions; the preview and detail facts name the next rate (`nextCreditRateNote`).
768
782
  */
769
783
  function withCreditBadge(model: Model, price: string): string {
770
- const credits = model.factoryDroidCredits;
784
+ const credits = getFactoryDroidCreditRate(model);
771
785
  if (credits === undefined) return price;
772
- const badge = `${formatCostLeg(credits)}×`;
786
+ const badge = `${formatCostLeg(credits.rate)}×`;
773
787
  const cost = getEffectiveTokenCost(model.cost);
774
788
  return cost.input !== 0 || cost.output !== 0 ? `${price} ${badge}` : badge;
775
789
  }
@@ -820,7 +834,9 @@ function previewPrice(model: Model): string {
820
834
  const cost = getEffectiveTokenCost(model.cost);
821
835
  const parts = [`$${formatCostLeg(cost.input)} in`, `$${formatCostLeg(cost.output)} out`];
822
836
  if (cost.cacheRead > 0) parts.push(`$${formatCostLeg(cost.cacheRead)} cache`);
823
- return withCreditBadge(model, parts.join(" · "));
837
+ const priced = withCreditBadge(model, parts.join(" · "));
838
+ const note = nextCreditRateNote(model);
839
+ return note ? `${priced} (${note})` : priced;
824
840
  }
825
841
 
826
842
  /**
@@ -1025,6 +1041,8 @@ export class ModelBrowser implements Component {
1025
1041
  | undefined;
1026
1042
  /** Theme-formatted catalog metric cells per item; rebuilt when the item's model or the theme changes. */
1027
1043
  #metricCells = new WeakMap<ModelBrowserItem, MetricCells>();
1044
+ /** Earliest dated credit-rate change among models whose rows are memoized; passing it rebuilds them. */
1045
+ #nextCreditChange = Number.POSITIVE_INFINITY;
1028
1046
  /** Non-separator items of the last ranked visible list, for {@link queryMatches}. */
1029
1047
  #queryMatches: { visible: readonly ModelBrowserItem[]; matches: readonly ModelBrowserItem[] } | undefined;
1030
1048
  #hoveredIndex: number | null = null;
@@ -1116,6 +1134,7 @@ export class ModelBrowser implements Component {
1116
1134
 
1117
1135
  /** Replace the scope's base items; the live query re-applies and selection is pinned by selector. */
1118
1136
  setItems(items: ModelBrowserItem[]): void {
1137
+ for (const item of items) this.#noteCreditChange(item.model);
1119
1138
  const selectedKey = this.getSelected()?.selector;
1120
1139
  this.#menu.setItems(this.#insertSeparator(items), selectedKey);
1121
1140
  this.onSelectionChange?.(this.getSelected());
@@ -1511,6 +1530,7 @@ export class ModelBrowser implements Component {
1511
1530
  #metricCellsFor(item: ModelBrowserItem): MetricCells {
1512
1531
  const cached = this.#metricCells.get(item);
1513
1532
  if (cached?.model === item.model && cached.theme === theme) return cached;
1533
+ this.#noteCreditChange(item.model);
1514
1534
  const intelligence = formatIntelligence(item.model);
1515
1535
  const ctx = formatContext(item.model);
1516
1536
  const cost = formatCostPair(item.model);
@@ -1627,6 +1647,9 @@ export class ModelBrowser implements Component {
1627
1647
  } else if (model.tps != null && Number.isFinite(model.tps) && model.tps > 0) {
1628
1648
  facts.push(`~${formatTps(model.tps)}`);
1629
1649
  }
1650
+ // Last fact before prose, so narrow widths cut it before capability and perf facts.
1651
+ const nextCredits = nextCreditRateNote(model);
1652
+ if (nextCredits) facts.push(nextCredits);
1630
1653
  if (model.description) {
1631
1654
  const description = formatDescription(model.description);
1632
1655
  if (description) facts.push(description);
@@ -1658,6 +1681,7 @@ export class ModelBrowser implements Component {
1658
1681
  }
1659
1682
 
1660
1683
  render(width: number): string[] {
1684
+ this.#syncCreditClock();
1661
1685
  const lines: string[] = [];
1662
1686
 
1663
1687
  const searchIcon = theme.fg("accent", theme.symbol("icon.search"));
@@ -1749,6 +1773,30 @@ export class ModelBrowser implements Component {
1749
1773
 
1750
1774
  invalidate(): void {}
1751
1775
 
1776
+ /** Called for every listed model and before a row is memoized: its credit rate changes at its next dated card. */
1777
+ #noteCreditChange(model: Model): void {
1778
+ const at = getFactoryDroidCreditRate(model)?.next?.at;
1779
+ if (at !== undefined && at < this.#nextCreditChange) this.#nextCreditChange = at;
1780
+ }
1781
+
1782
+ /**
1783
+ * A dated credit rate took effect since rows were memoized: rebuild every
1784
+ * memoized row, and re-rank the list, whose `free` search word follows the
1785
+ * rate too.
1786
+ */
1787
+ #syncCreditClock(): void {
1788
+ if (Date.now() < this.#nextCreditChange) return;
1789
+ this.#nextCreditChange = Number.POSITIVE_INFINITY;
1790
+ this.#metricCells = new WeakMap();
1791
+ this.#pickerPreview = undefined;
1792
+ this.#bumpPickerEpoch();
1793
+ this.#ranker = undefined;
1794
+ this.#menu.setItems(this.#menu.items);
1795
+ for (const item of this.#menu.items) {
1796
+ if (item.id !== "separator") this.#noteCreditChange(item.model);
1797
+ }
1798
+ }
1799
+
1752
1800
  #bumpNativeEpoch(): void {
1753
1801
  this.#nativeEpoch++;
1754
1802
  this.#itemNodes.clear();
@@ -1767,6 +1815,7 @@ export class ModelBrowser implements Component {
1767
1815
  * scrolls), and the selection's facts and role chips.
1768
1816
  */
1769
1817
  describe(): NativeNode {
1818
+ this.#syncCreditClock();
1770
1819
  this.#nativeSearch ??= row([text([span(theme.symbol("icon.search"), "accent")]), this.#searchInput], {
1771
1820
  gap: "sm",
1772
1821
  align: "center",
@@ -1837,6 +1886,7 @@ export class ModelBrowser implements Component {
1837
1886
  if (item.id === "separator") return node("rule", undefined, undefined, "separator");
1838
1887
  const cached = this.#itemNodes.get(item.selector);
1839
1888
  if (cached?.item === item) return cached.node;
1889
+ this.#noteCreditChange(item.model);
1840
1890
 
1841
1891
  const label: TspSpan[] = [];
1842
1892
  if (this.#showProvider) label.push(span(`${item.provider}/`, "dim"));
@@ -1879,6 +1929,7 @@ export class ModelBrowser implements Component {
1879
1929
  return prev.node;
1880
1930
  }
1881
1931
 
1932
+ if (selected) this.#noteCreditChange(selected.model);
1882
1933
  const children: NativeChild[] = [];
1883
1934
  if (selected) {
1884
1935
  const model = selected.model;
@@ -1903,6 +1954,8 @@ export class ModelBrowser implements Component {
1903
1954
  } else if (model.tps != null && Number.isFinite(model.tps) && model.tps > 0) {
1904
1955
  facts.push(`~${formatTps(model.tps)}`);
1905
1956
  }
1957
+ const nextCredits = nextCreditRateNote(model);
1958
+ if (nextCredits) facts.push(nextCredits);
1906
1959
  children.push(text([span(facts.join(" · "), "muted")], { wrap: "word" }));
1907
1960
  const description = model.description ? formatDescription(model.description) : "";
1908
1961
  if (description) children.push(text([span(description, "dim")], { wrap: "word", lines: 2 }));
@@ -1977,6 +2030,7 @@ export class ModelBrowser implements Component {
1977
2030
  * role moving) keeps the last whole `items` and patches it.
1978
2031
  */
1979
2032
  pickerItems(catalogue: readonly ModelBrowserItem[]): ModelPickerCatalogue {
2033
+ this.#syncCreditClock();
1980
2034
  const memo = this.#pickerItems;
1981
2035
  if (memo?.catalogue === catalogue && memo.epoch === this.#pickerEpoch && memo.roles === this.#roles) {
1982
2036
  return memo.value;
@@ -2028,6 +2082,7 @@ export class ModelBrowser implements Component {
2028
2082
  ) {
2029
2083
  return cached.value;
2030
2084
  }
2085
+ this.#noteCreditChange(model);
2031
2086
  const facts: Record<string, TspText | number> = {};
2032
2087
  const int = model.int != null && Number.isFinite(model.int) ? model.int : undefined;
2033
2088
  if (int !== undefined) facts.int = String(Math.round(int));
@@ -2174,6 +2229,7 @@ export class ModelBrowser implements Component {
2174
2229
  * below the list): one inline fact line and the held-role chips.
2175
2230
  */
2176
2231
  pickerPreview(mode: "full" | "compact", current?: string): readonly NativeChild[] {
2232
+ this.#syncCreditClock();
2177
2233
  const selected = this.getSelected();
2178
2234
  const item = selected && !this.#isDisabled(selected) ? selected : undefined;
2179
2235
  const key = `${mode}\0${current ?? ""}\0${this.#settings.revision}`;
@@ -2187,6 +2243,7 @@ export class ModelBrowser implements Component {
2187
2243
  ) {
2188
2244
  return memo.children;
2189
2245
  }
2246
+ if (item) this.#noteCreditChange(item.model);
2190
2247
  const children = item ? this.modelPreview(item, mode, current) : [];
2191
2248
  this.#pickerPreview = { item, epoch: this.#pickerEpoch, roles: this.#roles, key, children };
2192
2249
  return children;
@@ -2232,6 +2289,8 @@ export class ModelBrowser implements Component {
2232
2289
  if (ctx > 0) facts.push({ k: "ctx", v: formatNumber(ctx).toLowerCase() });
2233
2290
  if (out > 0) facts.push({ k: "out", v: formatNumber(out).toLowerCase() });
2234
2291
  facts.push({ k: "price", v: isFreeModel(model) ? "free" : formatCostDetail(model) });
2292
+ const nextCredits = nextCreditRateNote(model);
2293
+ if (nextCredits) facts.push({ k: "then", v: nextCredits });
2235
2294
  facts.push({ k: "reasoning", v: model.reasoning ? "yes" : "no" });
2236
2295
  const children: NativeChild[] = [node("kv", { items: facts, layout: "inline" })];
2237
2296
  const chips: NativeChild[] = [];
@@ -1485,10 +1485,15 @@ export interface SessionSelectorOptions<T extends SessionSelectorEntry = Session
1485
1485
  /** Persist the selected session's pin state (pin keys / the picker's Pin action). */
1486
1486
  onSetPinned?: (session: T, pinned: boolean) => Promise<void>;
1487
1487
  historyMatcher?: SessionHistoryMatcher;
1488
+ /**
1489
+ * Complete folder listing when the constructor's `sessions` are a preliminary
1490
+ * subset; replaces them once it settles.
1491
+ */
1492
+ completeSessions?: Promise<T[]>;
1488
1493
  /** Loads sessions across all projects for the all-projects scope toggle (Tab). */
1489
- loadAllSessions?: () => Promise<T[]>;
1494
+ loadAllSessions?: () => Promise<T[] | { sessions: T[] }>;
1490
1495
  /** Preloaded all-projects list; cached so the first Tab toggle is instant. */
1491
- allSessions?: T[];
1496
+ allSessions?: T[] | { sessions: T[] };
1492
1497
  /**
1493
1498
  * The host's resume model (project → workspace → conversation) and its
1494
1499
  * pure view builder. When set, the native `picker` describes the resume
@@ -1601,7 +1606,7 @@ export class SessionSelectorComponent<T extends SessionSelectorEntry = SessionSe
1601
1606
  #onRename?: (session: T, title: string) => Promise<string | null>;
1602
1607
  #onSetPinned?: (session: T, pinned: boolean) => Promise<void>;
1603
1608
  #onRequestRender?: () => void;
1604
- readonly #loadAllSessions?: () => Promise<T[]>;
1609
+ readonly #loadAllSessions?: () => Promise<T[] | { sessions: T[] }>;
1605
1610
  #folderSessions: T[];
1606
1611
  readonly #folderShowCwd: boolean;
1607
1612
  #globalSessions: T[] | null = null;
@@ -1714,13 +1719,27 @@ export class SessionSelectorComponent<T extends SessionSelectorEntry = SessionSe
1714
1719
  // Storage directory, not recorded cwd: one folder's sessions may record
1715
1720
  // symlink aliases of the same path, which must not turn the column on.
1716
1721
  this.#folderShowCwd = options.showCwd ?? new Set(sessions.map(session => path.dirname(session.path))).size > 1;
1717
- this.#globalSessions = options.allSessions ?? null;
1722
+ this.#globalSessions = Array.isArray(options.allSessions)
1723
+ ? options.allSessions
1724
+ : (options.allSessions?.sessions ?? null);
1718
1725
  this.#getTerminalRows = options.getTerminalRows ?? (() => 24);
1719
1726
  this.#fillHeight = options.fillHeight ?? false;
1720
1727
  this.#title = options.title ?? tuiText("ssTitleResume", "Resume Session");
1721
1728
  this.#actionLabel = options.actionLabel ?? "Resume";
1722
1729
  this.#pickerTitle = options.title;
1723
1730
  this.#standalone = options.standalone ?? false;
1731
+ if (options.completeSessions) {
1732
+ void options.completeSessions.then(rows => {
1733
+ const next = rows.filter(row => !this.#resumeHidden.has(row.path));
1734
+ const selected = this.#sessionList.selectedSession?.path;
1735
+ this.#folderSessions = next;
1736
+ if (this.#scope === "folder") {
1737
+ this.#sessionList.setSessions(next, this.#folderShowCwd);
1738
+ if (selected) this.#sessionList.selectSession(selected);
1739
+ }
1740
+ this.#onRequestRender?.();
1741
+ });
1742
+ }
1724
1743
  this.#resumeSource = options.resumeSource;
1725
1744
  this.#resumeScope = options.resumeSource?.initialScope ?? "workspace";
1726
1745
  this.#deleteMode = options.deleteMode ?? options.resumeSource?.deleteMode ?? "permanent";
@@ -1852,7 +1871,8 @@ export class SessionSelectorComponent<T extends SessionSelectorEntry = SessionSe
1852
1871
  this.#message = { kind: "loading", text: loading };
1853
1872
  this.#onRequestRender?.();
1854
1873
  try {
1855
- global = await this.#loadAllSessions();
1874
+ const loaded = await this.#loadAllSessions();
1875
+ global = Array.isArray(loaded) ? loaded : loaded.sessions;
1856
1876
  } catch (err) {
1857
1877
  this.#showError(err instanceof Error ? err.message : String(err));
1858
1878
  this.#toggling = false;
@@ -116,7 +116,7 @@ export const TAB_LEADS: Record<SettingTab, string> = {
116
116
  */
117
117
  export const TAB_GROUPS: Record<SettingTab, readonly string[]> = {
118
118
  appearance: ["General", "Theme", "Composer", "Status Line", "Display", "Images"],
119
- model: ["Thinking", "Sampling", "Prompt", "Roles", "Retry & Fallback", "Advisor", "Prewalk", "Vision"],
119
+ model: ["Thinking", "Sampling", "Prompt", "Catalog", "Roles", "Retry & Fallback", "Advisor", "Prewalk", "Vision"],
120
120
  interaction: [
121
121
  "Input",
122
122
  "Approvals",
@@ -132,7 +132,7 @@ export const TAB_GROUPS: Record<SettingTab, readonly string[]> = {
132
132
  "Skills",
133
133
  ],
134
134
  context: ["General", "Compaction", "Zeta Context Cache", "Rules (TTSR)", "Experimental"],
135
- memory: ["General", "Auto-Learn", "Mnemopi", "Hindsight", "Sharpshooter"],
135
+ memory: ["General", "Taste", "Auto-Learn", "Mnemopi", "Hindsight", "Sharpshooter"],
136
136
  files: ["Editing", "Reading", "Read Summaries", "LSP", "Session Trash"],
137
137
  shell: ["Bash", "Eval & Runtimes"],
138
138
  tools: [
@@ -10,7 +10,7 @@ import {
10
10
  TruncatedText,
11
11
  truncateToWidth,
12
12
  } from "../index";
13
- import { isRecord, sanitizeText } from "@linxiraos/pi-utils";
13
+ import { isRecord, oklabDistance, sanitizeText } from "@linxiraos/pi-utils";
14
14
  /** Available session-tree display filters. */
15
15
  export const TREE_FILTER_MODES = ["default", "no-tools", "user-only", "labeled-only", "all"] as const;
16
16
  /** Session-tree display filter. */
@@ -94,10 +94,15 @@ interface AdvisorTreeDisplay {
94
94
  */
95
95
  function sanitizeTreeField(value: string): string {
96
96
  return sanitizeText(value)
97
- .replace(/[\n\t]/g, " ")
97
+ .replace(/[\r\n\t\u2028\u2029]/g, " ")
98
98
  .trim();
99
99
  }
100
100
 
101
+ /** Strip ANSI/control characters and fold line breaks for single-line tree rows and headers. */
102
+ function treeRowText(value: string): string {
103
+ return plainText(value.replace(/[\r\n\u2028\u2029]/g, " "));
104
+ }
105
+
101
106
  /**
102
107
  * Extract display metadata from an advisor custom-message's `details.notes`,
103
108
  * ignoring the model-facing `<advisory>` wrapper stored in `content`. Collects
@@ -165,10 +170,38 @@ function stripSystemWrapperTags(content: string): string {
165
170
  /** Per-message cap on text folded into the tree search index. */
166
171
  const SEARCH_TEXT_LIMIT = 200;
167
172
 
168
- /** One theme-colored piece of an entry's display text. */
173
+ /** One theme-colored piece of an entry's display text; `strong` draws it bold. */
169
174
  interface EntryPart {
170
175
  t: string;
171
176
  s?: ThemeColor;
177
+ strong?: boolean;
178
+ }
179
+
180
+ /** An entry part as a native span. */
181
+ function partSpan(part: EntryPart): TspSpan {
182
+ const style = part.strong ? (part.s ? `${part.s} strong` : "strong") : part.s;
183
+ return span(treeRowText(part.t), style);
184
+ }
185
+
186
+ /** OKLab distance under which two role colors read as the same color. */
187
+ const SAME_COLOR_DISTANCE = 0.05;
188
+
189
+ let assistantLabel: { theme: typeof theme; color: ThemeColor } | undefined;
190
+
191
+ /**
192
+ * The `assistant:` label color: `success`, unless it looks like the `user:` label's
193
+ * `accent` (`dark-terminal`, `*-poimandres`); then the path color, then `muted`.
194
+ */
195
+ function assistantLabelColor(): ThemeColor {
196
+ if (assistantLabel?.theme !== theme) {
197
+ const accent = theme.getColorHex("accent");
198
+ const color =
199
+ (["success", "statusLinePath"] as const).find(
200
+ c => oklabDistance(theme.getColorHex(c), accent) >= SAME_COLOR_DISTANCE,
201
+ ) ?? "muted";
202
+ assistantLabel = { theme, color };
203
+ }
204
+ return assistantLabel.color;
172
205
  }
173
206
 
174
207
  /** A cached native tree item and the inputs it was built from. */
@@ -234,6 +267,8 @@ class TreeList implements Component {
234
267
  | undefined;
235
268
  /** Bumped on every label edit: labels are item badges. */
236
269
  #labelVersion = 0;
270
+ /** Theme the native item caches were built under: labels bake in the `assistant:` color. */
271
+ #nativeTheme = theme;
237
272
  #pickerItems:
238
273
  | { rows: readonly TreeRow<TreeSelectorNode, string>[]; labels: number; items: TspPickerItem[] }
239
274
  | undefined;
@@ -703,6 +738,7 @@ class TreeList implements Component {
703
738
  * only `order` (the visible entries) and the selection.
704
739
  */
705
740
  pickerView(): TreePickerView {
741
+ this.#syncNativeTheme();
706
742
  const allRows = this.#tree.allRows;
707
743
  if (this.#pickerItems?.rows !== allRows || this.#pickerItems.labels !== this.#labelVersion) {
708
744
  // Real branch points get a disclosure; linear chains stay flat at their head's depth.
@@ -734,9 +770,7 @@ class TreeList implements Component {
734
770
  #pickerItem(row: TreeRow<TreeSelectorNode, string>, open: boolean): TspPickerItem {
735
771
  const item = row.item;
736
772
  const entry = item.entry;
737
- const label = this.#entryParts(item).map(part =>
738
- span(part.t.includes("\x1b") ? plainText(part.t) : part.t, part.s),
739
- );
773
+ const label = this.#entryParts(item).map(partSpan);
740
774
  let kind: TspPickerItem["node"] = "marker";
741
775
  let role: string | undefined;
742
776
  if (isUserRequestEntry(entry)) {
@@ -755,7 +789,7 @@ class TreeList implements Component {
755
789
  node: kind,
756
790
  ...(role ? { role } : {}),
757
791
  ...(open ? { open: true } : {}),
758
- ...(item.label ? { badges: [{ text: plainText(item.label), tone: "warning" as const }] } : {}),
792
+ ...(item.label ? { badges: [{ text: treeRowText(item.label), tone: "warning" as const }] } : {}),
759
793
  ...(this.#activePathIds.has(row.key) ? { dot: "accent" as const } : {}),
760
794
  };
761
795
  }
@@ -772,7 +806,7 @@ class TreeList implements Component {
772
806
  if (selected) {
773
807
  const entry = selected.entry;
774
808
  const parts = this.#entryParts(selected)
775
- .map(part => (part.t.includes("\x1b") ? plainText(part.t) : part.t))
809
+ .map(part => treeRowText(part.t))
776
810
  .join("");
777
811
  if (entry.type === "message" || entry.type === "custom_message") {
778
812
  const target: OutlineTarget = {
@@ -784,12 +818,16 @@ class TreeList implements Component {
784
818
  entries: [entry],
785
819
  };
786
820
  const copy = targetCopy(target, collectBlocks(target.entries));
787
- preview.push(text(`${copy.label[0]!.toUpperCase()}${copy.label.slice(1)}`, { role: "zeta.picker.title" }));
788
- if (selected.label) preview.push(text([span(plainText(selected.label), "warning")]));
821
+ preview.push(
822
+ text(treeRowText(`${copy.label[0]!.toUpperCase()}${copy.label.slice(1)}`), {
823
+ role: "zeta.picker.title",
824
+ }),
825
+ );
826
+ if (selected.label) preview.push(text([span(treeRowText(selected.label), "warning")]));
789
827
  preview.push(turnPreview(target, copy.content || parts));
790
828
  } else {
791
829
  preview.push(text(parts, { role: "zeta.picker.title" }));
792
- if (selected.label) preview.push(text([span(plainText(selected.label), "warning")]));
830
+ if (selected.label) preview.push(text([span(treeRowText(selected.label), "warning")]));
793
831
  }
794
832
  }
795
833
  this.#previewMemo = { node: selected, labels: this.#labelVersion, preview };
@@ -803,6 +841,7 @@ class TreeList implements Component {
803
841
  * instead of drawn tree connectors.
804
842
  */
805
843
  describeList(): NativeNode {
844
+ this.#syncNativeTheme();
806
845
  const rows = this.#tree.rows;
807
846
  let items = this.#itemsNative;
808
847
  if (items?.rows !== rows) {
@@ -852,6 +891,15 @@ class TreeList implements Component {
852
891
  ];
853
892
  }
854
893
 
894
+ /** Drop native items built under another theme. */
895
+ #syncNativeTheme(): void {
896
+ if (this.#nativeTheme === theme) return;
897
+ this.#nativeTheme = theme;
898
+ this.#pickerItems = undefined;
899
+ this.#itemsNative = undefined;
900
+ this.#itemCache.clear();
901
+ }
902
+
855
903
  #describeRow(row: TreeRow<TreeSelectorNode, string>): NativeNode {
856
904
  const item = row.item;
857
905
  const branch = row.parentKey !== undefined && row.siblingCount > 1;
@@ -859,10 +907,8 @@ class TreeList implements Component {
859
907
  if (cached !== undefined && cached.label === item.label && cached.branch === branch) return cached.node;
860
908
  const label: TspSpan[] = [];
861
909
  if (this.#activePathIds.has(row.key)) label.push(span(`${theme.md.bullet} `, "accent"));
862
- if (item.label) label.push(span(`[${plainText(item.label)}] `, "warning"));
863
- for (const part of this.#entryParts(item)) {
864
- label.push(span(part.t.includes("\x1b") ? plainText(part.t) : part.t, part.s));
865
- }
910
+ if (item.label) label.push(span(`[${treeRowText(item.label)}] `, "warning"));
911
+ for (const part of this.#entryParts(item)) label.push(partSpan(part));
866
912
  const described = node("item", { label, icon: branch ? "branch" : undefined }, undefined, row.key);
867
913
  this.#itemCache.set(row.key, { label: item.label, branch, node: described });
868
914
  return described;
@@ -954,7 +1000,7 @@ class TreeList implements Component {
954
1000
  // Active path marker - shown right before the entry text
955
1001
  const isOnActivePath = this.#activePathIds.has(node.entry.id);
956
1002
  const pathMarker = isOnActivePath ? theme.fg("accent", `${theme.md.bullet} `) : "";
957
- const label = node.label ? theme.fg("warning", `[${node.label}] `) : "";
1003
+ const label = node.label ? theme.fg("warning", `[${treeRowText(node.label)}] `) : "";
958
1004
  return `${pathMarker}${label}${this.#getEntryDisplayText(node, selected)}`;
959
1005
  }
960
1006
 
@@ -1050,7 +1096,13 @@ class TreeList implements Component {
1050
1096
 
1051
1097
  #getEntryDisplayText(node: TreeSelectorNode, isSelected: boolean): string {
1052
1098
  let result = "";
1053
- for (const part of this.#entryParts(node)) result += part.s ? theme.fg(part.s, part.t) : part.t;
1099
+ for (const part of this.#entryParts(node)) {
1100
+ let value = treeRowText(part.t);
1101
+ if (part.s) value = theme.fg(part.s, value);
1102
+ // A selected row is bolded whole; nested bold would close it early.
1103
+ if (part.strong && !isSelected) value = theme.bold(value);
1104
+ result += value;
1105
+ }
1054
1106
  return isSelected ? theme.bold(result) : result;
1055
1107
  }
1056
1108
 
@@ -1066,7 +1118,10 @@ class TreeList implements Component {
1066
1118
  if (role === "user") {
1067
1119
  const msgWithContent = msg as { content?: unknown };
1068
1120
  const content = normalize(this.#extractContent(msgWithContent.content));
1069
- return [{ t: "user: ", s: "accent" }, { t: content }];
1121
+ return [
1122
+ { t: "user: ", s: "accent", strong: true },
1123
+ { t: content, s: "accent", strong: true },
1124
+ ];
1070
1125
  }
1071
1126
  if (role === "developer") {
1072
1127
  const msgWithContent = msg as { content?: unknown };
@@ -1078,15 +1133,10 @@ class TreeList implements Component {
1078
1133
  }
1079
1134
  if (role === "assistant") {
1080
1135
  const presentation = resolveAssistantErrorPresentation(msg);
1081
- if (presentation.kind === "compact-recovered") {
1082
- return [
1083
- { t: "assistant: ", s: "success" },
1084
- { t: presentation.text, s: "dim" },
1085
- ];
1086
- }
1136
+ const head: EntryPart = { t: "assistant: ", s: assistantLabelColor() };
1137
+ if (presentation.kind === "compact-recovered") return [head, { t: presentation.text, s: "dim" }];
1087
1138
  const msgWithContent = msg as { content?: unknown; stopReason?: string; errorMessage?: string };
1088
1139
  const textContent = normalize(this.#extractContent(msgWithContent.content));
1089
- const head: EntryPart = { t: "assistant: ", s: "success" };
1090
1140
  if (textContent) return [head, { t: textContent }];
1091
1141
  if (presentation.kind === "full") {
1092
1142
  return [head, { t: normalize(presentation.text).slice(0, 80), s: "error" }];
@@ -1110,10 +1160,16 @@ class TreeList implements Component {
1110
1160
  if (entry.customType === "advisor") {
1111
1161
  const { qualifier, text } = advisorTreeDisplay(entry.details);
1112
1162
  const label = qualifier ? `advisor (${qualifier}): ` : "advisor: ";
1113
- return [{ t: label, s: "customMessageLabel" }, { t: normalize(text) }];
1163
+ return [
1164
+ { t: label, s: "customMessageLabel" },
1165
+ { t: normalize(text), s: "muted" },
1166
+ ];
1114
1167
  }
1115
1168
  const content = stripSystemWrapperTags(this.#joinTextContent(entry.content));
1116
- return [{ t: `[${entry.customType}]: `, s: "customMessageLabel" }, { t: normalize(content) }];
1169
+ return [
1170
+ { t: `[${entry.customType}]: `, s: "customMessageLabel" },
1171
+ { t: normalize(content), s: "muted" },
1172
+ ];
1117
1173
  }
1118
1174
  case "compaction": {
1119
1175
  const tokens = Math.round(entry.tokensBefore / 1000);
@@ -43,7 +43,7 @@ import { editorKey, editorKeys } from "../chrome/keybinding-hints";
43
43
  import type { TspSpan, TspTableColumn, TspText, TspTone } from "@linxiraos/pi-wire";
44
44
  import { col, elapsed, node, span, text } from "../native/describe";
45
45
  import { type DescribeContext, leafKey, type NativeChild, type NativeNode, type NativeUiEvent } from "../native/node";
46
- import { actionBar, actionButton } from "../native/overlay";
46
+ import { actionBar, actionButton, segmentedTabs } from "../native/overlay";
47
47
 
48
48
  /** Local calendar-day activity consumed by the usage heatmap. */
49
49
  export interface DailyActivityPoint {
@@ -649,8 +649,8 @@ export interface UsageDashboardOptions {
649
649
  export function formatActivityErrorDetail(error: string, homeDir = os.homedir()): string {
650
650
  let text = replaceTabs(sanitizeText(error)).replace(/\s+/g, " ").trim();
651
651
  if (homeDir) {
652
- const escaped = homeDir.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
653
- const forward = homeDir.replaceAll("\\", "/").replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
652
+ const escaped = RegExp.escape(homeDir);
653
+ const forward = RegExp.escape(homeDir.replaceAll("\\", "/"));
654
654
  text = text.replace(new RegExp(`${escaped}|${forward}`, "gi"), "~");
655
655
  }
656
656
  return text.replace(/\.+$/, "");
@@ -1135,8 +1135,7 @@ export class UsageDashboardComponent implements Component {
1135
1135
  );
1136
1136
  }
1137
1137
  const children: NativeChild[] = [
1138
- node(
1139
- "tabs",
1138
+ segmentedTabs(
1140
1139
  {
1141
1140
  items: [
1142
1141
  { id: "overview", label: "Overview" },
@@ -1144,7 +1143,6 @@ export class UsageDashboardComponent implements Component {
1144
1143
  ],
1145
1144
  active: this.#view,
1146
1145
  },
1147
- undefined,
1148
1146
  "tabs",
1149
1147
  ),
1150
1148
  node("spacer", { grow: 1 }),
@@ -103,6 +103,13 @@ export interface RuntimeChildrenOptions {
103
103
  * to the roots below the transcript in render order.
104
104
  */
105
105
  readonly nativeDock?: readonly Component[];
106
+ /**
107
+ * Below-transcript containers whose children continue `main` on a TSP
108
+ * terminal, one block each after the transcript's, instead of riding in the
109
+ * dock: output on its way into the transcript (shell runs deferred until the
110
+ * next prompt) reads as its tail, and keeps its block when it moves in.
111
+ */
112
+ readonly nativeTail?: readonly Container[];
106
113
  /**
107
114
  * Below-transcript roots the user opens and closes (the editor surface that
108
115
  * drafts and dialogs swap into, docked reports). Their rows never become
@@ -266,6 +273,7 @@ export class Composer implements TerminalFrameProvider, NativeSurfaceProvider {
266
273
  #headerAfter: readonly Component[] = [];
267
274
  #runtimeChildren: readonly Component[] = [];
268
275
  #nativeDock: readonly Component[] | undefined;
276
+ #nativeTail: readonly Container[] = [];
269
277
  /** Cache-driven status line shown until {@link setStatusComponent} mounts the session's. */
270
278
  #startupStatus: StatusLineComponent | undefined;
271
279
  #runtimeMounted = false;
@@ -660,10 +668,11 @@ export class Composer implements TerminalFrameProvider, NativeSurfaceProvider {
660
668
  /**
661
669
  * Describe the whole surface for a TSP terminal. `main` is the flowing
662
670
  * document: the header (welcome, extras) and every transcript block as its
663
- * own component child. `dock` is the live chrome below the transcript in
664
- * render order: pending messages, HUDs, the working row, the editor and the
665
- * status line. There is no history/viewport split: retirement, resize
666
- * replay and hover bands are ANSI concerns.
671
+ * own component child, then the children of the
672
+ * {@link RuntimeChildrenOptions.nativeTail} roots. `dock` is the live chrome
673
+ * below the transcript in render order: pending messages, HUDs, the working
674
+ * row, the editor and the status line. There is no history/viewport split:
675
+ * retirement, resize replay and hover bands are ANSI concerns.
667
676
  */
668
677
  describeSurface(): NativeSurface {
669
678
  if (!this.#started || this.#stopped) return this.#nativeSurface;
@@ -680,7 +689,9 @@ export class Composer implements TerminalFrameProvider, NativeSurfaceProvider {
680
689
  } else {
681
690
  const transcript = roots[transcriptIndex] as TranscriptContainer;
682
691
  main.push(...roots.slice(0, transcriptIndex), ...transcript.nativeBlocks());
683
- dock.push(...(this.#nativeDock ?? roots.slice(transcriptIndex + 1)));
692
+ for (const root of this.#nativeTail) main.push(...root.children);
693
+ const tail: readonly Component[] = this.#nativeTail;
694
+ dock.push(...(this.#nativeDock ?? roots.slice(transcriptIndex + 1).filter(root => !tail.includes(root))));
684
695
  }
685
696
  }
686
697
  const previous = this.#nativeSurface;
@@ -1266,6 +1277,7 @@ export class Composer implements TerminalFrameProvider, NativeSurfaceProvider {
1266
1277
  this.#chromeFloorPromoted = false;
1267
1278
  this.#resetIdleChrome();
1268
1279
  this.#nativeDock = options.nativeDock;
1280
+ this.#nativeTail = options.nativeTail ?? [];
1269
1281
  this.#transientChrome = new Set(options.transientChrome);
1270
1282
  this.#selfClearingChrome = new Set(options.selfClearingChrome);
1271
1283
  this.#transientFloor = undefined;
@@ -74,7 +74,7 @@ function formatHeader(options: CodeCellOptions, theme: Theme): { title: string;
74
74
  if (status) {
75
75
  const icon = formatStatusIcon(
76
76
  status === "complete"
77
- ? "done"
77
+ ? "success"
78
78
  : status === "error"
79
79
  ? "error"
80
80
  : status === "warning"