fix: Improve Whisper model status error handling

- Set sidecarReady to false when model_error is received
- Store error message in activeWhisperConfig for status display
- Update frontend to show error state with red indicator
- Prevents showing  when model failed to load

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
egg
2025-12-18 11:46:51 +08:00
parent 0defc829dd
commit c05fdad8e4
2 changed files with 20 additions and 7 deletions

View File

@@ -434,10 +434,16 @@ function startSidecar() {
mainWindow.webContents.send("model-download-progress", msg); mainWindow.webContents.send("model-download-progress", msg);
} }
// Forward model error status // Forward model error status and mark sidecar as not ready
if (msg.status === "model_error" && mainWindow) { if (msg.status === "model_error") {
sidecarReady = false;
if (activeWhisperConfig) {
activeWhisperConfig.error = msg.error || "Model load failed";
}
if (mainWindow) {
mainWindow.webContents.send("model-download-progress", msg); mainWindow.webContents.send("model-download-progress", msg);
} }
}
} catch (e) { } catch (e) {
console.log("Sidecar output:", line); console.log("Sidecar output:", line);
} }

View File

@@ -289,10 +289,17 @@
try { try {
const status = await window.electronAPI.getSidecarStatus(); const status = await window.electronAPI.getSidecarStatus();
if (status.whisper) { if (status.whisper) {
// Check if there was an error loading the model
if (status.whisper.error) {
whisperStatusEl.textContent = `❌ Model error: ${status.whisper.error}`;
whisperStatusEl.style.color = '#dc3545';
whisperStatusEl.title = 'Model failed to load';
} else {
const readyIcon = status.ready ? '✅' : '⏳'; const readyIcon = status.ready ? '✅' : '⏳';
whisperStatusEl.textContent = `${readyIcon} Model: ${status.whisper.model} | Device: ${status.whisper.device} | Compute: ${status.whisper.compute}`; whisperStatusEl.textContent = `${readyIcon} Model: ${status.whisper.model} | Device: ${status.whisper.device} | Compute: ${status.whisper.compute}`;
whisperStatusEl.title = `Config source: ${status.whisper.configSource || 'unknown'}`; whisperStatusEl.title = `Config source: ${status.whisper.configSource || 'unknown'}`;
whisperStatusEl.style.color = status.ready ? '#28a745' : '#ffc107'; whisperStatusEl.style.color = status.ready ? '#28a745' : '#ffc107';
}
} else { } else {
whisperStatusEl.textContent = status.ready ? '✅ Ready' : '⏳ Loading...'; whisperStatusEl.textContent = status.ready ? '✅ Ready' : '⏳ Loading...';
whisperStatusEl.style.color = status.ready ? '#28a745' : '#ffc107'; whisperStatusEl.style.color = status.ready ? '#28a745' : '#ffc107';