Skip to content

JiuwenSwarm is an intelligent AI Agent built on openJiuwen. It extends the powerful capabilities of large language models directly to your fingertips through various communication apps you use daily.

Python

Fix TUI resize flicker

chensheng12345def4f798fae7
diff --git a/jiuwenclaw/channels/tui/frontend/src/index.ts b/jiuwenclaw/channels/tui/frontend/src/index.ts
index c010ebc578..589a0d51cf 100644
--- a/jiuwenclaw/channels/tui/frontend/src/index.ts
+++ b/jiuwenclaw/channels/tui/frontend/src/index.ts
@@ -42,7 +42,6 @@ commandService.register(createBuiltinCommands());
const terminal = new ProcessTerminal();
const tui = new TUI(terminal);
-tui.setClearOnShrink(true);
let closed = false;
let screen: AppScreen | null = null;
diff --git a/jiuwenclaw/channels/tui/frontend/src/ui/app-screen.ts b/jiuwenclaw/channels/tui/frontend/src/ui/app-screen.ts
index 112f3ed5df..1e0299b0b0 100644
--- a/jiuwenclaw/channels/tui/frontend/src/ui/app-screen.ts
+++ b/jiuwenclaw/channels/tui/frontend/src/ui/app-screen.ts
@@ -921,6 +921,7 @@ export class AppScreen implements Component, Focusable {
];
return buildAppScreenLines(snapshot, {
width,
+ height: this.tui.terminal.rows,
questionLines,
editorLines,
composerPreviewLines,
diff --git a/jiuwenclaw/channels/tui/frontend/src/ui/screen-layout.ts b/jiuwenclaw/channels/tui/frontend/src/ui/screen-layout.ts
index 63a98ef172..b99bcb243f 100644
--- a/jiuwenclaw/channels/tui/frontend/src/ui/screen-layout.ts
+++ b/jiuwenclaw/channels/tui/frontend/src/ui/screen-layout.ts
@@ -11,6 +11,7 @@ import { buildTranscriptLines } from "./transcript-renderer.js";
export interface ScreenLayoutOptions {
width: number;
+ height?: number;
questionLines: string[];
editorLines: string[];
composerPreviewLines: string[];
@@ -215,7 +216,7 @@ export function buildAppScreenLines(snapshot: AppSnapshot, options: ScreenLayout
options.width,
)
: [];
- return [
+ const lines = [
...transcriptLines,
...todoLines,
...(todoLines.length > 0 &&
@@ -231,4 +232,6 @@ export function buildAppScreenLines(snapshot: AppSnapshot, options: ScreenLayout
...statusLines,
...shortcutLines,
];
+ const height = Math.floor(options.height ?? 0);
+ return height > 0 && lines.length > height ? lines.slice(-height) : lines;
}