@@ -7,7 +7,7 @@ import delay from "delay"
77import * as vscode from "vscode"
88// kilocode_change start
99import axios from "axios"
10- import { getKiloUrlFromToken , isGlobalStateKey } from "@roo-code/types"
10+ import { codeReviewSettingsSchema , CodeReviewSettings , getKiloUrlFromToken , isGlobalStateKey } from "@roo-code/types"
1111import { getAppUrl } from "@roo-code/types"
1212import {
1313 MaybeTypedWebviewMessage ,
@@ -1025,7 +1025,13 @@ export const webviewMessageHandler = async (
10251025 // Call the code review API
10261026 const { CodeReviewService } = await import ( "../kilocode/api/codeReviewService" )
10271027 const state = await provider . getState ( )
1028- const codeReviewService = new CodeReviewService ( state . apiConfiguration ?. kilocodeToken || "" )
1028+
1029+ // Use enterprise settings if available, otherwise fall back to default
1030+ const enterpriseHost = state . codeReviewSettings ?. enterpriseHost
1031+ const enterpriseApiKey = state . codeReviewSettings ?. enterpriseApiKey
1032+ const apiToken = state . apiConfiguration ?. kilocodeToken || ""
1033+
1034+ const codeReviewService = new CodeReviewService ( apiToken , enterpriseHost , enterpriseApiKey )
10291035 const results = await codeReviewService . requestCodeReview ( {
10301036 git_diff : gitDiff ,
10311037 git_owner : gitMetadata . gitOwner ,
@@ -2228,6 +2234,44 @@ ${comment.suggestion}
22282234 vscode . commands . executeCommand ( "axon-code.ghost.reload" )
22292235 break
22302236 // kilocode_change end
2237+ case "codeReviewSettings" : {
2238+ const values = message . values as CodeReviewSettings
2239+ const validated = codeReviewSettingsSchema . parse ( values )
2240+ await updateGlobalState ( "codeReviewSettings" , validated )
2241+
2242+ // If both host and key are provided, ping the server
2243+ if ( validated . enterpriseHost && validated . enterpriseApiKey ) {
2244+ try {
2245+ const pingUrl = `${ validated . enterpriseHost ?. replace ( / \/ $ / , "" ) } /codereview/ping`
2246+ const response = await axios . get ( pingUrl , {
2247+ headers : {
2248+ Authorization : `Bearer ${ validated . enterpriseApiKey } ` ,
2249+ } ,
2250+ } )
2251+
2252+ if ( response . data ?. valid === true ) {
2253+ // Send toast message to webview
2254+ provider . postMessageToWebview ( {
2255+ type : "showToast" ,
2256+ toastType : "success" ,
2257+ toastMessage : "Enterprise server connected successfully" ,
2258+ } )
2259+ }
2260+ } catch ( error ) {
2261+ console . error ( "Failed to ping enterprise server:" , error )
2262+ // Send error toast message to webview
2263+ provider . postMessageToWebview ( {
2264+ type : "showToast" ,
2265+ toastType : "error" ,
2266+ toastMessage : "Failed to connect to enterprise server. Please check your host URL and API key." ,
2267+ } )
2268+ }
2269+ }
2270+
2271+ provider . postMessageToWebview ( { type : "state" , state : await provider . getStateToPostToWebview ( ) } )
2272+ break
2273+ }
2274+ // kilocode_change end
22312275 case "includeTaskHistoryInEnhance" :
22322276 await updateGlobalState ( "includeTaskHistoryInEnhance" , message . bool ?? true )
22332277 await provider . postStateToWebview ( )
0 commit comments