@neurocode-ai/tui 1.18.8

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 (241) hide show
  1. package/bunfig.toml +4 -0
  2. package/package.json +72 -0
  3. package/src/app.tsx +1134 -0
  4. package/src/attention.ts +260 -0
  5. package/src/audio.d.ts +9 -0
  6. package/src/audio.ts +53 -0
  7. package/src/clipboard.ts +124 -0
  8. package/src/component/bg-pulse-render.ts +436 -0
  9. package/src/component/bg-pulse.tsx +99 -0
  10. package/src/component/command-palette.tsx +79 -0
  11. package/src/component/dialog-agent.tsx +31 -0
  12. package/src/component/dialog-console-org.tsx +135 -0
  13. package/src/component/dialog-debug.tsx +90 -0
  14. package/src/component/dialog-mcp.tsx +85 -0
  15. package/src/component/dialog-model.tsx +197 -0
  16. package/src/component/dialog-move-session.tsx +353 -0
  17. package/src/component/dialog-provider.tsx +469 -0
  18. package/src/component/dialog-retry-action.tsx +160 -0
  19. package/src/component/dialog-session-delete-failed.tsx +99 -0
  20. package/src/component/dialog-session-list.tsx +364 -0
  21. package/src/component/dialog-session-rename.tsx +31 -0
  22. package/src/component/dialog-skill.tsx +70 -0
  23. package/src/component/dialog-stash.tsx +87 -0
  24. package/src/component/dialog-status.tsx +168 -0
  25. package/src/component/dialog-tag.tsx +47 -0
  26. package/src/component/dialog-theme-list.tsx +50 -0
  27. package/src/component/dialog-variant.tsx +39 -0
  28. package/src/component/dialog-workspace-create.tsx +308 -0
  29. package/src/component/dialog-workspace-file-changes.tsx +144 -0
  30. package/src/component/dialog-workspace-list.tsx +112 -0
  31. package/src/component/dialog-workspace-unavailable.tsx +69 -0
  32. package/src/component/error-component.tsx +240 -0
  33. package/src/component/logo.tsx +61 -0
  34. package/src/component/plugin-route-missing.tsx +14 -0
  35. package/src/component/prompt/autocomplete.tsx +781 -0
  36. package/src/component/prompt/cwd.ts +0 -0
  37. package/src/component/prompt/frecency.tsx +1 -0
  38. package/src/component/prompt/history.tsx +1 -0
  39. package/src/component/prompt/index.tsx +1713 -0
  40. package/src/component/prompt/local-attachment.ts +48 -0
  41. package/src/component/prompt/move.tsx +205 -0
  42. package/src/component/prompt/stash.tsx +1 -0
  43. package/src/component/prompt/workspace.tsx +137 -0
  44. package/src/component/register-spinner.ts +6 -0
  45. package/src/component/spinner.tsx +26 -0
  46. package/src/component/startup-loading.tsx +63 -0
  47. package/src/component/todo-item.tsx +32 -0
  48. package/src/component/use-connected.tsx +12 -0
  49. package/src/component/workspace-label.tsx +19 -0
  50. package/src/config/index.tsx +129 -0
  51. package/src/config/keybind.ts +471 -0
  52. package/src/context/args.tsx +16 -0
  53. package/src/context/clipboard.tsx +18 -0
  54. package/src/context/data.tsx +569 -0
  55. package/src/context/directory.ts +17 -0
  56. package/src/context/editor.ts +408 -0
  57. package/src/context/epilogue.tsx +6 -0
  58. package/src/context/event.ts +36 -0
  59. package/src/context/exit.tsx +8 -0
  60. package/src/context/helper.tsx +26 -0
  61. package/src/context/kv.tsx +66 -0
  62. package/src/context/local.tsx +542 -0
  63. package/src/context/location.tsx +14 -0
  64. package/src/context/path-format.tsx +24 -0
  65. package/src/context/permission.tsx +26 -0
  66. package/src/context/project.tsx +115 -0
  67. package/src/context/prompt.tsx +18 -0
  68. package/src/context/route.tsx +60 -0
  69. package/src/context/runtime.tsx +62 -0
  70. package/src/context/sdk.tsx +151 -0
  71. package/src/context/sync.tsx +666 -0
  72. package/src/context/theme.tsx +332 -0
  73. package/src/context/thinking.ts +67 -0
  74. package/src/editor-zed.ts +286 -0
  75. package/src/editor.ts +101 -0
  76. package/src/feature-plugins/builtins.ts +36 -0
  77. package/src/feature-plugins/home/footer.tsx +100 -0
  78. package/src/feature-plugins/home/tips-view.tsx +287 -0
  79. package/src/feature-plugins/home/tips.tsx +59 -0
  80. package/src/feature-plugins/sidebar/context.tsx +65 -0
  81. package/src/feature-plugins/sidebar/files.tsx +70 -0
  82. package/src/feature-plugins/sidebar/footer.tsx +98 -0
  83. package/src/feature-plugins/sidebar/lsp.tsx +65 -0
  84. package/src/feature-plugins/sidebar/mcp.tsx +97 -0
  85. package/src/feature-plugins/sidebar/todo.tsx +49 -0
  86. package/src/feature-plugins/system/diff-viewer-file-tree-utils.ts +232 -0
  87. package/src/feature-plugins/system/diff-viewer-file-tree.tsx +162 -0
  88. package/src/feature-plugins/system/diff-viewer-ui.tsx +103 -0
  89. package/src/feature-plugins/system/diff-viewer.tsx +1077 -0
  90. package/src/feature-plugins/system/notifications.ts +94 -0
  91. package/src/feature-plugins/system/plugins.tsx +269 -0
  92. package/src/feature-plugins/system/which-key.tsx +608 -0
  93. package/src/index.tsx +1 -0
  94. package/src/keymap.tsx +290 -0
  95. package/src/logo.ts +11 -0
  96. package/src/parsers-config.ts +386 -0
  97. package/src/plugin/adapters.tsx +355 -0
  98. package/src/plugin/api.ts +52 -0
  99. package/src/plugin/command-shim.ts +109 -0
  100. package/src/plugin/runtime.tsx +81 -0
  101. package/src/plugin/slots.tsx +65 -0
  102. package/src/prompt/display.ts +48 -0
  103. package/src/prompt/frecency.tsx +80 -0
  104. package/src/prompt/history.tsx +111 -0
  105. package/src/prompt/part.ts +29 -0
  106. package/src/prompt/stash.tsx +89 -0
  107. package/src/prompt/traits.ts +29 -0
  108. package/src/routes/home/session-destination.tsx +41 -0
  109. package/src/routes/home.tsx +95 -0
  110. package/src/routes/session/dialog-fork-from-timeline.tsx +76 -0
  111. package/src/routes/session/dialog-message.tsx +109 -0
  112. package/src/routes/session/dialog-subagent.tsx +26 -0
  113. package/src/routes/session/dialog-timeline.tsx +47 -0
  114. package/src/routes/session/footer.tsx +91 -0
  115. package/src/routes/session/index.tsx +2710 -0
  116. package/src/routes/session/permission.tsx +718 -0
  117. package/src/routes/session/question.tsx +514 -0
  118. package/src/routes/session/sidebar.tsx +103 -0
  119. package/src/routes/session/subagent-footer.tsx +132 -0
  120. package/src/runtime.tsx +9 -0
  121. package/src/terminal-win32.ts +130 -0
  122. package/src/theme/assets/aura.json +69 -0
  123. package/src/theme/assets/ayu.json +80 -0
  124. package/src/theme/assets/carbonfox.json +248 -0
  125. package/src/theme/assets/catppuccin-frappe.json +230 -0
  126. package/src/theme/assets/catppuccin-macchiato.json +230 -0
  127. package/src/theme/assets/catppuccin.json +112 -0
  128. package/src/theme/assets/cobalt2.json +225 -0
  129. package/src/theme/assets/cursor.json +249 -0
  130. package/src/theme/assets/dracula.json +219 -0
  131. package/src/theme/assets/everforest.json +241 -0
  132. package/src/theme/assets/flexoki.json +237 -0
  133. package/src/theme/assets/github.json +233 -0
  134. package/src/theme/assets/gruvbox.json +242 -0
  135. package/src/theme/assets/kanagawa.json +77 -0
  136. package/src/theme/assets/lucent-orng.json +234 -0
  137. package/src/theme/assets/material.json +235 -0
  138. package/src/theme/assets/matrix.json +77 -0
  139. package/src/theme/assets/mercury.json +252 -0
  140. package/src/theme/assets/monokai.json +221 -0
  141. package/src/theme/assets/nightowl.json +221 -0
  142. package/src/theme/assets/nord.json +223 -0
  143. package/src/theme/assets/one-dark.json +84 -0
  144. package/src/theme/assets/opencode.json +245 -0
  145. package/src/theme/assets/orng.json +249 -0
  146. package/src/theme/assets/osaka-jade.json +93 -0
  147. package/src/theme/assets/palenight.json +222 -0
  148. package/src/theme/assets/rosepine.json +234 -0
  149. package/src/theme/assets/solarized.json +223 -0
  150. package/src/theme/assets/synthwave84.json +226 -0
  151. package/src/theme/assets/tokyonight.json +243 -0
  152. package/src/theme/assets/vercel.json +245 -0
  153. package/src/theme/assets/vesper.json +218 -0
  154. package/src/theme/assets/zenburn.json +223 -0
  155. package/src/theme/index.ts +1089 -0
  156. package/src/ui/border.ts +21 -0
  157. package/src/ui/dialog-alert.tsx +66 -0
  158. package/src/ui/dialog-confirm.tsx +108 -0
  159. package/src/ui/dialog-export-options.tsx +217 -0
  160. package/src/ui/dialog-help.tsx +40 -0
  161. package/src/ui/dialog-prompt.tsx +126 -0
  162. package/src/ui/dialog-select.tsx +790 -0
  163. package/src/ui/dialog.tsx +231 -0
  164. package/src/ui/link.tsx +34 -0
  165. package/src/ui/spinner.ts +368 -0
  166. package/src/ui/toast.tsx +102 -0
  167. package/src/util/collapse-tool-output.ts +19 -0
  168. package/src/util/error.ts +182 -0
  169. package/src/util/filetype.ts +130 -0
  170. package/src/util/format.ts +20 -0
  171. package/src/util/layout.ts +25 -0
  172. package/src/util/locale.ts +86 -0
  173. package/src/util/model.ts +28 -0
  174. package/src/util/path.ts +12 -0
  175. package/src/util/persistence.ts +33 -0
  176. package/src/util/presentation.ts +38 -0
  177. package/src/util/provider-origin.ts +7 -0
  178. package/src/util/record.ts +3 -0
  179. package/src/util/renderer.ts +7 -0
  180. package/src/util/revert-diff.ts +18 -0
  181. package/src/util/scroll.ts +27 -0
  182. package/src/util/selection.ts +79 -0
  183. package/src/util/session.ts +3 -0
  184. package/src/util/signal.ts +51 -0
  185. package/src/util/system.ts +20 -0
  186. package/src/util/tool-display.ts +13 -0
  187. package/src/util/transcript.ts +112 -0
  188. package/sst-env.d.ts +10 -0
  189. package/test/app-lifecycle.test.tsx +128 -0
  190. package/test/cli/cmd/tui/dialog-workspace-create.test.ts +28 -0
  191. package/test/cli/cmd/tui/model-options.test.ts +32 -0
  192. package/test/cli/cmd/tui/notifications.test.ts +267 -0
  193. package/test/cli/cmd/tui/provider-options.test.ts +41 -0
  194. package/test/cli/cmd/tui/sync-fixture.tsx +70 -0
  195. package/test/cli/cmd/tui/sync-live-hydration.test.tsx +262 -0
  196. package/test/cli/cmd/tui/sync-undefined-messages.test.tsx +43 -0
  197. package/test/cli/cmd/tui/sync.test.tsx +65 -0
  198. package/test/cli/tui/__snapshots__/inline-tool-wrap-snapshot.test.tsx.snap +92 -0
  199. package/test/cli/tui/data.test.tsx +486 -0
  200. package/test/cli/tui/dialog-prompt.test.tsx +147 -0
  201. package/test/cli/tui/diff-viewer-file-tree.test.tsx +200 -0
  202. package/test/cli/tui/diff-viewer.test.tsx +268 -0
  203. package/test/cli/tui/inline-tool-wrap-snapshot.test.tsx +351 -0
  204. package/test/cli/tui/prompt-submit-race.test.ts +98 -0
  205. package/test/cli/tui/thinking.test.ts +36 -0
  206. package/test/cli/tui/use-event.test.tsx +148 -0
  207. package/test/clipboard.test.ts +19 -0
  208. package/test/component/dialog-session-list.test.ts +46 -0
  209. package/test/config.test.tsx +127 -0
  210. package/test/context/local.test.ts +22 -0
  211. package/test/editor.test.ts +32 -0
  212. package/test/feature-plugins/diff-viewer-file-tree-utils.test.ts +323 -0
  213. package/test/fixture/fixture.ts +13 -0
  214. package/test/fixture/tui-environment.tsx +32 -0
  215. package/test/fixture/tui-plugin.ts +36 -0
  216. package/test/fixture/tui-runtime.ts +12 -0
  217. package/test/fixture/tui-sdk.ts +109 -0
  218. package/test/index.test.tsx +6 -0
  219. package/test/keymap.test.tsx +141 -0
  220. package/test/plugin/runtime.test.ts +50 -0
  221. package/test/plugin/slots.test.tsx +38 -0
  222. package/test/prompt/display.test.ts +33 -0
  223. package/test/prompt/history.test.ts +39 -0
  224. package/test/prompt/jsonl.test.ts +24 -0
  225. package/test/prompt/local-attachment.test.ts +43 -0
  226. package/test/prompt/part.test.ts +53 -0
  227. package/test/prompt/persistence.test.ts +23 -0
  228. package/test/prompt/traits.test.ts +25 -0
  229. package/test/runtime.test.tsx +37 -0
  230. package/test/theme.test.ts +81 -0
  231. package/test/util/error.test.ts +49 -0
  232. package/test/util/filetype.test.ts +16 -0
  233. package/test/util/format.test.ts +59 -0
  234. package/test/util/model.test.ts +9 -0
  235. package/test/util/presentation.test.ts +8 -0
  236. package/test/util/renderer.test.ts +30 -0
  237. package/test/util/revert-diff.test.ts +35 -0
  238. package/test/util/session.test.ts +10 -0
  239. package/test/util/tool-display.test.ts +40 -0
  240. package/test/util/transcript.test.ts +421 -0
  241. package/tsconfig.json +10 -0
@@ -0,0 +1,81 @@
1
+ import { expect, test } from "bun:test"
2
+ import { mkdir, writeFile } from "node:fs/promises"
3
+ import path from "node:path"
4
+ import type { TerminalColors } from "@opentui/core"
5
+ import { DEFAULT_THEMES, addTheme, allThemes, hasTheme, resolveTheme, terminalMode } from "../src/theme"
6
+ import { discoverThemes } from "../src/context/theme"
7
+ import { tmpdir } from "./fixture/fixture"
8
+
9
+ test("addTheme writes into module theme store", () => {
10
+ const name = `plugin-theme-${Date.now()}`
11
+ expect(addTheme(name, DEFAULT_THEMES.opencode)).toBe(true)
12
+ expect(allThemes()[name]).toBeDefined()
13
+ })
14
+
15
+ test("addTheme keeps first theme for duplicate names", () => {
16
+ const name = `plugin-theme-keep-${Date.now()}`
17
+ const one = structuredClone(DEFAULT_THEMES.opencode)
18
+ const two = structuredClone(DEFAULT_THEMES.opencode)
19
+ one.theme.primary = "#101010"
20
+ two.theme.primary = "#fefefe"
21
+
22
+ expect(addTheme(name, one)).toBe(true)
23
+ expect(addTheme(name, two)).toBe(false)
24
+ expect(allThemes()[name]!.theme.primary).toBe("#101010")
25
+ })
26
+
27
+ test("addTheme ignores entries without a theme object", () => {
28
+ const name = `plugin-theme-invalid-${Date.now()}`
29
+ expect(addTheme(name, { defs: { a: "#ffffff" } })).toBe(false)
30
+ expect(allThemes()[name]).toBeUndefined()
31
+ })
32
+
33
+ test("hasTheme checks theme presence", () => {
34
+ const name = `plugin-theme-has-${Date.now()}`
35
+ expect(hasTheme(name)).toBe(false)
36
+ expect(addTheme(name, DEFAULT_THEMES.opencode)).toBe(true)
37
+ expect(hasTheme(name)).toBe(true)
38
+ })
39
+
40
+ test("resolveTheme rejects circular color refs", () => {
41
+ const item = structuredClone(DEFAULT_THEMES.opencode)
42
+ item.defs = { ...item.defs, one: "two", two: "one" }
43
+ item.theme.primary = "one"
44
+ expect(() => resolveTheme(item, "dark")).toThrow("Circular color reference")
45
+ })
46
+
47
+ function terminalColors(defaultBackground: string | null, palette: Array<string | null> = []): TerminalColors {
48
+ return {
49
+ palette,
50
+ defaultForeground: null,
51
+ defaultBackground,
52
+ cursorColor: null,
53
+ mouseForeground: null,
54
+ mouseBackground: null,
55
+ tekForeground: null,
56
+ tekBackground: null,
57
+ highlightBackground: null,
58
+ highlightForeground: null,
59
+ }
60
+ }
61
+
62
+ test("terminalMode derives mode from refreshed background", () => {
63
+ expect(terminalMode(terminalColors("#fbf1c7"))).toBe("light")
64
+ expect(terminalMode(terminalColors("#1a1b26"))).toBe("dark")
65
+ })
66
+
67
+ test("terminalMode does not derive mode from ANSI slot zero", () => {
68
+ expect(terminalMode(terminalColors(null, ["#000000"]))).toBeUndefined()
69
+ })
70
+
71
+ test("custom theme precedence follows directory order", async () => {
72
+ await using tmp = await tmpdir()
73
+ const global = path.join(tmp.path, "global")
74
+ const project = path.join(tmp.path, "project")
75
+ await mkdir(path.join(global, "themes"), { recursive: true })
76
+ await mkdir(path.join(project, "themes"), { recursive: true })
77
+ await writeFile(path.join(global, "themes", "custom.json"), JSON.stringify({ source: "global" }))
78
+ await writeFile(path.join(project, "themes", "custom.json"), JSON.stringify({ source: "project" }))
79
+
80
+ await expect(discoverThemes([global, project])).resolves.toEqual({ custom: { source: "project" } })
81
+ })
@@ -0,0 +1,49 @@
1
+ import { describe, expect, test } from "bun:test"
2
+ import { errorData, errorFormat, errorMessage } from "../../src/util/error"
3
+
4
+ describe("util.error", () => {
5
+ test("formats native Error instances", () => {
6
+ const err = new Error("boom")
7
+ expect(errorMessage(err)).toBe("boom")
8
+ expect(errorFormat(err)).toContain("boom")
9
+
10
+ const data = errorData(err)
11
+ expect(data.type).toBe("Error")
12
+ expect(data.message).toBe("boom")
13
+ expect(String(data.formatted)).toContain("boom")
14
+ })
15
+
16
+ test("extracts message from record-like values", () => {
17
+ const err = { message: "bad input", code: "E_BAD" }
18
+ expect(errorMessage(err)).toBe("bad input")
19
+
20
+ const data = errorData(err)
21
+ expect(data.message).toBe("bad input")
22
+ expect(data.code).toBe("E_BAD")
23
+ })
24
+
25
+ test("never returns bare {} for opaque object errors", () => {
26
+ expect(errorFormat({})).not.toBe("{}")
27
+ expect(errorFormat({})).toContain("no message")
28
+
29
+ class OpaqueError {}
30
+ const opaque = new OpaqueError()
31
+ Object.defineProperty(opaque, "secret", { value: "hidden", enumerable: false })
32
+ expect(errorFormat(opaque)).not.toBe("{}")
33
+ expect(errorFormat(opaque)).toContain("OpaqueError")
34
+ })
35
+
36
+ test("handles opaque throwables with custom toString", () => {
37
+ const err = {
38
+ toString() {
39
+ return "ResolveMessage: Cannot resolve module"
40
+ },
41
+ }
42
+
43
+ expect(errorMessage(err)).toBe("ResolveMessage: Cannot resolve module")
44
+
45
+ const data = errorData(err)
46
+ expect(data.message).toBe("ResolveMessage: Cannot resolve module")
47
+ expect(String(data.formatted)).toContain("ResolveMessage")
48
+ })
49
+ })
@@ -0,0 +1,16 @@
1
+ import { describe, expect, test } from "bun:test"
2
+ import { filetype } from "../../src/util/filetype"
3
+
4
+ describe("util.filetype", () => {
5
+ test("maps filenames to presentation languages", () => {
6
+ expect(filetype("component.tsx")).toBe("typescript")
7
+ expect(filetype("script.js")).toBe("typescript")
8
+ expect(filetype("main.py")).toBe("python")
9
+ expect(filetype("README.unknown")).toBeUndefined()
10
+ })
11
+
12
+ test("uses none for missing filenames", () => {
13
+ expect(filetype()).toBe("none")
14
+ expect(filetype("")).toBe("none")
15
+ })
16
+ })
@@ -0,0 +1,59 @@
1
+ import { describe, expect, test } from "bun:test"
2
+ import { formatDuration } from "../../src/util/format"
3
+
4
+ describe("util.format", () => {
5
+ describe("formatDuration", () => {
6
+ test("returns empty string for zero or negative values", () => {
7
+ expect(formatDuration(0)).toBe("")
8
+ expect(formatDuration(-1)).toBe("")
9
+ expect(formatDuration(-100)).toBe("")
10
+ })
11
+
12
+ test("formats seconds under a minute", () => {
13
+ expect(formatDuration(1)).toBe("1s")
14
+ expect(formatDuration(30)).toBe("30s")
15
+ expect(formatDuration(59)).toBe("59s")
16
+ })
17
+
18
+ test("formats minutes under an hour", () => {
19
+ expect(formatDuration(60)).toBe("1m")
20
+ expect(formatDuration(61)).toBe("1m 1s")
21
+ expect(formatDuration(90)).toBe("1m 30s")
22
+ expect(formatDuration(120)).toBe("2m")
23
+ expect(formatDuration(330)).toBe("5m 30s")
24
+ expect(formatDuration(3599)).toBe("59m 59s")
25
+ })
26
+
27
+ test("formats hours under a day", () => {
28
+ expect(formatDuration(3600)).toBe("1h")
29
+ expect(formatDuration(3660)).toBe("1h 1m")
30
+ expect(formatDuration(7200)).toBe("2h")
31
+ expect(formatDuration(8100)).toBe("2h 15m")
32
+ expect(formatDuration(86399)).toBe("23h 59m")
33
+ })
34
+
35
+ test("formats days under a week", () => {
36
+ expect(formatDuration(86400)).toBe("~1 day")
37
+ expect(formatDuration(172800)).toBe("~2 days")
38
+ expect(formatDuration(259200)).toBe("~3 days")
39
+ expect(formatDuration(604799)).toBe("~6 days")
40
+ })
41
+
42
+ test("formats weeks", () => {
43
+ expect(formatDuration(604800)).toBe("~1 week")
44
+ expect(formatDuration(1209600)).toBe("~2 weeks")
45
+ expect(formatDuration(1609200)).toBe("~2 weeks")
46
+ })
47
+
48
+ test("handles boundary values correctly", () => {
49
+ expect(formatDuration(59)).toBe("59s")
50
+ expect(formatDuration(60)).toBe("1m")
51
+ expect(formatDuration(3599)).toBe("59m 59s")
52
+ expect(formatDuration(3600)).toBe("1h")
53
+ expect(formatDuration(86399)).toBe("23h 59m")
54
+ expect(formatDuration(86400)).toBe("~1 day")
55
+ expect(formatDuration(604799)).toBe("~6 days")
56
+ expect(formatDuration(604800)).toBe("~1 week")
57
+ })
58
+ })
59
+ })
@@ -0,0 +1,9 @@
1
+ import { describe, expect, test } from "bun:test"
2
+ import { parse } from "../../src/util/model"
3
+
4
+ describe("util.model", () => {
5
+ test("splits provider from a nested model identifier", () => {
6
+ expect(parse("provider/org/model")).toEqual({ providerID: "provider", modelID: "org/model" })
7
+ expect(parse("invalid")).toEqual({ providerID: "invalid", modelID: "" })
8
+ })
9
+ })
@@ -0,0 +1,8 @@
1
+ import { expect, test } from "bun:test"
2
+ import { sessionEpilogue } from "../../src/util/presentation"
3
+
4
+ test("formats session continuation summary", () => {
5
+ const epilogue = sessionEpilogue({ title: "A session", sessionID: "ses_123" })
6
+ expect(epilogue).toContain("A session")
7
+ expect(epilogue).toContain("neurocode -s ses_123")
8
+ })
@@ -0,0 +1,30 @@
1
+ import { expect, test } from "bun:test"
2
+ import { destroyRenderer } from "../../src/util/renderer"
3
+
4
+ test("clears the terminal title before destroying the renderer", () => {
5
+ const calls: string[] = []
6
+ destroyRenderer({
7
+ isDestroyed: false,
8
+ setTerminalTitle(title) {
9
+ calls.push(`title:${title}`)
10
+ },
11
+ destroy() {
12
+ calls.push("destroy")
13
+ },
14
+ })
15
+ expect(calls).toEqual(["title:", "destroy"])
16
+ })
17
+
18
+ test("still clears the title after renderer destruction", () => {
19
+ const calls: string[] = []
20
+ destroyRenderer({
21
+ isDestroyed: true,
22
+ setTerminalTitle(title) {
23
+ calls.push(`title:${title}`)
24
+ },
25
+ destroy() {
26
+ calls.push("destroy")
27
+ },
28
+ })
29
+ expect(calls).toEqual(["title:"])
30
+ })
@@ -0,0 +1,35 @@
1
+ import { describe, expect, test } from "bun:test"
2
+ import { getRevertDiffFiles } from "../../src/util/revert-diff"
3
+
4
+ describe("revert diff", () => {
5
+ test("prefers the actual file path over /dev/null for added and deleted files", () => {
6
+ const files = getRevertDiffFiles(`diff --git a/new.txt b/new.txt
7
+ new file mode 100644
8
+ index 0000000..3b18e51
9
+ --- /dev/null
10
+ +++ b/new.txt
11
+ @@ -0,0 +1 @@
12
+ +new content
13
+ diff --git a/old.txt b/old.txt
14
+ deleted file mode 100644
15
+ index 3b18e51..0000000
16
+ --- a/old.txt
17
+ +++ /dev/null
18
+ @@ -1 +0,0 @@
19
+ -old content
20
+ `)
21
+
22
+ expect(files).toEqual([
23
+ {
24
+ filename: "new.txt",
25
+ additions: 1,
26
+ deletions: 0,
27
+ },
28
+ {
29
+ filename: "old.txt",
30
+ additions: 0,
31
+ deletions: 1,
32
+ },
33
+ ])
34
+ })
35
+ })
@@ -0,0 +1,10 @@
1
+ import { describe, expect, test } from "bun:test"
2
+ import { isDefaultTitle } from "../../src/util/session"
3
+
4
+ describe("util.session", () => {
5
+ test("recognizes generated parent and child titles", () => {
6
+ expect(isDefaultTitle("New session - 2026-06-06T12:34:56.789Z")).toBeTrue()
7
+ expect(isDefaultTitle("Child session - 2026-06-06T12:34:56.789Z")).toBeTrue()
8
+ expect(isDefaultTitle("New session - custom")).toBeFalse()
9
+ })
10
+ })
@@ -0,0 +1,40 @@
1
+ import { describe, expect, test } from "bun:test"
2
+ import { toolDisplayMetadata, webSearchProviderLabel } from "../../src/util/tool-display"
3
+
4
+ describe("webSearchProviderLabel", () => {
5
+ test("labels known providers", () => {
6
+ expect(webSearchProviderLabel("parallel")).toBe("Parallel Web Search")
7
+ expect(webSearchProviderLabel("exa")).toBe("Exa Web Search")
8
+ })
9
+
10
+ for (const [name, provider] of [
11
+ ["undefined", undefined],
12
+ ["null", null],
13
+ ["an object", {}],
14
+ ["an array", []],
15
+ ["a number", 1],
16
+ ["an unexpected string", "other"],
17
+ ] as const) {
18
+ test(`uses the generic label for ${name}`, () => {
19
+ expect(webSearchProviderLabel(provider)).toBe("Web Search")
20
+ })
21
+ }
22
+ })
23
+
24
+ describe("toolDisplayMetadata", () => {
25
+ test("returns structured metadata for non-pending states", () => {
26
+ const structured = { provider: "parallel", numResults: 3 }
27
+
28
+ expect(toolDisplayMetadata({ status: "running", structured })).toBe(structured)
29
+ expect(toolDisplayMetadata({ status: "completed", structured })).toBe(structured)
30
+ expect(toolDisplayMetadata({ status: "error", structured })).toBe(structured)
31
+ })
32
+
33
+ test("does not expose pending or malformed metadata", () => {
34
+ expect(toolDisplayMetadata({ status: "pending", structured: { provider: "exa" } })).toEqual({})
35
+ expect(toolDisplayMetadata({ status: "completed" })).toEqual({})
36
+ expect(toolDisplayMetadata({ status: "completed", structured: null })).toEqual({})
37
+ expect(toolDisplayMetadata({ status: "completed", structured: [] })).toEqual({})
38
+ expect(toolDisplayMetadata(undefined)).toEqual({})
39
+ })
40
+ })