Add support for dynamic config UI (#256)

* Add support for dynamic config UI

* Add support for section description

* Better dynamic class settings

Added dynamic_fields hash field - Stores all undeclared settings
[] method - Checks declared fields first, then falls back to dynamic hash
[]= method - Updates declared fields normally, stores others in hash
No runtime field declaration - Fields are never dynamically created on the class

* FIX proper lookup for provider keys

- Also validate configurable values properly.
- Change Provider factory to use Rails autoloading (Zeitwerk)

* Fix factory

The derive_adapter_name method relies on string manipulation ("PlaidAccount".sub(/Account$/, "") + "Adapter" → "PlaidAdapter"), but we already have explicit registration in place.

* Make updates atomic, field-aware, and handle blanks explicitly

* Small UX detail

* Add support for PlaidEU in UI also

- This looks like partial support atm
This commit is contained in:
soky srm
2025-10-29 13:11:04 +01:00
committed by GitHub
parent 9fefe57de5
commit 96713ee8b4
13 changed files with 763 additions and 43 deletions

View File

@@ -3,13 +3,14 @@ require "test_helper"
class Provider::RegistryTest < ActiveSupport::TestCase
test "providers filters out nil values when provider is not configured" do
# Ensure OpenAI is not configured
Setting.stubs(:openai_access_token).returns(nil)
ENV.stubs(:fetch).with("OPENAI_ACCESS_TOKEN", nil).returns(nil)
ClimateControl.modify("OPENAI_ACCESS_TOKEN" => nil) do
Setting.stubs(:openai_access_token).returns(nil)
registry = Provider::Registry.for_concept(:llm)
registry = Provider::Registry.for_concept(:llm)
# Should return empty array instead of [nil]
assert_equal [], registry.providers
# Should return empty array instead of [nil]
assert_equal [], registry.providers
end
end
test "providers returns configured providers" do
@@ -34,13 +35,14 @@ class Provider::RegistryTest < ActiveSupport::TestCase
test "get_provider returns nil when provider not configured" do
# Ensure OpenAI is not configured
Setting.stubs(:openai_access_token).returns(nil)
ENV.stubs(:[]).with("OPENAI_ACCESS_TOKEN").returns(nil)
ClimateControl.modify("OPENAI_ACCESS_TOKEN" => nil) do
Setting.stubs(:openai_access_token).returns(nil)
registry = Provider::Registry.for_concept(:llm)
registry = Provider::Registry.for_concept(:llm)
# Should return nil when provider method exists but returns nil
assert_nil registry.get_provider(:openai)
# Should return nil when provider method exists but returns nil
assert_nil registry.get_provider(:openai)
end
end
test "openai provider falls back to Setting when ENV is empty string" do