@@ -246,7 +246,7 @@ export class AIProviderService implements Disposable {
246
246
} ;
247
247
const source : Parameters < TelemetryService [ 'sendEvent' ] > [ 2 ] = { source : sourceContext . source } ;
248
248
249
- const confirmed = await confirmAIProviderToS ( model , this . container . storage ) ;
249
+ const confirmed = await confirmAIProviderToS ( this , model , this . container . storage ) ;
250
250
if ( ! confirmed ) {
251
251
this . container . telemetry . sendEvent ( 'ai/generate' , { ...payload , 'failed.reason' : 'user-declined' } , source ) ;
252
252
@@ -327,7 +327,7 @@ export class AIProviderService implements Disposable {
327
327
} ;
328
328
const source : Parameters < TelemetryService [ 'sendEvent' ] > [ 2 ] = { source : sourceContext . source } ;
329
329
330
- const confirmed = await confirmAIProviderToS ( model , this . container . storage ) ;
330
+ const confirmed = await confirmAIProviderToS ( this , model , this . container . storage ) ;
331
331
if ( ! confirmed ) {
332
332
this . container . telemetry . sendEvent ( 'ai/generate' , { ...payload , 'failed.reason' : 'user-declined' } , source ) ;
333
333
@@ -427,7 +427,7 @@ export class AIProviderService implements Disposable {
427
427
} ;
428
428
const source : Parameters < TelemetryService [ 'sendEvent' ] > [ 2 ] = { source : sourceContext . source } ;
429
429
430
- const confirmed = await confirmAIProviderToS ( model , this . container . storage ) ;
430
+ const confirmed = await confirmAIProviderToS ( this , model , this . container . storage ) ;
431
431
if ( ! confirmed ) {
432
432
this . container . telemetry . sendEvent ( 'ai/explain' , { ...payload , 'failed.reason' : 'user-declined' } , source ) ;
433
433
@@ -546,6 +546,7 @@ export class AIProviderService implements Disposable {
546
546
}
547
547
548
548
async function confirmAIProviderToS < Provider extends AIProviders > (
549
+ service : AIProviderService ,
549
550
model : AIModel < Provider , AIModels < Provider > > ,
550
551
storage : Storage ,
551
552
) : Promise < boolean > {
@@ -555,20 +556,28 @@ async function confirmAIProviderToS<Provider extends AIProviders>(
555
556
if ( confirmed ) return true ;
556
557
557
558
const accept : MessageItem = { title : 'Continue' } ;
559
+ const switchModel : MessageItem = { title : 'Switch Model' } ;
558
560
const acceptWorkspace : MessageItem = { title : 'Always for this Workspace' } ;
559
561
const acceptAlways : MessageItem = { title : 'Always' } ;
560
562
const decline : MessageItem = { title : 'Cancel' , isCloseAffordance : true } ;
563
+
561
564
const result = await window . showInformationMessage (
562
565
`GitLens AI features require sending a diff of the code changes to ${ model . provider . name } for analysis. This may contain sensitive information.\n\nDo you want to continue?` ,
563
566
{ modal : true } ,
564
567
accept ,
568
+ switchModel ,
565
569
acceptWorkspace ,
566
570
acceptAlways ,
567
571
decline ,
568
572
) ;
569
573
570
574
if ( result === accept ) return true ;
571
575
576
+ if ( result === switchModel ) {
577
+ void service . switchModel ( ) ;
578
+ return false ;
579
+ }
580
+
572
581
if ( result === acceptWorkspace ) {
573
582
void storage . storeWorkspace ( `confirm:ai:tos:${ model . provider . id } ` , true ) . catch ( ) ;
574
583
return true ;
0 commit comments