Skip to content

fix(core): preserve shell transcript across narrow wraps#3587

Closed
chiga0 wants to merge 3 commits into
codex/pr2-large-output-detail-stabilityfrom
codex/pr3-narrow-shell-viewport
Closed

fix(core): preserve shell transcript across narrow wraps#3587
chiga0 wants to merge 3 commits into
codex/pr2-large-output-detail-stabilityfrom
codex/pr3-narrow-shell-viewport

Conversation

@chiga0

@chiga0 chiga0 commented Apr 24, 2026

Copy link
Copy Markdown
Collaborator

Summary

This is PR3 in the TUI flicker/stability series and is intentionally stacked on #3586 (codex/pr2-large-output-detail-stability). After the earlier PRs land, this PR can be retargeted down the stack.

It addresses the narrow-terminal / tmux-pane shell class where xterm visual soft wraps and resize reflow can be mistaken for duplicated output. Final shell transcript text now unwraps xterm continuation rows using line.isWrapped, and live shell rendering now suppresses updates whose only change is soft-wrap segmentation of the same logical content.

Changes

  • Add serializeTerminalToText() for transcript-oriented xterm serialization.
  • Preserve explicit newlines while joining soft-wrapped visual continuation rows.
  • Use the transcript serializer for shell final output and startup-empty checks.
  • Add an unwrapWrappedLines comparison mode to serializeTerminalToObject() for live ANSI snapshots.
  • Coalesce adjacent ANSI tokens with the same style while unwrapping, so width-only reflow does not create a different comparison shape.
  • Replace the live output JSON.stringify comparison with semantic ANSI token comparison.
  • Suppress re-emitting live shell output when the raw viewport changed only because the same logical line was soft-wrapped differently.
  • Apply the same logical comparison to the default showColor=false shell path, so the default configuration is covered too.

Issue Class

Targets the PR3 issue class from the TUI plan:

  • Narrow terminals / tmux panes repeatedly showing wrapped output.
  • Interactive shell transcript pollution from viewport reflow.
  • Separating live viewport display from persisted transcript text.

Verification

  • git diff --check
  • cd packages/core && npx vitest run src/utils/terminalSerializer.test.ts src/services/shellExecutionService.test.ts
  • npm run lint --workspace=packages/core
  • Full-stack verification after rebasing PR4 on this branch:
    • npm run typecheck --workspace=packages/core
    • npm run typecheck --workspace=packages/cli
    • CLI/core targeted test suites all pass

Effect Comparison

Before screenshot/video:

TODO: attach narrow terminal / tmux pane shell output before this PR.

After screenshot/video:

TODO: attach the same scenario after this PR.

@chiga0 chiga0 force-pushed the codex/pr3-narrow-shell-viewport branch from edac442 to b30bfa2 Compare April 24, 2026 08:17
@chiga0

chiga0 commented Apr 24, 2026

Copy link
Copy Markdown
Collaborator Author

Superseded by #3591, which consolidates the effective PR1-PR4 TUI flicker foundation changes onto the latest main as one reviewable PR. The new PR also documents what is fixed now and what remains for follow-up Closure-A/B/C work.

@chiga0 chiga0 closed this Apr 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant