From 13533cdb4fd4ee430058c01cce8acd19c79bc4d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=B6n?= Date: Mon, 2 Nov 2026 08:35:28 +0000 Subject: [PATCH] =?UTF-8?q?Tower:=20View=20'Wartet=20auf=20mich'=20?= =?UTF-8?q?=E2=80=94=20strukturierte=20Attention-Fragen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Der Rueckstau war bisher eine Zahl ('94 offene Tasks'). Diese View zeigt nur Tasks mit attention-Block, also die, bei denen ein Agent ohne eine Mensch-Entscheidung nicht weiterkommt. - /api/fleet/attention: GET ruft attention_summary, POST ruft answer_attention. - AttentionPanel: Frage, Optionen als Buttons, Freitextfeld, Rueckmeldung (OK / OK_ALREADY / OK_JOURNAL_ONLY), Poll 10 s, fail loud. - Sidebar-View 'attention' + Verdrahtung in page.tsx. Die Antwort geht ueber board-service answer_attention: Frage wird am Task geschlossen (answered_at) und der Agent bekommt einen fyi-Reply-Task mit reply_to. Kein Chat, kein Bauauftrag. --- app/api/fleet/attention/route.ts | 52 ++++++ app/components/Sidebar.tsx | 17 +- app/components/fleet/AttentionPanel.tsx | 204 ++++++++++++++++++++++++ app/page.tsx | 11 +- 4 files changed, 282 insertions(+), 2 deletions(-) create mode 100644 app/api/fleet/attention/route.ts create mode 100644 app/components/fleet/AttentionPanel.tsx 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' ? (