Workflow output renders with overlapping ghost frames on return to main view
Description
When a /workflow completes and the view transitions back to the main conversation, the output renders with overlapping/scrambled content. Multiple agent outputs, tables, and text layers from different workflow phases bleed together, making the result unreadable.
Steps to Reproduce
- Run a multi-agent workflow (e.g., a workflow with 3+ parallel agents producing markdown tables/structured output)
- Wait for workflow to complete
- Observe the
/workflowsview — renders correctly - Return to the main conversation view
Expected: Clean, sequential rendering of the workflow result
Actual: Text layers overlap, tables render on top of each other, content from different agents bleeds together
Screenshots
The output looks like multiple terminal frames composited on top of each other — text from different agents visible simultaneously at overlapping positions.
Environment
- Claude Code version at time of bug: 2.1.186
- Current version: 2.1.211 (updated, retesting)
- OS: macOS Darwin 25.5.0
- Terminal: Default macOS Terminal
- Shell: zsh
Analysis
Root cause appears to be in the alternate screen buffer transition from workflow view → main view:
- Frame buffer not fully cleared: The renderer's damage-map optimization skips redrawing "unchanged" regions, but stale workflow content remains in those regions after the view transition.
prevFrameContaminatednot reset: The frame compositor doesn't force a full repaint when exiting the workflow view, so partial frame data from the workflow persists.
- Synchronized output not flushed: The
\x1B[?2026h/lsynchronized output protocol may have pending batches during the\x1B[?1049l(exit alternate screen) call, causing interleaved frame data.
- Damage map not reset to full screen: On workflow exit, the damage map should be set to
{x:0, y:0, width: cols, height: rows}to force a complete repaint, but it appears to retain the workflow view's partial damage state.
Changelog Reference
v2.1.206 partially addressed this:
"Fixed returning to the agents view from a session leaving overlapping ghost frames with CLAUDE_CODE_DISABLE_ALTERNATE_SCREEN=1"
The fix may be incomplete for the workflow → main view transition (as opposed to agents view → session).
Suggested Fix
During exitAlternateScreen() → main view initialization:
- Force full repaint: set damage map to full screen
- Flush synchronized output: complete any pending
\x1B[?2026lbefore exiting - Reset frame contamination: force
prevFrameContaminated = true - Send explicit clear + home:
\x1B[2J\x1B[Hafter alternate screen exit - Synchronize dimensions: ensure
terminalColumns/terminalRowsmatch between both rendering contexts
Workaround
export CLAUDE_CODE_DISABLE_ALTERNATE_SCREEN=1
This disables alternate screen mode entirely, avoiding the buffer-swap issue.