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

fix(tui): suppress SQLite warning, simplify input to gray line

- Filter ExperimentalWarning from stderr during TUI session
- Replace bordered input box with single gray separator line
- Gray ❯ prompt with proper spacing above and below
- Input line spans full terminal width
Ma 7 месяцев назад
Родитель
Сommit
7a1752b2fb
2 измененных файлов с 22 добавлено и 26 удалено
  1. 18 14
      packages/cli/src/tui/app.ts
  2. 4 12
      packages/cli/src/tui/effects.ts

+ 18 - 14
packages/cli/src/tui/app.ts

@@ -28,8 +28,7 @@ import {
   printStyledHelp,
   printStyledStatus,
   printInputSeparator,
-  drawInputBoxTop,
-  drawInputBoxBottom,
+  drawInputLine,
 } from "./effects.js";
 
 /* ── Version ── */
@@ -207,30 +206,37 @@ export async function launchTui(
     return;
   }
 
-  // 7. REPL loop
+  // 7. Suppress noisy Node warnings (e.g. SQLite experimental)
+  const origStderrWrite = process.stderr.write.bind(process.stderr);
+  process.stderr.write = (chunk: string | Uint8Array, ...args: unknown[]) => {
+    const s = typeof chunk === "string" ? chunk : chunk.toString();
+    if (s.includes("ExperimentalWarning") || s.includes("--trace-warnings")) {
+      return true;
+    }
+    return (origStderrWrite as Function)(chunk, ...args);
+  };
+
+  // 8. REPL loop
   const rl = readline.createInterface({
     input: process.stdin,
     output: process.stdout,
-    prompt: `  ${c("│", gray)} ${c("❯", brightCyan)} `,
+    prompt: `  ${c("❯", gray)} `,
   });
 
   const cleanup = () => {
+    process.stderr.write = origStderrWrite;
     process.stdout.write(showCursor);
     rl.close();
   };
 
   const promptInput = () => {
-    drawInputBoxTop();
+    drawInputLine();
+    console.log();
     rl.prompt();
   };
 
-  const closeInputBox = () => {
-    drawInputBoxBottom();
-  };
-
   process.on("SIGINT", () => {
     console.log();
-    closeInputBox();
     console.log(c("  ◇ goodbye", dim));
     console.log();
     cleanup();
@@ -240,7 +246,6 @@ export async function launchTui(
   promptInput();
 
   for await (const line of rl) {
-    closeInputBox();
     const input = line.trim();
 
     if (!input) {
@@ -248,6 +253,8 @@ export async function launchTui(
       continue;
     }
 
+    console.log();
+
     // Built-in TUI commands
     if (/^\/quit$/i.test(input) || /^\/exit$/i.test(input) || /^(quit|exit|bye)$/i.test(input)) {
       console.log(c("  ◇ goodbye", dim));
@@ -256,14 +263,12 @@ export async function launchTui(
     }
 
     if (/^\/help$/i.test(input) || /^(help|帮助)$/i.test(input)) {
-      console.log();
       printStyledHelp();
       promptInput();
       continue;
     }
 
     if (/^\/status$/i.test(input) || /^(status|状态)$/i.test(input)) {
-      console.log();
       try {
         const s = await loadProjectSession(projectRoot);
         const bId = await resolveSessionActiveBook(projectRoot, s);
@@ -287,7 +292,6 @@ export async function launchTui(
     }
 
     // Delegate to interaction layer with themed animation
-    console.log();
     await processInput(projectRoot, input, tools);
     console.log();
 

+ 4 - 12
packages/cli/src/tui/effects.ts

@@ -161,19 +161,11 @@ const ASCII_LOGO = [
   " ╚═╝╚═╝  ╚═══╝╚═╝  ╚═╝ ╚═════╝ ╚══════╝",
 ];
 
-/* ── Input box ── */
+/* ── Input area ── */
 
-export function drawInputBoxTop(): void {
-  const w = Math.min(process.stdout.columns ?? 60, 60);
-  const label = c(" inkos ", dim);
-  const labelLen = 7; // visible length of " inkos "
-  const lineLen = w - 4 - 2 - labelLen; // ╭─ + label + ─...─
-  process.stdout.write(`  ${c("╭─", gray)}${label}${c("─".repeat(Math.max(0, lineLen)), gray)}\n`);
-}
-
-export function drawInputBoxBottom(): void {
-  const w = Math.min(process.stdout.columns ?? 60, 60);
-  process.stdout.write(`  ${c("╰" + "─".repeat(w - 5), gray)}\n`);
+export function drawInputLine(): void {
+  const w = process.stdout.columns ?? 80;
+  console.log(c("  " + "─".repeat(w - 4), gray));
 }
 
 export function printInputSeparator(): void {