@@ -14,6 +14,7 @@ import {
1414} from "@vscode/webview-ui-toolkit/react" ;
1515import type { ModelEditorViewState } from "../../model-editor/shared/view-state" ;
1616import type { AccessPathSuggestionOptions } from "../../model-editor/suggestions" ;
17+ import { getCandidates } from "../../model-editor/auto-model" ;
1718
1819const LibraryContainer = styled . div `
1920 background-color: var(--vscode-peekViewResult-background);
@@ -186,6 +187,17 @@ export const LibraryRow = ({
186187 return methods . some ( ( method ) => inProgressMethods . has ( method . signature ) ) ;
187188 } , [ methods , inProgressMethods ] ) ;
188189
190+ const modelWithAIDisabled = useMemo ( ( ) => {
191+ return (
192+ getCandidates (
193+ viewState . mode ,
194+ methods ,
195+ modeledMethodsMap ,
196+ processedByAutoModelMethods ,
197+ ) . length === 0
198+ ) ;
199+ } , [ methods , modeledMethodsMap , processedByAutoModelMethods , viewState . mode ] ) ;
200+
189201 return (
190202 < LibraryContainer >
191203 < TitleContainer onClick = { toggleExpanded } aria-expanded = { isExpanded } >
@@ -205,7 +217,11 @@ export const LibraryRow = ({
205217 { hasUnsavedChanges ? < VSCodeTag > UNSAVED</ VSCodeTag > : null }
206218 </ NameContainer >
207219 { viewState . showLlmButton && ! canStopAutoModeling && (
208- < VSCodeButton appearance = "icon" onClick = { handleModelWithAI } >
220+ < VSCodeButton
221+ appearance = "icon"
222+ disabled = { modelWithAIDisabled }
223+ onClick = { handleModelWithAI }
224+ >
209225 < Codicon name = "lightbulb-autofix" label = "Model with AI" />
210226 Model with AI
211227 </ VSCodeButton >
0 commit comments