Skip to content
Open
Show file tree
Hide file tree
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
6 changes: 5 additions & 1 deletion frontend/src-tauri/capabilities/model_manager.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
{
"identifier": "model-manager-capabilities",
"windows": ["model-manager"],
"permissions": ["core:window:default", "core:app:allow-version"]
"permissions": ["core:window:default",
"core:app:allow-version",
"core:event:default",
"core:window:allow-close",
"core:window:allow-destroy"]
}
7 changes: 7 additions & 0 deletions frontend/src/hooks/useUserPreferences.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,13 @@ export const useUserPreferences = () => {
updateYoloModelSize,
toggleGpuAcceleration,


// ISSUE - 1369: Exposed so other Tauri windows (e.g. Model Manager) can access it and
// refresh the preferences after making changes inside Model-Manager Window.
refetch: preferencesQuery.refetch,



// Mutation state (for use in UI, e.g., disabling buttons)
isUpdating: updatePreferencesMutation.isPending,
};
Expand Down
27 changes: 27 additions & 0 deletions frontend/src/pages/ModelManager/ModelManager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ import { Download, Cloud } from 'lucide-react';
import { usePictoQuery } from '@/hooks/useQueryExtension';
import { fetchModelStatus } from '@/api/api-functions';

// ISSUE - 1369: Importing emit and getCurrentWindow for the connection between settings and model manager.
import { getCurrentWindow } from '@tauri-apps/api/window';
import { emit } from '@tauri-apps/api/event';

const TABS: TabConfig[] = [
{ id: 'Installed', label: 'Installed', icon: Download },
{ id: 'Available', label: 'Available', icon: Cloud },
Expand Down Expand Up @@ -63,6 +67,29 @@ export const ModelManager: React.FC = () => {
}
}, [statusData, downloadingTiers, installedJustNow]);


// ISSUE - 1369: Model Manager runs in its own Tauri window, separate from the Settings.
// They don't share React/query state. When the Model Manager closes,
// it emits 'models-updated' so Settings can get notified..
useEffect(() => {
const unlistenPromise = getCurrentWindow().onCloseRequested(async (event) => {
event.preventDefault();
try {
await emit('models-updated');
} catch (err) {
console.error('Failed to emit models-updated', err);
}
await getCurrentWindow().destroy();

});

return () => {
unlistenPromise.then((unlisten) => unlisten());
};
}, []);
Comment thread
coderabbitai[bot] marked this conversation as resolved.



const handleTabChange = (newTab: string) => {
if (activeTab === 'Available' && newTab !== 'Available') {
setInstalledJustNow(new Set());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ import {
DropdownMenuTrigger,
} from '@/components/ui/dropdown-menu';
import { Button } from '@/components/ui/button';


import { invoke } from '@tauri-apps/api/core';
import { listen } from '@tauri-apps/api/event';


import { useUserPreferences } from '@/hooks/useUserPreferences';
import SettingsCard from './SettingsCard';
Expand All @@ -28,7 +32,7 @@ import {
* Component for managing user preferences in settings
*/
const UserPreferencesCard: React.FC = () => {
const { preferences, updateYoloModelSize, toggleGpuAcceleration } =
const { preferences, updateYoloModelSize, toggleGpuAcceleration, refetch } =
useUserPreferences();
const [installedTiers, setInstalledTiers] = useState<ModelTier[]>([]);
const [loadingTiers, setLoadingTiers] = useState(true);
Expand Down Expand Up @@ -82,6 +86,36 @@ const UserPreferencesCard: React.FC = () => {
};
}, []);



// ISSUE - 1369: Model Manager runs in its own Tauri window and doesn't share state with
// Settings. It emits 'models-updated' when it closes; refresh both the
// installed-tiers list and the active preference here in response.
useEffect(() => {
const unlistenPromise = listen('models-updated', async () => {
try {
const res = await fetch(`${BACKEND_URL}/models/status`);
if (res.ok) {
const data: ModelStatusResponse = await res.json();
if (data.success && data.data) {
setInstalledTiers(getInstalledModelTiers(data.data));
}
}
} catch (err) {
console.error('Failed to refresh model status', err);
}
refetch().catch(console.error);
});

return () => {
unlistenPromise.then((unlisten) => unlisten());
};
}, [refetch]);





return (
<SettingsCard
icon={Cpu}
Expand Down
Loading