Build a rich panel showing task checklist.
(queue)
| 156 | _task_live = None |
| 157 | |
| 158 | def _build_task_panel(queue): |
| 159 | """Build a rich panel showing task checklist.""" |
| 160 | from core.taskqueue import STATUS_DONE, STATUS_RUNNING, STATUS_FAILED, STATUS_PENDING |
| 161 | text = Text.from_markup('') |
| 162 | for t in queue.tasks: |
| 163 | if t.status == STATUS_DONE: |
| 164 | icon = '[green]✓[/green]' # markup |
| 165 | style = 'dim' |
| 166 | elif t.status == STATUS_RUNNING: |
| 167 | icon = '[cyan]⠸[/cyan]' # markup |
| 168 | style = 'bold' |
| 169 | elif t.status == STATUS_FAILED: |
| 170 | icon = '[red]✗[/red]' # markup |
| 171 | style = 'red' |
| 172 | else: |
| 173 | icon = '[dim]☐[/dim]' # markup |
| 174 | style = 'dim' |
| 175 | done = queue.done_count() |
| 176 | total = len(queue.tasks) |
| 177 | line = f' {icon} {t.id}. {t.description[:50]}' |
| 178 | if t.status == STATUS_DONE and t.result: |
| 179 | line += f' [dim]→ {t.result[:40]}[/dim]' |
| 180 | text.append_text(Text.from_markup(line + '\n')) |
| 181 | done = queue.done_count() |
| 182 | total = len(queue.tasks) |
| 183 | title = f'Task Plan [dim]{done}/{total}[/dim]' |
| 184 | return Panel(text, title=title, border_style='cyan', box=box.ROUNDED) |
| 185 | |
| 186 | def show_task_plan(queue): |
| 187 | """Print initial task plan (static).""" |
no test coverage detected