@@ -4,9 +4,12 @@ import {
4
4
type AutocompleteContextSnippet ,
5
5
type DocumentContext ,
6
6
contextFiltersProvider ,
7
+ subscriptionDisposable ,
7
8
wrapInActiveSpan ,
8
9
} from '@sourcegraph/cody-shared'
9
10
11
+ import { GitHubDotComRepoMetadata } from '../../repository/repo-metadata-from-git-api' ;
12
+ import { completionProviderConfig } from '../completion-provider-config'
10
13
import type { LastInlineCompletionCandidate } from '../get-inline-completions'
11
14
import {
12
15
DefaultCompletionsContextRanker ,
@@ -21,6 +24,8 @@ interface GetContextOptions {
21
24
abortSignal ?: AbortSignal
22
25
maxChars : number
23
26
lastCandidate ?: LastInlineCompletionCandidate
27
+ gitUrl ?: string
28
+ isDotComUser ?: boolean
24
29
}
25
30
26
31
export interface ContextSummary {
@@ -72,8 +77,19 @@ export interface GetContextResult {
72
77
* ranged for the top ranked document from all retrieval sources before we move on to the second
73
78
* document).
74
79
*/
75
- export class ContextMixer {
76
- constructor ( private strategyFactory : ContextStrategyFactory ) { }
80
+ export class ContextMixer implements vscode . Disposable {
81
+ private disposables : vscode . Disposable [ ] = [ ]
82
+ private dataCollectionFlag = false
83
+
84
+ constructor ( private strategyFactory : ContextStrategyFactory ) {
85
+ this . disposables . push (
86
+ subscriptionDisposable (
87
+ completionProviderConfig . completionDataCollectionFlag . subscribe ( dataCollectionFlag => {
88
+ this . dataCollectionFlag = dataCollectionFlag
89
+ } )
90
+ )
91
+ )
92
+ }
77
93
78
94
public async getContext ( options : GetContextOptions ) : Promise < GetContextResult > {
79
95
const start = performance . now ( )
@@ -176,6 +192,22 @@ export class ContextMixer {
176
192
rankedContextCandidates : Array . from ( fusedResults ) ,
177
193
}
178
194
}
195
+
196
+ private shouldLogContext ( gitUrl : string , isDotComUser : boolean ) : boolean {
197
+ if ( ! isDotComUser || ! this . dataCollectionFlag ) {
198
+ return false
199
+ }
200
+ const instance = GitHubDotComRepoMetadata . getInstance ( )
201
+ const gitRepoMetadata = instance . getRepoMetadataIfCached ( gitUrl )
202
+ return gitRepoMetadata ?. isPublic ?? false
203
+ }
204
+
205
+ public dispose ( ) : void {
206
+ for ( const disposable of this . disposables ) {
207
+ disposable . dispose ( )
208
+ }
209
+ this . disposables = [ ]
210
+ }
179
211
}
180
212
181
213
async function filter ( snippets : AutocompleteContextSnippet [ ] ) : Promise < AutocompleteContextSnippet [ ] > {
0 commit comments