90944948f5
TUI for orchestrating AI coding harness sessions (Claude Code, Codex, Kiro, etc.) via tmux. Click CLI bootstraps a Textual TUI over ProjectService/SessionService backed by SQLite, spawning harness sessions as tmux windows through TmuxManager. Includes recent fixes: - Visible Tab focus highlight on dialog OK/Cancel buttons - Auto-select first project on launch - Auto-select first session + per-project session-selection memory - tmux new-window targets an explicit free index, fixing "index N in use" failures (broken spawn/attach in attached sessions) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
73 lines
2.0 KiB
Python
73 lines
2.0 KiB
Python
from pathlib import Path
|
|
from sqlalchemy import inspect
|
|
from sqlalchemy.orm import Session as DbSession
|
|
|
|
from hqt.config import Settings
|
|
from hqt.db.engine import ensure_db, get_engine, get_session_factory
|
|
from hqt.db.models import Harness, Project, Session
|
|
|
|
|
|
def _tmp_settings(tmp_path: Path) -> Settings:
|
|
return Settings(db_path=tmp_path / "test.db")
|
|
|
|
|
|
def test_ensure_db_creates_tables(tmp_path):
|
|
settings = _tmp_settings(tmp_path)
|
|
ensure_db(settings)
|
|
engine = get_engine(settings)
|
|
tables = inspect(engine).get_table_names()
|
|
assert "projects" in tables
|
|
assert "sessions" in tables
|
|
assert "harnesses" in tables
|
|
assert "mcp_servers" in tables
|
|
assert "project_mcp_servers" in tables
|
|
assert "project_skills" in tables
|
|
|
|
|
|
def test_project_crud(tmp_path):
|
|
settings = _tmp_settings(tmp_path)
|
|
ensure_db(settings)
|
|
engine = get_engine(settings)
|
|
factory = get_session_factory(engine)
|
|
|
|
with factory() as session:
|
|
p = Project(name="test", path="/tmp/test")
|
|
session.add(p)
|
|
session.commit()
|
|
assert p.id is not None
|
|
|
|
p.name = "updated"
|
|
session.commit()
|
|
|
|
fetched = session.get(Project, p.id)
|
|
assert fetched.name == "updated"
|
|
|
|
session.delete(fetched)
|
|
session.commit()
|
|
assert session.get(Project, p.id) is None
|
|
|
|
|
|
def test_session_with_fk(tmp_path):
|
|
settings = _tmp_settings(tmp_path)
|
|
ensure_db(settings)
|
|
engine = get_engine(settings)
|
|
factory = get_session_factory(engine)
|
|
|
|
with factory() as session:
|
|
p = Project(name="proj", path="/tmp/proj")
|
|
h = Harness(name="claude-code")
|
|
session.add_all([p, h])
|
|
session.commit()
|
|
|
|
s = Session(
|
|
project_id=p.id,
|
|
harness_id=h.id,
|
|
tmux_session_name="hqt-test-1",
|
|
)
|
|
session.add(s)
|
|
session.commit()
|
|
|
|
assert s.project.name == "proj"
|
|
assert s.harness.name == "claude-code"
|
|
assert s in p.sessions
|