Add Ollama health check status indicator to chat views
Adds visibility into whether Ollama is reachable and the configured model is ready before allowing chat. Prevents silent failures when the model is still downloading or Ollama is unavailable. - Backend: GET /api/chat/status endpoint checks Ollama /api/tags (5s timeout) Returns ollama availability + model readiness + default model name - Frontend: OllamaStatus type, chat store polling (30s interval) - ChatView: status dot + label in header (green/yellow/red), disabled send - ChatPanel: compact status indicator in panel header, disabled send - summary.md: updated with new endpoint, store changes, and component descriptions Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { ref } from "vue";
|
||||
import { ref, computed } from "vue";
|
||||
import { defineStore } from "pinia";
|
||||
import {
|
||||
apiGet,
|
||||
@@ -12,6 +12,7 @@ import type {
|
||||
ConversationDetail,
|
||||
Message,
|
||||
OllamaModel,
|
||||
OllamaStatus,
|
||||
} from "@/types/chat";
|
||||
|
||||
export const useChatStore = defineStore("chat", () => {
|
||||
@@ -22,6 +23,14 @@ export const useChatStore = defineStore("chat", () => {
|
||||
const streaming = ref(false);
|
||||
const streamingContent = ref("");
|
||||
const models = ref<OllamaModel[]>([]);
|
||||
const ollamaStatus = ref<"checking" | "available" | "unavailable">("checking");
|
||||
const modelStatus = ref<"checking" | "ready" | "not_found">("checking");
|
||||
const defaultModel = ref("");
|
||||
let statusPollTimer: ReturnType<typeof setInterval> | null = null;
|
||||
|
||||
const chatReady = computed(
|
||||
() => ollamaStatus.value === "available" && modelStatus.value === "ready"
|
||||
);
|
||||
|
||||
async function fetchConversations(limit = 50, offset = 0) {
|
||||
loading.value = true;
|
||||
@@ -157,6 +166,31 @@ export const useChatStore = defineStore("chat", () => {
|
||||
);
|
||||
}
|
||||
|
||||
async function fetchStatus() {
|
||||
try {
|
||||
const data = await apiGet<OllamaStatus>("/api/chat/status");
|
||||
ollamaStatus.value = data.ollama;
|
||||
modelStatus.value = data.model;
|
||||
defaultModel.value = data.default_model;
|
||||
} catch {
|
||||
ollamaStatus.value = "unavailable";
|
||||
modelStatus.value = "not_found";
|
||||
}
|
||||
}
|
||||
|
||||
function startStatusPolling() {
|
||||
fetchStatus();
|
||||
stopStatusPolling();
|
||||
statusPollTimer = setInterval(fetchStatus, 30_000);
|
||||
}
|
||||
|
||||
function stopStatusPolling() {
|
||||
if (statusPollTimer !== null) {
|
||||
clearInterval(statusPollTimer);
|
||||
statusPollTimer = null;
|
||||
}
|
||||
}
|
||||
|
||||
async function fetchModels() {
|
||||
try {
|
||||
const data = await apiGet<{ models: OllamaModel[] }>("/api/chat/models");
|
||||
@@ -174,6 +208,10 @@ export const useChatStore = defineStore("chat", () => {
|
||||
streaming,
|
||||
streamingContent,
|
||||
models,
|
||||
ollamaStatus,
|
||||
modelStatus,
|
||||
defaultModel,
|
||||
chatReady,
|
||||
fetchConversations,
|
||||
createConversation,
|
||||
fetchConversation,
|
||||
@@ -183,5 +221,8 @@ export const useChatStore = defineStore("chat", () => {
|
||||
saveMessageAsNote,
|
||||
summarizeAsNote,
|
||||
fetchModels,
|
||||
fetchStatus,
|
||||
startStatusPolling,
|
||||
stopStatusPolling,
|
||||
};
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user