footer.view.test.tsx 40 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375
  1. /** @jsxImportSource @opentui/solid */
  2. import { expect, test } from "bun:test"
  3. import { BoxRenderable, RGBA, type RootRenderable } from "@opentui/core"
  4. import { testRender, useRenderer } from "@opentui/solid"
  5. import { createSignal } from "solid-js"
  6. import { createDefaultOpenTuiKeymap } from "@opentui/keymap/opentui"
  7. import type { QuestionRequest } from "@kirincode-ai/sdk/v2"
  8. import { OpencodeKeymapProvider, registerOpencodeKeymap } from "@kirincode-ai/tui/keymap"
  9. import {
  10. RUN_COMMAND_PANEL_ROWS,
  11. RUN_SUBAGENT_PANEL_ROWS,
  12. RunCommandMenuBody,
  13. RunModelSelectBody,
  14. RunQueuedPromptSelectBody,
  15. RunSkillSelectBody,
  16. RunSubagentSelectBody,
  17. RunVariantSelectBody,
  18. } from "@/cli/cmd/run/footer.command"
  19. import { RunFooterView } from "@/cli/cmd/run/footer.view"
  20. import { RunEntryContent } from "@/cli/cmd/run/scrollback.writer"
  21. import { RUN_THEME_FALLBACK, type RunTheme } from "@/cli/cmd/run/theme"
  22. import type {
  23. FooterState,
  24. FooterSubagentState,
  25. FooterSubagentTab,
  26. FooterView,
  27. RunCommand,
  28. RunInput,
  29. RunPrompt,
  30. RunProvider,
  31. RunTuiConfig,
  32. StreamCommit,
  33. } from "@/cli/cmd/run/types"
  34. import { RunQuestionBody } from "@/cli/cmd/run/footer.question"
  35. import { RejectField } from "@/cli/cmd/run/footer.permission"
  36. import { createTuiResolvedConfig } from "../../fixture/tui-runtime"
  37. const tuiConfig = createTuiResolvedConfig()
  38. function command(input: { name: string; description: string; source?: "command" | "mcp" | "skill" }) {
  39. return {
  40. name: input.name,
  41. description: input.description,
  42. source: input.source,
  43. template: "",
  44. hints: [],
  45. } satisfies RunCommand
  46. }
  47. function model(input: {
  48. id: string
  49. name: string
  50. status?: "active" | "deprecated"
  51. cost?: number
  52. variants?: Record<string, Record<string, never>>
  53. }) {
  54. return {
  55. id: input.id,
  56. providerID: "kirincode",
  57. api: {
  58. id: "kirincode",
  59. url: "https://kirincode.ai",
  60. npm: "@ai-sdk/openai-compatible",
  61. },
  62. name: input.name,
  63. capabilities: {
  64. temperature: true,
  65. reasoning: true,
  66. attachment: true,
  67. toolcall: true,
  68. input: {
  69. text: true,
  70. audio: false,
  71. image: true,
  72. video: false,
  73. pdf: true,
  74. },
  75. output: {
  76. text: true,
  77. audio: false,
  78. image: false,
  79. video: false,
  80. pdf: false,
  81. },
  82. interleaved: false,
  83. },
  84. cost: {
  85. input: input.cost ?? 1,
  86. output: 1,
  87. cache: {
  88. read: 0,
  89. write: 0,
  90. },
  91. },
  92. limit: {
  93. context: 128000,
  94. output: 8192,
  95. },
  96. status: input.status ?? "active",
  97. options: {},
  98. headers: {},
  99. release_date: "2026-01-01",
  100. variants: input.variants,
  101. } satisfies RunProvider["models"][string]
  102. }
  103. function provider() {
  104. return {
  105. id: "kirincode",
  106. name: "kirincode",
  107. source: "api",
  108. env: [],
  109. options: {},
  110. models: {
  111. "gpt-5": model({ id: "gpt-5", name: "GPT-5", variants: { high: {}, minimal: {} } }),
  112. "gpt-free": model({ id: "gpt-free", name: "GPT Free", cost: 0 }),
  113. old: model({ id: "old", name: "Old Model", status: "deprecated" }),
  114. },
  115. } satisfies RunProvider
  116. }
  117. function subagent(input: {
  118. sessionID: string
  119. label: string
  120. description: string
  121. status?: FooterSubagentTab["status"]
  122. }) {
  123. return {
  124. sessionID: input.sessionID,
  125. partID: `part-${input.sessionID}`,
  126. callID: `call-${input.sessionID}`,
  127. label: input.label,
  128. description: input.description,
  129. status: input.status ?? "running",
  130. lastUpdatedAt: 1,
  131. } satisfies FooterSubagentTab
  132. }
  133. function footerState(input: Partial<FooterState> = {}) {
  134. return createSignal<FooterState>({
  135. phase: "idle",
  136. status: "",
  137. queue: 0,
  138. model: "gpt-5",
  139. duration: "",
  140. usage: "",
  141. first: false,
  142. interrupt: 0,
  143. exit: 0,
  144. ...input,
  145. })[0]
  146. }
  147. async function renderFooter(
  148. input: {
  149. tuiConfig?: RunTuiConfig
  150. commands?: RunCommand[]
  151. theme?: () => RunTheme
  152. providers?: RunProvider[]
  153. currentModel?: RunInput["model"]
  154. currentVariant?: string
  155. subagents?: FooterSubagentState
  156. backgroundSubagents?: boolean
  157. width?: number
  158. height?: number
  159. state?: Partial<FooterState>
  160. onCycle?: () => void
  161. onSubmit?: (prompt: RunPrompt) => boolean
  162. } = {},
  163. ) {
  164. const [view] = createSignal<FooterView>({ type: "prompt" })
  165. const [subagents] = createSignal<FooterSubagentState>(
  166. input.subagents ?? { tabs: [], details: {}, permissions: [], questions: [] },
  167. )
  168. const state = footerState(input.state)
  169. const config = input.tuiConfig ?? tuiConfig
  170. let offKeymap: (() => void) | undefined
  171. function Harness() {
  172. const renderer = useRenderer()
  173. const keymap = createDefaultOpenTuiKeymap(renderer)
  174. offKeymap = registerOpencodeKeymap(keymap, renderer, config)
  175. return (
  176. <OpencodeKeymapProvider keymap={keymap}>
  177. <RunFooterView
  178. directory="/tmp"
  179. findFiles={async () => []}
  180. agents={() => []}
  181. resources={() => []}
  182. commands={() => input.commands ?? []}
  183. providers={() => input.providers}
  184. currentModel={() => input.currentModel}
  185. variants={() => []}
  186. currentVariant={() => input.currentVariant}
  187. state={state}
  188. view={view}
  189. subagent={subagents}
  190. theme={input.theme ?? (() => RUN_THEME_FALLBACK)}
  191. tuiConfig={config}
  192. backgroundSubagents={input.backgroundSubagents ?? true}
  193. agent="kirincode"
  194. onSubmit={input.onSubmit ?? (() => true)}
  195. onPermissionReply={() => {}}
  196. onQuestionReply={() => {}}
  197. onQuestionReject={() => {}}
  198. onCycle={input.onCycle ?? (() => {})}
  199. onInterrupt={() => false}
  200. onEditorOpen={async () => undefined}
  201. onInputClear={() => {}}
  202. onExit={() => {}}
  203. onModelSelect={() => {}}
  204. onVariantSelect={() => {}}
  205. onRows={() => {}}
  206. onLayout={() => {}}
  207. onStatus={() => {}}
  208. onQueuedRemove={async () => true}
  209. />
  210. </OpencodeKeymapProvider>
  211. )
  212. }
  213. const app = await testRender(
  214. () => (
  215. <box width={input.width ?? 100} height={input.height ?? 8}>
  216. <Harness />
  217. </box>
  218. ),
  219. { width: input.width ?? 100, height: input.height ?? 8, kittyKeyboard: true },
  220. )
  221. return {
  222. ...app,
  223. cleanup() {
  224. app.renderer.currentFocusedRenderable?.blur()
  225. app.renderer.currentFocusedEditor?.blur()
  226. offKeymap?.()
  227. offKeymap = undefined
  228. app.renderer.destroy()
  229. },
  230. }
  231. }
  232. function expectPaletteList(list: BoxRenderable, selectedIndex: number) {
  233. expect(list.backgroundColor.toInts()).toEqual((RUN_THEME_FALLBACK.footer.shade as RGBA).toInts())
  234. expect((list.getChildren()[selectedIndex] as BoxRenderable).backgroundColor.toInts()).toEqual(
  235. (RUN_THEME_FALLBACK.footer.selected as RGBA).toInts(),
  236. )
  237. }
  238. function child(root: BoxRenderable | RootRenderable, index: number) {
  239. return root.getChildren()[index] as BoxRenderable
  240. }
  241. function boxPath(root: BoxRenderable | RootRenderable, name: string): BoxRenderable[] | undefined {
  242. for (const item of root.getChildren()) {
  243. if (item.constructor.name === name) return root instanceof BoxRenderable ? [root] : []
  244. if (!(item instanceof BoxRenderable)) continue
  245. const path = boxPath(item, name)
  246. if (path) return root instanceof BoxRenderable ? [root, ...path] : path
  247. }
  248. }
  249. function footerComposerFrame(root: BoxRenderable | RootRenderable) {
  250. return boxPath(root, "TextareaRenderable")!.at(-5)!
  251. }
  252. function footerStatusline(root: BoxRenderable | RootRenderable) {
  253. const status = (RUN_THEME_FALLBACK.footer.status as RGBA).toInts()
  254. const accent = (RUN_THEME_FALLBACK.footer.statusAccent as RGBA).toInts()
  255. const boxes = root.getChildren().filter((item): item is BoxRenderable => item instanceof BoxRenderable)
  256. for (const box of boxes) {
  257. const first = box.getChildren().find((item): item is BoxRenderable => item instanceof BoxRenderable)
  258. if (
  259. box.backgroundColor?.toInts().every((value, index) => value === status[index]) &&
  260. first?.backgroundColor?.toInts().every((value, index) => value === accent[index])
  261. )
  262. return box
  263. boxes.push(...box.getChildren().filter((item): item is BoxRenderable => item instanceof BoxRenderable))
  264. }
  265. throw new Error("Footer statusline not found")
  266. }
  267. function panelMenu(root: BoxRenderable | RootRenderable) {
  268. const panel = child(child(root, 0), 0)
  269. const content = child(panel, 0)
  270. return child(content.getChildren().at(-1) as BoxRenderable, 0)
  271. }
  272. test("direct footer composer area does not adopt footer surface", async () => {
  273. const surface = RGBA.fromHex("#123456")
  274. const [theme, setTheme] = createSignal(RUN_THEME_FALLBACK)
  275. const app = await renderFooter({ theme })
  276. try {
  277. await app.renderOnce()
  278. const area = child(footerComposerFrame(app.renderer.root), 0)
  279. expect(area.backgroundColor.toInts()).not.toEqual(surface.toInts())
  280. setTheme({
  281. ...RUN_THEME_FALLBACK,
  282. footer: {
  283. ...RUN_THEME_FALLBACK.footer,
  284. surface,
  285. },
  286. })
  287. await app.renderOnce()
  288. expect(area.backgroundColor.toInts()).not.toEqual(surface.toInts())
  289. } finally {
  290. app.cleanup()
  291. }
  292. })
  293. test("run entry content updates when live commit text changes", async () => {
  294. const [commit, setCommit] = createSignal<StreamCommit>({
  295. kind: "tool",
  296. text: "I",
  297. phase: "progress",
  298. source: "tool",
  299. messageID: "msg-1",
  300. partID: "part-1",
  301. tool: "bash",
  302. })
  303. const app = await testRender(
  304. () => (
  305. <box width={80} height={4}>
  306. <RunEntryContent commit={commit()} theme={RUN_THEME_FALLBACK} width={80} />
  307. </box>
  308. ),
  309. {
  310. width: 80,
  311. height: 4,
  312. },
  313. )
  314. try {
  315. await app.renderOnce()
  316. expect(app.captureCharFrame()).toContain("I")
  317. setCommit({
  318. kind: "tool",
  319. text: "I need to inspect the codebase",
  320. phase: "progress",
  321. source: "tool",
  322. messageID: "msg-1",
  323. partID: "part-1",
  324. tool: "bash",
  325. })
  326. await app.renderOnce()
  327. expect(app.captureCharFrame()).toContain("I need to inspect the codebase")
  328. } finally {
  329. app.renderer.destroy()
  330. }
  331. })
  332. test("direct command panel renders grouped command palette", async () => {
  333. const [commands] = createSignal<RunCommand[] | undefined>([
  334. command({ name: "review", description: "Review code" }),
  335. command({ name: "deploy", description: "Deploy prompt", source: "mcp" }),
  336. command({ name: "internal", description: "Skill command", source: "skill" }),
  337. ])
  338. const [subagents] = createSignal([])
  339. const [variants] = createSignal(["high", "minimal"])
  340. const app = await testRender(
  341. () => (
  342. <box width={100} height={RUN_COMMAND_PANEL_ROWS}>
  343. <RunCommandMenuBody
  344. theme={() => RUN_THEME_FALLBACK.footer}
  345. commands={commands}
  346. subagents={subagents}
  347. queued={() => []}
  348. variants={variants}
  349. variantCycle="ctrl+t"
  350. onClose={() => {}}
  351. onModel={() => {}}
  352. onEditor={() => {}}
  353. onSkill={() => {}}
  354. onSubagent={() => {}}
  355. onQueued={() => {}}
  356. onVariant={() => {}}
  357. onVariantCycle={() => {}}
  358. onCommand={() => {}}
  359. onNew={() => {}}
  360. onExit={() => {}}
  361. />
  362. </box>
  363. ),
  364. {
  365. width: 100,
  366. height: RUN_COMMAND_PANEL_ROWS,
  367. },
  368. )
  369. try {
  370. await app.renderOnce()
  371. const frame = app.captureCharFrame()
  372. expect(frame).toContain("Commands")
  373. expect(frame).toContain("Search")
  374. expect(frame).toContain("Session")
  375. expect(frame).toContain("Agent")
  376. expect(frame).toContain("Prompt")
  377. expect(frame).toContain("Open editor")
  378. expect(frame).toContain("/editor")
  379. expect(frame).toContain("Switch model")
  380. expect(frame).toContain("Skills")
  381. expect(frame).toContain("/skills")
  382. expect(frame.match(/\bAgent\b/g)?.length).toBe(1)
  383. expect(frame).not.toContain("┌")
  384. expect(frame).not.toContain("┃")
  385. expect(frame).not.toContain("/internal")
  386. expect(frame).not.toContain("Choose model for future turns")
  387. expect(frame).not.toContain("Cycle reasoning effort for future turns")
  388. expect(frame).not.toContain("Review code")
  389. expect(frame).not.toContain("Commands 8")
  390. } finally {
  391. app.renderer.destroy()
  392. }
  393. })
  394. test("direct skill panel renders searchable skill list", async () => {
  395. const [commands] = createSignal<RunCommand[] | undefined>([
  396. command({ name: "review", description: "Review code" }),
  397. command({ name: "internal", description: "Skill command", source: "skill" }),
  398. command({ name: "formatter", description: "Apply formatter fixes", source: "skill" }),
  399. ])
  400. const app = await testRender(
  401. () => (
  402. <box width={100} height={RUN_COMMAND_PANEL_ROWS}>
  403. <RunSkillSelectBody
  404. theme={() => RUN_THEME_FALLBACK.footer}
  405. commands={commands}
  406. onClose={() => {}}
  407. onSelect={() => {}}
  408. />
  409. </box>
  410. ),
  411. {
  412. width: 100,
  413. height: RUN_COMMAND_PANEL_ROWS,
  414. },
  415. )
  416. try {
  417. await app.renderOnce()
  418. const frame = app.captureCharFrame()
  419. expect(frame).toContain("Skills")
  420. expect(frame).toContain("Search")
  421. expect(frame).toContain("internal")
  422. expect(frame).not.toContain("/internal")
  423. expect(frame).toContain("formatter")
  424. expect(frame).toContain("Apply formatter fixes")
  425. expect(frame).not.toContain("review")
  426. } finally {
  427. app.renderer.destroy()
  428. }
  429. })
  430. test("direct skill panel truncates long descriptions from the end", async () => {
  431. const [commands] = createSignal<RunCommand[] | undefined>([
  432. command({
  433. name: "terminal-control",
  434. description:
  435. "Control and test terminal applications, REPLs, interactive CLIs, shell processes, OpenTUI applications, or other terminal-backed workflows.",
  436. source: "skill",
  437. }),
  438. ])
  439. const app = await testRender(
  440. () => (
  441. <box width={100} height={RUN_COMMAND_PANEL_ROWS}>
  442. <RunSkillSelectBody
  443. theme={() => RUN_THEME_FALLBACK.footer}
  444. commands={commands}
  445. onClose={() => {}}
  446. onSelect={() => {}}
  447. />
  448. </box>
  449. ),
  450. {
  451. width: 100,
  452. height: RUN_COMMAND_PANEL_ROWS,
  453. },
  454. )
  455. try {
  456. await app.renderOnce()
  457. const frame = app.captureCharFrame()
  458. expect(frame).toContain("terminal-control")
  459. expect(frame).toContain("Control and test terminal applications")
  460. expect(frame).not.toMatch(/application(?:…|\.\.\.)ocess/)
  461. } finally {
  462. app.renderer.destroy()
  463. }
  464. })
  465. test("direct command panel shows subagent entry when available", async () => {
  466. const [commands] = createSignal<RunCommand[] | undefined>([])
  467. const [subagents] = createSignal([subagent({ sessionID: "s-1", label: "Explore", description: "Inspect auth flow" })])
  468. const [variants] = createSignal<string[]>([])
  469. const app = await testRender(
  470. () => (
  471. <box width={100} height={RUN_COMMAND_PANEL_ROWS}>
  472. <RunCommandMenuBody
  473. theme={() => RUN_THEME_FALLBACK.footer}
  474. commands={commands}
  475. subagents={subagents}
  476. queued={() => []}
  477. variants={variants}
  478. variantCycle="ctrl+t"
  479. onClose={() => {}}
  480. onModel={() => {}}
  481. onEditor={() => {}}
  482. onSkill={() => {}}
  483. onSubagent={() => {}}
  484. onQueued={() => {}}
  485. onVariant={() => {}}
  486. onVariantCycle={() => {}}
  487. onCommand={() => {}}
  488. onNew={() => {}}
  489. onExit={() => {}}
  490. />
  491. </box>
  492. ),
  493. {
  494. width: 100,
  495. height: RUN_COMMAND_PANEL_ROWS,
  496. },
  497. )
  498. try {
  499. await app.renderOnce()
  500. const frame = app.captureCharFrame()
  501. expect(frame).toContain("View subagents")
  502. expect(frame).toContain("1 active")
  503. } finally {
  504. app.renderer.destroy()
  505. }
  506. })
  507. test("direct command panel keeps completed subagents available", async () => {
  508. const [commands] = createSignal<RunCommand[] | undefined>([])
  509. const [subagents] = createSignal([
  510. subagent({ sessionID: "s-1", label: "Explore", description: "Inspect auth flow", status: "completed" }),
  511. ])
  512. const [variants] = createSignal<string[]>([])
  513. const app = await testRender(
  514. () => (
  515. <box width={100} height={RUN_COMMAND_PANEL_ROWS}>
  516. <RunCommandMenuBody
  517. theme={() => RUN_THEME_FALLBACK.footer}
  518. commands={commands}
  519. subagents={subagents}
  520. queued={() => []}
  521. variants={variants}
  522. variantCycle="ctrl+t"
  523. onClose={() => {}}
  524. onModel={() => {}}
  525. onEditor={() => {}}
  526. onSkill={() => {}}
  527. onSubagent={() => {}}
  528. onQueued={() => {}}
  529. onVariant={() => {}}
  530. onVariantCycle={() => {}}
  531. onCommand={() => {}}
  532. onNew={() => {}}
  533. onExit={() => {}}
  534. />
  535. </box>
  536. ),
  537. {
  538. width: 100,
  539. height: RUN_COMMAND_PANEL_ROWS,
  540. },
  541. )
  542. try {
  543. await app.renderOnce()
  544. const frame = app.captureCharFrame()
  545. expect(frame).toContain("View subagents")
  546. expect(frame).toContain("1 recent")
  547. } finally {
  548. app.renderer.destroy()
  549. }
  550. })
  551. test("direct subagent panel renders active subagents", async () => {
  552. const [tabs] = createSignal([
  553. subagent({ sessionID: "s-1", label: "Explore", description: "Inspect auth flow" }),
  554. subagent({ sessionID: "s-2", label: "General", description: "Write migration plan", status: "completed" }),
  555. ])
  556. const [current] = createSignal<string | undefined>("s-1")
  557. let rows = 0
  558. const app = await testRender(
  559. () => (
  560. <box width={100} height={RUN_SUBAGENT_PANEL_ROWS}>
  561. <RunSubagentSelectBody
  562. theme={() => RUN_THEME_FALLBACK.footer}
  563. tabs={tabs}
  564. current={current}
  565. onClose={() => {}}
  566. onSelect={() => {}}
  567. onRows={(value) => {
  568. rows = value
  569. }}
  570. />
  571. </box>
  572. ),
  573. {
  574. width: 100,
  575. height: RUN_SUBAGENT_PANEL_ROWS,
  576. },
  577. )
  578. try {
  579. await app.renderOnce()
  580. const frame = app.captureCharFrame()
  581. const list = panelMenu(app.renderer.root)
  582. expect(frame).toContain("Select subagent")
  583. expect(frame).toContain("Inspect auth flow")
  584. expect(frame).toContain("Write migration plan")
  585. expect(frame).toContain("done")
  586. expect(frame).not.toContain("┌")
  587. expect(frame).not.toContain("┃")
  588. expectPaletteList(list, 0)
  589. expect(rows).toBe(8)
  590. } finally {
  591. app.renderer.destroy()
  592. }
  593. })
  594. test("direct queued prompt panel renders pending prompt actions", async () => {
  595. const [prompts] = createSignal([
  596. { messageID: "m-1", partID: "p-1", prompt: { text: "fix the auth test", parts: [] } },
  597. ])
  598. const app = await testRender(
  599. () => (
  600. <box width={100} height={RUN_SUBAGENT_PANEL_ROWS}>
  601. <RunQueuedPromptSelectBody
  602. theme={() => RUN_THEME_FALLBACK.footer}
  603. prompts={prompts}
  604. onClose={() => {}}
  605. onEdit={() => {}}
  606. onDelete={() => {}}
  607. />
  608. </box>
  609. ),
  610. { width: 100, height: RUN_SUBAGENT_PANEL_ROWS },
  611. )
  612. try {
  613. await app.renderOnce()
  614. const frame = app.captureCharFrame()
  615. const list = panelMenu(app.renderer.root)
  616. expect(frame).toContain("Queued prompts")
  617. expect(frame).toContain("fix the auth test")
  618. expect(frame).toContain("queued")
  619. expect(frame).not.toContain("┌")
  620. expect(frame).not.toContain("┃")
  621. expectPaletteList(list, 0)
  622. } finally {
  623. app.renderer.destroy()
  624. }
  625. })
  626. // OpenTUI currently crashes Bun in the full `test/cli/run` directory run here.
  627. // Re-enable after the upstream OpenTUI fix lands in this repo.
  628. test.skip("direct footer recreates the frame across command panel transitions", async () => {
  629. const app = await renderFooter()
  630. try {
  631. await app.renderOnce()
  632. for (let index = 0; index < 3; index++) {
  633. const composerFrame = footerComposerFrame(app.renderer.root)
  634. app.mockInput.pressKey("p", { ctrl: true })
  635. await app.renderOnce()
  636. expect(app.captureCharFrame()).toContain("Commands")
  637. expect(footerComposerFrame(app.renderer.root)).not.toBe(composerFrame)
  638. app.mockInput.pressKey("c", { ctrl: true })
  639. await app.renderOnce()
  640. expect(app.captureCharFrame()).not.toContain("Commands")
  641. expect(app.captureCharFrame()).not.toContain("┃")
  642. expect(app.captureCharFrame()).not.toContain("█")
  643. }
  644. } finally {
  645. app.cleanup()
  646. }
  647. })
  648. test.skip("direct footer dispatches leader variant binding only when leader is registered", async () => {
  649. const calls: string[] = []
  650. const app = await renderFooter({
  651. tuiConfig: createTuiResolvedConfig({ keybinds: { leader: "ctrl+x", variant_cycle: "<leader>t" } }),
  652. onCycle: () => calls.push("cycle"),
  653. })
  654. try {
  655. await app.renderOnce()
  656. app.mockInput.pressKey("t")
  657. expect(calls).toEqual([])
  658. app.mockInput.pressKey("x", { ctrl: true })
  659. app.mockInput.pressKey("t")
  660. expect(calls).toEqual(["cycle"])
  661. } finally {
  662. app.cleanup()
  663. }
  664. })
  665. test("direct footer keeps leader variant binding inactive when leader is disabled", async () => {
  666. const calls: string[] = []
  667. const app = await renderFooter({
  668. tuiConfig: createTuiResolvedConfig({ keybinds: { leader: "none", variant_cycle: "<leader>t" } }),
  669. onCycle: () => calls.push("cycle"),
  670. })
  671. try {
  672. await app.renderOnce()
  673. app.mockInput.pressKey("t")
  674. app.mockInput.pressKey("x", { ctrl: true })
  675. app.mockInput.pressKey("t")
  676. expect(calls).toEqual([])
  677. } finally {
  678. app.cleanup()
  679. }
  680. })
  681. test("direct footer submits slash autocomplete selections without dispatching shell completions", async () => {
  682. const submits: RunPrompt[] = []
  683. const app = await renderFooter({
  684. commands: [command({ name: "review", description: "Review code" })],
  685. onSubmit(prompt) {
  686. submits.push(prompt)
  687. return true
  688. },
  689. })
  690. try {
  691. await app.renderOnce()
  692. "/rev".split("").forEach((key) => app.mockInput.pressKey(key))
  693. await app.renderOnce()
  694. app.mockInput.pressEnter()
  695. await app.renderOnce()
  696. "/rev".split("").forEach((key) => app.mockInput.pressKey(key))
  697. await app.renderOnce()
  698. app.mockInput.pressKey("TAB")
  699. await app.renderOnce()
  700. "/re branch".split("").forEach((key) => app.mockInput.pressKey(key))
  701. Array.from({ length: 7 }).forEach(() => app.mockInput.pressKey("ARROW_LEFT"))
  702. app.mockInput.pressKey("v")
  703. await app.renderOnce()
  704. app.mockInput.pressEnter()
  705. await app.renderOnce()
  706. "/nx".split("").forEach((key) => app.mockInput.pressKey(key))
  707. app.mockInput.pressKey("ARROW_LEFT")
  708. app.mockInput.pressKey("e")
  709. await app.renderOnce()
  710. app.mockInput.pressEnter()
  711. await app.renderOnce()
  712. "/n scratch".split("").forEach((key) => app.mockInput.pressKey(key))
  713. Array.from({ length: 8 }).forEach(() => app.mockInput.pressKey("ARROW_LEFT"))
  714. app.mockInput.pressKey("e")
  715. await app.renderOnce()
  716. app.mockInput.pressEnter()
  717. await app.renderOnce()
  718. app.mockInput.pressKey("!")
  719. "/rev".split("").forEach((key) => app.mockInput.pressKey(key))
  720. await app.renderOnce()
  721. app.mockInput.pressEnter()
  722. await app.renderOnce()
  723. expect(submits).toEqual([
  724. { text: "/review ", parts: [], command: { name: "review", arguments: "" } },
  725. { text: "/review ", parts: [], command: { name: "review", arguments: "" } },
  726. { text: "/review branch", parts: [], command: { name: "review", arguments: "branch" } },
  727. { text: "/new ", parts: [] },
  728. { text: "/new ", parts: [] },
  729. ])
  730. expect(app.captureCharFrame()).toContain("/review")
  731. } finally {
  732. app.cleanup()
  733. }
  734. })
  735. test("direct footer slash autocomplete keeps a real skills command", async () => {
  736. const submits: RunPrompt[] = []
  737. const app = await renderFooter({
  738. commands: [
  739. command({ name: "skills", description: "Run the real skills command" }),
  740. command({ name: "formatter", description: "Apply formatter fixes", source: "skill" }),
  741. ],
  742. onSubmit(prompt) {
  743. submits.push(prompt)
  744. return true
  745. },
  746. })
  747. try {
  748. await app.renderOnce()
  749. "/skills".split("").forEach((key) => app.mockInput.pressKey(key))
  750. await app.renderOnce()
  751. app.mockInput.pressEnter()
  752. await app.renderOnce()
  753. expect(submits).toEqual([{ text: "/skills ", parts: [], command: { name: "skills", arguments: "" } }])
  754. expect(app.captureCharFrame()).not.toContain("Apply formatter fixes")
  755. } finally {
  756. app.cleanup()
  757. }
  758. })
  759. // OpenTUI currently segfaults Bun while tearing down this composer-to-skill-panel transition.
  760. // Re-enable after the upstream renderer teardown fix lands.
  761. test.skip("direct footer skill picker inserts an editable bound skill command", async () => {
  762. const submits: RunPrompt[] = []
  763. const app = await renderFooter({
  764. commands: [command({ name: "new", description: "Skill named new", source: "skill" })],
  765. onSubmit(prompt) {
  766. submits.push(prompt)
  767. return true
  768. },
  769. })
  770. try {
  771. await app.renderOnce()
  772. "/skills".split("").forEach((key) => app.mockInput.pressKey(key))
  773. await app.renderOnce()
  774. app.mockInput.pressEnter()
  775. await app.renderOnce()
  776. expect(app.captureCharFrame()).toContain("Skill named new")
  777. app.mockInput.pressEnter()
  778. await app.renderOnce()
  779. expect(submits).toEqual([])
  780. expect(app.captureCharFrame()).toContain("/new")
  781. "task".split("").forEach((key) => app.mockInput.pressKey(key))
  782. await app.renderOnce()
  783. app.mockInput.pressEnter()
  784. await app.renderOnce()
  785. expect(submits).toEqual([{ text: "/new task", parts: [], command: { name: "new", arguments: "task" } }])
  786. } finally {
  787. app.cleanup()
  788. }
  789. })
  790. // OpenTUI currently segfaults Bun while tearing down this skill-panel close transition.
  791. // Re-enable after the upstream renderer teardown fix lands.
  792. test.skip("direct footer clears the synthetic skills draft when the panel closes", async () => {
  793. const submits: RunPrompt[] = []
  794. const app = await renderFooter({
  795. commands: [command({ name: "formatter", description: "Apply formatter fixes", source: "skill" })],
  796. onSubmit(prompt) {
  797. submits.push(prompt)
  798. return true
  799. },
  800. })
  801. try {
  802. await app.renderOnce()
  803. "/skills".split("").forEach((key) => app.mockInput.pressKey(key))
  804. await app.renderOnce()
  805. app.mockInput.pressEnter()
  806. await app.renderOnce()
  807. expect(app.captureCharFrame()).toContain("Apply formatter fixes")
  808. app.mockInput.pressKey("c", { ctrl: true })
  809. await app.renderOnce()
  810. app.mockInput.pressEnter()
  811. await app.renderOnce()
  812. expect(submits).toEqual([])
  813. expect(app.captureCharFrame()).not.toContain("/skills")
  814. } finally {
  815. app.cleanup()
  816. }
  817. })
  818. test("direct footer shows editable prompts and additional queued work while running", async () => {
  819. const [state] = createSignal<FooterState>({
  820. phase: "running",
  821. status: "",
  822. queue: 3,
  823. model: "gpt-5",
  824. duration: "",
  825. usage: "",
  826. first: false,
  827. interrupt: 0,
  828. exit: 0,
  829. })
  830. const [view] = createSignal<FooterView>({ type: "prompt" })
  831. const [subagents] = createSignal<FooterSubagentState>({
  832. tabs: [subagent({ sessionID: "s-1", label: "Explore", description: "Inspect auth flow" })],
  833. details: {},
  834. permissions: [],
  835. questions: [],
  836. })
  837. let offKeymap: (() => void) | undefined
  838. function Harness() {
  839. const renderer = useRenderer()
  840. const keymap = createDefaultOpenTuiKeymap(renderer)
  841. offKeymap = registerOpencodeKeymap(keymap, renderer, tuiConfig)
  842. return (
  843. <OpencodeKeymapProvider keymap={keymap}>
  844. <RunFooterView
  845. directory="/tmp"
  846. findFiles={async () => []}
  847. agents={() => []}
  848. resources={() => []}
  849. commands={() => []}
  850. providers={() => undefined}
  851. currentModel={() => ({
  852. providerID: "kirincode",
  853. modelID: "a-model-name-long-enough-to-force-responsive-truncation",
  854. })}
  855. variants={() => []}
  856. currentVariant={() => undefined}
  857. state={state}
  858. view={view}
  859. subagent={subagents}
  860. queuedPrompts={() => [
  861. { messageID: "m-queued", partID: "p-queued", prompt: { text: "follow up", parts: [] } },
  862. ]}
  863. theme={() => RUN_THEME_FALLBACK}
  864. tuiConfig={tuiConfig}
  865. backgroundSubagents={true}
  866. agent="kirincode"
  867. onSubmit={() => true}
  868. onPermissionReply={() => {}}
  869. onQuestionReply={() => {}}
  870. onQuestionReject={() => {}}
  871. onCycle={() => {}}
  872. onInterrupt={() => false}
  873. onEditorOpen={async () => undefined}
  874. onInputClear={() => {}}
  875. onExit={() => {}}
  876. onModelSelect={() => {}}
  877. onVariantSelect={() => {}}
  878. onRows={() => {}}
  879. onLayout={() => {}}
  880. onStatus={() => {}}
  881. onQueuedRemove={async () => true}
  882. />
  883. </OpencodeKeymapProvider>
  884. )
  885. }
  886. const app = await testRender(
  887. () => (
  888. <box width={160} height={8}>
  889. <Harness />
  890. </box>
  891. ),
  892. {
  893. width: 160,
  894. height: 8,
  895. },
  896. )
  897. try {
  898. await app.renderOnce()
  899. const frame = app.captureCharFrame()
  900. const transparent = RGBA.fromValues(0, 0, 0, 0).toInts()
  901. const tinted = (RUN_THEME_FALLBACK.footer.status as RGBA).toInts()
  902. const accent = (RUN_THEME_FALLBACK.footer.statusAccent as RGBA).toInts()
  903. const statusline = footerStatusline(app.renderer.root)
  904. const statusItems = statusline.getChildren().filter((item): item is BoxRenderable => item instanceof BoxRenderable)
  905. const mode = statusItems[0]
  906. const main = statusItems[1]
  907. const spinner = main.getChildren()[0]
  908. const model = statusItems[2]
  909. const queued = statusItems[3]
  910. const hint = statusItems.at(-1)!
  911. expect(spinner).toBeDefined()
  912. expect(frame).toContain("a-model-name-long-enough-to-force-responsive-truncation")
  913. expect(frame).toContain("3 queued")
  914. expect(frame).toContain("ctrl+b background")
  915. expect(frame).toContain("ctrl+x q 3 queued")
  916. expect(frame).toContain("ctrl+x down subagents")
  917. expect(frame).toContain("ctrl+p cmd")
  918. expect(frame).toContain("a-model-name-long-enough-to-force-responsive-truncation")
  919. expect(frame).toContain("subagents · ctrl+p cmd")
  920. expect(frame).not.toContain("1 agent")
  921. expect(statusline.backgroundColor.toInts()).toEqual(tinted)
  922. expect(mode.backgroundColor.toInts()).toEqual(accent)
  923. expect(main.backgroundColor.toInts()).toEqual(transparent)
  924. expect(model.backgroundColor.toInts()).toEqual(transparent)
  925. expect(queued.backgroundColor.toInts()).toEqual(transparent)
  926. expect(hint.backgroundColor.toInts()).toEqual(transparent)
  927. } finally {
  928. app.renderer.currentFocusedRenderable?.blur()
  929. app.renderer.currentFocusedEditor?.blur()
  930. offKeymap?.()
  931. app.renderer.destroy()
  932. }
  933. })
  934. test("direct footer separates a lone context hint from model and command hint", async () => {
  935. const app = await renderFooter({
  936. providers: [provider()],
  937. currentModel: { providerID: "kirincode", modelID: "gpt-5" },
  938. currentVariant: "xhigh",
  939. subagents: {
  940. tabs: [subagent({ sessionID: "s-1", label: "Explore", description: "Inspect auth flow" })],
  941. details: {},
  942. permissions: [],
  943. questions: [],
  944. },
  945. backgroundSubagents: false,
  946. width: 160,
  947. })
  948. try {
  949. await app.renderOnce()
  950. const frame = app.captureCharFrame()
  951. expect(frame).toContain("GPT-5")
  952. expect(frame).toContain("xhigh · ctrl+x down subagents · ctrl+p cmd")
  953. expect(frame).not.toContain("ctrl+b background")
  954. expect(frame).not.toContain("queued")
  955. } finally {
  956. app.cleanup()
  957. }
  958. })
  959. test("direct footer hides the subagent hint when only completed subagents remain", async () => {
  960. const app = await renderFooter({
  961. providers: [provider()],
  962. currentModel: { providerID: "kirincode", modelID: "gpt-5" },
  963. currentVariant: "xhigh",
  964. subagents: {
  965. tabs: [subagent({ sessionID: "s-1", label: "Explore", description: "Inspect auth flow", status: "completed" })],
  966. details: {},
  967. permissions: [],
  968. questions: [],
  969. },
  970. backgroundSubagents: false,
  971. width: 160,
  972. })
  973. try {
  974. await app.renderOnce()
  975. const frame = app.captureCharFrame()
  976. expect(frame).toContain("GPT-5")
  977. expect(frame).toContain("xhigh · ctrl+p cmd")
  978. expect(frame).not.toContain("ctrl+x down subagents")
  979. } finally {
  980. app.cleanup()
  981. }
  982. })
  983. test("direct footer omits interrupt key hint when interrupt is unbound", async () => {
  984. const app = await renderFooter({
  985. tuiConfig: createTuiResolvedConfig({ keybinds: { session_interrupt: "none", input_clear: "ctrl+l" } }),
  986. state: { phase: "running" },
  987. })
  988. try {
  989. await app.renderOnce()
  990. const frame = app.captureCharFrame()
  991. expect(frame).toContain("interrupt")
  992. expect(frame).not.toContain("ctrl+l")
  993. } finally {
  994. app.cleanup()
  995. }
  996. })
  997. test("direct footer shows full usage metadata when room is available", async () => {
  998. const app = await renderFooter({
  999. state: { usage: "159.6K (16%) · $4.23" },
  1000. })
  1001. try {
  1002. await app.renderOnce()
  1003. const frame = app.captureCharFrame()
  1004. expect(frame).toContain("159.6K (16%) · $4.23")
  1005. } finally {
  1006. app.cleanup()
  1007. }
  1008. })
  1009. test("direct footer mode label keeps left padding without a status pill", async () => {
  1010. const app = await renderFooter()
  1011. try {
  1012. await app.renderOnce()
  1013. const statusline = app
  1014. .captureCharFrame()
  1015. .split("\n")
  1016. .find((line) => line.includes("BUILD") && line.includes("cmd"))
  1017. expect(statusline).toBeDefined()
  1018. expect(statusline?.startsWith(" BUILD ")).toBe(true)
  1019. } finally {
  1020. app.cleanup()
  1021. }
  1022. })
  1023. test("direct question body separates single-select checkmark from label", async () => {
  1024. const request = {
  1025. id: "question-1",
  1026. sessionID: "session-1",
  1027. questions: [
  1028. {
  1029. question: "Which categorical concept is often described as a universal way to combine two objects?",
  1030. header: "Universal Product",
  1031. options: [
  1032. { label: "Product", description: "A product comes with projections." },
  1033. { label: "Equalizer", description: "An equalizer selects morphisms where arrows agree." },
  1034. ],
  1035. },
  1036. ],
  1037. } satisfies QuestionRequest
  1038. const replies: unknown[] = []
  1039. const app = await testRender(
  1040. () => (
  1041. <box width={100} height={12}>
  1042. <RunQuestionBody
  1043. request={request}
  1044. theme={RUN_THEME_FALLBACK.footer}
  1045. onReply={(input) => {
  1046. replies.push(input)
  1047. }}
  1048. onReject={() => {}}
  1049. />
  1050. </box>
  1051. ),
  1052. {
  1053. width: 100,
  1054. height: 12,
  1055. },
  1056. )
  1057. try {
  1058. app.mockInput.pressEnter()
  1059. await app.renderOnce()
  1060. expect(replies).toHaveLength(1)
  1061. expect(app.captureCharFrame()).toContain("Product ✓")
  1062. } finally {
  1063. app.renderer.destroy()
  1064. }
  1065. })
  1066. // OpenTUI currently segfaults while tearing down this textarea-backed keymap renderer.
  1067. // Re-enable after the runtime fix.
  1068. test.skip("direct custom answer submits through keymap return binding", async () => {
  1069. const question = {
  1070. id: "question-1",
  1071. sessionID: "session-1",
  1072. questions: [
  1073. {
  1074. question: "Which answer should I use?",
  1075. header: "Answer",
  1076. options: [{ label: "Provided", description: "Use the listed answer." }],
  1077. custom: true,
  1078. },
  1079. ],
  1080. } satisfies QuestionRequest
  1081. const questions: unknown[] = []
  1082. let off: (() => void) | undefined
  1083. function Harness() {
  1084. const renderer = useRenderer()
  1085. const keymap = createDefaultOpenTuiKeymap(renderer)
  1086. off = registerOpencodeKeymap(keymap, renderer, tuiConfig)
  1087. return (
  1088. <OpencodeKeymapProvider keymap={keymap}>
  1089. <RunQuestionBody
  1090. request={question}
  1091. theme={RUN_THEME_FALLBACK.footer}
  1092. onReply={(input) => {
  1093. questions.push(input)
  1094. }}
  1095. onReject={() => {}}
  1096. />
  1097. </OpencodeKeymapProvider>
  1098. )
  1099. }
  1100. const app = await testRender(
  1101. () => (
  1102. <box width={100} height={18}>
  1103. <Harness />
  1104. </box>
  1105. ),
  1106. { width: 100, height: 18, kittyKeyboard: true },
  1107. )
  1108. try {
  1109. await app.renderOnce()
  1110. app.mockInput.pressKey("2")
  1111. await app.renderOnce()
  1112. "typed".split("").forEach((key) => app.mockInput.pressKey(key))
  1113. await app.renderOnce()
  1114. app.mockInput.pressEnter()
  1115. await app.renderOnce()
  1116. expect(questions).toEqual([{ requestID: "question-1", answers: [["typed"]] }])
  1117. } finally {
  1118. app.renderer.currentFocusedRenderable?.blur()
  1119. app.renderer.currentFocusedEditor?.blur()
  1120. off?.()
  1121. app.renderer.destroy()
  1122. }
  1123. })
  1124. test("direct permission rejection submits through keymap return binding", async () => {
  1125. let text = ""
  1126. const submits: string[] = []
  1127. let off: (() => void) | undefined
  1128. function Harness() {
  1129. const renderer = useRenderer()
  1130. const keymap = createDefaultOpenTuiKeymap(renderer)
  1131. off = registerOpencodeKeymap(keymap, renderer, tuiConfig)
  1132. return (
  1133. <OpencodeKeymapProvider keymap={keymap}>
  1134. <RejectField
  1135. theme={RUN_THEME_FALLBACK.footer}
  1136. text=""
  1137. disabled={false}
  1138. onChange={(input) => {
  1139. text = input
  1140. }}
  1141. onConfirm={() => {
  1142. submits.push(text)
  1143. }}
  1144. onCancel={() => {}}
  1145. />
  1146. </OpencodeKeymapProvider>
  1147. )
  1148. }
  1149. const app = await testRender(
  1150. () => (
  1151. <box width={100} height={18}>
  1152. <Harness />
  1153. </box>
  1154. ),
  1155. { width: 100, height: 18, kittyKeyboard: true },
  1156. )
  1157. try {
  1158. await app.renderOnce()
  1159. "retry".split("").forEach((key) => app.mockInput.pressKey(key))
  1160. await app.renderOnce()
  1161. expect(app.captureCharFrame()).toContain("retry")
  1162. app.mockInput.pressEnter()
  1163. await app.renderOnce()
  1164. expect(submits).toEqual(["retry"])
  1165. } finally {
  1166. app.renderer.currentFocusedRenderable?.blur()
  1167. app.renderer.currentFocusedEditor?.blur()
  1168. off?.()
  1169. app.renderer.destroy()
  1170. }
  1171. })
  1172. test("direct model panel renders current model selector", async () => {
  1173. const [providers] = createSignal<RunProvider[] | undefined>([provider()])
  1174. const [current] = createSignal<RunInput["model"]>({ providerID: "kirincode", modelID: "gpt-5" })
  1175. const app = await testRender(
  1176. () => (
  1177. <box width={100} height={RUN_COMMAND_PANEL_ROWS}>
  1178. <RunModelSelectBody
  1179. theme={() => RUN_THEME_FALLBACK.footer}
  1180. providers={providers}
  1181. current={current}
  1182. onClose={() => {}}
  1183. onSelect={() => {}}
  1184. />
  1185. </box>
  1186. ),
  1187. {
  1188. width: 100,
  1189. height: RUN_COMMAND_PANEL_ROWS,
  1190. },
  1191. )
  1192. try {
  1193. await app.renderOnce()
  1194. const frame = app.captureCharFrame()
  1195. const list = panelMenu(app.renderer.root)
  1196. expect(frame).toContain("Select model")
  1197. expect(frame).toContain("Search")
  1198. expect(frame).toContain("kirincode")
  1199. expect(frame).toContain("GPT-5")
  1200. expect(frame).toContain("current")
  1201. expect(frame).toContain("GPT Free")
  1202. expect(frame).toContain("Free")
  1203. expect(frame).not.toContain("┌")
  1204. expect(frame).not.toContain("┃")
  1205. expect(frame).not.toContain("Old Model")
  1206. expectPaletteList(list, 2)
  1207. } finally {
  1208. app.renderer.destroy()
  1209. }
  1210. })
  1211. test("direct variant panel renders current variant selector", async () => {
  1212. const [variants] = createSignal(["high", "minimal"])
  1213. const [current] = createSignal<string | undefined>("high")
  1214. const app = await testRender(
  1215. () => (
  1216. <box width={100} height={RUN_COMMAND_PANEL_ROWS}>
  1217. <RunVariantSelectBody
  1218. theme={() => RUN_THEME_FALLBACK.footer}
  1219. variants={variants}
  1220. current={current}
  1221. onClose={() => {}}
  1222. onSelect={() => {}}
  1223. />
  1224. </box>
  1225. ),
  1226. {
  1227. width: 100,
  1228. height: RUN_COMMAND_PANEL_ROWS,
  1229. },
  1230. )
  1231. try {
  1232. await app.renderOnce()
  1233. const frame = app.captureCharFrame()
  1234. const list = panelMenu(app.renderer.root)
  1235. expect(frame).toContain("Select variant")
  1236. expect(frame).toContain("Default")
  1237. expect(frame).toContain("high")
  1238. expect(frame).toContain("minimal")
  1239. expect(frame).toContain("current")
  1240. expect(frame).not.toContain("┌")
  1241. expect(frame).not.toContain("┃")
  1242. expectPaletteList(list, 1)
  1243. } finally {
  1244. app.renderer.destroy()
  1245. }
  1246. })