fix(tui): stop ANSI escape leaks + drop redundant update_plan cards - #316
Conversation
Two chat-clarity fixes surfaced by comparing Zero's output to a reference agent on a "build a website" task. 1. ANSI escape garbage in the final answer. styleAssistantMarkdownLine treated already-styled input (syntax-highlighted code, headings, tables — which carry real ANSI) byte-by-byte as runes and re-wrapped the whole line in another base.Render. That doubled the SGR density and let a downstream width-truncation slice mid-escape, leaking "[38;2;…" / "[1;4;…" fragments as literal text next to code blocks. Now real escape sequences pass through verbatim (via the existing ansiSequenceEnd helper, like truncateStyledLine); the synthetic bold markers are still matched first so their style switch is kept. Only styled segments were affected — plain prose never had embedded escapes to split. 2. Redundant update_plan tool cards. The plan is already shown in the pinned plan panel AND the PLAN sidebar, so rendering each update_plan call as its own transcript card was pure duplication (it stacked 3x in the demo). Generalize the existing Task-card skip into toolCardSuppressedInTranscript and skip update_plan's call+result rows too; the plan-panel sync and session events are unchanged. Tests: TestStyleAssistantMarkdownLinePassesAnsiVerbatim (fails before the fix), TestToolCardSuppressedInTranscript.
Zero automated PR reviewVerdict: No blockers found Blockers
Validation
ScopeHead: This deterministic review checks validation status and basic diff hygiene. A human reviewer still owns product judgment and design quality. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
WalkthroughThis PR preserves ANSI escape sequences in assistant markdown rendering and centralizes transcript-card suppression for ChangesANSI assistant markdown styling
Tool transcript suppression
Estimated code review effort🎯 2 (Simple) | ⏱️ ~15 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
Comment |
What
Two chat-clarity fixes from comparing Zero's output to a reference agent on a "build a website" task.
1. ANSI escape garbage in the final answer 🐛
The final text was leaking raw, truncated terminal color codes as literal characters next to code blocks:
Root cause:
styleAssistantMarkdownLinetreated already-styled input (syntax-highlighted code, headings, tables — which carry real ANSI) byte-by-byte as runes and re-wrapped the whole line in anotherbase.Render. That doubled the SGR density, and a downstream width-truncation then sliced mid-escape, dropping the leadingESCand printing the leftover ([38;2;…) as text. Only styled segments were affected — plain prose has no embedded escapes to split.Fix: real escape sequences now pass through verbatim (using the existing
ansiSequenceEndhelper, exactly liketruncateStyledLine); the synthetic bold markers are still matched first so their style switch is preserved. ~14 lines.2. Redundant
update_plantool cards 🧹The plan is already shown in two places — the pinned plan panel above the composer and the PLAN sidebar — so rendering every
update_plancall as its own transcript card was pure duplication (it stacked 3× in the demo). Generalized the existingTask-card skip intotoolCardSuppressedInTranscriptand now skipupdate_plan's call+result rows too. The plan-panel sync and session events are unchanged.Tests
TestStyleAssistantMarkdownLinePassesAnsiVerbatim— proves already-styled input passes through verbatim; verified it fails before the fix (output re-wraps the input escape inside base's\x1b[1m).TestToolCardSuppressedInTranscript—Task/update_plansuppressed, everything else still shown../internal/tui/...suite green; build + gofmt clean.Part of a series
This is 1 of 3 from the chat-clarity comparison. Follow-ups: diff/code preview on write/edit cards (the render half +
go-udiffalready exist), and a system-prompt preamble so the agent briefly states its approach. Independent PRs.Summary by CodeRabbit