@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
30 lines • 1.26 kB
JavaScript
import { truncateToWidth, visibleWidth } from "@earendil-works/pi-tui";
import { getGrokChromeTokens } from "./chrome-tokens.js";
/** Rounded grok input shell for the mode-owned base editor. */
export class GrokInputCard {
constructor(editor) {
this.editor = editor;
}
invalidate() {
this.editor.invalidate?.();
}
render(width) {
if (width < 3)
return this.editor.render(width);
const tokens = getGrokChromeTokens();
const contentWidth = width - 2;
const horizontal = "─".repeat(contentWidth);
const editorLines = this.editor.render(contentWidth);
const content = editorLines.length > 0 ? editorLines : [""];
const paddedLines = content.map((line) => {
const truncated = truncateToWidth(line, contentWidth, "");
return `${truncated}${" ".repeat(Math.max(0, contentWidth - visibleWidth(truncated)))}`;
});
return [
tokens.inputBorder(`╭${horizontal}╮`),
...paddedLines.map((line) => `${tokens.inputBorder("│")}${tokens.inputInterior(line)}${tokens.inputBorder("│")}`),
tokens.inputBorder(`╰${horizontal}╯`),
];
}
}
//# sourceMappingURL=input-card.js.map