-
Notifications
You must be signed in to change notification settings - Fork 1
feat: segmented progress bar with running/pending counts #57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
yfarjoun
wants to merge
2
commits into
fg-labs:main
Choose a base branch
from
yfarjoun:yf_segmented-progress-bar
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1678,32 +1678,25 @@ def _make_header(self, progress: WorkflowProgress) -> Panel: | |
| return Panel(header_text, style="white on grey23", border_style=FG_BLUE, height=3) | ||
|
|
||
| def _make_progress_bar(self, progress: WorkflowProgress, width: int = 40) -> Text: | ||
| """Create a colored progress bar showing succeeded/failed portions.""" | ||
| """Create a colored progress bar showing succeeded/failed/running/pending portions.""" | ||
| total = max(1, progress.total_jobs) | ||
| succeeded = progress.completed_jobs | ||
| failed = progress.failed_jobs | ||
| running = len(progress.running_jobs) | ||
| config = self._accessibility_config | ||
|
|
||
| # Calculate widths for each segment | ||
| # Calculate widths for each segment, distributing rounding remainders | ||
| succeeded_width = int((succeeded / total) * width) | ||
| failed_width = int((failed / total) * width) | ||
| unfinished = max(0, progress.total_jobs - progress.completed_jobs - progress.failed_jobs) | ||
| incomplete = ( | ||
| min(len(progress.incomplete_jobs_list), unfinished) | ||
| if progress.status == WorkflowStatus.INCOMPLETE | ||
| else 0 | ||
| ) | ||
| incomplete_width = int((incomplete / total) * width) | ||
| remaining_width = width - succeeded_width - failed_width - incomplete_width | ||
| running_width = int((running / total) * width) | ||
| pending_width = width - succeeded_width - failed_width - running_width | ||
|
|
||
| # Build the bar with colored segments | ||
| bar = Text() | ||
| bar.append(config.succeeded.char * succeeded_width, style="green") | ||
| bar.append(config.failed.char * failed_width, style="red") | ||
| if incomplete_width > 0: | ||
| bar.append(config.incomplete.char * incomplete_width, style="yellow") | ||
| if remaining_width > 0: | ||
| bar.append(config.remaining.char * remaining_width, style="dim") | ||
| bar.append(config.running.char * running_width, style="yellow") | ||
| bar.append(config.remaining.char * pending_width, style="dim") | ||
|
|
||
| return bar | ||
|
|
||
|
|
@@ -1725,6 +1718,8 @@ def _make_progress_panel( | |
| # Create colored progress bar | ||
| progress_bar = self._make_progress_bar(progress, width=bar_width) | ||
|
|
||
| running = len(progress.running_jobs) | ||
|
|
||
| # Progress text line | ||
| progress_line = Text() | ||
| progress_line.append("Progress ", style=f"bold {FG_BLUE}") | ||
|
|
@@ -1764,35 +1759,26 @@ def _make_progress_panel( | |
|
|
||
| eta_text = Text.from_markup(" ".join(eta_parts)) if eta_parts else Text("") | ||
|
|
||
| # Legend for the progress bar | ||
| # Legend for the progress bar showing non-zero segments | ||
| config = self._accessibility_config | ||
| legend = Text() | ||
| show_legend = progress.failed_jobs > 0 or config.show_legend | ||
| if show_legend: | ||
| legend_parts: list[tuple[str, str, str]] = [] | ||
| if progress.completed_jobs > 0: | ||
| legend_parts.append((config.succeeded.char, "green", f"{progress.completed_jobs} {config.succeeded.label}")) | ||
| if progress.failed_jobs > 0: | ||
| legend_parts.append((config.failed.char, "red", f"{progress.failed_jobs} {config.failed.label}")) | ||
| if running > 0: | ||
| legend_parts.append((config.running.char, "yellow", f"{running} {config.running.label}")) | ||
| pending = total - progress.completed_jobs - progress.failed_jobs - running | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. issue: |
||
| if pending > 0: | ||
| legend_parts.append((config.remaining.char, "dim", f"{pending} {config.remaining.label}")) | ||
| if legend_parts: | ||
| legend.append(" (", style="dim") | ||
| legend.append(config.succeeded.char, style="green") | ||
| legend.append(f"={progress.completed_jobs} {config.succeeded.label}", style="dim") | ||
| if progress.failed_jobs > 0: | ||
| legend.append(" ", style="dim") | ||
| legend.append(config.failed.char, style="red") | ||
| legend.append(f"={progress.failed_jobs} {config.failed.label}", style="dim") | ||
| unfinished = max( | ||
| 0, progress.total_jobs - progress.completed_jobs - progress.failed_jobs | ||
| ) | ||
| incomplete = ( | ||
| min(len(progress.incomplete_jobs_list), unfinished) | ||
| if progress.status == WorkflowStatus.INCOMPLETE | ||
| else 0 | ||
| ) | ||
| remaining = unfinished - incomplete | ||
| if incomplete > 0: | ||
| legend.append(" ", style="dim") | ||
| legend.append(config.incomplete.char, style="yellow") | ||
| legend.append(f"={incomplete} {config.incomplete.label}", style="dim") | ||
| if remaining > 0: | ||
| legend.append(" ", style="dim") | ||
| legend.append(config.remaining.char, style="dim") | ||
| legend.append(f"={remaining} {config.remaining.label}", style="dim") | ||
| for i, (symbol, style, label) in enumerate(legend_parts): | ||
| if i > 0: | ||
| legend.append(" ", style="dim") | ||
| legend.append(symbol, style=style) | ||
| legend.append(f"={label}", style="dim") | ||
| legend.append(")", style="dim") | ||
|
|
||
| # Border color based on status (use FG colors for normal states) | ||
|
|
@@ -1805,19 +1791,12 @@ def _make_progress_panel( | |
| } | ||
| border_style = border_colors.get(progress.status, FG_BLUE) | ||
|
|
||
| # Combine progress line with legend if present | ||
| if show_legend: | ||
| full_progress = Text() | ||
| full_progress.append(progress_line) | ||
| full_progress.append(legend) | ||
| return Panel( | ||
| Group(full_progress, eta_text), | ||
| title="Progress", | ||
| border_style=border_style, | ||
| ) | ||
|
|
||
| # Combine progress line with legend | ||
| full_progress = Text() | ||
| full_progress.append(progress_line) | ||
| full_progress.append(legend) | ||
| return Panel( | ||
| Group(progress_line, eta_text), | ||
| Group(full_progress, eta_text), | ||
| title="Progress", | ||
| border_style=border_style, | ||
| ) | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Guard segment width math against transient counter skew.
If counts briefly exceed
total,pending_widthbecomes negative at Line 1657, and the bar under-renders. Clamp intermediate widths and pending width to non-negative bounds.Proposed fix
🤖 Prompt for AI Agents