Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:23blocks OS Ai maestro Use Open Tasks Hook

From Leeroopedia
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>)}
    </>
  )
}

Related Pages

Implements Principle

Requires Environment

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment