(self, args: str, context: CommandContext)
| 42 | pattern); ``run()`` returns text without touching ``ctx.ui``.""" |
| 43 | |
| 44 | async def run(self, args: str, context: CommandContext) -> InteractiveOutcome: |
| 45 | tc = getattr(context, "tool_context", None) |
| 46 | registry = getattr(tc, "runtime_tasks", None) if tc is not None else None |
| 47 | if registry is None: |
| 48 | # SDK / listing surfaces have no live task registry. |
| 49 | return InteractiveOutcome( |
| 50 | message="Background tasks are unavailable on this surface.", |
| 51 | display="system", |
| 52 | ) |
| 53 | try: |
| 54 | tasks = list(registry.all()) |
| 55 | except Exception: |
| 56 | tasks = [] |
| 57 | if not tasks: |
| 58 | return InteractiveOutcome(message="No background tasks.", display="system") |
| 59 | lines = [f"• {_format_task(t)}" for t in tasks] |
| 60 | return InteractiveOutcome( |
| 61 | message="Background tasks:\n" + "\n".join(lines), display="system" |
| 62 | ) |
| 63 | |
| 64 | |
| 65 | TASKS_COMMAND = TasksCommand( |
nothing calls this directly
no test coverage detected