Skip to content

Conversation

@gagik
Copy link
Contributor

@gagik gagik commented Nov 1, 2024

VSCODE-610 mentions also behavior for cases where is 0, I will make a follow up PR as this one is getting too large. This handles the case where there is only 1 database or collection, so we'd want to pick that instead of prompting the user.

I was originally planning to split them, but it ended up being nicer organization wise to combine collection and database picking logic as a lot of it is mirrored and uses some helper methods.

Description

Checklist

Motivation and Context

  • Bugfix
  • New feature
  • Dependency update
  • Misc

Open Questions

Dependents

Types of changes

  • Backport Needed
  • Patch (non-breaking change which fixes an issue)
  • Minor (non-breaking change which adds functionality)
  • Major (fix or feature that would cause existing functionality to change)

@gagik gagik changed the title WIP: one or no collection handling feat(participant): automatically pick the collection if there exists only one in the database. Nov 1, 2024
@gagik gagik changed the title feat(participant): automatically pick the collection if there exists only one in the database. feat(participant): automatically pick the collection if there exists only one in the database VSCODE-610 Nov 1, 2024
@gagik gagik changed the title feat(participant): automatically pick the collection if there exists only one in the database VSCODE-610 feat(chat): automatically pick the collection if there exists only one in the database VSCODE-610 Nov 1, 2024
@gagik gagik marked this pull request as ready for review November 1, 2024 14:29
@gagik gagik changed the base branch from main to gagik/add-test-filtering November 3, 2024 23:25
@gagik gagik changed the title feat(chat): automatically pick the collection if there exists only one in the database VSCODE-610 feat(chat): automatically pick the database & collection if there exists only one VSCODE-610 Nov 3, 2024
Base automatically changed from gagik/add-test-filtering to main November 5, 2024 11:01
Copy link
Member

@Anemy Anemy left a comment

Choose a reason for hiding this comment

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

Couple code quality comments, changes look good though.

Copy link
Contributor

@nirinchev nirinchev left a comment

Choose a reason for hiding this comment

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

Looks reasonable - I have mostly code style comments/questions.

Comment on lines 942 to 946
// If the database name could not get automatically selected,
// then the user has been prompted for it instead.
if (!databaseName) {
return { databaseName, collectionName };
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure I understand how this works. As far as I can follow this, if I don't have any databases, I'd get the "No databases found" error and no prompt to create/select a new one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The comment was not describing everything so I updated that. databaseName ends up as undefined either because we don't have it set yet (so the user has been prompted for it) or if there's an error. It's handled by the _getOrAskFor... function.

const askForDBMessage = chatStreamStub.markdown.getCall(0).args[0];
expect(askForDBMessage).to.include(
'What is the name of the database you would like this query to run against?'
'Which database would you like this query to run against? Select one by either clicking on an item in the list or typing the name manually in the chat.\n\n'
Copy link
Contributor Author

@gagik gagik Nov 7, 2024

Choose a reason for hiding this comment

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

@nirinchev @Anemy I combined the message used by handleEmptyNamespaceMessage and regular namespace prompting. It's nice to mention the option to type it manually right away and just repeat the same exact prompt if they send an empty message, that also lets us re-use the_getOrAskForMissingNamespace helper in handleEmptyNamespaceMessage.

@gagik gagik merged commit 9d666ff into main Nov 8, 2024
6 checks passed
@gagik gagik deleted the gagik/one-no-collection-handling branch November 8, 2024 13:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants