hermes-agent/tests/test_dashboard_sidecar_close_on_disconnect.py
Austin Pickett 0bbf325a8f
fix(dashboard): scope chat sidebar model card to selected profile (#46665)
* fix(dashboard): scope chat sidebar model card to selected profile

The PTY already honors ?profile= on profile switch, but the JSON-RPC
sidecar created sessions against the dashboard launch profile. Pass the
management profile through session.create and reconnect on switch.

Co-authored-by: Cursor <cursoragent@cursor.com>

* fix(dashboard): sync active profile with management scope

Align the sidebar switcher with the sticky active profile on load and
when "Set as active" is clicked, so Chat and management pages match
what the Profiles page shows as active.

Co-authored-by: Cursor <cursoragent@cursor.com>

* fix(dashboard): auto-reconnect chat sidebar on profile switch

Bump the sidecar connection version when profile or PTY channel changes,
matching the manual Reconnect path so gateway and events sockets come
back without clicking the error banner.

Co-authored-by: Cursor <cursoragent@cursor.com>

* fix(dashboard): prevent model selector chevron overlapping label

Use inline flex layout instead of Button suffix, which is absolutely
positioned and overlapped truncated model names at px-0.

Co-authored-by: Cursor <cursoragent@cursor.com>

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-15 12:50:19 -04:00

26 lines
1.0 KiB
Python

import re
from pathlib import Path
CHAT_SIDEBAR = Path(__file__).resolve().parent.parent / "web/src/components/ChatSidebar.tsx"
def test_sidecar_session_create_requests_close_on_disconnect():
"""The sidecar must opt its session into close_on_disconnect so the gateway
reaps the slash_worker on WS disconnect (the #21370/#21467 leak)."""
source = CHAT_SIDEBAR.read_text(encoding="utf-8")
call = re.search(r'"session\.create",\s*\{(.*?)\}', source, re.DOTALL)
assert call, "sidecar session.create call not found"
assert re.search(r"close_on_disconnect:\s*true", call.group(1))
def test_sidecar_session_create_scopes_profile():
"""The sidecar must pass the dashboard's selected profile so model/credential
info matches the PTY child under profile-scoped chat."""
source = CHAT_SIDEBAR.read_text(encoding="utf-8")
assert '"session.create"' in source
assert re.search(
r"close_on_disconnect:\s*true,\s*\.\.\.\(profile\s*\?\s*\{\s*profile\s*\}\s*:\s*\{\}\)",
source,
re.DOTALL,
)