Skip to content

task_display

task_display

Presentation tables for task lifecycle, mode, and project badges.

Maps the domain status keys produced by effective_status (and the mode/security-class strings carried by project metadata) to display attributes — emoji, color, label.

Domain logic (TaskState, effective_status, container_name, has_gpu) lives in task_state.

STATUS_DISPLAY = {'running': StatusInfo(label='running', emoji='🟢', color='green'), 'init': StatusInfo(label='init', emoji='🟡', color='yellow'), 'starting': StatusInfo(label='starting', emoji='⏳', color='yellow'), 'stopped': StatusInfo(label='stopped', emoji='🔴', color='red'), 'completed': StatusInfo(label='completed', emoji='✅', color='green'), 'failed': StatusInfo(label='failed', emoji='❌', color='red'), 'created': StatusInfo(label='created', emoji='🆕', color='yellow'), 'not found': StatusInfo(label='not found', emoji='❓', color='yellow'), 'deleting': StatusInfo(label='deleting', emoji='🧹', color='yellow')} module-attribute

MODE_DISPLAY = {'cli': ModeInfo(emoji='💻', label='CLI'), 'run': ModeInfo(emoji='🚀', label='Autopilot'), 'toad': ModeInfo(emoji='🐸', label='Toad'), None: ModeInfo(emoji='🦗', label='')} module-attribute

SECURITY_CLASS_DISPLAY = {'gatekeeping': ProjectBadge(emoji='🚪', label='gate'), 'online': ProjectBadge(emoji='🌐', label='online')} module-attribute

ISOLATION_DISPLAY = {'shared': ProjectBadge(emoji='📂', label='shared'), 'sealed': ProjectBadge(emoji='🔒', label='sealed')} module-attribute

GPU_DISPLAY = {True: ProjectBadge(emoji='🎮', label='GPU'), False: ProjectBadge(emoji='💿', label='CPU')} module-attribute

StatusInfo(label, emoji, color) dataclass

Display attributes for a task effective status.

label instance-attribute

emoji instance-attribute

color instance-attribute

ModeInfo(emoji, label) dataclass

Display attributes for a task mode.

emoji instance-attribute

label instance-attribute

ProjectBadge(emoji, label) dataclass

Display attributes for a project-level badge (security class, GPU, etc.).

emoji instance-attribute

label instance-attribute

mode_info(mode)

Return the display info for a task mode string.

Source code in src/terok/lib/core/task_display.py
def mode_info(mode: str | None) -> ModeInfo:
    """Return the display info for a task mode string."""
    info = MODE_DISPLAY.get(mode if isinstance(mode, str) else None)
    return info if info else MODE_DISPLAY[None]