Skip to content

fix: Prevent TUI rendering errors by stripping control chars#42

Merged
aliou merged 2 commits into
aliou:mainfrom
xXJSONDeruloXx:fix/sanitize-log-control-chars
May 20, 2026
Merged

fix: Prevent TUI rendering errors by stripping control chars#42
aliou merged 2 commits into
aliou:mainfrom
xXJSONDeruloXx:fix/sanitize-log-control-chars

Conversation

@xXJSONDeruloXx
Copy link
Copy Markdown
Contributor

@xXJSONDeruloXx xXJSONDeruloXx commented May 19, 2026

Summary

  • strip non-printing terminal control chars like carriage return and backspace in stripAnsi()
  • sanitize the collapsed log dock preview before rendering it
  • add regression tests for ANSI/control-char stripping

Why

Some process output includes spinner/progress style control bytes such as bare or . Those bytes can make pi's TUI render orphaned, repeated, or cascading lines when log content is rendered back into widgets/components.

This keeps the current output capture behavior intact, but hardens the render/sanitization path so control characters do not leak into the TUI.

Verification

  • npx pnpm test
  • npx pnpm typecheck
  • npx pnpm lint

Testing with a proc which helps repro this issue (one of various cases, but this is an extreme one for demo purposes):

i=0; while true; do i=$((i+1)); printf '\033[1A\033[2K\033[G[UP-REPRO %04d] this line tries to move the cursor up before rendering preview %s %s %s %s %s\n' "$i" alpha bravo charlie delta echo >&2; sleep 0.2; done

Before:

image

After:

image

@xXJSONDeruloXx xXJSONDeruloXx changed the title fix: sanitize process log control chars fix: Prevent TUI rendering errors by stripping control chars May 19, 2026
@aliou aliou force-pushed the fix/sanitize-log-control-chars branch from f558ce6 to 88fd62d Compare May 20, 2026 09:49
@aliou
Copy link
Copy Markdown
Owner

aliou commented May 20, 2026

Hey @xXJSONDeruloXx , thanks for this! Made some tweaks, merging this now and releasing it later today with other fixes

@aliou aliou merged commit 233d30b into aliou:main May 20, 2026
1 check passed
@xXJSONDeruloXx xXJSONDeruloXx deleted the fix/sanitize-log-control-chars branch May 20, 2026 10:01
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.

2 participants