Add Bedrock model refresh and fix auto-region discovery race

Co-Authored-By: Warp <agent@warp.dev>
This commit is contained in:
Josh Woodcock
2026-10-19 12:51:53 -05:00
co-authored by Warp
parent 1820561f2a
commit 3ddd8f25ac
2 changed files with 18 additions and 4 deletions
+16 -1
View File
@@ -43,7 +43,7 @@ use strum::IntoEnumIterator;
use super::execution_profile_view::{ExecutionProfileView, ExecutionProfileViewEvent};
use super::provider_setup_view::{
model_catalog_table, AcpProviderDraft, BedrockProviderDraft, ProviderSetupProviderType,
ProviderSetupView, ProviderSetupViewEvent,
ProviderSetupView, ProviderSetupViewAction, ProviderSetupViewEvent,
};
use super::settings_page::{
build_sub_header, build_toggle_element, render_body_item_label,
@@ -2720,6 +2720,7 @@ pub enum AISettingsPageAction {
},
RemoveOpenAIProvider(usize),
EditBedrockProvider,
RefreshBedrockModels,
RemoveBedrockProvider,
RemoveAcpProvider(String),
ToggleFileBasedMcp,
@@ -3457,6 +3458,12 @@ impl TypedActionView for AISettingsPageView {
AISettingsPageAction::EditBedrockProvider => {
self.begin_inline_bedrock_setup(ctx);
}
AISettingsPageAction::RefreshBedrockModels => {
self.begin_inline_bedrock_setup(ctx);
self.provider_setup_body.update(ctx, |body, ctx| {
body.handle_action(&ProviderSetupViewAction::Next, ctx);
});
}
AISettingsPageAction::RemoveBedrockProvider => {
AISettings::handle(ctx).update(ctx, |settings, ctx| {
report_if_error!(settings.bedrock_enabled.set_value(false, ctx));
@@ -6641,6 +6648,7 @@ struct ProviderSettingsWidget {
bedrock_add_button: ViewHandle<ActionButton>,
acp_add_button: ViewHandle<ActionButton>,
bedrock_edit_button: ViewHandle<ActionButton>,
bedrock_refresh_button: ViewHandle<ActionButton>,
bedrock_remove_button: ViewHandle<ActionButton>,
provider_cards: Vec<OpenAIProviderCardState>,
acp_provider_cards: Vec<AcpProviderCardState>,
@@ -6749,6 +6757,11 @@ impl ProviderSettingsWidget {
ctx.dispatch_typed_action(AISettingsPageAction::EditBedrockProvider);
})
});
let bedrock_refresh_button = ctx.add_typed_action_view(|_| {
ActionButton::new("Refresh models", SecondaryTheme).on_click(|ctx| {
ctx.dispatch_typed_action(AISettingsPageAction::RefreshBedrockModels);
})
});
let bedrock_remove_button = ctx.add_typed_action_view(|_| {
ActionButton::new("Delete", DangerSecondaryTheme).on_click(|ctx| {
ctx.dispatch_typed_action(AISettingsPageAction::RemoveBedrockProvider);
@@ -6766,6 +6779,7 @@ impl ProviderSettingsWidget {
bedrock_add_button,
acp_add_button,
bedrock_edit_button,
bedrock_refresh_button,
bedrock_remove_button,
provider_cards,
acp_provider_cards,
@@ -7275,6 +7289,7 @@ impl ProviderSettingsWidget {
.with_child(
Flex::row()
.with_spacing(8.)
.with_child(ChildView::new(&self.bedrock_refresh_button).finish())
.with_child(ChildView::new(&self.bedrock_edit_button).finish())
.with_child(ChildView::new(&self.bedrock_remove_button).finish())
.finish(),
+2 -3
View File
@@ -687,10 +687,8 @@ impl ProviderSetupView {
self.draft_bedrock = draft;
self.draft_models.clear();
self.discovery_state = DiscoveryState::Idle;
self.bedrock_region_request += 1;
self.sync_editors(ctx);
if self.draft_bedrock.region.is_empty() {
self.load_bedrock_profile_region(ctx);
}
self.sync_provider_type_buttons(ctx);
self.sync_bedrock_auth_buttons(ctx);
self.sync_model_switches(ctx);
@@ -1146,6 +1144,7 @@ impl ProviderSetupView {
fn begin_discovery(&mut self, ctx: &mut ViewContext<Self>) {
self.cancel_acp_setup();
self.bedrock_region_request += 1;
self.step = ProviderSetupStep::Discover;
self.discovery_state = DiscoveryState::Loading;
self.acp_setup_status.clear();