diff --git a/apps/desktop/src/components/toast/model-download.tsx b/apps/desktop/src/components/toast/model-download.tsx index d83c9ba691..a044d22cef 100644 --- a/apps/desktop/src/components/toast/model-download.tsx +++ b/apps/desktop/src/components/toast/model-download.tsx @@ -41,6 +41,14 @@ export default function ModelDownloadNotification() { refetchInterval: 5000, }); + const listDownloadedModels = useQuery({ + queryKey: ["list-downloaded-models"], + queryFn: async () => { + return localLlmCommands.listDownloadedModel(); + }, + refetchInterval: 3000, + }); + const sttModelDownloading = useQuery({ enabled: !checkForModelDownload.data?.sttModelDownloaded, queryKey: ["stt-model-downloading"], @@ -77,7 +85,7 @@ export default function ModelDownloadNotification() { } const needsSttModel = !checkForModelDownload.data?.sttModelDownloaded; - const needsLlmModel = !checkForModelDownload.data?.llmModelDownloaded; + const needsLlmModel = listDownloadedModels.data?.length === 0; let title: string; let content: string; diff --git a/apps/desktop/src/components/welcome-modal/index.tsx b/apps/desktop/src/components/welcome-modal/index.tsx index 973b2773a0..0388da8d75 100644 --- a/apps/desktop/src/components/welcome-modal/index.tsx +++ b/apps/desktop/src/components/welcome-modal/index.tsx @@ -78,6 +78,9 @@ export function WelcomeModal({ isOpen, onClose }: WelcomeModalProps) { const handleModelSelected = (model: SupportedModel) => { selectSTTModel.mutate(model); + + sessionStorage.setItem("model-download-toast-dismissed", "true"); + onClose(); }; diff --git a/plugins/local-llm/build.rs b/plugins/local-llm/build.rs index bda06d322d..6a34ca67de 100644 --- a/plugins/local-llm/build.rs +++ b/plugins/local-llm/build.rs @@ -1,6 +1,5 @@ const COMMANDS: &[&str] = &[ "models_dir", - "list_supported_models", "is_server_running", "is_model_downloaded", "is_model_downloading", @@ -10,6 +9,7 @@ const COMMANDS: &[&str] = &[ "restart_server", "get_current_model", "set_current_model", + "list_downloaded_model", ]; fn main() { diff --git a/plugins/local-llm/permissions/autogenerated/commands/list_downloaded_model.toml b/plugins/local-llm/permissions/autogenerated/commands/list_downloaded_model.toml new file mode 100644 index 0000000000..7454fc0fbd --- /dev/null +++ b/plugins/local-llm/permissions/autogenerated/commands/list_downloaded_model.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-list-downloaded-model" +description = "Enables the list_downloaded_model command without any pre-configured scope." +commands.allow = ["list_downloaded_model"] + +[[permission]] +identifier = "deny-list-downloaded-model" +description = "Denies the list_downloaded_model command without any pre-configured scope." +commands.deny = ["list_downloaded_model"] diff --git a/plugins/local-llm/permissions/autogenerated/commands/list_supported_models.toml b/plugins/local-llm/permissions/autogenerated/commands/list_supported_models.toml deleted file mode 100644 index 0240e3c9ad..0000000000 --- a/plugins/local-llm/permissions/autogenerated/commands/list_supported_models.toml +++ /dev/null @@ -1,13 +0,0 @@ -# Automatically generated - DO NOT EDIT! - -"$schema" = "../../schemas/schema.json" - -[[permission]] -identifier = "allow-list-supported-models" -description = "Enables the list_supported_models command without any pre-configured scope." -commands.allow = ["list_supported_models"] - -[[permission]] -identifier = "deny-list-supported-models" -description = "Denies the list_supported_models command without any pre-configured scope." -commands.deny = ["list_supported_models"] diff --git a/plugins/local-llm/permissions/autogenerated/reference.md b/plugins/local-llm/permissions/autogenerated/reference.md index 79386a35be..dbd98ee19a 100644 --- a/plugins/local-llm/permissions/autogenerated/reference.md +++ b/plugins/local-llm/permissions/autogenerated/reference.md @@ -14,7 +14,7 @@ Default permissions for the plugin - `allow-restart-server` - `allow-get-current-model` - `allow-set-current-model` -- `allow-list-supported-models` +- `allow-list-downloaded-model` ## Permission Table @@ -184,12 +184,12 @@ Denies the is_server_running command without any pre-configured scope. -`local-llm:allow-list-supported-models` +`local-llm:allow-list-downloaded-model` -Enables the list_supported_models command without any pre-configured scope. +Enables the list_downloaded_model command without any pre-configured scope. @@ -197,12 +197,12 @@ Enables the list_supported_models command without any pre-configured scope. -`local-llm:deny-list-supported-models` +`local-llm:deny-list-downloaded-model` -Denies the list_supported_models command without any pre-configured scope. +Denies the list_downloaded_model command without any pre-configured scope. diff --git a/plugins/local-llm/permissions/default.toml b/plugins/local-llm/permissions/default.toml index 96dc1c89f7..484fd43a4b 100644 --- a/plugins/local-llm/permissions/default.toml +++ b/plugins/local-llm/permissions/default.toml @@ -11,5 +11,5 @@ permissions = [ "allow-restart-server", "allow-get-current-model", "allow-set-current-model", - "allow-list-supported-models", + "allow-list-downloaded-model", ] diff --git a/plugins/local-llm/permissions/schemas/schema.json b/plugins/local-llm/permissions/schemas/schema.json index af125d8e50..65c7de939e 100644 --- a/plugins/local-llm/permissions/schemas/schema.json +++ b/plugins/local-llm/permissions/schemas/schema.json @@ -367,16 +367,16 @@ "markdownDescription": "Denies the is_server_running command without any pre-configured scope." }, { - "description": "Enables the list_supported_models command without any pre-configured scope.", + "description": "Enables the list_downloaded_model command without any pre-configured scope.", "type": "string", - "const": "allow-list-supported-models", - "markdownDescription": "Enables the list_supported_models command without any pre-configured scope." + "const": "allow-list-downloaded-model", + "markdownDescription": "Enables the list_downloaded_model command without any pre-configured scope." }, { - "description": "Denies the list_supported_models command without any pre-configured scope.", + "description": "Denies the list_downloaded_model command without any pre-configured scope.", "type": "string", - "const": "deny-list-supported-models", - "markdownDescription": "Denies the list_supported_models command without any pre-configured scope." + "const": "deny-list-downloaded-model", + "markdownDescription": "Denies the list_downloaded_model command without any pre-configured scope." }, { "description": "Enables the models_dir command without any pre-configured scope.", @@ -439,10 +439,10 @@ "markdownDescription": "Denies the stop_server command without any pre-configured scope." }, { - "description": "Default permissions for the plugin\n#### This default permission set includes:\n\n- `allow-models-dir`\n- `allow-is-server-running`\n- `allow-is-model-downloading`\n- `allow-is-model-downloaded`\n- `allow-download-model`\n- `allow-start-server`\n- `allow-stop-server`\n- `allow-restart-server`\n- `allow-get-current-model`\n- `allow-set-current-model`\n- `allow-list-supported-models`", + "description": "Default permissions for the plugin\n#### This default permission set includes:\n\n- `allow-models-dir`\n- `allow-is-server-running`\n- `allow-is-model-downloading`\n- `allow-is-model-downloaded`\n- `allow-download-model`\n- `allow-start-server`\n- `allow-stop-server`\n- `allow-restart-server`\n- `allow-get-current-model`\n- `allow-set-current-model`\n- `allow-list-downloaded-model`", "type": "string", "const": "default", - "markdownDescription": "Default permissions for the plugin\n#### This default permission set includes:\n\n- `allow-models-dir`\n- `allow-is-server-running`\n- `allow-is-model-downloading`\n- `allow-is-model-downloaded`\n- `allow-download-model`\n- `allow-start-server`\n- `allow-stop-server`\n- `allow-restart-server`\n- `allow-get-current-model`\n- `allow-set-current-model`\n- `allow-list-supported-models`" + "markdownDescription": "Default permissions for the plugin\n#### This default permission set includes:\n\n- `allow-models-dir`\n- `allow-is-server-running`\n- `allow-is-model-downloading`\n- `allow-is-model-downloaded`\n- `allow-download-model`\n- `allow-start-server`\n- `allow-stop-server`\n- `allow-restart-server`\n- `allow-get-current-model`\n- `allow-set-current-model`\n- `allow-list-downloaded-model`" } ] }