Skip to content

Add size sorting to file list (#254)#334

Merged
nitrobass24 merged 2 commits intodevelopfrom
feat/file-list-size-sort-v2
Apr 4, 2026
Merged

Add size sorting to file list (#254)#334
nitrobass24 merged 2 commits intodevelopfrom
feat/file-list-size-sort-v2

Conversation

@nitrobass24
Copy link
Copy Markdown
Owner

@nitrobass24 nitrobass24 commented Apr 3, 2026

Summary

  • Add SIZE_ASC and SIZE_DESC to SortMethod enum
  • Comparators use remoteSize, fall back to localSize, nulls sort last, ties break by name
  • UI shows "Size S→L" and "Size L→S" in sort dropdown

Test plan

  • All 303 Vitest tests pass (12 new sort tests added)
  • Verify size sort in UI with mixed file sizes
  • Verify null-size files sort to bottom
  • Verify sort persists across page reloads

Closes #254

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added two size-based sort options to the Sort menu (Size S→L, Size L→S); sorts use available size data and place items without size at the end, tie-broken alphabetically.
  • Accessibility
    • Improved alt text for sort icons in the UI.
  • Tests
    • Added unit tests validating size-based sorting behavior and edge cases.

Add SIZE_ASC and SIZE_DESC options to the SortMethod enum so users can
sort the file list by size (smallest-first or largest-first). Uses
remoteSize with localSize fallback; null/zero sizes sort last. Includes
Vitest tests for both directions, null handling, and tiebreaking by name.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 3, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: fbdd6a32-45a4-4a97-8f71-3eec6dc96b97

📥 Commits

Reviewing files that changed from the base of the PR and between 334c9ec and 0d48390.

📒 Files selected for processing (1)
  • src/angular/src/app/pages/files/file-options.component.html

📝 Walkthrough

Walkthrough

Adds size-based sorting to the file list: new SIZE_ASC/SIZE_DESC enum values, UI dropdown entries, comparator implementations using effective size (remote → local → null) with name tie-breakers, and unit tests covering comparator behavior.

Changes

Cohort / File(s) Summary
Enum Extension
src/angular/src/app/models/view-file-options.ts
Added SIZE_ASC and SIZE_DESC to SortMethod.
UI Component
src/angular/src/app/pages/files/file-options.component.html
Updated Sort dropdown/selected display to include size sort options and accessible alt text for icons; new dropdown-items invoke onSort with size methods and reflect active state.
Service Implementation
src/angular/src/app/services/files/view-file-sort.service.ts
Added getEffectiveSize helper and SizeAscendingComparator / SizeDescendingComparator; comparators place null/zero sizes last and use name.localeCompare for ties; switch updated to set these comparators with debug logs.
Test Suite
src/angular/src/app/services/files/view-file-sort.service.spec.ts
New unit tests validating comparator registration and behavior for default, SIZE_ASC, and SIZE_DESC (effective size selection, null/zero handling, tie-breaking by name).

Sequence Diagram(s)

sequenceDiagram
  participant UI as "File Options UI"
  participant OptionsSvc as "ViewFileOptionsService"
  participant SortSvc as "ViewFileSortService"
  participant FileSvc as "ViewFileService"

  UI->>OptionsSvc: user selects SortMethod (e.g. SIZE_ASC)
  OptionsSvc-->>SortSvc: emits new options (sortMethod)
  SortSvc->>SortSvc: compute comparator (getEffectiveSize + comparator)
  SortSvc->>FileSvc: setComparator(comparator)
  FileSvc->>FileSvc: apply comparator when sorting file list
  FileSvc-->>UI: updated sorted file list
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I nibble bytes and count each size,

From tiny crumbs to mountain pies.
Remote then local is the trick,
Name breaks ties, both clever and quick.
Hop, sort, and dance — small to big or vice! 🎋

🚥 Pre-merge checks | ✅ 2 | ❌ 3

❌ Failed checks (2 warnings, 1 inconclusive)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The PR partially addresses linked issue #254: SIZE_ASC/SIZE_DESC sorting with numeric comparison, proper tie-breaking, and null-value handling are implemented, but sort preference persistence via localStorage is not evidenced in the changes. Verify or implement localStorage persistence to complete acceptance criterion 'Sort preference persists across page reloads' from issue #254.
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Out of Scope Changes check ❓ Inconclusive The PR introduces accessible alt text for sort icons, which is a quality improvement but not explicitly required by issue #254's acceptance criteria. Clarify whether accessibility improvements for existing UI elements fall within the scope of this sorting feature implementation.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title 'Add size sorting to file list' clearly and concisely summarizes the main change: introducing size-based sorting capability to the file list.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/file-list-size-sort-v2

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.

❤️ Share

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

@nitrobass24
Copy link
Copy Markdown
Owner Author

@CodeRabbit review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 3, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/angular/src/app/pages/files/file-options.component.html`:
- Around line 145-156: The new <img> icons inside the
file-options.component.html conditional blocks for SortMethod.SIZE_ASC and
SortMethod.SIZE_DESC (and the similar icons later at lines ~181–187) are missing
alt attributes; update each <img> (e.g., those with class names sort-asc and
sort-desc) to be decorative by adding alt="" and aria-hidden="true" so assistive
tech ignores them while the visible <span class="text"> remains the accessible
label.
🪄 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: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 2b58a26d-9c69-4d6e-a345-cbb532882650

📥 Commits

Reviewing files that changed from the base of the PR and between eedd9e7 and 334c9ec.

📒 Files selected for processing (4)
  • src/angular/src/app/models/view-file-options.ts
  • src/angular/src/app/pages/files/file-options.component.html
  • src/angular/src/app/services/files/view-file-sort.service.spec.ts
  • src/angular/src/app/services/files/view-file-sort.service.ts

Comment on lines +145 to +156
@if ((options | async)?.sortMethod === SortMethod.SIZE_ASC) {
<div class="sel-item">
<div class="icon"><img src="assets/icons/sort-asc.svg" class="sort-asc" /></div>
<span class="text">Size S&#8594;L</span>
</div>
}
@if ((options | async)?.sortMethod === SortMethod.SIZE_DESC) {
<div class="sel-item">
<div class="icon"><img src="assets/icons/sort-desc.svg" class="sort-desc" /></div>
<span class="text">Size L&#8594;S</span>
</div>
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify any Angular template img tags still missing alt attributes
rg -nP --type-add 'html:*.html' --type=html '<img(?![^>]*\balt=)[^>]*>' src/angular/src

Repository: nitrobass24/seedsync

Length of output: 4209


Add alt attributes to the new sort icons for accessibility.

Lines 147, 153, 181, and 187 introduce <img> elements without alt. Since visible text already labels each option, use decorative alt text (alt="") and hide icons from assistive tech with aria-hidden="true".

Proposed fix
-                        <div class="icon"><img src="assets/icons/sort-asc.svg" class="sort-asc" /></div>
+                        <div class="icon"><img src="assets/icons/sort-asc.svg" class="sort-asc" alt="" aria-hidden="true" /></div>
-                        <div class="icon"><img src="assets/icons/sort-desc.svg" class="sort-desc" /></div>
+                        <div class="icon"><img src="assets/icons/sort-desc.svg" class="sort-desc" alt="" aria-hidden="true" /></div>

(Also applies to lines 181–187)

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
@if ((options | async)?.sortMethod === SortMethod.SIZE_ASC) {
<div class="sel-item">
<div class="icon"><img src="assets/icons/sort-asc.svg" class="sort-asc" /></div>
<span class="text">Size S&#8594;L</span>
</div>
}
@if ((options | async)?.sortMethod === SortMethod.SIZE_DESC) {
<div class="sel-item">
<div class="icon"><img src="assets/icons/sort-desc.svg" class="sort-desc" /></div>
<span class="text">Size L&#8594;S</span>
</div>
}
`@if` ((options | async)?.sortMethod === SortMethod.SIZE_ASC) {
<div class="sel-item">
<div class="icon"><img src="assets/icons/sort-asc.svg" class="sort-asc" alt="" aria-hidden="true" /></div>
<span class="text">Size S&#8594;L</span>
</div>
}
`@if` ((options | async)?.sortMethod === SortMethod.SIZE_DESC) {
<div class="sel-item">
<div class="icon"><img src="assets/icons/sort-desc.svg" class="sort-desc" alt="" aria-hidden="true" /></div>
<span class="text">Size L&#8594;S</span>
</div>
}
🧰 Tools
🪛 HTMLHint (1.9.2)

[warning] 147-147: An alt attribute must be present on elements.

(alt-require)


[warning] 153-153: An alt attribute must be present on elements.

(alt-require)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/angular/src/app/pages/files/file-options.component.html` around lines 145
- 156, The new <img> icons inside the file-options.component.html conditional
blocks for SortMethod.SIZE_ASC and SortMethod.SIZE_DESC (and the similar icons
later at lines ~181–187) are missing alt attributes; update each <img> (e.g.,
those with class names sort-asc and sort-desc) to be decorative by adding alt=""
and aria-hidden="true" so assistive tech ignores them while the visible <span
class="text"> remains the accessible label.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@nitrobass24
Copy link
Copy Markdown
Owner Author

@CodeRabbit review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 4, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@nitrobass24 nitrobass24 merged commit 9e86676 into develop Apr 4, 2026
16 checks passed
@nitrobass24 nitrobass24 deleted the feat/file-list-size-sort-v2 branch April 4, 2026 23:15
@nitrobass24 nitrobass24 mentioned this pull request Apr 8, 2026
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.

File list sorting by name, status, and size

1 participant