@@ -3,9 +3,8 @@ import { QuickInputButtons, ThemeIcon, window } from 'vscode';
33import type { AIProviders } from '../constants.ai' ;
44import type { Container } from '../container' ;
55import type { AIModel , AIModelDescriptor , AIProviderDescriptorWithConfiguration } from '../plus/ai/models/model' ;
6+ import { ensureAccess } from '../plus/ai/utils/-webview/ai.utils' ;
67import { isSubscriptionPaidPlan } from '../plus/gk/utils/subscription.utils' ;
7- import { configuration } from '../system/-webview/configuration' ;
8- import { getContext } from '../system/-webview/context' ;
98import { getQuickPickIgnoreFocusOut } from '../system/-webview/vscode' ;
109import { getSettledValue } from '../system/promise' ;
1110import { createQuickPickSeparator } from './items/common' ;
@@ -34,25 +33,7 @@ export async function showAIProviderPicker(
3433 container : Container ,
3534 current : AIModelDescriptor | undefined ,
3635) : Promise < ProviderQuickPickItem | undefined > {
37- if ( ! configuration . get ( 'ai.enabled' ) ) {
38- await window . showQuickPick ( [ { label : 'OK' } ] , {
39- title : 'AI is Disabled' ,
40- placeHolder : 'GitLens AI features have been disabled via settings' ,
41- canPickMany : false ,
42- } ) ;
43-
44- return undefined ;
45- }
46-
47- if ( ! getContext ( 'gitlens:gk:organization:ai:enabled' , true ) ) {
48- await window . showQuickPick ( [ { label : 'OK' } ] , {
49- title : 'AI is Disabled' ,
50- placeHolder : 'GitLens AI features have been disabled by your GitKraken admin' ,
51- canPickMany : false ,
52- } ) ;
53-
54- return undefined ;
55- }
36+ if ( ! ( await ensureAccess ( { showPicker : true } ) ) ) return undefined ;
5637
5738 const [ providersResult , modelResult , subscriptionResult ] = await Promise . allSettled ( [
5839 container . ai . getProvidersConfiguration ( ) ,
@@ -150,25 +131,7 @@ export async function showAIModelPicker(
150131 provider : AIProviders ,
151132 current ?: AIModelDescriptor ,
152133) : Promise < ModelQuickPickItem | Directive | undefined > {
153- if ( ! configuration . get ( 'ai.enabled' ) ) {
154- await window . showQuickPick ( [ { label : 'OK' } ] , {
155- title : 'AI is Disabled' ,
156- placeHolder : 'GitLens AI features have been disabled via settings' ,
157- canPickMany : false ,
158- } ) ;
159-
160- return undefined ;
161- }
162-
163- if ( ! getContext ( 'gitlens:gk:organization:ai:enabled' , true ) ) {
164- await window . showQuickPick ( [ { label : 'OK' } ] , {
165- title : 'AI is Disabled' ,
166- placeHolder : 'GitLens AI features have been disabled by your GitKraken admin' ,
167- canPickMany : false ,
168- } ) ;
169-
170- return undefined ;
171- }
134+ if ( ! ( await ensureAccess ( { showPicker : true } ) ) ) return undefined ;
172135
173136 const models = ( await container . ai . getModels ( provider ) ) ?? [ ] ;
174137
0 commit comments