@mariozechner/pi-coding-agent 0.30.2 → 0.31.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (297) hide show
  1. package/CHANGELOG.md +244 -1
  2. package/README.md +105 -84
  3. package/dist/cli/args.d.ts.map +1 -1
  4. package/dist/cli/args.js +5 -1
  5. package/dist/cli/args.js.map +1 -1
  6. package/dist/cli/file-processor.d.ts +3 -3
  7. package/dist/cli/file-processor.d.ts.map +1 -1
  8. package/dist/cli/file-processor.js +7 -10
  9. package/dist/cli/file-processor.js.map +1 -1
  10. package/dist/config.d.ts +9 -0
  11. package/dist/config.d.ts.map +1 -1
  12. package/dist/config.js +18 -0
  13. package/dist/config.js.map +1 -1
  14. package/dist/core/agent-session.d.ts +73 -34
  15. package/dist/core/agent-session.d.ts.map +1 -1
  16. package/dist/core/agent-session.js +464 -210
  17. package/dist/core/agent-session.js.map +1 -1
  18. package/dist/core/auth-storage.d.ts +2 -2
  19. package/dist/core/auth-storage.d.ts.map +1 -1
  20. package/dist/core/auth-storage.js +2 -2
  21. package/dist/core/auth-storage.js.map +1 -1
  22. package/dist/core/bash-executor.d.ts +2 -2
  23. package/dist/core/bash-executor.d.ts.map +1 -1
  24. package/dist/core/bash-executor.js +2 -2
  25. package/dist/core/bash-executor.js.map +1 -1
  26. package/dist/core/compaction/branch-summarization.d.ts +84 -0
  27. package/dist/core/compaction/branch-summarization.d.ts.map +1 -0
  28. package/dist/core/compaction/branch-summarization.js +233 -0
  29. package/dist/core/compaction/branch-summarization.js.map +1 -0
  30. package/dist/core/{compaction.d.ts → compaction/compaction.d.ts} +38 -19
  31. package/dist/core/compaction/compaction.d.ts.map +1 -0
  32. package/dist/core/compaction/compaction.js +558 -0
  33. package/dist/core/compaction/compaction.js.map +1 -0
  34. package/dist/core/compaction/index.d.ts +7 -0
  35. package/dist/core/compaction/index.d.ts.map +1 -0
  36. package/dist/core/compaction/index.js +7 -0
  37. package/dist/core/compaction/index.js.map +1 -0
  38. package/dist/core/compaction/utils.d.ts +35 -0
  39. package/dist/core/compaction/utils.d.ts.map +1 -0
  40. package/dist/core/compaction/utils.js +138 -0
  41. package/dist/core/compaction/utils.js.map +1 -0
  42. package/dist/core/custom-tools/index.d.ts +2 -1
  43. package/dist/core/custom-tools/index.d.ts.map +1 -1
  44. package/dist/core/custom-tools/index.js +1 -0
  45. package/dist/core/custom-tools/index.js.map +1 -1
  46. package/dist/core/custom-tools/loader.d.ts.map +1 -1
  47. package/dist/core/custom-tools/loader.js +13 -80
  48. package/dist/core/custom-tools/loader.js.map +1 -1
  49. package/dist/core/custom-tools/types.d.ts +84 -59
  50. package/dist/core/custom-tools/types.d.ts.map +1 -1
  51. package/dist/core/custom-tools/types.js.map +1 -1
  52. package/dist/core/custom-tools/wrapper.d.ts +15 -0
  53. package/dist/core/custom-tools/wrapper.d.ts.map +1 -0
  54. package/dist/core/custom-tools/wrapper.js +23 -0
  55. package/dist/core/custom-tools/wrapper.js.map +1 -0
  56. package/dist/core/exec.d.ts +29 -0
  57. package/dist/core/exec.d.ts.map +1 -0
  58. package/dist/core/exec.js +71 -0
  59. package/dist/core/exec.js.map +1 -0
  60. package/dist/core/export-html/index.d.ts +17 -0
  61. package/dist/core/export-html/index.d.ts.map +1 -0
  62. package/dist/core/export-html/index.js +171 -0
  63. package/dist/core/export-html/index.js.map +1 -0
  64. package/dist/core/export-html/template.css +781 -0
  65. package/dist/core/export-html/template.html +54 -0
  66. package/dist/core/export-html/template.js +1185 -0
  67. package/dist/core/export-html/vendor/highlight.min.js +1213 -0
  68. package/dist/core/export-html/vendor/marked.min.js +6 -0
  69. package/dist/core/hooks/index.d.ts +4 -4
  70. package/dist/core/hooks/index.d.ts.map +1 -1
  71. package/dist/core/hooks/index.js +3 -3
  72. package/dist/core/hooks/index.js.map +1 -1
  73. package/dist/core/hooks/loader.d.ts +40 -5
  74. package/dist/core/hooks/loader.d.ts.map +1 -1
  75. package/dist/core/hooks/loader.js +43 -10
  76. package/dist/core/hooks/loader.js.map +1 -1
  77. package/dist/core/hooks/runner.d.ts +94 -18
  78. package/dist/core/hooks/runner.d.ts.map +1 -1
  79. package/dist/core/hooks/runner.js +199 -120
  80. package/dist/core/hooks/runner.js.map +1 -1
  81. package/dist/core/hooks/tool-wrapper.d.ts +1 -1
  82. package/dist/core/hooks/tool-wrapper.d.ts.map +1 -1
  83. package/dist/core/hooks/tool-wrapper.js +36 -19
  84. package/dist/core/hooks/tool-wrapper.js.map +1 -1
  85. package/dist/core/hooks/types.d.ts +407 -96
  86. package/dist/core/hooks/types.d.ts.map +1 -1
  87. package/dist/core/hooks/types.js.map +1 -1
  88. package/dist/core/index.d.ts +4 -3
  89. package/dist/core/index.d.ts.map +1 -1
  90. package/dist/core/index.js.map +1 -1
  91. package/dist/core/messages.d.ts +44 -12
  92. package/dist/core/messages.d.ts.map +1 -1
  93. package/dist/core/messages.js +82 -34
  94. package/dist/core/messages.js.map +1 -1
  95. package/dist/core/model-registry.d.ts +5 -5
  96. package/dist/core/model-registry.d.ts.map +1 -1
  97. package/dist/core/model-registry.js +7 -7
  98. package/dist/core/model-registry.js.map +1 -1
  99. package/dist/core/model-resolver.d.ts +7 -7
  100. package/dist/core/model-resolver.d.ts.map +1 -1
  101. package/dist/core/model-resolver.js +45 -14
  102. package/dist/core/model-resolver.js.map +1 -1
  103. package/dist/core/sdk.d.ts +7 -10
  104. package/dist/core/sdk.d.ts.map +1 -1
  105. package/dist/core/sdk.js +88 -32
  106. package/dist/core/sdk.js.map +1 -1
  107. package/dist/core/session-manager.d.ts +202 -36
  108. package/dist/core/session-manager.d.ts.map +1 -1
  109. package/dist/core/session-manager.js +565 -133
  110. package/dist/core/session-manager.js.map +1 -1
  111. package/dist/core/settings-manager.d.ts +9 -3
  112. package/dist/core/settings-manager.d.ts.map +1 -1
  113. package/dist/core/settings-manager.js +13 -12
  114. package/dist/core/settings-manager.js.map +1 -1
  115. package/dist/core/system-prompt.d.ts.map +1 -1
  116. package/dist/core/system-prompt.js +6 -3
  117. package/dist/core/system-prompt.js.map +1 -1
  118. package/dist/core/tools/bash.d.ts +1 -1
  119. package/dist/core/tools/bash.d.ts.map +1 -1
  120. package/dist/core/tools/bash.js.map +1 -1
  121. package/dist/core/tools/edit-diff.d.ts +33 -0
  122. package/dist/core/tools/edit-diff.d.ts.map +1 -0
  123. package/dist/core/tools/edit-diff.js +171 -0
  124. package/dist/core/tools/edit-diff.js.map +1 -0
  125. package/dist/core/tools/edit.d.ts +7 -1
  126. package/dist/core/tools/edit.d.ts.map +1 -1
  127. package/dist/core/tools/edit.js +20 -95
  128. package/dist/core/tools/edit.js.map +1 -1
  129. package/dist/core/tools/find.d.ts +1 -1
  130. package/dist/core/tools/find.d.ts.map +1 -1
  131. package/dist/core/tools/find.js.map +1 -1
  132. package/dist/core/tools/grep.d.ts +1 -1
  133. package/dist/core/tools/grep.d.ts.map +1 -1
  134. package/dist/core/tools/grep.js.map +1 -1
  135. package/dist/core/tools/index.d.ts +1 -1
  136. package/dist/core/tools/index.d.ts.map +1 -1
  137. package/dist/core/tools/index.js.map +1 -1
  138. package/dist/core/tools/ls.d.ts +1 -1
  139. package/dist/core/tools/ls.d.ts.map +1 -1
  140. package/dist/core/tools/ls.js.map +1 -1
  141. package/dist/core/tools/read.d.ts +1 -1
  142. package/dist/core/tools/read.d.ts.map +1 -1
  143. package/dist/core/tools/read.js.map +1 -1
  144. package/dist/core/tools/write.d.ts +1 -1
  145. package/dist/core/tools/write.d.ts.map +1 -1
  146. package/dist/core/tools/write.js.map +1 -1
  147. package/dist/index.d.ts +8 -7
  148. package/dist/index.d.ts.map +1 -1
  149. package/dist/index.js +5 -5
  150. package/dist/index.js.map +1 -1
  151. package/dist/main.d.ts.map +1 -1
  152. package/dist/main.js +22 -21
  153. package/dist/main.js.map +1 -1
  154. package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
  155. package/dist/modes/interactive/components/assistant-message.js +3 -4
  156. package/dist/modes/interactive/components/assistant-message.js.map +1 -1
  157. package/dist/modes/interactive/components/bash-execution.d.ts +1 -1
  158. package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -1
  159. package/dist/modes/interactive/components/bash-execution.js +6 -2
  160. package/dist/modes/interactive/components/bash-execution.js.map +1 -1
  161. package/dist/modes/interactive/components/bordered-loader.d.ts +12 -0
  162. package/dist/modes/interactive/components/bordered-loader.d.ts.map +1 -0
  163. package/dist/modes/interactive/components/bordered-loader.js +30 -0
  164. package/dist/modes/interactive/components/bordered-loader.js.map +1 -0
  165. package/dist/modes/interactive/components/branch-summary-message.d.ts +14 -0
  166. package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -0
  167. package/dist/modes/interactive/components/branch-summary-message.js +35 -0
  168. package/dist/modes/interactive/components/branch-summary-message.js.map +1 -0
  169. package/dist/modes/interactive/components/compaction-summary-message.d.ts +14 -0
  170. package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -0
  171. package/dist/modes/interactive/components/compaction-summary-message.js +36 -0
  172. package/dist/modes/interactive/components/compaction-summary-message.js.map +1 -0
  173. package/dist/modes/interactive/components/dynamic-border.d.ts +5 -1
  174. package/dist/modes/interactive/components/dynamic-border.d.ts.map +1 -1
  175. package/dist/modes/interactive/components/dynamic-border.js +5 -1
  176. package/dist/modes/interactive/components/dynamic-border.js.map +1 -1
  177. package/dist/modes/interactive/components/footer.d.ts +12 -6
  178. package/dist/modes/interactive/components/footer.d.ts.map +1 -1
  179. package/dist/modes/interactive/components/footer.js +57 -25
  180. package/dist/modes/interactive/components/footer.js.map +1 -1
  181. package/dist/modes/interactive/components/hook-editor.d.ts +15 -0
  182. package/dist/modes/interactive/components/hook-editor.d.ts.map +1 -0
  183. package/dist/modes/interactive/components/hook-editor.js +95 -0
  184. package/dist/modes/interactive/components/hook-editor.js.map +1 -0
  185. package/dist/modes/interactive/components/hook-message.d.ts +18 -0
  186. package/dist/modes/interactive/components/hook-message.d.ts.map +1 -0
  187. package/dist/modes/interactive/components/hook-message.js +80 -0
  188. package/dist/modes/interactive/components/hook-message.js.map +1 -0
  189. package/dist/modes/interactive/components/model-selector.d.ts +3 -3
  190. package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
  191. package/dist/modes/interactive/components/model-selector.js +1 -1
  192. package/dist/modes/interactive/components/model-selector.js.map +1 -1
  193. package/dist/modes/interactive/components/tool-execution.d.ts +15 -2
  194. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  195. package/dist/modes/interactive/components/tool-execution.js +70 -21
  196. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  197. package/dist/modes/interactive/components/tree-selector.d.ts +52 -0
  198. package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -0
  199. package/dist/modes/interactive/components/tree-selector.js +745 -0
  200. package/dist/modes/interactive/components/tree-selector.js.map +1 -0
  201. package/dist/modes/interactive/components/user-message-selector.d.ts +3 -3
  202. package/dist/modes/interactive/components/user-message-selector.d.ts.map +1 -1
  203. package/dist/modes/interactive/components/user-message-selector.js +1 -1
  204. package/dist/modes/interactive/components/user-message-selector.js.map +1 -1
  205. package/dist/modes/interactive/components/user-message.d.ts +1 -1
  206. package/dist/modes/interactive/components/user-message.d.ts.map +1 -1
  207. package/dist/modes/interactive/components/user-message.js +2 -5
  208. package/dist/modes/interactive/components/user-message.js.map +1 -1
  209. package/dist/modes/interactive/interactive-mode.d.ts +29 -12
  210. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  211. package/dist/modes/interactive/interactive-mode.js +589 -208
  212. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  213. package/dist/modes/interactive/theme/dark.json +13 -1
  214. package/dist/modes/interactive/theme/light.json +13 -1
  215. package/dist/modes/interactive/theme/theme-schema.json +34 -0
  216. package/dist/modes/interactive/theme/theme.d.ts +20 -2
  217. package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
  218. package/dist/modes/interactive/theme/theme.js +135 -2
  219. package/dist/modes/interactive/theme/theme.js.map +1 -1
  220. package/dist/modes/print-mode.d.ts +3 -3
  221. package/dist/modes/print-mode.d.ts.map +1 -1
  222. package/dist/modes/print-mode.js +26 -20
  223. package/dist/modes/print-mode.js.map +1 -1
  224. package/dist/modes/rpc/rpc-client.d.ts +13 -10
  225. package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
  226. package/dist/modes/rpc/rpc-client.js +11 -10
  227. package/dist/modes/rpc/rpc-client.js.map +1 -1
  228. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  229. package/dist/modes/rpc/rpc-mode.js +88 -35
  230. package/dist/modes/rpc/rpc-mode.js.map +1 -1
  231. package/dist/modes/rpc/rpc-types.d.ts +30 -11
  232. package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
  233. package/dist/modes/rpc/rpc-types.js.map +1 -1
  234. package/dist/utils/shell.d.ts +4 -2
  235. package/dist/utils/shell.d.ts.map +1 -1
  236. package/dist/utils/shell.js +36 -7
  237. package/dist/utils/shell.js.map +1 -1
  238. package/dist/utils/tools-manager.d.ts +1 -1
  239. package/dist/utils/tools-manager.d.ts.map +1 -1
  240. package/dist/utils/tools-manager.js +2 -2
  241. package/dist/utils/tools-manager.js.map +1 -1
  242. package/docs/compaction.md +388 -0
  243. package/docs/custom-tools.md +146 -43
  244. package/docs/extension-loading.md +1004 -0
  245. package/docs/hooks.md +562 -596
  246. package/docs/rpc.md +33 -19
  247. package/docs/sdk.md +93 -21
  248. package/docs/session-tree-plan.md +441 -0
  249. package/docs/session.md +172 -21
  250. package/docs/skills.md +2 -0
  251. package/docs/theme.md +31 -2
  252. package/docs/tree.md +197 -0
  253. package/docs/tui.md +343 -0
  254. package/examples/README.md +1 -9
  255. package/examples/custom-tools/hello/index.ts +4 -3
  256. package/examples/custom-tools/question/index.ts +4 -4
  257. package/examples/custom-tools/subagent/index.ts +7 -6
  258. package/examples/custom-tools/todo/index.ts +11 -5
  259. package/examples/hooks/README.md +29 -71
  260. package/examples/hooks/auto-commit-on-exit.ts +8 -9
  261. package/examples/hooks/confirm-destructive.ts +29 -30
  262. package/examples/hooks/custom-compaction.ts +20 -21
  263. package/examples/hooks/dirty-repo-guard.ts +41 -40
  264. package/examples/hooks/file-trigger.ts +10 -5
  265. package/examples/hooks/git-checkpoint.ts +16 -12
  266. package/examples/hooks/handoff.ts +150 -0
  267. package/examples/hooks/permission-gate.ts +1 -1
  268. package/examples/hooks/protected-paths.ts +1 -1
  269. package/examples/hooks/qna.ts +119 -0
  270. package/examples/hooks/snake.ts +343 -0
  271. package/examples/hooks/status-line.ts +40 -0
  272. package/examples/sdk/01-minimal.ts +1 -1
  273. package/examples/sdk/02-custom-model.ts +1 -1
  274. package/examples/sdk/03-custom-prompt.ts +1 -1
  275. package/examples/sdk/04-skills.ts +1 -1
  276. package/examples/sdk/05-tools.ts +4 -4
  277. package/examples/sdk/06-hooks.ts +1 -1
  278. package/examples/sdk/07-context-files.ts +1 -1
  279. package/examples/sdk/08-slash-commands.ts +6 -1
  280. package/examples/sdk/09-api-keys-and-oauth.ts +1 -1
  281. package/examples/sdk/10-settings.ts +1 -1
  282. package/examples/sdk/11-sessions.ts +1 -1
  283. package/examples/sdk/12-full-control.ts +4 -7
  284. package/package.json +6 -6
  285. package/dist/core/compaction.d.ts.map +0 -1
  286. package/dist/core/compaction.js +0 -412
  287. package/dist/core/compaction.js.map +0 -1
  288. package/dist/core/export-html.d.ts +0 -23
  289. package/dist/core/export-html.d.ts.map +0 -1
  290. package/dist/core/export-html.js +0 -1185
  291. package/dist/core/export-html.js.map +0 -1
  292. package/dist/modes/interactive/components/compaction.d.ts +0 -15
  293. package/dist/modes/interactive/components/compaction.d.ts.map +0 -1
  294. package/dist/modes/interactive/components/compaction.js +0 -41
  295. package/dist/modes/interactive/components/compaction.js.map +0 -1
  296. package/docs/hooks-v2.md +0 -385
  297. package/docs/session-tree.md +0 -452
@@ -0,0 +1,745 @@
1
+ import { Container, Input, isArrowDown, isArrowLeft, isArrowRight, isArrowUp, isBackspace, isCtrlC, isCtrlO, isEnter, isEscape, isShiftCtrlO, Spacer, Text, TruncatedText, truncateToWidth, } from "@mariozechner/pi-tui";
2
+ import { theme } from "../theme/theme.js";
3
+ import { DynamicBorder } from "./dynamic-border.js";
4
+ class TreeList {
5
+ flatNodes = [];
6
+ filteredNodes = [];
7
+ selectedIndex = 0;
8
+ currentLeafId;
9
+ maxVisibleLines;
10
+ filterMode = "default";
11
+ searchQuery = "";
12
+ toolCallMap = new Map();
13
+ multipleRoots = false;
14
+ activePathIds = new Set();
15
+ onSelect;
16
+ onCancel;
17
+ onLabelEdit;
18
+ constructor(tree, currentLeafId, maxVisibleLines) {
19
+ this.currentLeafId = currentLeafId;
20
+ this.maxVisibleLines = maxVisibleLines;
21
+ this.multipleRoots = tree.length > 1;
22
+ this.flatNodes = this.flattenTree(tree);
23
+ this.buildActivePath();
24
+ this.applyFilter();
25
+ // Start with current leaf selected
26
+ const leafIndex = this.filteredNodes.findIndex((n) => n.node.entry.id === currentLeafId);
27
+ if (leafIndex !== -1) {
28
+ this.selectedIndex = leafIndex;
29
+ }
30
+ else {
31
+ this.selectedIndex = Math.max(0, this.filteredNodes.length - 1);
32
+ }
33
+ }
34
+ /** Build the set of entry IDs on the path from root to current leaf */
35
+ buildActivePath() {
36
+ this.activePathIds.clear();
37
+ if (!this.currentLeafId)
38
+ return;
39
+ // Build a map of id -> entry for parent lookup
40
+ const entryMap = new Map();
41
+ for (const flatNode of this.flatNodes) {
42
+ entryMap.set(flatNode.node.entry.id, flatNode);
43
+ }
44
+ // Walk from leaf to root
45
+ let currentId = this.currentLeafId;
46
+ while (currentId) {
47
+ this.activePathIds.add(currentId);
48
+ const node = entryMap.get(currentId);
49
+ if (!node)
50
+ break;
51
+ currentId = node.node.entry.parentId ?? null;
52
+ }
53
+ }
54
+ flattenTree(roots) {
55
+ const result = [];
56
+ this.toolCallMap.clear();
57
+ const stack = [];
58
+ // Determine which subtrees contain the active leaf (to sort current branch first)
59
+ // Use iterative post-order traversal to avoid stack overflow
60
+ const containsActive = new Map();
61
+ const leafId = this.currentLeafId;
62
+ {
63
+ // Build list in pre-order, then process in reverse for post-order effect
64
+ const allNodes = [];
65
+ const preOrderStack = [...roots];
66
+ while (preOrderStack.length > 0) {
67
+ const node = preOrderStack.pop();
68
+ allNodes.push(node);
69
+ // Push children in reverse so they're processed left-to-right
70
+ for (let i = node.children.length - 1; i >= 0; i--) {
71
+ preOrderStack.push(node.children[i]);
72
+ }
73
+ }
74
+ // Process in reverse (post-order): children before parents
75
+ for (let i = allNodes.length - 1; i >= 0; i--) {
76
+ const node = allNodes[i];
77
+ let has = leafId !== null && node.entry.id === leafId;
78
+ for (const child of node.children) {
79
+ if (containsActive.get(child)) {
80
+ has = true;
81
+ }
82
+ }
83
+ containsActive.set(node, has);
84
+ }
85
+ }
86
+ // Add roots in reverse order, prioritizing the one containing the active leaf
87
+ // If multiple roots, treat them as children of a virtual root that branches
88
+ const multipleRoots = roots.length > 1;
89
+ const orderedRoots = [...roots].sort((a, b) => Number(containsActive.get(b)) - Number(containsActive.get(a)));
90
+ for (let i = orderedRoots.length - 1; i >= 0; i--) {
91
+ const isLast = i === orderedRoots.length - 1;
92
+ stack.push([orderedRoots[i], multipleRoots ? 1 : 0, multipleRoots, multipleRoots, isLast, [], multipleRoots]);
93
+ }
94
+ while (stack.length > 0) {
95
+ const [node, indent, justBranched, showConnector, isLast, gutters, isVirtualRootChild] = stack.pop();
96
+ // Extract tool calls from assistant messages for later lookup
97
+ const entry = node.entry;
98
+ if (entry.type === "message" && entry.message.role === "assistant") {
99
+ const content = entry.message.content;
100
+ if (Array.isArray(content)) {
101
+ for (const block of content) {
102
+ if (typeof block === "object" && block !== null && "type" in block && block.type === "toolCall") {
103
+ const tc = block;
104
+ this.toolCallMap.set(tc.id, { name: tc.name, arguments: tc.arguments });
105
+ }
106
+ }
107
+ }
108
+ }
109
+ result.push({ node, indent, showConnector, isLast, gutters, isVirtualRootChild });
110
+ const children = node.children;
111
+ const multipleChildren = children.length > 1;
112
+ // Order children so the branch containing the active leaf comes first
113
+ const orderedChildren = (() => {
114
+ const prioritized = [];
115
+ const rest = [];
116
+ for (const child of children) {
117
+ if (containsActive.get(child)) {
118
+ prioritized.push(child);
119
+ }
120
+ else {
121
+ rest.push(child);
122
+ }
123
+ }
124
+ return [...prioritized, ...rest];
125
+ })();
126
+ // Calculate child indent
127
+ let childIndent;
128
+ if (multipleChildren) {
129
+ // Parent branches: children get +1
130
+ childIndent = indent + 1;
131
+ }
132
+ else if (justBranched && indent > 0) {
133
+ // First generation after a branch: +1 for visual grouping
134
+ childIndent = indent + 1;
135
+ }
136
+ else {
137
+ // Single-child chain: stay flat
138
+ childIndent = indent;
139
+ }
140
+ // Build gutters for children
141
+ // If this node showed a connector, add a gutter entry for descendants
142
+ // Only add gutter if connector is actually displayed (not suppressed for virtual root children)
143
+ const connectorDisplayed = showConnector && !isVirtualRootChild;
144
+ // When connector is displayed, add a gutter entry at the connector's position
145
+ // Connector is at position (displayIndent - 1), so gutter should be there too
146
+ const currentDisplayIndent = this.multipleRoots ? Math.max(0, indent - 1) : indent;
147
+ const connectorPosition = Math.max(0, currentDisplayIndent - 1);
148
+ const childGutters = connectorDisplayed
149
+ ? [...gutters, { position: connectorPosition, show: !isLast }]
150
+ : gutters;
151
+ // Add children in reverse order
152
+ for (let i = orderedChildren.length - 1; i >= 0; i--) {
153
+ const childIsLast = i === orderedChildren.length - 1;
154
+ stack.push([
155
+ orderedChildren[i],
156
+ childIndent,
157
+ multipleChildren,
158
+ multipleChildren,
159
+ childIsLast,
160
+ childGutters,
161
+ false,
162
+ ]);
163
+ }
164
+ }
165
+ return result;
166
+ }
167
+ applyFilter() {
168
+ // Remember currently selected node to preserve cursor position
169
+ const previouslySelectedId = this.filteredNodes[this.selectedIndex]?.node.entry.id;
170
+ const searchTokens = this.searchQuery.toLowerCase().split(/\s+/).filter(Boolean);
171
+ this.filteredNodes = this.flatNodes.filter((flatNode) => {
172
+ const entry = flatNode.node.entry;
173
+ const isCurrentLeaf = entry.id === this.currentLeafId;
174
+ // Skip assistant messages with only tool calls (no text) unless error/aborted
175
+ // Always show current leaf so active position is visible
176
+ if (entry.type === "message" && entry.message.role === "assistant" && !isCurrentLeaf) {
177
+ const msg = entry.message;
178
+ const hasText = this.hasTextContent(msg.content);
179
+ const isErrorOrAborted = msg.stopReason && msg.stopReason !== "stop" && msg.stopReason !== "toolUse";
180
+ // Only hide if no text AND not an error/aborted message
181
+ if (!hasText && !isErrorOrAborted) {
182
+ return false;
183
+ }
184
+ }
185
+ // Apply filter mode
186
+ let passesFilter = true;
187
+ // Entry types hidden in default view (settings/bookkeeping)
188
+ const isSettingsEntry = entry.type === "label" ||
189
+ entry.type === "custom" ||
190
+ entry.type === "model_change" ||
191
+ entry.type === "thinking_level_change";
192
+ switch (this.filterMode) {
193
+ case "user-only":
194
+ // Just user messages
195
+ passesFilter = entry.type === "message" && entry.message.role === "user";
196
+ break;
197
+ case "no-tools":
198
+ // Default minus tool results
199
+ passesFilter = !isSettingsEntry && !(entry.type === "message" && entry.message.role === "toolResult");
200
+ break;
201
+ case "labeled-only":
202
+ // Just labeled entries
203
+ passesFilter = flatNode.node.label !== undefined;
204
+ break;
205
+ case "all":
206
+ // Show everything
207
+ passesFilter = true;
208
+ break;
209
+ default:
210
+ // Default mode: hide settings/bookkeeping entries
211
+ passesFilter = !isSettingsEntry;
212
+ break;
213
+ }
214
+ if (!passesFilter)
215
+ return false;
216
+ // Apply search filter
217
+ if (searchTokens.length > 0) {
218
+ const nodeText = this.getSearchableText(flatNode.node).toLowerCase();
219
+ return searchTokens.every((token) => nodeText.includes(token));
220
+ }
221
+ return true;
222
+ });
223
+ // Try to preserve cursor on the same node after filtering
224
+ if (previouslySelectedId) {
225
+ const newIndex = this.filteredNodes.findIndex((n) => n.node.entry.id === previouslySelectedId);
226
+ if (newIndex !== -1) {
227
+ this.selectedIndex = newIndex;
228
+ return;
229
+ }
230
+ }
231
+ // Fall back: clamp index if out of bounds
232
+ if (this.selectedIndex >= this.filteredNodes.length) {
233
+ this.selectedIndex = Math.max(0, this.filteredNodes.length - 1);
234
+ }
235
+ }
236
+ /** Get searchable text content from a node */
237
+ getSearchableText(node) {
238
+ const entry = node.entry;
239
+ const parts = [];
240
+ if (node.label) {
241
+ parts.push(node.label);
242
+ }
243
+ switch (entry.type) {
244
+ case "message": {
245
+ const msg = entry.message;
246
+ parts.push(msg.role);
247
+ if ("content" in msg && msg.content) {
248
+ parts.push(this.extractContent(msg.content));
249
+ }
250
+ if (msg.role === "bashExecution") {
251
+ const bashMsg = msg;
252
+ if (bashMsg.command)
253
+ parts.push(bashMsg.command);
254
+ }
255
+ break;
256
+ }
257
+ case "custom_message": {
258
+ parts.push(entry.customType);
259
+ if (typeof entry.content === "string") {
260
+ parts.push(entry.content);
261
+ }
262
+ else {
263
+ parts.push(this.extractContent(entry.content));
264
+ }
265
+ break;
266
+ }
267
+ case "compaction":
268
+ parts.push("compaction");
269
+ break;
270
+ case "branch_summary":
271
+ parts.push("branch summary", entry.summary);
272
+ break;
273
+ case "model_change":
274
+ parts.push("model", entry.modelId);
275
+ break;
276
+ case "thinking_level_change":
277
+ parts.push("thinking", entry.thinkingLevel);
278
+ break;
279
+ case "custom":
280
+ parts.push("custom", entry.customType);
281
+ break;
282
+ case "label":
283
+ parts.push("label", entry.label ?? "");
284
+ break;
285
+ }
286
+ return parts.join(" ");
287
+ }
288
+ invalidate() { }
289
+ getSearchQuery() {
290
+ return this.searchQuery;
291
+ }
292
+ getSelectedNode() {
293
+ return this.filteredNodes[this.selectedIndex]?.node;
294
+ }
295
+ updateNodeLabel(entryId, label) {
296
+ for (const flatNode of this.flatNodes) {
297
+ if (flatNode.node.entry.id === entryId) {
298
+ flatNode.node.label = label;
299
+ break;
300
+ }
301
+ }
302
+ }
303
+ getFilterLabel() {
304
+ switch (this.filterMode) {
305
+ case "no-tools":
306
+ return " [no-tools]";
307
+ case "user-only":
308
+ return " [user]";
309
+ case "labeled-only":
310
+ return " [labeled]";
311
+ case "all":
312
+ return " [all]";
313
+ default:
314
+ return "";
315
+ }
316
+ }
317
+ render(width) {
318
+ const lines = [];
319
+ if (this.filteredNodes.length === 0) {
320
+ lines.push(truncateToWidth(theme.fg("muted", " No entries found"), width));
321
+ lines.push(truncateToWidth(theme.fg("muted", ` (0/0)${this.getFilterLabel()}`), width));
322
+ return lines;
323
+ }
324
+ const startIndex = Math.max(0, Math.min(this.selectedIndex - Math.floor(this.maxVisibleLines / 2), this.filteredNodes.length - this.maxVisibleLines));
325
+ const endIndex = Math.min(startIndex + this.maxVisibleLines, this.filteredNodes.length);
326
+ for (let i = startIndex; i < endIndex; i++) {
327
+ const flatNode = this.filteredNodes[i];
328
+ const entry = flatNode.node.entry;
329
+ const isSelected = i === this.selectedIndex;
330
+ // Build line: cursor + prefix + path marker + label + content
331
+ const cursor = isSelected ? theme.fg("accent", "› ") : " ";
332
+ // If multiple roots, shift display (roots at 0, not 1)
333
+ const displayIndent = this.multipleRoots ? Math.max(0, flatNode.indent - 1) : flatNode.indent;
334
+ // Build prefix with gutters at their correct positions
335
+ // Each gutter has a position (displayIndent where its connector was shown)
336
+ const connector = flatNode.showConnector && !flatNode.isVirtualRootChild ? (flatNode.isLast ? "└─ " : "├─ ") : "";
337
+ const connectorPosition = connector ? displayIndent - 1 : -1;
338
+ // Build prefix char by char, placing gutters and connector at their positions
339
+ const totalChars = displayIndent * 3;
340
+ const prefixChars = [];
341
+ for (let i = 0; i < totalChars; i++) {
342
+ const level = Math.floor(i / 3);
343
+ const posInLevel = i % 3;
344
+ // Check if there's a gutter at this level
345
+ const gutter = flatNode.gutters.find((g) => g.position === level);
346
+ if (gutter) {
347
+ if (posInLevel === 0) {
348
+ prefixChars.push(gutter.show ? "│" : " ");
349
+ }
350
+ else {
351
+ prefixChars.push(" ");
352
+ }
353
+ }
354
+ else if (connector && level === connectorPosition) {
355
+ // Connector at this level
356
+ if (posInLevel === 0) {
357
+ prefixChars.push(flatNode.isLast ? "└" : "├");
358
+ }
359
+ else if (posInLevel === 1) {
360
+ prefixChars.push("─");
361
+ }
362
+ else {
363
+ prefixChars.push(" ");
364
+ }
365
+ }
366
+ else {
367
+ prefixChars.push(" ");
368
+ }
369
+ }
370
+ const prefix = prefixChars.join("");
371
+ // Active path marker - shown right before the entry text
372
+ const isOnActivePath = this.activePathIds.has(entry.id);
373
+ const pathMarker = isOnActivePath ? theme.fg("accent", "• ") : "";
374
+ const label = flatNode.node.label ? theme.fg("warning", `[${flatNode.node.label}] `) : "";
375
+ const content = this.getEntryDisplayText(flatNode.node, isSelected);
376
+ let line = cursor + theme.fg("dim", prefix) + pathMarker + label + content;
377
+ if (isSelected) {
378
+ line = theme.bg("selectedBg", line);
379
+ }
380
+ lines.push(truncateToWidth(line, width));
381
+ }
382
+ lines.push(truncateToWidth(theme.fg("muted", ` (${this.selectedIndex + 1}/${this.filteredNodes.length})${this.getFilterLabel()}`), width));
383
+ return lines;
384
+ }
385
+ getEntryDisplayText(node, isSelected) {
386
+ const entry = node.entry;
387
+ let result;
388
+ const normalize = (s) => s.replace(/[\n\t]/g, " ").trim();
389
+ switch (entry.type) {
390
+ case "message": {
391
+ const msg = entry.message;
392
+ const role = msg.role;
393
+ if (role === "user") {
394
+ const msgWithContent = msg;
395
+ const content = normalize(this.extractContent(msgWithContent.content));
396
+ result = theme.fg("accent", "user: ") + content;
397
+ }
398
+ else if (role === "assistant") {
399
+ const msgWithContent = msg;
400
+ const textContent = normalize(this.extractContent(msgWithContent.content));
401
+ if (textContent) {
402
+ result = theme.fg("success", "assistant: ") + textContent;
403
+ }
404
+ else if (msgWithContent.stopReason === "aborted") {
405
+ result = theme.fg("success", "assistant: ") + theme.fg("muted", "(aborted)");
406
+ }
407
+ else if (msgWithContent.errorMessage) {
408
+ const errMsg = normalize(msgWithContent.errorMessage).slice(0, 80);
409
+ result = theme.fg("success", "assistant: ") + theme.fg("error", errMsg);
410
+ }
411
+ else {
412
+ result = theme.fg("success", "assistant: ") + theme.fg("muted", "(no content)");
413
+ }
414
+ }
415
+ else if (role === "toolResult") {
416
+ const toolMsg = msg;
417
+ const toolCall = toolMsg.toolCallId ? this.toolCallMap.get(toolMsg.toolCallId) : undefined;
418
+ if (toolCall) {
419
+ result = theme.fg("muted", this.formatToolCall(toolCall.name, toolCall.arguments));
420
+ }
421
+ else {
422
+ result = theme.fg("muted", `[${toolMsg.toolName ?? "tool"}]`);
423
+ }
424
+ }
425
+ else if (role === "bashExecution") {
426
+ const bashMsg = msg;
427
+ result = theme.fg("dim", `[bash]: ${normalize(bashMsg.command ?? "")}`);
428
+ }
429
+ else {
430
+ result = theme.fg("dim", `[${role}]`);
431
+ }
432
+ break;
433
+ }
434
+ case "custom_message": {
435
+ const content = typeof entry.content === "string"
436
+ ? entry.content
437
+ : entry.content
438
+ .filter((c) => c.type === "text")
439
+ .map((c) => c.text)
440
+ .join("");
441
+ result = theme.fg("customMessageLabel", `[${entry.customType}]: `) + normalize(content);
442
+ break;
443
+ }
444
+ case "compaction": {
445
+ const tokens = Math.round(entry.tokensBefore / 1000);
446
+ result = theme.fg("borderAccent", `[compaction: ${tokens}k tokens]`);
447
+ break;
448
+ }
449
+ case "branch_summary":
450
+ result = theme.fg("warning", `[branch summary]: `) + normalize(entry.summary);
451
+ break;
452
+ case "model_change":
453
+ result = theme.fg("dim", `[model: ${entry.modelId}]`);
454
+ break;
455
+ case "thinking_level_change":
456
+ result = theme.fg("dim", `[thinking: ${entry.thinkingLevel}]`);
457
+ break;
458
+ case "custom":
459
+ result = theme.fg("dim", `[custom: ${entry.customType}]`);
460
+ break;
461
+ case "label":
462
+ result = theme.fg("dim", `[label: ${entry.label ?? "(cleared)"}]`);
463
+ break;
464
+ default:
465
+ result = "";
466
+ }
467
+ return isSelected ? theme.bold(result) : result;
468
+ }
469
+ extractContent(content) {
470
+ const maxLen = 200;
471
+ if (typeof content === "string")
472
+ return content.slice(0, maxLen);
473
+ if (Array.isArray(content)) {
474
+ let result = "";
475
+ for (const c of content) {
476
+ if (typeof c === "object" && c !== null && "type" in c && c.type === "text") {
477
+ result += c.text;
478
+ if (result.length >= maxLen)
479
+ return result.slice(0, maxLen);
480
+ }
481
+ }
482
+ return result;
483
+ }
484
+ return "";
485
+ }
486
+ hasTextContent(content) {
487
+ if (typeof content === "string")
488
+ return content.trim().length > 0;
489
+ if (Array.isArray(content)) {
490
+ for (const c of content) {
491
+ if (typeof c === "object" && c !== null && "type" in c && c.type === "text") {
492
+ const text = c.text;
493
+ if (text && text.trim().length > 0)
494
+ return true;
495
+ }
496
+ }
497
+ }
498
+ return false;
499
+ }
500
+ formatToolCall(name, args) {
501
+ const shortenPath = (p) => {
502
+ const home = process.env.HOME || process.env.USERPROFILE || "";
503
+ if (home && p.startsWith(home))
504
+ return `~${p.slice(home.length)}`;
505
+ return p;
506
+ };
507
+ switch (name) {
508
+ case "read": {
509
+ const path = shortenPath(String(args.path || args.file_path || ""));
510
+ const offset = args.offset;
511
+ const limit = args.limit;
512
+ let display = path;
513
+ if (offset !== undefined || limit !== undefined) {
514
+ const start = offset ?? 1;
515
+ const end = limit !== undefined ? start + limit - 1 : "";
516
+ display += `:${start}${end ? `-${end}` : ""}`;
517
+ }
518
+ return `[read: ${display}]`;
519
+ }
520
+ case "write": {
521
+ const path = shortenPath(String(args.path || args.file_path || ""));
522
+ return `[write: ${path}]`;
523
+ }
524
+ case "edit": {
525
+ const path = shortenPath(String(args.path || args.file_path || ""));
526
+ return `[edit: ${path}]`;
527
+ }
528
+ case "bash": {
529
+ const rawCmd = String(args.command || "");
530
+ const cmd = rawCmd
531
+ .replace(/[\n\t]/g, " ")
532
+ .trim()
533
+ .slice(0, 50);
534
+ return `[bash: ${cmd}${rawCmd.length > 50 ? "..." : ""}]`;
535
+ }
536
+ case "grep": {
537
+ const pattern = String(args.pattern || "");
538
+ const path = shortenPath(String(args.path || "."));
539
+ return `[grep: /${pattern}/ in ${path}]`;
540
+ }
541
+ case "find": {
542
+ const pattern = String(args.pattern || "");
543
+ const path = shortenPath(String(args.path || "."));
544
+ return `[find: ${pattern} in ${path}]`;
545
+ }
546
+ case "ls": {
547
+ const path = shortenPath(String(args.path || "."));
548
+ return `[ls: ${path}]`;
549
+ }
550
+ default: {
551
+ // Custom tool - show name and truncated JSON args
552
+ const argsStr = JSON.stringify(args).slice(0, 40);
553
+ return `[${name}: ${argsStr}${JSON.stringify(args).length > 40 ? "..." : ""}]`;
554
+ }
555
+ }
556
+ }
557
+ handleInput(keyData) {
558
+ if (isArrowUp(keyData)) {
559
+ this.selectedIndex = this.selectedIndex === 0 ? this.filteredNodes.length - 1 : this.selectedIndex - 1;
560
+ }
561
+ else if (isArrowDown(keyData)) {
562
+ this.selectedIndex = this.selectedIndex === this.filteredNodes.length - 1 ? 0 : this.selectedIndex + 1;
563
+ }
564
+ else if (isArrowLeft(keyData)) {
565
+ // Page up
566
+ this.selectedIndex = Math.max(0, this.selectedIndex - this.maxVisibleLines);
567
+ }
568
+ else if (isArrowRight(keyData)) {
569
+ // Page down
570
+ this.selectedIndex = Math.min(this.filteredNodes.length - 1, this.selectedIndex + this.maxVisibleLines);
571
+ }
572
+ else if (isEnter(keyData)) {
573
+ const selected = this.filteredNodes[this.selectedIndex];
574
+ if (selected && this.onSelect) {
575
+ this.onSelect(selected.node.entry.id);
576
+ }
577
+ }
578
+ else if (isEscape(keyData)) {
579
+ if (this.searchQuery) {
580
+ this.searchQuery = "";
581
+ this.applyFilter();
582
+ }
583
+ else {
584
+ this.onCancel?.();
585
+ }
586
+ }
587
+ else if (isCtrlC(keyData)) {
588
+ this.onCancel?.();
589
+ }
590
+ else if (isShiftCtrlO(keyData)) {
591
+ // Cycle filter backwards
592
+ const modes = ["default", "no-tools", "user-only", "labeled-only", "all"];
593
+ const currentIndex = modes.indexOf(this.filterMode);
594
+ this.filterMode = modes[(currentIndex - 1 + modes.length) % modes.length];
595
+ this.applyFilter();
596
+ }
597
+ else if (isCtrlO(keyData)) {
598
+ // Cycle filter forwards: default → no-tools → user-only → labeled-only → all → default
599
+ const modes = ["default", "no-tools", "user-only", "labeled-only", "all"];
600
+ const currentIndex = modes.indexOf(this.filterMode);
601
+ this.filterMode = modes[(currentIndex + 1) % modes.length];
602
+ this.applyFilter();
603
+ }
604
+ else if (isBackspace(keyData)) {
605
+ if (this.searchQuery.length > 0) {
606
+ this.searchQuery = this.searchQuery.slice(0, -1);
607
+ this.applyFilter();
608
+ }
609
+ }
610
+ else if (keyData === "l" && !this.searchQuery) {
611
+ const selected = this.filteredNodes[this.selectedIndex];
612
+ if (selected && this.onLabelEdit) {
613
+ this.onLabelEdit(selected.node.entry.id, selected.node.label);
614
+ }
615
+ }
616
+ else {
617
+ const hasControlChars = [...keyData].some((ch) => {
618
+ const code = ch.charCodeAt(0);
619
+ return code < 32 || code === 0x7f || (code >= 0x80 && code <= 0x9f);
620
+ });
621
+ if (!hasControlChars && keyData.length > 0) {
622
+ this.searchQuery += keyData;
623
+ this.applyFilter();
624
+ }
625
+ }
626
+ }
627
+ }
628
+ /** Component that displays the current search query */
629
+ class SearchLine {
630
+ treeList;
631
+ constructor(treeList) {
632
+ this.treeList = treeList;
633
+ }
634
+ invalidate() { }
635
+ render(width) {
636
+ const query = this.treeList.getSearchQuery();
637
+ if (query) {
638
+ return [truncateToWidth(` ${theme.fg("muted", "Search:")} ${theme.fg("accent", query)}`, width)];
639
+ }
640
+ return [truncateToWidth(` ${theme.fg("muted", "Search:")}`, width)];
641
+ }
642
+ handleInput(_keyData) { }
643
+ }
644
+ /** Label input component shown when editing a label */
645
+ class LabelInput {
646
+ input;
647
+ entryId;
648
+ onSubmit;
649
+ onCancel;
650
+ constructor(entryId, currentLabel) {
651
+ this.entryId = entryId;
652
+ this.input = new Input();
653
+ if (currentLabel) {
654
+ this.input.setValue(currentLabel);
655
+ }
656
+ }
657
+ invalidate() { }
658
+ render(width) {
659
+ const lines = [];
660
+ const indent = " ";
661
+ const availableWidth = width - indent.length;
662
+ lines.push(truncateToWidth(`${indent}${theme.fg("muted", "Label (empty to remove):")}`, width));
663
+ lines.push(...this.input.render(availableWidth).map((line) => truncateToWidth(`${indent}${line}`, width)));
664
+ lines.push(truncateToWidth(`${indent}${theme.fg("dim", "enter: save esc: cancel")}`, width));
665
+ return lines;
666
+ }
667
+ handleInput(keyData) {
668
+ if (isEnter(keyData)) {
669
+ const value = this.input.getValue().trim();
670
+ this.onSubmit?.(this.entryId, value || undefined);
671
+ }
672
+ else if (isEscape(keyData)) {
673
+ this.onCancel?.();
674
+ }
675
+ else {
676
+ this.input.handleInput(keyData);
677
+ }
678
+ }
679
+ }
680
+ /**
681
+ * Component that renders a session tree selector for navigation
682
+ */
683
+ export class TreeSelectorComponent extends Container {
684
+ treeList;
685
+ labelInput = null;
686
+ labelInputContainer;
687
+ treeContainer;
688
+ onLabelChangeCallback;
689
+ constructor(tree, currentLeafId, terminalHeight, onSelect, onCancel, onLabelChange) {
690
+ super();
691
+ this.onLabelChangeCallback = onLabelChange;
692
+ const maxVisibleLines = Math.max(5, Math.floor(terminalHeight / 2));
693
+ this.treeList = new TreeList(tree, currentLeafId, maxVisibleLines);
694
+ this.treeList.onSelect = onSelect;
695
+ this.treeList.onCancel = onCancel;
696
+ this.treeList.onLabelEdit = (entryId, currentLabel) => this.showLabelInput(entryId, currentLabel);
697
+ this.treeContainer = new Container();
698
+ this.treeContainer.addChild(this.treeList);
699
+ this.labelInputContainer = new Container();
700
+ this.addChild(new Spacer(1));
701
+ this.addChild(new DynamicBorder());
702
+ this.addChild(new Text(theme.bold(" Session Tree"), 1, 0));
703
+ this.addChild(new TruncatedText(theme.fg("muted", " ↑/↓: move. ←/→: page. l: label. ^O/⇧^O: filter. Type to search"), 0, 0));
704
+ this.addChild(new SearchLine(this.treeList));
705
+ this.addChild(new DynamicBorder());
706
+ this.addChild(new Spacer(1));
707
+ this.addChild(this.treeContainer);
708
+ this.addChild(this.labelInputContainer);
709
+ this.addChild(new Spacer(1));
710
+ this.addChild(new DynamicBorder());
711
+ if (tree.length === 0) {
712
+ setTimeout(() => onCancel(), 100);
713
+ }
714
+ }
715
+ showLabelInput(entryId, currentLabel) {
716
+ this.labelInput = new LabelInput(entryId, currentLabel);
717
+ this.labelInput.onSubmit = (id, label) => {
718
+ this.treeList.updateNodeLabel(id, label);
719
+ this.onLabelChangeCallback?.(id, label);
720
+ this.hideLabelInput();
721
+ };
722
+ this.labelInput.onCancel = () => this.hideLabelInput();
723
+ this.treeContainer.clear();
724
+ this.labelInputContainer.clear();
725
+ this.labelInputContainer.addChild(this.labelInput);
726
+ }
727
+ hideLabelInput() {
728
+ this.labelInput = null;
729
+ this.labelInputContainer.clear();
730
+ this.treeContainer.clear();
731
+ this.treeContainer.addChild(this.treeList);
732
+ }
733
+ handleInput(keyData) {
734
+ if (this.labelInput) {
735
+ this.labelInput.handleInput(keyData);
736
+ }
737
+ else {
738
+ this.treeList.handleInput(keyData);
739
+ }
740
+ }
741
+ getTreeList() {
742
+ return this.treeList;
743
+ }
744
+ }
745
+ //# sourceMappingURL=tree-selector.js.map