fix: terminal WebSocket connection — manage xterm containers in JS

- Remove Alpine x-for template for xterm containers (async rendering bug)
- Add static #xterm-wrapper div, JS creates/removes container elements directly
- addTab() uses document.createElement + appendChild for instant DOM
- switchTab() toggles display:block/none, closeTab() removes from DOM
- Add console.log for WebSocket open/close/error debugging
- Terminal now connects on page load
This commit is contained in:
swanadiva
2026-07-09 19:28:15 +07:00
parent 71864336f6
commit d5406eab6c
3 changed files with 90 additions and 88 deletions
+2 -10
View File
@@ -49,16 +49,8 @@
</div>
</div>
<!-- xterm.js containers — one per tab, shown/hidden by Alpine -->
<div class="flex-1 relative min-h-0">
<template x-for="(tab, idx) in tabs" :key="tab.id">
<div x-show="idx === activeTab"
x-cloak
class="absolute inset-0">
<div :id="'xterm-' + tab.id" class="w-full h-full"></div>
</div>
</template>
</div>
<!-- xterm.js containers — managed by JS, not Alpine -->
<div id="xterm-wrapper" class="flex-1 relative min-h-0"></div>
<!-- Input prompt -->
<form @submit.prevent="submitCommand()"