fix: remove update popup and handle budget exceeded errors gracefully#5
fix: remove update popup and handle budget exceeded errors gracefully#5AhtishamShahid wants to merge 10 commits into
Conversation
Removed the update checker integration from the Electron app by dropping the import and all calls to startUpdateChecker/stopUpdateChecker in main.ts so the update banner no longer appears.
When the OpenAI API key runs out of budget it returns a 400 with type=budget_exceeded. The error handler was forwarding the raw OpenAI error string to the UI. Now detect that specific error type and return a clean 402 with an actionable message instead. Applied to both web app and Electron desktop app FastAPI servers.
There was a problem hiding this comment.
Pull request overview
Removes the Electron desktop app’s update-checker integration (and thus the update popup/banner) and improves user-facing handling of OpenAI “budget exceeded” errors by mapping them to a clean 402 response with a friendly message in both the web and Electron FastAPI servers.
Changes:
- Removed
startUpdateChecker/stopUpdateCheckerwiring from the Electron main process to prevent update banners from being shown. - Added OpenAI error inspection in the FastAPI LLM error handler to detect “budget exceeded” and return HTTP 402 with a user-friendly message.
- Applied the same budget-exceeded handling to both
servers/fastapiandelectron/servers/fastapi.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| servers/fastapi/utils/llm_client_error_handler.py | Detects OpenAI budget-exceeded errors and returns a friendly 402 response. |
| electron/servers/fastapi/utils/llm_client_error_handler.py | Mirrors the same OpenAI budget-exceeded handling for the Electron-bundled FastAPI server. |
| electron/app/main.ts | Removes update-checker integration to eliminate the update popup/banner. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
The update checker was disabled in a prior commit. Remove the now-unused update-checker.ts module, generate_update.js script, version.json, and the generate:version npm script from build:electron.
| error_body = getattr(e, "body", None) or {} | ||
| error_type = ( | ||
| error_body.get("error", {}).get("type", "") | ||
| if isinstance(error_body, dict) | ||
| else "" | ||
| ) |
There was a problem hiding this comment.
Fixed in commit 0299c7c1. Extracted error_obj separately and guarded it with isinstance(error_obj, dict) before calling .get('type', ''), so a non-dict error value no longer raises AttributeError.
| error_body = getattr(e, "body", None) or {} | ||
| error_type = ( | ||
| error_body.get("error", {}).get("type", "") | ||
| if isinstance(error_body, dict) | ||
| else "" | ||
| ) |
There was a problem hiding this comment.
Fixed in commit 0299c7c1. Same fix applied to electron/servers/fastapi/utils/llm_client_error_handler.py.
Text and image API key visibility toggles shared a single showApiKey state, causing both fields to reveal/hide together. Added a separate showImageApiKey state for all image provider API key inputs.
Summary
startUpdateChecker/stopUpdateCheckerintegration inelectron/app/main.tsbudget_exceededOpenAI error now returns a clean 402 with the message: "Your API key has exceeded its budget limit. Please add credits to your account to continue."showImageApiKeystate so each section's toggle is independent.Test plan