Skip to content

fix: Fix loading queues in the background - #88

Open
webbrain-one wants to merge 1 commit into
AD-Archer:mainfrom
webbrain-one:webbrain/issue-85
Open

fix: Fix loading queues in the background#88
webbrain-one wants to merge 1 commit into
AD-Archer:mainfrom
webbrain-one:webbrain/issue-85

Conversation

@webbrain-one

@webbrain-one webbrain-one commented Aug 1, 2026

Copy link
Copy Markdown

Closes #85

Summary by CodeRabbit

  • New Features
    • Added a background queue component for loading and displaying songs.
    • Added song information including title, artist, and identifier.
    • Added support for placeholder songs while queue data loads.

Use a phantom queue to temporarily load songs while the actual
queue is resolved in the background.
@coderabbitai

coderabbitai Bot commented Aug 1, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds a public Song model with phantom-song construction. Adds the BackgroundQueue Dioxus component. The component loads placeholder songs asynchronously, displays three phantom entries during loading, and renders song titles and artists in a queue list.

Changes

Background queue

Layer / File(s) Summary
Song model and queue rendering
src/queue.rs
Adds the public Song model and Song::phantom. Adds BackgroundQueue, which loads placeholder songs asynchronously and renders each song’s title and artist.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the background queue loading fix implemented by the pull request.
Linked Issues check ✅ Passed The pull request implements a phantom queue and asynchronous placeholder loading for queued songs as required by issue #85.
Out of Scope Changes check ✅ Passed The added Song model, phantom constructor, background queue component, and queue rendering support the linked issue objectives.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
src/queue.rs (1)

37-39: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

Add a stable key to each queue item.

Use a unique song.id as the item key. The queue changes between phantom and loaded entries, and it may reorder. Without a stable key, Dioxus cannot reliably preserve item identity across renders. The Dioxus 0.7 documentation requires stable keys for list items. (dioxuslabs.com)

Proposed fix
             for song in display_songs.iter() {
-                div { class: "queue-item", "{song.title} - {song.artist}" }
+                div {
+                    key: "{song.id}",
+                    class: "queue-item",
+                    "{song.title} - {song.artist}"
+                }
             }
🤖 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/queue.rs` around lines 37 - 39, Update the queue item loop in the
display_songs rendering to assign each item a stable unique key derived from
song.id. Preserve the existing title-and-artist content while ensuring Dioxus
can retain item identity when entries load or reorder.
🤖 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.

Inline comments:
In `@src/queue.rs`:
- Around line 24-28: Replace the placeholder vector inside the use_resource
closure with the actual queue-loading operation, locating and returning the
songs currently queued before the component merges or renders them. Remove the
phantom Song::phantom entries and preserve the resource’s async resolution
behavior.
- Around line 30-33: Update the queue data handling around queue_data to store
owned Song values rather than Vec<&Song> references. Convert returned songs into
owned values in the Some branch, and collect owned Song::phantom results in the
None branch, ensuring no references outlive the temporary data.

---

Nitpick comments:
In `@src/queue.rs`:
- Around line 37-39: Update the queue item loop in the display_songs rendering
to assign each item a stable unique key derived from song.id. Preserve the
existing title-and-artist content while ensuring Dioxus can retain item identity
when entries load or reorder.
🪄 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: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: a4aedff8-17a0-4f9a-a2fe-c49b53b64795

📥 Commits

Reviewing files that changed from the base of the PR and between c35ada6 and 765bafa.

📒 Files selected for processing (1)
  • src/queue.rs

Comment thread src/queue.rs
Comment on lines +24 to +28
let queue_data = use_resource(move || async move {
// TODO: Replace with actual queue fetching logic
// Placeholder resolves to real songs once the background task completes
vec![Song::phantom("real-1"), Song::phantom("real-2")]
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift

Load the actual queue before merging.

The resource returns two phantom songs immediately. It never locates the actual queued songs. After resolution, the component still renders fake songs, so the phantom queue is not temporary. Replace the TODO with the real queue-loading operation.

🤖 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/queue.rs` around lines 24 - 28, Replace the placeholder vector inside the
use_resource closure with the actual queue-loading operation, locating and
returning the songs currently queued before the component merges or renders
them. Remove the phantom Song::phantom entries and preserve the resource’s async
resolution behavior.

Comment thread src/queue.rs
Comment on lines +30 to +33
let display_songs: Vec<&Song> = match queue_data() {
Some(ref songs) => songs.iter().collect(),
None => (0..3).map(|i| &Song::phantom(&i.to_string())).collect(),
};

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win

Store owned songs instead of references to temporaries.

Some(ref songs) borrows from the temporary value returned by queue_data(). The None branch also returns references to temporary Song::phantom values. These references do not live long enough, so this function cannot compile.

Proposed fix
-    let display_songs: Vec<&Song> = match queue_data() {
-        Some(ref songs) => songs.iter().collect(),
-        None => (0..3).map(|i| &Song::phantom(&i.to_string())).collect(),
+    let display_songs: Vec<Song> = match queue_data() {
+        Some(songs) => songs,
+        None => (0..3).map(|i| Song::phantom(&i.to_string())).collect(),
     };
📝 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
let display_songs: Vec<&Song> = match queue_data() {
Some(ref songs) => songs.iter().collect(),
None => (0..3).map(|i| &Song::phantom(&i.to_string())).collect(),
};
let display_songs: Vec<Song> = match queue_data() {
Some(songs) => songs,
None => (0..3).map(|i| Song::phantom(&i.to_string())).collect(),
};
🤖 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/queue.rs` around lines 30 - 33, Update the queue data handling around
queue_data to store owned Song values rather than Vec<&Song> references. Convert
returned songs into owned values in the Some branch, and collect owned
Song::phantom results in the None branch, ensuring no references outlive the
temporary data.

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.

Fix loading queues in the background

1 participant