Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.
Python agentagent-osaiai-agentsai-partnerchatopsclaudeclaude-codecodexdevtoolsdiscord-botlark-botllmlocal-firstlong-term-memoryopencodeslack-botvibe-codingvibeywechat
fix(ui): improve error handling for API requests
cyhhaoe747189cf4a3
diff --git a/ui/src/App.tsx b/ui/src/App.tsxindex 1e16d61b3..cb5f12212 100644--- a/ui/src/App.tsx+++ b/ui/src/App.tsx@@ -54,13 +54,13 @@ function AppRoutes() {function App() {return (<StatusProvider>- <ApiProvider>- <ToastProvider>+ <ToastProvider>+ <ApiProvider><BrowserRouter><AppRoutes /></BrowserRouter>- </ToastProvider>- </ApiProvider>+ </ApiProvider>+ </ToastProvider></StatusProvider>);}diff --git a/ui/src/context/ApiContext.tsx b/ui/src/context/ApiContext.tsxindex 218ab2b6d..706e48ea7 100644--- a/ui/src/context/ApiContext.tsx+++ b/ui/src/context/ApiContext.tsx@@ -1,4 +1,5 @@import React, { createContext, useContext } from 'react';+import { useToast } from './ToastContext';export type ApiContextType = {getConfig: () => Promise<any>;@@ -48,9 +49,39 @@ export const useApi = () => {};export const ApiProvider: React.FC<{ children: React.ReactNode }> = ({ children }) => {+ const { showToast } = useToast();++ const handleApiError = async (res: Response, path: string) => {+ let errorMessage = `Request failed: ${path} (${res.status})`;++ try {+ const data = await res.json();+ if (data.error) {+ errorMessage = data.error;+ }+ } catch {+ // Response is not JSON, use status text+ errorMessage = `${path}: ${res.statusText || 'Unknown error'} (${res.status})`;+ }++ // Log error details to console+ console.error(`[API Error] ${path}`, {+ status: res.status,+ statusText: res.statusText,+ error: errorMessage,+ });++ // Show toast to user+ showToast(errorMessage, 'error');++ throw new Error(errorMessage);+ };+const getJson = async (path: string) => {const res = await fetch(path);- if (!res.ok) throw new Error(`Request failed: ${path}`);+ if (!res.ok) {+ await handleApiError(res, path);+ }return res.json();};@@ -60,7 +91,9 @@ export const ApiProvider: React.FC<{ children: React.ReactNode }> = ({ childrenheaders: { 'Content-Type': 'application/json' },body: JSON.stringify(payload),});- if (!res.ok) throw new Error(`Request failed: ${path}`);+ if (!res.ok) {+ await handleApiError(res, path);+ }return res.json();};diff --git a/vibe/ui_server.py b/vibe/ui_server.pyindex 381a16d7d..7331c9187 100644--- a/vibe/ui_server.py+++ b/vibe/ui_server.py@@ -56,6 +56,13 @@ def _run_async(coro, timeout: float = 10.0) -> dict:@app.errorhandler(Exception)def handle_exception(e):"""Global exception handler - ensures all errors return JSON."""+ from werkzeug.exceptions import HTTPException++ # Preserve HTTP status codes for client errors (4xx)+ if isinstance(e, HTTPException):+ return jsonify({"error": e.description}), e.code++ # Log and return 500 for unexpected server errorslogger.exception("Unhandled exception in UI server")return jsonify({"error": str(e)}), 500