Adds a base class for retrievers that handles caching and cache invalidation.
The target for this is Jaccard similarity, however that retriever has a lot of dependencies on files. So instead of trying to collect all of the external deps, I added some mock VSCode APIs, so that when accessing files or tabs, we automatically start tracking those as dependencies for the current retrieval and subscribe to changes in those. Currently we handle that pretty crudely, but it could be expanded to handle more fine grained dependencies.
EDIT: It's a bit hard to read the diff for JaccardSimilarityRetriever because I moved the getRelevantFiles function in as a method so it could access the tracking methods. The only difference is s/vscode.workspace/this.workspace/ and similarly for window
TODO:
[x] Unit Tests
[x] Fix a bug where closing tabs is not impacting cache lines for the tabGroups
Adds a base class for retrievers that handles caching and cache invalidation.
The target for this is Jaccard similarity, however that retriever has a lot of dependencies on files. So instead of trying to collect all of the external deps, I added some mock VSCode APIs, so that when accessing files or tabs, we automatically start tracking those as dependencies for the current retrieval and subscribe to changes in those. Currently we handle that pretty crudely, but it could be expanded to handle more fine grained dependencies.
EDIT: It's a bit hard to read the diff for
JaccardSimilarityRetriever
because I moved thegetRelevantFiles
function in as a method so it could access the tracking methods. The only difference iss/vscode.workspace/this.workspace/
and similarly forwindow
TODO:
tabGroups
Closes https://linear.app/sourcegraph/issue/CODY-2228/[autocomplete-latency]-add-additional-caching-to-the-jaccard
Test plan
Added unit tests and manually tested.