feat(media): add filename and readiness filters to shared listing - #126
feat(media): add filename and readiness filters to shared listing#126FaiziNerd wants to merge 8 commits into
Conversation
tulayha
left a comment
There was a problem hiding this comment.
Adding filters to workspace() makes the existing action calculation incorrect. page.total is now the filtered count, while indexed_media still contains every indexed media item in the repository. Comparing them can hide index_media even when later filtered results are not indexed. Please calculate workspace actions using consistent filtered or unfiltered values.
| raise ValueError("The media cursor is invalid.") from exc | ||
| total = self.catalog.count_media() | ||
| total = self.catalog.count_media( | ||
| filename=command.filename, |
There was a problem hiding this comment.
The cursor is scoped only to the repository, so it can be reused with different filters. For example, a cursor from filename=clip can be sent with state=failed, and the failed-media results will start at the old offset and skip items. Please include filename and state in the cursor scope so a cursor is valid only for the query that created it.
|
Workspace action consistency Cursor/filter scoping Frontend ready-only picker |
Closes #80
Summary
Larger repositories can now be narrowed in
list_media/workspacewithout paging through the full catalog client-side.ListMediaCommandaccepts optionalfilenameandstatefilters. The same semantics are projected through CLI (--filename,--state), HTTP (GET /media,GET /workspace), and MCP (list_media,get_workspace). Filtering runs in the existing SQLite media catalog (COUNT+LISTwith the same predicates). Pagination and repository scoping are unchanged: cursors still encode offset in the current repository, and a filtered page uses the filtered total.Filename matching is a case-insensitive substring of
original_filename(soclipandCLIPboth matchHoliday-Clip.mp4).LIKEwildcards in the query are escaped. Readiness filtering uses the existingMediaStatevalues (ready,pending,failed). The two filters combine. This is catalog lookup, not a second library index and not video-content search.The browser UI lists ready media with
state=readyso the registered-video picker does not mix incomplete or failed imports. No storage or index rebuild is required.Test plan
filenameandstateare passed throughListMediaCommandwith the same meaningValidation
uv run --no-sync ruff check . uv run --no-sync pytest -q tests/test_media_catalog.py tests/test_media_services.py tests/test_api.py tests/test_cli.py tests/test_mcp.py tests/test_frontend.py