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,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { onMounted, ref, computed, watch, nextTick } from "vue";
|
||||
import { onMounted, onUnmounted, ref, computed, watch, nextTick } from "vue";
|
||||
import { useRoute, useRouter } from "vue-router";
|
||||
import { useChatStore } from "@/stores/chat";
|
||||
import { renderMarkdown } from "@/utils/markdown";
|
||||
@@ -24,13 +24,38 @@ const streamingRendered = computed(() => {
|
||||
return renderMarkdown(store.streamingContent);
|
||||
});
|
||||
|
||||
const statusLabel = computed(() => {
|
||||
if (store.ollamaStatus === "unavailable") return "Ollama unavailable";
|
||||
if (store.modelStatus === "not_found") return "Model downloading...";
|
||||
if (store.ollamaStatus === "available" && store.modelStatus === "ready")
|
||||
return "Connected";
|
||||
return "Checking...";
|
||||
});
|
||||
|
||||
const statusClass = computed(() => {
|
||||
if (store.ollamaStatus === "unavailable") return "status-red";
|
||||
if (store.modelStatus === "not_found") return "status-yellow";
|
||||
if (store.chatReady) return "status-green";
|
||||
return "status-yellow";
|
||||
});
|
||||
|
||||
const inputPlaceholder = computed(() => {
|
||||
if (!store.chatReady) return `Chat unavailable — ${statusLabel.value}`;
|
||||
return "Type a message... (Enter to send, Shift+Enter for new line)";
|
||||
});
|
||||
|
||||
onMounted(async () => {
|
||||
store.startStatusPolling();
|
||||
await store.fetchConversations();
|
||||
if (convId.value) {
|
||||
await store.fetchConversation(convId.value);
|
||||
}
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
store.stopStatusPolling();
|
||||
});
|
||||
|
||||
watch(convId, async (newId) => {
|
||||
if (newId) {
|
||||
await store.fetchConversation(newId);
|
||||
@@ -159,6 +184,10 @@ function onInputKeydown(e: KeyboardEvent) {
|
||||
<template v-if="store.currentConversation">
|
||||
<div class="chat-header">
|
||||
<h2>{{ store.currentConversation.title || "New Chat" }}</h2>
|
||||
<span class="status-indicator" :class="statusClass">
|
||||
<span class="status-dot"></span>
|
||||
{{ statusLabel }}
|
||||
</span>
|
||||
<button
|
||||
v-if="store.currentConversation.messages.length"
|
||||
class="btn-summarize"
|
||||
@@ -195,14 +224,14 @@ function onInputKeydown(e: KeyboardEvent) {
|
||||
<textarea
|
||||
v-model="messageInput"
|
||||
@keydown="onInputKeydown"
|
||||
placeholder="Type a message... (Enter to send, Shift+Enter for new line)"
|
||||
:disabled="store.streaming"
|
||||
:placeholder="inputPlaceholder"
|
||||
:disabled="store.streaming || !store.chatReady"
|
||||
rows="2"
|
||||
></textarea>
|
||||
<button
|
||||
class="btn-send"
|
||||
@click="sendMessage"
|
||||
:disabled="!messageInput.trim() || store.streaming"
|
||||
:disabled="!messageInput.trim() || store.streaming || !store.chatReady"
|
||||
>
|
||||
Send
|
||||
</button>
|
||||
@@ -315,6 +344,35 @@ function onInputKeydown(e: KeyboardEvent) {
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.status-indicator {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.35rem;
|
||||
font-size: 0.8rem;
|
||||
color: var(--color-text-muted);
|
||||
white-space: nowrap;
|
||||
}
|
||||
.status-dot {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
border-radius: 50%;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.status-green .status-dot {
|
||||
background: #22c55e;
|
||||
}
|
||||
.status-yellow .status-dot {
|
||||
background: #eab308;
|
||||
animation: pulse-dot 2s infinite;
|
||||
}
|
||||
.status-red .status-dot {
|
||||
background: #ef4444;
|
||||
}
|
||||
@keyframes pulse-dot {
|
||||
0%, 100% { opacity: 1; }
|
||||
50% { opacity: 0.4; }
|
||||
}
|
||||
|
||||
.btn-summarize {
|
||||
padding: 0.3rem 0.75rem;
|
||||
background: var(--color-bg-secondary);
|
||||
|
||||
Reference in New Issue
Block a user