UNPKG

@code-yeongyu/senpi

Version:

Coding agent CLI with read, bash, edit, write tools and session management

66 lines • 2.28 kB
import { Container, Markdown, Text } from "@earendil-works/pi-tui"; import { DynamicBorder } from "../../../../modes/interactive/components/dynamic-border.js"; import { getMarkdownTheme } from "../../../../modes/interactive/theme/theme.js"; export class BtwPanel { constructor(question, tui, theme) { this.answer = ""; this.status = "streaming"; this.detail = ""; this.question = question; this.tui = tui; this.theme = theme; this.container = new Container(); this.container.addChild(new DynamicBorder((s) => this.theme.fg("muted", s))); this.header = new Text("", 1, 0); this.body = new Markdown("", 1, 0, getMarkdownTheme()); this.footer = new Text("", 1, 0); this.container.addChild(this.header); this.container.addChild(this.body); this.container.addChild(this.footer); this.container.addChild(new DynamicBorder((s) => this.theme.fg("muted", s))); this.repaint(); } get component() { return this.container; } appendText(delta) { this.answer += delta; this.repaint(); } markDone() { this.status = "done"; this.repaint(); } markError(message) { this.status = "error"; this.detail = message; this.repaint(); } markAborted() { this.status = "aborted"; this.repaint(); } repaint() { const thm = this.theme; this.header.setText(thm.fg("accent", thm.bold("btw: ")) + thm.fg("text", this.question)); this.body.setText(this.answer); let footer; switch (this.status) { case "streaming": footer = thm.fg("dim", "answering… (/btw or Esc to cancel)"); break; case "done": footer = thm.fg("dim", "(/btw or Esc to dismiss; clears on next message)"); break; case "error": footer = thm.fg("error", `error: ${this.detail}`); break; case "aborted": footer = thm.fg("dim", "(dismissed)"); break; } this.footer.setText(footer); this.tui.requestRender(); } } //# sourceMappingURL=panel.js.map