fix: terminal WebSocket connection timing + better mock fallback
- Fix xterm.js container not found: use requestAnimationFrame retry loop instead of single $nextTick (Alpine x-for renders asynchronously) - Better mock fallback: use host name+IP instead of raw UUID - Add logging for WebSocket connection path (found/not-found/hostname)
This commit is contained in:
@@ -108,13 +108,16 @@ document.addEventListener('alpine:init', () => {
|
||||
|
||||
this._createTerminal(id, host.name);
|
||||
|
||||
this.$nextTick(() => {
|
||||
const tryOpen = (retries) => {
|
||||
const container = document.getElementById('xterm-' + id);
|
||||
if (container) {
|
||||
this.terminals[id].open(container);
|
||||
this._connectWebSocket(id, host.id, host.name);
|
||||
} else if (retries > 0) {
|
||||
requestAnimationFrame(() => tryOpen(retries - 1));
|
||||
}
|
||||
});
|
||||
};
|
||||
this.$nextTick(() => tryOpen(10));
|
||||
},
|
||||
|
||||
switchTab(i) {
|
||||
|
||||
Reference in New Issue
Block a user