diff --git a/AppImage/components/terminal-panel.tsx b/AppImage/components/terminal-panel.tsx index 5b0ded1..882519c 100644 --- a/AppImage/components/terminal-panel.tsx +++ b/AppImage/components/terminal-panel.tsx @@ -317,20 +317,23 @@ export const TerminalPanel: React.FC = ({ websocketUrl, onCl term.open(container) - setTimeout(() => { + const performResize = () => { const xtermViewport = container.querySelector(".xterm-viewport") as HTMLElement const xtermScreen = container.querySelector(".xterm-screen") as HTMLElement if (xtermViewport) xtermViewport.style.padding = "0" if (xtermScreen) xtermScreen.style.padding = "0" + fitAddon.fit() - console.log(`[v0] Terminal fitted: ${term.cols}x${term.rows}`) + const cols = term.cols + const rows = term.rows + console.log(`[v0] Terminal resized: ${cols}x${rows}`) // Send resize to backend via HTTP const apiUrl = getApiUrl() fetch(`${apiUrl}/api/terminal/${terminal.id}/resize`, { method: "POST", headers: { "Content-Type": "application/json" }, - body: JSON.stringify({ cols: term.cols, rows: term.rows }), + body: JSON.stringify({ cols, rows }), }) .then((res) => res.json()) .then((data) => { @@ -339,7 +342,11 @@ export const TerminalPanel: React.FC = ({ websocketUrl, onCl .catch((err) => { console.error(`[v0] Error resizing backend PTY:`, err) }) - }, 100) + } + + setTimeout(() => performResize(), 100) + setTimeout(() => performResize(), 300) + setTimeout(() => performResize(), 600) const wsUrl = websocketUrl || getWebSocketUrl() const ws = new WebSocket(wsUrl) @@ -347,6 +354,9 @@ export const TerminalPanel: React.FC = ({ websocketUrl, onCl ws.onopen = () => { setTerminals((prev) => prev.map((t) => (t.id === terminal.id ? { ...t, isConnected: true, term, ws } : t))) term.writeln("\x1b[32mConnected to ProxMenux terminal.\x1b[0m") + + setTimeout(() => performResize(), 200) + setTimeout(() => performResize(), 500) } ws.onmessage = (event) => { @@ -372,20 +382,7 @@ export const TerminalPanel: React.FC = ({ websocketUrl, onCl const handleResize = () => { try { - fitAddon.fit() - const cols = term.cols - const rows = term.rows - console.log(`[v0] Window resized, terminal now: ${cols}x${rows}`) - - // Send resize to backend via HTTP - const apiUrl = getApiUrl() - fetch(`${apiUrl}/api/terminal/${terminal.id}/resize`, { - method: "POST", - headers: { "Content-Type": "application/json" }, - body: JSON.stringify({ cols, rows }), - }).catch((err) => { - console.error(`[v0] Error resizing backend PTY:`, err) - }) + performResize() } catch { // Ignore resize errors } @@ -613,25 +610,36 @@ export const TerminalPanel: React.FC = ({ websocketUrl, onCl ))} ) : ( -
+
{terminals.map((terminal) => ( -
-
- +
setActiveTerminalId(terminal.id)} + > +
+ {terminal.title} {terminals.length > 1 && ( - + )}
-
+
))}