@tinfoilsh/tinfoil-terminal 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 (369) hide show
  1. package/AGENTS.md +27 -0
  2. package/Dockerfile +18 -0
  3. package/README.md +15 -0
  4. package/bin/opencode +88 -0
  5. package/bunfig.toml +7 -0
  6. package/package.json +134 -0
  7. package/parsers-config.ts +253 -0
  8. package/script/build.ts +176 -0
  9. package/script/postinstall.mjs +122 -0
  10. package/script/publish-registries.ts +187 -0
  11. package/script/publish.ts +70 -0
  12. package/script/schema.ts +47 -0
  13. package/src/acp/README.md +164 -0
  14. package/src/acp/agent.ts +1124 -0
  15. package/src/acp/session.ts +101 -0
  16. package/src/acp/types.ts +22 -0
  17. package/src/agent/agent.ts +284 -0
  18. package/src/agent/generate.txt +75 -0
  19. package/src/agent/prompt/compaction.txt +12 -0
  20. package/src/agent/prompt/explore.txt +18 -0
  21. package/src/agent/prompt/summary.txt +11 -0
  22. package/src/agent/prompt/title.txt +43 -0
  23. package/src/auth/index.ts +73 -0
  24. package/src/bun/index.ts +130 -0
  25. package/src/bus/bus-event.ts +43 -0
  26. package/src/bus/global.ts +10 -0
  27. package/src/bus/index.ts +105 -0
  28. package/src/cli/bootstrap.ts +17 -0
  29. package/src/cli/cmd/acp.ts +69 -0
  30. package/src/cli/cmd/agent.ts +257 -0
  31. package/src/cli/cmd/auth.ts +400 -0
  32. package/src/cli/cmd/cmd.ts +7 -0
  33. package/src/cli/cmd/debug/agent.ts +29 -0
  34. package/src/cli/cmd/debug/config.ts +16 -0
  35. package/src/cli/cmd/debug/file.ts +97 -0
  36. package/src/cli/cmd/debug/index.ts +48 -0
  37. package/src/cli/cmd/debug/lsp.ts +52 -0
  38. package/src/cli/cmd/debug/ripgrep.ts +87 -0
  39. package/src/cli/cmd/debug/scrap.ts +16 -0
  40. package/src/cli/cmd/debug/skill.ts +16 -0
  41. package/src/cli/cmd/debug/snapshot.ts +52 -0
  42. package/src/cli/cmd/export.ts +88 -0
  43. package/src/cli/cmd/generate.ts +38 -0
  44. package/src/cli/cmd/github.ts +1546 -0
  45. package/src/cli/cmd/import.ts +98 -0
  46. package/src/cli/cmd/mcp.ts +671 -0
  47. package/src/cli/cmd/models.ts +77 -0
  48. package/src/cli/cmd/pr.ts +112 -0
  49. package/src/cli/cmd/run.ts +395 -0
  50. package/src/cli/cmd/serve.ts +16 -0
  51. package/src/cli/cmd/session.ts +135 -0
  52. package/src/cli/cmd/stats.ts +402 -0
  53. package/src/cli/cmd/tui/app.tsx +743 -0
  54. package/src/cli/cmd/tui/attach.ts +31 -0
  55. package/src/cli/cmd/tui/component/border.tsx +21 -0
  56. package/src/cli/cmd/tui/component/dialog-agent.tsx +31 -0
  57. package/src/cli/cmd/tui/component/dialog-command.tsx +124 -0
  58. package/src/cli/cmd/tui/component/dialog-mcp.tsx +86 -0
  59. package/src/cli/cmd/tui/component/dialog-model.tsx +168 -0
  60. package/src/cli/cmd/tui/component/dialog-provider.tsx +47 -0
  61. package/src/cli/cmd/tui/component/dialog-session-list.tsx +115 -0
  62. package/src/cli/cmd/tui/component/dialog-session-rename.tsx +31 -0
  63. package/src/cli/cmd/tui/component/dialog-stash.tsx +86 -0
  64. package/src/cli/cmd/tui/component/dialog-status.tsx +162 -0
  65. package/src/cli/cmd/tui/component/dialog-tag.tsx +44 -0
  66. package/src/cli/cmd/tui/component/dialog-theme-list.tsx +50 -0
  67. package/src/cli/cmd/tui/component/did-you-know.tsx +85 -0
  68. package/src/cli/cmd/tui/component/logo.tsx +33 -0
  69. package/src/cli/cmd/tui/component/prompt/autocomplete.tsx +718 -0
  70. package/src/cli/cmd/tui/component/prompt/frecency.tsx +89 -0
  71. package/src/cli/cmd/tui/component/prompt/history.tsx +108 -0
  72. package/src/cli/cmd/tui/component/prompt/index.tsx +1083 -0
  73. package/src/cli/cmd/tui/component/prompt/stash.tsx +101 -0
  74. package/src/cli/cmd/tui/component/textarea-keybindings.ts +73 -0
  75. package/src/cli/cmd/tui/component/tips.ts +103 -0
  76. package/src/cli/cmd/tui/component/todo-item.tsx +32 -0
  77. package/src/cli/cmd/tui/context/args.tsx +14 -0
  78. package/src/cli/cmd/tui/context/directory.ts +13 -0
  79. package/src/cli/cmd/tui/context/exit.tsx +23 -0
  80. package/src/cli/cmd/tui/context/helper.tsx +25 -0
  81. package/src/cli/cmd/tui/context/keybind.tsx +101 -0
  82. package/src/cli/cmd/tui/context/kv.tsx +49 -0
  83. package/src/cli/cmd/tui/context/local.tsx +393 -0
  84. package/src/cli/cmd/tui/context/prompt.tsx +18 -0
  85. package/src/cli/cmd/tui/context/route.tsx +46 -0
  86. package/src/cli/cmd/tui/context/sdk.tsx +94 -0
  87. package/src/cli/cmd/tui/context/sync.tsx +427 -0
  88. package/src/cli/cmd/tui/context/theme/aura.json +69 -0
  89. package/src/cli/cmd/tui/context/theme/ayu.json +80 -0
  90. package/src/cli/cmd/tui/context/theme/catppuccin-frappe.json +233 -0
  91. package/src/cli/cmd/tui/context/theme/catppuccin-macchiato.json +233 -0
  92. package/src/cli/cmd/tui/context/theme/catppuccin.json +112 -0
  93. package/src/cli/cmd/tui/context/theme/cobalt2.json +228 -0
  94. package/src/cli/cmd/tui/context/theme/cursor.json +249 -0
  95. package/src/cli/cmd/tui/context/theme/dracula.json +219 -0
  96. package/src/cli/cmd/tui/context/theme/everforest.json +241 -0
  97. package/src/cli/cmd/tui/context/theme/flexoki.json +237 -0
  98. package/src/cli/cmd/tui/context/theme/github.json +233 -0
  99. package/src/cli/cmd/tui/context/theme/gruvbox.json +95 -0
  100. package/src/cli/cmd/tui/context/theme/kanagawa.json +77 -0
  101. package/src/cli/cmd/tui/context/theme/lucent-orng.json +237 -0
  102. package/src/cli/cmd/tui/context/theme/material.json +235 -0
  103. package/src/cli/cmd/tui/context/theme/matrix.json +77 -0
  104. package/src/cli/cmd/tui/context/theme/mercury.json +252 -0
  105. package/src/cli/cmd/tui/context/theme/monokai.json +221 -0
  106. package/src/cli/cmd/tui/context/theme/nightowl.json +221 -0
  107. package/src/cli/cmd/tui/context/theme/nord.json +223 -0
  108. package/src/cli/cmd/tui/context/theme/one-dark.json +84 -0
  109. package/src/cli/cmd/tui/context/theme/orng.json +249 -0
  110. package/src/cli/cmd/tui/context/theme/osaka-jade.json +93 -0
  111. package/src/cli/cmd/tui/context/theme/palenight.json +222 -0
  112. package/src/cli/cmd/tui/context/theme/rosepine.json +234 -0
  113. package/src/cli/cmd/tui/context/theme/solarized.json +223 -0
  114. package/src/cli/cmd/tui/context/theme/synthwave84.json +226 -0
  115. package/src/cli/cmd/tui/context/theme/tokyonight.json +243 -0
  116. package/src/cli/cmd/tui/context/theme/vercel.json +245 -0
  117. package/src/cli/cmd/tui/context/theme/vesper.json +218 -0
  118. package/src/cli/cmd/tui/context/theme/zenburn.json +223 -0
  119. package/src/cli/cmd/tui/context/theme.tsx +1150 -0
  120. package/src/cli/cmd/tui/event.ts +46 -0
  121. package/src/cli/cmd/tui/routes/home.tsx +138 -0
  122. package/src/cli/cmd/tui/routes/session/dialog-fork-from-timeline.tsx +64 -0
  123. package/src/cli/cmd/tui/routes/session/dialog-message.tsx +109 -0
  124. package/src/cli/cmd/tui/routes/session/dialog-subagent.tsx +26 -0
  125. package/src/cli/cmd/tui/routes/session/dialog-timeline.tsx +47 -0
  126. package/src/cli/cmd/tui/routes/session/footer.tsx +88 -0
  127. package/src/cli/cmd/tui/routes/session/header.tsx +105 -0
  128. package/src/cli/cmd/tui/routes/session/index.tsx +1897 -0
  129. package/src/cli/cmd/tui/routes/session/permission.tsx +416 -0
  130. package/src/cli/cmd/tui/routes/session/question.tsx +368 -0
  131. package/src/cli/cmd/tui/routes/session/sidebar.tsx +279 -0
  132. package/src/cli/cmd/tui/spawn.ts +46 -0
  133. package/src/cli/cmd/tui/thread.ts +174 -0
  134. package/src/cli/cmd/tui/ui/dialog-alert.tsx +57 -0
  135. package/src/cli/cmd/tui/ui/dialog-confirm.tsx +83 -0
  136. package/src/cli/cmd/tui/ui/dialog-export-options.tsx +204 -0
  137. package/src/cli/cmd/tui/ui/dialog-help.tsx +38 -0
  138. package/src/cli/cmd/tui/ui/dialog-prompt.tsx +77 -0
  139. package/src/cli/cmd/tui/ui/dialog-select.tsx +345 -0
  140. package/src/cli/cmd/tui/ui/dialog.tsx +172 -0
  141. package/src/cli/cmd/tui/ui/link.tsx +28 -0
  142. package/src/cli/cmd/tui/ui/spinner.ts +368 -0
  143. package/src/cli/cmd/tui/ui/toast.tsx +100 -0
  144. package/src/cli/cmd/tui/util/clipboard.ts +128 -0
  145. package/src/cli/cmd/tui/util/editor.ts +32 -0
  146. package/src/cli/cmd/tui/util/signal.ts +7 -0
  147. package/src/cli/cmd/tui/util/terminal.ts +114 -0
  148. package/src/cli/cmd/tui/util/transcript.ts +98 -0
  149. package/src/cli/cmd/tui/worker.ts +95 -0
  150. package/src/cli/cmd/uninstall.ts +344 -0
  151. package/src/cli/cmd/upgrade.ts +67 -0
  152. package/src/cli/cmd/web.ts +73 -0
  153. package/src/cli/error.ts +57 -0
  154. package/src/cli/network.ts +53 -0
  155. package/src/cli/ui.ts +87 -0
  156. package/src/cli/upgrade.ts +25 -0
  157. package/src/command/index.ts +131 -0
  158. package/src/command/template/initialize.txt +10 -0
  159. package/src/command/template/review.txt +97 -0
  160. package/src/config/config.ts +1226 -0
  161. package/src/config/markdown.ts +41 -0
  162. package/src/env/index.ts +26 -0
  163. package/src/file/ignore.ts +83 -0
  164. package/src/file/index.ts +411 -0
  165. package/src/file/ripgrep.ts +409 -0
  166. package/src/file/time.ts +64 -0
  167. package/src/file/watcher.ts +118 -0
  168. package/src/flag/flag.ts +51 -0
  169. package/src/format/formatter.ts +359 -0
  170. package/src/format/index.ts +137 -0
  171. package/src/global/index.ts +55 -0
  172. package/src/id/id.ts +83 -0
  173. package/src/ide/index.ts +76 -0
  174. package/src/index.ts +161 -0
  175. package/src/installation/index.ts +205 -0
  176. package/src/lsp/client.ts +252 -0
  177. package/src/lsp/index.ts +485 -0
  178. package/src/lsp/language.ts +119 -0
  179. package/src/lsp/server.ts +2032 -0
  180. package/src/mcp/auth.ts +135 -0
  181. package/src/mcp/index.ts +874 -0
  182. package/src/mcp/oauth-callback.ts +200 -0
  183. package/src/mcp/oauth-provider.ts +154 -0
  184. package/src/patch/index.ts +622 -0
  185. package/src/permission/arity.ts +163 -0
  186. package/src/permission/index.ts +210 -0
  187. package/src/permission/next.ts +269 -0
  188. package/src/plugin/codex.ts +524 -0
  189. package/src/plugin/index.ts +118 -0
  190. package/src/project/bootstrap.ts +31 -0
  191. package/src/project/instance.ts +78 -0
  192. package/src/project/project.ts +316 -0
  193. package/src/project/state.ts +65 -0
  194. package/src/project/vcs.ts +76 -0
  195. package/src/provider/auth.ts +147 -0
  196. package/src/provider/models-macro.ts +11 -0
  197. package/src/provider/models.ts +86 -0
  198. package/src/provider/provider.ts +429 -0
  199. package/src/provider/sdk/openai-compatible/src/README.md +5 -0
  200. package/src/provider/sdk/openai-compatible/src/index.ts +2 -0
  201. package/src/provider/sdk/openai-compatible/src/openai-compatible-provider.ts +100 -0
  202. package/src/provider/sdk/openai-compatible/src/responses/convert-to-openai-responses-input.ts +303 -0
  203. package/src/provider/sdk/openai-compatible/src/responses/map-openai-responses-finish-reason.ts +22 -0
  204. package/src/provider/sdk/openai-compatible/src/responses/openai-config.ts +18 -0
  205. package/src/provider/sdk/openai-compatible/src/responses/openai-error.ts +22 -0
  206. package/src/provider/sdk/openai-compatible/src/responses/openai-responses-api-types.ts +207 -0
  207. package/src/provider/sdk/openai-compatible/src/responses/openai-responses-language-model.ts +1713 -0
  208. package/src/provider/sdk/openai-compatible/src/responses/openai-responses-prepare-tools.ts +177 -0
  209. package/src/provider/sdk/openai-compatible/src/responses/openai-responses-settings.ts +1 -0
  210. package/src/provider/sdk/openai-compatible/src/responses/tool/code-interpreter.ts +88 -0
  211. package/src/provider/sdk/openai-compatible/src/responses/tool/file-search.ts +128 -0
  212. package/src/provider/sdk/openai-compatible/src/responses/tool/image-generation.ts +115 -0
  213. package/src/provider/sdk/openai-compatible/src/responses/tool/local-shell.ts +65 -0
  214. package/src/provider/sdk/openai-compatible/src/responses/tool/web-search-preview.ts +104 -0
  215. package/src/provider/sdk/openai-compatible/src/responses/tool/web-search.ts +103 -0
  216. package/src/provider/transform.ts +654 -0
  217. package/src/pty/index.ts +229 -0
  218. package/src/question/index.ts +170 -0
  219. package/src/server/error.ts +36 -0
  220. package/src/server/mdns.ts +57 -0
  221. package/src/server/project.ts +79 -0
  222. package/src/server/question.ts +95 -0
  223. package/src/server/server.ts +2878 -0
  224. package/src/server/tui.ts +71 -0
  225. package/src/session/compaction.ts +225 -0
  226. package/src/session/index.ts +476 -0
  227. package/src/session/llm.ts +235 -0
  228. package/src/session/message-v2.ts +683 -0
  229. package/src/session/message.ts +189 -0
  230. package/src/session/processor.ts +406 -0
  231. package/src/session/prompt/anthropic-20250930.txt +166 -0
  232. package/src/session/prompt/anthropic.txt +105 -0
  233. package/src/session/prompt/anthropic_spoof.txt +1 -0
  234. package/src/session/prompt/beast.txt +147 -0
  235. package/src/session/prompt/build-switch.txt +5 -0
  236. package/src/session/prompt/codex.txt +318 -0
  237. package/src/session/prompt/codex_header.txt +318 -0
  238. package/src/session/prompt/copilot-gpt-5.txt +143 -0
  239. package/src/session/prompt/gemini.txt +155 -0
  240. package/src/session/prompt/max-steps.txt +16 -0
  241. package/src/session/prompt/plan-reminder-anthropic.txt +67 -0
  242. package/src/session/prompt/plan.txt +26 -0
  243. package/src/session/prompt/qwen.txt +109 -0
  244. package/src/session/prompt.ts +1652 -0
  245. package/src/session/retry.ts +90 -0
  246. package/src/session/revert.ts +108 -0
  247. package/src/session/status.ts +76 -0
  248. package/src/session/summary.ts +194 -0
  249. package/src/session/system.ts +138 -0
  250. package/src/session/todo.ts +37 -0
  251. package/src/share/share-next.ts +194 -0
  252. package/src/share/share.ts +87 -0
  253. package/src/shell/shell.ts +67 -0
  254. package/src/skill/index.ts +1 -0
  255. package/src/skill/skill.ts +127 -0
  256. package/src/snapshot/index.ts +199 -0
  257. package/src/storage/storage.ts +226 -0
  258. package/src/tool/bash.ts +258 -0
  259. package/src/tool/bash.txt +115 -0
  260. package/src/tool/batch.ts +175 -0
  261. package/src/tool/batch.txt +24 -0
  262. package/src/tool/codesearch.ts +132 -0
  263. package/src/tool/codesearch.txt +12 -0
  264. package/src/tool/edit.ts +645 -0
  265. package/src/tool/edit.txt +10 -0
  266. package/src/tool/external-directory.ts +33 -0
  267. package/src/tool/glob.ts +77 -0
  268. package/src/tool/glob.txt +6 -0
  269. package/src/tool/grep.ts +136 -0
  270. package/src/tool/grep.txt +8 -0
  271. package/src/tool/invalid.ts +17 -0
  272. package/src/tool/ls.ts +121 -0
  273. package/src/tool/ls.txt +1 -0
  274. package/src/tool/lsp.ts +96 -0
  275. package/src/tool/lsp.txt +19 -0
  276. package/src/tool/multiedit.ts +46 -0
  277. package/src/tool/multiedit.txt +41 -0
  278. package/src/tool/patch.ts +201 -0
  279. package/src/tool/patch.txt +1 -0
  280. package/src/tool/question.ts +33 -0
  281. package/src/tool/question.txt +10 -0
  282. package/src/tool/read.ts +200 -0
  283. package/src/tool/read.txt +12 -0
  284. package/src/tool/registry.ts +141 -0
  285. package/src/tool/skill.ts +75 -0
  286. package/src/tool/task.ts +181 -0
  287. package/src/tool/task.txt +60 -0
  288. package/src/tool/todo.ts +53 -0
  289. package/src/tool/todoread.txt +14 -0
  290. package/src/tool/todowrite.txt +167 -0
  291. package/src/tool/tool.ts +88 -0
  292. package/src/tool/truncation.ts +98 -0
  293. package/src/tool/webfetch.ts +182 -0
  294. package/src/tool/webfetch.txt +13 -0
  295. package/src/tool/websearch.ts +144 -0
  296. package/src/tool/websearch.txt +11 -0
  297. package/src/tool/write.ts +80 -0
  298. package/src/tool/write.txt +8 -0
  299. package/src/util/archive.ts +16 -0
  300. package/src/util/color.ts +19 -0
  301. package/src/util/context.ts +25 -0
  302. package/src/util/defer.ts +12 -0
  303. package/src/util/eventloop.ts +20 -0
  304. package/src/util/filesystem.ts +83 -0
  305. package/src/util/fn.ts +11 -0
  306. package/src/util/iife.ts +3 -0
  307. package/src/util/keybind.ts +102 -0
  308. package/src/util/lazy.ts +18 -0
  309. package/src/util/locale.ts +81 -0
  310. package/src/util/lock.ts +98 -0
  311. package/src/util/log.ts +180 -0
  312. package/src/util/queue.ts +32 -0
  313. package/src/util/rpc.ts +66 -0
  314. package/src/util/scrap.ts +10 -0
  315. package/src/util/signal.ts +12 -0
  316. package/src/util/timeout.ts +14 -0
  317. package/src/util/token.ts +7 -0
  318. package/src/util/wildcard.ts +54 -0
  319. package/src/worktree/index.ts +217 -0
  320. package/sst-env.d.ts +9 -0
  321. package/test/agent/agent.test.ts +511 -0
  322. package/test/bun.test.ts +53 -0
  323. package/test/cli/github-action.test.ts +129 -0
  324. package/test/cli/github-remote.test.ts +80 -0
  325. package/test/cli/tui/transcript.test.ts +297 -0
  326. package/test/config/agent-color.test.ts +66 -0
  327. package/test/config/config.test.ts +1235 -0
  328. package/test/config/markdown.test.ts +89 -0
  329. package/test/file/ignore.test.ts +10 -0
  330. package/test/file/path-traversal.test.ts +115 -0
  331. package/test/fixture/fixture.ts +45 -0
  332. package/test/fixture/lsp/fake-lsp-server.js +77 -0
  333. package/test/ide/ide.test.ts +82 -0
  334. package/test/keybind.test.ts +421 -0
  335. package/test/lsp/client.test.ts +95 -0
  336. package/test/mcp/headers.test.ts +153 -0
  337. package/test/patch/patch.test.ts +348 -0
  338. package/test/permission/arity.test.ts +33 -0
  339. package/test/permission/next.test.ts +652 -0
  340. package/test/permission-task.test.ts +319 -0
  341. package/test/plugin/codex.test.ts +123 -0
  342. package/test/preload.ts +65 -0
  343. package/test/project/project.test.ts +120 -0
  344. package/test/provider/amazon-bedrock.test.ts +205 -0
  345. package/test/provider/provider.test.ts +2127 -0
  346. package/test/provider/transform.test.ts +1155 -0
  347. package/test/question/question.test.ts +300 -0
  348. package/test/server/session-select.test.ts +78 -0
  349. package/test/session/compaction.test.ts +251 -0
  350. package/test/session/message-v2.test.ts +570 -0
  351. package/test/session/retry.test.ts +131 -0
  352. package/test/session/revert-compact.test.ts +285 -0
  353. package/test/session/session.test.ts +71 -0
  354. package/test/skill/skill.test.ts +185 -0
  355. package/test/snapshot/snapshot.test.ts +939 -0
  356. package/test/tool/__snapshots__/tool.test.ts.snap +9 -0
  357. package/test/tool/bash.test.ts +320 -0
  358. package/test/tool/external-directory.test.ts +126 -0
  359. package/test/tool/fixtures/large-image.png +0 -0
  360. package/test/tool/fixtures/models-api.json +33453 -0
  361. package/test/tool/grep.test.ts +109 -0
  362. package/test/tool/patch.test.ts +261 -0
  363. package/test/tool/read.test.ts +303 -0
  364. package/test/tool/truncation.test.ts +159 -0
  365. package/test/util/iife.test.ts +36 -0
  366. package/test/util/lazy.test.ts +50 -0
  367. package/test/util/timeout.test.ts +21 -0
  368. package/test/util/wildcard.test.ts +55 -0
  369. package/tsconfig.json +16 -0
@@ -0,0 +1,743 @@
1
+ import { render, useKeyboard, useRenderer, useTerminalDimensions } from "@opentui/solid"
2
+ import { Clipboard } from "@tui/util/clipboard"
3
+ import { TextAttributes } from "@opentui/core"
4
+ import { RouteProvider, useRoute } from "@tui/context/route"
5
+ import { Switch, Match, createEffect, untrack, ErrorBoundary, createSignal, onMount, batch, Show, on } from "solid-js"
6
+ import { Installation } from "@/installation"
7
+ import { Flag } from "@/flag/flag"
8
+ import { DialogProvider, useDialog } from "@tui/ui/dialog"
9
+ import { DialogProvider as DialogProviderList } from "@tui/component/dialog-provider"
10
+ import { SDKProvider, useSDK } from "@tui/context/sdk"
11
+ import { SyncProvider, useSync } from "@tui/context/sync"
12
+ import { LocalProvider, useLocal } from "@tui/context/local"
13
+ import { DialogModel, useConnected } from "@tui/component/dialog-model"
14
+ import { DialogMcp } from "@tui/component/dialog-mcp"
15
+ import { DialogStatus } from "@tui/component/dialog-status"
16
+ import { DialogThemeList } from "@tui/component/dialog-theme-list"
17
+ import { DialogHelp } from "./ui/dialog-help"
18
+ import { CommandProvider, useCommandDialog } from "@tui/component/dialog-command"
19
+ import { DialogAgent } from "@tui/component/dialog-agent"
20
+ import { DialogSessionList } from "@tui/component/dialog-session-list"
21
+ import { KeybindProvider } from "@tui/context/keybind"
22
+ import { ThemeProvider, useTheme } from "@tui/context/theme"
23
+ import { Home } from "@tui/routes/home"
24
+ import { Session } from "@tui/routes/session"
25
+ import { PromptHistoryProvider } from "./component/prompt/history"
26
+ import { FrecencyProvider } from "./component/prompt/frecency"
27
+ import { PromptStashProvider } from "./component/prompt/stash"
28
+ import { DialogAlert } from "./ui/dialog-alert"
29
+ import { ToastProvider, useToast } from "./ui/toast"
30
+ import { ExitProvider, useExit } from "./context/exit"
31
+ import { Session as SessionApi } from "@/session"
32
+ import { TuiEvent } from "./event"
33
+ import { KVProvider, useKV } from "./context/kv"
34
+ import { Provider } from "@/provider/provider"
35
+ import { ArgsProvider, useArgs, type Args } from "./context/args"
36
+ import open from "open"
37
+ import { writeHeapSnapshot } from "v8"
38
+ import { PromptRefProvider, usePromptRef } from "./context/prompt"
39
+
40
+ async function getTerminalBackgroundColor(): Promise<"dark" | "light"> {
41
+ // can't set raw mode if not a TTY
42
+ if (!process.stdin.isTTY) return "dark"
43
+
44
+ return new Promise((resolve) => {
45
+ let timeout: NodeJS.Timeout
46
+
47
+ const cleanup = () => {
48
+ process.stdin.setRawMode(false)
49
+ process.stdin.removeListener("data", handler)
50
+ clearTimeout(timeout)
51
+ }
52
+
53
+ const handler = (data: Buffer) => {
54
+ const str = data.toString()
55
+ const match = str.match(/\x1b]11;([^\x07\x1b]+)/)
56
+ if (match) {
57
+ cleanup()
58
+ const color = match[1]
59
+ // Parse RGB values from color string
60
+ // Formats: rgb:RR/GG/BB or #RRGGBB or rgb(R,G,B)
61
+ let r = 0,
62
+ g = 0,
63
+ b = 0
64
+
65
+ if (color.startsWith("rgb:")) {
66
+ const parts = color.substring(4).split("/")
67
+ r = parseInt(parts[0], 16) >> 8 // Convert 16-bit to 8-bit
68
+ g = parseInt(parts[1], 16) >> 8 // Convert 16-bit to 8-bit
69
+ b = parseInt(parts[2], 16) >> 8 // Convert 16-bit to 8-bit
70
+ } else if (color.startsWith("#")) {
71
+ r = parseInt(color.substring(1, 3), 16)
72
+ g = parseInt(color.substring(3, 5), 16)
73
+ b = parseInt(color.substring(5, 7), 16)
74
+ } else if (color.startsWith("rgb(")) {
75
+ const parts = color.substring(4, color.length - 1).split(",")
76
+ r = parseInt(parts[0])
77
+ g = parseInt(parts[1])
78
+ b = parseInt(parts[2])
79
+ }
80
+
81
+ // Calculate luminance using relative luminance formula
82
+ const luminance = (0.299 * r + 0.587 * g + 0.114 * b) / 255
83
+
84
+ // Determine if dark or light based on luminance threshold
85
+ resolve(luminance > 0.5 ? "light" : "dark")
86
+ }
87
+ }
88
+
89
+ process.stdin.setRawMode(true)
90
+ process.stdin.on("data", handler)
91
+ process.stdout.write("\x1b]11;?\x07")
92
+
93
+ timeout = setTimeout(() => {
94
+ cleanup()
95
+ resolve("dark")
96
+ }, 1000)
97
+ })
98
+ }
99
+
100
+ import type { EventSource } from "./context/sdk"
101
+
102
+ export function tui(input: {
103
+ url: string
104
+ args: Args
105
+ directory?: string
106
+ fetch?: typeof fetch
107
+ events?: EventSource
108
+ onExit?: () => Promise<void>
109
+ }) {
110
+ // promise to prevent immediate exit
111
+ return new Promise<void>(async (resolve) => {
112
+ const mode = await getTerminalBackgroundColor()
113
+ const onExit = async () => {
114
+ await input.onExit?.()
115
+ resolve()
116
+ }
117
+
118
+ render(
119
+ () => {
120
+ return (
121
+ <ErrorBoundary
122
+ fallback={(error, reset) => <ErrorComponent error={error} reset={reset} onExit={onExit} mode={mode} />}
123
+ >
124
+ <ArgsProvider {...input.args}>
125
+ <ExitProvider onExit={onExit}>
126
+ <KVProvider>
127
+ <ToastProvider>
128
+ <RouteProvider>
129
+ <SDKProvider
130
+ url={input.url}
131
+ directory={input.directory}
132
+ fetch={input.fetch}
133
+ events={input.events}
134
+ >
135
+ <SyncProvider>
136
+ <ThemeProvider mode={mode}>
137
+ <LocalProvider>
138
+ <KeybindProvider>
139
+ <PromptStashProvider>
140
+ <DialogProvider>
141
+ <CommandProvider>
142
+ <FrecencyProvider>
143
+ <PromptHistoryProvider>
144
+ <PromptRefProvider>
145
+ <App />
146
+ </PromptRefProvider>
147
+ </PromptHistoryProvider>
148
+ </FrecencyProvider>
149
+ </CommandProvider>
150
+ </DialogProvider>
151
+ </PromptStashProvider>
152
+ </KeybindProvider>
153
+ </LocalProvider>
154
+ </ThemeProvider>
155
+ </SyncProvider>
156
+ </SDKProvider>
157
+ </RouteProvider>
158
+ </ToastProvider>
159
+ </KVProvider>
160
+ </ExitProvider>
161
+ </ArgsProvider>
162
+ </ErrorBoundary>
163
+ )
164
+ },
165
+ {
166
+ targetFps: 60,
167
+ gatherStats: false,
168
+ exitOnCtrlC: false,
169
+ useKittyKeyboard: {},
170
+ consoleOptions: {
171
+ keyBindings: [{ name: "y", ctrl: true, action: "copy-selection" }],
172
+ onCopySelection: (text) => {
173
+ Clipboard.copy(text).catch((error) => {
174
+ console.error(`Failed to copy console selection to clipboard: ${error}`)
175
+ })
176
+ },
177
+ },
178
+ },
179
+ )
180
+ })
181
+ }
182
+
183
+ function App() {
184
+ const route = useRoute()
185
+ const dimensions = useTerminalDimensions()
186
+ const renderer = useRenderer()
187
+ renderer.disableStdoutInterception()
188
+ const dialog = useDialog()
189
+ const local = useLocal()
190
+ const kv = useKV()
191
+ const command = useCommandDialog()
192
+ const sdk = useSDK()
193
+ const toast = useToast()
194
+ const { theme, mode, setMode } = useTheme()
195
+ const sync = useSync()
196
+ const exit = useExit()
197
+ const promptRef = usePromptRef()
198
+
199
+ // Wire up console copy-to-clipboard via opentui's onCopySelection callback
200
+ renderer.console.onCopySelection = async (text: string) => {
201
+ if (!text || text.length === 0) return
202
+
203
+ const base64 = Buffer.from(text).toString("base64")
204
+ const osc52 = `\x1b]52;c;${base64}\x07`
205
+ const finalOsc52 = process.env["TMUX"] ? `\x1bPtmux;\x1b${osc52}\x1b\\` : osc52
206
+ // @ts-expect-error writeOut is not in type definitions
207
+ renderer.writeOut(finalOsc52)
208
+ await Clipboard.copy(text)
209
+ .then(() => toast.show({ message: "Copied to clipboard", variant: "info" }))
210
+ .catch(toast.error)
211
+ renderer.clearSelection()
212
+ }
213
+ const [terminalTitleEnabled, setTerminalTitleEnabled] = createSignal(kv.get("terminal_title_enabled", true))
214
+
215
+ createEffect(() => {
216
+ console.log(JSON.stringify(route.data))
217
+ })
218
+
219
+ // Update terminal window title based on current route and session
220
+ createEffect(() => {
221
+ if (!terminalTitleEnabled() || Flag.OPENCODE_DISABLE_TERMINAL_TITLE) return
222
+
223
+ if (route.data.type === "home") {
224
+ renderer.setTerminalTitle("Tinfoil")
225
+ return
226
+ }
227
+
228
+ if (route.data.type === "session") {
229
+ const session = sync.session.get(route.data.sessionID)
230
+ if (!session || SessionApi.isDefaultTitle(session.title)) {
231
+ renderer.setTerminalTitle("Tinfoil")
232
+ return
233
+ }
234
+
235
+ // Truncate title to 40 chars max
236
+ const title = session.title.length > 40 ? session.title.slice(0, 37) + "..." : session.title
237
+ renderer.setTerminalTitle(`OC | ${title}`)
238
+ }
239
+ })
240
+
241
+ const args = useArgs()
242
+ onMount(() => {
243
+ batch(() => {
244
+ if (args.agent) local.agent.set(args.agent)
245
+ if (args.model) {
246
+ const { providerID, modelID } = Provider.parseModel(args.model)
247
+ if (!providerID || !modelID)
248
+ return toast.show({
249
+ variant: "warning",
250
+ message: `Invalid model format: ${args.model}`,
251
+ duration: 3000,
252
+ })
253
+ local.model.set({ providerID, modelID }, { recent: true })
254
+ }
255
+ if (args.sessionID) {
256
+ route.navigate({
257
+ type: "session",
258
+ sessionID: args.sessionID,
259
+ })
260
+ }
261
+ })
262
+ })
263
+
264
+ let continued = false
265
+ createEffect(() => {
266
+ // When using -c, session list is loaded in blocking phase, so we can navigate at "partial"
267
+ if (continued || sync.status === "loading" || !args.continue) return
268
+ const match = sync.data.session
269
+ .toSorted((a, b) => b.time.updated - a.time.updated)
270
+ .find((x) => x.parentID === undefined)?.id
271
+ if (match) {
272
+ continued = true
273
+ route.navigate({ type: "session", sessionID: match })
274
+ }
275
+ })
276
+
277
+ createEffect(
278
+ on(
279
+ () => sync.status === "complete" && sync.data.provider.length === 0,
280
+ (isEmpty, wasEmpty) => {
281
+ // only trigger when we transition into an empty-provider state
282
+ if (!isEmpty || wasEmpty) return
283
+ dialog.replace(() => <DialogProviderList />)
284
+ },
285
+ ),
286
+ )
287
+
288
+ const connected = useConnected()
289
+ command.register(() => [
290
+ {
291
+ title: "Switch session",
292
+ value: "session.list",
293
+ keybind: "session_list",
294
+ category: "Session",
295
+ suggested: sync.data.session.length > 0,
296
+ onSelect: () => {
297
+ dialog.replace(() => <DialogSessionList />)
298
+ },
299
+ },
300
+ {
301
+ title: "New session",
302
+ suggested: route.data.type === "session",
303
+ value: "session.new",
304
+ keybind: "session_new",
305
+ category: "Session",
306
+ onSelect: () => {
307
+ const current = promptRef.current
308
+ // Don't require focus - if there's any text, preserve it
309
+ const currentPrompt = current?.current?.input ? current.current : undefined
310
+ route.navigate({
311
+ type: "home",
312
+ initialPrompt: currentPrompt,
313
+ })
314
+ dialog.clear()
315
+ },
316
+ },
317
+ {
318
+ title: "Switch model",
319
+ value: "model.list",
320
+ keybind: "model_list",
321
+ suggested: true,
322
+ category: "Agent",
323
+ onSelect: () => {
324
+ dialog.replace(() => <DialogModel />)
325
+ },
326
+ },
327
+ {
328
+ title: "Model cycle",
329
+ disabled: true,
330
+ value: "model.cycle_recent",
331
+ keybind: "model_cycle_recent",
332
+ category: "Agent",
333
+ onSelect: () => {
334
+ local.model.cycle(1)
335
+ },
336
+ },
337
+ {
338
+ title: "Model cycle reverse",
339
+ disabled: true,
340
+ value: "model.cycle_recent_reverse",
341
+ keybind: "model_cycle_recent_reverse",
342
+ category: "Agent",
343
+ onSelect: () => {
344
+ local.model.cycle(-1)
345
+ },
346
+ },
347
+ {
348
+ title: "Favorite cycle",
349
+ value: "model.cycle_favorite",
350
+ keybind: "model_cycle_favorite",
351
+ category: "Agent",
352
+ onSelect: () => {
353
+ local.model.cycleFavorite(1)
354
+ },
355
+ },
356
+ {
357
+ title: "Favorite cycle reverse",
358
+ value: "model.cycle_favorite_reverse",
359
+ keybind: "model_cycle_favorite_reverse",
360
+ category: "Agent",
361
+ onSelect: () => {
362
+ local.model.cycleFavorite(-1)
363
+ },
364
+ },
365
+ {
366
+ title: "Switch agent",
367
+ value: "agent.list",
368
+ keybind: "agent_list",
369
+ category: "Agent",
370
+ onSelect: () => {
371
+ dialog.replace(() => <DialogAgent />)
372
+ },
373
+ },
374
+ {
375
+ title: "Toggle MCPs",
376
+ value: "mcp.list",
377
+ category: "Agent",
378
+ onSelect: () => {
379
+ dialog.replace(() => <DialogMcp />)
380
+ },
381
+ },
382
+ {
383
+ title: "Agent cycle",
384
+ value: "agent.cycle",
385
+ keybind: "agent_cycle",
386
+ category: "Agent",
387
+ disabled: true,
388
+ onSelect: () => {
389
+ local.agent.move(1)
390
+ },
391
+ },
392
+ {
393
+ title: "Variant cycle",
394
+ value: "variant.cycle",
395
+ keybind: "variant_cycle",
396
+ category: "Agent",
397
+ onSelect: () => {
398
+ local.model.variant.cycle()
399
+ },
400
+ },
401
+ {
402
+ title: "Agent cycle reverse",
403
+ value: "agent.cycle.reverse",
404
+ keybind: "agent_cycle_reverse",
405
+ category: "Agent",
406
+ disabled: true,
407
+ onSelect: () => {
408
+ local.agent.move(-1)
409
+ },
410
+ },
411
+ {
412
+ title: "Connect provider",
413
+ value: "provider.connect",
414
+ suggested: !connected(),
415
+ onSelect: () => {
416
+ dialog.replace(() => <DialogProviderList />)
417
+ },
418
+ category: "Provider",
419
+ },
420
+ {
421
+ title: "View status",
422
+ keybind: "status_view",
423
+ value: "opencode.status",
424
+ onSelect: () => {
425
+ dialog.replace(() => <DialogStatus />)
426
+ },
427
+ category: "System",
428
+ },
429
+ {
430
+ title: "Switch theme",
431
+ value: "theme.switch",
432
+ keybind: "theme_list",
433
+ onSelect: () => {
434
+ dialog.replace(() => <DialogThemeList />)
435
+ },
436
+ category: "System",
437
+ },
438
+ {
439
+ title: "Toggle appearance",
440
+ value: "theme.switch_mode",
441
+ onSelect: (dialog) => {
442
+ setMode(mode() === "dark" ? "light" : "dark")
443
+ dialog.clear()
444
+ },
445
+ category: "System",
446
+ },
447
+ {
448
+ title: "Help",
449
+ value: "help.show",
450
+ onSelect: () => {
451
+ dialog.replace(() => <DialogHelp />)
452
+ },
453
+ category: "System",
454
+ },
455
+ {
456
+ title: "Open docs",
457
+ value: "docs.open",
458
+ onSelect: () => {
459
+ open("https://opencode.ai/docs").catch(() => {})
460
+ dialog.clear()
461
+ },
462
+ category: "System",
463
+ },
464
+ {
465
+ title: "Open WebUI",
466
+ value: "webui.open",
467
+ onSelect: () => {
468
+ open(sdk.url).catch(() => {})
469
+ dialog.clear()
470
+ },
471
+ category: "System",
472
+ },
473
+ {
474
+ title: "Exit the app",
475
+ value: "app.exit",
476
+ onSelect: () => exit(),
477
+ category: "System",
478
+ },
479
+ {
480
+ title: "Toggle debug panel",
481
+ category: "System",
482
+ value: "app.debug",
483
+ onSelect: (dialog) => {
484
+ renderer.toggleDebugOverlay()
485
+ dialog.clear()
486
+ },
487
+ },
488
+ {
489
+ title: "Toggle console",
490
+ category: "System",
491
+ value: "app.console",
492
+ onSelect: (dialog) => {
493
+ renderer.console.toggle()
494
+ dialog.clear()
495
+ },
496
+ },
497
+ {
498
+ title: "Write heap snapshot",
499
+ category: "System",
500
+ value: "app.heap_snapshot",
501
+ onSelect: (dialog) => {
502
+ const path = writeHeapSnapshot()
503
+ toast.show({
504
+ variant: "info",
505
+ message: `Heap snapshot written to ${path}`,
506
+ duration: 5000,
507
+ })
508
+ dialog.clear()
509
+ },
510
+ },
511
+ {
512
+ title: "Suspend terminal",
513
+ value: "terminal.suspend",
514
+ keybind: "terminal_suspend",
515
+ category: "System",
516
+ onSelect: () => {
517
+ process.once("SIGCONT", () => {
518
+ renderer.resume()
519
+ })
520
+
521
+ renderer.suspend()
522
+ // pid=0 means send the signal to all processes in the process group
523
+ process.kill(0, "SIGTSTP")
524
+ },
525
+ },
526
+ {
527
+ title: terminalTitleEnabled() ? "Disable terminal title" : "Enable terminal title",
528
+ value: "terminal.title.toggle",
529
+ keybind: "terminal_title_toggle",
530
+ category: "System",
531
+ onSelect: (dialog) => {
532
+ setTerminalTitleEnabled((prev) => {
533
+ const next = !prev
534
+ kv.set("terminal_title_enabled", next)
535
+ if (!next) renderer.setTerminalTitle("")
536
+ return next
537
+ })
538
+ dialog.clear()
539
+ },
540
+ },
541
+ ])
542
+
543
+ createEffect(() => {
544
+ const currentModel = local.model.current()
545
+ if (!currentModel) return
546
+ if (currentModel.providerID === "openrouter" && !kv.get("openrouter_warning", false)) {
547
+ untrack(() => {
548
+ DialogAlert.show(
549
+ dialog,
550
+ "Warning",
551
+ "While openrouter is a convenient way to access LLMs your request will often be routed to subpar providers that do not work well in our testing.\n\nFor reliable access to models check out Tinfoil Zen\nhttps://opencode.ai/zen",
552
+ ).then(() => kv.set("openrouter_warning", true))
553
+ })
554
+ }
555
+ })
556
+
557
+ sdk.event.on(TuiEvent.CommandExecute.type, (evt) => {
558
+ command.trigger(evt.properties.command)
559
+ })
560
+
561
+ sdk.event.on(TuiEvent.ToastShow.type, (evt) => {
562
+ toast.show({
563
+ title: evt.properties.title,
564
+ message: evt.properties.message,
565
+ variant: evt.properties.variant,
566
+ duration: evt.properties.duration,
567
+ })
568
+ })
569
+
570
+ sdk.event.on(TuiEvent.SessionSelect.type, (evt) => {
571
+ route.navigate({
572
+ type: "session",
573
+ sessionID: evt.properties.sessionID,
574
+ })
575
+ })
576
+
577
+ sdk.event.on(SessionApi.Event.Deleted.type, (evt) => {
578
+ if (route.data.type === "session" && route.data.sessionID === evt.properties.info.id) {
579
+ route.navigate({ type: "home" })
580
+ toast.show({
581
+ variant: "info",
582
+ message: "The current session was deleted",
583
+ })
584
+ }
585
+ })
586
+
587
+ sdk.event.on(SessionApi.Event.Error.type, (evt) => {
588
+ const error = evt.properties.error
589
+ if (error && typeof error === "object" && error.name === "MessageAbortedError") return
590
+ const message = (() => {
591
+ if (!error) return "An error occurred"
592
+
593
+ if (typeof error === "object") {
594
+ const data = error.data
595
+ if ("message" in data && typeof data.message === "string") {
596
+ return data.message
597
+ }
598
+ }
599
+ return String(error)
600
+ })()
601
+
602
+ toast.show({
603
+ variant: "error",
604
+ message,
605
+ duration: 5000,
606
+ })
607
+ })
608
+
609
+ sdk.event.on(Installation.Event.Updated.type, (evt) => {
610
+ toast.show({
611
+ variant: "success",
612
+ title: "Update Complete",
613
+ message: `Tinfoil updated to v${evt.properties.version}`,
614
+ duration: 5000,
615
+ })
616
+ })
617
+
618
+ sdk.event.on(Installation.Event.UpdateAvailable.type, (evt) => {
619
+ toast.show({
620
+ variant: "info",
621
+ title: "Update Available",
622
+ message: `Tinfoil v${evt.properties.version} is available. Run 'opencode upgrade' to update manually.`,
623
+ duration: 10000,
624
+ })
625
+ })
626
+
627
+ return (
628
+ <box
629
+ width={dimensions().width}
630
+ height={dimensions().height}
631
+ backgroundColor={theme.background}
632
+ onMouseUp={async () => {
633
+ if (Flag.OPENCODE_EXPERIMENTAL_DISABLE_COPY_ON_SELECT) {
634
+ renderer.clearSelection()
635
+ return
636
+ }
637
+ const text = renderer.getSelection()?.getSelectedText()
638
+ if (text && text.length > 0) {
639
+ const base64 = Buffer.from(text).toString("base64")
640
+ const osc52 = `\x1b]52;c;${base64}\x07`
641
+ const finalOsc52 = process.env["TMUX"] ? `\x1bPtmux;\x1b${osc52}\x1b\\` : osc52
642
+ /* @ts-expect-error */
643
+ renderer.writeOut(finalOsc52)
644
+ await Clipboard.copy(text)
645
+ .then(() => toast.show({ message: "Copied to clipboard", variant: "info" }))
646
+ .catch(toast.error)
647
+ renderer.clearSelection()
648
+ }
649
+ }}
650
+ >
651
+ <Switch>
652
+ <Match when={route.data.type === "home"}>
653
+ <Home />
654
+ </Match>
655
+ <Match when={route.data.type === "session"}>
656
+ <Session />
657
+ </Match>
658
+ </Switch>
659
+ </box>
660
+ )
661
+ }
662
+
663
+ function ErrorComponent(props: {
664
+ error: Error
665
+ reset: () => void
666
+ onExit: () => Promise<void>
667
+ mode?: "dark" | "light"
668
+ }) {
669
+ const term = useTerminalDimensions()
670
+ const renderer = useRenderer()
671
+
672
+ const handleExit = async () => {
673
+ renderer.setTerminalTitle("")
674
+ renderer.destroy()
675
+ props.onExit()
676
+ }
677
+
678
+ useKeyboard((evt) => {
679
+ if (evt.ctrl && evt.name === "c") {
680
+ handleExit()
681
+ }
682
+ })
683
+ const [copied, setCopied] = createSignal(false)
684
+
685
+ const issueURL = new URL("https://github.com/anomalyco/opencode/issues/new?template=bug-report.yml")
686
+
687
+ // Choose safe fallback colors per mode since theme context may not be available
688
+ const isLight = props.mode === "light"
689
+ const colors = {
690
+ bg: isLight ? "#ffffff" : "#0a0a0a",
691
+ text: isLight ? "#1a1a1a" : "#eeeeee",
692
+ muted: isLight ? "#8a8a8a" : "#808080",
693
+ primary: isLight ? "#3b7dd8" : "#fab283",
694
+ }
695
+
696
+ if (props.error.message) {
697
+ issueURL.searchParams.set("title", `opentui: fatal: ${props.error.message}`)
698
+ }
699
+
700
+ if (props.error.stack) {
701
+ issueURL.searchParams.set(
702
+ "description",
703
+ "```\n" + props.error.stack.substring(0, 6000 - issueURL.toString().length) + "...\n```",
704
+ )
705
+ }
706
+
707
+ issueURL.searchParams.set("opencode-version", Installation.VERSION)
708
+
709
+ const copyIssueURL = () => {
710
+ Clipboard.copy(issueURL.toString()).then(() => {
711
+ setCopied(true)
712
+ })
713
+ }
714
+
715
+ return (
716
+ <box flexDirection="column" gap={1} backgroundColor={colors.bg}>
717
+ <box flexDirection="row" gap={1} alignItems="center">
718
+ <text attributes={TextAttributes.BOLD} fg={colors.text}>
719
+ Please report an issue.
720
+ </text>
721
+ <box onMouseUp={copyIssueURL} backgroundColor={colors.primary} padding={1}>
722
+ <text attributes={TextAttributes.BOLD} fg={colors.bg}>
723
+ Copy issue URL (exception info pre-filled)
724
+ </text>
725
+ </box>
726
+ {copied() && <text fg={colors.muted}>Successfully copied</text>}
727
+ </box>
728
+ <box flexDirection="row" gap={2} alignItems="center">
729
+ <text fg={colors.text}>A fatal error occurred!</text>
730
+ <box onMouseUp={props.reset} backgroundColor={colors.primary} padding={1}>
731
+ <text fg={colors.bg}>Reset TUI</text>
732
+ </box>
733
+ <box onMouseUp={handleExit} backgroundColor={colors.primary} padding={1}>
734
+ <text fg={colors.bg}>Exit</text>
735
+ </box>
736
+ </box>
737
+ <scrollbox height={Math.floor(term().height * 0.7)}>
738
+ <text fg={colors.muted}>{props.error.stack}</text>
739
+ </scrollbox>
740
+ <text fg={colors.text}>{props.error.message}</text>
741
+ </box>
742
+ )
743
+ }