@@ -11,6 +11,7 @@ import { CodeReviewService } from "./codeReviewService"
1111import { CommentService } from "../../../integrations/comment"
1212import type { ReviewComment } from "./reviewComment"
1313import { supportPrompt } from "../../../shared/support-prompt"
14+ import { t } from "../../../i18n"
1415export function initCodeReview (
1516 context : vscode . ExtensionContext ,
1617 provider : ClineProvider ,
@@ -36,6 +37,11 @@ export function initCodeReview(
3637 if ( ! visibleProvider || ! editor ) {
3738 return
3839 }
40+ const { apiConfiguration } = await visibleProvider . getState ( )
41+ if ( apiConfiguration . apiProvider !== "zgsm" ) {
42+ vscode . window . showInformationMessage ( t ( "common:review.tip.api_provider_not_support" ) )
43+ return
44+ }
3945 const fileUri = editor . document . uri
4046 const range = editor . selection
4147 const cwd = visibleProvider . cwd . toPosix ( )
@@ -61,6 +67,11 @@ export function initCodeReview(
6167 if ( ! visibleProvider ) {
6268 return
6369 }
70+ const { apiConfiguration } = await visibleProvider . getState ( )
71+ if ( apiConfiguration . apiProvider !== "zgsm" ) {
72+ vscode . window . showInformationMessage ( t ( "common:review.tip.api_provider_not_support" ) )
73+ return
74+ }
6475 const cwd = visibleProvider . cwd . toPosix ( )
6576 const targets : ReviewTarget [ ] = await Promise . all (
6677 selectedUris . map ( async ( uri ) => {
@@ -79,6 +90,11 @@ export function initCodeReview(
7990 if ( ! visibleProvider ) {
8091 return
8192 }
93+ const { apiConfiguration } = await visibleProvider . getState ( )
94+ if ( apiConfiguration . apiProvider !== "zgsm" ) {
95+ vscode . window . showInformationMessage ( t ( "common:review.tip.api_provider_not_support" ) )
96+ return
97+ }
8298 reviewInstance . setProvider ( visibleProvider )
8399 reviewInstance . startReview ( [
84100 {
@@ -92,6 +108,11 @@ export function initCodeReview(
92108 if ( ! visibleProvider ) {
93109 return
94110 }
111+ const { apiConfiguration } = await visibleProvider . getState ( )
112+ if ( apiConfiguration . apiProvider !== "zgsm" ) {
113+ vscode . window . showInformationMessage ( t ( "common:review.tip.api_provider_not_support" ) )
114+ return
115+ }
95116 reviewInstance . setProvider ( visibleProvider )
96117 const comments = thread . comments as ReviewComment [ ]
97118 comments . forEach ( async ( comment ) => {
@@ -103,6 +124,11 @@ export function initCodeReview(
103124 if ( ! visibleProvider ) {
104125 return
105126 }
127+ const { apiConfiguration } = await visibleProvider . getState ( )
128+ if ( apiConfiguration . apiProvider !== "zgsm" ) {
129+ vscode . window . showInformationMessage ( t ( "common:review.tip.api_provider_not_support" ) )
130+ return
131+ }
106132 reviewInstance . setProvider ( visibleProvider )
107133 const comments = thread . comments as ReviewComment [ ]
108134 comments . forEach ( async ( comment ) => {
@@ -114,6 +140,11 @@ export function initCodeReview(
114140 if ( ! visibleProvider ) {
115141 return
116142 }
143+ const { apiConfiguration } = await visibleProvider . getState ( )
144+ if ( apiConfiguration . apiProvider !== "zgsm" ) {
145+ vscode . window . showInformationMessage ( t ( "common:review.tip.api_provider_not_support" ) )
146+ return
147+ }
117148 reviewInstance . setProvider ( visibleProvider )
118149 const comment = thread . comments [ 0 ] as ReviewComment
119150 if ( comment ) {
@@ -125,6 +156,11 @@ export function initCodeReview(
125156 if ( ! visibleProvider ) {
126157 return
127158 }
159+ const { apiConfiguration } = await visibleProvider . getState ( )
160+ if ( apiConfiguration . apiProvider !== "zgsm" ) {
161+ vscode . window . showInformationMessage ( t ( "common:review.tip.api_provider_not_support" ) )
162+ return
163+ }
128164 visibleProvider . log ( `[CodeReview] start review ${ args } ` )
129165
130166 const data = args ?. [ 0 ] ?. [ 0 ]
@@ -160,6 +196,11 @@ export function initCodeReview(
160196 if ( ! visibleProvider ) {
161197 return
162198 }
199+ const { apiConfiguration } = await visibleProvider . getState ( )
200+ if ( apiConfiguration . apiProvider !== "zgsm" ) {
201+ vscode . window . showInformationMessage ( t ( "common:review.tip.api_provider_not_support" ) )
202+ return
203+ }
163204 visibleProvider . log ( `[CodeReview] start review ${ JSON . stringify ( args ) } ` )
164205 const data = args ?. [ 0 ] ?. [ 0 ]
165206 if ( ! data ) {
@@ -184,6 +225,11 @@ export function initCodeReview(
184225 if ( ! visibleProvider ) {
185226 return
186227 }
228+ const { apiConfiguration } = await visibleProvider . getState ( )
229+ if ( apiConfiguration . apiProvider !== "zgsm" ) {
230+ vscode . window . showInformationMessage ( t ( "common:review.tip.api_provider_not_support" ) )
231+ return
232+ }
187233 reviewInstance . setProvider ( visibleProvider )
188234 visibleProvider . log ( `[CodeReview] accept issue ${ JSON . stringify ( args ) } ` )
189235 const data = args ?. [ 0 ] ?. [ 0 ]
@@ -200,6 +246,11 @@ export function initCodeReview(
200246 if ( ! visibleProvider ) {
201247 return
202248 }
249+ const { apiConfiguration } = await visibleProvider . getState ( )
250+ if ( apiConfiguration . apiProvider !== "zgsm" ) {
251+ vscode . window . showInformationMessage ( t ( "common:review.tip.api_provider_not_support" ) )
252+ return
253+ }
203254 reviewInstance . setProvider ( visibleProvider )
204255 visibleProvider . log ( `[CodeReview] reject issue ${ JSON . stringify ( args ) } ` )
205256 const data = args ?. [ 0 ] ?. [ 0 ]
@@ -216,6 +267,11 @@ export function initCodeReview(
216267 if ( ! visibleProvider ) {
217268 return
218269 }
270+ const { apiConfiguration } = await visibleProvider . getState ( )
271+ if ( apiConfiguration . apiProvider !== "zgsm" ) {
272+ vscode . window . showInformationMessage ( t ( "common:review.tip.api_provider_not_support" ) )
273+ return
274+ }
219275 visibleProvider . log ( `[CodeReview] ask review suggestion with AI ${ JSON . stringify ( args ) } ` )
220276 reviewInstance . setProvider ( visibleProvider )
221277 const data = args ?. [ 0 ] ?. [ 0 ]
0 commit comments