|
| 1 | +--- |
| 2 | +id: TASK-311 |
| 3 | +title: >- |
| 4 | + Refactor Genius to preview/refine/approve flow instead of one-shot playlist |
| 5 | + creation |
| 6 | +status: In Progress |
| 7 | +assignee: [] |
| 8 | +created_date: '2026-04-04 08:59' |
| 9 | +updated_date: '2026-04-04 09:07' |
| 10 | +labels: |
| 11 | + - genius |
| 12 | + - ux |
| 13 | + - refactor |
| 14 | +dependencies: [] |
| 15 | +references: |
| 16 | + - docs/agent.md |
| 17 | + - docs/genius.md |
| 18 | + - crates/mt-tauri/src/agent/mod.rs |
| 19 | + - app/frontend/js/components/genius-browser.js |
| 20 | +priority: medium |
| 21 | +--- |
| 22 | + |
| 23 | +## Description |
| 24 | + |
| 25 | +<!-- SECTION:DESCRIPTION:BEGIN --> |
| 26 | +Currently, Genius one-shots playlist creation: the user enters a prompt, the agent generates tracks, and a playlist is immediately persisted to the database. There is no opportunity to preview, refine, or reject the result before it's saved. |
| 27 | + |
| 28 | +Refactor the flow into a multi-step dialogue: |
| 29 | + |
| 30 | +1. **Generate** — User submits a prompt, agent generates a candidate track list (as today) |
| 31 | +2. **Preview** — Display the candidate tracks in the UI *without* persisting to the database. User can see track names, artists, and any other relevant metadata |
| 32 | +3. **Refine** — User can provide feedback (e.g., "remove the jazz tracks", "add more Radiohead", "make it longer") which triggers another agent turn to revise the candidate list. This can repeat multiple times |
| 33 | +4. **Approve** — User explicitly approves the final track list, at which point the playlist is created in the database |
| 34 | + |
| 35 | +### Backend changes (Rust) |
| 36 | + |
| 37 | +- Split `agent_generate_playlist` into two phases: |
| 38 | + - **Generate/refine phase**: Returns a candidate `AgentResponse` with track list but does NOT persist to database |
| 39 | + - **Approve phase**: New Tauri command (e.g., `agent_approve_playlist`) that accepts the finalized track IDs and creates the playlist |
| 40 | +- Support multi-turn refinement: the agent needs conversational context (prior turns) to refine intelligently. Consider whether to maintain session state in the backend or pass conversation history from the frontend |
| 41 | +- `shuffle_spread_artists()` should run at approve time, not generate time |
| 42 | + |
| 43 | +### Frontend changes (Alpine.js) |
| 44 | + |
| 45 | +- After generation, show a preview panel with the candidate tracks (not a toast) |
| 46 | +- Provide UI for: |
| 47 | + - Approving the playlist (triggers persist) |
| 48 | + - Entering refinement feedback (triggers another agent turn with context) |
| 49 | + - Canceling/discarding the candidate |
| 50 | +- Track list in preview should show enough metadata for the user to evaluate quality (title, artist, album, duration) |
| 51 | +- Consider drag-to-reorder or remove-individual-tracks in the preview |
| 52 | + |
| 53 | +### Key files |
| 54 | + |
| 55 | +- `crates/mt-tauri/src/agent/mod.rs` — agent orchestration, `agent_generate_playlist`, `parse_agent_response`, `shuffle_spread_artists` |
| 56 | +- `app/frontend/js/components/genius-browser.js` — Alpine.js component, generation flow |
| 57 | +- `app/frontend/js/api/agent.js` — Tauri IPC bridge |
| 58 | +- `app/frontend/views/genius.html` — Genius view template |
| 59 | +<!-- SECTION:DESCRIPTION:END --> |
| 60 | + |
| 61 | +## Acceptance Criteria |
| 62 | +<!-- AC:BEGIN --> |
| 63 | +- [ ] #1 Submitting a Genius prompt returns a candidate track list without creating a playlist in the database |
| 64 | +- [ ] #2 Candidate tracks are displayed in a preview panel showing title, artist, album, and duration |
| 65 | +- [ ] #3 User can enter refinement feedback that sends another agent turn with conversational context, updating the preview |
| 66 | +- [ ] #4 Refinement can be repeated multiple times before approving |
| 67 | +- [ ] #5 User can approve the candidate, which persists the playlist to the database and emits PlaylistsUpdatedEvent |
| 68 | +- [ ] #6 User can discard/cancel a candidate without any database side effects |
| 69 | +- [ ] #7 shuffle_spread_artists runs at approve time, not generate time |
| 70 | +- [ ] #8 Existing one-shot behavior is fully replaced (no legacy path) |
| 71 | +<!-- AC:END --> |
0 commit comments