mirror of
https://github.com/multica-ai/multica.git
synced 2026-07-31 00:40:46 +02:00
Two fixes for Emacs Round 2 findings:
1. Desktop TerminalPanel now sends `{type:"auth", payload:{token}}` as
the first WS frame in token mode and waits for `auth_ack`. Previously
it transitioned straight to "connected" without authing, so the
server's 10s first-frame deadline closed the connection and the
terminal never opened. Cookie-mode apps still skip the handshake.
Exposes ApiClient.getToken() so the panel can snapshot the bearer
without reaching into auth-store internals.
2. terminalBridge.handleOpen no longer treats `terminal.opened` as a
droppable control frame. sendFrame now returns bool; if the ack
can't be enqueued the bridge rolls the half-open session back
(cancel ctx, drop the route, sess.Close) so the spawned PTY doesn't
orphan until the idle sweep — which also pinned the GC active-env
mark for that window.
Regression coverage:
- TestTerminalBridge_OpenedEnqueueFailureClosesSession: drop-only
sender, spawn must happen exactly once, manager and bridge route map
must drain to zero.
- packages/views/issues/components/terminal-panel.test.tsx: asserts
the auth frame is sent in token mode and NOT sent in cookie mode.
Co-authored-by: multica-agent <github@multica.ai>