@onpoint-dev-tools/crewcoder-opentui 0.0.0-stage → 0.1.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 (325) hide show
  1. package/LICENSE +191 -0
  2. package/README.md +262 -2
  3. package/THIRD_PARTY_NOTICES.md +51 -0
  4. package/dist/App.d.ts +16 -0
  5. package/dist/App.d.ts.map +1 -0
  6. package/dist/App.js +428 -0
  7. package/dist/App.js.map +1 -0
  8. package/dist/Root.d.ts +11 -0
  9. package/dist/Root.d.ts.map +1 -0
  10. package/dist/Root.js +13 -0
  11. package/dist/Root.js.map +1 -0
  12. package/dist/alert-model.d.ts +31 -0
  13. package/dist/alert-model.d.ts.map +1 -0
  14. package/dist/alert-model.js +34 -0
  15. package/dist/alert-model.js.map +1 -0
  16. package/dist/args.d.ts +13 -0
  17. package/dist/args.d.ts.map +1 -0
  18. package/dist/args.js +63 -0
  19. package/dist/args.js.map +1 -0
  20. package/dist/attachments.d.ts +29 -0
  21. package/dist/attachments.d.ts.map +1 -0
  22. package/dist/attachments.js +38 -0
  23. package/dist/attachments.js.map +1 -0
  24. package/dist/block-panels.d.ts +43 -0
  25. package/dist/block-panels.d.ts.map +1 -0
  26. package/dist/block-panels.js +210 -0
  27. package/dist/block-panels.js.map +1 -0
  28. package/dist/cli.d.ts +3 -0
  29. package/dist/cli.d.ts.map +1 -0
  30. package/dist/cli.js +138 -0
  31. package/dist/cli.js.map +1 -0
  32. package/dist/command-format.d.ts +18 -0
  33. package/dist/command-format.d.ts.map +1 -0
  34. package/dist/command-format.js +66 -0
  35. package/dist/command-format.js.map +1 -0
  36. package/dist/command-runner.d.ts +128 -0
  37. package/dist/command-runner.d.ts.map +1 -0
  38. package/dist/command-runner.js +571 -0
  39. package/dist/command-runner.js.map +1 -0
  40. package/dist/commands.d.ts +47 -0
  41. package/dist/commands.d.ts.map +1 -0
  42. package/dist/commands.js +108 -0
  43. package/dist/commands.js.map +1 -0
  44. package/dist/components/AttachmentRow.d.ts +11 -0
  45. package/dist/components/AttachmentRow.d.ts.map +1 -0
  46. package/dist/components/AttachmentRow.js +17 -0
  47. package/dist/components/AttachmentRow.js.map +1 -0
  48. package/dist/components/Composer.d.ts +23 -0
  49. package/dist/components/Composer.d.ts.map +1 -0
  50. package/dist/components/Composer.js +45 -0
  51. package/dist/components/Composer.js.map +1 -0
  52. package/dist/components/ExtensionQuestion.d.ts +18 -0
  53. package/dist/components/ExtensionQuestion.d.ts.map +1 -0
  54. package/dist/components/ExtensionQuestion.js +45 -0
  55. package/dist/components/ExtensionQuestion.js.map +1 -0
  56. package/dist/components/GoalForm.d.ts +18 -0
  57. package/dist/components/GoalForm.d.ts.map +1 -0
  58. package/dist/components/GoalForm.js +26 -0
  59. package/dist/components/GoalForm.js.map +1 -0
  60. package/dist/components/Home.d.ts +21 -0
  61. package/dist/components/Home.d.ts.map +1 -0
  62. package/dist/components/Home.js +48 -0
  63. package/dist/components/Home.js.map +1 -0
  64. package/dist/components/MentionList.d.ts +14 -0
  65. package/dist/components/MentionList.d.ts.map +1 -0
  66. package/dist/components/MentionList.js +24 -0
  67. package/dist/components/MentionList.js.map +1 -0
  68. package/dist/components/SearchBar.d.ts +19 -0
  69. package/dist/components/SearchBar.d.ts.map +1 -0
  70. package/dist/components/SearchBar.js +28 -0
  71. package/dist/components/SearchBar.js.map +1 -0
  72. package/dist/components/Sidebar.d.ts +19 -0
  73. package/dist/components/Sidebar.d.ts.map +1 -0
  74. package/dist/components/Sidebar.js +35 -0
  75. package/dist/components/Sidebar.js.map +1 -0
  76. package/dist/components/SummaryEditor.d.ts +16 -0
  77. package/dist/components/SummaryEditor.d.ts.map +1 -0
  78. package/dist/components/SummaryEditor.js +21 -0
  79. package/dist/components/SummaryEditor.js.map +1 -0
  80. package/dist/components/Transcript.d.ts +37 -0
  81. package/dist/components/Transcript.d.ts.map +1 -0
  82. package/dist/components/Transcript.js +314 -0
  83. package/dist/components/Transcript.js.map +1 -0
  84. package/dist/components/ui/alert.d.ts +9 -0
  85. package/dist/components/ui/alert.d.ts.map +1 -0
  86. package/dist/components/ui/alert.js +18 -0
  87. package/dist/components/ui/alert.js.map +1 -0
  88. package/dist/components/ui/command-palette.d.ts +15 -0
  89. package/dist/components/ui/command-palette.d.ts.map +1 -0
  90. package/dist/components/ui/command-palette.js +14 -0
  91. package/dist/components/ui/command-palette.js.map +1 -0
  92. package/dist/components/ui/confirm.d.ts +12 -0
  93. package/dist/components/ui/confirm.d.ts.map +1 -0
  94. package/dist/components/ui/confirm.js +16 -0
  95. package/dist/components/ui/confirm.js.map +1 -0
  96. package/dist/components/ui/select.d.ts +11 -0
  97. package/dist/components/ui/select.d.ts.map +1 -0
  98. package/dist/components/ui/select.js +29 -0
  99. package/dist/components/ui/select.js.map +1 -0
  100. package/dist/components/ui/spinner.d.ts +14 -0
  101. package/dist/components/ui/spinner.d.ts.map +1 -0
  102. package/dist/components/ui/spinner.js +17 -0
  103. package/dist/components/ui/spinner.js.map +1 -0
  104. package/dist/components/ui/tool-approval.d.ts +14 -0
  105. package/dist/components/ui/tool-approval.d.ts.map +1 -0
  106. package/dist/components/ui/tool-approval.js +37 -0
  107. package/dist/components/ui/tool-approval.js.map +1 -0
  108. package/dist/components/ui/tool-call.d.ts +12 -0
  109. package/dist/components/ui/tool-call.d.ts.map +1 -0
  110. package/dist/components/ui/tool-call.js +69 -0
  111. package/dist/components/ui/tool-call.js.map +1 -0
  112. package/dist/components/ui/types.d.ts +82 -0
  113. package/dist/components/ui/types.d.ts.map +1 -0
  114. package/dist/components/ui/types.js +2 -0
  115. package/dist/components/ui/types.js.map +1 -0
  116. package/dist/crewcoder-cli.d.ts +51 -0
  117. package/dist/crewcoder-cli.d.ts.map +1 -0
  118. package/dist/crewcoder-cli.js +26 -0
  119. package/dist/crewcoder-cli.js.map +1 -0
  120. package/dist/diff-anchors.d.ts +14 -0
  121. package/dist/diff-anchors.d.ts.map +1 -0
  122. package/dist/diff-anchors.js +43 -0
  123. package/dist/diff-anchors.js.map +1 -0
  124. package/dist/footer-layout.d.ts +49 -0
  125. package/dist/footer-layout.d.ts.map +1 -0
  126. package/dist/footer-layout.js +79 -0
  127. package/dist/footer-layout.js.map +1 -0
  128. package/dist/glyphs.d.ts +32 -0
  129. package/dist/glyphs.d.ts.map +1 -0
  130. package/dist/glyphs.js +35 -0
  131. package/dist/glyphs.js.map +1 -0
  132. package/dist/goal-form.d.ts +47 -0
  133. package/dist/goal-form.d.ts.map +1 -0
  134. package/dist/goal-form.js +59 -0
  135. package/dist/goal-form.js.map +1 -0
  136. package/dist/hooks/use-animation.d.ts +6 -0
  137. package/dist/hooks/use-animation.d.ts.map +1 -0
  138. package/dist/hooks/use-animation.js +52 -0
  139. package/dist/hooks/use-animation.js.map +1 -0
  140. package/dist/hooks/use-app-colors.d.ts +6 -0
  141. package/dist/hooks/use-app-colors.d.ts.map +1 -0
  142. package/dist/hooks/use-app-colors.js +6 -0
  143. package/dist/hooks/use-app-colors.js.map +1 -0
  144. package/dist/hooks/use-glyph-set.d.ts +8 -0
  145. package/dist/hooks/use-glyph-set.d.ts.map +1 -0
  146. package/dist/hooks/use-glyph-set.js +22 -0
  147. package/dist/hooks/use-glyph-set.js.map +1 -0
  148. package/dist/hooks/use-motion.d.ts +6 -0
  149. package/dist/hooks/use-motion.d.ts.map +1 -0
  150. package/dist/hooks/use-motion.js +8 -0
  151. package/dist/hooks/use-motion.js.map +1 -0
  152. package/dist/hooks/use-terminal-focus.d.ts +16 -0
  153. package/dist/hooks/use-terminal-focus.d.ts.map +1 -0
  154. package/dist/hooks/use-terminal-focus.js +30 -0
  155. package/dist/hooks/use-terminal-focus.js.map +1 -0
  156. package/dist/hooks/use-theme.d.ts +6 -0
  157. package/dist/hooks/use-theme.d.ts.map +1 -0
  158. package/dist/hooks/use-theme.js +11 -0
  159. package/dist/hooks/use-theme.js.map +1 -0
  160. package/dist/hunk.d.ts +27 -0
  161. package/dist/hunk.d.ts.map +1 -0
  162. package/dist/hunk.js +43 -0
  163. package/dist/hunk.js.map +1 -0
  164. package/dist/image-view.d.ts +33 -0
  165. package/dist/image-view.d.ts.map +1 -0
  166. package/dist/image-view.js +51 -0
  167. package/dist/image-view.js.map +1 -0
  168. package/dist/keybindings.d.ts +28 -0
  169. package/dist/keybindings.d.ts.map +1 -0
  170. package/dist/keybindings.js +105 -0
  171. package/dist/keybindings.js.map +1 -0
  172. package/dist/lib/terminal-themes/default.d.ts +3 -0
  173. package/dist/lib/terminal-themes/default.d.ts.map +1 -0
  174. package/dist/lib/terminal-themes/default.js +49 -0
  175. package/dist/lib/terminal-themes/default.js.map +1 -0
  176. package/dist/logo-pulse.d.ts +23 -0
  177. package/dist/logo-pulse.d.ts.map +1 -0
  178. package/dist/logo-pulse.js +30 -0
  179. package/dist/logo-pulse.js.map +1 -0
  180. package/dist/markdown-style.d.ts +47 -0
  181. package/dist/markdown-style.d.ts.map +1 -0
  182. package/dist/markdown-style.js +138 -0
  183. package/dist/markdown-style.js.map +1 -0
  184. package/dist/mentions.d.ts +57 -0
  185. package/dist/mentions.d.ts.map +1 -0
  186. package/dist/mentions.js +109 -0
  187. package/dist/mentions.js.map +1 -0
  188. package/dist/palette-model.d.ts +42 -0
  189. package/dist/palette-model.d.ts.map +1 -0
  190. package/dist/palette-model.js +77 -0
  191. package/dist/palette-model.js.map +1 -0
  192. package/dist/path-suggestions.d.ts +50 -0
  193. package/dist/path-suggestions.d.ts.map +1 -0
  194. package/dist/path-suggestions.js +99 -0
  195. package/dist/path-suggestions.js.map +1 -0
  196. package/dist/picker-flows.d.ts +78 -0
  197. package/dist/picker-flows.d.ts.map +1 -0
  198. package/dist/picker-flows.js +444 -0
  199. package/dist/picker-flows.js.map +1 -0
  200. package/dist/pickers.d.ts +34 -0
  201. package/dist/pickers.d.ts.map +1 -0
  202. package/dist/pickers.js +136 -0
  203. package/dist/pickers.js.map +1 -0
  204. package/dist/prompt-history.d.ts +32 -0
  205. package/dist/prompt-history.d.ts.map +1 -0
  206. package/dist/prompt-history.js +40 -0
  207. package/dist/prompt-history.js.map +1 -0
  208. package/dist/providers/app-theme-provider.d.ts +12 -0
  209. package/dist/providers/app-theme-provider.d.ts.map +1 -0
  210. package/dist/providers/app-theme-provider.js +14 -0
  211. package/dist/providers/app-theme-provider.js.map +1 -0
  212. package/dist/providers/theme-provider.d.ts +10 -0
  213. package/dist/providers/theme-provider.d.ts.map +1 -0
  214. package/dist/providers/theme-provider.js +57 -0
  215. package/dist/providers/theme-provider.js.map +1 -0
  216. package/dist/question-model.d.ts +71 -0
  217. package/dist/question-model.d.ts.map +1 -0
  218. package/dist/question-model.js +176 -0
  219. package/dist/question-model.js.map +1 -0
  220. package/dist/search-controller.d.ts +46 -0
  221. package/dist/search-controller.d.ts.map +1 -0
  222. package/dist/search-controller.js +89 -0
  223. package/dist/search-controller.js.map +1 -0
  224. package/dist/search-jump.d.ts +27 -0
  225. package/dist/search-jump.d.ts.map +1 -0
  226. package/dist/search-jump.js +65 -0
  227. package/dist/search-jump.js.map +1 -0
  228. package/dist/session-controller.d.ts +268 -0
  229. package/dist/session-controller.d.ts.map +1 -0
  230. package/dist/session-controller.js +941 -0
  231. package/dist/session-controller.js.map +1 -0
  232. package/dist/sidebar-model.d.ts +45 -0
  233. package/dist/sidebar-model.d.ts.map +1 -0
  234. package/dist/sidebar-model.js +223 -0
  235. package/dist/sidebar-model.js.map +1 -0
  236. package/dist/sidebar.d.ts +49 -0
  237. package/dist/sidebar.d.ts.map +1 -0
  238. package/dist/sidebar.js +106 -0
  239. package/dist/sidebar.js.map +1 -0
  240. package/dist/status-line.d.ts +32 -0
  241. package/dist/status-line.d.ts.map +1 -0
  242. package/dist/status-line.js +69 -0
  243. package/dist/status-line.js.map +1 -0
  244. package/dist/syntax/filetype.d.ts +12 -0
  245. package/dist/syntax/filetype.d.ts.map +1 -0
  246. package/dist/syntax/filetype.js +28 -0
  247. package/dist/syntax/filetype.js.map +1 -0
  248. package/dist/syntax/grammars.d.ts +42 -0
  249. package/dist/syntax/grammars.d.ts.map +1 -0
  250. package/dist/syntax/grammars.js +52 -0
  251. package/dist/syntax/grammars.js.map +1 -0
  252. package/dist/text-offset.d.ts +5 -0
  253. package/dist/text-offset.d.ts.map +1 -0
  254. package/dist/text-offset.js +38 -0
  255. package/dist/text-offset.js.map +1 -0
  256. package/dist/text-wrap.d.ts +12 -0
  257. package/dist/text-wrap.d.ts.map +1 -0
  258. package/dist/text-wrap.js +53 -0
  259. package/dist/text-wrap.js.map +1 -0
  260. package/dist/theme-controller.d.ts +77 -0
  261. package/dist/theme-controller.d.ts.map +1 -0
  262. package/dist/theme-controller.js +178 -0
  263. package/dist/theme-controller.js.map +1 -0
  264. package/dist/theme.d.ts +51 -0
  265. package/dist/theme.d.ts.map +1 -0
  266. package/dist/theme.js +86 -0
  267. package/dist/theme.js.map +1 -0
  268. package/dist/tmux-check.d.ts +35 -0
  269. package/dist/tmux-check.d.ts.map +1 -0
  270. package/dist/tmux-check.js +66 -0
  271. package/dist/tmux-check.js.map +1 -0
  272. package/dist/tmux.d.ts +69 -0
  273. package/dist/tmux.d.ts.map +1 -0
  274. package/dist/tmux.js +135 -0
  275. package/dist/tmux.js.map +1 -0
  276. package/dist/tool-diff.d.ts +51 -0
  277. package/dist/tool-diff.d.ts.map +1 -0
  278. package/dist/tool-diff.js +158 -0
  279. package/dist/tool-diff.js.map +1 -0
  280. package/dist/tool-presentation.d.ts +46 -0
  281. package/dist/tool-presentation.d.ts.map +1 -0
  282. package/dist/tool-presentation.js +148 -0
  283. package/dist/tool-presentation.js.map +1 -0
  284. package/dist/tool-renderer-view.d.ts +14 -0
  285. package/dist/tool-renderer-view.d.ts.map +1 -0
  286. package/dist/tool-renderer-view.js +10 -0
  287. package/dist/tool-renderer-view.js.map +1 -0
  288. package/dist/transcript-search.d.ts +54 -0
  289. package/dist/transcript-search.d.ts.map +1 -0
  290. package/dist/transcript-search.js +160 -0
  291. package/dist/transcript-search.js.map +1 -0
  292. package/dist/transcript.d.ts +59 -0
  293. package/dist/transcript.d.ts.map +1 -0
  294. package/dist/transcript.js +123 -0
  295. package/dist/transcript.js.map +1 -0
  296. package/dist/workflow-tools.d.ts +42 -0
  297. package/dist/workflow-tools.d.ts.map +1 -0
  298. package/dist/workflow-tools.js +89 -0
  299. package/dist/workflow-tools.js.map +1 -0
  300. package/examples/themes/ember.json +75 -0
  301. package/grammars/bash/LICENSE +21 -0
  302. package/grammars/bash/highlights.scm +56 -0
  303. package/grammars/bash/tree-sitter-bash.wasm +0 -0
  304. package/grammars/css/LICENSE +21 -0
  305. package/grammars/css/highlights.scm +76 -0
  306. package/grammars/css/tree-sitter-css.wasm +0 -0
  307. package/grammars/go/LICENSE +21 -0
  308. package/grammars/go/highlights.scm +123 -0
  309. package/grammars/go/tree-sitter-go.wasm +0 -0
  310. package/grammars/html/LICENSE +21 -0
  311. package/grammars/html/highlights.scm +13 -0
  312. package/grammars/html/tree-sitter-html.wasm +0 -0
  313. package/grammars/json/LICENSE +21 -0
  314. package/grammars/json/highlights.scm +16 -0
  315. package/grammars/json/tree-sitter-json.wasm +0 -0
  316. package/grammars/python/LICENSE +21 -0
  317. package/grammars/python/highlights.scm +137 -0
  318. package/grammars/python/tree-sitter-python.wasm +0 -0
  319. package/grammars/rust/LICENSE +21 -0
  320. package/grammars/rust/highlights.scm +161 -0
  321. package/grammars/rust/tree-sitter-rust.wasm +0 -0
  322. package/grammars/yaml/LICENSE +20 -0
  323. package/grammars/yaml/highlights.scm +79 -0
  324. package/grammars/yaml/tree-sitter-yaml.wasm +0 -0
  325. package/package.json +56 -5
package/dist/App.js ADDED
@@ -0,0 +1,428 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "@opentui/react/jsx-runtime";
2
+ import os from "node:os";
3
+ import { useKeyboard, useRenderer, useTerminalDimensions } from "@opentui/react";
4
+ import { useEffect, useRef, useState, useSyncExternalStore } from "react";
5
+ import { alertView } from "./alert-model.js";
6
+ import { Alert } from "./components/ui/alert.js";
7
+ import { AttachmentRow } from "./components/AttachmentRow.js";
8
+ import { Spinner } from "./components/ui/spinner.js";
9
+ import { ToolApproval } from "./components/ui/tool-approval.js";
10
+ import { CommandPalette } from "./components/ui/command-palette.js";
11
+ import { Composer } from "./components/Composer.js";
12
+ import { ExtensionQuestion } from "./components/ExtensionQuestion.js";
13
+ import { GoalForm } from "./components/GoalForm.js";
14
+ import { Home } from "./components/Home.js";
15
+ import { MentionList } from "./components/MentionList.js";
16
+ import { SearchBar } from "./components/SearchBar.js";
17
+ import { Sidebar } from "./components/Sidebar.js";
18
+ import { SummaryEditor } from "./components/SummaryEditor.js";
19
+ import { Transcript } from "./components/Transcript.js";
20
+ import { COMPOSER_ROWS, homeComposerWidth, isHome, shortenPath } from "./footer-layout.js";
21
+ import { useTerminalFocus } from "./hooks/use-terminal-focus.js";
22
+ import { resolveImageMode } from "./image-view.js";
23
+ import { useTheme } from "./hooks/use-theme.js";
24
+ import { actionLabel, matchesAction } from "./keybindings.js";
25
+ import { locateMatchRow } from "./search-jump.js";
26
+ import { summaryEditorTextRows } from "./session-controller.js";
27
+ import { splitGauge, statusLine } from "./status-line.js";
28
+ import { indexToOffset } from "./text-offset.js";
29
+ /**
30
+ * The full-screen UI: the conversation in a scrollbox, and below it a footer
31
+ * that holds only the working spinner, alerts (errors and command results),
32
+ * the approval card, the composer, and the status line. Running tools and
33
+ * streaming text live in the transcript, never in the footer.
34
+ */
35
+ export function App({ controller, onQuit }) {
36
+ useSyncExternalStore(controller.subscribe, controller.getVersion);
37
+ const { width: terminalWidth, height } = useTerminalDimensions();
38
+ const theme = useTheme();
39
+ // The sidebar spans the full height on the right; everything else lays out in `width`.
40
+ const sidebarColumns = controller.sidebar.columns(terminalWidth);
41
+ const width = sidebarColumns > 0 ? terminalWidth - sidebarColumns - 1 : terminalWidth;
42
+ const inputRef = useRef(null);
43
+ const editorRef = useRef(null);
44
+ const questionInputRef = useRef(null);
45
+ const scrollRef = useRef(null);
46
+ const searchInputRef = useRef(null);
47
+ const goalInputRef = useRef(null);
48
+ const renderer = useRenderer();
49
+ const terminalFocused = useTerminalFocus();
50
+ const state = controller.state;
51
+ const picker = controller.picker;
52
+ const editor = controller.editor;
53
+ const question = controller.question();
54
+ const questionView = controller.questionView(height, width);
55
+ const goalForm = controller.goalForm;
56
+ const overlayOpen = picker !== undefined || editor !== undefined || question !== undefined || goalForm !== undefined;
57
+ const home = isHome(state.blocks, state.running);
58
+ // The alert sits in the composer's column: the main column, or the narrower home composer.
59
+ const alertWidth = home ? homeComposerWidth(width) : width;
60
+ const extras = controller.footerExtras(alertWidth);
61
+ const approval = state.running ? controller.pendingApproval() : undefined;
62
+ const search = controller.search;
63
+ const searching = search.isOpen && !home;
64
+ // Content row of the current match, measured after layout; the transcript marks it.
65
+ const [markRow, setMarkRow] = useState();
66
+ useEffect(() => {
67
+ if (overlayOpen)
68
+ inputRef.current?.blur();
69
+ else
70
+ inputRef.current?.focus();
71
+ }, [overlayOpen]);
72
+ // Scroll to the current match once the frame that may have expanded its tool is laid
73
+ // out, then mark its line. Again on resize: rows move when text rewraps.
74
+ useEffect(() => {
75
+ const match = searching ? search.current : undefined;
76
+ if (!match) {
77
+ setMarkRow(undefined);
78
+ return;
79
+ }
80
+ const scroll = scrollRef.current;
81
+ if (!scroll)
82
+ return;
83
+ const query = search.query;
84
+ let cancelled = false;
85
+ // After the next layout and before it paints: rows are current and the scroll shows in that frame.
86
+ scroll.afterLayout(() => {
87
+ const row = cancelled ? undefined : locateMatchRow(scroll, match, query);
88
+ if (row === undefined)
89
+ return;
90
+ // A third of the way down, so the lines before the match show too.
91
+ scroll.scrollTo(Math.max(0, row - Math.floor(scroll.height / 3)));
92
+ setMarkRow(row);
93
+ });
94
+ renderer.requestRender();
95
+ return () => {
96
+ cancelled = true;
97
+ };
98
+ }, [searching, search, search.jumpVersion, width, renderer]);
99
+ // Pickers such as /commands hand text to the uncontrolled composer. The
100
+ // composer unmounts while a picker is open, so apply each draft once, after
101
+ // it remounts.
102
+ const appliedDraft = useRef(0);
103
+ useEffect(() => {
104
+ const input = inputRef.current;
105
+ if (controller.composerDraftVersion === appliedDraft.current || !input)
106
+ return;
107
+ appliedDraft.current = controller.composerDraftVersion;
108
+ input.setText(controller.composerDraft);
109
+ input.gotoBufferEnd();
110
+ }, [controller.composerDraftVersion, controller.composerDraft, overlayOpen, searching]);
111
+ useKeyboard((key) => {
112
+ // An unfocused surface ignores input (Ctrl+C included): it was meant for another pane.
113
+ if (!terminalFocused.current) {
114
+ key.preventDefault?.();
115
+ return;
116
+ }
117
+ if (matchesAction(key, "quit")) {
118
+ onQuit();
119
+ return;
120
+ }
121
+ // An alert lasts until the next key; the key itself still does its job.
122
+ controller.dismissAlert();
123
+ // The summary editor and an extension question gate a live run, so they
124
+ // take keys before a picker.
125
+ if (controller.editor) {
126
+ handleEditorKey(key);
127
+ return;
128
+ }
129
+ const pending = controller.question();
130
+ if (pending) {
131
+ handleQuestionKey(key, pending.uiKind);
132
+ return;
133
+ }
134
+ if (controller.goalForm) {
135
+ handleGoalFormKey(key);
136
+ return;
137
+ }
138
+ // Read overlays live, not from this render: keys typed right after "/"
139
+ // can arrive before React re-renders. Global handlers run before the
140
+ // focused textarea, so preventDefault keeps it from also taking the key
141
+ // (the composer would otherwise submit its leftover text on Enter).
142
+ if (controller.picker) {
143
+ key.preventDefault?.();
144
+ if (matchesAction(key, "togglePalette") && controller.picker.kind === "commands")
145
+ controller.closePicker();
146
+ else if (matchesAction(key, "paletteClose"))
147
+ controller.closePicker();
148
+ else if (matchesAction(key, "paletteUp"))
149
+ controller.movePickerCursor(-1);
150
+ else if (matchesAction(key, "paletteDown"))
151
+ controller.movePickerCursor(1);
152
+ else if (matchesAction(key, "paletteSelect"))
153
+ controller.selectPickerItem();
154
+ else if (controller.picker.kind === "session" && matchesAction(key, "sessionBranch"))
155
+ controller.branchPickerItem();
156
+ else if (matchesAction(key, "paletteBackspace"))
157
+ controller.setPickerQuery(controller.pickerQuery.slice(0, -1));
158
+ else if (!key.ctrl && !key.meta && key.name.length === 1)
159
+ controller.setPickerQuery(controller.pickerQuery + key.name);
160
+ return;
161
+ }
162
+ if (matchesAction(key, "toggleSidebar")) {
163
+ key.preventDefault?.();
164
+ controller.sidebar.toggle();
165
+ return;
166
+ }
167
+ if (handleSearchKey(key))
168
+ return;
169
+ if (matchesAction(key, "searchOpen")) {
170
+ key.preventDefault?.();
171
+ controller.openSearch();
172
+ return;
173
+ }
174
+ if (handleMentionKey(key))
175
+ return;
176
+ if (handleComposerShortcut(key))
177
+ return;
178
+ if (handleTranscriptKey(key))
179
+ return;
180
+ if (handleHistoryKey(key))
181
+ return;
182
+ if (approval && matchesAction(key, "approve"))
183
+ controller.resolvePendingApproval(true);
184
+ else if (approval && matchesAction(key, "deny"))
185
+ controller.resolvePendingApproval(false);
186
+ else if (matchesAction(key, "abort"))
187
+ controller.abort();
188
+ });
189
+ /**
190
+ * While the search bar is open it takes every key: its own (older, newer, close),
191
+ * transcript scrolling and toggles, and approvals pass; anything else types into
192
+ * the field. Esc closes the bar and never aborts the run.
193
+ */
194
+ function handleSearchKey(key) {
195
+ if (!controller.search.isOpen)
196
+ return false;
197
+ if (matchesAction(key, "searchClose"))
198
+ controller.search.close();
199
+ else if (matchesAction(key, "searchNewer"))
200
+ controller.search.newer();
201
+ else if (matchesAction(key, "searchOlder"))
202
+ controller.search.older();
203
+ else if (matchesAction(key, "searchOpen"))
204
+ searchInputRef.current?.focus();
205
+ else if (handleTranscriptKey(key))
206
+ return true;
207
+ else if (approval && matchesAction(key, "approve"))
208
+ controller.resolvePendingApproval(true);
209
+ else if (approval && matchesAction(key, "deny"))
210
+ controller.resolvePendingApproval(false);
211
+ else
212
+ return true;
213
+ key.preventDefault?.();
214
+ return true;
215
+ }
216
+ /**
217
+ * The open `@` list takes Up/Down/Enter/Tab/Esc before history, submit, and
218
+ * abort. Enter with nothing to pick (an empty list) still submits. True when
219
+ * the key was used.
220
+ */
221
+ function handleMentionKey(key) {
222
+ if (!controller.mention)
223
+ return false;
224
+ if (matchesAction(key, "mentionUp"))
225
+ controller.mentions.move(-1);
226
+ else if (matchesAction(key, "mentionDown"))
227
+ controller.mentions.move(1);
228
+ else if (matchesAction(key, "mentionClose"))
229
+ controller.mentions.dismiss();
230
+ else if (matchesAction(key, "mentionSelect")) {
231
+ const picked = controller.mentions.accept();
232
+ const input = inputRef.current;
233
+ if (!picked || !input)
234
+ return false;
235
+ input.setText(picked.text);
236
+ input.cursorOffset = indexToOffset(picked.text, picked.cursor);
237
+ }
238
+ else
239
+ return false;
240
+ key.preventDefault?.();
241
+ return true;
242
+ }
243
+ /**
244
+ * Ctrl+V (clipboard image, else clipboard text), Ctrl+X (clear images, only
245
+ * when there are some), Ctrl+P (palette), Tab / Ctrl+I (modes). True when the
246
+ * key was used.
247
+ */
248
+ function handleComposerShortcut(key) {
249
+ if (matchesAction(key, "pasteClipboard")) {
250
+ const text = controller.pasteClipboard();
251
+ if (text)
252
+ inputRef.current?.insertText(text.replace(/\r\n?/g, "\n"));
253
+ }
254
+ else if (matchesAction(key, "clearAttachments")) {
255
+ if (!controller.clearAttachments())
256
+ return false;
257
+ }
258
+ else if (matchesAction(key, "togglePalette"))
259
+ controller.togglePalette();
260
+ else if (matchesAction(key, "openModes"))
261
+ controller.openModesPicker();
262
+ else
263
+ return false;
264
+ key.preventDefault?.();
265
+ return true;
266
+ }
267
+ /** Scrolling and Ctrl+O; true when the key was used. */
268
+ function handleTranscriptKey(key) {
269
+ const scroll = scrollRef.current;
270
+ if (matchesAction(key, "toggleToolOutput"))
271
+ controller.toggleAllToolOutput();
272
+ else if (matchesAction(key, "toggleDiffs"))
273
+ controller.toggleAllDiffs();
274
+ else if (matchesAction(key, "transcriptPageUp"))
275
+ scroll?.scrollBy(-1, "viewport");
276
+ else if (matchesAction(key, "transcriptPageDown"))
277
+ scroll?.scrollBy(1, "viewport");
278
+ else if (matchesAction(key, "transcriptTop"))
279
+ scroll?.scrollTo(0);
280
+ else if (matchesAction(key, "transcriptBottom"))
281
+ scroll?.scrollTo(Number.POSITIVE_INFINITY);
282
+ else
283
+ return false;
284
+ key.preventDefault?.();
285
+ return true;
286
+ }
287
+ /**
288
+ * Up/Down move between the composer's wrapped lines; only when the cursor
289
+ * cannot move further do they recall sent messages (legacy order). True when
290
+ * the key was used.
291
+ */
292
+ function handleHistoryKey(key) {
293
+ const direction = matchesAction(key, "composerHistoryPrev") ? "up" : matchesAction(key, "composerHistoryNext") ? "down" : undefined;
294
+ const input = inputRef.current;
295
+ if (!direction || !input)
296
+ return false;
297
+ key.preventDefault?.();
298
+ // moveCursorUp/Down return true even on the first/last row (OpenTUI 0.9.2),
299
+ // so compare the cursor offset to tell whether it actually moved.
300
+ const before = input.cursorOffset;
301
+ if (direction === "up")
302
+ input.moveCursorUp();
303
+ else
304
+ input.moveCursorDown();
305
+ if (input.cursorOffset !== before)
306
+ return true;
307
+ const text = controller.recallPrompt(direction, input.plainText);
308
+ if (text !== undefined) {
309
+ input.setText(text);
310
+ input.gotoBufferEnd();
311
+ }
312
+ return true;
313
+ }
314
+ /** The `/goal` form's keys; anything else edits the selected field's input. */
315
+ function handleGoalFormKey(key) {
316
+ if (matchesAction(key, "goalFormSubmit"))
317
+ controller.submitGoalForm();
318
+ else if (matchesAction(key, "goalFormCancel"))
319
+ controller.closeGoalForm();
320
+ else if (matchesAction(key, "goalFormPrev"))
321
+ controller.moveGoalField(-1);
322
+ else if (matchesAction(key, "goalFormNext"))
323
+ controller.moveGoalField(1);
324
+ else if (matchesAction(key, "goalFormEnter"))
325
+ controller.goalFormEnter();
326
+ else
327
+ return;
328
+ key.preventDefault?.();
329
+ }
330
+ function handleEditorKey(key) {
331
+ const current = controller.editor;
332
+ if (!current)
333
+ return;
334
+ // Other keys edit the summary in the focused textarea.
335
+ if (matchesAction(key, "summaryApply")) {
336
+ key.preventDefault?.();
337
+ controller.resolveSummary(true, editorRef.current?.plainText ?? current.summary);
338
+ }
339
+ else if (matchesAction(key, "summaryReset")) {
340
+ key.preventDefault?.();
341
+ editorRef.current?.setText(current.summary);
342
+ }
343
+ else if (matchesAction(key, "summaryCancel")) {
344
+ key.preventDefault?.();
345
+ controller.resolveSummary(false, "");
346
+ }
347
+ }
348
+ function handleQuestionKey(key, kind) {
349
+ const scroll = matchesAction(key, "questionScrollUp") ? -3 : matchesAction(key, "questionScrollDown") ? 3 : 0;
350
+ if (scroll) {
351
+ key.preventDefault?.();
352
+ controller.scrollQuestion(scroll, height, width);
353
+ }
354
+ else if (matchesAction(key, "questionCancel")) {
355
+ key.preventDefault?.();
356
+ controller.answerQuestion(null);
357
+ }
358
+ else if (kind === "input") {
359
+ // Other keys edit the reply in the focused input.
360
+ if (!matchesAction(key, "questionSubmit"))
361
+ return;
362
+ key.preventDefault?.();
363
+ controller.answerQuestion(questionInputRef.current?.value ?? "");
364
+ }
365
+ else {
366
+ key.preventDefault?.();
367
+ if (matchesAction(key, "questionPrev"))
368
+ controller.moveQuestionCursor(-1);
369
+ else if (matchesAction(key, "questionNext"))
370
+ controller.moveQuestionCursor(1);
371
+ else if (matchesAction(key, "questionSubmit"))
372
+ controller.submitQuestionChoice();
373
+ else if (kind === "confirm" && matchesAction(key, "questionYes"))
374
+ controller.answerQuestion(true);
375
+ else if (kind === "confirm" && matchesAction(key, "questionNo"))
376
+ controller.answerQuestion(false);
377
+ }
378
+ }
379
+ const submit = (text) => {
380
+ // The composer is uncontrolled; clear its buffer after each submission.
381
+ inputRef.current?.setText("");
382
+ // Now, not when the textarea reports the change: an overlay opening first would keep the sent text as a draft.
383
+ controller.setComposerText("");
384
+ controller.setComposerLines(1);
385
+ controller.submit(text);
386
+ };
387
+ // One row under the composer; paddingLeft takes a cell, the right edge keeps one free.
388
+ const status = statusLine(state, Math.max(0, width - 2));
389
+ const composer = (_jsx(Composer, { inputRef: inputRef, lines: controller.composerLines, placeholder: state.running ? "Send a follow-up to the running turn" : "Ask CrewCoder", onLines: (lines) => controller.setComposerLines(lines), onText: (text) => controller.setComposerText(text), onSlash: () => controller.openCommandPalette(), onCursor: (text, cursor) => controller.mentions.update(text, cursor), onSubmit: submit }));
390
+ const mentionList = controller.mention ? _jsx(MentionList, { mention: controller.mention }) : null;
391
+ const attachmentRow = state.attachments.length > 0 ? _jsx(AttachmentRow, { attachments: state.attachments }) : null;
392
+ const alert = controller.currentAlert
393
+ ? _jsx(Alert, { variant: controller.currentAlert.variant, view: alertView(controller.currentAlert, alertWidth) })
394
+ : null;
395
+ // Overlays replace the footer (and the welcome screen); the transcript stays above them.
396
+ const view = controller.pickerView(height);
397
+ const overlay = editor ? (_jsx(SummaryEditor, { editor: editor, editorRef: editorRef, textRows: summaryEditorTextRows(height) })) : question && questionView ? (_jsx(ExtensionQuestion, { block: question, view: questionView, inputRef: questionInputRef, onChoose: (choice) => controller.chooseQuestion(choice) })) : goalForm ? (_jsx(GoalForm, { form: goalForm, maker: `${state.provider}/${state.model}`, inputRef: goalInputRef, onInput: (value) => controller.editGoalField(value), onSelect: (index) => controller.selectGoalField(index) })) : picker && view ? (_jsx("box", { width: "100%", alignItems: "center", flexShrink: 0, children: _jsx("box", { width: Math.max(1, Math.min(width - 2, 80)), flexShrink: 0, children: _jsx(CommandPalette, { view: view, query: controller.pickerQuery, title: picker.title, placeholder: picker.placeholder, emptyText: picker.loading ? "Loading…" : picker.emptyText, hint: picker.hint }) }) })) : null;
398
+ const sidebar = sidebarColumns > 0 ? (_jsx(Sidebar, { state: state, tasks: controller.sidebar.tasks, width: sidebarColumns, height: height, home: state.remoteTarget ? undefined : os.homedir(), onDividerDrag: (x) => controller.sidebar.resize(terminalWidth - x - 1, terminalWidth) })) : null;
399
+ const last = state.blocks.at(-1);
400
+ const main = home ? (_jsx("box", { width: width, height: "100%", justifyContent: "center", flexShrink: 0, children: overlay ?? (_jsx(Home, { width: width, height: height, info: homeInfo(state.provider, state.model, state.cwd, state.remoteTarget, width), composer: _jsxs(_Fragment, { children: [attachmentRow, composer, mentionList] }), alert: alert, extraRows: (extras.alertRows ?? 0) + (extras.mentionRows ?? 0) + (extras.attachmentRows ?? 0) + (extras.composerRows ?? COMPOSER_ROWS) - COMPOSER_ROWS })) })) : (_jsxs("box", { flexDirection: "column", width: width, height: "100%", flexShrink: 0, children: [_jsx(Transcript, { blocks: state.blocks, running: state.running, cwd: state.cwd, expansion: controller.toolExpansion,
401
+ // Columns inside the transcript: its padding (1 + 1) and the scrollbar.
402
+ images: { mode: resolveImageMode(process.env, Boolean(state.remoteTarget)), cols: width - TRANSCRIPT_CHROME_COLUMNS, screenRows: height }, scrollRef: scrollRef, markRow: searching ? markRow : undefined, renderers: state.rendererHooks }), _jsx("box", { flexDirection: "column", width: "100%", flexShrink: 0, marginTop: 1, children: overlay ?? (_jsxs(_Fragment, { children: [state.running ? (_jsxs("box", { flexDirection: "row", height: 1, flexShrink: 0, paddingLeft: 1, children: [_jsx(Spinner, { label: last?.type === "thinking" ? "Thinking" : "Working" }), _jsx("text", { fg: theme.colors.mutedForeground, wrapMode: "none", children: ` ${actionLabel("abort")} to stop` })] })) : null, approval ? (_jsx(ToolApproval, { name: approval.toolName ?? "tool", description: approval.text, args: approval.args, risk: riskLevel(approval.risk), onApprove: () => controller.resolvePendingApproval(true), onDeny: () => controller.resolvePendingApproval(false) })) : null, alert, searching ? (_jsx(SearchBar, { search: search, width: width, inputRef: searchInputRef, onQuery: (query) => search.setQuery(query) })) : (_jsxs(_Fragment, { children: [attachmentRow, composer, mentionList] })), _jsx(StatusRow, { status: status })] })) })] }));
403
+ return (_jsxs("box", { flexDirection: "row", width: "100%", height: "100%", backgroundColor: theme.colors.background, children: [main, sidebar] }));
404
+ }
405
+ /**
406
+ * Access, mode, model, and session on the left; context usage and cost pinned
407
+ * right. Full Access reads in the warning color: it skips approvals.
408
+ */
409
+ function StatusRow({ status }) {
410
+ const theme = useTheme();
411
+ const { gauge, rest: usage } = splitGauge(status.right);
412
+ return (_jsxs("box", { flexDirection: "row", height: 1, flexShrink: 0, paddingLeft: 1, paddingRight: 1, children: [_jsxs("text", { height: 1, wrapMode: "none", flexGrow: 1, flexShrink: 1, children: [_jsx("span", { fg: status.access === "Full Access" ? theme.colors.warning : theme.colors.success, children: status.access }), _jsx("span", { fg: theme.colors.mutedForeground, children: status.left })] }), status.right ? (_jsxs("text", { height: 1, wrapMode: "none", flexShrink: 0, children: [gauge ? _jsx("span", { fg: theme.colors.accent, children: gauge }) : null, _jsx("span", { fg: theme.colors.mutedForeground, children: usage })] })) : null] }));
413
+ }
414
+ /** Map the agent's ApprovalRisk (`safe | review | dangerous`) onto termcn's levels. */
415
+ const RISK_LEVELS = { safe: "low", review: "medium", dangerous: "high" };
416
+ export function riskLevel(value) {
417
+ // hasOwn guards against prototype keys such as "constructor" in agent data.
418
+ return value !== undefined && Object.hasOwn(RISK_LEVELS, value) ? RISK_LEVELS[value] : undefined;
419
+ }
420
+ /** `provider · model · cwd`, with the cwd shortened so the line fits and stays centered. */
421
+ const TRANSCRIPT_CHROME_COLUMNS = 3;
422
+ function homeInfo(provider, model, cwd, remoteTarget, width) {
423
+ const prefix = `${provider} · ${model} · `;
424
+ const location = remoteTarget ? `${remoteTarget}:${cwd}` : cwd;
425
+ const room = Math.max(8, width - 2 - prefix.length);
426
+ return `${prefix}${shortenPath(location, room, remoteTarget ? undefined : os.homedir())}`;
427
+ }
428
+ //# sourceMappingURL=App.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"App.js","sourceRoot":"","sources":["../src/App.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AAEzB,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AACjF,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,oBAAoB,EAAkB,MAAM,OAAO,CAAC;AAC1F,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,C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enderer, useTerminalDimensions } from \"@opentui/react\";\nimport { useEffect, useRef, useState, useSyncExternalStore, type ReactNode } from \"react\";\nimport { alertView } from \"./alert-model.js\";\nimport { Alert } from \"./components/ui/alert.js\";\nimport { AttachmentRow } from \"./components/AttachmentRow.js\";\nimport { Spinner } from \"./components/ui/spinner.js\";\nimport { ToolApproval, type RiskLevel } from \"./components/ui/tool-approval.js\";\nimport { CommandPalette } from \"./components/ui/command-palette.js\";\nimport { Composer } from \"./components/Composer.js\";\nimport { ExtensionQuestion } from \"./components/ExtensionQuestion.js\";\nimport { GoalForm } from \"./components/GoalForm.js\";\nimport { Home } from \"./components/Home.js\";\nimport { MentionList } from \"./components/MentionList.js\";\nimport { SearchBar } from \"./components/SearchBar.js\";\nimport { Sidebar } from \"./components/Sidebar.js\";\nimport { SummaryEditor } from \"./components/SummaryEditor.js\";\nimport { Transcript } from \"./components/Transcript.js\";\nimport { COMPOSER_ROWS, homeComposerWidth, isHome, shortenPath } from \"./footer-layout.js\";\nimport { useTerminalFocus } from \"./hooks/use-terminal-focus.js\";\nimport { resolveImageMode } from \"./image-view.js\";\nimport { useTheme } from \"./hooks/use-theme.js\";\nimport { actionLabel, matchesAction, type KeyLike } from \"./keybindings.js\";\nimport { locateMatchRow } from \"./search-jump.js\";\nimport { summaryEditorTextRows, type SessionController } from \"./session-controller.js\";\nimport { splitGauge, statusLine, type StatusLine } from \"./status-line.js\";\nimport { indexToOffset } from \"./text-offset.js\";\n\nexport type AppProps = {\n controller: SessionController;\n onQuit: () => void;\n};\n\n/**\n * The full-screen UI: the conversation in a scrollbox, and below it a footer\n * that holds only the working spinner, alerts (errors and command results),\n * the approval card, the composer, and the status line. Running tools and\n * streaming text live in the transcript, never in the footer.\n */\nexport function App({ controller, onQuit }: AppProps): ReactNode {\n useSyncExternalStore(controller.subscribe, controller.getVersion);\n const { width: terminalWidth, height } = useTerminalDimensions();\n const theme = useTheme();\n // The sidebar spans the full height on the right; everything else lays out in `width`.\n const sidebarColumns = controller.sidebar.columns(terminalWidth);\n const width = sidebarColumns > 0 ? terminalWidth - sidebarColumns - 1 : terminalWidth;\n const inputRef = useRef<TextareaRenderable>(null);\n const editorRef = useRef<TextareaRenderable>(null);\n const questionInputRef = useRef<InputRenderable>(null);\n const scrollRef = useRef<ScrollBoxRenderable>(null);\n const searchInputRef = useRef<InputRenderable>(null);\n const goalInputRef = useRef<InputRenderable>(null);\n const renderer = useRenderer();\n const terminalFocused = useTerminalFocus();\n const state = controller.state;\n const picker = controller.picker;\n const editor = controller.editor;\n const question = controller.question();\n const questionView = controller.questionView(height, width);\n const goalForm = controller.goalForm;\n const overlayOpen = picker !== undefined || editor !== undefined || question !== undefined || goalForm !== undefined;\n const home = isHome(state.blocks, state.running);\n // The alert sits in the composer's column: the main column, or the narrower home composer.\n const alertWidth = home ? homeComposerWidth(width) : width;\n const extras = controller.footerExtras(alertWidth);\n const approval = state.running ? controller.pendingApproval() : undefined;\n const search = controller.search;\n const searching = search.isOpen && !home;\n // Content row of the current match, measured after layout; the transcript marks it.\n const [markRow, setMarkRow] = useState<number>();\n\n useEffect(() => {\n if (overlayOpen) inputRef.current?.blur();\n else inputRef.current?.focus();\n }, [overlayOpen]);\n\n // Scroll to the current match once the frame that may have expanded its tool is laid\n // out, then mark its line. Again on resize: rows move when text rewraps.\n useEffect(() => {\n const match = searching ? search.current : undefined;\n if (!match) {\n setMarkRow(undefined);\n return;\n }\n const scroll = scrollRef.current;\n if (!scroll) return;\n const query = search.query;\n let cancelled = false;\n // After the next layout and before it paints: rows are current and the scroll shows in that frame.\n scroll.afterLayout(() => {\n const row = cancelled ? undefined : locateMatchRow(scroll, match, query);\n if (row === undefined) return;\n // A third of the way down, so the lines before the match show too.\n scroll.scrollTo(Math.max(0, row - Math.floor(scroll.height / 3)));\n setMarkRow(row);\n });\n renderer.requestRender();\n return () => {\n cancelled = true;\n };\n }, [searching, search, search.jumpVersion, width, renderer]);\n\n // Pickers such as /commands hand text to the uncontrolled composer. The\n // composer unmounts while a picker is open, so apply each draft once, after\n // it remounts.\n const appliedDraft = useRef(0);\n useEffect(() => {\n const input = inputRef.current;\n if (controller.composerDraftVersion === appliedDraft.current || !input) return;\n appliedDraft.current = controller.composerDraftVersion;\n input.setText(controller.composerDraft);\n input.gotoBufferEnd();\n }, [controller.composerDraftVersion, controller.composerDraft, overlayOpen, searching]);\n\n useKeyboard((key: KeyLike) => {\n // An unfocused surface ignores input (Ctrl+C included): it was meant for another pane.\n if (!terminalFocused.current) {\n key.preventDefault?.();\n return;\n }\n if (matchesAction(key, \"quit\")) {\n onQuit();\n return;\n }\n // An alert lasts until the next key; the key itself still does its job.\n controller.dismissAlert();\n // The summary editor and an extension question gate a live run, so they\n // take keys before a picker.\n if (controller.editor) {\n handleEditorKey(key);\n return;\n }\n const pending = controller.question();\n if (pending) {\n handleQuestionKey(key, pending.uiKind);\n return;\n }\n if (controller.goalForm) {\n handleGoalFormKey(key);\n return;\n }\n // Read overlays live, not from this render: keys typed right after \"/\"\n // can arrive before React re-renders. Global handlers run before the\n // focused textarea, so preventDefault keeps it from also taking the key\n // (the composer would otherwise submit its leftover text on Enter).\n if (controller.picker) {\n key.preventDefault?.();\n if (matchesAction(key, \"togglePalette\") && controller.picker.kind === \"commands\") controller.closePicker();\n else if (matchesAction(key, \"paletteClose\")) controller.closePicker();\n else if (matchesAction(key, \"paletteUp\")) controller.movePickerCursor(-1);\n else if (matchesAction(key, \"paletteDown\")) controller.movePickerCursor(1);\n else if (matchesAction(key, \"paletteSelect\")) controller.selectPickerItem();\n else if (controller.picker.kind === \"session\" && matchesAction(key, \"sessionBranch\")) controller.branchPickerItem();\n else if (matchesAction(key, \"paletteBackspace\")) controller.setPickerQuery(controller.pickerQuery.slice(0, -1));\n else if (!key.ctrl && !key.meta && key.name.length === 1) controller.setPickerQuery(controller.pickerQuery + key.name);\n return;\n }\n if (matchesAction(key, \"toggleSidebar\")) {\n key.preventDefault?.();\n controller.sidebar.toggle();\n return;\n }\n if (handleSearchKey(key)) return;\n if (matchesAction(key, \"searchOpen\")) {\n key.preventDefault?.();\n controller.openSearch();\n return;\n }\n if (handleMentionKey(key)) return;\n if (handleComposerShortcut(key)) return;\n if (handleTranscriptKey(key)) return;\n if (handleHistoryKey(key)) return;\n if (approval && matchesAction(key, \"approve\")) controller.resolvePendingApproval(true);\n else if (approval && matchesAction(key, \"deny\")) controller.resolvePendingApproval(false);\n else if (matchesAction(key, \"abort\")) controller.abort();\n });\n\n /**\n * While the search bar is open it takes every key: its own (older, newer, close),\n * transcript scrolling and toggles, and approvals pass; anything else types into\n * the field. Esc closes the bar and never aborts the run.\n */\n function handleSearchKey(key: KeyLike): boolean {\n if (!controller.search.isOpen) return false;\n if (matchesAction(key, \"searchClose\")) controller.search.close();\n else if (matchesAction(key, \"searchNewer\")) controller.search.newer();\n else if (matchesAction(key, \"searchOlder\")) controller.search.older();\n else if (matchesAction(key, \"searchOpen\")) searchInputRef.current?.focus();\n else if (handleTranscriptKey(key)) return true;\n else if (approval && matchesAction(key, \"approve\")) controller.resolvePendingApproval(true);\n else if (approval && matchesAction(key, \"deny\")) controller.resolvePendingApproval(false);\n else return true;\n key.preventDefault?.();\n return true;\n }\n\n /**\n * The open `@` list takes Up/Down/Enter/Tab/Esc before history, submit, and\n * abort. Enter with nothing to pick (an empty list) still submits. True when\n * the key was used.\n */\n function handleMentionKey(key: KeyLike): boolean {\n if (!controller.mention) return false;\n if (matchesAction(key, \"mentionUp\")) controller.mentions.move(-1);\n else if (matchesAction(key, \"mentionDown\")) controller.mentions.move(1);\n else if (matchesAction(key, \"mentionClose\")) controller.mentions.dismiss();\n else if (matchesAction(key, \"mentionSelect\")) {\n const picked = controller.mentions.accept();\n const input = inputRef.current;\n if (!picked || !input) return false;\n input.setText(picked.text);\n input.cursorOffset = indexToOffset(picked.text, picked.cursor);\n } else return false;\n key.preventDefault?.();\n return true;\n }\n\n /**\n * Ctrl+V (clipboard image, else clipboard text), Ctrl+X (clear images, only\n * when there are some), Ctrl+P (palette), Tab / Ctrl+I (modes). True when the\n * key was used.\n */\n function handleComposerShortcut(key: KeyLike): boolean {\n if (matchesAction(key, \"pasteClipboard\")) {\n const text = controller.pasteClipboard();\n if (text) inputRef.current?.insertText(text.replace(/\\r\\n?/g, \"\\n\"));\n } else if (matchesAction(key, \"clearAttachments\")) {\n if (!controller.clearAttachments()) return false;\n } else if (matchesAction(key, \"togglePalette\")) controller.togglePalette();\n else if (matchesAction(key, \"openModes\")) controller.openModesPicker();\n else return false;\n key.preventDefault?.();\n return true;\n }\n\n /** Scrolling and Ctrl+O; true when the key was used. */\n function handleTranscriptKey(key: KeyLike): boolean {\n const scroll = scrollRef.current;\n if (matchesAction(key, \"toggleToolOutput\")) controller.toggleAllToolOutput();\n else if (matchesAction(key, \"toggleDiffs\")) controller.toggleAllDiffs();\n else if (matchesAction(key, \"transcriptPageUp\")) scroll?.scrollBy(-1, \"viewport\");\n else if (matchesAction(key, \"transcriptPageDown\")) scroll?.scrollBy(1, \"viewport\");\n else if (matchesAction(key, \"transcriptTop\")) scroll?.scrollTo(0);\n else if (matchesAction(key, \"transcriptBottom\")) scroll?.scrollTo(Number.POSITIVE_INFINITY);\n else return false;\n key.preventDefault?.();\n return true;\n }\n\n /**\n * Up/Down move between the composer's wrapped lines; only when the cursor\n * cannot move further do they recall sent messages (legacy order). True when\n * the key was used.\n */\n function handleHistoryKey(key: KeyLike): boolean {\n const direction = matchesAction(key, \"composerHistoryPrev\") ? \"up\" : matchesAction(key, \"composerHistoryNext\") ? \"down\" : undefined;\n const input = inputRef.current;\n if (!direction || !input) return false;\n key.preventDefault?.();\n // moveCursorUp/Down return true even on the first/last row (OpenTUI 0.9.2),\n // so compare the cursor offset to tell whether it actually moved.\n const before = input.cursorOffset;\n if (direction === \"up\") input.moveCursorUp();\n else input.moveCursorDown();\n if (input.cursorOffset !== before) return true;\n const text = controller.recallPrompt(direction, input.plainText);\n if (text !== undefined) {\n input.setText(text);\n input.gotoBufferEnd();\n }\n return true;\n }\n\n /** The `/goal` form's keys; anything else edits the selected field's input. */\n function handleGoalFormKey(key: KeyLike): void {\n if (matchesAction(key, \"goalFormSubmit\")) controller.submitGoalForm();\n else if (matchesAction(key, \"goalFormCancel\")) controller.closeGoalForm();\n else if (matchesAction(key, \"goalFormPrev\")) controller.moveGoalField(-1);\n else if (matchesAction(key, \"goalFormNext\")) controller.moveGoalField(1);\n else if (matchesAction(key, \"goalFormEnter\")) controller.goalFormEnter();\n else return;\n key.preventDefault?.();\n }\n\n function handleEditorKey(key: KeyLike): void {\n const current = controller.editor;\n if (!current) return;\n // Other keys edit the summary in the focused textarea.\n if (matchesAction(key, \"summaryApply\")) {\n key.preventDefault?.();\n controller.resolveSummary(true, editorRef.current?.plainText ?? current.summary);\n } else if (matchesAction(key, \"summaryReset\")) {\n key.preventDefault?.();\n editorRef.current?.setText(current.summary);\n } else if (matchesAction(key, \"summaryCancel\")) {\n key.preventDefault?.();\n controller.resolveSummary(false, \"\");\n }\n }\n\n function handleQuestionKey(key: KeyLike, kind: string): void {\n const scroll = matchesAction(key, \"questionScrollUp\") ? -3 : matchesAction(key, \"questionScrollDown\") ? 3 : 0;\n if (scroll) {\n key.preventDefault?.();\n controller.scrollQuestion(scroll, height, width);\n } else if (matchesAction(key, \"questionCancel\")) {\n key.preventDefault?.();\n controller.answerQuestion(null);\n } else if (kind === \"input\") {\n // Other keys edit the reply in the focused input.\n if (!matchesAction(key, \"questionSubmit\")) return;\n key.preventDefault?.();\n controller.answerQuestion(questionInputRef.current?.value ?? \"\");\n } else {\n key.preventDefault?.();\n if (matchesAction(key, \"questionPrev\")) controller.moveQuestionCursor(-1);\n else if (matchesAction(key, \"questionNext\")) controller.moveQuestionCursor(1);\n else if (matchesAction(key, \"questionSubmit\")) controller.submitQuestionChoice();\n else if (kind === \"confirm\" && matchesAction(key, \"questionYes\")) controller.answerQuestion(true);\n else if (kind === \"confirm\" && matchesAction(key, \"questionNo\")) controller.answerQuestion(false);\n }\n }\n\n const submit = (text: string): void => {\n // The composer is uncontrolled; clear its buffer after each submission.\n inputRef.current?.setText(\"\");\n // Now, not when the textarea reports the change: an overlay opening first would keep the sent text as a draft.\n controller.setComposerText(\"\");\n controller.setComposerLines(1);\n controller.submit(text);\n };\n\n // One row under the composer; paddingLeft takes a cell, the right edge keeps one free.\n const status = statusLine(state, Math.max(0, width - 2));\n\n const composer = (\n <Composer\n inputRef={inputRef}\n lines={controller.composerLines}\n placeholder={state.running ? \"Send a follow-up to the running turn\" : \"Ask CrewCoder\"}\n onLines={(lines) => controller.setComposerLines(lines)}\n onText={(text) => controller.setComposerText(text)}\n onSlash={() => controller.openCommandPalette()}\n onCursor={(text, cursor) => controller.mentions.update(text, cursor)}\n onSubmit={submit}\n />\n );\n const mentionList = controller.mention ? <MentionList mention={controller.mention} /> : null;\n const attachmentRow = state.attachments.length > 0 ? <AttachmentRow attachments={state.attachments} /> : null;\n\n const alert = controller.currentAlert\n ? <Alert variant={controller.currentAlert.variant} view={alertView(controller.currentAlert, alertWidth)} />\n : null;\n\n // Overlays replace the footer (and the welcome screen); the transcript stays above them.\n const view = controller.pickerView(height);\n const overlay = editor ? (\n <SummaryEditor editor={editor} editorRef={editorRef} textRows={summaryEditorTextRows(height)} />\n ) : question && questionView ? (\n <ExtensionQuestion block={question} view={questionView} inputRef={questionInputRef} onChoose={(choice) => controller.chooseQuestion(choice)} />\n ) : goalForm ? (\n <GoalForm\n form={goalForm}\n maker={`${state.provider}/${state.model}`}\n inputRef={goalInputRef}\n onInput={(value) => controller.editGoalField(value)}\n onSelect={(index) => controller.selectGoalField(index)}\n />\n ) : picker && view ? (\n <box width=\"100%\" alignItems=\"center\" flexShrink={0}>\n <box width={Math.max(1, Math.min(width - 2, 80))} flexShrink={0}>\n <CommandPalette\n view={view}\n query={controller.pickerQuery}\n title={picker.title}\n placeholder={picker.placeholder}\n emptyText={picker.loading ? \"Loading…\" : picker.emptyText}\n hint={picker.hint}\n />\n </box>\n </box>\n ) : null;\n\n const sidebar = sidebarColumns > 0 ? (\n <Sidebar\n state={state}\n tasks={controller.sidebar.tasks}\n width={sidebarColumns}\n height={height}\n home={state.remoteTarget ? undefined : os.homedir()}\n onDividerDrag={(x) => controller.sidebar.resize(terminalWidth - x - 1, terminalWidth)}\n />\n ) : null;\n\n const last = state.blocks.at(-1);\n const main = home ? (\n <box width={width} height=\"100%\" justifyContent=\"center\" flexShrink={0}>\n {overlay ?? (\n <Home\n width={width}\n height={height}\n info={homeInfo(state.provider, state.model, state.cwd, state.remoteTarget, width)}\n composer={<>{attachmentRow}{composer}{mentionList}</>}\n alert={alert}\n extraRows={(extras.alertRows ?? 0) + (extras.mentionRows ?? 0) + (extras.attachmentRows ?? 0) + (extras.composerRows ?? COMPOSER_ROWS) - COMPOSER_ROWS}\n />\n )}\n </box>\n ) : (\n <box flexDirection=\"column\" width={width} height=\"100%\" flexShrink={0}>\n <Transcript\n blocks={state.blocks}\n running={state.running}\n cwd={state.cwd}\n expansion={controller.toolExpansion}\n // Columns inside the transcript: its padding (1 + 1) and the scrollbar.\n images={{ mode: resolveImageMode(process.env, Boolean(state.remoteTarget)), cols: width - TRANSCRIPT_CHROME_COLUMNS, screenRows: height }}\n scrollRef={scrollRef}\n markRow={searching ? markRow : undefined}\n renderers={state.rendererHooks}\n />\n <box flexDirection=\"column\" width=\"100%\" flexShrink={0} marginTop={1}>\n {overlay ?? (\n <>\n {state.running ? (\n <box flexDirection=\"row\" height={1} flexShrink={0} paddingLeft={1}>\n <Spinner label={last?.type === \"thinking\" ? \"Thinking\" : \"Working\"} />\n <text fg={theme.colors.mutedForeground} wrapMode=\"none\">{` ${actionLabel(\"abort\")} to stop`}</text>\n </box>\n ) : null}\n {approval ? (\n <ToolApproval\n name={approval.toolName ?? \"tool\"}\n description={approval.text}\n args={approval.args}\n risk={riskLevel(approval.risk)}\n onApprove={() => controller.resolvePendingApproval(true)}\n onDeny={() => controller.resolvePendingApproval(false)}\n />\n ) : null}\n {alert}\n {searching ? (\n <SearchBar search={search} width={width} inputRef={searchInputRef} onQuery={(query) => search.setQuery(query)} />\n ) : (\n <>\n {attachmentRow}\n {composer}\n {mentionList}\n </>\n )}\n <StatusRow status={status} />\n </>\n )}\n </box>\n </box>\n );\n\n return (\n <box flexDirection=\"row\" width=\"100%\" height=\"100%\" backgroundColor={theme.colors.background}>\n {main}\n {sidebar}\n </box>\n );\n}\n\n/**\n * Access, mode, model, and session on the left; context usage and cost pinned\n * right. Full Access reads in the warning color: it skips approvals.\n */\nfunction StatusRow({ status }: { status: StatusLine }): ReactNode {\n const theme = useTheme();\n const { gauge, rest: usage } = splitGauge(status.right);\n return (\n <box flexDirection=\"row\" height={1} flexShrink={0} paddingLeft={1} paddingRight={1}>\n <text height={1} wrapMode=\"none\" flexGrow={1} flexShrink={1}>\n <span fg={status.access === \"Full Access\" ? theme.colors.warning : theme.colors.success}>{status.access}</span>\n <span fg={theme.colors.mutedForeground}>{status.left}</span>\n </text>\n {status.right ? (\n <text height={1} wrapMode=\"none\" flexShrink={0}>\n {gauge ? <span fg={theme.colors.accent}>{gauge}</span> : null}\n <span fg={theme.colors.mutedForeground}>{usage}</span>\n </text>\n ) : null}\n </box>\n );\n}\n\n/** Map the agent's ApprovalRisk (`safe | review | dangerous`) onto termcn's levels. */\nconst RISK_LEVELS: Readonly<Record<string, RiskLevel>> = { safe: \"low\", review: \"medium\", dangerous: \"high\" };\n\nexport function riskLevel(value: string | undefined): RiskLevel | undefined {\n // hasOwn guards against prototype keys such as \"constructor\" in agent data.\n return value !== undefined && Object.hasOwn(RISK_LEVELS, value) ? RISK_LEVELS[value] : undefined;\n}\n\n/** `provider · model · cwd`, with the cwd shortened so the line fits and stays centered. */\nconst TRANSCRIPT_CHROME_COLUMNS = 3;\n\nfunction homeInfo(provider: string, model: string, cwd: string, remoteTarget: string | undefined, width: number): string {\n const prefix = `${provider} · ${model} · `;\n const location = remoteTarget ? `${remoteTarget}:${cwd}` : cwd;\n const room = Math.max(8, width - 2 - prefix.length);\n return `${prefix}${shortenPath(location, room, remoteTarget ? undefined : os.homedir())}`;\n}\n"]}
package/dist/Root.d.ts ADDED
@@ -0,0 +1,11 @@
1
+ import { type ReactNode } from "react";
2
+ import type { SessionController } from "./session-controller.js";
3
+ /**
4
+ * The app under the controller's current theme. It subscribes to the
5
+ * controller so a `/theme` preview or pick re-themes the whole tree at once.
6
+ */
7
+ export declare function Root({ controller, onQuit }: {
8
+ controller: SessionController;
9
+ onQuit: () => void;
10
+ }): ReactNode;
11
+ //# sourceMappingURL=Root.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Root.d.ts","sourceRoot":"","sources":["../src/Root.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAwB,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAG7D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAEjE;;;GAGG;AACH,wBAAgB,IAAI,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,EAAE;IAAE,UAAU,EAAE,iBAAiB,CAAC;IAAC,MAAM,EAAE,MAAM,IAAI,CAAA;CAAE,GAAG,SAAS,CAO7G"}
package/dist/Root.js ADDED
@@ -0,0 +1,13 @@
1
+ import { jsx as _jsx } from "@opentui/react/jsx-runtime";
2
+ import { useSyncExternalStore } from "react";
3
+ import { App } from "./App.js";
4
+ import { AppThemeProvider } from "./providers/app-theme-provider.js";
5
+ /**
6
+ * The app under the controller's current theme. It subscribes to the
7
+ * controller so a `/theme` preview or pick re-themes the whole tree at once.
8
+ */
9
+ export function Root({ controller, onQuit }) {
10
+ useSyncExternalStore(controller.subscribe, controller.getVersion);
11
+ return (_jsx(AppThemeProvider, { theme: controller.themes.current, children: _jsx(App, { controller: controller, onQuit: onQuit }) }));
12
+ }
13
+ //# sourceMappingURL=Root.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Root.js","sourceRoot":"","sources":["../src/Root.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,oBAAoB,EAAkB,MAAM,OAAO,CAAC;AAC7D,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAGrE;;;GAGG;AACH,MAAM,UAAU,IAAI,CAAC,EAAE,UAAU,EAAE,MAAM,EAAyD;IAChG,oBAAoB,CAAC,UAAU,CAAC,SAAS,EAAE,UAAU,CAAC,UAAU,CAAC,CAAC;IAClE,OAAO,CACL,KAAC,gBAAgB,IAAC,KAAK,EAAE,UAAU,CAAC,MAAM,CAAC,OAAO,YAChD,KAAC,GAAG,IAAC,UAAU,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,GAAI,GAC9B,CACpB,CAAC;AACJ,CAAC","sourcesContent":["import { useSyncExternalStore, type ReactNode } from \"react\";\nimport { App } from \"./App.js\";\nimport { AppThemeProvider } from \"./providers/app-theme-provider.js\";\nimport type { SessionController } from \"./session-controller.js\";\n\n/**\n * The app under the controller's current theme. It subscribes to the\n * controller so a `/theme` preview or pick re-themes the whole tree at once.\n */\nexport function Root({ controller, onQuit }: { controller: SessionController; onQuit: () => void }): ReactNode {\n useSyncExternalStore(controller.subscribe, controller.getVersion);\n return (\n <AppThemeProvider theme={controller.themes.current}>\n <App controller={controller} onQuit={onQuit} />\n </AppThemeProvider>\n );\n}\n"]}
@@ -0,0 +1,31 @@
1
+ export type AlertVariant = "success" | "error" | "warning" | "info";
2
+ /**
3
+ * A status message shown above the composer until the next keypress or
4
+ * command: on/off/status results and the text output of one-shot commands.
5
+ */
6
+ export type FooterAlert = {
7
+ variant: AlertVariant;
8
+ title: string;
9
+ body?: string;
10
+ };
11
+ /** Most body rows (after wrapping) an alert shows; longer output ends with a "… N more lines" row. */
12
+ export declare const MAX_ALERT_BODY_LINES = 16;
13
+ /** Columns the alert box itself takes: its border (1 + 1) and padding (1 + 1). */
14
+ export declare const ALERT_CHROME_COLUMNS = 4;
15
+ /** The icon and the gap after it, before the title text. */
16
+ export declare const ALERT_ICON_COLUMNS = 2;
17
+ /** What an alert draws at a box width: the title and body, wrapped (never cut) to fit. */
18
+ export type AlertView = {
19
+ title: string[];
20
+ lines: string[];
21
+ };
22
+ /**
23
+ * Title and body rows at `width` (the alert box's outer width). Text wraps to the
24
+ * room inside the border and padding, keeping each line's indent and hanging a list
25
+ * item's continuation under its text; the title wraps beside its icon. The body is
26
+ * clamped after wrapping, so `alertRows` is exactly what draws.
27
+ */
28
+ export declare function alertView(alert: FooterAlert, width: number): AlertView;
29
+ /** Footer rows the alert takes at `width`: border (2) + title rows + body rows. */
30
+ export declare function alertRows(alert: FooterAlert | undefined, width: number): number;
31
+ //# sourceMappingURL=alert-model.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"alert-model.d.ts","sourceRoot":"","sources":["../src/alert-model.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,GAAG,MAAM,CAAC;AAEpE;;;GAGG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,OAAO,EAAE,YAAY,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,sGAAsG;AACtG,eAAO,MAAM,oBAAoB,KAAK,CAAC;AAEvC,kFAAkF;AAClF,eAAO,MAAM,oBAAoB,IAAI,CAAC;AAEtC,4DAA4D;AAC5D,eAAO,MAAM,kBAAkB,IAAI,CAAC;AAEpC,0FAA0F;AAC1F,MAAM,MAAM,SAAS,GAAG;IAAE,KAAK,EAAE,MAAM,EAAE,CAAC;IAAC,KAAK,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC;AAE7D;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,GAAG,SAAS,CAStE;AAED,mFAAmF;AACnF,wBAAgB,SAAS,CAAC,KAAK,EAAE,WAAW,GAAG,SAAS,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAI/E"}
@@ -0,0 +1,34 @@
1
+ import { wrapIndented } from "./text-wrap.js";
2
+ import { normalize } from "./transcript.js";
3
+ /** Most body rows (after wrapping) an alert shows; longer output ends with a "… N more lines" row. */
4
+ export const MAX_ALERT_BODY_LINES = 16;
5
+ /** Columns the alert box itself takes: its border (1 + 1) and padding (1 + 1). */
6
+ export const ALERT_CHROME_COLUMNS = 4;
7
+ /** The icon and the gap after it, before the title text. */
8
+ export const ALERT_ICON_COLUMNS = 2;
9
+ /**
10
+ * Title and body rows at `width` (the alert box's outer width). Text wraps to the
11
+ * room inside the border and padding, keeping each line's indent and hanging a list
12
+ * item's continuation under its text; the title wraps beside its icon. The body is
13
+ * clamped after wrapping, so `alertRows` is exactly what draws.
14
+ */
15
+ export function alertView(alert, width) {
16
+ const inner = Math.max(1, width - ALERT_CHROME_COLUMNS);
17
+ const title = wrapIndented(normalize(alert.title), Math.max(1, inner - ALERT_ICON_COLUMNS));
18
+ const body = normalize(alert.body ?? "").replace(/\s+$/, "");
19
+ if (!body)
20
+ return { title, lines: [] };
21
+ const lines = wrapIndented(body, inner);
22
+ if (lines.length <= MAX_ALERT_BODY_LINES)
23
+ return { title, lines };
24
+ const shown = lines.slice(0, MAX_ALERT_BODY_LINES - 1);
25
+ return { title, lines: [...shown, `… ${lines.length - shown.length} more lines`] };
26
+ }
27
+ /** Footer rows the alert takes at `width`: border (2) + title rows + body rows. */
28
+ export function alertRows(alert, width) {
29
+ if (!alert)
30
+ return 0;
31
+ const view = alertView(alert, width);
32
+ return 2 + view.title.length + view.lines.length;
33
+ }
34
+ //# sourceMappingURL=alert-model.js.map