tui-render-debug
Diagnose and fix pi-go TUI rendering corruption, especially displaced panels, stale rows, cursor drift, and terminal-specific ANSI incompatibilities.
- License 许可
- MIT
- 所属仓库
- dimetron/pi-go
- 最近更新
- 2026-11-12
- Stars
- ★ 224
- Forks
- 34
01 前言 Front Matter
- name
- tui-render-debug
- description
- Diagnose and fix pi-go TUI rendering corruption, especially displaced panels, stale rows, cursor drift, and terminal-specific ANSI incompatibilities.
02 资源文件 1
- 参考文档_AIWF_IMPORT.json371 B
03 SKILL.md 正文
TUI Render Debugging
Use this skill when pi-go's Bubble Tea interface is broken in a terminal: text appears in the wrong row or column, the sidebar moves, old frames remain after a resize, or a redraw repairs the display.
Establish the symptom
Capture the exact terminal, TERM, COLORTERM, TERMINAL_EMULATOR, terminal
size, and whether a full redraw or switching terminal modes repairs the frame.
Compare the broken frame with the next clean frame. A clean redraw after a bad
incremental frame points to renderer cursor state, not necessarily to bad
View() geometry.
For JetBrains IDE terminals, record TERMINAL_EMULATOR=JetBrains-JediTerm.
JediTerm can report TERM=xterm-256color while mishandling cursor-backward-tab
(CSI Z, CBT), which makes Bubble Tea's differential renderer believe the
cursor is in a different column than the emulator.
Separate output leaks from renderer drift
The interactive TUI owns the terminal. Search the active path for direct output:
rg -n 'fmt\.Print|log\.Print|os\.(Stdout|Stderr)|slog\.' internal cmd
Routine diagnostics must use the session logger. User-facing notices must use the TUI message or notice channel. A subprocess's stdout and stderr must be captured and surfaced as a tool result. Direct writes can move the cursor, but the absence of leaked stderr does not rule out a renderer incompatibility.
Build a red-capable repro
Use a PTY with the affected environment and capture stdout and stderr separately. Count and inspect control sequences in stdout; stderr should contain only diagnostics expected outside the frame.
For renderer-level tests, create an ultraviolet.TerminalRenderer with the
affected environment, move from a later column to an earlier column, and assert
that unsupported CBT is not emitted. Replay the captured bytes through a
JediTerm-compatible emulator when available. Also verify ordinary xterm and
tmux/screen environments remain unchanged.
Fix decisions
Keep frame geometry tests independent: every rendered row must match the terminal width, the rail must stay in one display column, and no ANSI escape may leak into visible content. Do not solve a terminal capability bug by changing layout constants.
When the Bubble Tea dependency has no per-capability switch, isolate a compatibility environment to Bubble Tea's renderer. Preserve the original environment for subprocesses and use the original environment for color-profile detection. Prefer disabling only the broken capability when the dependency supports it; otherwise use the narrowest compatible renderer profile and add a comment explaining why.
Verification
Run the focused regression test first, then the full TUI package, race tests for
the affected seam, golangci-lint run ./internal/tui/..., and a build. Re-run
the PTY capture and confirm the affected terminal no longer drifts while normal
terminal output and colors remain intact.
04 同仓库更多 Skills
verify-session-flow
Formally verify the interactive session flow before or after changing it. Use when editing internal/tui/tui.go's handleKey, handleInterruptKey, handleInputSubmit, ctrlCCount or quitting, internal/tui/agent_loop.go's enqueuePrompt, submit, steerPrompt, cancelAgent or handleAgentDone, or the deferred-init splash — or when a user reports that Ctrl+C quit on the first press, that Esc did not stop a turn or a goal loop, that a queued prompt was lost when they canceled, or that the TUI hung on a spinner nothing could clear.
verify-run-pipeline
Formally verify the /run phase machine before or after changing it. Use when editing internal/tui/run.go's phase transitions (handleRunAgentDone, runGates result handling, verifyRunComplete, retryRun, reportGateHang, merge), internal/sop/verdict.go's Passed, or the checklist refresh — or when a run merged work it should not have, retried a hung gate, lost a cycle at the retry budget, or merged on a stale PASS.
verify-history-rewrite
Formally verify the session-history rewrite path before or after changing it. Use when editing internal/session/autocompact.go, internal/session/compaction*.go, internal/session/store.go's Compact/ClearEvents/rewriteEvents, internal/agent/agent.go's Run/RunStreaming/runPreTurn, or internal/tui/commands.go's clearConversation/clearSessionContext and the context gauge — or when a turn is canceled mid-flight, a tool call and its result get separated, a session's history disappears while the agent is still working, or the model is sent a tool result whose call was compacted away.
verify-goal-loop
Formally verify the /goal automatic loop before or after changing it. Use when editing internal/tui/goal.go, internal/tui/agent_loop.go's handleAgentDone/cancelAgent/steerPrompt, or internal/tools/goal.go's GoalController — or when a goal loop will not stop, stops one cycle early, closes a goal that is not met, or restarts a goal you finished.
verify-agent-lifecycle
Formally verify the subagent lifecycle before or after changing it. Use when editing internal/subagent/orchestrator.go's Spawn, trackAgent, forwardAgentEvents, terminalStatus, Cancel, ShutdownWithTimeout or evictCompletedAgentsLocked, or internal/subagent/pool.go — or when a canceled agent is reported as failed, an agent vanishes from the list with no verdict, the orchestrator panics on a pool release, or an agent can be canceled twice.
test-new-skill
暂无简介