feat: add colorblind-accessible mode for progress bars#54
Conversation
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 12 minutes and 57 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (6)
📝 WalkthroughWalkthroughThis PR introduces a colorblind-accessible progress bar rendering mode. Users can enable an alternative visual encoding via a CLI parameter or by pressing the 'a' key, which switches progress bars from color-dependent indicators to character-based representations using distinct symbols and optional text labels. Changes
Sequence Diagram(s)sequenceDiagram
actor User
participant CLI as CLI (watch)
participant TUI as WorkflowMonitorTUI
participant Config as accessibility_config
participant Renderer as Progress Renderer
User->>CLI: Call with colorblind=True
CLI->>Config: Select ACCESSIBLE_CONFIG
CLI->>TUI: __init__(accessibility_config)
TUI->>TUI: Store accessibility_config
Note over User,Renderer: Progress rendering loop
TUI->>Renderer: _make_progress_bar(config)
Renderer->>Renderer: Use config.succeeded.char, config.failed.char, etc.
Renderer-->>TUI: Rendered bar with symbols
Note over User,TUI: Keyboard toggle (while TUI running)
User->>TUI: Press 'a' key
TUI->>Config: Toggle config (DEFAULT ↔ ACCESSIBLE)
TUI->>TUI: Force refresh
TUI->>Renderer: Re-render with new config
Renderer-->>TUI: Updated bar display
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #54 +/- ##
=======================================
Coverage 88.25% 88.26%
=======================================
Files 48 48
Lines 4692 4694 +2
=======================================
+ Hits 4141 4143 +2
Misses 551 551
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
tests/test_cli.py (1)
51-67: Add a positive-path test forcolorblind=True.This only locks down the default
accessibility_config=Nonebranch. The new user-facing flag can still regress unnoticed unless we also assert thatwatch(..., colorblind=True)passesACCESSIBLE_CONFIGintoWorkflowMonitorTUI.🧪 Suggested test
+ def test_watch_calls_tui_in_accessible_mode( + self, snakemake_dir: Path, tmp_path: Path + ) -> None: + """Test that watch enables accessible rendering when requested.""" + from snakesee.tui.accessibility import ACCESSIBLE_CONFIG + + with patch("snakesee.tui.WorkflowMonitorTUI") as mock_tui: + watch(tmp_path, colorblind=True) + + assert mock_tui.call_args.kwargs["accessibility_config"] is ACCESSIBLE_CONFIG🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@tests/test_cli.py` around lines 51 - 67, Add a positive-path unit test that asserts the new colorblind flag passes the expected accessibility config into the TUI: update tests/test_cli.py by adding a test alongside test_watch_calls_tui that calls watch(tmp_path, refresh=2.0, no_estimate=True, colorblind=True) and then asserts WorkflowMonitorTUI was called with accessibility_config=ACCESSIBLE_CONFIG (keeping other expected args: workflow_dir=tmp_path, refresh_rate=2.0, use_estimation=False, profile_path=None, use_wildcard_conditioning=True, weighting_strategy="index", half_life_logs=10, half_life_days=7.0). Ensure you import or reference ACCESSIBLE_CONFIG in the test scope so the equality check succeeds.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@snakesee/tui/monitor.py`:
- Around line 1677-1682: The incomplete/remaining segment is using total_jobs -
completed_jobs - failed_jobs for all unfinished work; change the bar
construction (the code around bar.append calls and the WorkflowStatus.INCOMPLETE
branch) to render the interrupted portion using
len(progress.incomplete_jobs_list) (apply that to compute incomplete_width and
use config.incomplete.char) and render only the true still-pending remainder
using config.remaining.char (adjust remaining_width = total_unfinished -
len(progress.incomplete_jobs_list)). Update the same logic wherever the bar is
built for progress (including the other similar block around the later bar
construction) so the accessible label reflects interrupted jobs separately from
still-pending jobs.
---
Nitpick comments:
In `@tests/test_cli.py`:
- Around line 51-67: Add a positive-path unit test that asserts the new
colorblind flag passes the expected accessibility config into the TUI: update
tests/test_cli.py by adding a test alongside test_watch_calls_tui that calls
watch(tmp_path, refresh=2.0, no_estimate=True, colorblind=True) and then asserts
WorkflowMonitorTUI was called with accessibility_config=ACCESSIBLE_CONFIG
(keeping other expected args: workflow_dir=tmp_path, refresh_rate=2.0,
use_estimation=False, profile_path=None, use_wildcard_conditioning=True,
weighting_strategy="index", half_life_logs=10, half_life_days=7.0). Ensure you
import or reference ACCESSIBLE_CONFIG in the test scope so the equality check
succeeds.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 568bdf8f-282f-406f-9d76-35145a270c7e
📒 Files selected for processing (6)
snakesee/cli.pysnakesee/tui/__init__.pysnakesee/tui/accessibility.pysnakesee/tui/monitor.pytests/test_cli.pytests/test_tui.py
Add alternative visual encoding using distinct characters (=, X, ·, ?) so progress bar status can be distinguished without color perception. - New --colorblind CLI flag for watch command - 'a' key toggles accessible mode at runtime - Always-on legend in accessible mode shows character meanings - AccessibilityConfig frozen dataclass for clean configuration Closes #46
63c6821 to
70d37da
Compare
Summary
--colorblindCLI flag towatchcommand for colorblind-accessible progress bars=succeeded,Xfailed,·remaining,?incomplete) instead of relying on color aloneakey binding to toggle accessible mode at runtimeAccessibilityConfigfrozen dataclass insnakesee/tui/accessibility.pyCloses #46
Test plan
TestAccessibilityclass covering:akey toggles between modes?characterSummary by CodeRabbit
New Features
Tests