-
Notifications
You must be signed in to change notification settings - Fork 76
feat: initial feature-flagged, new autocompleter. Now lazy loaded on first use MONGOSH-2036 #2462
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
Conversation
@@ -482,6 +482,11 @@ class MongoshNodeRepl implements EvaluationListener { | |||
}); | |||
} | |||
|
|||
// mongodb-ts-autocomplete requires a connection and a schema | |||
if (this.shellCliOptions.nodb) { |
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.
--nodb
does not directly imply that db
is inaccessible, e.g. you can do
$ mongosh --nodb
[...]
> db = connect(process.env.CLUSTER);
to basically get the same behavior as mongosh $CLUSTER
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.
Do you have an idea of a better thing to check?
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.
You'd have to check what the methods on getAutocompletionContext() return (/whether they return), I'd say
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.
I removed the code from here. Will add it to mongodb-ts-autocomplete separately
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.
and added mongodb-js/devtools-shared#542
In addition to now lazy loading mongodb-ts-autocomplete, I previously forgot that the tests won't run for the new one unless you specify USE_NEW_AUTOCOMPLETE=true.
I fixed the tests now, but it does highlight some subtle changes between the new design and the old. Notably with the typescript way we only autocomplete for collections that are known to exist, so we can't autocomplete
db.doesNotExistYet.insertOne(
which is a valid use case for creating a new collection. In probably all other instances this new behaviour is arguably an improvement because if you typed out a collection name that does not exist then not getting autocomplete results is a powerful hint that you made a mistake.Furthermore the new autocomplete does not take into account server version or capabilities (yet), so things like getShardDistribution autocompletes for every collection and db.watch autocomplete for every database.
And finally mongodb-ts-autocomplete does not support connections that aren't connected. It expects objects like
db
to be real and to be able to list databases and collections and get collection schemas. We can probably tweak it in future so you can get a partial experience, but for now I'm not calling it in the noDb scenario. It is still feature flagged after all.