Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions app/api/terminal/[id]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ export async function POST(
}
if (body.type === "resize" && Number.isInteger(body.cols) && Number.isInteger(body.rows)
&& (body.cols as number) >= 2 && (body.cols as number) <= 1000
&& (body.rows as number) >= 2 && (body.rows as number) <= 1000) {
return resizeTerminal(id, body.cols as number, body.rows as number)
&& (body.rows as number) >= 1 && (body.rows as number) <= 1000) {
return resizeTerminal(id, body.cols as number, Math.max(2, body.rows as number))
? NextResponse.json({ success: true })
: NextResponse.json({ error: "Terminal not found" }, { status: 404 });
}
Expand Down
5 changes: 3 additions & 2 deletions components/TerminalPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ export function TerminalPanel({ tab, active, onRestart, onClosed, onCloseError }
fit.fit();
};
const onResize = terminal.onResize(({ cols, rows }) => {
if (connected && !exited && !inputFailed) writer.resize(cols, rows);
if (!connected || exited || inputFailed) return;
writer.resize(Math.max(2, cols), Math.max(2, rows));
});
const resizeObserver = new ResizeObserver(fitAndResize);
resizeObserver.observe(container);
Expand Down Expand Up @@ -138,7 +139,7 @@ export function TerminalPanel({ tab, active, onRestart, onClosed, onCloseError }
terminal.options.disableStdin = false;
setStatus("ready");
fitAndResize();
writer.resize(terminal.cols, terminal.rows);
writer.resize(Math.max(2, terminal.cols), Math.max(2, terminal.rows));
if (container.offsetWidth && container.offsetHeight) terminal.focus();
};
events.onerror = () => {
Expand Down
Loading