Skip to content

bug: Ollama connection is checked only during the setup wizard β€” if Ollama stops running after setup, all LLM-dependent features (notes, quiz, flashcards) fail with unhandled Rust panics instead of a user-friendly errorΒ #9

Description

@prince-pokharna

πŸ› Problem Statement

Knowte verifies Ollama is running during the initial setup wizard (curl http://localhost:11434/api/tags). However, after setup completes and the app is in normal use, if Ollama:

  • Crashes or is killed by the OS (common on low-RAM machines processing large models)
  • Is restarted on a different port
  • Has its model unloaded

...the next LLM call from the Rust backend (src-tauri/) will fail with a low-level HTTP connection error. Without a graceful handler, this surfaces as either a frozen UI or an unhandled Rust panic.

πŸ’‘ Proposed Fix

Add a pre-inference health check in the Tauri command handler:

// src-tauri/src/llm.rs

use reqwest::Client;

async fn check_ollama_health(ollama_url: &str) -> Result<(), String> {
    let client = Client::new();
    match client
        .get(format!("{}/api/tags", ollama_url))
        .timeout(std::time::Duration::from_secs(3))
        .send()
        .await
    {
        Ok(resp) if resp.status().is_success() => Ok(()),
        Ok(resp) => Err(format!("Ollama returned status {}", resp.status())),
        Err(e) => Err(format!(
            "Cannot reach Ollama at {}. Is it running? Error: {}",
            ollama_url, e
        )),
    }
}

#[tauri::command]
pub async fn generate_notes(transcript: String, model: String) -> Result<String, String> {
    check_ollama_health("http://localhost:11434").await?;
    // ... proceed with LLM call
}

Surface the error in the frontend as a dismissible banner:

// src/components/OllamaStatusBanner.tsx
{ollamaError && (
  <div className="bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded">
    ⚠️ Ollama is not running. Start it with <code>ollama serve</code> and retry.
  </div>
)}

πŸ“ Files to Modify

File Change
src-tauri/src/llm.rs Add check_ollama_health before every LLM invocation
src/components/OllamaStatusBanner.tsx New β€” user-visible connectivity error banner
src/ Propagate Tauri error string to UI state

Suggested labels: bug, reliability, tauri, ux

I would like to work on this. Could you please assign it to me?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions