Skip to content

Conversation

@ansu86d
Copy link
Contributor

@ansu86d ansu86d commented Oct 25, 2025

Fix for #343

@ansu86d
Copy link
Contributor Author

ansu86d commented Nov 2, 2025

PR #1223 Summary: Progress Bar Display with owo_colors Integration

Changes Made

1. Replaced Hardcoded ANSI with owo_colors Crate

  • Removed hardcoded ANSI escape sequences (\x1B[90m, etc.)
  • Integrated owo_colors library using the OwoColorize trait
  • Colors applied via .color(AnsiColors::*) method

2. Implemented TTY Detection

  • Added is_stdout_tty() function using atty crate
  • Colors only render in terminal output (TTY)
  • Plain text output when redirected to files or pipes

3. Grey-Scale Color Palette

  • Progress bar: BrightBlack (light grey)
  • Additions (+): BrightBlack
  • Removals (-): White
  • Updates (~): Black (dark grey)

4. Visual Texture with Unicode Characters

  • Completed portions: (full block)
  • Partial completion: (decreasing density)
  • Provides visual distinction without bright colors

5. Fixed Record Count Display

  • Now displays correct total: insertions + deletions + updates + no_change
  • Fixes previous issue showing incorrect counts

File Modified

  • src/execution/stats.rs

Test Results

✅ All 12 stats tests passing
✅ Terminal output: styled progress bars with grey colors
✅ File output: clean plain text (no ANSI codes)

Example Output

░░░░░░░░▒▒▒▒▒▒▒▒▓▓▓▓████] 2/2 records (~1 updated)
[▓▓▓▓▓▓▓▓▓▓░░░░░░░░░░░░░░░░] 3/3 records (-2 removed)
[░░░░░░░░░░░░░░░░░░░░████████] 1/1 records (+1 added)

@ansu86d
Copy link
Contributor Author

ansu86d commented Nov 2, 2025

@georgeh0 / @badmonster0 requesting review

Copilot AI review requested due to automatic review settings November 2, 2025 17:29
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request enhances statistics display with visual progress bars and better formatting, including TTY-aware colored output for terminal displays. It also adds a cumulative total tracker and suppresses dead code warnings for currently unused functions.

Key changes:

  • Reimplemented the UpdateStats display formatting with a visual progress bar and color-coded segments for different operation types (insertions, deletions, updates)
  • Added TTY detection to conditionally apply color formatting only when output is directed to a terminal
  • Introduced a cumulative_total field to track the net effect of operations over time

Reviewed Changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/execution/stats.rs Major refactoring of display logic to include progress bars, TTY detection, and cumulative totals tracking
src/ops/factory_bases.rs Added #[allow(dead_code)] to suppress warning for take_value method
src/execution/db_tracking.rs Added #[allow(dead_code)] to suppress warnings for read_source_state and upsert_source_state functions
examples/custom_output_files/run_and_capture.py Added new Python helper script to run and capture output for testing
Cargo.toml Added atty dependency for TTY detection
Cargo.lock Updated lock file with new dependencies (atty, winapi, hermit-abi) and version adjustments

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

messages.push(format!("{num_in_process} source rows IN PROCESS"));
// Error handling
if num_errors > 0 {
let tty = is_stdout_tty();
Copy link

Copilot AI Nov 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The is_stdout_tty() function is called multiple times (lines 237, 300, 343) within the same fmt method. Consider calling it once at the beginning of the method and reusing the result to avoid redundant system calls.

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot open a new pull request to apply changes based on this feedback

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@georgeh0 georgeh0 merged commit 8ef8ef4 into cocoindex-io:main Nov 2, 2025
3 of 8 checks passed
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