Refine refresh static logic (#1349)

This commit is contained in:
Sandy Tao 2025-06-23 14:45:15 -07:00 committed by GitHub
parent 1faf53a3af
commit fcb8be2fb9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 8 deletions

View File

@ -239,7 +239,6 @@ const App = ({ config, settings, startupWarnings = [] }: AppProps) => {
const pendingHistoryItems = [...pendingSlashCommandHistoryItems];
const { rows: terminalHeight, columns: terminalWidth } = useTerminalSize();
const lastTerminalWidth = useRef(terminalWidth);
const isInitialMount = useRef(true);
const { stdin, setRawMode } = useStdin();
const isValidPath = useCallback((filePath: string): boolean => {
@ -319,11 +318,9 @@ const App = ({ config, settings, startupWarnings = [] }: AppProps) => {
if (key.ctrl && input === 'o') {
setShowErrorDetails((prev) => !prev);
refreshStatic();
} else if (key.ctrl && input === 't') {
const newValue = !showToolDescriptions;
setShowToolDescriptions(newValue);
refreshStatic();
const mcpServers = config.getMcpServers();
if (Object.keys(mcpServers || {}).length > 0) {
@ -475,16 +472,14 @@ const App = ({ config, settings, startupWarnings = [] }: AppProps) => {
// debounce so it doesn't fire up too often during resize
const handler = setTimeout(() => {
if (terminalWidth < lastTerminalWidth.current) {
setStaticNeedsRefresh(true);
}
lastTerminalWidth.current = terminalWidth;
setStaticNeedsRefresh(false);
refreshStatic();
}, 300);
return () => {
clearTimeout(handler);
};
}, [terminalWidth]);
}, [terminalWidth, terminalHeight, refreshStatic]);
useEffect(() => {
if (!pendingHistoryItems.length) {