@linxiraos/pi-tui 1.4.7 → 1.4.10

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 (181) hide show
  1. package/CHANGELOG.md +154 -231
  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/setup/scenes/language.d.ts +3 -0
  33. package/dist/types/setup/scenes/types.d.ts +5 -0
  34. package/dist/types/setup/setup-version.d.ts +1 -1
  35. package/dist/types/setup/wizard.d.ts +1 -1
  36. package/dist/types/status-line/startup.d.ts +0 -15
  37. package/dist/types/terminal-capabilities.d.ts +1 -1
  38. package/dist/types/theme/symbols.d.ts +3 -1
  39. package/dist/types/theme/theme-class.d.ts +1 -0
  40. package/dist/types/theme/theme.d.ts +1 -1
  41. package/dist/types/theme/tui-adapters.d.ts +2 -0
  42. package/dist/types/thinking.d.ts +8 -6
  43. package/dist/types/tools/ast-grep.d.ts +2 -0
  44. package/dist/types/tools/eval.d.ts +2 -0
  45. package/dist/types/tools/find.d.ts +1 -1
  46. package/dist/types/tools/grouped-file-output.d.ts +100 -19
  47. package/dist/types/tools/hashline-format.d.ts +5 -0
  48. package/dist/types/tools/native-view.d.ts +2 -0
  49. package/dist/types/tools/output-meta.d.ts +27 -0
  50. package/dist/types/tools/read.d.ts +14 -4
  51. package/dist/types/tools/task.d.ts +4 -3
  52. package/dist/types/tools/wait.d.ts +2 -0
  53. package/dist/types/tui.d.ts +12 -0
  54. package/dist/types/utils.d.ts +4 -0
  55. package/package.json +9 -9
  56. package/src/app-keybindings.d.ts +5 -0
  57. package/src/app-keybindings.ts +5 -0
  58. package/src/apps/git/git-tui.ts +10 -17
  59. package/src/apps/git/sidebar.ts +21 -35
  60. package/src/apps/ps-top.ts +4 -12
  61. package/src/charts/chart-plan.ts +0 -29
  62. package/src/charts/table-data.d.ts +4 -2
  63. package/src/charts/table-data.ts +55 -6
  64. package/src/chat/bash-execution.d.ts +4 -1
  65. package/src/chat/bash-execution.ts +20 -9
  66. package/src/chat/chat-transcript-builder.ts +5 -2
  67. package/src/chat/eval-execution.d.ts +2 -0
  68. package/src/chat/eval-execution.ts +14 -7
  69. package/src/chat/execution-shared.d.ts +14 -8
  70. package/src/chat/execution-shared.ts +39 -18
  71. package/src/chat/figure-markdown.d.ts +2 -0
  72. package/src/chat/figure-markdown.ts +6 -4
  73. package/src/chat/read-tool-group.ts +56 -36
  74. package/src/chat/svg-figure.d.ts +5 -0
  75. package/src/chat/svg-figure.ts +55 -16
  76. package/src/chat/table-chart.d.ts +2 -0
  77. package/src/chat/table-chart.ts +19 -2
  78. package/src/chat/transcript-render-helpers.d.ts +11 -3
  79. package/src/chat/transcript-render-helpers.ts +70 -22
  80. package/src/chrome/dynamic-border.d.ts +6 -0
  81. package/src/chrome/dynamic-border.ts +28 -2
  82. package/src/chrome/transcript-status.d.ts +2 -2
  83. package/src/chrome/transcript-status.ts +5 -3
  84. package/src/components/editor.d.ts +15 -6
  85. package/src/components/editor.ts +123 -24
  86. package/src/components/image.d.ts +6 -0
  87. package/src/components/image.ts +13 -0
  88. package/src/components/key-value-list.ts +9 -9
  89. package/src/components/loader.d.ts +2 -0
  90. package/src/components/loader.ts +7 -0
  91. package/src/components/section.ts +1 -9
  92. package/src/components/table.ts +1 -9
  93. package/src/keybinding-matchers.d.ts +7 -0
  94. package/src/keybinding-matchers.ts +13 -0
  95. package/src/native/backend.ts +7 -3
  96. package/src/native/describe.d.ts +4 -2
  97. package/src/native/describe.ts +9 -4
  98. package/src/native/node.d.ts +2 -3
  99. package/src/native/node.ts +2 -3
  100. package/src/native/overlay.d.ts +42 -2
  101. package/src/native/overlay.ts +124 -16
  102. package/src/native/state.d.ts +4 -0
  103. package/src/native/state.ts +25 -5
  104. package/src/overlays/btw-history-panel.ts +106 -14
  105. package/src/overlays/btw-history.ts +65 -0
  106. package/src/overlays/btw-inject.ts +91 -0
  107. package/src/overlays/btw-panel.ts +53 -12
  108. package/src/overlays/extensions/extension-dashboard.ts +7 -8
  109. package/src/overlays/hook-editor.ts +6 -0
  110. package/src/overlays/jobs-panel.ts +82 -22
  111. package/src/overlays/login-dialog.ts +8 -26
  112. package/src/overlays/model-browser.ts +69 -10
  113. package/src/overlays/session-selector.ts +25 -5
  114. package/src/overlays/settings-defs.ts +2 -2
  115. package/src/overlays/settings-selector.ts +113 -11
  116. package/src/overlays/tree-selector.ts +83 -27
  117. package/src/overlays/usage-dashboard.ts +4 -6
  118. package/src/prompt/composer.ts +17 -5
  119. package/src/render/code-cell.ts +1 -1
  120. package/src/render/file-list.ts +4 -7
  121. package/src/render/render-utils.d.ts +23 -1
  122. package/src/render/render-utils.ts +38 -6
  123. package/src/setup/scenes/glyph.ts +1 -1
  124. package/src/setup/scenes/language.ts +122 -0
  125. package/src/setup/scenes/types.ts +6 -0
  126. package/src/setup/setup-version.ts +1 -1
  127. package/src/setup/wizard.ts +2 -0
  128. package/src/status-line/startup.ts +36 -70
  129. package/src/terminal-capabilities.d.ts +1 -1
  130. package/src/terminal-capabilities.ts +5 -0
  131. package/src/theme/symbols.d.ts +3 -1
  132. package/src/theme/symbols.ts +16 -9
  133. package/src/theme/theme-class.d.ts +1 -0
  134. package/src/theme/theme-class.ts +15 -3
  135. package/src/theme/theme.d.ts +1 -1
  136. package/src/theme/theme.ts +1 -0
  137. package/src/theme/tui-adapters.d.ts +2 -0
  138. package/src/theme/tui-adapters.ts +8 -3
  139. package/src/thinking.d.ts +8 -6
  140. package/src/thinking.ts +17 -11
  141. package/src/tmux.ts +1 -0
  142. package/src/tools/agent-tree.ts +13 -11
  143. package/src/tools/ask.ts +24 -37
  144. package/src/tools/ast-edit.ts +48 -93
  145. package/src/tools/ast-grep.d.ts +2 -0
  146. package/src/tools/ast-grep.ts +31 -67
  147. package/src/tools/bash.ts +7 -0
  148. package/src/tools/default-renderer.ts +1 -1
  149. package/src/tools/edit.ts +50 -43
  150. package/src/tools/eval.d.ts +2 -0
  151. package/src/tools/eval.ts +2 -0
  152. package/src/tools/fetch.ts +2 -1
  153. package/src/tools/find.d.ts +1 -1
  154. package/src/tools/find.ts +13 -5
  155. package/src/tools/github.ts +14 -46
  156. package/src/tools/glob.ts +2 -1
  157. package/src/tools/grep.ts +47 -277
  158. package/src/tools/grouped-file-output.d.ts +100 -19
  159. package/src/tools/grouped-file-output.ts +414 -103
  160. package/src/tools/hashline-format.d.ts +5 -0
  161. package/src/tools/hashline-format.ts +5 -0
  162. package/src/tools/json-tree.ts +1 -5
  163. package/src/tools/lsp.ts +210 -32
  164. package/src/tools/native-view.d.ts +2 -0
  165. package/src/tools/native-view.ts +11 -5
  166. package/src/tools/output-meta.d.ts +27 -0
  167. package/src/tools/output-meta.ts +68 -4
  168. package/src/tools/proc-render.ts +3 -3
  169. package/src/tools/read.d.ts +14 -4
  170. package/src/tools/read.ts +20 -5
  171. package/src/tools/task.d.ts +4 -3
  172. package/src/tools/task.ts +41 -81
  173. package/src/tools/vibe.ts +4 -4
  174. package/src/tools/wait.d.ts +2 -0
  175. package/src/tools/wait.ts +8 -5
  176. package/src/tools/write.ts +17 -27
  177. package/src/tools/yield.ts +1 -1
  178. package/src/tui.d.ts +12 -0
  179. package/src/tui.ts +91 -9
  180. package/src/utils.d.ts +4 -0
  181. package/src/utils.ts +10 -0
@@ -629,6 +629,18 @@ export class SettingsSelectorComponent implements Component {
629
629
  /** Single-line editor backing the search banner (cursor, word ops, paste). */
630
630
  #searchInput = new Input();
631
631
  #searchMatchCount = 0;
632
+ /**
633
+ * Bumped whenever the native page's structure or values may have changed.
634
+ * `#describePrefs` uses it to skip rebuilding hundreds of rows on frames
635
+ * where nothing moved; the terminal patches the same node in place.
636
+ */
637
+ #prefsRevision = 0;
638
+ /**
639
+ * Search text typed since the last frame. Keys can arrive in a burst (a
640
+ * paste, fast typing); ranking every settings tab for each byte makes the
641
+ * page stutter, so the burst is coalesced into one rebuild per frame.
642
+ */
643
+ #pendingSearchQuery: string | null = null;
632
644
  /** First matching item id per tab id, for Tab-key jumps while searching. */
633
645
  #searchFirstMatch = new Map<string, string>();
634
646
  /**
@@ -675,6 +687,7 @@ export class SettingsSelectorComponent implements Component {
675
687
  }
676
688
 
677
689
  invalidate(): void {
690
+ this.#prefsRevision += 1;
678
691
  this.#tabBar.invalidate();
679
692
  this.#currentList?.invalidate();
680
693
  this.#searchList?.invalidate();
@@ -683,12 +696,22 @@ export class SettingsSelectorComponent implements Component {
683
696
 
684
697
  /** Swap the active content (per-tab list, search list, or plugins). */
685
698
  #setContent(build: () => void): void {
699
+ this.#prefsRevision += 1;
686
700
  this.#currentList = null;
687
701
  this.#searchList = null;
688
702
  this.#pluginComponent = null;
689
703
  build();
690
704
  }
691
705
 
706
+ /** Apply search text typed since the last frame, once. */
707
+ #flushSearchQuery(): void {
708
+ const pending = this.#pendingSearchQuery;
709
+ if (pending === null) return;
710
+ this.#pendingSearchQuery = null;
711
+ if (pending.length === 0) this.#endSearch(false);
712
+ else this.#setSearchQuery(pending);
713
+ }
714
+
692
715
  #switchToTab(tabId: SettingTab | "plugins"): void {
693
716
  this.#currentTabId = tabId;
694
717
  this.#setContent(() => {
@@ -737,6 +760,7 @@ export class SettingsSelectorComponent implements Component {
737
760
  * then a footer hint pinned above the bottom border.
738
761
  */
739
762
  render(width: number): readonly string[] {
763
+ this.#flushSearchQuery();
740
764
  const height = Math.max(14, process.stdout.rows || 40);
741
765
  const innerWidth = Math.max(1, width - 4);
742
766
 
@@ -801,6 +825,7 @@ export class SettingsSelectorComponent implements Component {
801
825
  * root card of today's generic composition.
802
826
  */
803
827
  describe(cx: DescribeContext): NativeNode {
828
+ this.#flushSearchQuery();
804
829
  return cx.supports("prefs") ? this.#describePrefs() : this.#describeCard();
805
830
  }
806
831
 
@@ -826,14 +851,45 @@ export class SettingsSelectorComponent implements Component {
826
851
  });
827
852
  pages.push({ id: PLUGINS_PAGE, label: "Installed", icon: "plugins", group: "Plugins" });
828
853
 
829
- let sections: TspPrefsProps["sections"] = [];
830
854
  let focus: string | null = null;
831
855
  let editing: TspPrefsProps["editing"] = null;
832
- const children: NativeChild[] = [];
833
856
  if (pluginPage) {
834
- sections = pluginPage.sections;
835
857
  focus = pluginPage.focus;
836
858
  editing = pluginPage.editing;
859
+ } else if (list) {
860
+ const at = list.prefsFocus();
861
+ focus = at.row ?? (at.section ? prefsSectionId(at.section) : null);
862
+ editing = list.prefsEditing(id => this.#inlineMenu(id));
863
+ }
864
+
865
+ // Rebuilding every row and JSON-stringifying them each frame is what
866
+ // made the page stutter while typing in search. The revision covers
867
+ // every value/list change; focus, editing, the open menu and the search
868
+ // text cover the rest. Only a real change pays for the full build.
869
+ let signature: string | null = null;
870
+ if (!pluginPage) {
871
+ const preview = tab === "appearance" && !searching ? this.#getStatusPreviewString() : "";
872
+ const pageKey = pages.map(page => `${page.id}:${page.changed ?? 0}`).join(",");
873
+ const cursor = searching ? this.#searchInput.getCursor() : -1;
874
+ signature = [
875
+ this.#prefsRevision,
876
+ this.#currentTabId,
877
+ searching ? 1 : 0,
878
+ this.#searchQuery,
879
+ cursor,
880
+ pageKey,
881
+ focus ?? "",
882
+ editing ? JSON.stringify(editing) : "",
883
+ list?.openSubmenu?.id ?? "",
884
+ preview,
885
+ ].join("\u0000");
886
+ if (memo.prefs?.signature === signature) return memo.prefs.node;
887
+ }
888
+
889
+ let sections: TspPrefsProps["sections"] = [];
890
+ const children: NativeChild[] = [];
891
+ if (pluginPage) {
892
+ sections = pluginPage.sections;
837
893
  if (pluginPage.editor) children.push(pluginPage.editor);
838
894
  } else if (list) {
839
895
  sections = list.prefsSections(
@@ -845,9 +901,6 @@ export class SettingsSelectorComponent implements Component {
845
901
  },
846
902
  item => this.#prefsControl(item.id, item.currentValue),
847
903
  );
848
- const at = list.prefsFocus();
849
- focus = at.row ?? (at.section ? prefsSectionId(at.section) : null);
850
- editing = list.prefsEditing(id => this.#inlineMenu(id));
851
904
  const open = list.openSubmenu;
852
905
  if (open && !editing) {
853
906
  // Pickers describe themselves as a sheet; anything else sits in a card over the page.
@@ -889,15 +942,17 @@ export class SettingsSelectorComponent implements Component {
889
942
  focus,
890
943
  editing,
891
944
  };
892
- const signature = JSON.stringify(props);
893
- if (memo.prefs && memo.prefs.signature === signature && sameItems(memo.prefs.children, children)) {
894
- return memo.prefs.node;
945
+ if (signature === null) {
946
+ // The plugin page owns its own structure; keep the structural memo.
947
+ signature = JSON.stringify(props);
948
+ if (memo.prefs && memo.prefs.signature === signature && sameItems(memo.prefs.children, children)) {
949
+ return memo.prefs.node;
950
+ }
895
951
  }
896
952
  const root = node("prefs", props, children);
897
953
  memo.prefs = { signature, children, node: root };
898
954
  return root;
899
955
  }
900
-
901
956
  /** Settings changed from their default on `tab` (visible ones only); cached until the items rebuild. */
902
957
  #changedCount(tab: SettingTab): number {
903
958
  const cached = this.#changedCounts.get(tab);
@@ -1032,6 +1087,10 @@ export class SettingsSelectorComponent implements Component {
1032
1087
  }
1033
1088
  if (list.openSubmenu) list.handleInput(ESCAPE);
1034
1089
  list.selectItem(event.item);
1090
+ // Tern reports a click on the row itself (not its control) as
1091
+ // `select`. A label click is the click users make to open a popup or
1092
+ // a text field, so open the editor the control would have opened.
1093
+ if (this.#opensOnRowClick(event.item)) list.openSubmenuFor(event.item);
1035
1094
  return;
1036
1095
  }
1037
1096
  case "activate":
@@ -1051,6 +1110,31 @@ export class SettingsSelectorComponent implements Component {
1051
1110
  if (id !== this.#currentTabId) this.#tabBar.selectTab(id);
1052
1111
  }
1053
1112
 
1113
+ /**
1114
+ * Rows whose control is a popup, a text field or an action button: a click
1115
+ * on the row's label should open it. Segments, switches, steppers and chip
1116
+ * rows act in place and must not grow a menu from a label click.
1117
+ */
1118
+ #opensOnRowClick(id: string): boolean {
1119
+ const def = getSettingDef(this.#context.settings.entries, id);
1120
+ if (!def) return false;
1121
+ if (def.type === "text" || def.type === "providerLimits") return true;
1122
+ if (def.type === "submenu") {
1123
+ if (numberSteps(def)) return false;
1124
+ const options = this.#submenuOptions(def);
1125
+ return (
1126
+ PREVIEWED_SETTINGS.has(def.path) ||
1127
+ options.some(option => option.description) ||
1128
+ options.length > 4 ||
1129
+ options.reduce((width, option) => width + option.label.length, 0) > 28
1130
+ );
1131
+ }
1132
+ if (def.type === "enum") {
1133
+ return def.values.length > 4 || def.values.reduce((width, value) => width + value.length, 0) > 28;
1134
+ }
1135
+ return false;
1136
+ }
1137
+
1054
1138
  /** A pointer value change on row `id`, through the path its keys take (see {@link #handlePrefsEvent}). */
1055
1139
  #applyPrefsChange(
1056
1140
  list: SettingsList,
@@ -1121,7 +1205,9 @@ export class SettingsSelectorComponent implements Component {
1121
1205
 
1122
1206
  /** Rebuilds the visible items after a change made outside a list's own `onChange` (changed flags, conditions). */
1123
1207
  #refreshItems(): void {
1208
+ this.#prefsRevision += 1;
1124
1209
  if (this.#searchList) {
1210
+ this.#flushSearchQuery();
1125
1211
  this.#searchCorpora = null;
1126
1212
  this.#setSearchQuery(this.#searchQuery);
1127
1213
  } else if (this.#currentTabId !== "plugins")
@@ -1213,6 +1299,8 @@ export class SettingsSelectorComponent implements Component {
1213
1299
  * jump, while searching), unless an open submenu owns the pointer.
1214
1300
  */
1215
1301
  handleNativeEvent(event: NativeUiEvent): void {
1302
+ this.#flushSearchQuery();
1303
+ this.#prefsRevision += 1;
1216
1304
  if (event.key === "") {
1217
1305
  this.#handlePrefsEvent(event);
1218
1306
  return;
@@ -1230,6 +1318,7 @@ export class SettingsSelectorComponent implements Component {
1230
1318
  * activates it (toggle / open submenu).
1231
1319
  */
1232
1320
  #handleMouse(data: string): boolean {
1321
+ this.#flushSearchQuery();
1233
1322
  return routeSgrMouseInput(data, event => this.#routeMouseEvent(event));
1234
1323
  }
1235
1324
 
@@ -1274,6 +1363,7 @@ export class SettingsSelectorComponent implements Component {
1274
1363
  return true;
1275
1364
  }
1276
1365
  if (overContent && list) {
1366
+ this.#prefsRevision += 1;
1277
1367
  const itemId = list.hoverTest(contentLine, innerCol);
1278
1368
  const id = itemId ?? list.hitTest(contentLine, innerCol);
1279
1369
  if (id !== undefined) {
@@ -1292,6 +1382,7 @@ export class SettingsSelectorComponent implements Component {
1292
1382
 
1293
1383
  /** Swap the tab content for the global search result list. */
1294
1384
  #startSearch(initialQuery: string): void {
1385
+ this.#pendingSearchQuery = null;
1295
1386
  this.#preSearchTabId = this.#currentTabId;
1296
1387
  this.#searchCorpora = null;
1297
1388
  this.#searchInput = new Input();
@@ -1325,10 +1416,12 @@ export class SettingsSelectorComponent implements Component {
1325
1416
  */
1326
1417
  #setSearchQuery(query: string): void {
1327
1418
  if (!this.#searchList) return;
1419
+ this.#pendingSearchQuery = null;
1328
1420
  if (query.length === 0) {
1329
1421
  this.#endSearch(false);
1330
1422
  return;
1331
1423
  }
1424
+ this.#prefsRevision += 1;
1332
1425
  this.#searchQuery = query;
1333
1426
  this.#changedCounts.clear();
1334
1427
 
@@ -1390,6 +1483,8 @@ export class SettingsSelectorComponent implements Component {
1390
1483
  */
1391
1484
  #endSearch(jumpToSelection: boolean): void {
1392
1485
  if (!this.#searchList) return;
1486
+ this.#pendingSearchQuery = null;
1487
+ this.#prefsRevision += 1;
1393
1488
  const selected = jumpToSelection ? this.#searchList.getSelectedItem() : undefined;
1394
1489
  const selectedDef = selected ? getSettingDef(this.#context.settings.entries, selected.id) : undefined;
1395
1490
  const targetTab: SettingTab | "plugins" = selectedDef?.tab ?? this.#preSearchTabId;
@@ -1875,6 +1970,7 @@ export class SettingsSelectorComponent implements Component {
1875
1970
  /** Re-evaluate condition gates against the current settings and refresh the active list. */
1876
1971
  #refreshCurrentTabItems(defs: SettingDef[]): void {
1877
1972
  if (this.#currentTabId === "plugins" || !this.#currentList) return;
1973
+ this.#prefsRevision += 1;
1878
1974
  this.#currentList.setItems(this.#buildItemsForDefs(defs));
1879
1975
  }
1880
1976
 
@@ -1917,6 +2013,9 @@ export class SettingsSelectorComponent implements Component {
1917
2013
  this.#handleMouse(data);
1918
2014
  return;
1919
2015
  }
2016
+ this.#flushSearchQuery();
2017
+ // Any key can move the selection, edit a draft or change the search.
2018
+ this.#prefsRevision += 1;
1920
2019
 
1921
2020
  // Text-input submenus take every byte: arrow keys must reach the
1922
2021
  // cursor and Tab must not switch tabs.
@@ -1998,6 +2097,9 @@ export class SettingsSelectorComponent implements Component {
1998
2097
  // cursor movement, word ops, kill ring, undo, paste.
1999
2098
  this.#searchInput.handleInput(data);
2000
2099
  const value = this.#searchInput.getValue();
2001
- if (value !== this.#searchQuery) this.#setSearchQuery(value);
2100
+ if (value !== this.#searchQuery) {
2101
+ this.#pendingSearchQuery = value;
2102
+ this.#context.requestRender?.();
2103
+ }
2002
2104
  }
2003
2105
  }
@@ -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"
@@ -6,6 +6,7 @@ import { node, span } from "../native/describe";
6
6
  import type { NativeNode } from "../native/node";
7
7
  import type { Theme } from "../theme/theme";
8
8
  import { fileLinkSpan } from "./hyperlink";
9
+ import { formatStyledPath } from "./render-utils";
9
10
  import { renderTreeList } from "./tree-list";
10
11
 
11
12
  /** A file-list item with optional display metadata. */
@@ -69,15 +70,11 @@ export function renderFileList(options: FileListOptions, theme: Theme): string[]
69
70
  const isDirectory = entry.isDirectory ?? entry.path.endsWith("/");
70
71
  const displayPath = entry.path;
71
72
  const lang = isDirectory ? undefined : getLanguageFromPath(displayPath);
72
- const icon = !showIcons
73
- ? ""
74
- : isDirectory
75
- ? theme.fg("accent", theme.icon.folder)
76
- : theme.fg("muted", theme.getLangIcon(lang));
77
- const labelColor = isDirectory ? "accent" : "toolOutput";
73
+ // Type icons stay muted beside the dim directory and colored file name.
74
+ const icon = !showIcons ? "" : theme.fg("muted", isDirectory ? theme.icon.folder : theme.getLangIcon(lang));
78
75
  const meta = entry.meta ? ` ${theme.fg("dim", entry.meta)}` : "";
79
76
  const iconPrefix = icon ? `${icon} ` : "";
80
- const pathStr = theme.fg(labelColor, displayPath);
77
+ const pathStr = formatStyledPath(displayPath, theme);
81
78
  const linkedPath = entry.absPath && hyperlinkFn ? hyperlinkFn(entry.absPath, pathStr) : pathStr;
82
79
  return `${iconPrefix}${linkedPath}${meta}`;
83
80
  },