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

Commit 3e45da6

Browse files
committed
remove dotcom related code from tsx files
1 parent 355f6c0 commit 3e45da6

12 files changed

Lines changed: 32 additions & 185 deletions

File tree

lib/shared/src/auth/types.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,6 @@ export const AUTH_STATUS_FIXTURE_AUTHED_DOTCOM: AuthenticatedAuthStatus = {
7676
export function isCodyProUser(authStatus: AuthStatus, sub: UserProductSubscription | null): boolean {
7777
return isDotCom(authStatus) && authStatus.authenticated && sub !== null && !sub.userCanUpgrade
7878
}
79-
80-
export function isFreeUser(authStatus: AuthStatus, sub: UserProductSubscription | null): boolean {
81-
return isDotCom(authStatus) && authStatus.authenticated && sub !== null && !!sub.userCanUpgrade
82-
}
83-
8479
export function isEnterpriseUser(authStatus: AuthStatus): boolean {
8580
return !isDotCom(authStatus)
8681
}

lib/shared/src/models/modelsService.ts

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { type Observable, map } from 'observable-fns'
22

33
import { authStatus, currentAuthStatus } from '../auth/authStatus'
44
import { mockAuthStatus } from '../auth/authStatus'
5-
import { type AuthStatus, isCodyProUser, isEnterpriseUser } from '../auth/types'
5+
import { type AuthStatus, isEnterpriseUser } from '../auth/types'
66
import { AUTH_STATUS_FIXTURE_AUTHED_DOTCOM } from '../auth/types'
77
import { type PickResolvedConfiguration, resolvedConfig } from '../configuration/resolver'
88
import { FeatureFlag, featureFlagProvider } from '../experimentation/FeatureFlagProvider'
@@ -18,10 +18,7 @@ import {
1818
} from '../misc/observable'
1919
import { firstResultFromOperation, pendingOperation } from '../misc/observableOperation'
2020
import { ClientConfigSingleton } from '../sourcegraph-api/clientConfig'
21-
import {
22-
type UserProductSubscription,
23-
userProductSubscription,
24-
} from '../sourcegraph-api/userProductSubscription'
21+
import { userProductSubscription } from '../sourcegraph-api/userProductSubscription'
2522
import { CHAT_INPUT_TOKEN_BUDGET, CHAT_OUTPUT_TOKEN_BUDGET } from '../token/constants'
2623
import { configOverwrites } from './configOverwrites'
2724
import { type Model, type ServerModel, modelTier } from './model'
@@ -454,8 +451,8 @@ export class ModelsService {
454451
// Find the first model the user can use that isn't a reasoning model
455452
const firstModelUserCanUse = models.find(
456453
m =>
457-
this._isModelAvailable(modelsData, authStatus, userProductSubscription, m) ===
458-
true && !m.tags.includes(ModelTag.Reasoning)
454+
this._isModelAvailable(modelsData, authStatus, m) === true &&
455+
!m.tags.includes(ModelTag.Reasoning)
459456
)
460457

461458
if (modelsData.preferences) {
@@ -473,12 +470,7 @@ export class ModelsService {
473470
(selected.tags.includes(ModelTag.Reasoning) ||
474471
selected.tags.includes(ModelTag.Deprecated))
475472
) &&
476-
this._isModelAvailable(
477-
modelsData,
478-
authStatus,
479-
userProductSubscription,
480-
selected
481-
) === true
473+
this._isModelAvailable(modelsData, authStatus, selected) === true
482474
) {
483475
return selected
484476
}
@@ -551,7 +543,7 @@ export class ModelsService {
551543
map(([authStatus, modelsData, userProductSubscription]) =>
552544
modelsData === pendingOperation || userProductSubscription === pendingOperation
553545
? pendingOperation
554-
: this._isModelAvailable(modelsData, authStatus, userProductSubscription, model)
546+
: this._isModelAvailable(modelsData, authStatus, model)
555547
),
556548
distinctUntilChanged()
557549
)
@@ -560,7 +552,6 @@ export class ModelsService {
560552
private _isModelAvailable(
561553
modelsData: ModelsData,
562554
authStatus: AuthStatus,
563-
sub: UserProductSubscription | null,
564555
model: string | Model
565556
): boolean {
566557
const resolved = this.resolveModel(modelsData, model)
@@ -573,17 +564,6 @@ export class ModelsService {
573564
return true
574565
}
575566

576-
// A Cody Pro user can use any Free or Pro model, but not Enterprise.
577-
// (But in reality, Sourcegraph.com wouldn't serve any Enterprise-only models to
578-
// Cody Pro users anyways.)
579-
if (isCodyProUser(authStatus, sub)) {
580-
return (
581-
tier !== 'enterprise' &&
582-
!resolved.tags.includes(ModelTag.Waitlist) &&
583-
!resolved.tags.includes(ModelTag.OnWaitlist)
584-
)
585-
}
586-
587567
return tier === 'free'
588568
}
589569

vscode/webviews/Chat.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,6 @@ export const Chat: React.FunctionComponent<React.PropsWithChildren<ChatboxProps>
228228
}
229229

230230
export interface UserAccountInfo {
231-
isDotComUser: boolean
232-
isCodyProUser: boolean
233231
user: Pick<
234232
AuthenticatedAuthStatus,
235233
'username' | 'displayName' | 'avatarURL' | 'endpoint' | 'primaryEmail' | 'organizations'

vscode/webviews/chat/ErrorItem.tsx

Lines changed: 11 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import type {
77
PriorHumanMessageInfo,
88
} from './cells/messageCell/assistant/AssistantMessageCell'
99

10-
import type { UserAccountInfo } from '../Chat'
1110
import type { ApiPostMessage } from '../Chat'
1211

1312
import { Button } from '../components/shadcn/ui/button'
@@ -20,18 +19,11 @@ import styles from './ErrorItem.module.css'
2019
*/
2120
export const ErrorItem: React.FunctionComponent<{
2221
error: Omit<ChatError, 'isChatErrorGuard'>
23-
userInfo: Pick<UserAccountInfo, 'isCodyProUser' | 'isDotComUser'>
2422
postMessage?: ApiPostMessage
2523
humanMessage?: PriorHumanMessageInfo | null
26-
}> = ({ error, userInfo, postMessage, humanMessage }) => {
24+
}> = ({ error, postMessage, humanMessage }) => {
2725
if (typeof error !== 'string' && error.name === RateLimitError.errorName && postMessage) {
28-
return (
29-
<RateLimitErrorItem
30-
error={error as RateLimitError}
31-
userInfo={userInfo}
32-
postMessage={postMessage}
33-
/>
34-
)
26+
return <RateLimitErrorItem error={error as RateLimitError} postMessage={postMessage} />
3527
}
3628
return <RequestErrorItem error={error} humanMessage={humanMessage} />
3729
}
@@ -97,30 +89,18 @@ export const RequestErrorItem: React.FunctionComponent<{
9789
*/
9890
const RateLimitErrorItem: React.FunctionComponent<{
9991
error: RateLimitError
100-
userInfo: Pick<UserAccountInfo, 'isCodyProUser' | 'isDotComUser'>
10192
postMessage: ApiPostMessage
102-
}> = ({ error, userInfo, postMessage }) => {
103-
// Only show Upgrades if both the error said an upgrade was available and we know the user
104-
// has not since upgraded.
105-
const isEnterpriseUser = userInfo.isDotComUser !== true
106-
const canUpgrade = error.upgradeIsAvailable && !userInfo?.isCodyProUser
107-
const tier = isEnterpriseUser ? 'enterprise' : canUpgrade ? 'free' : 'pro'
93+
}> = ({ error, postMessage }) => {
10894
const telemetryRecorder = useMemo(() => createWebviewTelemetryRecorder(postMessage), [postMessage])
10995

110-
// Only log once on mount
111-
// biome-ignore lint/correctness/useExhaustiveDependencies: intentionally only logs once on mount
11296
React.useEffect(() => {
11397
// Log as abuseUsageLimit if pro user run into rate limit
114-
telemetryRecorder.recordEvent(
115-
canUpgrade ? 'cody.upsellUsageLimitCTA' : 'cody.abuseUsageLimitCTA',
116-
'shown',
117-
{
118-
privateMetadata: {
119-
limit_type: 'chat_commands',
120-
tier,
121-
},
122-
}
123-
)
98+
telemetryRecorder.recordEvent('cody.abuseUsageLimitCTA', 'shown', {
99+
privateMetadata: {
100+
limit_type: 'chat_commands',
101+
tier: 'enterprise',
102+
},
103+
})
124104
}, [telemetryRecorder])
125105

126106
const onButtonClick = useCallback(
@@ -130,14 +110,14 @@ const RateLimitErrorItem: React.FunctionComponent<{
130110
privateMetadata: {
131111
limit_type: 'chat_commands',
132112
call_to_action,
133-
tier,
113+
tier: 'enterprise',
134114
},
135115
})
136116

137117
// open the page in browser
138118
postMessage({ command: 'show-page', page })
139119
},
140-
[postMessage, tier, telemetryRecorder]
120+
[postMessage, telemetryRecorder]
141121
)
142122

143123
let ctaText = 'Unable to Send Message'

vscode/webviews/chat/Transcript.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,6 @@ const TranscriptInteraction: FC<TranscriptInteractionProps> = memo(props => {
402402
isLastInteraction,
403403
isLastSentInteraction,
404404
priorAssistantMessageIsLoading,
405-
userInfo,
406405
chatEnabled,
407406
chatCodeHighlightingEnabled,
408407
postMessage,
@@ -725,7 +724,6 @@ const TranscriptInteraction: FC<TranscriptInteractionProps> = memo(props => {
725724
)}
726725
<HumanMessageCell
727726
key={humanMessage.index}
728-
userInfo={userInfo}
729727
models={models}
730728
chatEnabled={chatEnabled}
731729
message={humanMessage}
@@ -773,7 +771,6 @@ const TranscriptInteraction: FC<TranscriptInteractionProps> = memo(props => {
773771
(assistantMessage.subMessages && assistantMessage.subMessages.length > 0)) && (
774772
<AssistantMessageCell
775773
key={assistantMessage.index}
776-
userInfo={userInfo}
777774
models={models}
778775
chatEnabled={chatEnabled}
779776
chatCodeHighlightingEnabled={chatCodeHighlightingEnabled}

vscode/webviews/chat/cells/messageCell/assistant/AssistantMessageCell.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { DeepCodyAgentID } from '@sourcegraph/cody-shared/src/models/client'
1515
import type { PromptEditorRefAPI } from '@sourcegraph/prompt-editor'
1616
import isEqual from 'lodash/isEqual'
1717
import { type FunctionComponent, type RefObject, memo, useMemo } from 'react'
18-
import type { ApiPostMessage, UserAccountInfo } from '../../../../Chat'
18+
import type { ApiPostMessage } from '../../../../Chat'
1919
import {
2020
ChatMessageContent,
2121
type CodeBlockActionsProps,
@@ -38,7 +38,6 @@ export const AssistantMessageCell: FunctionComponent<{
3838
/** Information about the human message that led to this assistant response. */
3939
humanMessage: PriorHumanMessageInfo | null
4040

41-
userInfo: UserAccountInfo
4241
chatEnabled: boolean
4342
chatCodeHighlightingEnabled: boolean
4443
isLoading: boolean
@@ -61,7 +60,6 @@ export const AssistantMessageCell: FunctionComponent<{
6160
message,
6261
models,
6362
humanMessage,
64-
userInfo,
6563
chatEnabled,
6664
chatCodeHighlightingEnabled,
6765
isLoading,
@@ -98,7 +96,6 @@ export const AssistantMessageCell: FunctionComponent<{
9896
) : (
9997
<ErrorItem
10098
error={message.error}
101-
userInfo={userInfo}
10299
postMessage={postMessage}
103100
humanMessage={humanMessage}
104101
/>

vscode/webviews/chat/cells/messageCell/human/HumanMessageCell.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,12 @@ import {
77
} from '@sourcegraph/cody-shared'
88
import type { PromptEditorRefAPI } from '@sourcegraph/prompt-editor'
99
import { type FC, memo, useMemo } from 'react'
10-
import type { UserAccountInfo } from '../../../../Chat'
1110
import { BaseMessageCell } from '../BaseMessageCell'
1211
import { HumanMessageEditor } from './editor/HumanMessageEditor'
1312

1413
interface HumanMessageCellProps {
1514
message: ChatMessage
1615
models: Model[]
17-
userInfo: UserAccountInfo
1816
chatEnabled: boolean
1917

2018
/** Whether this editor is for the first message (not a followup). */
@@ -77,7 +75,6 @@ const HumanMessageCellContent = memo<HumanMessageCellContent>(props => {
7775
const {
7876
models,
7977
initialEditorState,
80-
userInfo,
8178
chatEnabled = true,
8279
isFirstMessage,
8380
isSent,
@@ -101,7 +98,6 @@ const HumanMessageCellContent = memo<HumanMessageCellContent>(props => {
10198
content={
10299
<HumanMessageEditor
103100
models={models}
104-
userInfo={userInfo}
105101
initialEditorState={initialEditorState}
106102
placeholder={
107103
isFirstMessage

vscode/webviews/chat/cells/messageCell/human/editor/HumanMessageEditor.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import {
2828
useRef,
2929
useState,
3030
} from 'react'
31-
import type { UserAccountInfo } from '../../../../../Chat'
3231
import { type ClientActionListener, useClientActionListener } from '../../../../../client/clientState'
3332
import { promptModeToIntent } from '../../../../../prompts/promptUtils'
3433
import { useTelemetryRecorder } from '../../../../../utils/telemetry'
@@ -43,7 +42,6 @@ import { Toolbar } from './toolbar/Toolbar'
4342
*/
4443
export const HumanMessageEditor: FunctionComponent<{
4544
models: Model[]
46-
userInfo: UserAccountInfo
4745

4846
initialEditorState: SerializedPromptEditorState | undefined
4947
placeholder: string
@@ -78,7 +76,6 @@ export const HumanMessageEditor: FunctionComponent<{
7876
manuallySelectIntent: (intent: ChatMessage['intent']) => void
7977
}> = ({
8078
models,
81-
userInfo,
8279
initialEditorState,
8380
placeholder,
8481
isFirstMessage,
@@ -435,7 +432,6 @@ export const HumanMessageEditor: FunctionComponent<{
435432
{!disabled && (
436433
<Toolbar
437434
models={models}
438-
userInfo={userInfo}
439435
isEditorFocused={focused}
440436
onSubmitClick={onSubmitClick}
441437
submitState={submitState}

vscode/webviews/chat/cells/messageCell/human/editor/toolbar/ModeSelectorButton.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ interface IntentOption {
3939
}
4040

4141
export const ModeSelectorField: React.FunctionComponent<{
42-
isDotComUser: boolean
43-
isCodyProUser: boolean
4442
_intent: ChatMessage['intent']
4543
className?: string
4644
manuallySelectIntent: (intent?: ChatMessage['intent']) => void

vscode/webviews/chat/cells/messageCell/human/editor/toolbar/Toolbar.tsx

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import {
99
} from '@sourcegraph/cody-shared'
1010
import clsx from 'clsx'
1111
import { type FunctionComponent, useCallback, useEffect, useMemo, useRef } from 'react'
12-
import type { UserAccountInfo } from '../../../../../../Chat'
1312
import { ModelSelectField } from '../../../../../../components/modelSelectField/ModelSelectField'
1413
import { PromptSelectField } from '../../../../../../components/promptSelectField/PromptSelectField'
1514
import toolbarStyles from '../../../../../../components/shadcn/ui/toolbar.module.css'
@@ -24,7 +23,6 @@ import { SubmitButton, type SubmitButtonState } from './SubmitButton'
2423
*/
2524
export const Toolbar: FunctionComponent<{
2625
models: Model[]
27-
userInfo: UserAccountInfo
2826

2927
isEditorFocused: boolean
3028

@@ -47,7 +45,6 @@ export const Toolbar: FunctionComponent<{
4745

4846
setLastManuallySelectedIntent: (intent: ChatMessage['intent']) => void
4947
}> = ({
50-
userInfo,
5148
isEditorFocused,
5249
onSubmitClick,
5350
submitState,
@@ -82,12 +79,9 @@ export const Toolbar: FunctionComponent<{
8279
* or is using a BYOK model with vision tag.
8380
*/
8481
const isImageUploadEnabled = useMemo(() => {
85-
const isDotCom = userInfo?.isDotComUser
8682
const selectedModel = models?.[0]
87-
const isBYOK = selectedModel?.tags?.includes(ModelTag.BYOK)
88-
const isVision = selectedModel?.tags?.includes(ModelTag.Vision)
89-
return (!isDotCom || isBYOK) && isVision
90-
}, [userInfo?.isDotComUser, models?.[0]])
83+
return selectedModel?.tags?.includes(ModelTag.Vision)
84+
}, [models?.[0]])
9185

9286
const modelSelectorRef = useRef<{ open: () => void; close: () => void } | null>(null)
9387
const promptSelectorRef = useRef<{ open: () => void; close: () => void } | null>(null)
@@ -148,14 +142,11 @@ export const Toolbar: FunctionComponent<{
148142
<ModeSelectorField
149143
className={className}
150144
_intent={intent}
151-
isDotComUser={userInfo?.isDotComUser}
152-
isCodyProUser={userInfo?.isCodyProUser}
153145
manuallySelectIntent={setLastManuallySelectedIntent}
154146
/>
155147
{models?.length >= 2 && (
156148
<ModelSelectFieldToolbarItem
157149
models={models}
158-
userInfo={userInfo}
159150
focusEditor={focusEditor}
160151
modelSelectorRef={modelSelectorRef}
161152
className="tw-mr-1"
@@ -198,13 +189,12 @@ const PromptSelectFieldToolbarItem: FunctionComponent<{
198189

199190
const ModelSelectFieldToolbarItem: FunctionComponent<{
200191
models: Model[]
201-
userInfo: UserAccountInfo
202192
focusEditor?: () => void
203193
className?: string
204194
extensionAPI: WebviewToExtensionAPI
205195
modelSelectorRef: React.MutableRefObject<{ open: () => void; close: () => void } | null>
206196
intent?: ChatMessage['intent']
207-
}> = ({ userInfo, focusEditor, className, models, extensionAPI, modelSelectorRef, intent }) => {
197+
}> = ({ focusEditor, className, models, extensionAPI, modelSelectorRef, intent }) => {
208198
const clientConfig = useClientConfig()
209199
const serverSentModelsEnabled = !!clientConfig?.modelsAPIEnabled
210200

@@ -231,12 +221,11 @@ const ModelSelectFieldToolbarItem: FunctionComponent<{
231221

232222
return (
233223
!!models?.length &&
234-
(userInfo.isDotComUser || serverSentModelsEnabled) && (
224+
serverSentModelsEnabled && (
235225
<ModelSelectField
236226
models={models}
237227
onModelSelect={onModelSelect}
238228
serverSentModelsEnabled={serverSentModelsEnabled}
239-
userInfo={userInfo}
240229
className={className}
241230
data-testid="chat-model-selector"
242231
modelSelectorRef={modelSelectorRef}

0 commit comments

Comments
 (0)