Skip to content

feat(ui): add persisted sound sorting - #211

Merged
thewrz merged 4 commits into
mainfrom
feat/issue-197
Jul 23, 2026
Merged

feat(ui): add persisted sound sorting#211
thewrz merged 4 commits into
mainfrom
feat/issue-197

Conversation

@thewrz

@thewrz thewrz commented Jul 23, 2026

Copy link
Copy Markdown
Collaborator

Why

Sound libraries need predictable ordering that survives restarts without coupling sort preferences to the session-only filter.

What

Add reusable sort state, chip, and dismissible options menu; persist tolerant per-view preferences; and sort main sound tiles by Name, Length, Folder, Modified, or Added with deterministic ties and unknown dates last. Malformed sort preference fields or future view entries now fall back independently without weakening validation for the rest of the application config. The change also extracts header and config helpers so touched files remain within the repository size limit.

Testing

  • Unit tests pass: cargo test (654 library tests)
  • Integration tests pass: cargo test (all binary/integration/doc targets)
  • Lints pass: cargo clippy --all-targets -- -D warnings
  • Formatting passes: cargo fmt --all -- --check
  • Manual verification: launch HonkHonk and exercise the sort chip/menu
  • CI green

🤖 Co-authored by Codex. Closes #197.

Summary by CodeRabbit

  • New Features

    • Added sound sorting by name, length, folder, modified date, and added date.
    • Added ascending/descending controls with a sort menu and visual sort indicator.
    • Sort preferences are saved and restored between sessions.
    • Filtering and sorting now work together with cached, responsive results.
    • Added header navigation, search, recording controls, and improved favorites handling.
  • Bug Fixes

    • Unknown dates and durations are consistently placed at the end of sorted results.
    • Updating metadata, favorites, or library information now refreshes displayed results correctly.
  • Documentation

    • Added a design specification for persisted sound-tile sorting.

@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown

Review Change Stack

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: a5db0728-650a-42c8-9767-49d9cd2bfb44

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Changes

Sound sorting and indexed rendering

Layer / File(s) Summary
Sorting contracts and configuration
docs/superpowers/specs/..., src/state/config/*, src/ui/list_controls/*
Adds persisted SortPref data, tolerant configuration deserialization, generic sort state and menu controls, and index-based filtering.
Sound sorting and filter cache
src/app/sorting*, src/app/filtering*, src/app/library_scan.rs, src/app/sound_metadata.rs
Adds sound sort keys, deterministic ordering, cached filtered indices, and refreshes for query, category, metadata, duration, and library changes.
Application wiring and sort-menu rendering
src/app/mod.rs, src/app/header.rs, src/app/sorting/view.rs, src/ui/sound_grid.rs
Connects sort messages and persistence to application state, renders the header and overlay menu, and renders grid tiles from visible indices.
Benchmark rendering migration
benches/grid_render.rs, benches/support/mod.rs
Updates tiny-skia and wgpu benchmarks to pass sound slices and explicit visible-index lists.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant Header
  participant HonkHonk
  participant FilterCache
  participant SoundGrid
  User->>Header: choose sort key or direction
  Header->>HonkHonk: send sort message
  HonkHonk->>FilterCache: refresh filtered sound indices
  FilterCache-->>HonkHonk: ordered indices
  HonkHonk->>SoundGrid: render sounds with indices
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 38.74% 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 clearly summarizes the main change: persisted sound sorting in the UI.
Linked Issues check ✅ Passed The PR covers the sort module, chip/menu UI, per-view persisted prefs, main-grid consumer, and config/tests required for #197.
Out of Scope Changes check ✅ Passed No clearly unrelated code changes stand out; the diff stays focused on sorting, persistence, filtering, and supporting UI/config plumbing.

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

@thewrz

thewrz commented Jul 23, 2026

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

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.

@thewrz

thewrz commented Jul 23, 2026

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

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.

thewrz and others added 3 commits July 23, 2026 13:23
Add reusable list sort controls, tolerant per-view preferences, and deterministic ordering for the main sound grid.

Co-Authored-By: Codex <noreply@openai.com>
Deserialize sort preferences independently so malformed future entries fall back without invalidating otherwise usable application settings.

Co-Authored-By: Codex <noreply@openai.com>
Move sound filtering and sorting to update-side invalidation boundaries so Iced view construction only indexes cached results. Project only the active sort key and keep render benchmarks on the production cached-index API.

Co-Authored-By: Codex <noreply@openai.com>
@thewrz
thewrz marked this pull request as ready for review July 23, 2026 20:40

@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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/ui/sound_grid.rs (1)

87-109: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Padding count should be based on resolved tiles, not raw index-chunk length.

missing_tile_slots(chunk.len(), columns) pads using the chunk's raw index count, but tiles may have fewer elements than chunk.len() if any index in chunk fails to resolve via sounds.get(index) (dropped by filter_map). In that case the row ends up short by the number of dropped indices instead of being padded up to columns, causing a visually misaligned row rather than a full, correctly-padded one.

🐛 Proposed fix
-            tiles.extend((0..missing_tile_slots(chunk.len(), columns)).map(|_| {
+            tiles.extend((0..missing_tile_slots(tiles.len(), columns)).map(|_| {
                 Space::new()
                     .width(Length::Fill)
                     .height(tile_layout::tile_slot_height())
                     .into()
             }));
🤖 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 `@src/ui/sound_grid.rs` around lines 87 - 109, Update the padding calculation
in the row-building closure around sound_tile::view so missing_tile_slots uses
the number of resolved tiles in tiles, not chunk.len(). Preserve the existing
padding behavior while ensuring rows with unresolved sounds are filled to
columns.
🧹 Nitpick comments (1)
src/state/config/persistence.rs (1)

19-53: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Deduplicate load()/load_from().

Both methods repeat the same exists-check → default-save → read → deserialize sequence, differing only in how path is obtained.

♻️ Proposed refactor
     pub fn load() -> Result<Self, ConfigError> {
-        let path = Self::config_path()?;
-
-        if !path.exists() {
-            let config = Self::default();
-            config.save()?;
-            return Ok(config);
-        }
-
-        let contents = read_config(&path)?;
-        serde_json::from_str(&contents).map_err(|source| ConfigError::Deserialize {
-            path: path.display().to_string(),
-            source,
-        })
+        Self::load_from(&Self::config_path()?)
     }
🤖 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 `@src/state/config/persistence.rs` around lines 19 - 53, Deduplicate the shared
loading logic by making load() obtain Self::config_path() and delegate to
load_from(), leaving load_from() as the single implementation of the
exists-check, default-save, read, and deserialization sequence. Preserve the
existing ConfigError handling and behavior for both configured and explicit
paths.
🤖 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.

Outside diff comments:
In `@src/ui/sound_grid.rs`:
- Around line 87-109: Update the padding calculation in the row-building closure
around sound_tile::view so missing_tile_slots uses the number of resolved tiles
in tiles, not chunk.len(). Preserve the existing padding behavior while ensuring
rows with unresolved sounds are filled to columns.

---

Nitpick comments:
In `@src/state/config/persistence.rs`:
- Around line 19-53: Deduplicate the shared loading logic by making load()
obtain Self::config_path() and delegate to load_from(), leaving load_from() as
the single implementation of the exists-check, default-save, read, and
deserialization sequence. Preserve the existing ConfigError handling and
behavior for both configured and explicit paths.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 7de4d802-062f-4a08-b8aa-f014b31804df

📥 Commits

Reviewing files that changed from the base of the PR and between 640595c and 767723a.

📒 Files selected for processing (21)
  • benches/grid_render.rs
  • benches/support/mod.rs
  • docs/superpowers/specs/2026-07-23-issue-197-design.md
  • src/app/filtering.rs
  • src/app/filtering/cache.rs
  • src/app/header.rs
  • src/app/library_scan.rs
  • src/app/mod.rs
  • src/app/sorting.rs
  • src/app/sorting/tests.rs
  • src/app/sorting/view.rs
  • src/app/sound_metadata.rs
  • src/state/config.rs
  • src/state/config/persistence.rs
  • src/state/config/sort.rs
  • src/state/config/types.rs
  • src/state/mod.rs
  • src/ui/list_controls/filter.rs
  • src/ui/list_controls/mod.rs
  • src/ui/list_controls/sort.rs
  • src/ui/sound_grid.rs

coderabbitai[bot]
coderabbitai Bot previously approved these changes Jul 23, 2026
Keep grid rows aligned when cached indices no longer resolve and consolidate config loading through the explicit-path implementation.

Co-Authored-By: Codex <noreply@openai.com>
Comment thread src/ui/sound_grid.rs
Comment thread src/state/config/persistence.rs
@thewrz
thewrz merged commit c13bcda into main Jul 23, 2026
7 checks passed
@thewrz
thewrz deleted the feat/issue-197 branch July 23, 2026 21:11
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.

feat(ui): list-controls sort module — chip + options menu + persisted prefs

1 participant