Skip to content

refactor(config): replace get_default_provider/get_provider_model with unified get_session_config#3000

Merged
tusharmath merged 4 commits intomainfrom
default-model-provider-fixes
Apr 14, 2026
Merged

refactor(config): replace get_default_provider/get_provider_model with unified get_session_config#3000
tusharmath merged 4 commits intomainfrom
default-model-provider-fixes

Conversation

@tusharmath
Copy link
Copy Markdown
Collaborator

@tusharmath tusharmath commented Apr 14, 2026

Summary

Replace the dual get_default_provider / get_provider_model API with a single unified get_session_config method that returns a ModelConfig (provider + model pair) or None.

Context

The previous AppConfigService trait exposed two separate methods — get_default_provider() returning Result<ProviderId> and get_provider_model(Option<&ProviderId>) returning Result<ModelId> — that callers always had to invoke together and chain manually. This split made call-sites verbose, error-prone, and hard to reason about. Since provider and model are always configured atomically via SetSessionConfig, there is no reason to read them separately.

Changes

  • Removed get_default_provider and get_provider_model from AppConfigService and replaced them with get_session_config() -> Option<ModelConfig>
  • Updated ForgeAppConfigService implementation: the new method reads ForgeConfig::session once and returns Some(ModelConfig) or None, eliminating the intermediate provider_id lookup step
  • Updated all call-sites across forge_api, forge_app (agent, agent_provider_resolver, command_generator, data_gen), and forge_main (ui, vscode) to use the new method
  • Simplified vscode.rs test helpers by removing the mutex-guarded EnvGuard boilerplate and replacing it with a lighter inline unsafe env-var setup/teardown
  • Updated all related tests to assert on the full ModelConfig object instead of provider and model separately

Testing

cargo insta test --accept

@github-actions github-actions bot added the type: refactor Code refactoring and restructuring. label Apr 14, 2026
@tusharmath tusharmath merged commit a387bfd into main Apr 14, 2026
8 checks passed
@tusharmath tusharmath deleted the default-model-provider-fixes branch April 14, 2026 09:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: refactor Code refactoring and restructuring.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant