Skip to content
Merged
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
11 changes: 11 additions & 0 deletions .changeset/fix-ollama-model-check.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
"think-app": patch
---

fix(app): show setup wizard when configured Ollama model is missing

Fixes #44

Previously, if Ollama was installed and running but the configured chat model (e.g., llama3.2) wasn't downloaded, the app would skip the setup wizard and fail when trying to chat.

Now the app checks if the configured model is actually available before skipping the setup wizard. Also improved the model download progress to show user-friendly status messages instead of raw layer hashes.
17 changes: 17 additions & 0 deletions app/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,23 @@ function App() {
setAppState("ai_setup");
return;
}

// Check if the configured model is actually downloaded
const modelsRes = await apiFetch("/api/settings/models?provider=ollama");
const modelsData = await modelsRes.json();

// Check if current_model exists in the available models list
const hasConfiguredModel = modelsData.models?.some(
(m: { name: string }) =>
m.name === modelsData.current_model ||
m.name.startsWith(modelsData.current_model + ":")
);

if (!hasConfiguredModel) {
// Configured model not downloaded - show setup wizard
setAppState("ai_setup");
return;
}
}
} catch {
// If checks fail, proceed to app (don't block on check failure)
Expand Down
44 changes: 35 additions & 9 deletions app/src/SetupWizard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,15 @@ function WizardLayout({ title, children }: { title?: string; children: React.Rea
);
}

const formatPullStatus = (status: string): string => {
if (status.startsWith('pulling manifest')) return 'Preparing download...';
if (status.startsWith('pulling ')) return 'Downloading model...';
if (status.startsWith('verifying')) return 'Verifying download...';
if (status.startsWith('writing')) return 'Finalizing...';
if (status === 'success') return 'Complete!';
return status;
};

export default function SetupWizard({ onComplete }: Props) {
const [step, setStep] = useState<SetupStep>('check');
const [progress, setProgress] = useState(0);
Expand Down Expand Up @@ -85,7 +94,7 @@ export default function SetupWizard({ onComplete }: Props) {
setProgress(data.progress);
}
if (data.status) {
setStatusText(data.status);
setStatusText(formatPullStatus(data.status));
}
});

Expand All @@ -112,17 +121,34 @@ export default function SetupWizard({ onComplete }: Props) {
if (res.ok) {
const data = await res.json();
const models = data.models?.map((m: { name: string }) => m.name) || [];
const hasChatModel = models.some((n: string) => n.startsWith('llama3.2'));
const hasEmbedding = models.some((n: string) => n.startsWith('mxbai-embed-large'));

if (!hasEmbedding && window.electronAPI) {
if ((!hasChatModel || !hasEmbedding) && window.electronAPI) {
setStep('pulling');
setProgress(0);
setStatusText('Downloading embedding model...');
const result = await window.electronAPI.pullModel('mxbai-embed-large');
if (!result.success) {
setError(result.error || 'Embedding model download failed');
setStep('choose');
return;

// Pull chat model if missing
if (!hasChatModel) {
setProgress(0);
setStatusText('Downloading chat model...');
const chatResult = await window.electronAPI.pullModel('llama3.2');
if (!chatResult.success) {
setError(chatResult.error || 'Chat model download failed');
setStep('choose');
return;
}
}

// Pull embedding model if missing
if (!hasEmbedding) {
setProgress(0);
setStatusText('Downloading embedding model...');
const embedResult = await window.electronAPI.pullModel('mxbai-embed-large');
if (!embedResult.success) {
setError(embedResult.error || 'Embedding model download failed');
setStep('choose');
return;
}
}
}

Expand Down