Implementation:23blocks OS Ai maestro Use Open Tasks Hook
| Knowledge Sources | |
|---|---|
| Domains | UI, Task_Management |
| Last Updated | 2026-10-26 18:00 GMT |
Overview
Concrete tool for fetching every open card across every host in the mesh every 15 seconds, tracking unreachable hosts, provided by AI Maestro's `hooks/useOpenTasks.ts`.
Description
The useOpenTasks hook aggregates open cards (kanban tasks) across all hosts in the mesh. It calls `GET /api/tasks` on each host concurrently (8s timeout), tags each card with its host, and flattens the results. A host that is down contributes nothing and is named in `unreachable`, so an empty list is never mistaken for "no work". The hook polls every 15 seconds. With no host list yet, it falls back to the local host.
Usage
Call with the `hosts` array. Read `cards` (MeshCard[]), `unreachable` (string[]), `loading`.
Code Reference
Source Location
- Repository: ai-maestro
- File: hooks/useOpenTasks.ts
- Lines: L1-L53
Signature
export type MeshCard = TaskWithDeps & { agentId: string; agentName: string; hostId: string; hostName: string; hostBase: string }
export function useOpenTasks(hosts: Host[]): {
cards: MeshCard[]
unreachable: string[]
loading: boolean
refresh: () => Promise<void>
}
Import
import { useOpenTasks } from '@/hooks/useOpenTasks'
I/O Contract
| Name | Type | Description |
|---|---|---|
| cards | MeshCard[] | All open cards across all hosts |
| unreachable | string[] | Hosts that did not respond |
| loading | boolean | True during initial fetch |
Usage Examples
import { useOpenTasks } from '@/hooks/useOpenTasks'
function OpenCards({ hosts }) {
const { cards, unreachable, loading } = useOpenTasks(hosts)
if (loading) return <p>Loading…</p>
return (
<>
{unreachable.length > 0 && <p>Unreachable: {unreachable.join(', ')}</p>}
{cards.map(c => <div key={c.id}>{c.agentName}: {c.subject}</div>)}
</>
)
}