Skip to content

Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.

2.6 KB
Raw Blame
"""Workspace launch choices never wait for CLI version or model subprocesses."""

from __future__ import annotations

import threading

import pytest

from dodaios.ui.web import agentic_ide_routes as routes
from dodaios.workspace import agents, launch_picks


@pytest.mark.parametrize("pty_available", [False, True])
async def test_quick_catalog_resolves_off_loop_without_expensive_probes(
    monkeypatch: pytest.MonkeyPatch,
    pty_available: bool,
) -> None:
    specs = [
        agents.WorkspaceAgent(
            name="example",
            display_name="Example Agent",
            description="A custom coding agent",
            custom=True,
            logo_url="/logo.svg",
            accepts_typed_prompts=False,
        ),
        agents.WorkspaceAgent(name="missing", display_name="Missing Agent"),
        agents.WorkspaceAgent(
            name="shell", display_name="Plain Terminal", kind="shell", needs_trust=False
        ),
    ]
    by_name = {spec.name: spec for spec in specs}
    monkeypatch.setattr(agents, "list_agents", lambda: specs)
    monkeypatch.setattr(agents, "get_agent", by_name.get)
    monkeypatch.setattr(agents, "pty_available", lambda: pty_available)

    async def forbidden_probe():
        pytest.fail("The quick catalog must not execute CLI version/model probes")

    monkeypatch.setattr(agents, "detect_agents", forbidden_probe)
    monkeypatch.setattr(launch_picks, "live_models", forbidden_probe)
    event_loop_thread = threading.get_ident()
    resolved = []

    def resolve_agent(name):
        assert threading.get_ident() != event_loop_thread
        resolved.append(name)
        return (name,) if name in {"example", "shell"} else None

    monkeypatch.setattr(routes, "agent_argv", resolve_agent)
    result = await routes.get_agents(quick=True)
    assert resolved == ["example", "missing", "shell"]
    assert result.terminal_available is pty_available
    assert result.max_panes_per_request == routes.MAX_PANES_PER_REQUEST
    assert len(result.suggested_names) == routes.MAX_PANES_PER_REQUEST
    example, missing, shell = result.agents
    assert shell.installed is True
    assert shell.kind == "shell"
    assert shell.accepts_prompts is False
    assert shell.display_name == "Plain Terminal"
    assert example.installed is True
    assert missing.installed is False
    assert example.version is None
    assert example.install_command is None
    assert example.kind == "cli"
    assert example.description == "A custom coding agent"
    assert example.custom is True
    assert example.logo_url == "/logo.svg"
    assert example.accepts_prompts is False
    assert missing.accepts_prompts is True