359afb3a59
Infrastructure configs for GMKtec K11 (Docker, vLLM, LocalAI, ComfyUI, control-plane, gpu-fan agent, Server UI with CLI/file explorer/GPU fan curve). Co-authored-by: Cursor <cursoragent@cursor.com>
66 lines
2.3 KiB
Markdown
66 lines
2.3 KiB
Markdown
# Server UI CLI — bugfix (pusty terminal)
|
|
|
|
**Data:** 2026-07-05
|
|
**Status:** naprawione
|
|
|
|
## Symptom
|
|
|
|
- Zakładka **CLI** pusta (`cli-terminal-wrap` bez zawartości)
|
|
- Przycisk **Połącz ponownie** bez efektu
|
|
- Inne zakładki (Stacki, Pliki, GPU Fan) działają z tym samym API Key
|
|
- **Sprawdź klucz** zwraca „Klucz poprawny”
|
|
|
|
## Root cause
|
|
|
|
Błąd JavaScript w [`stacks/server-ui/static/index.html`](../stacks/server-ui/static/index.html) — `connectCli()`:
|
|
|
|
```javascript
|
|
cliFitAddon = new FitAddon(); // TypeError: FitAddon is not a constructor
|
|
```
|
|
|
|
Bundel UMD [`addon-fit.min.js`](../stacks/server-ui/static/vendor/xterm/addon-fit.min.js) eksportuje **obiekt modułu** `{ FitAddon: class }`, nie samą klasę na `window.FitAddon`.
|
|
|
|
Wywołanie rzuca wyjątek **przed** `cliTerm.open()` → pusty kontener, WebSocket nigdy nie startuje.
|
|
|
|
Auth WebSocket (`?api_key=`) nie był przyczyną — HTTP API używa tego samego klucza i działało.
|
|
|
|
## Fix
|
|
|
|
1. **`createFitAddon()`** — obsługa obu wariantów UMD:
|
|
- `new FitAddon()` (gdy global to klasa)
|
|
- `new FitAddon.FitAddon()` (aktualny bundel)
|
|
2. **`try/catch`** w `connectCli()` — błąd widoczny w `#cli-status`
|
|
3. **Sprawdzenie** `typeof Terminal === 'function'`
|
|
4. **Fallback** bez FitAddon: `cols: 80`, `rows: 24`, `#cli-terminal { min-height: 360px }`
|
|
5. **Reconnect** po udanym `verifyApiKey()` na zakładce CLI
|
|
6. **Czytelne komunikaty** `cliWs.onclose` (kod 1008, zły klucz, CLI disabled)
|
|
|
|
## Weryfikacja
|
|
|
|
```bash
|
|
# Deploy
|
|
rsync -a --exclude '.venv' --exclude '__pycache__' stacks/server-ui/ /opt/server-ui/
|
|
sudo systemctl restart server-ui
|
|
|
|
# WebSocket (wymaga websockets / wscat)
|
|
API_KEY=$(sudo grep ^API_KEY= /opt/control-plane/.env | cut -d= -f2)
|
|
# python -c z websockets → echo hello-cli-test
|
|
```
|
|
|
|
**UI:**
|
|
|
|
1. `http://<IP>:8091/#cli` + API Key → **Zapisz** → **Sprawdź klucz**
|
|
2. Prompt bash widoczny, `echo test` działa
|
|
3. **Połącz ponownie** → nowa sesja OK
|
|
4. Zły klucz → komunikat w statusie (nie pusty ekran)
|
|
|
|
## Pliki zmienione
|
|
|
|
| Plik | Zmiana |
|
|
|------|--------|
|
|
| `stacks/server-ui/static/index.html` | createFitAddon, try/catch, WS messages, CSS |
|
|
| `manual-tutorial/10-server-ui-cli.md` | troubleshooting pustego CLI |
|
|
| `coding-agent/SERVER-UI-CLI.md` | link do tego raportu |
|
|
|
|
Tutorial użytkownika: [`manual-tutorial/10-server-ui-cli.md`](../manual-tutorial/10-server-ui-cli.md)
|