Skip to content

fix: deduplicate FormatSize (CQ-002) and batch ConsoleViewModel trim (CQ-008)#254

Merged
laurentiu021 merged 2 commits into
mainfrom
fix/code-review-batch-3
May 12, 2026
Merged

fix: deduplicate FormatSize (CQ-002) and batch ConsoleViewModel trim (CQ-008)#254
laurentiu021 merged 2 commits into
mainfrom
fix/code-review-batch-3

Conversation

@laurentiu021

@laurentiu021 laurentiu021 commented May 12, 2026

Copy link
Copy Markdown
Owner

Summary

Two low-effort code quality fixes from code review.

  • CQ-002: Removed duplicate FormatSize methods from DiskUsageEntry, InstalledApp, ProcessEntry — all now use CleanupCategory.HumanSize
  • CQ-008: ConsoleViewModel batch-removes excess lines from end-to-start instead of repeated RemoveAt(0)

Build: 0 errors

Summary by CodeRabbit

  • Refactor
    • Standardized size formatting across disk usage, installed apps, and process memory so byte values display consistently as human-readable sizes.
    • Optimized console output handling to remove excess lines in batches, improving performance and reducing overhead during active logging.

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 12, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 39b362c7-c000-400f-800f-4fb015c59126

📥 Commits

Reviewing files that changed from the base of the PR and between 11b8296 and 7dc7080.

📒 Files selected for processing (1)
  • SysManager/SysManager.Tests/ProcessManagerServiceTests.cs
✅ Files skipped from review due to trivial changes (1)
  • SysManager/SysManager.Tests/ProcessManagerServiceTests.cs
📜 Recent review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Build & unit tests
  • GitHub Check: Analyze (csharp)

📝 Walkthrough

Walkthrough

Consolidates size-formatting into CleanupCategory.HumanSize across DiskUsageEntry, InstalledApp, and ProcessEntry, updates an associated test and CHANGELOG, and changes ConsoleViewModel.Append to batch-remove excess lines instead of repeated head removals.

Changes

Code Deduplication and Performance Optimization

Layer / File(s) Summary
Size format deduplication across model classes
SysManager/SysManager/Models/DiskUsageEntry.cs, SysManager/SysManager/Models/InstalledApp.cs, SysManager/SysManager/Models/ProcessEntry.cs, SysManager/SysManager.Tests/ProcessManagerServiceTests.cs, CHANGELOG.md
DiskUsageEntry.SizeDisplay and InstalledApp.SizeDisplay now use CleanupCategory.HumanSize(SizeBytes); ProcessEntry.MemoryDisplay uses CleanupCategory.HumanSize(MemoryBytes). Local FormatSize helpers were removed; a test expectation was updated and the CHANGELOG records the deduplication.
Console line-capping performance optimization
SysManager/SysManager/ViewModels/ConsoleViewModel.cs
ConsoleViewModel.Append computes excess = Lines.Count - MaxLines and removes that many oldest entries in a bounded loop instead of repeatedly calling RemoveAt(0).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 I hopped through bytes both big and small,
One helper now serves sizes for all.
Old console lines I sweep in a trice,
Neat code, fewer hops, and less device. 🥕

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes both main changes: deduplicating FormatSize across three models and optimizing ConsoleViewModel trimming logic with batch removal.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/code-review-batch-3

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
SysManager/SysManager/ViewModels/ConsoleViewModel.cs (1)

39-44: 🏗️ Heavy lift

This still does O(n) head-removal in steady state.

Because Append inserts one line at a time, excess is typically 1, so Line 43 is effectively RemoveAt(0) per append. That keeps the same shifting cost on ObservableCollection. If amortized O(1) is the goal, use a ring-buffer/queue-backed store and project the latest MaxLines to the UI.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@SysManager/SysManager/ViewModels/ConsoleViewModel.cs` around lines 39 - 44,
The current Append logic removes from the head of ObservableCollection
(Lines.RemoveAt(i)) which causes O(n) shifts per append; replace the
head-removal approach with a ring-buffer or queue-backed store and have the
ObservableCollection only reflect the latest window: add a private Queue<T> or
circular buffer field (e.g. _buffer) in ConsoleViewModel, on Append enqueue the
new line and while _buffer.Count > MaxLines dequeue from _buffer (O(1) ops),
then update Lines to project the _buffer contents (replace the
ObservableCollection contents in one update or by efficient batch/ReplaceRange)
instead of calling RemoveAt(0); reference the existing symbols Lines, MaxLines
and the current head-removal loop to locate where to swap in the queue-backed
logic.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@SysManager/SysManager/ViewModels/ConsoleViewModel.cs`:
- Around line 39-44: The current Append logic removes from the head of
ObservableCollection (Lines.RemoveAt(i)) which causes O(n) shifts per append;
replace the head-removal approach with a ring-buffer or queue-backed store and
have the ObservableCollection only reflect the latest window: add a private
Queue<T> or circular buffer field (e.g. _buffer) in ConsoleViewModel, on Append
enqueue the new line and while _buffer.Count > MaxLines dequeue from _buffer
(O(1) ops), then update Lines to project the _buffer contents (replace the
ObservableCollection contents in one update or by efficient batch/ReplaceRange)
instead of calling RemoveAt(0); reference the existing symbols Lines, MaxLines
and the current head-removal loop to locate where to swap in the queue-backed
logic.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 9851504b-1e64-4e9b-8a10-3d61c2d12fb6

📥 Commits

Reviewing files that changed from the base of the PR and between c78b2e7 and 11b8296.

📒 Files selected for processing (5)
  • CHANGELOG.md
  • SysManager/SysManager/Models/DiskUsageEntry.cs
  • SysManager/SysManager/Models/InstalledApp.cs
  • SysManager/SysManager/Models/ProcessEntry.cs
  • SysManager/SysManager/ViewModels/ConsoleViewModel.cs
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Analyze (csharp)
  • GitHub Check: Build & unit tests
🔇 Additional comments (3)
SysManager/SysManager/Models/DiskUsageEntry.cs (1)

24-24: Good deduplication to shared formatter.

Centralizing size formatting through CleanupCategory.HumanSize improves consistency and maintainability.

SysManager/SysManager/Models/ProcessEntry.cs (1)

36-36: Nice consistency win across models.

Using CleanupCategory.HumanSize here removes duplicate formatting logic and keeps output uniform.

SysManager/SysManager/Models/InstalledApp.cs (1)

26-26: Looks good—deduplicated without changing the fallback behavior.

The shared formatter plus existing "—" guard keeps display behavior clear.

@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@laurentiu021
laurentiu021 merged commit 6aa7bda into main May 12, 2026
5 checks passed
@laurentiu021
laurentiu021 deleted the fix/code-review-batch-3 branch May 12, 2026 08:43
laurentiu021 added a commit that referenced this pull request May 22, 2026
## Summary
Replace standalone sort buttons/dropdowns with native DataGrid clickable
column headers across 5 tabs, consistent with Windows Task Manager
behavior.

## Changes

### Process Manager (#266)
- Converted ListView to DataGrid with sortable columns: PID, Name,
Memory, CPU%, Threads, Status
- Removed toolbar sort buttons (Memory, CPU, Name, PID)
- Removed SortBy property and sort commands from ViewModel

### Uninstaller (#254)
- Converted ListView to DataGrid with sortable columns: Name, Size,
Version, Publisher, Source, Status
- Removed toolbar sort buttons (Name, Size, Publisher)
- Removed SortBy property and sort commands from ViewModel

### Services
- Removed redundant Sort ComboBox from toolbar (DataGrid already has
CanUserSortColumns)
- Added SortMemberPath on all columns
- Removed SortBy/SortOptions properties from ViewModel

### Startup Manager
- Converted ListView to DataGrid with sortable columns: Name, Publisher,
Status

### App Updates
- Added CanUserSortColumns=True and SortMemberPath on all columns

## Behavior
Click any column header to sort ascending. Click again to sort
descending.

## Tests
- Updated ProcessManagerViewModelTests and UninstallerViewModelTests for
removed sort commands

Closes #266, Closes #254, Closes #250

Co-authored-by: laurentiu021 <laurentiu021@users.noreply.github.com>
laurentiu021 added a commit that referenced this pull request May 22, 2026
…(CQ-008) (#254)

* fix: deduplicate FormatSize (CQ-002) and batch ConsoleViewModel trim (CQ-008)

* test: update MemoryDisplay expected format to match HumanSize

---------

Co-authored-by: laurentiu021 <laurentiu021@users.noreply.github.com>
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