fix: font stack, sparklines, and DA1 response issues

- Restore terminal.options.fontFamily assignment for proper font stack handling
- Add dynamic service registration to DockerStatsCollector for docker watch mode
- Remove force_redraw on reconnect that caused DA1 responses to display as text
This commit is contained in:
GitHub Copilot
2026-01-29 18:38:49 +00:00
parent 6ad9bc9ad0
commit 3a6f797e84
6 changed files with 75 additions and 28 deletions
+29
View File
@@ -168,6 +168,35 @@ class TestDockerStatsCollector:
assert len(collector._cpu_history["test"]) == STATS_HISTORY_SIZE
def test_add_service_dynamic(self):
"""Services can be added dynamically after start."""
collector = DockerStatsCollector("/nonexistent")
collector._service_names = ["svc1"]
collector.add_service("svc2")
assert "svc2" in collector._service_names
# Adding same service again is a no-op
collector.add_service("svc2")
assert collector._service_names.count("svc2") == 1
def test_remove_service_dynamic(self):
"""Services can be removed dynamically."""
from collections import deque
collector = DockerStatsCollector("/nonexistent")
collector._service_names = ["svc1", "svc2"]
collector._cpu_history["svc1"] = deque([10.0, 20.0])
collector._prev_cpu["svc1"] = (100, 200)
collector.remove_service("svc1")
assert "svc1" not in collector._service_names
assert "svc1" not in collector._cpu_history
assert "svc1" not in collector._prev_cpu
# Removing non-existent service is safe
collector.remove_service("nonexistent") # Should not raise
class TestLocalServerSparklineEndpoint:
"""Tests for the CPU sparkline endpoint in LocalServer."""
@@ -81,19 +81,12 @@ async def test_websocket_creates_session_on_resize(tmp_path):
await client.close()
assert created["args"] == ("test", 90, 25)
# Reconnect should trigger redraw without creating a new session
called = {"redraw": 0, "stdin": 0}
# Reconnect to an existing session should reuse it and send replay buffer
class DummySession:
def is_running(self):
return True
async def force_redraw(self):
called["redraw"] += 1
async def send_bytes(self, data: bytes):
called["stdin"] += 1
server.session_manager.routes["test"] = "sid"
server.session_manager.sessions["sid"] = DummySession()
@@ -111,9 +104,6 @@ async def test_websocket_creates_session_on_resize(tmp_path):
finally:
await client.close()
assert called["redraw"] == 1
assert called["stdin"] == 1
@pytest.mark.asyncio
async def test_websocket_ping_pong(tmp_path):