fix(logging): restore AUR progress bars and render clean colored logs #44

Merged
rootiest merged 5 commits from fix/aur-wrapper-pty-progress-bars into main 2026-06-12 03:02:21 +00:00
Owner

Summary

With logging enabled, paru/yay showed no download progress bars. The wrappers piped output through tee, so libalpm detected a non-TTY stdout and suppressed the bars. This PR restores on-screen progress bars and produces clean, colored log files.

The fix, in two parts

1. PTY capture restores on-screen progress bars
The wrappers now run paru/yay inside a pseudo-TTY via script(1) (-q -e -c), so libalpm sees a real terminal and renders progress bars normally on screen.

2. Terminal emulator renders clean static logs
pacman's download progress is a multi-line terminal animation — it repaints lines in place using ANSI cursor-movement (ESC[<n>A) and erase-line (ESC[K) sequences, not just carriage returns. No line-wise regex can reconstruct that: stripping CRs concatenates every redraw frame into one giant line, while collapsing on CRs discards the final frame and leaves blanks.

New helper scripts/clean_progress_log.py is a small, dependency-free terminal screen-buffer emulator. It replays the captured cursor movements against an in-memory grid exactly as a real terminal would, then dumps the final static frame. SGR color codes are preserved (so logs still render with color in ov/bat/less -R), and the script(1) header/footer are dropped. If python3 is unavailable, the wrapper falls back to stripping only the script(1) header.

Both wrappers are bumped to version 5 to force regeneration; old wrappers are removed automatically.

Files

  • conf.d/paru-wrapper.fish, conf.d/yay-wrapper.fish — PTY capture + pipe through the cleaner (version 5)
  • scripts/clean_progress_log.py — terminal-emulator log renderer (new)
  • docs/fish-config.md — document the scripts/ dir and the capture/render mechanism

Manual Verification

  • Start a new shell (or source ~/.config/fish/conf.d/paru-wrapper.fish) and confirm ~/.local/bin/paru is version 5
  • Run paru -Syu (or paru -Sw <uncached-pkg>) and confirm download progress bars are visible on screen
  • Open the resulting ~/.terminal_history/paru_*.log (e.g. logs -c paru) and confirm it shows the final progress frame only — no concatenated frames, no blank gaps, no Script started/done header
  • Confirm ANSI color is preserved when viewing the log
  • Toggle logging off (set -U __fish_config_op_logging 0), confirm the wrapper is removed from ~/.local/bin/; re-enable (set -e __fish_config_op_logging) and confirm it regenerates at version 5
  • Temporarily rename python3 out of PATH (or test on a host without it) and confirm the wrapper still produces a usable log via the fallback
  • Repeat the progress-bar and log checks for yay if installed
## Summary With logging enabled, paru/yay showed no download progress bars. The wrappers piped output through `tee`, so libalpm detected a non-TTY stdout and suppressed the bars. This PR restores on-screen progress bars **and** produces clean, colored log files. ### The fix, in two parts **1. PTY capture restores on-screen progress bars** The wrappers now run paru/yay inside a pseudo-TTY via `script(1)` (`-q -e -c`), so libalpm sees a real terminal and renders progress bars normally on screen. **2. Terminal emulator renders clean static logs** pacman's download progress is a *multi-line terminal animation* — it repaints lines in place using ANSI cursor-movement (`ESC[<n>A`) and erase-line (`ESC[K`) sequences, not just carriage returns. No line-wise regex can reconstruct that: stripping CRs concatenates every redraw frame into one giant line, while collapsing on CRs discards the final frame and leaves blanks. New helper `scripts/clean_progress_log.py` is a small, dependency-free **terminal screen-buffer emulator**. It replays the captured cursor movements against an in-memory grid exactly as a real terminal would, then dumps the final static frame. SGR color codes are preserved (so logs still render with color in `ov`/`bat`/`less -R`), and the `script(1)` header/footer are dropped. If `python3` is unavailable, the wrapper falls back to stripping only the `script(1)` header. Both wrappers are bumped to version 5 to force regeneration; old wrappers are removed automatically. ### Files - `conf.d/paru-wrapper.fish`, `conf.d/yay-wrapper.fish` — PTY capture + pipe through the cleaner (version 5) - `scripts/clean_progress_log.py` — terminal-emulator log renderer (new) - `docs/fish-config.md` — document the `scripts/` dir and the capture/render mechanism ## Manual Verification - [x] Start a new shell (or `source ~/.config/fish/conf.d/paru-wrapper.fish`) and confirm `~/.local/bin/paru` is version 5 - [x] Run `paru -Syu` (or `paru -Sw <uncached-pkg>`) and confirm download progress bars are visible **on screen** - [x] Open the resulting `~/.terminal_history/paru_*.log` (e.g. `logs -c paru`) and confirm it shows the **final** progress frame only — no concatenated frames, no blank gaps, no `Script started/done` header - [x] Confirm ANSI **color** is preserved when viewing the log - [x] Toggle logging off (`set -U __fish_config_op_logging 0`), confirm the wrapper is removed from `~/.local/bin/`; re-enable (`set -e __fish_config_op_logging`) and confirm it regenerates at version 5 - [x] Temporarily rename `python3` out of PATH (or test on a host without it) and confirm the wrapper still produces a usable log via the fallback - [x] Repeat the progress-bar and log checks for `yay` if installed
rootiest added 1 commit 2026-06-12 02:03:22 +00:00
Piping through tee caused libalpm to detect a non-TTY stdout and
suppress download progress bars. Switch to script(1) with -q -e -c
which allocates a pseudo-TTY so paru/yay see a real terminal, then
strip ANSI escape sequences from the captured log for readability.
Bump wrapper version to 2 to force regeneration on next shell start.
rootiest added 1 commit 2026-06-12 02:10:26 +00:00
script(1) captures every \r-redrawn frame of the pacman progress bar
as raw bytes. The previous sed pass only stripped ANSI codes, leaving
all intermediate frames concatenated in the log. col -bp semantically
replays the carriage-return overwrites and retains only the final state
of each line; the sed pass then strips residual ANSI codes and the
"Script started/done" header that script(1) writes to the file even
under -q. Bump wrapper version to 3.
rootiest added 1 commit 2026-06-12 02:23:45 +00:00
col -bp is designed for backspace-overstriking (man pages), not ANSI
terminal animations; it mangled escape sequences and garbled overprinted
progress bar text. Replace with a perl -ne one-liner that:
  1. Skips Script started/done header lines (next if matches, with -ne
     so next truly suppresses print, unlike -pe which still auto-prints)
  2. Strips trailing \r from PTY \r\n line endings
  3. Collapses CR-redrawn progress bar frames to their final state
  4. Preserves all ANSI color codes so ov renders them correctly
Bump wrapper version to 4 to force regeneration.
rootiest added 1 commit 2026-06-12 02:48:11 +00:00
pacman/paru download progress is a multi-line terminal animation: it
repaints lines in place using ANSI cursor-movement (ESC[<n>A) and
erase-line (ESC[K) sequences, not just carriage returns. The previous
line-wise regex approaches could not reconstruct this — frames either
concatenated into one giant line (CR removed) or collapsed to blanks
(CR kept), discarding the final 100% frame.

Add scripts/clean_progress_log.py, a small dependency-free terminal
screen-buffer emulator that replays the cursor movements against an
in-memory grid and dumps the final static frame, preserving SGR color
so logs still render with color in ov/bat/less -R. It also drops the
script(1) header/footer.

Both wrappers now pipe the raw PTY capture through this cleaner (bumped
to version 5), falling back to stripping only the script(1) header when
python3 is unavailable. Document the scripts/ dir and mechanism in
AGENTS.md and docs/fish-config.md.
rootiest added 1 commit 2026-06-12 02:57:35 +00:00
rootiest changed title from fix(logging): run paru/yay wrappers in PTY to restore progress bars to fix(logging): restore AUR progress bars and render clean colored logs 2026-06-12 02:58:24 +00:00
rootiest merged commit 71aa38c7ca into main 2026-06-12 03:02:21 +00:00
rootiest deleted branch fix/aur-wrapper-pty-progress-bars 2026-06-12 03:02:22 +00:00
Sign in to join this conversation.