Repository navigation
fix: dev harness hosted AI via a vite backend proxy, inline AI failure message - #70
Merged
Merged
Conversation
The dev preview harness (dev.html on http://localhost:5173) resolved BACKEND_BASE_URL to the staging worker, whose CORS allowlist admits only the extension origin and the staging site. The browser blocked every hosted-AI, license and billing response before the app saw it, so the "AI suggested" boxes never filled and the only feedback was a brief toast. Add a /api/backend proxy to vite.config.dev.ts, mirroring the existing /api/anthropic proxy, and make BACKEND_BASE_URL resolve to it only when a development-mode page is served over http(s). The unpacked dev extension (chrome-extension:// pages), the service worker, unit tests and production builds keep their previous targets. No backend change; the staging allowlist stays as tight as before. Refs #67 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
When a generation failed, the "AI suggested" box stayed on its placeholder and the only feedback was a toast that vanished within seconds, so a user who looked away saw an empty box and no explanation. Show the failure inside the box (role="alert") until the next attempt or a new suggestion arrives, using the same message as the toast so quota and availability errors from the proxy surface verbatim. H2 headings get the message per item, including the slots Generate All could not fill. Refs #67 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
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.
Summary
dev.htmlon http://localhost:5173) could not use hosted AI: every backend call went to the staging worker, whose CORS allowlist admits only the extension origin and the staging site, so the browser blocked the response and the "AI suggested" boxes never filled.Origin: http://localhost:5173returns 204 with noaccess-control-allow-originwhile the staging-site origin gets one, and the backend'sresolveOriginadmits localhost only whenENVIRONMENT === "development"./api/backendproxy invite.config.dev.ts, mirroring the existing/api/anthropicproxy. It forwards only the headers the backend accepts and relays status and body untouched, so the app's error mapping still applies.BACKEND_BASE_URLnow resolves throughresolveBackendBaseUrl()and points at the proxy only when a development-mode page is served over http(s); the unpacked dev extension (chrome-extension://pages), the service worker, unit tests and production builds keep their previous targets.role="alert") until the next attempt or a new suggestion arrives, using the same message as the toast so quota/availability errors from the proxy surface verbatim. H2 headings get it per item, including the slots "Generate All" could not fill.RecommendationBoxis unused in the app and was left alone.Verification
resolveBackendBaseUrl(harness → proxy; extension page, service worker, test and staging modes → staging; production → production) and the proxy middleware driven with fake req/res objects and a stubbedfetch(GET/POST forwarding, header allowlist, error relay, preflight, 502 when the backend is unreachable), plus component tests for the inline message on both boxes.POST /api/backend/ai/generate → 200. With the request aborted, the box showed "Could not reach the AI service." immediately and still 6 s later after the toast was gone.curlthrough the running harness:/api/backend/health200,/api/backend/ai/modelsreturns the model list, unknown routes relay staging's 404.tsc --noEmit,eslint .andpnpm buildclean.🤖 Generated with Claude Code