debug: add switchToTerminal logging and fitAddon error handling
- Log when switchToTerminal is called and if terminal is in map - Log fitAddon.fit() execution with error handling - Log when switchToTerminal completes This will help identify if switchToTerminal is causing the WebSocket closure
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -1140,6 +1140,8 @@ class TerminalManager {
|
||||
* Switch to specific terminal
|
||||
*/
|
||||
async switchToTerminal(terminalId) {
|
||||
this.debugLog('INIT', `switchToTerminal called for ${terminalId}, checking if terminal in map...`);
|
||||
|
||||
// Hide all containers and remove active class
|
||||
document.querySelectorAll('.terminal-container').forEach(c => {
|
||||
c.classList.remove('active');
|
||||
@@ -1159,13 +1161,27 @@ class TerminalManager {
|
||||
|
||||
// Initialize xterm.js if not already done
|
||||
if (!this.terminals.has(terminalId)) {
|
||||
this.debugLog('INIT', `Terminal ${terminalId} NOT in map, calling initializeXTerm...`);
|
||||
await this.initializeXTerm(terminalId);
|
||||
} else {
|
||||
this.debugLog('INIT', `Terminal ${terminalId} already in map, skipping initialization`);
|
||||
}
|
||||
|
||||
// Fit terminal
|
||||
const terminal = this.terminals.get(terminalId);
|
||||
if (terminal && terminal.fitAddon) {
|
||||
setTimeout(() => terminal.fitAddon.fit(), 100);
|
||||
this.debugLog('INIT', `Calling fitAddon.fit() for ${terminalId} in 100ms...`);
|
||||
setTimeout(() => {
|
||||
this.debugLog('INIT', `Executing fitAddon.fit() for ${terminalId}`);
|
||||
try {
|
||||
terminal.fitAddon.fit();
|
||||
this.debugLog('INIT', `fitAddon.fit() completed for ${terminalId}`);
|
||||
} catch (error) {
|
||||
this.debugLog('ERROR', `fitAddon.fit() failed for ${terminalId}`, { error: error.message });
|
||||
}
|
||||
}, 100);
|
||||
} else {
|
||||
this.debugLog('INIT', `No fitAddon for terminal ${terminalId} (terminal=${!!terminal}, fitAddon=${!!terminal?.fitAddon})`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1175,6 +1191,7 @@ class TerminalManager {
|
||||
tab.classList.add('active');
|
||||
}
|
||||
|
||||
this.debugLog('INIT', `switchToTerminal completed for ${terminalId}`);
|
||||
this.activeTerminalId = terminalId;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user