Просмотр исходного кода

fix(tui): drop input box borders, use simple › prompt with spacing

Ma 7 месяцев назад
Родитель
Сommit
e944280392

+ 3 - 9
packages/cli/src/__tests__/tui-input-chrome.test.ts

@@ -1,16 +1,10 @@
 import { describe, expect, it } from "vitest";
-import { inputPromptPrefix, drawInputTop, drawInputBottom } from "../tui/effects.js";
+import { inputPromptPrefix } from "../tui/effects.js";
 import { stripAnsi } from "../tui/ansi.js";
 
 describe("tui input chrome", () => {
-  it("produces a prompt prefix with the ❯ indicator", () => {
+  it("produces a prompt prefix with the › indicator", () => {
     const prefix = stripAnsi(inputPromptPrefix());
-    expect(prefix).toContain("❯");
-  });
-
-  it("drawInputTop and drawInputBottom are callable", () => {
-    // Smoke test — these write to stdout, just verify no throw
-    expect(typeof drawInputTop).toBe("function");
-    expect(typeof drawInputBottom).toBe("function");
+    expect(prefix).toContain("›");
   });
 });

+ 2 - 12
packages/cli/src/tui/app.ts

@@ -29,8 +29,7 @@ import {
   printStyledStatus,
   printInputSeparator,
   inputPromptPrefix,
-  drawInputTop,
-  drawInputBottom,
+  drawInputHint,
 } from "./effects.js";
 
 /* ── Version ── */
@@ -250,19 +249,13 @@ export async function launchTui(
     rl.close();
   };
 
-  const bottomPad = 4;
   const promptInput = () => {
-    drawInputTop();
+    drawInputHint();
     rl.prompt();
-    // Add padding below prompt so it's not flush with terminal bottom,
-    // then move cursor back up to the prompt line.
-    process.stdout.write("\n".repeat(bottomPad));
-    process.stdout.write(`\x1b[${bottomPad}A`);
   };
 
   process.on("SIGINT", () => {
     console.log();
-    drawInputBottom();
     console.log(c("  ◇ goodbye", dim));
     console.log();
     cleanup();
@@ -272,9 +265,6 @@ export async function launchTui(
   promptInput();
 
   for await (const line of rl) {
-    // Move past the bottom padding, then draw box bottom
-    process.stdout.write(`\x1b[${bottomPad}B`);
-    drawInputBottom();
     const input = line.trim();
 
     if (!input) {

+ 3 - 13
packages/cli/src/tui/effects.ts

@@ -166,22 +166,12 @@ const ASCII_LOGO = [
 /* ── Input chrome ── */
 
 export function inputPromptPrefix(): string {
-  return `  ${c("❯", gray)} `;
+  return `  ${c("›", cyan)} `;
 }
 
-export function drawInputTop(): void {
-  const w = Math.max(48, Math.min((process.stdout.columns ?? 80) - 6, 84));
+export function drawInputHint(): void {
+  console.log();
   console.log();
-  console.log(`  ${c(`╭${"─".repeat(w - 2)}╮`, gray)}`);
-  const hint = "Ask InkOS to write, revise, or explain…";
-  const inner = w - 4;
-  const padded = hint.length > inner ? hint.slice(0, inner) : hint.padEnd(inner);
-  console.log(`  ${c("│", gray)} ${c(padded, dim)} ${c("│", gray)}`);
-}
-
-export function drawInputBottom(): void {
-  const w = Math.max(48, Math.min((process.stdout.columns ?? 80) - 6, 84));
-  console.log(`  ${c(`╰${"─".repeat(w - 2)}╯`, gray)}`);
 }
 
 export function printInputSeparator(): void {