-
Notifications
You must be signed in to change notification settings - Fork 561
feat: support searching by title in partial ID resolver #158
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -263,9 +263,10 @@ async def _resolve_partial_id( | |||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| Allows users to type partial IDs like 'abc' instead of full UUIDs. | ||||||||||||||||||||||||||
| Matches are case-insensitive prefix matches. | ||||||||||||||||||||||||||
| Also supports searching by title (prefix match, case-insensitive). | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| Args: | ||||||||||||||||||||||||||
| partial_id: Full or partial ID to resolve | ||||||||||||||||||||||||||
| partial_id: Full or partial ID to resolve, or title to search | ||||||||||||||||||||||||||
| list_fn: Async function that returns list of items with id/title attributes | ||||||||||||||||||||||||||
| entity_name: Name for error messages (e.g., "notebook", "source") | ||||||||||||||||||||||||||
| list_command: CLI command to list items (e.g., "list", "source list") | ||||||||||||||||||||||||||
|
|
@@ -284,7 +285,13 @@ async def _resolve_partial_id( | |||||||||||||||||||||||||
| return partial_id | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| items = await list_fn() | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| # First try ID prefix match | ||||||||||||||||||||||||||
| matches = [item for item in items if item.id.lower().startswith(partial_id.lower())] | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| # If no ID matches, try title prefix match | ||||||||||||||||||||||||||
| if len(matches) == 0: | ||||||||||||||||||||||||||
| matches = [item for item in items if item.title and item.title.lower().startswith(partial_id.lower())] | ||||||||||||||||||||||||||
|
Comment on lines
290
to
+294
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This implementation calls
Suggested change
|
||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| if len(matches) == 1: | ||||||||||||||||||||||||||
| if matches[0].id != partial_id: | ||||||||||||||||||||||||||
|
|
@@ -293,11 +300,11 @@ async def _resolve_partial_id( | |||||||||||||||||||||||||
| return matches[0].id | ||||||||||||||||||||||||||
| elif len(matches) == 0: | ||||||||||||||||||||||||||
| raise click.ClickException( | ||||||||||||||||||||||||||
| f"No {entity_name} found starting with '{partial_id}'. " | ||||||||||||||||||||||||||
| f"No {entity_name} found matching '{partial_id}'. " | ||||||||||||||||||||||||||
| f"Run 'notebooklm {list_command}' to see available {entity_name}s." | ||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||
| else: | ||||||||||||||||||||||||||
| lines = [f"Ambiguous ID '{partial_id}' matches {len(matches)} {entity_name}s:"] | ||||||||||||||||||||||||||
| lines = [f"Ambiguous input '{partial_id}' matches {len(matches)} {entity_name}s:"] | ||||||||||||||||||||||||||
| for item in matches[:5]: | ||||||||||||||||||||||||||
| title = item.title or "(untitled)" | ||||||||||||||||||||||||||
| lines.append(f" {item.id[:12]}... {title}") | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a great feature enhancement. However, the new functionality of searching by title is not covered by unit tests. Please add tests to
tests/unit/cli/test_resolve.pyto cover various scenarios, such as:References