@@ -9,21 +9,60 @@ export function renderModel(
99 renderedModelProvider ?: RenderedModelProvider ,
1010) {
1111 return async ( ) => {
12+ if ( ! lspClient ) {
13+ vscode . window . showErrorMessage ( 'LSP client not available' )
14+ return
15+ }
16+
1217 // Get the current active editor
1318 const activeEditor = vscode . window . activeTextEditor
1419
20+ let documentUri : string
21+
1522 if ( ! activeEditor ) {
16- vscode . window . showErrorMessage ( 'No active editor found' )
17- return
18- }
23+ // No active editor, show a list of all models
24+ const allModelsResult = await lspClient . call_custom_method (
25+ 'sqlmesh/all_models_for_render' ,
26+ { } ,
27+ )
1928
20- if ( ! lspClient ) {
21- vscode . window . showErrorMessage ( 'LSP client not available' )
22- return
23- }
29+ if ( isErr ( allModelsResult ) ) {
30+ vscode . window . showErrorMessage (
31+ `Failed to get models: ${ allModelsResult . error } ` ,
32+ )
33+ return
34+ }
35+
36+ if (
37+ ! allModelsResult . value . models ||
38+ allModelsResult . value . models . length === 0
39+ ) {
40+ vscode . window . showInformationMessage ( 'No models found in the project' )
41+ return
42+ }
2443
25- // Get the current document URI
26- const documentUri = activeEditor . document . uri . toString ( true )
44+ // Let user choose from all models
45+ const items = allModelsResult . value . models . map ( model => ( {
46+ label : model . name ,
47+ description : model . fqn ,
48+ detail : model . description ? model . description : undefined ,
49+ model : model ,
50+ } ) )
51+
52+ const selected = await vscode . window . showQuickPick ( items , {
53+ placeHolder : 'Select a model to render' ,
54+ } )
55+
56+ if ( ! selected ) {
57+ return
58+ }
59+
60+ // Use the selected model's URI
61+ documentUri = selected . model . uri
62+ } else {
63+ // Get the current document URI
64+ documentUri = activeEditor . document . uri . toString ( true )
65+ }
2766
2867 // Call the render model API
2968 const result = await lspClient . call_custom_method ( 'sqlmesh/render_model' , {
0 commit comments