Compare commits

...

3 Commits

Author SHA1 Message Date
Fusion 9c57a94e9f Merge branch 'dev' of ssh://git.commumedia.org:2222/alex/headquarter into dev 2026-05-24 23:21:28 +02:00
Fusion 84b7b64ec0 fix: change mobile terminal wrapper from grid to flexbox
Grid layout was not properly sizing the content area, causing 0 height.
Flexbox with flex: 1 on content area ensures proper filling.
2026-05-24 23:20:51 +02:00
Fusion 9e88acaa36 fix: remove 0-dimension check blocking terminal fit and add debug logging
- Remove chicken-and-egg check that prevented fit() when cols/rows were 0
- Add console logging for container dimensions and fit results
- Add retry limit (50 attempts) for initial fit to prevent infinite loops
2026-05-24 23:15:15 +02:00
2 changed files with 14 additions and 9 deletions
+12 -7
View File
@@ -246,8 +246,6 @@ export const TerminalComponent: React.FC<TerminalProps> = ({
// Define fitTerminal before connectWebSocket so it's available in onmessage
const fitTerminal = () => {
if (!fitAddonRef.current || !termRef.current) return;
// Ensure terminal is opened and has valid dimensions
if (termRef.current.cols === 0 || termRef.current.rows === 0) return;
const oldCols = termRef.current.cols;
const oldRows = termRef.current.rows;
try {
@@ -257,8 +255,9 @@ export const TerminalComponent: React.FC<TerminalProps> = ({
return;
}
const { cols, rows } = termRef.current;
// Force refresh if dimensions changed and are valid
if ((cols !== oldCols || rows !== oldRows) && cols > 0 && rows > 0) {
console.log(`[Terminal] fit() result: ${cols}x${rows} (was ${oldCols}x${oldRows})`);
// Force refresh if dimensions are valid
if (cols > 0 && rows > 0) {
try {
termRef.current.refresh(0, rows - 1);
} catch {
@@ -266,7 +265,7 @@ export const TerminalComponent: React.FC<TerminalProps> = ({
}
}
const currentWs = wsRef.current;
if (currentWs?.readyState === WebSocket.OPEN) {
if (currentWs?.readyState === WebSocket.OPEN && cols > 0 && rows > 0) {
currentWs.send(JSON.stringify({ type: "resize", cols, rows }));
}
};
@@ -276,14 +275,20 @@ export const TerminalComponent: React.FC<TerminalProps> = ({
ws = connectWebSocket();
// Initial fit after layout settles (terminal must be opened first)
let fitAttempts = 0;
const doInitialFit = () => {
if (!container.isConnected) return;
fitAttempts++;
// Ensure container has dimensions before fitting
if (container.clientWidth > 0 && container.clientHeight > 0) {
console.log(`[Terminal] Container ready: ${container.clientWidth}x${container.clientHeight} (attempt ${fitAttempts})`);
fitTerminal();
} else {
// Container not ready yet, try again
} else if (fitAttempts < 50) {
// Container not ready yet, try again (max 50 attempts ~ 1s)
console.log(`[Terminal] Container not ready: ${container.clientWidth}x${container.clientHeight} (attempt ${fitAttempts})`);
requestAnimationFrame(doInitialFit);
} else {
console.warn(`[Terminal] Container never got dimensions after ${fitAttempts} attempts`);
}
};
requestAnimationFrame(doInitialFit);
+2 -2
View File
@@ -3122,8 +3122,8 @@ a.nav-item,
}
.mobile-terminal-wrapper {
display: grid;
grid-template-rows: auto 1fr auto;
display: flex;
flex-direction: column;
height: 100%;
min-height: 0;
background: #1e1e1e;