3737 SUPPORTED_METHODS_FEATURE ,
3838 FORMAT_PROJECT_FEATURE ,
3939 GET_ENVIRONMENTS_FEATURE ,
40+ GET_MODELS_FEATURE ,
4041 AllModelsRequest ,
4142 AllModelsResponse ,
4243 AllModelsForRenderRequest ,
5253 GetEnvironmentsRequest ,
5354 GetEnvironmentsResponse ,
5455 EnvironmentInfo ,
56+ GetModelsRequest ,
57+ GetModelsResponse ,
58+ ModelInfo ,
5559)
5660from sqlmesh .lsp .hints import get_hints
5761from sqlmesh .lsp .reference import (
@@ -130,6 +134,7 @@ def __init__(
130134 SUPPORTED_METHODS_FEATURE : self ._custom_supported_methods ,
131135 FORMAT_PROJECT_FEATURE : self ._custom_format_project ,
132136 GET_ENVIRONMENTS_FEATURE : self ._custom_get_environments ,
137+ GET_MODELS_FEATURE : self ._custom_get_models ,
133138 }
134139
135140 # Register LSP features (e.g., formatting, hover, etc.)
@@ -195,24 +200,6 @@ def _custom_get_environments(
195200 plan_id = env .plan_id or "" ,
196201 )
197202
198- # Add prod if not present (mirroring web/server/api/endpoints/environments.py)
199- if c .PROD not in environments :
200- environments [c .PROD ] = EnvironmentInfo (
201- name = c .PROD ,
202- snapshots = [],
203- start_at = str (to_timestamp (c .EPOCH )),
204- plan_id = "" ,
205- )
206-
207- # Add default target environment if not present
208- if context .context .config .default_target_environment not in environments :
209- environments [context .context .config .default_target_environment ] = EnvironmentInfo (
210- name = context .context .config .default_target_environment ,
211- snapshots = [],
212- start_at = str (to_timestamp (c .EPOCH )),
213- plan_id = "" ,
214- )
215-
216203 return GetEnvironmentsResponse (
217204 environments = environments ,
218205 pinned_environments = context .context .config .pinned_environments ,
@@ -227,6 +214,30 @@ def _custom_get_environments(
227214 default_target_environment = "" ,
228215 )
229216
217+ def _custom_get_models (
218+ self , ls : LanguageServer , params : GetModelsRequest
219+ ) -> GetModelsResponse :
220+ """Get all models available for table diff."""
221+ try :
222+ context = self ._context_get_or_load ()
223+ models = [
224+ ModelInfo (
225+ name = model .name ,
226+ fqn = model .fqn ,
227+ description = model .description ,
228+ )
229+ for model in context .context .models .values ()
230+ # Filter for models that are suitable for table diff
231+ if model ._path is not None # Has a file path
232+ ]
233+ return GetModelsResponse (models = models )
234+ except Exception as e :
235+ ls .log_trace (f"Error getting table diff models: { e } " )
236+ return GetModelsResponse (
237+ response_error = str (e ),
238+ models = [],
239+ )
240+
230241 def _custom_api (
231242 self , ls : LanguageServer , request : ApiRequest
232243 ) -> t .Union [
0 commit comments