Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/notebooklm/cli/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,11 +275,15 @@ async def _resolve_partial_id(
partial_id = validate_id(partial_id, entity_name)

# Skip resolution for IDs that look complete (20+ chars)
if len(partial_id) >= 20:
if len(partial_id) >= 50:
Comment on lines 277 to +278

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The comment on line 277 is now out of sync with the code on line 278. Please update the comment to reflect the new threshold of 50 characters.

Additionally, this change will likely cause the unit test TestResolveNotebookId.test_long_id_skips_resolution in tests/unit/cli/test_resolve.py to fail, as it asserts behavior based on the old 20-character threshold. Please update the test accordingly.

Suggested change
# Skip resolution for IDs that look complete (20+ chars)
if len(partial_id) >= 20:
if len(partial_id) >= 50:
# Skip resolution for IDs that look complete (50+ chars)
if len(partial_id) >= 50:

return partial_id

items = await list_fn()
matches = [item for item in items if item.id.lower().startswith(partial_id.lower())]

# Do a match based on title if there is no match on UUID:
if len(matches) == 0:
matches = [item for item in items if (item.title or "").lower().startswith(partial_id.lower())]
Comment on lines 282 to +286

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The current logic prioritizes ID matches and only searches by title if no ID matches are found. This can lead to confusing behavior if a user's search term matches an ID prefix but they intended to find an item by its title. For example, searching for 'action' might match an item with ID 'action-item-id' and ignore another item with the title 'action plan'.

To provide more intuitive results, it would be better to search by both ID and title, and then present all unique matches to the user. This way, if there are multiple possibilities, the user is notified of the ambiguity.

Suggested change
matches = [item for item in items if item.id.lower().startswith(partial_id.lower())]
# Do a match based on title if there is no match on UUID:
if len(matches) == 0:
matches = [item for item in items if (item.title or "").lower().startswith(partial_id.lower())]
matches = [item for item in items if item.id.lower().startswith(partial_id.lower()) or (item.title or "").lower().startswith(partial_id.lower())]


if len(matches) == 1:
if matches[0].id != partial_id:
Expand Down
Loading