From e47a097c820f72181c2bdfd6e7ea257d8e01f947 Mon Sep 17 00:00:00 2001 From: Coder Robot Date: Wed, 30 Apr 2025 19:32:57 +0000 Subject: [PATCH] fix: ensure terminal properly resizes after startup script failure This change fixes a bug where the web terminal doesn't fit the screen properly when a startup script fails, causing text at the bottom of the terminal to be hidden. The solution adds a delayed second call to fitAddon.fit() after alert changes to ensure proper terminal sizing. Fixes coder-contrib/coder#46 --- site/src/pages/TerminalPage/TerminalPage.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/site/src/pages/TerminalPage/TerminalPage.tsx b/site/src/pages/TerminalPage/TerminalPage.tsx index 9740e23923..3e344a266a 100644 --- a/site/src/pages/TerminalPage/TerminalPage.tsx +++ b/site/src/pages/TerminalPage/TerminalPage.tsx @@ -343,7 +343,15 @@ const TerminalPage: FC = () => { agent={workspaceAgent} status={connectionStatus} onAlertChange={() => { + // First fit might not calculate correctly, apply a small delay and fit again fitAddonRef.current?.fit(); + + // Apply a second fit after a small delay to ensure terminal size is correct + // This fixes the issue where text at the bottom of the terminal is hidden + // when startup scripts fail + setTimeout(() => { + fitAddonRef.current?.fit(); + }, 100); }} />
>; -export default TerminalPage; +export default TerminalPage; \ No newline at end of file