debug: add console logging for terminal resize debugging
This commit is contained in:
@@ -164,6 +164,19 @@ class TerminalSession:
|
|||||||
).encode()
|
).encode()
|
||||||
await self.write_input(stty_cmd)
|
await self.write_input(stty_cmd)
|
||||||
logger.debug(f"Sent stty resize to container for session {self.session_id}: {cols}x{rows}")
|
logger.debug(f"Sent stty resize to container for session {self.session_id}: {cols}x{rows}")
|
||||||
|
|
||||||
|
# Docker exec doesn't forward PTY resize to the container process,
|
||||||
|
# so we need to explicitly set the size inside the container shell.
|
||||||
|
# Send on every resize so the container shell always matches the frontend.
|
||||||
|
# Use ANSI escape sequences to hide the command from view:
|
||||||
|
# - \x1b[?25l: hide cursor
|
||||||
|
# - \x1b[A\x1b[2K: move up and clear line
|
||||||
|
# - \x1b[?25h: show cursor
|
||||||
|
stty_cmd = (
|
||||||
|
f"\x1b[?25lstty cols {cols} rows {rows}\n\x1b[A\x1b[2K\x1b[?25h"
|
||||||
|
).encode()
|
||||||
|
await self.write_input(stty_cmd)
|
||||||
|
logger.debug(f"Sent stty resize to container for session {self.session_id}: {cols}x{rows}")
|
||||||
|
|
||||||
async def reset(self) -> None:
|
async def reset(self) -> None:
|
||||||
"""Reset the session by killing the process and clearing state."""
|
"""Reset the session by killing the process and clearing state."""
|
||||||
|
|||||||
@@ -216,26 +216,29 @@ export const TerminalComponent: React.FC<TerminalProps> = ({
|
|||||||
|
|
||||||
// Fit terminal and notify backend
|
// Fit terminal and notify backend
|
||||||
const fitTerminal = () => {
|
const fitTerminal = () => {
|
||||||
if (!fitAddonRef.current || !termRef.current) return;
|
if (!fitAddonRef.current || !termRef.current) {
|
||||||
|
console.log('[Terminal] fitTerminal: refs not ready');
|
||||||
|
return;
|
||||||
|
}
|
||||||
const oldCols = termRef.current.cols;
|
const oldCols = termRef.current.cols;
|
||||||
const oldRows = termRef.current.rows;
|
const oldRows = termRef.current.rows;
|
||||||
|
|
||||||
// Force layout recalculation before fit
|
console.log('[Terminal] fitTerminal called, container dims:', container?.offsetWidth, container?.offsetHeight);
|
||||||
if (container) {
|
|
||||||
void container.offsetWidth;
|
|
||||||
void container.offsetHeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
fitAddonRef.current.fit();
|
fitAddonRef.current.fit();
|
||||||
const { cols, rows } = termRef.current;
|
const { cols, rows } = termRef.current;
|
||||||
if (cols !== oldCols || rows !== oldRows) {
|
console.log('[Terminal] fitTerminal result:', cols, rows, '(was:', oldCols, oldRows + ')');
|
||||||
// Delay refresh to next frame so renderer can process resize first
|
|
||||||
requestAnimationFrame(() => {
|
// Always refresh on initial load or when dimensions change
|
||||||
termRef.current?.refresh(0, rows - 1);
|
requestAnimationFrame(() => {
|
||||||
});
|
termRef.current?.refresh(0, rows - 1);
|
||||||
}
|
});
|
||||||
|
|
||||||
if (ws.readyState === WebSocket.OPEN) {
|
if (ws.readyState === WebSocket.OPEN) {
|
||||||
|
console.log('[Terminal] Sending resize:', cols, rows);
|
||||||
ws.send(JSON.stringify({ type: "resize", cols, rows }));
|
ws.send(JSON.stringify({ type: "resize", cols, rows }));
|
||||||
|
} else {
|
||||||
|
console.log('[Terminal] WebSocket not open, state:', ws.readyState);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user