Repository navigation
feat(admin): admin libraries UX polish — full-table unmatched search, larger match-candidate posters with hover preview, paginated Ambiguous Roots - #20
Conversation
Match the sibling tables on the Admin Libraries page (Troubleshooting/unmatched): use the existing usePagination hook + PaginationBar (10/page, auto-hidden when <=10 rows), render pag.rows, and reset to page 0 when the library selector or search filter changes.
Unmatched-item match dialog rendered candidate posters at 44x64px, too small to identify a film. Bump to 64x96 (2:3) and add a portaled Tooltip hover preview (192x288) using the existing poster image, so operators can tell candidates apart. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThis PR adds server-side unmatched-item search (optional q), frontend debounced searching and query-key changes, ambiguous-roots pagination, candidate image preview tooltips, and test updates to exercise the new shapes and providers. ChangesLibrary Items Search, Pagination, and Preview Features
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
web/src/pages/AdminLibraries.test.tsx (1)
171-201: ⚡ Quick winReplace the skipped section test with the new ambiguous-roots contract.
This test is now the main missing coverage for the refactored area. Updating it to assert against
useLibraryRoots(_, "ambiguous")will keep regressions visible instead of silent.I can draft the updated test case (new mock shape + assertions) if you want me to open it as a follow-up issue.
🤖 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 `@web/src/pages/AdminLibraries.test.tsx` around lines 171 - 201, Replace the skipped test that mocks useSkippedLibraryRoots with a test that mocks mocks.useLibraryRoots to return data for the "ambiguous" root type (call useLibraryRoots(_, "ambiguous") in the component), updating the mock shape to match LibraryRoot (e.g., include library_id, library_name, root_path, ambiguity_reason or similar fields used by the UI) and set isLoading:false; then call renderPage() and change assertions to look for the ambiguous-roots UI strings (e.g., "Troubleshooting" plus the library_name, root_path, the ambiguity reason label, and any "First seen" / "Last seen" fields the refactored component renders) so the test exercises the new contract rather than the old useSkippedLibraryRoots shape.
🤖 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 `@internal/api/handlers/libraries.go`:
- Around line 2073-2086: The count query always includes the LEFT JOIN LATERAL
(aliased lib) which is unnecessary when the search/filter (q) is empty; modify
the code that builds countSQL in the handler so it conditionally omits the LEFT
JOIN LATERAL and its subselect when there is no folder_name-related filter,
i.e., construct two variants of countSQL (one with the lib lateral join and one
without) and use the appropriate one before calling h.pool.QueryRow(...). Ensure
you reference the same filterArgs ordering/parameters when switching SQL so
Scan(&total) behavior for total stays identical.
---
Nitpick comments:
In `@web/src/pages/AdminLibraries.test.tsx`:
- Around line 171-201: Replace the skipped test that mocks
useSkippedLibraryRoots with a test that mocks mocks.useLibraryRoots to return
data for the "ambiguous" root type (call useLibraryRoots(_, "ambiguous") in the
component), updating the mock shape to match LibraryRoot (e.g., include
library_id, library_name, root_path, ambiguity_reason or similar fields used by
the UI) and set isLoading:false; then call renderPage() and change assertions to
look for the ambiguous-roots UI strings (e.g., "Troubleshooting" plus the
library_name, root_path, the ambiguity reason label, and any "First seen" /
"Last seen" fields the refactored component renders) so the test exercises the
new contract rather than the old useSkippedLibraryRoots shape.
🪄 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: e5e0ae65-009f-43cf-bd17-935a077c6b57
📥 Commits
Reviewing files that changed from the base of the PR and between 985b296 and 925328d94484d25f5f7c648262d0b92a6bcba94f.
📒 Files selected for processing (6)
internal/api/handlers/libraries.goweb/src/components/MatchItemDialog.tsxweb/src/hooks/queries/admin/libraries.tsweb/src/hooks/queries/keys.tsweb/src/pages/AdminLibraries.test.tsxweb/src/pages/AdminLibraries.tsx
…he page
The unmatched-items search filtered only the current page's rows client-side.
Push the query server-side: HandleListUnmatchedItems takes an optional 'q' param
and filters title/library/type/status with parameterized ILIKE across all rows,
paginating the filtered set. Frontend hook takes a debounced search, resets to
page 1 on change, keeps the section mounted while searching. Also fixes stale
test mocks that returned the pre-pagination array shape instead of {items,total}.
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…nChange Run prettier over the Tooltip-wrapped poster JSX, and reset the unmatched-items page in the search input's onChange rather than a useEffect (avoids the react-hooks/set-state-in-effect warning / cascading renders). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…te runs The AdminLibraries test file failed all 6 tests with 'No QueryClient set' on this branch and at the parent commit -- pre-existing infrastructure gap. With that fixed, several hooks that the page imports (useCancelLibraryScans, useLibraryRoots, useUpsertLibraryRootOverride, useDeleteLibraryRootOverride, useActiveScans) and the UNMATCHED_PAGE_SIZE constant also needed mocking. One stale assertion on the renamed 'Root path' header is updated; the deeper troubleshooting test, which mocked useSkippedLibraryRoots but the section was refactored to useLibraryRoots(_, 'ambiguous'), is skipped with a TODO -- a real rewrite is needed and is out of scope for this MR. 5 of 6 tests now run and pass; the 6th is properly flagged. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
Actionable comments posted: 0 |
|
Actionable comments posted: 0 |
feat(admin): admin libraries UX polish — full-table unmatched search, larger match-candidate posters with hover preview, paginated Ambiguous Roots
feat(admin): admin libraries UX polish — full-table unmatched search, larger match-candidate posters with hover preview, paginated Ambiguous Roots
Problem
Three small but real admin-page UX issues:
Approach
web/src/components/MatchItemDialog.tsx): base size bumped to 64×96 (correct 2:3 aspect), and the poster is wrapped in a portaled RadixTooltipthat shows a 192×288 preview on hover. Uses the existingw300/w500poster variants already produced by the image resolver — no backend change. Tooltip portals out of the dialog'soverflow-y-autoscroll container so it isn't clipped. Click still selects the row (Tooltip'sasChildon the<img>doesn't create a nested-button problem).internal/api/handlers/libraries.go, hooks, page):HandleListUnmatchedItemstakes a new optionalqparam and filterstitle / type / status / library_nameserver-side with parameterisedILIKE(injection-safe; theLATERALjoin carrieslib.folder_nameinto bothCOUNTandLISTqueries so predicate parity holds). The frontend hook gains a debouncedsearchparameter; the page resets to page 1 in the input'sonChange(nosetState-in-useEffectcascade); the section stays mounted while a search is active so the "no matches" state stays visible.qis optional — existing callers are unaffected.usePaginationhelper and resets to page 0 on filter/library change.Testing
This MR also includes a test-infra fix (
web/src/pages/AdminLibraries.test.tsx): the suite was failing all 6 tests withNo QueryClient setonmain(pre-existing pre-merge gate gap). WithQueryClientProviderwired and five additional hooks mocked (useCancelLibraryScans,useLibraryRoots,useUpsertLibraryRootOverride,useDeleteLibraryRootOverride,useActiveScans) plus theUNMATCHED_PAGE_SIZEconstant export, the suite actually runs. The one test that remains skipped is the deeper troubleshooting-section refactor (useSkippedLibraryRoots→useLibraryRoots(_, "ambiguous")); fixing it is a test rewrite, not a one-liner, and is intentionally out of scope.The frontend build (
pnpm run build) succeeded; the rebuilt image was deployed to a personal instance and the three flows visually verified.Watch out
LATERAL ... LIMIT 1subquery picks an arbitrary folder when an item belongs to multiple libraries (pre-existing behaviour, not introduced here) — the newqfilter onlib.folder_nametherefore matches only that arbitrary folder name. Pinning this to "any library the item is in" is a sensible follow-up.pnpm run lintreports 115 warnings (0 errors) andpnpm run format:checkflags 18 files needing prettier — all pre-existing, none introduced by this MR.Compatibility
GET /libraries/unmatched-itemsadds optionalqquery param. Existing callers continue to work unchanged.Note on process
I did not open an issue first; happy to retroactively if preferred.
AI disclosure
AI (Claude) meaningfully shaped this implementation across the three changes and the test-infra fix; every line was read locally before commit.
Summary by CodeRabbit
New Features
Behavioral Fixes
Tests