Files
fn_registry/dev/issues/0132-cpp-module-terminal-panel.md
T
egutierrez fe65c5e527 feat(infra): auto-commit con 86 cambios
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-26 19:38:15 +02:00

3.1 KiB

id, title, status, type, domain, scope, priority, depends, blocks, related, created, updated, tags, flow
id title status type domain scope priority depends blocks related created updated tags flow
0132 Modulo C++ terminal_panel — emulador TTY ImGui embebible pendiente app
cpp-stack
dev-ux
apps-infra
cross-stack alta
0130
0131
2026-05-22 2026-05-22
cpp
imgui
terminal
pty
module

0132 — Modulo C++ terminal_panel

Status: pendiente

Por que

Apps del ecosistema (kanban_cpp, services_monitor, agents_dashboard) necesitan ver output crudo de comandos shell sin abrir un terminal externo. Tipico: tail de un log, watch de un curl, ejecutar git status rapido. Solucion estandar: modulo terminal_panel reusable que arranca un shell hijo via PTY y lo renderiza en ImGui.

Que entrega

Modulo cpp/functions/viz/terminal_panel/:

namespace fn_term {
    struct TerminalPanel {
        std::string shell;          // "/bin/bash" linux, "powershell.exe" windows; default auto
        std::string cwd;             // working dir; default = current
        std::vector<std::string> env; // KEY=VAL extras
        int  scrollback_lines = 5000;
        bool readonly = false;       // true = no input forwarding (tail-only)
    };
    void open(TerminalPanel& panel);  // crea proceso hijo + PTY
    void render(TerminalPanel& panel);
    void send(TerminalPanel& panel, const std::string& text);  // stdin
    void close(TerminalPanel& panel);
}

Implementacion:

  • Linux: forkpty + read/write non-blocking en background thread.
  • Windows: ConPTY (CreatePseudoConsole) + ReadFile en thread.
  • Buffer circular scrollback_lines filas; render con ImGui::TextUnformatted por chunk para minimizar costo.
  • Soporte minimo de ANSI: cursor pos, color FG/BG basico (16 colores), clear screen. NO soporte completo (no Vim, no top, no curses pesado).
  • Toolbar: clear, copy selection, reset shell, scroll-to-bottom.

Estructura

cpp/functions/viz/terminal_panel/
  terminal_panel.h
  terminal_panel.cpp
  terminal_panel.md
  terminal_panel_linux.cpp   // forkpty path
  terminal_panel_windows.cpp // ConPTY path
  terminal_panel_test.cpp

Reusa del registry

  • logger_cpp_core (fn_log) — log errores spawn/io.
  • ansi_parser_cpp_core — si existe, parsear secuencias ANSI. Si no, delegar a fn-constructor para crearlo dentro de este issue (sub-deliverable).

DoD

  • Compila Linux + Windows.
  • Demo: primitives_gallery muestra terminal corriendo bash -i (linux) / cmd.exe (windows).
  • Smoke test: spawn echo hello && exit 0 → buffer contiene "hello".
  • Integracion en kanban_cpp v2: panel "Logs" que toma run_id de issue activa y arranca tail -f /tmp/wt-<slug>-<runid>/agent.log (readonly=true).
  • FPS sin caida bajo carga de yes "x" (saturado): 60fps target con scrollback truncado.

Anti-scope (v1)

  • Sin soporte completo ANSI (no italics, no 256 colores, no Unicode wide).
  • Sin Vim / programas curses-pesados (cursor visible solo).
  • Sin SSH remoto (solo shell local).
  • Sin tabs multiples en un panel (un panel = un proceso).

Notas

ConPTY requiere Windows 10 v1809+. Si target inferior, fallback a CreatePipe sin PTY (sin redimensionado).