tui-composer.test.ts 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657
  1. import type { Component } from "../../src/tui/rendering/component.js";
  2. import { stripAnsi, visibleWidth } from "../../src/tui/rendering/text.js";
  3. import { describe, expect, it } from "vitest";
  4. import {
  5. TuiComposer,
  6. resolveTuiComposerBorderColor,
  7. resolveTuiComposerColor,
  8. type TuiComposerState,
  9. } from "../../src/tui/shell/composer.js";
  10. import type { TuiComposerInputIntent } from "../../src/tui/commands/input-intent.js";
  11. import { tuiColors, tuiEditorTheme } from "../../src/tui/theme/runtime.js";
  12. import { Editor } from "../../src/tui/widgets/editor/editor.js";
  13. import { formatTuiShortcut } from "../../src/tui/shell/shortcut-labels.js";
  14. import { buildTuiTips } from "../../src/tui/shell/tips.js";
  15. import {
  16. createDefaultTuiKeybindingRegistry,
  17. createTuiHostKeybindings,
  18. } from "../../src/tui/shell/keybindings.js";
  19. function editor(lines: string[]): Component {
  20. return {
  21. render: () => lines,
  22. invalidate: () => undefined,
  23. };
  24. }
  25. describe("TuiComposer", () => {
  26. const queueShortcut = formatTuiShortcut("alt+enter");
  27. it("uses warning emphasis for a missing side conversation while preserving the draft", () => {
  28. const state: TuiComposerState = {
  29. mode: "message",
  30. surface: "conversation",
  31. hint: "No side conversation is open. Run /btw first; this shortcut only switches conversations.",
  32. hintTone: "warning",
  33. };
  34. const composer = new TuiComposer(editor(["draft"]), state);
  35. expect(resolveTuiComposerColor(state)).toBe(tuiColors.warning);
  36. const rendered = stripAnsi(composer.render(80).join("\n"));
  37. expect(rendered).toContain("No side conversation is open. Run /btw first;");
  38. expect(rendered).toContain("draft");
  39. });
  40. it("turns the editor into a clear primary input with truthful key hints", () => {
  41. const composer = new TuiComposer(editor(["──────", "draft", "──────"]), {
  42. mode: "message",
  43. surface: "conversation",
  44. });
  45. const lines = composer.render(64);
  46. const rendered = lines.join("\n");
  47. expect(rendered).toContain("Message");
  48. expect(rendered).toContain("Enter send");
  49. expect(rendered).toContain("Ctrl+J newline");
  50. expect(rendered).not.toContain("Shift+Enter");
  51. expect(rendered).not.toContain("Shift+Tab");
  52. expect(rendered).toContain("› draft");
  53. expect(lines.filter((line) => line.includes("─"))).toHaveLength(2);
  54. expect(
  55. lines.some((line) => line.includes("Message") && line.includes("─")),
  56. ).toBe(false);
  57. });
  58. it("renders the side-mode placeholder inside an empty editor and a stable context label below it", () => {
  59. const input = new Editor(
  60. { terminal: { rows: 24 }, requestRender: () => undefined },
  61. tuiEditorTheme,
  62. );
  63. const composer = new TuiComposer(input, {
  64. mode: "message",
  65. surface: "conversation",
  66. draftCharacterCount: 0,
  67. placeholder: "Ask a side question…",
  68. contextLabel: "Side from main session · Ctrl+/ to main · Ctrl+C to close",
  69. });
  70. const rendered = composer.render(80).map(stripAnsi).join("\n");
  71. expect(rendered).toContain("Ask a side question…");
  72. expect(rendered).toContain(
  73. "Side from main session · Ctrl+/ to main · Ctrl+C to close",
  74. );
  75. });
  76. it("hides the placeholder as soon as the draft has content", () => {
  77. const input = new Editor(
  78. { terminal: { rows: 24 }, requestRender: () => undefined },
  79. tuiEditorTheme,
  80. );
  81. input.setText("draft");
  82. const composer = new TuiComposer(input, {
  83. mode: "message",
  84. surface: "conversation",
  85. draftCharacterCount: 5,
  86. placeholder: "Ask a side question…",
  87. });
  88. const rendered = composer.render(80).map(stripAnsi).join("\n");
  89. expect(rendered).not.toContain("Ask a side question…");
  90. expect(rendered).toContain("› draft");
  91. });
  92. it.each([
  93. {
  94. input: "Explain this repository",
  95. intent: { kind: "prompt" },
  96. header: "Prompt · Enter send · Ctrl+J newline",
  97. color: tuiColors.signal,
  98. },
  99. {
  100. input: "!pwd",
  101. intent: { kind: "bash" },
  102. header: "Shell · Enter run",
  103. color: tuiColors.warning,
  104. },
  105. {
  106. input: "/context",
  107. intent: { kind: "command", token: "/context" },
  108. header: "Command · Enter run",
  109. color: tuiColors.accent,
  110. },
  111. {
  112. input: "/compact preserve evidence",
  113. intent: { kind: "command-arguments", token: "/compact" },
  114. header: "Command · arguments · Enter run",
  115. color: tuiColors.accent,
  116. },
  117. {
  118. input: "/docs",
  119. intent: { kind: "skill", token: "/docs" },
  120. header: "Skill · Enter invoke",
  121. color: tuiColors.orbit,
  122. },
  123. {
  124. input: "/docs summarize this repository",
  125. intent: { kind: "skill-instructions", token: "/docs" },
  126. header: "Skill · instructions · Enter invoke",
  127. color: tuiColors.orbit,
  128. },
  129. ] satisfies Array<{
  130. input: string;
  131. intent: TuiComposerInputIntent;
  132. header: string;
  133. color: string;
  134. }>)(
  135. "shows $intent.kind intent without changing the submitted text",
  136. ({ input, intent, header, color }) => {
  137. const state: TuiComposerState = {
  138. mode: "message",
  139. surface: "conversation",
  140. draftCharacterCount: input.length,
  141. inputIntent: intent,
  142. };
  143. const composer = new TuiComposer(
  144. editor(["────────", ` ${input} `, "────────"]),
  145. state,
  146. );
  147. const rendered = composer.render(80);
  148. expect(stripAnsi(rendered[0] ?? "").trim()).toBe(header);
  149. expect(stripAnsi(rendered.join("\n"))).toContain(input);
  150. expect(resolveTuiComposerColor(state)).toBe(color);
  151. expect(resolveTuiComposerBorderColor(state)).toBe(color);
  152. },
  153. );
  154. it("keeps empty Composer chrome neutral until the input has a resolved intent", () => {
  155. const state: TuiComposerState = {
  156. mode: "message",
  157. surface: "conversation",
  158. inputIntent: { kind: "empty" },
  159. };
  160. const composer = new TuiComposer(
  161. editor(["────────", " ", "────────"]),
  162. state,
  163. {
  164. showTips: false,
  165. },
  166. );
  167. expect(stripAnsi(composer.render(80)[0] ?? "").trim()).toBe(
  168. "Message · Enter send · Ctrl+J newline",
  169. );
  170. expect(resolveTuiComposerBorderColor(state)).toBe(tuiColors.line);
  171. });
  172. it.each([
  173. [{ kind: "prompt" }, `Prompt · Enter steer · ${queueShortcut} queue`],
  174. [{ kind: "command", token: "/context" }, "Command · Enter run"],
  175. [
  176. { kind: "skill-instructions", token: "/docs" },
  177. `Skill · instructions · Enter steer · ${queueShortcut} queue`,
  178. ],
  179. ] satisfies Array<[TuiComposerInputIntent, string]>)(
  180. "keeps intent-specific Enter guidance accurate while a Turn is active",
  181. (inputIntent, expected) => {
  182. const composer = new TuiComposer(
  183. editor(["────────", " /context ", "────────"]),
  184. {
  185. mode: "follow-up",
  186. surface: "conversation",
  187. inputIntent,
  188. },
  189. );
  190. expect(stripAnsi(composer.render(80).join("\n"))).toContain(expected);
  191. },
  192. );
  193. it("preserves intent borders, prefix, and token hierarchy while the Editor is scrolled", () => {
  194. const composer = new TuiComposer(
  195. editor(["─── ↑ 2 more ─────", " /docs summarize ", "─── ↓ 1 more ─────"]),
  196. {
  197. mode: "message",
  198. surface: "conversation",
  199. inputIntent: { kind: "skill-instructions", token: "/docs" },
  200. },
  201. );
  202. const rendered = composer.render(80).slice(1).map(stripAnsi);
  203. expect(rendered[0]).toMatch(/^ {2}─── ↑ 2 more/u);
  204. expect(rendered[1]).toContain("› /docs summarize");
  205. expect(rendered[2]).toMatch(/^ {2}─── ↓ 1 more/u);
  206. });
  207. it("keeps permission controls out of the idle input header", () => {
  208. const composer = new TuiComposer(editor(["──────", "", "──────"]), {
  209. mode: "message",
  210. surface: "conversation",
  211. });
  212. const header = stripAnsi(composer.render(80)[0] ?? "");
  213. expect(header.trimStart()).toMatch(
  214. /^Message · Enter send · Ctrl\+J newline/u,
  215. );
  216. expect(header).not.toContain("Shift+Tab");
  217. expect(visibleWidth(header)).toBeLessThanOrEqual(80);
  218. });
  219. it("uses spare idle header width for a right-aligned Tip", () => {
  220. const tip = buildTuiTips()[0];
  221. const composer = new TuiComposer(
  222. editor(["──────", "", "──────"]),
  223. {
  224. mode: "message",
  225. surface: "conversation",
  226. draftCharacterCount: 0,
  227. },
  228. { now: () => 0, tips: tip ? [tip] : [] },
  229. );
  230. const header = stripAnsi(composer.render(120)[0] ?? "");
  231. expect(header).toContain("Message · Enter send · Ctrl+J newline");
  232. expect(
  233. header
  234. .trimEnd()
  235. .endsWith("Tip: /goal keeps multi-step work focused on a finish line"),
  236. ).toBe(true);
  237. expect(visibleWidth(header)).toBe(120);
  238. const compactHeader = stripAnsi(composer.render(80)[0] ?? "");
  239. expect(compactHeader).toContain("Tip: /goal tracks multi-step work");
  240. expect(compactHeader).not.toContain("focused on a finish line");
  241. expect(stripAnsi(composer.render(64)[0] ?? "")).not.toContain("Tip:");
  242. });
  243. it("keeps the idle header stable when Tips are disabled", () => {
  244. const tip = buildTuiTips()[0];
  245. const composer = new TuiComposer(
  246. editor(["──────", "", "──────"]),
  247. {
  248. mode: "message",
  249. surface: "conversation",
  250. draftCharacterCount: 0,
  251. contextualTip: {
  252. id: "codex-handoff",
  253. command: "resume-codex",
  254. text: "Tip: Ctrl+U resumes your recent Codex session",
  255. shortText: "Tip: Ctrl+U resumes Codex",
  256. },
  257. },
  258. { showTips: false, now: () => 0, tips: tip ? [tip] : [] },
  259. );
  260. const header = stripAnsi(composer.render(120)[0] ?? "");
  261. expect(header.trim()).toBe("Message · Enter send · Ctrl+J newline");
  262. });
  263. it("rotates a contextual Welcome Tip with ordinary Tips instead of replacing the main hint", () => {
  264. const ordinaryTip = buildTuiTips()[0];
  265. const contextualTip = {
  266. id: "codex-handoff",
  267. command: "resume-codex",
  268. text: "Tip: Ctrl+U resumes your recent Codex session",
  269. shortText: "Tip: Ctrl+U resumes Codex",
  270. };
  271. const composer = new TuiComposer(
  272. editor(["──────", "", "──────"]),
  273. {
  274. mode: "message",
  275. surface: "welcome",
  276. draftCharacterCount: 0,
  277. contextualTip,
  278. },
  279. { now: () => 0, tips: ordinaryTip ? [ordinaryTip] : [] },
  280. );
  281. const firstHeader = stripAnsi(composer.render(120)[0] ?? "");
  282. expect(firstHeader).toContain("Start · @ file · / autocomplete");
  283. expect(firstHeader).toContain(
  284. "Tip: /goal keeps multi-step work focused on a finish line",
  285. );
  286. expect(firstHeader).not.toContain("Ctrl+U resumes");
  287. const nextComposer = new TuiComposer(
  288. editor(["──────", "", "──────"]),
  289. {
  290. mode: "message",
  291. surface: "welcome",
  292. draftCharacterCount: 0,
  293. contextualTip,
  294. },
  295. { now: () => 30_000, tips: ordinaryTip ? [ordinaryTip] : [] },
  296. );
  297. const nextHeader = stripAnsi(nextComposer.render(120)[0] ?? "");
  298. expect(nextHeader).toContain("Start · @ file · / autocomplete");
  299. expect(nextHeader).toContain(
  300. "Tip: Ctrl+U resumes your recent Codex session",
  301. );
  302. });
  303. it.each([
  304. {
  305. name: "Welcome",
  306. state: { mode: "message", surface: "welcome", draftCharacterCount: 0 },
  307. },
  308. {
  309. name: "a non-empty Draft",
  310. state: {
  311. mode: "message",
  312. surface: "conversation",
  313. draftCharacterCount: 1,
  314. },
  315. },
  316. {
  317. name: "an attachment",
  318. state: { mode: "message", surface: "conversation", attachmentCount: 1 },
  319. },
  320. {
  321. name: "Follow-up mode",
  322. state: {
  323. mode: "follow-up",
  324. surface: "conversation",
  325. draftCharacterCount: 0,
  326. },
  327. },
  328. {
  329. name: "a transient hint",
  330. state: {
  331. mode: "message",
  332. surface: "conversation",
  333. draftCharacterCount: 0,
  334. hint: "Press Ctrl+C again to exit",
  335. },
  336. },
  337. ] satisfies Array<{ name: string; state: TuiComposerState }>)(
  338. "yields to $name",
  339. ({ state }) => {
  340. const composer = new TuiComposer(
  341. editor(["──────", "", "──────"]),
  342. state,
  343. { now: () => 0 },
  344. );
  345. expect(stripAnsi(composer.render(120)[0] ?? "")).not.toContain("Tip:");
  346. },
  347. );
  348. it("updates input hints from live bindings while preserving terminal-specific defaults", () => {
  349. const { registry, manager, hostOverrides } = createTuiHostKeybindings({
  350. platform: "linux",
  351. suspendSupported: true,
  352. });
  353. let supportsShiftEnter = false;
  354. const composer = new TuiComposer(
  355. editor(["──────", "", "──────"]),
  356. {
  357. mode: "message",
  358. surface: "conversation",
  359. },
  360. {
  361. supportsShiftEnter: () => supportsShiftEnter,
  362. keybindings: registry,
  363. showTips: false,
  364. },
  365. );
  366. expect(stripAnsi(composer.render(80)[0] ?? "")).toContain("Ctrl+J newline");
  367. supportsShiftEnter = true;
  368. const header = stripAnsi(composer.render(80)[0] ?? "");
  369. expect(header).toContain("Shift+Enter newline");
  370. expect(header).not.toContain("Ctrl+J");
  371. manager.setUserBindings({
  372. ...hostOverrides,
  373. "tui.input.submit": ["ctrl+s", "ctrl+q"],
  374. "tui.input.newLine": ["ctrl+n", "ctrl+j"],
  375. });
  376. for (const enhanced of [false, true]) {
  377. supportsShiftEnter = enhanced;
  378. expect(stripAnsi(composer.render(100)[0] ?? "").trim()).toBe(
  379. "Message · Ctrl+S / Ctrl+Q send · Ctrl+N / Ctrl+J newline",
  380. );
  381. }
  382. manager.setUserBindings({
  383. ...hostOverrides,
  384. "tui.input.submit": [],
  385. "tui.input.newLine": [],
  386. });
  387. expect(stripAnsi(composer.render(80)[0] ?? "").trim()).toBe(
  388. "Message · Unbound send · Unbound newline",
  389. );
  390. manager.setUserBindings(hostOverrides);
  391. expect(stripAnsi(composer.render(80)[0] ?? "").trim()).toBe(
  392. "Message · Enter send · Shift+Enter newline",
  393. );
  394. });
  395. it("uses the idle header for a short actionable hint instead of the status rail", () => {
  396. const composer = new TuiComposer(editor(["──────", "", "──────"]), {
  397. mode: "message",
  398. surface: "conversation",
  399. hint: "Press Ctrl+C again to exit",
  400. });
  401. const rendered = composer.render(64).join("\n");
  402. expect(rendered).toContain("Press Ctrl+C again to exit");
  403. expect(rendered).not.toContain("Message · Enter send");
  404. });
  405. it.each([
  406. [{ mode: "working", surface: "conversation" }, "Working"],
  407. [
  408. { mode: "follow-up", surface: "conversation" },
  409. `Message · Enter steer · ${queueShortcut} queue`,
  410. ],
  411. [
  412. { mode: "blocked", surface: "conversation" },
  413. "Reply required · choose an action",
  414. ],
  415. [
  416. { mode: "message", surface: "welcome" },
  417. "Start · @ file · / autocomplete",
  418. ],
  419. ] satisfies Array<[TuiComposerState, string]>)(
  420. "explains the %s submission mode before the user presses Enter",
  421. (state, expected) => {
  422. const composer = new TuiComposer(editor(["──────", "", "──────"]), state);
  423. expect(composer.render(64).join("\n")).toContain(expected);
  424. },
  425. );
  426. it("keeps the editor and mode label inside a narrow terminal", () => {
  427. const composer = new TuiComposer(
  428. editor([
  429. "──────────────────────",
  430. "a deliberately long draft",
  431. "──────────────────────",
  432. ]),
  433. {
  434. mode: "follow-up",
  435. surface: "conversation",
  436. },
  437. );
  438. expect(composer.render(24).every((line) => visibleWidth(line) <= 24)).toBe(
  439. true,
  440. );
  441. expect(composer.render(24).join("\n")).toContain(`${queueShortcut} queue`);
  442. expect(composer.render(24).join("\n")).not.toContain("Follow-up");
  443. expect(composer.render(24).join("\n")).not.toContain("Shift+Tab");
  444. });
  445. it.each([
  446. [80, `Message · Enter steer · ${queueShortcut} queue`],
  447. [40, `Enter steer · ${queueShortcut} queue`],
  448. [28, `${queueShortcut} queue`],
  449. [18, process.platform === "darwin" ? "Message" : `${queueShortcut} queue`],
  450. [16, "Message"],
  451. ] as const)(
  452. "keeps the most useful follow-up actions at %s columns",
  453. (width, expected) => {
  454. const composer = new TuiComposer(editor(["──────", "", "──────"]), {
  455. mode: "follow-up",
  456. surface: "conversation",
  457. });
  458. const rendered = composer.render(width).join("\n");
  459. expect(rendered).toContain(expected);
  460. expect(
  461. rendered.split("\n").every((line) => visibleWidth(line) <= width),
  462. ).toBe(true);
  463. },
  464. );
  465. it("retains configured queue hints for narrow prompts and skills without relabeling commands", () => {
  466. const keybindings = createDefaultTuiKeybindingRegistry().withOverrides({
  467. "run.queue-draft": "ctrl+q",
  468. });
  469. for (const inputIntent of [
  470. { kind: "prompt" },
  471. { kind: "skill", token: "/docs" },
  472. ] satisfies TuiComposerInputIntent[]) {
  473. const composer = new TuiComposer(
  474. editor(["────", "draft", "────"]),
  475. {
  476. mode: "follow-up",
  477. surface: "conversation",
  478. inputIntent,
  479. attachmentCount: 2,
  480. },
  481. { keybindings },
  482. );
  483. expect(stripAnsi(composer.render(24).join("\n"))).toContain(
  484. "Ctrl+Q queue",
  485. );
  486. }
  487. const command = new TuiComposer(
  488. editor(["────", "/context", "────"]),
  489. {
  490. mode: "follow-up",
  491. surface: "conversation",
  492. inputIntent: { kind: "command", token: "/context" },
  493. },
  494. { keybindings },
  495. );
  496. expect(stripAnsi(command.render(24).join("\n"))).toContain("Enter run");
  497. expect(stripAnsi(command.render(24).join("\n"))).not.toContain("queue");
  498. });
  499. it("explains Enter steering and Tab queueing without duplicating interrupt controls", () => {
  500. const composer = new TuiComposer(editor(["──────", "", "──────"]), {
  501. mode: "follow-up",
  502. surface: "conversation",
  503. });
  504. const rendered = composer.render(80).join("\n");
  505. expect(rendered).not.toContain("interrupt");
  506. expect(rendered).toContain("Enter steer");
  507. expect(rendered).toContain(`${queueShortcut} queue`);
  508. });
  509. it("explains steering and queueing when a running Draft has attachments", () => {
  510. const composer = new TuiComposer(editor(["──────", "", "──────"]), {
  511. mode: "follow-up",
  512. surface: "conversation",
  513. attachmentCount: 1,
  514. });
  515. const rendered = composer.render(80).join("\n");
  516. expect(rendered).toContain(
  517. `1 attachment · Enter steer · ${queueShortcut} queue`,
  518. );
  519. });
  520. it("keeps only the attachment count in the header because images live inline in the editor", () => {
  521. const composer = new TuiComposer(editor(["──────", "", "──────"]), {
  522. mode: "message",
  523. surface: "conversation",
  524. attachmentCount: 2,
  525. });
  526. const rendered = composer.render(64).join("\n");
  527. expect(rendered).toContain("2 attachments · Enter send");
  528. expect(rendered).not.toContain("image-123.png");
  529. expect(rendered).not.toContain("Delete remove");
  530. expect(rendered).toContain("› ");
  531. expect(
  532. rendered
  533. .split("\n")
  534. .some((line) => line.includes("2 attachments") && line.includes("─")),
  535. ).toBe(false);
  536. });
  537. it("keeps the inline-attachment header inside a narrow terminal", () => {
  538. const composer = new TuiComposer(editor(["──────", "", "──────"]), {
  539. mode: "message",
  540. surface: "conversation",
  541. attachmentCount: 5,
  542. });
  543. const rendered = composer.render(32);
  544. expect(rendered.every((line) => visibleWidth(line) <= 32)).toBe(true);
  545. expect(rendered.join("\n")).toContain("5 attachments");
  546. });
  547. it("renders the external-editor hint from the active host keybinding registry", () => {
  548. const keybindings = createDefaultTuiKeybindingRegistry().withOverrides({
  549. "composer.external-editor": "ctrl+y",
  550. });
  551. const composer = new TuiComposer(
  552. editor(["──────", "draft", "──────"]),
  553. {
  554. mode: "message",
  555. surface: "conversation",
  556. draftCharacterCount: 1_001,
  557. },
  558. { keybindings },
  559. );
  560. expect(stripAnsi(composer.render(80)[0] ?? "")).toContain("Ctrl+Y edit");
  561. });
  562. it("uses blue for Ask User and follow-ups, reserving gold for permission confirmation", () => {
  563. expect(
  564. resolveTuiComposerColor({
  565. mode: "blocked",
  566. surface: "conversation",
  567. attention: "question",
  568. }),
  569. ).toBe(tuiColors.signal);
  570. expect(
  571. resolveTuiComposerColor({
  572. mode: "follow-up",
  573. surface: "conversation",
  574. }),
  575. ).toBe(tuiColors.signal);
  576. expect(
  577. resolveTuiComposerColor({
  578. mode: "blocked",
  579. surface: "conversation",
  580. attention: "permission",
  581. }),
  582. ).toBe(tuiColors.warning);
  583. });
  584. it("uses the danger color for a stopping-response hint", () => {
  585. expect(
  586. resolveTuiComposerColor({
  587. mode: "follow-up",
  588. surface: "conversation",
  589. hint: "Stopping · draft preserved",
  590. hintTone: "danger",
  591. }),
  592. ).toBe(tuiColors.error);
  593. });
  594. });