Make image model visibility provider-aware - #210
Conversation
Deploying zodiac with
|
| Latest commit: |
acf709a
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://1fa968d6.zodiac-c9y.pages.dev |
| Branch Preview URL: | https://feature-206-image-model-visi.zodiac-c9y.pages.dev |
faetalize
left a comment
There was a problem hiding this comment.
Automated multi-angle code review. Three confirmed correctness bugs share one root cause: every production IMAGE_MODELS entry is EDGE-only, yet EDGE availability is wired to the premium-preference checkbox (isPremiumEndpointToggleEnabled()) rather than actual edge/credit eligibility. As a result, any user with that toggle off — logged-in free-tier users who hold image credits, and paid users who simply disable it — now sees zero visible image models and is blocked from generating, where the old type === "all" credit check let them through. Separately, the new reconcile → synthetic change → saveSettings path persists "" over the user's saved image-model choice. Details are inline.
Note: I also checked the image-editing isImagePremiumEndpointPreferred shortcut (isImageEditingActive() || …). It is not currently triggerable (all editing models are EDGE-only, so validateVisibleImageModelSelection blocks first), but it would become a real routing bug if a non-EDGE editing model is ever added — worth a guarding comment.
|
Reworked this in This addresses the earlier review — mapping each finding:
The inline comments above are anchored to lines that were rewritten or deleted, so they should now show as outdated. |
Replace the provider-aware visibility filtering with a show-all + validate-at-send approach driven by a pure route resolver.
- Add src/utils/imageModelRouting.ts: resolveImageModelRoute(model, preferEdge, availability) -> {route: edge|google|openrouter} | {route: null, reason}, strict (preferEdge = edge-only, else BYOK-only). Covered by unit tests.
- Add a second, image-specific premium toggle (preferPremiumImageEndpoint), credit-gated (not pro-gated) so free users with image credits keep access. A hidden toggle counts as off, so no-credit users route via BYOK instead of getting stranded on prefer-edge.
- Revert the image/image-edit selectors to static population; remove the reconcile machinery, synthetic change events, and the empty-state placeholder.
- Settings.service image-model fallbacks are validity-only again (never persist "").
- Message.service resolves the route at send time and warns with a reason-specific, actionable toast; the chat-model API-key gate no longer applies to image requests.
- Remove the now-dead imageModelVisibility util and update tests.
Resolves the correctness/cleanup findings from the earlier review (preference wipes, free-user lockout, duplication, widened import contract).
4162669 to
5221ab0
Compare
Summary
Tests
close #206