Skip to content
This repository was archived by the owner on Aug 1, 2025. It is now read-only.

Commit b8684bd

Browse files
committed
remove more
1 parent 934006f commit b8684bd

47 files changed

Lines changed: 88 additions & 889 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

agent/bindings/kotlin/lib/src/main/kotlin/com/sourcegraph/cody/agent/protocol_generated/CodyAgentServer.kt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,8 @@ interface CodyAgentServer {
6464
fun graphql_getRepoIds(params: Graphql_GetRepoIdsParams): CompletableFuture<Graphql_GetRepoIdsResult>
6565
@JsonRequest("graphql/currentUserId")
6666
fun graphql_currentUserId(params: Null?): CompletableFuture<String>
67-
@JsonRequest("graphql/currentUserIsPro")
68-
fun graphql_currentUserIsPro(params: Null?): CompletableFuture<Boolean>
6967
@JsonRequest("featureFlags/getFeatureFlag")
7068
fun featureFlags_getFeatureFlag(params: FeatureFlags_GetFeatureFlagParams): CompletableFuture<Boolean?>
71-
@JsonRequest("graphql/getCurrentUserCodySubscription")
72-
fun graphql_getCurrentUserCodySubscription(params: Null?): CompletableFuture<CurrentUserCodySubscription?>
7369
@JsonRequest("telemetry/recordEvent")
7470
fun telemetry_recordEvent(params: TelemetryEvent): CompletableFuture<Null?>
7571
@JsonRequest("graphql/getRepoIdIfEmbeddingExists")

agent/bindings/kotlin/lib/src/main/kotlin/com/sourcegraph/cody/agent/protocol_generated/CurrentUserCodySubscription.kt

Lines changed: 0 additions & 11 deletions
This file was deleted.

agent/src/TestClient.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -729,6 +729,7 @@ export class TestClient extends MessageHandler {
729729
const jsonText = message.split('\n').slice(1).join('\n')
730730
const json = JSON.parse(jsonText)
731731
const bodyText = json?.body ?? '{}'
732+
console.log(`[mixer] bodyText: ${bodyText}`)
732733
const body = JSON.parse(bodyText)
733734
const { closestBody } = await this.request('testing/closestPostData', {
734735
url: json?.url ?? '',

agent/src/agent.ts

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1090,24 +1090,6 @@ export class Agent extends MessageHandler implements ExtensionClient {
10901090
throw id
10911091
})
10921092

1093-
this.registerAuthenticatedRequest('graphql/currentUserIsPro', async () => {
1094-
const res = await graphqlClient.getCurrentUserCodyProEnabled()
1095-
if (res instanceof Error) {
1096-
throw res
1097-
}
1098-
1099-
return Boolean(res?.codyProEnabled)
1100-
})
1101-
1102-
this.registerAuthenticatedRequest('graphql/getCurrentUserCodySubscription', async () => {
1103-
const res = await graphqlClient.getCurrentUserCodySubscription()
1104-
if (res instanceof Error) {
1105-
throw res
1106-
}
1107-
1108-
return res
1109-
})
1110-
11111093
this.registerAuthenticatedRequest('telemetry/recordEvent', async event => {
11121094
telemetryRecorder.recordEvent(
11131095
// 👷 HACK: We have no control over what gets sent over JSON RPC,

agent/src/index.test.ts

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -173,25 +173,6 @@ describe('Agent', () => {
173173
)
174174
}, 10_000)
175175

176-
it('graphql/getCurrentUserCodySubscription', async () => {
177-
const currentUserCodySubscription = await client.request(
178-
'graphql/getCurrentUserCodySubscription',
179-
null
180-
)
181-
expect(currentUserCodySubscription).toMatchInlineSnapshot(`
182-
{
183-
"applyProRateLimits": true,
184-
"currentPeriodEndAt": "2025-01-14T22:11:32Z",
185-
"currentPeriodStartAt": "2024-12-14T22:11:32Z",
186-
"plan": "PRO",
187-
"status": "ACTIVE",
188-
}
189-
`)
190-
// telemetry assertion, to validate the expected events fired during the test run
191-
// Do not remove this assertion, and instead update the expectedEvents list above
192-
expect(await exportedTelemetryEvents(client)).toEqual(expect.arrayContaining([]))
193-
}, 10_000)
194-
195176
describe('Chat', () => {
196177
it('chat/submitMessage (short message)', async () => {
197178
await setChatModel('anthropic::2024-10-22::claude-3-5-sonnet-latest')

lib/shared/src/auth/types.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { isDotCom } from '../sourcegraph-api/environments'
22
import type { AuthError } from '../sourcegraph-api/errors'
3-
import type { UserProductSubscription } from '../sourcegraph-api/userProductSubscription'
43

54
/**
65
* The authentication status, which includes representing the state when authentication failed or
@@ -73,14 +72,6 @@ export const AUTH_STATUS_FIXTURE_AUTHED_DOTCOM: AuthenticatedAuthStatus = {
7372
endpoint: 'https://sourcegraph.com' as string,
7473
}
7574

76-
export function isCodyProUser(authStatus: AuthStatus, sub: UserProductSubscription | null): boolean {
77-
return isDotCom(authStatus) && authStatus.authenticated && sub !== null && !sub.userCanUpgrade
78-
}
79-
80-
export function isFreeUser(authStatus: AuthStatus, sub: UserProductSubscription | null): boolean {
81-
return isDotCom(authStatus) && authStatus.authenticated && sub !== null && !!sub.userCanUpgrade
82-
}
83-
8475
export function isEnterpriseUser(authStatus: AuthStatus): boolean {
8576
return !isDotCom(authStatus)
8677
}

lib/shared/src/index.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,6 @@ export {
343343
promise,
344344
type ReadonlyDeep,
345345
} from './utils'
346-
export type { CurrentUserCodySubscription } from './sourcegraph-api/graphql/client'
347346
export * from './auth/types'
348347
export * from './auth/tokens'
349348
export * from './auth/referral'
@@ -421,13 +420,6 @@ export * from './singletons'
421420
export * from './auth/authStatus'
422421
export { fetchLocalOllamaModels } from './llm-providers/ollama/utils'
423422
export * from './editor/editorState'
424-
export {
425-
currentUserProductSubscription,
426-
checkIfEnterpriseUser,
427-
type UserProductSubscription,
428-
cachedUserProductSubscription,
429-
userProductSubscription,
430-
} from './sourcegraph-api/userProductSubscription'
431423
export {
432424
siteVersion,
433425
currentSiteVersion,

lib/shared/src/misc/rpc/webviewAPI.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { type Observable, map } from 'observable-fns'
2-
import type { AuthStatus, ModelsData, ResolvedConfiguration, UserProductSubscription } from '../..'
2+
import type { AuthStatus, ModelsData, ResolvedConfiguration } from '../..'
33
import type { SerializedPromptEditorState } from '../..'
44
import type { ChatHistoryType, LightweightChatHistory } from '../../chat/transcript'
55
import type { ChatMessage, UserLocalHistory } from '../../chat/transcript/messages'
@@ -106,11 +106,6 @@ export interface WebviewToExtensionAPI {
106106
*/
107107
userHistory(type?: ChatHistoryType): Observable<LightweightChatHistory | UserLocalHistory | null>
108108

109-
/**
110-
* The current user's product subscription information (Cody Free/Pro).
111-
*/
112-
userProductSubscription(): Observable<UserProductSubscription | null>
113-
114109
mcpSettings(): Observable<McpServer[] | null>
115110
}
116111

@@ -160,7 +155,6 @@ export function createExtensionAPI(
160155
authStatus: proxyExtensionAPI(messageAPI, 'authStatus'),
161156
transcript: proxyExtensionAPI(messageAPI, 'transcript'),
162157
userHistory: proxyExtensionAPI(messageAPI, 'userHistory'),
163-
userProductSubscription: proxyExtensionAPI(messageAPI, 'userProductSubscription'),
164158
repos: proxyExtensionAPI(messageAPI, 'repos'),
165159
mcpSettings: proxyExtensionAPI(messageAPI, 'mcpSettings'),
166160
}

lib/shared/src/models/modelsService.test.ts

Lines changed: 9 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@ import { currentAuthStatus, mockAuthStatus } from '../auth/authStatus'
44
import { AUTH_STATUS_FIXTURE_AUTHED, type AuthenticatedAuthStatus } from '../auth/types'
55
import { FeatureFlag, featureFlagProvider } from '../experimentation/FeatureFlagProvider'
66
import { firstValueFrom } from '../misc/observable'
7-
import { DOTCOM_URL } from '../sourcegraph-api/environments'
8-
import * as userProductSubscriptionModule from '../sourcegraph-api/userProductSubscription'
9-
import type { UserProductSubscription } from '../sourcegraph-api/userProductSubscription'
107
import { CHAT_INPUT_TOKEN_BUDGET, CHAT_OUTPUT_TOKEN_BUDGET } from '../token/constants'
118
import { FIXTURE_MODELS } from './fixtures'
129
import type { Model } from './model'
@@ -31,22 +28,6 @@ describe('modelsService', () => {
3128
return modelsService
3229
}
3330

34-
const freeUserAuthStatus: AuthenticatedAuthStatus = {
35-
...AUTH_STATUS_FIXTURE_AUTHED,
36-
endpoint: DOTCOM_URL.toString(),
37-
authenticated: true,
38-
}
39-
const freeUserSub: UserProductSubscription = {
40-
userCanUpgrade: true,
41-
}
42-
43-
const codyProAuthStatus: AuthenticatedAuthStatus = {
44-
...freeUserAuthStatus,
45-
}
46-
const codyProSub: UserProductSubscription = {
47-
userCanUpgrade: false,
48-
}
49-
5031
const enterpriseAuthStatus: AuthenticatedAuthStatus = {
5132
...AUTH_STATUS_FIXTURE_AUTHED,
5233
endpoint: 'https://sourcegraph.example.com',
@@ -173,10 +154,7 @@ describe('modelsService', () => {
173154

174155
let modelsService: ModelsService
175156
beforeEach(() => {
176-
mockAuthStatus(codyProAuthStatus)
177-
vi.spyOn(userProductSubscriptionModule, 'userProductSubscription', 'get').mockReturnValue(
178-
Observable.of(codyProSub)
179-
)
157+
mockAuthStatus(enterpriseAuthStatus)
180158
modelsService = modelsServiceWithModels([
181159
model1chat,
182160
model2chat,
@@ -247,78 +225,29 @@ describe('modelsService', () => {
247225
usage: [ModelUsage.Chat],
248226
tags: [ModelTag.Enterprise],
249227
})
250-
const proModel = createModel({
251-
id: 'pro-model',
252-
usage: [ModelUsage.Chat],
253-
tags: [ModelTag.Pro],
254-
})
255-
const freeModel = createModel({
256-
id: 'free-model',
257-
usage: [ModelUsage.Chat],
258-
// We don't include ModelTag.Free here to test that it's not required.
259-
tags: [],
260-
})
261228

262229
beforeEach(() => {
263230
vi.spyOn(modelsService, 'modelsChanges', 'get').mockReturnValue(
264231
Observable.of({
265232
...EMPTY_MODELS_DATA,
266-
primaryModels: [enterpriseModel, proModel, freeModel],
233+
primaryModels: [enterpriseModel],
267234
})
268235
)
269236
})
270237

271238
it('returns false for unknown model', async () => {
272-
mockAuthStatus(codyProAuthStatus)
273-
vi.spyOn(userProductSubscriptionModule, 'userProductSubscription', 'get').mockReturnValue(
274-
Observable.of(codyProSub)
275-
)
239+
mockAuthStatus(enterpriseAuthStatus)
276240
expect(await firstValueFrom(modelsService.isModelAvailable('unknown-model'))).toBe(false)
277241
})
278242

279243
it('allows enterprise user to use any model', async () => {
280244
mockAuthStatus(enterpriseAuthStatus)
281-
vi.spyOn(userProductSubscriptionModule, 'userProductSubscription', 'get').mockReturnValue(
282-
Observable.of(null)
283-
)
284245
expect(await firstValueFrom(modelsService.isModelAvailable(enterpriseModel))).toBe(true)
285-
expect(await firstValueFrom(modelsService.isModelAvailable(proModel))).toBe(true)
286-
expect(await firstValueFrom(modelsService.isModelAvailable(freeModel))).toBe(true)
287-
})
288-
289-
it('allows Cody Pro user to use Pro and Free models', async () => {
290-
mockAuthStatus(codyProAuthStatus)
291-
vi.spyOn(userProductSubscriptionModule, 'userProductSubscription', 'get').mockReturnValue(
292-
Observable.of(codyProSub)
293-
)
294-
expect(await firstValueFrom(modelsService.isModelAvailable(enterpriseModel))).toBe(false)
295-
expect(await firstValueFrom(modelsService.isModelAvailable(proModel))).toBe(true)
296-
expect(await firstValueFrom(modelsService.isModelAvailable(freeModel))).toBe(true)
297-
})
298-
299-
it('allows free user to use only Free models', async () => {
300-
mockAuthStatus(freeUserAuthStatus)
301-
vi.spyOn(userProductSubscriptionModule, 'userProductSubscription', 'get').mockReturnValue(
302-
Observable.of(freeUserSub)
303-
)
304-
expect(await firstValueFrom(modelsService.isModelAvailable(enterpriseModel))).toBe(false)
305-
expect(await firstValueFrom(modelsService.isModelAvailable(proModel))).toBe(false)
306-
expect(await firstValueFrom(modelsService.isModelAvailable(freeModel))).toBe(true)
307246
})
308247

309248
it('handles model passed as string', async () => {
310-
mockAuthStatus(freeUserAuthStatus)
311-
vi.spyOn(userProductSubscriptionModule, 'userProductSubscription', 'get').mockReturnValue(
312-
Observable.of(freeUserSub)
313-
)
314-
expect(await firstValueFrom(modelsService.isModelAvailable(freeModel.id))).toBe(true)
315-
expect(await firstValueFrom(modelsService.isModelAvailable(proModel.id))).toBe(false)
316-
317-
mockAuthStatus(codyProAuthStatus)
318-
vi.spyOn(userProductSubscriptionModule, 'userProductSubscription', 'get').mockReturnValue(
319-
Observable.of(codyProSub)
320-
)
321-
expect(await firstValueFrom(modelsService.isModelAvailable(proModel.id))).toBe(true)
249+
mockAuthStatus(enterpriseAuthStatus)
250+
expect(await firstValueFrom(modelsService.isModelAvailable(enterpriseModel.id))).toBe(true)
322251
})
323252
})
324253

@@ -475,10 +404,7 @@ describe('modelsService', () => {
475404
})
476405

477406
beforeEach(() => {
478-
mockAuthStatus(codyProAuthStatus)
479-
vi.spyOn(userProductSubscriptionModule, 'userProductSubscription', 'get').mockReturnValue(
480-
Observable.of(codyProSub)
481-
)
407+
mockAuthStatus(enterpriseAuthStatus)
482408

483409
modelsService = new ModelsService()
484410
storage = new TestLocalStorageForModelPreferences()
@@ -674,12 +600,8 @@ describe('modelsService', () => {
674600
})
675601

676602
beforeEach(() => {
677-
mockAuthStatus(freeUserAuthStatus)
603+
mockAuthStatus(enterpriseAuthStatus)
678604
vi.spyOn(featureFlagProvider, 'evaluatedFeatureFlag').mockReturnValue(Observable.of(true))
679-
vi.spyOn(userProductSubscriptionModule, 'userProductSubscription', 'get').mockReturnValue(
680-
Observable.of(codyProSub)
681-
)
682-
683605
storage = new TestLocalStorageForModelPreferences()
684606
})
685607

@@ -704,7 +626,7 @@ describe('modelsService', () => {
704626
expect(defaultEditModelId).toBe('gpt-4o-mini')
705627

706628
const prefsAfter = storage.getModelPreferences()
707-
const selectedEditModel = prefsAfter[freeUserAuthStatus.endpoint]?.selected?.edit
629+
const selectedEditModel = prefsAfter[enterpriseAuthStatus.endpoint]?.selected?.edit
708630
expect(selectedEditModel).toBe('gpt-4o-mini')
709631
})
710632

@@ -733,7 +655,7 @@ describe('modelsService', () => {
733655
expect(defaultEditModelId).toBe('other-edit-model')
734656

735657
const prefsAfter = storage.getModelPreferences()
736-
const selectedEditModel = prefsAfter[freeUserAuthStatus.endpoint]?.selected?.edit
658+
const selectedEditModel = prefsAfter[enterpriseAuthStatus.endpoint]?.selected?.edit
737659
expect(selectedEditModel).toBe('other-edit-model')
738660
})
739661
})

0 commit comments

Comments
 (0)