from __future__ import annotations

from app.modules.agent.task_runtime.models import TaskRuntimeContext


def emit_status_block(
    ctx: TaskRuntimeContext,
    *,
    block_id: str,
    title: str,
    lines: list[str],
    append: bool = False,
) -> None:
    if ctx.progress_cb is None:
        return
    ctx.progress_cb(
        f"status.{block_id}",
        title,
        "task_progress",
        {
            "status_block": {
                "id": block_id,
                "title": title,
                "lines": [line for line in lines if str(line).strip()],
                "append": append,
            }
        },
    )
