Polish tool-window methods: error format, logging, async test

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-10 21:30:06 -04:00
parent e588c62fd4
commit 3da3fc6c4c
2 changed files with 5 additions and 5 deletions
+2 -1
View File
@@ -410,6 +410,7 @@ class SessionService:
for an unknown tool, a missing binary, or a missing session/project. for an unknown tool, a missing binary, or a missing session/project.
Returns the new window_id, or None if the tmux spawn fails. Returns the new window_id, or None if the tmux spawn fails.
""" """
log.info("Opening tool window: session=%s tool=%s", session_id, tool)
spec = TOOLS.get(tool) spec = TOOLS.get(tool)
if spec is None: if spec is None:
raise ServiceError(f"Unknown tool '{tool}'") raise ServiceError(f"Unknown tool '{tool}'")
@@ -421,7 +422,7 @@ class SessionService:
raise ServiceError("Session not found") raise ServiceError("Session not found")
project = db.get(Project, sess.project_id) project = db.get(Project, sess.project_id)
if project is None: if project is None:
raise ServiceError("Project no longer exists") raise ServiceError(f"Project {sess.project_id} no longer exists")
cwd = project.path cwd = project.path
label = f"{spec.label} · {project.name}" label = f"{spec.label} · {project.name}"
return await self.tmux.open_aux_window(spec.label, cwd, spec.command, label) return await self.tmux.open_aux_window(spec.label, cwd, spec.command, label)
+3 -4
View File
@@ -1574,10 +1574,9 @@ async def test_open_tool_window_unknown_session_raises(service, monkeypatch):
await service.open_tool_window(999, "nvim") await service.open_tool_window(999, "nvim")
def test_session_id_for_window_resolves_and_misses(service, db): @pytest.mark.asyncio
import asyncio async def test_session_id_for_window_resolves_and_misses(service, db):
await service.create_session(project_id=1, harness_name="claude-code")
asyncio.run(service.create_session(project_id=1, harness_name="claude-code"))
assert service.session_id_for_window("hqt-1") == 1 assert service.session_id_for_window("hqt-1") == 1
assert service.session_id_for_window("not-an-hqt-window") is None assert service.session_id_for_window("not-an-hqt-window") is None