621e8895c9
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
91 lines
3.1 KiB
Markdown
91 lines
3.1 KiB
Markdown
---
|
|
id: "0131"
|
|
title: "Modulo C++ chat_panel — panel ImGui para chat con agentes"
|
|
status: pendiente
|
|
type: app
|
|
domain:
|
|
- cpp-stack
|
|
- agents
|
|
- dev-ux
|
|
scope: cross-stack
|
|
priority: alta
|
|
depends:
|
|
- "0113"
|
|
blocks: []
|
|
related:
|
|
- "0130"
|
|
created: 2026-05-22
|
|
updated: 2026-05-22
|
|
tags: [cpp, imgui, agents, chat, module, sse]
|
|
flow: ""
|
|
---
|
|
|
|
# 0131 — Modulo C++ chat_panel
|
|
|
|
**Status:** pendiente
|
|
|
|
## Por que
|
|
|
|
Tras lanzar un agente desde kanban_cpp (issue 0130), no hay forma de interactuar con el desde la propia app. Hoy el flujo es: lanzar agente, abrir terminal aparte, `tail -f /tmp/wt-.../agent.log`. Queremos un panel C++ reutilizable que cualquier app embebra para chatear con un agente (Claude headless o futuros) y ver su output en streaming.
|
|
|
|
## Que entrega
|
|
|
|
Modulo `cpp/functions/viz/chat_panel/` (paquete del registry, kind: function, lang: cpp, domain: viz). API:
|
|
|
|
```cpp
|
|
namespace fn_chat {
|
|
struct ChatPanel {
|
|
// run_id del agent_runner_api; null = panel vacio "no agent attached"
|
|
std::string run_id;
|
|
std::string backend_url = "http://127.0.0.1:8486"; // agent_runner_api
|
|
bool auto_scroll = true;
|
|
};
|
|
void render(ChatPanel& panel);
|
|
}
|
|
```
|
|
|
|
Comportamiento:
|
|
- Conecta SSE `/api/runs/<run_id>/sse` en background thread (reusa `sse_client_cpp_core`).
|
|
- Parsea eventos `state`, `log`, `evidence`, `finish` y los renderiza:
|
|
- `log` → linea cruda en buffer scrollable.
|
|
- `state` → badge superior con status (`pending/running/done/aborted/failed`).
|
|
- `evidence` → chip lateral con kind + payload_url.
|
|
- `finish` → marca run terminada, deja conexion para ver historico.
|
|
- Input box inferior (multiline) + boton "Send". POST a `/api/runs/<run_id>/message` (endpoint A IMPLEMENTAR en agent_runner_api — extension paralela; si no existe, boton se deshabilita).
|
|
- Toolbar: `Abort run`, `Clear buffer`, `Show evidence panel`.
|
|
|
|
## Estructura
|
|
|
|
```
|
|
cpp/functions/viz/chat_panel/
|
|
chat_panel.h
|
|
chat_panel.cpp
|
|
chat_panel.md
|
|
chat_panel_test.cpp
|
|
```
|
|
|
|
## Reusa del registry
|
|
|
|
- `sse_client_cpp_core` — SSE async.
|
|
- `http_request_cpp_core` — POST mensajes / abort.
|
|
- `selectable_text_cpp_viz` — copy log lines.
|
|
- `data_table_cpp_viz` — opcional para tabla de evidencias.
|
|
|
|
## DoD
|
|
|
|
- Modulo compila en Linux + Windows.
|
|
- Demo en `primitives_gallery` o app dedicada `agent_chat_demo` con run_id fijo + mock SSE feeder.
|
|
- Integracion en kanban_cpp v2: nuevo panel "Chat" que se abre al hacer click en card con agent_active, run_id se pasa automatico.
|
|
- `e2e_checks`: smoke con mock SSE; assertion: tras emitir 3 eventos de log, panel los muestra en orden.
|
|
|
|
## Anti-scope (v1)
|
|
|
|
- No persiste history local (refresh = perdemos buffer; agent.log es la fuente).
|
|
- No syntax highlight markdown / codigo.
|
|
- Sin multi-run (un panel = un run).
|
|
- Sin file diff inline (kind:evidence con kind:diff queda como link a `git show`).
|
|
|
|
## Notas
|
|
|
|
Si el endpoint POST `/api/runs/:id/message` no existe en agent_runner_api, abrir issue paralelo `0131b` para anadirlo (claude headless aceptara mensajes via stdin del subprocess — el runner debe forwardearlos). Para v1 se acepta panel read-only.
|