Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions tests/test_windows_subprocess_no_window_flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,3 +399,26 @@ def fake_popen(cmd, **kwargs):

assert captured[0][0][:3] == [server.sys.executable, "-m", "tui_gateway.slash_worker"]
assert captured[0][1]["creationflags"] == _CREATE_NO_WINDOW


def test_tui_slash_worker_decodes_subprocess_streams_as_utf8(monkeypatch):
from tui_gateway import server

captured = []

class _Proc:
stdin = SimpleNamespace()
stdout = []
stderr = []

def fake_popen(cmd, **kwargs):
captured.append((cmd, kwargs))
return _Proc()

monkeypatch.setattr(server.subprocess, "Popen", fake_popen)
monkeypatch.setattr(server.threading, "Thread", lambda *a, **k: SimpleNamespace(start=lambda: None))

server._SlashWorker("session-key", "model-x")

assert captured[0][1]["encoding"] == "utf-8"
assert captured[0][1]["errors"] == "replace"
2 changes: 2 additions & 0 deletions tui_gateway/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,8 @@ def __init__(self, session_key: str, model: str, profile_home: str | None = None
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True,
encoding="utf-8",
errors="replace",
bufsize=1,
cwd=os.getcwd(),
env=env,
Expand Down
Loading