← Back to Pull requests

feat(library): complete library context menu (T2.1.10 Batch B/C) #60

Open
unknown opened this pull request with 650 lines diff across 8 files
View on GitHub
unknown unknown commented on Oct 26, 2026 23:55 UTC
Author

Summary


  • Reversible soft remove. Migration 008 adds tracks.removed_at; the list, count and library-stats SQL all filter removed_at IS NULL, so a removed track leaves every read path while its row, cue points, tags and analysis stay on disk. The write and its skill_runs snapshot commit in one transaction; Undo restores only the rows still holding the state the write left (a track removed again since is skipped), and a second undo of the same id is refused. Nothing ever touches the audio file.

  • Reveal in Finder / Explorer. New reveal_in_file_manager command: explorer /select,<path> on Windows, open -R on macOS, xdg-open <parent dir> on Linux. The argument shape lives in crates/core/src/reveal.rs so it is unit-tested (the desktop crate's test binary cannot start on the dev box); the command only checks the path exists and spawns the program — never through a shell. A missing xdg-open surfaces as a readable error.

  • Copy path via the Web clipboard (no clipboard plugin is in the capability set), with the same failure copy the track panel's File tab already uses.

  • The rest of §3.5. Reveal → Copy path → Remove last, in the spec's order and grouping; Analyze, Add to playlist/set, Find in playlists, Mix suggestions and the two online-find items render disabled with their reason ("Selection-scoped analysis coming soon", "Coming in Phase 3", "Coming in Slice 6"), and Fix tags keeps its Tag Surgeon (T2.2) tooltip. Menu rows/order/grouping come from MENU_LAYOUT in src/lib/library-menu.ts — a pure module, because .tsx tests are never collected by this repo's harness.

  • Removal is confirm-gated (ModalShell dialog) and the Undo toast now carries a kind, so the remove toast runs the remove undo path rather than the metadata one.
  • Tests


  • crates/core: 157 unit tests (remove/undo SQL, snapshot docs, guards, reveal arg shapes) — library_remove.rs, reveal.rs.

  • tests/schema/tests/soft_remove.rs: 6 round-trip tests on the real migrated schema — row + cues + tags survive, undo restores once then refuses, a re-removed track is skipped, an already-removed selection writes no snapshot, a foreign skill_runs snapshot is refused, and stats agree with the list after a remove. Mutation-checked: weakening present_states or dropping the undo AND removed_at IS ?2 guard makes them fail.

  • scripts/make-library-fixture.test.mjs: migration count 7 → 8 (the fixture reads the migrations directory).

  • pnpm ci:local:portable is green end to end (lint, typecheck, 173 desktop + 23 shared + 2 api + 59 agent + 10 tools JS tests, rustfmt, clippy -D warnings, and the portable Rust suites).
  • Known limits (not covered by a test on this box)


  • UI surface is code-verified only. The Tauri desktop test binary dies with STATUS_ENTRYPOINT_NOT_FOUND before running, .tsx tests are never collected, and the browser dev server mocks an empty library, so the menu render, the confirm dialog and the clipboard write were read and type-checked but not driven.

  • Per-id detail reads (get_track, cues, tags) still resolve a soft-removed row — intentional, so the Undo path and the panel can still name the track; only the list and the stats were filtered.

  • The two online-find stubs cite "Coming in Phase 3" although no roadmap entry schedules them yet; the playlist (Phase 3) and mix-suggestions (Slice 6) citations are real.
  • Test plan


  • pnpm ci:local:portable green (ran locally, exit 0)

  • In the real app: right-click a row → menu matches docs/ui/03-LIBRARY-VIEW.md §3.5 order, stubs greyed with tooltips

  • Remove 1 track → toast "Removed 1 track from library" + Undo → row returns; SELECT removed_at is NULL again and skill_runs.status = undone

  • Remove, then Undo after removing it again → reported as skipped, not resurrected

  • Reveal opens Explorer at the file; Copy path puts the path on the clipboard

  • Confirm no audio file changed on disk
  • <!-- greptile_comment -->

    <!-- greptile_summary -->

    <h2><a href="https://app.greptile.com/api/retrigger?id=88548637"><picture><source media="(prefers-color-scheme: dark)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/RetriggerDark.svg?v=2"><source media="(prefers-color-scheme: light)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/Retrigger.svg?v=2"><img alt="Retrigger" src="https://greptile-static-assets.s3.amazonaws.com/badges/Retrigger.svg?v=2" align="right"></picture></a><a href="https://app.greptile.com/mediabubble/github/iDorgham/dj-assistant/-/pull/60"><picture><source media="(prefers-color-scheme: dark)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptileDark.svg?v=2"><source media="(prefers-color-scheme: light)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptile.svg?v=2"><img alt="View in Greptile" src="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptile.svg?v=2" align="right"></picture></a>Confidence Score: 2/5</h2>

    <!-- greptile-risk -->

    Fix track recovery, older-database reads, and library-wide removal filters before merging.

    <h2>Findings</h2>

    1. <img alt="P1" src="https://greptile-static-assets.s3.amazonaws.com/badges/p1.svg?v=9" align="top">&nbsp;Removed tracks cannot return <a href="https://github.com/iDorgham/DJ-Assistant/pull/60#discussion_r4383789531">▶</a>
    2. <img alt="P1" src="https://greptile-static-assets.s3.amazonaws.com/badges/p1.svg?v=9" align="top">&nbsp;Older library queries fail <a href="https://github.com/iDorgham/DJ-Assistant/pull/60#discussion_r4383789542">▶</a>
    3. <img alt="P1" src="https://greptile-static-assets.s3.amazonaws.com/badges/p1.svg?v=9" align="top">&nbsp;Removed tracks still get work <a href="https://github.com/iDorgham/DJ-Assistant/pull/60#discussion_r4383789547">▶</a>
    4. <img alt="P2" src="https://greptile-static-assets.s3.amazonaws.com/badges/p2.svg?v=9" align="top">&nbsp;Menu actions lose keyboard focus <a href="https://github.com/iDorgham/DJ-Assistant/pull/60#discussion_r4383789562">▶</a>

    <details><summary>Fix with agent prompt</summary>

    `

    ### Issue 1
    crates/core/src/library_remove.rs:63-64
    `remove_statement` keeps the row and its hash, but the desktop scanner treats every matching hash as already imported and skips it. Once the Undo toast closes, scanning the folder cannot bring the track back, and the user has no app control to recover it. Make scanning restore a matching removed row while keeping its saved analysis, cues, and tags.
    
    ### Issue 2
    crates/core/src/library_query.rs:232
    `TrackQuery::build` now requires `removed_at` for every query, but `dj-query` supports older databases and `dj-scan` still creates databases with only migration 001. Listing those databases now fails with `no such column: removed_at`; the changed statistics queries fail too. Add this condition only when the column exists, or update every supported database path before requiring it.
    
    ### Issue 3
    apps/desktop/src-tauri/src/commands.rs:1235-1236
    Removal hides tracks from `TrackQuery` and the shared statistics, but other library-wide reads still include them. `list_genres` counts them, `analyze_library` queues them, and `enrichment_preview` returns them for online lookup. These are active app flows, not the intentionally preserved per-track detail reads. Add `removed_at IS NULL` to library-wide reads so removed tracks stop appearing in counts and bulk work.
    
    ### Issue 4
    apps/desktop/src/components/RowContextMenu.tsx:235-239
    `run` prevents focus from returning for Copy path and Reveal, although neither action focuses another element in the app. When a keyboard user activates either item, the focused menu button disappears and focus falls back to the page. Restore row focus for these actions; reserve `actionTakenRef` suppression for actions that open another app control.
    
    Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
    
    ---
    
    For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.
    
    `

    </details>

    <h3>Summary</h3>

    Adds confirmed soft removal with Undo, file reveal, Copy path, and the remaining disabled context-menu items.

  • Removing tracks hides them from the library but keeps them available for Undo.

  • The row menu shows every library action in the spec’s order.

  • The menu can reveal a track’s file or copy its path.
  • Acknowledged limits from iDorgham: per-track detail reads intentionally remain available; online-find stubs cite Phase 3 without a scheduled roadmap entry. Neither is reported as a finding.

    <details open><summary><h3>Diagram</h3></summary>

    %%{init: {'theme': 'neutral'}}%%
    flowchart TD
      A[Confirm removal] --> B[Stamp removed_at]
      B --> C[Save Undo snapshot in same transaction]
      C --> D[Commit]
      D --> E[List and shared stats hide track]
      D --> F[Other bulk reads still include track]
      D --> G[Scanner still finds retained hash]
      G --> H[Reimport skipped]
      C --> I[Undo checks snapshot and current stamp]
      I --> J[Clear removed_at and mark snapshot undone]
    

    </details>

    <!-- greptile_confidence_score:2 -->

    <sub>Reviews (1) · Last reviewed commit: "feat(library): complete context menu wit..." · Reviewed by Greptile</sub>

    <!-- /greptile_comment -->

    <!-- This is an auto-generated comment: release notes by coderabbit.ai -->

    <!-- coderabbit-ai-generated:v1 -->

    Summary by CodeRabbit

    New Features
    Remove tracks from the library without deleting their files or associated data, and undo removals when possible.
    Use the row menu to copy a track’s path or reveal it in the file manager.
    The row menu now supports scrolling and provides clearer disabled-action guidance.

    Bug Fixes
    Removed tracks no longer appear in library lists, searches, or summary counts.

    <!-- end of auto-generated comment: release notes by coderabbit.ai -->

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: greptile-apps[bot] Review duration: 7m
    All Vouch review confidence checks passed
    Residual risk 0.39 = Change Risk (0.52) × (1 − Review Confidence (0.24)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.52 · 650 lines diff across 8 files
    0.52
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 44% · Reviewer familiarity: 35%
    24%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.388
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #60"
    general weight: 0.35
    Assignees
    Unassigned
    Labels
    risk: medium confidence: 24.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 52% (MEDIUM) · Higher = larger blast radius
    52%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 24.5% · Lower = rushed or shallow review
    24.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 39.3% · Moderate risk
    39.3%