In @vovakulikov 's demo of Cody Web today, I noticed that he @-mentioned insight.go, which didn't match any files. He corrected it to insights.go, which did match a file, and continued the demo.
Seeing that made me think that we should add the ability to more fuzzily match remote files, similar to how we match local files (@-mentioning chatcontext will match .../chat/.../context..., ...chatContext..., ...chat-context..., and perhaps more)
This PR attempts to add fuzziness to the file search by expanding the path into OR elements in the GQL query and querying for 300 results rather than 30. Those 300 are fed through fuzzysorter, comparing them to the entered path and returning the top 30.
Alternate approach to #4755.
Neither approach completely recreates the local file experience because it can't apply fuzzysort to all of the files. From experimentation, it looks like fuzzysort uses a trie or similar to match paths containing parts of the entered file name. For example, mentioning chatcontext surfaces paths containing either chat or context or chatcontext because fuzzysort is able to apply its heuristics to all of the local files.
But either approach does help with some misspellings.
Test plan
run locally (cde web && pnpm install && pnpm dev) and experiment with @-mentions. I've been using internal/databse/insight (purposeful misspelling), adding .go also.
Use your creativity to come up with different options.
In @vovakulikov 's demo of Cody Web today, I noticed that he @-mentioned
insight.go
, which didn't match any files. He corrected it toinsights.go
, which did match a file, and continued the demo.Seeing that made me think that we should add the ability to more fuzzily match remote files, similar to how we match local files (@-mentioning
chatcontext
will match.../chat/.../context...
,...chatContext...
,...chat-context...
, and perhaps more)This PR attempts to add fuzziness to the file search by expanding the path into
OR
elements in the GQL query and querying for 300 results rather than 30. Those 300 are fed throughfuzzysorter
, comparing them to the entered path and returning the top 30.Alternate approach to #4755.
Neither approach completely recreates the local file experience because it can't apply
fuzzysort
to all of the files. From experimentation, it looks likefuzzysort
uses a trie or similar to match paths containing parts of the entered file name. For example, mentioningchatcontext
surfaces paths containing eitherchat
orcontext
orchatcontext
becausefuzzysort
is able to apply its heuristics to all of the local files.But either approach does help with some misspellings.
Test plan
run locally (
cde web && pnpm install && pnpm dev
) and experiment with @-mentions. I've been usinginternal/databse/insight
(purposeful misspelling), adding.go
also. Use your creativity to come up with different options.