refactor: Redesign ProgressPrinter with clean architecture#1956
refactor: Redesign ProgressPrinter with clean architecture#1956
Conversation
SummaryThis PR extracts Critical IssuesNone found ✅ Suggestions1. Exception Handling Regression in Background TasksIn the original catch (Exception ex) when (ex is not (OutOfMemoryException or StackOverflowException))But based on the diff, catch (Exception)
{
// Suppress other exceptions to prevent unobserved task exceptions
// Progress updates are non-critical UI feedback
}Recommendation: Maintain the same exception filter pattern from the original to avoid swallowing critical exceptions like 2. Test Plan IncompleteThe PR description shows:
Recommendation: Complete the test plan checklist before merging, especially running existing unit tests to ensure the refactor maintains behavioral equivalence. 3. DI Registration OrderThe new services are correctly registered before Verdict✅ APPROVE - No critical issues found. The refactoring follows clean architecture principles and properly separates concerns. Suggestion #1 about exception handling should ideally be addressed to maintain the original safety guarantees, but this is a minor issue in non-critical UI feedback code. |
SummaryThis PR refactors Critical IssuesNone found ✅ Note: While reviewing this code, I identified several pre-existing issues that were moved (not introduced) by this refactoring: Pre-existing Issues (not blocking for this PR)
Since these issues pre-exist and this PR is a refactoring (not a bug fix), they should not block this PR. They can be addressed in follow-up issues. Suggestions1. Exception Handling in StartProgressTicker (Medium Priority)The diff shows that exception handling was updated in the new 2. Consider Adding XML DocumentationThe new interfaces have good documentation, but some implementation details in Verdict✅ APPROVE - No critical issues introduced by this refactoring This is a solid architectural improvement that increases testability and maintainability. The separation of concerns is well-executed, and the dependency injection setup is appropriate. |
Extract separate components following Single Responsibility Principle: - IProgressDisplay / SpectreProgressDisplay: Handles all Spectre.Console progress rendering (adding tasks, styling, progress bar updates) - IResultsPrinter / SpectreResultsPrinter: Handles results table rendering and execution metrics printing - IProgressCalculator / ProgressCalculator: Extracts progress calculation logic (tick rates, progress increments) - ProgressPrinter: Now a thin coordinator that connects the notification system to display components This separation makes the code easier to test, maintain, and potentially swap out display implementations (e.g., for non-console scenarios). Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
67066ad to
b0436d4
Compare
SummaryThis PR refactors ProgressPrinter into separate components following the Single Responsibility Principle, extracting progress display, results printing, and calculation logic into dedicated interfaces and implementations. Critical Issues1. Weakened Exception Handling in StartProgressTicker (src/ModularPipelines/Helpers/SpectreProgressDisplay.cs:228-248) The refactored code changed the exception filter from a safe pattern to catching all exceptions: Original (safe): catch (Exception ex) when (ex is not (OutOfMemoryException or StackOverflowException))
{
// Suppress other exceptions to prevent unobserved task exceptions
// Progress updates are non-critical UI feedback
}New (unsafe): catch (Exception)
{
// Suppress other exceptions to prevent unobserved task exceptions
// Progress updates are non-critical UI feedback
}Issue: The new code catches all exceptions including critical ones like Fix: Restore the original exception filter: catch (Exception ex) when (ex is not (OutOfMemoryException or StackOverflowException))SuggestionsNone - the refactoring is well-structured and maintains the original functionality otherwise. The separation of concerns will improve testability and maintainability. Verdict |
Restores the exception filter to prevent catching critical exceptions like OutOfMemoryException and StackOverflowException, which indicate process-level failure that requires immediate termination. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
Restored the exception filter Note: As discussed, these exceptions are largely uncatchable in practice (StackOverflowException terminates immediately, OOM is rarely catchable), so this filter is defensive but mostly theoretical. |
SummaryThis PR refactors ProgressPrinter into separate components following the Single Responsibility Principle - extracting progress display, results printing, and progress calculation logic into dedicated classes. Critical IssuesNone found ✅ Suggestions
Verdict✅ APPROVE - Clean refactoring that improves testability and maintainability. The separation of concerns is well-designed, with clear interfaces and appropriate use of dependency injection. |
Summary
ProgressPrinterfollowing Single Responsibility PrincipleIProgressDisplay/SpectreProgressDisplayfor Spectre.Console progress renderingIResultsPrinter/SpectreResultsPrinterfor results table and metrics printingIProgressCalculator/ProgressCalculatorfor progress calculation logicProgressPrinteris now a thin coordinator connecting notifications to display componentsChanges
IProgressDisplaySpectreProgressDisplayIResultsPrinterSpectreResultsPrinterIProgressCalculatorProgressPrinterBenefits
SpectreProgressDisplayTest plan
Closes #1924
Generated with Claude Code