diff --git a/app/api/fleet/attention/route.ts b/app/api/fleet/attention/route.ts new file mode 100644 index 0000000..1b7e7d3 --- /dev/null +++ b/app/api/fleet/attention/route.ts @@ -0,0 +1,52 @@ +import { NextResponse } from "next/server" +import { mcpCallTool, FLEET_BOARD_MCP_URL } from "@/app/lib/fleet/fleetSource" + +export const dynamic = "force-dynamic" + +/** + * GET /api/fleet/attention — strukturierte Attention-Fragen. + * Ruft attention_summary() im board-service: wie viele offene Tasks warten + * wirklich auf einen MENSCHEN (Frage + Optionen), nicht nur "offen". + */ +export async function GET() { + try { + const res = await mcpCallTool(FLEET_BOARD_MCP_URL, "attention_summary", {}) + if (!res.ok) { + return NextResponse.json({ error: `attention_summary: ${res.error}` }, { status: 500 }) + } + const payload = typeof res.data === "string" ? JSON.parse(res.data) : res.data + return NextResponse.json(payload, { headers: { "Cache-Control": "no-store" } }) + } catch (err) { + return NextResponse.json( + { error: `ATTENTION_FAILED: ${err instanceof Error ? err.message : String(err)}` }, + { status: 500 } + ) + } +} + +/** + * POST /api/fleet/attention — Antwort des Owners auf eine Attention-Frage. + * Geht ueber board-service answer_attention: setzt attention.answer am Task + * und legt beim fragenden Agenten einen fyi-Reply-Task ab. + */ +export async function POST(request: Request) { + try { + const body = (await request.json()) as { task_id?: string; answer?: string } + const task_id = String(body.task_id || "").trim() + const answer = String(body.answer || "").trim() + if (!task_id || !answer) { + return NextResponse.json({ error: "task_id und answer sind Pflicht" }, { status: 400 }) + } + const res = await mcpCallTool(FLEET_BOARD_MCP_URL, "answer_attention", { task_id, answer }) + if (!res.ok) { + return NextResponse.json({ error: `answer_attention: ${res.error}` }, { status: 500 }) + } + const payload = typeof res.data === "string" ? JSON.parse(res.data) : res.data + return NextResponse.json(payload, { headers: { "Cache-Control": "no-store" } }) + } catch (err) { + return NextResponse.json( + { error: `ATTENTION_ANSWER_FAILED: ${err instanceof Error ? err.message : String(err)}` }, + { status: 500 } + ) + } +} diff --git a/app/components/Sidebar.tsx b/app/components/Sidebar.tsx index 6a78ed3..03faa26 100644 --- a/app/components/Sidebar.tsx +++ b/app/components/Sidebar.tsx @@ -14,7 +14,7 @@ type ControllerNodeRecord = { interface SidebarProps { sandboxesRunning: number sandboxesTotal: number - activeView: 'settings' | 'sandboxes' | 'help' | 'wizards' | 'mcp' | 'org' | 'messages' | 'board' | 'owner' | 'escalations' | 'approvals' | 'fleet-sandboxes' | 'tasks' | 'ops' + activeView: 'settings' | 'sandboxes' | 'help' | 'wizards' | 'mcp' | 'org' | 'messages' | 'board' | 'owner' | 'escalations' | 'approvals' | 'attention' | 'fleet-sandboxes' | 'tasks' | 'ops' isCreateMode: boolean isDestroyMode: boolean onSandboxesClick: () => void @@ -30,6 +30,8 @@ interface SidebarProps { onFleetBoardClick: () => void onFleetOwnerClick: () => void onFleetApprovalsClick: () => void + onFleetAttentionClick: () => void + onFleetEscalationsClick: () => void onFleetSandboxesClick: () => void onFleetTasksClick: () => void @@ -60,6 +62,7 @@ export default function Sidebar({ onFleetBoardClick, onFleetOwnerClick, onFleetApprovalsClick, + onFleetAttentionClick, onFleetEscalationsClick, onFleetSandboxesClick, onFleetTasksClick, @@ -318,6 +321,18 @@ export default function Sidebar({ Owner + + + ))} + + )} + +
+ setDraft((p) => ({ ...p, [it.task_id]: e.target.value }))} + placeholder="Oder eigene Antwort…" + className="min-w-0 flex-1 rounded border border-neutral-700 bg-neutral-900 px-3 py-1.5 text-sm" + /> + +
+ + ))} + + ) +} diff --git a/app/page.tsx b/app/page.tsx index da48d8e..a16d0c0 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -15,6 +15,7 @@ import MessageFeed from './components/fleet/MessageFeed' import KanbanBoard from './components/fleet/KanbanBoard' import OwnerPanel from './components/fleet/OwnerPanel' import OwnerApprovals from './components/fleet/OwnerApprovals' +import AttentionPanel from './components/fleet/AttentionPanel' import EscalationHistory from './components/fleet/EscalationHistory' import SandboxFleetView from './components/fleet/SandboxFleetView' import TaskBrowser from './components/fleet/TaskBrowser' @@ -34,7 +35,7 @@ export default function Dashboard() { const [dashboardSession, setDashboardSession] = useState(() => createHydrationSafeDashboardSessionState()) const [isCreateMode, setIsCreateMode] = useState(false) const [isDestroyMode, setIsDestroyMode] = useState(false) - const [activeView, setActiveView] = useState<'settings' | 'sandboxes' | 'help' | 'wizards' | 'mcp' | 'org' | 'messages' | 'board' | 'owner' | 'escalations' | 'approvals' | 'fleet-sandboxes' | 'tasks' | 'ops'>('org') + const [activeView, setActiveView] = useState<'settings' | 'sandboxes' | 'help' | 'wizards' | 'mcp' | 'org' | 'messages' | 'board' | 'owner' | 'escalations' | 'approvals' | 'attention' | 'fleet-sandboxes' | 'tasks' | 'ops'>('org') const [telemetryBarEnabled, setTelemetryBarEnabled] = useState(false) const [deletingSandboxId, setDeletingSandboxId] = useState(null) const [showDeleteConfirm, setShowDeleteConfirm] = useState(false) @@ -273,6 +274,12 @@ export default function Dashboard() { setIsDestroyMode(false) clearSelection() }} + onFleetAttentionClick={() => { + setActiveView('attention') + setIsCreateMode(false) + setIsDestroyMode(false) + clearSelection() + }} onFleetEscalationsClick={() => { setActiveView('escalations') setIsCreateMode(false) @@ -326,6 +333,8 @@ export default function Dashboard() { ) : activeView === 'ops' ? ( + ) : activeView === 'attention' ? ( + ) : activeView === 'approvals' ? ( ) : activeView === 'escalations' ? (