feat(ai): self-host settings UI for Anthropic provider (5/5)#1987
Draft
gariasf wants to merge 2 commits into
Draft
feat(ai): self-host settings UI for Anthropic provider (5/5)#1987gariasf wants to merge 2 commits into
gariasf wants to merge 2 commits into
Conversation
Contributor
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
58c88d9 to
6d92ea2
Compare
a2866b2 to
21f475b
Compare
6d92ea2 to
bb4fee3
Compare
21f475b to
6b7a5c5
Compare
bb4fee3 to
06762d0
Compare
6b7a5c5 to
603a2fd
Compare
9 tasks
06762d0 to
d962f61
Compare
603a2fd to
6903400
Compare
d962f61 to
509a2d2
Compare
6903400 to
fb9fd93
Compare
Adds the Anthropic panel and the install-wide LLM provider selector to the self-hosting settings page, plus a shared data-retention disclosure that covers both OpenAI and Anthropic. - New _llm_provider_selector partial: select for Setting.llm_provider (openai | anthropic), respects the LLM_PROVIDER env var (disables the control + shows the "configured through environment variables" hint when set, mirroring the existing OpenAI panel behaviour), and renders a compact data-handling block with one-line retention statements for each provider. - New _anthropic_settings partial mirrors _openai_settings exactly: password-field for the API key with **** redaction, optional base_url (for AWS Bedrock / GCP Vertex), optional default model. All three fields disable when their ENV var is set. - show.html.erb renders provider selector + OpenAI panel + Anthropic panel under the same "General" section so users can configure either (or both) without switching pages. - Settings::HostingsController#update now permits and persists anthropic_access_token (ignoring the **** placeholder, same pattern as OpenAI), anthropic_base_url, anthropic_model, and llm_provider (validated against %w[openai anthropic]). On Setting::ValidationError the rescue branch preserves anthropic_base_url / anthropic_model input so the form re-renders with the user's typed values intact — parity with the issue #1824 fix for OpenAI. - Locale keys added under settings.hostings.{llm_provider_selector, anthropic_settings}. Tests cover token update + placeholder redaction, base_url + model update, llm_provider switch to anthropic, and rejection of unknown provider values. The existing GET render test still passes, exercising all three new partials. Closes the 5/5 Anthropic series stacked on #1986.
- Data-handling block in _llm_provider_selector swaps the invalid bg-surface-secondary token for bg-container-inset, matching the inset-card pattern used elsewhere in sure-design-system/components.css. bg-surface-secondary is not defined anywhere in the design system — Tailwind treated it as a no-op, so the block rendered with no background contrast. - Settings::HostingsController validates anthropic_base_url as a URI::HTTP (catches https too) and raises Setting::ValidationError with a localized message when the input is not parseable. Previously any string was persisted, surfacing as an opaque connection error at request time instead of an immediate UX failure. - Blank base_url now clears the setting (was already the case but exercised explicitly in tests now).
509a2d2 to
b6e4b11
Compare
fb9fd93 to
6d977c3
Compare
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
Closes the 5-PR Anthropic series. PR 5 of 5, stacked on #1986.
Adds the Anthropic panel and the install-wide LLM provider selector to the self-hosting settings page, plus a shared data-handling disclosure that covers both OpenAI and Anthropic with parity.
What changed
Views
_llm_provider_selector.html.erb— install-level select forSetting.llm_provider(`openai | anthropic`). Respects the `LLM_PROVIDER` env var (disables the control + shows the "configured through environment variables" hint, mirroring the OpenAI panel). Renders a compact "Data handling" block with one-sentence retention statements for each provider — surfaced once for both providers since the wording is the same._anthropic_settings.html.erb— mirrors_openai_settings.html.erbfield-for-field:anthropic_access_tokenpassword field,********redaction when stored, disabled when `ANTHROPIC_ACCESS_TOKEN` / `ANTHROPIC_API_KEY` env is set.anthropic_base_urltext field (optional — for AWS Bedrock / GCP Vertex proxies).anthropic_modeltext field (optional — defaults to `claude-sonnet-4-6`).show.html.erb— renders provider selector → OpenAI panel → Anthropic panel under the existing "General" section. No section restructure.Controller (
Settings::HostingsController)anthropic_access_token,anthropic_base_url,anthropic_model,llm_providerinhosting_params."********"placeholder protection that OpenAI uses so an unchanged form re-submit doesn't overwrite a stored key with the redacted display string.llm_provideragainst%w[openai anthropic]— unknown values are dropped without raising.Setting::ValidationErrorthe rescue branch now also stashes@anthropic_base_url_input/@anthropic_model_inputso the form re-renders with the user's typed values intact (parity with the OpenAI fix from issue Bug: OpenAI Custom URL field clears itself if Model is not filled first #1824).Locales
settings.hostings.llm_provider_selector.*andsettings.hostings.anthropic_settings.*keys toconfig/locales/views/settings/hostings/en.yml.Visual layout (General section)
Test plan
test/controllers/settings/hostings_controller_test.rb— 5 new tests:"********"placeholder ignored (no overwrite of a stored key)llm_providerto anthropicbundle exec erb_lint ./app/views/settings/hostings/_anthropic_settings.html.erb ./app/views/settings/hostings/_llm_provider_selector.html.erb ./app/views/settings/hostings/show.html.erb— no errors.bin/rails runner I18n.t(...).bin/rubocopclean on touched Ruby files.bin/brakeman --no-pagerclean.