Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions packages/cli/src/ui/AppContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@ export const AppContainer = (props: AppContainerProps) => {

// Terminal and layout hooks
const { columns: terminalWidth, rows: terminalHeight } = useTerminalSize();
const previousTerminalWidthRef = useRef(terminalWidth);
const { stdin, setRawMode } = useStdin();
const { stdout } = useStdout();

Expand Down Expand Up @@ -563,6 +564,13 @@ export const AppContainer = (props: AppContainerProps) => {
remountStaticHistory();
}, [remountStaticHistory, stdout]);

// Targeted repaint for resize events: move cursor to top-left and erase
// downward instead of a full clearTerminal, avoiding the full-screen flash.
const repaintStaticViewport = useCallback(() => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Suggestion] repaintStaticViewport 回调和新 width-change useEffect 缺少测试覆盖。repaintStaticViewport 是未导出的私有回调,现有 56 个 AppContainer 测试中没有测试能触发它。建议至少新增以下测试:(1) 通过 actions context 暴露该回调并验证其写入 cursorTo(0,0) + eraseDown;(2) 宽度变化时验证 effect 写入正确转义序列;(3) 等值守卫(80→80)时验证不写入任何转义序列。

另外,现有测试 "does not clear the terminal just because width changed" (AppContainer.test.tsx:501) 仅断言旧行为(clearTerminal 未写入),应同步更新为验证新行为(cursorTo + eraseDown 已写入),避免未来回归被掩盖。

— DeepSeek/deepseek-v4-pro via Qwen Code /review

stdout.write(`${ansiEscapes.cursorTo(0, 0)}${ansiEscapes.eraseDown}`);
remountStaticHistory();
}, [remountStaticHistory, stdout]);

// Keep the static header in sync with model changes without polling.
// Ink's <Static> output is append-only, so model changes must explicitly
// clear and remount the static region to redraw the banner at the top.
Expand Down Expand Up @@ -1747,6 +1755,14 @@ export const AppContainer = (props: AppContainerProps) => {
}
}, [terminalWidth, availableTerminalHeight, activePtyId]);

useEffect(() => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Suggestion] 新增的 resize effect(previousTerminalWidthRef 等值守卫)未被测试。ref 初始值取决于 useTerminalSize() 的返回值 —— 若该 hook 在某些环境下短暂返回 0 后再返回正确值,ref 会被污染导致首次真实 resize 时等值比较误跳过。建议增加测试:模拟 rerender 时宽度从初始值不变→跳过,再从该值变为新宽度→触发 repaint。

— DeepSeek/deepseek-v4-pro via Qwen Code /review

if (previousTerminalWidthRef.current === terminalWidth) {
return;
}
previousTerminalWidthRef.current = terminalWidth;
repaintStaticViewport();
}, [terminalWidth, repaintStaticViewport]);

useEffect(() => {
if (ideNeedsRestart) {
// IDE trust changed, force a restart.
Expand Down
Loading