fix(frontend): make channel settings robust against API failures and proxy channel requests#365
Closed
opj161 wants to merge 1 commit into
Closed
fix(frontend): make channel settings robust against API failures and proxy channel requests#365opj161 wants to merge 1 commit into
opj161 wants to merge 1 commit into
Conversation
…proxy channel requests Signed-off-by: opj161 <opj161@outlook.com>
There was a problem hiding this comment.
Pull request overview
Improves the frontend Settings experience when channel runtime endpoints are unavailable (e.g., Vite SPA fallback returning HTML) by hardening API response parsing, proxying /channels during development, and rendering the Settings page even when channel status fails.
Changes:
- Proxy
/channelsAPI routes through the Vite dev server to avoid SPA HTML fallback responses. - Switch Settings page loading to
Promise.allSettledand make the channels panel resilient to channel-status load failures. - Add diagnostics + regression tests for non-JSON API responses and for Settings rendering when channel status fails.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| frontend/vite.config.ts | Proxies /channels to the backend during dev to prevent SPA fallback HTML responses. |
| frontend/src/pages/Settings.tsx | Uses allSettled and renders channels section even when channel status fails; disables actions when unavailable. |
| frontend/src/lib/api.ts | Throws a descriptive ApiError when a successful response is not JSON (content-type mismatch). |
| frontend/src/pages/tests/SettingsChannels.test.tsx | Adds regression test ensuring Settings still renders when channel status API rejects. |
| frontend/src/lib/tests/api.test.ts | Adds unit test verifying non-JSON responses are rejected with a descriptive ApiError. |
| frontend/src/tests/viteProxy.test.ts | Adds test that Vite config contains expected proxy paths (including /channels). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
54
to
+58
| useEffect(() => { | ||
| let alive = true; | ||
| Promise.all([api.getLLMSettings(), api.getDataSourceSettings(), api.getChannelStatus()]) | ||
| .then(([llmData, dataSourceData, channelData]) => { | ||
|
|
||
| Promise.allSettled([ | ||
| api.getLLMSettings(), |
Comment on lines
+69
to
+76
| const message = llmResult.reason instanceof Error ? llmResult.reason.message : "Unknown error"; | ||
| setSettingsLoadError(message); | ||
| if (isAuthRequiredError(llmResult.reason)) { | ||
| toast.error(message); | ||
| } else { | ||
| toast.error(`Failed to load LLM settings: ${message}`); | ||
| } | ||
| } |
Comment on lines
+133
to
+135
| apiMock.getChannelStatus.mockRejectedValue( | ||
| new Error('Expected JSON from /channels/status, got text/html: <!doctype html>'), | ||
| ); |
Collaborator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Goal