🎨 Palette: Add visual progress bar for CLI operations#125
Conversation
* 💡 What: Replaced text-based progress counters with a visual progress bar (`[██░░]`). * 🎯 Why: Improves user feedback during long-running operations (cache warming, rule pushing) and ensures cleaner terminal output. * 📸 Before: `🚀 Folder X: Pushing batch 1/10...` * 📸 After: `🚀 Folder X: [██░░░░░░░░] 10% (1/10)` * ♿ Accessibility: Improved visual contrast and feedback.
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
|
Merging to
|
| combined = "".join(writes) | ||
|
|
||
| # \033[K clear line | ||
| assert "\033[K" in combined |
Check notice
Code scanning / Bandit
Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test
| # \033[K clear line | ||
| assert "\033[K" in combined | ||
| # Prefix and Label | ||
| assert "T Test" in combined |
Check notice
Code scanning / Bandit
Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test
| # Prefix and Label | ||
| assert "T Test" in combined | ||
| # Progress bar and percentage | ||
| assert "50%" in combined |
Check notice
Code scanning / Bandit
Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test
| assert "T Test" in combined | ||
| # Progress bar and percentage | ||
| assert "50%" in combined | ||
| assert "5/10" in combined |
Check notice
Code scanning / Bandit
Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test
| assert "50%" in combined | ||
| assert "5/10" in combined | ||
| # Color codes | ||
| assert m.Colors.CYAN in combined |
Check notice
Code scanning / Bandit
Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test
| assert "5/10" in combined | ||
| # Color codes | ||
| assert m.Colors.CYAN in combined | ||
| assert m.Colors.ENDC in combined |
Check notice
Code scanning / Bandit
Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test
| combined = "".join(writes) | ||
|
|
||
| # \033[K clear line | ||
| assert "\033[K" in combined |
Check notice
Code scanning / Bandit (reported by Codacy)
Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test
| # \033[K clear line | ||
| assert "\033[K" in combined | ||
| # Prefix and Label | ||
| assert "T Test" in combined |
Check notice
Code scanning / Bandit (reported by Codacy)
Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test
| # Prefix and Label | ||
| assert "T Test" in combined | ||
| # Progress bar and percentage | ||
| assert "50%" in combined |
Check notice
Code scanning / Bandit (reported by Codacy)
Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test
| assert "T Test" in combined | ||
| # Progress bar and percentage | ||
| assert "50%" in combined | ||
| assert "5/10" in combined |
Check notice
Code scanning / Bandit (reported by Codacy)
Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test
| assert "50%" in combined | ||
| assert "5/10" in combined | ||
| # Color codes | ||
| assert m.Colors.CYAN in combined |
Check notice
Code scanning / Bandit (reported by Codacy)
Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test
| assert "5/10" in combined | ||
| # Color codes | ||
| assert m.Colors.CYAN in combined | ||
| assert m.Colors.ENDC in combined |
Check notice
Code scanning / Bandit (reported by Codacy)
Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test
| sys.stderr.flush() | ||
|
|
||
|
|
||
| def _clean_env_kv(value: Optional[str], key: str) -> Optional[str]: |
Check warning
Code scanning / Pylint (reported by Codacy)
Black listed name "bar" Warning
| @@ -481,15 +497,11 @@ def warm_up_cache(urls: Sequence[str]) -> None: | |||
| with concurrent.futures.ThreadPoolExecutor() as executor: | |||
Check warning
Code scanning / Pylint (reported by Codacy)
Line too long (115/100) Warning
| sys.stderr.write(f"\r\033[K{Colors.GREEN}✅ Folder {sanitize_for_log(folder_name)}: Finished ({len(filtered_hostnames)} rules){Colors.ENDC}\n") | ||
| sys.stderr.flush() | ||
| else: | ||
| log.info("Folder %s – finished (%d new rules added)", sanitize_for_log(folder_name), len(filtered_hostnames)) |
Check warning
Code scanning / Pylint (reported by Codacy)
Line too long (109/100) Warning
main.py
Outdated
Check warning
Code scanning / Pylint (reported by Codacy)
Line too long (154/100) Warning
| assert "Network failure" in str(mock_log.error.call_args) | ||
|
|
||
| # Case 8: render_progress_bar renders correctly | ||
| def test_render_progress_bar(monkeypatch): |
Check warning
Code scanning / Pylint (reported by Codacy)
Missing function docstring Warning test
|
|
||
| # Case 8: render_progress_bar renders correctly | ||
| def test_render_progress_bar(monkeypatch): | ||
| m = reload_main_with_env(monkeypatch, no_color=None, isatty=True) |
Check warning
Code scanning / Pylint (reported by Codacy)
Variable name "m" doesn't conform to snake_case naming style Warning test
| sys.stderr.flush() | ||
|
|
||
|
|
||
| def _clean_env_kv(value: Optional[str], key: str) -> Optional[str]: |
Check warning
Code scanning / Pylintpython3 (reported by Codacy)
Black listed name "bar" Warning
| @@ -481,15 +497,11 @@ def warm_up_cache(urls: Sequence[str]) -> None: | |||
| with concurrent.futures.ThreadPoolExecutor() as executor: | |||
Check warning
Code scanning / Pylintpython3 (reported by Codacy)
Line too long (115/100) Warning
| sys.stderr.write(f"\r\033[K{Colors.GREEN}✅ Folder {sanitize_for_log(folder_name)}: Finished ({len(filtered_hostnames)} rules){Colors.ENDC}\n") | ||
| sys.stderr.flush() | ||
| else: | ||
| log.info("Folder %s – finished (%d new rules added)", sanitize_for_log(folder_name), len(filtered_hostnames)) |
Check warning
Code scanning / Pylintpython3 (reported by Codacy)
Line too long (109/100) Warning
main.py
Outdated
Check warning
Code scanning / Pylintpython3 (reported by Codacy)
Line too long (154/100) Warning
| m.render_progress_bar(5, 10, "Test", prefix="T") | ||
|
|
||
| # Check output | ||
| writes = [args[0] for args, _ in mock_stderr.write.call_args_list] |
Check warning
Code scanning / Pylintpython3 (reported by Codacy)
Missing function or method docstring Warning test
There was a problem hiding this comment.
Pull request overview
This PR centralizes CLI progress reporting by introducing a reusable visual progress bar helper and adopting it in long-running operations to produce cleaner terminal output.
Changes:
- Added
render_progress_bar()helper to render a consistent progress bar tostderrin TTY/color mode. - Updated cache warm-up and rule-push batch progress output to use the new helper and clear-line handling (
\033[K). - Added a unit test validating progress bar rendering output and ANSI color wrapping.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
main.py |
Introduces render_progress_bar() and replaces ad-hoc progress counter writes with the centralized progress bar + clear-line handling. |
test_main.py |
Adds a unit test asserting the progress bar emits expected text, percentages, and ANSI codes. |
.Jules/palette.md |
Documents the “centralized CLI progress” learning and action item aligned with this refactor. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
[██░░]).🚀 Folder X: Pushing batch 1/10...🚀 Folder X: [██░░░░░░░░] 10% (1/10)PR created automatically by Jules for task 12317048477751304272 started by @abhimehro