Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions apps/desktop/src/components/toast/model-download.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
import { useQuery, useQueryClient } from "@tanstack/react-query";
import { useEffect } from "react";
import { useEffect, useState } from "react";

import { commands as localLlmCommands } from "@hypr/plugin-local-llm";
import { commands as localSttCommands } from "@hypr/plugin-local-stt";
import { sonnerToast, toast } from "@hypr/ui/components/ui/toast";
import { showLlmModelDownloadToast, showSttModelDownloadToast } from "./shared";

const TOAST_DISMISSAL_KEY = "model-download-toast-dismissed";

export default function ModelDownloadNotification() {
const queryClient = useQueryClient();
const [isDismissed, setIsDismissed] = useState(() => {
return sessionStorage.getItem(TOAST_DISMISSAL_KEY) === "true";
});
const currentSttModel = useQuery({
queryKey: ["current-stt-model"],
queryFn: () => localSttCommands.getCurrentModel(),
Expand Down Expand Up @@ -67,6 +72,10 @@ export default function ModelDownloadNotification() {
return;
}

if (isDismissed) {
return;
}

const needsSttModel = !checkForModelDownload.data?.sttModelDownloaded;
const needsLlmModel = !checkForModelDownload.data?.llmModelDownloaded;

Expand All @@ -90,6 +99,12 @@ export default function ModelDownloadNotification() {
return;
}

const handleDismiss = () => {
setIsDismissed(true);
sessionStorage.setItem(TOAST_DISMISSAL_KEY, "true");
sonnerToast.dismiss("model-download-needed");
};

toast({
id: "model-download-needed",
title,
Expand All @@ -110,10 +125,15 @@ export default function ModelDownloadNotification() {
},
primary: true,
},
{
label: "Dismiss",
onClick: handleDismiss,
primary: false,
},
],
dismissible: false,
});
}, [checkForModelDownload.data, sttModelDownloading.data, llmModelDownloading.data]);
}, [checkForModelDownload.data, sttModelDownloading.data, llmModelDownloading.data, isDismissed]);

return null;
}
Loading