Add Bedrock model refresh and fix auto-region discovery race
Co-Authored-By: Warp <agent@warp.dev>
This commit is contained in:
@@ -43,7 +43,7 @@ use strum::IntoEnumIterator;
|
|||||||
use super::execution_profile_view::{ExecutionProfileView, ExecutionProfileViewEvent};
|
use super::execution_profile_view::{ExecutionProfileView, ExecutionProfileViewEvent};
|
||||||
use super::provider_setup_view::{
|
use super::provider_setup_view::{
|
||||||
model_catalog_table, AcpProviderDraft, BedrockProviderDraft, ProviderSetupProviderType,
|
model_catalog_table, AcpProviderDraft, BedrockProviderDraft, ProviderSetupProviderType,
|
||||||
ProviderSetupView, ProviderSetupViewEvent,
|
ProviderSetupView, ProviderSetupViewAction, ProviderSetupViewEvent,
|
||||||
};
|
};
|
||||||
use super::settings_page::{
|
use super::settings_page::{
|
||||||
build_sub_header, build_toggle_element, render_body_item_label,
|
build_sub_header, build_toggle_element, render_body_item_label,
|
||||||
@@ -2720,6 +2720,7 @@ pub enum AISettingsPageAction {
|
|||||||
},
|
},
|
||||||
RemoveOpenAIProvider(usize),
|
RemoveOpenAIProvider(usize),
|
||||||
EditBedrockProvider,
|
EditBedrockProvider,
|
||||||
|
RefreshBedrockModels,
|
||||||
RemoveBedrockProvider,
|
RemoveBedrockProvider,
|
||||||
RemoveAcpProvider(String),
|
RemoveAcpProvider(String),
|
||||||
ToggleFileBasedMcp,
|
ToggleFileBasedMcp,
|
||||||
@@ -3457,6 +3458,12 @@ impl TypedActionView for AISettingsPageView {
|
|||||||
AISettingsPageAction::EditBedrockProvider => {
|
AISettingsPageAction::EditBedrockProvider => {
|
||||||
self.begin_inline_bedrock_setup(ctx);
|
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 => {
|
AISettingsPageAction::RemoveBedrockProvider => {
|
||||||
AISettings::handle(ctx).update(ctx, |settings, ctx| {
|
AISettings::handle(ctx).update(ctx, |settings, ctx| {
|
||||||
report_if_error!(settings.bedrock_enabled.set_value(false, ctx));
|
report_if_error!(settings.bedrock_enabled.set_value(false, ctx));
|
||||||
@@ -6641,6 +6648,7 @@ struct ProviderSettingsWidget {
|
|||||||
bedrock_add_button: ViewHandle<ActionButton>,
|
bedrock_add_button: ViewHandle<ActionButton>,
|
||||||
acp_add_button: ViewHandle<ActionButton>,
|
acp_add_button: ViewHandle<ActionButton>,
|
||||||
bedrock_edit_button: ViewHandle<ActionButton>,
|
bedrock_edit_button: ViewHandle<ActionButton>,
|
||||||
|
bedrock_refresh_button: ViewHandle<ActionButton>,
|
||||||
bedrock_remove_button: ViewHandle<ActionButton>,
|
bedrock_remove_button: ViewHandle<ActionButton>,
|
||||||
provider_cards: Vec<OpenAIProviderCardState>,
|
provider_cards: Vec<OpenAIProviderCardState>,
|
||||||
acp_provider_cards: Vec<AcpProviderCardState>,
|
acp_provider_cards: Vec<AcpProviderCardState>,
|
||||||
@@ -6749,6 +6757,11 @@ impl ProviderSettingsWidget {
|
|||||||
ctx.dispatch_typed_action(AISettingsPageAction::EditBedrockProvider);
|
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(|_| {
|
let bedrock_remove_button = ctx.add_typed_action_view(|_| {
|
||||||
ActionButton::new("Delete", DangerSecondaryTheme).on_click(|ctx| {
|
ActionButton::new("Delete", DangerSecondaryTheme).on_click(|ctx| {
|
||||||
ctx.dispatch_typed_action(AISettingsPageAction::RemoveBedrockProvider);
|
ctx.dispatch_typed_action(AISettingsPageAction::RemoveBedrockProvider);
|
||||||
@@ -6766,6 +6779,7 @@ impl ProviderSettingsWidget {
|
|||||||
bedrock_add_button,
|
bedrock_add_button,
|
||||||
acp_add_button,
|
acp_add_button,
|
||||||
bedrock_edit_button,
|
bedrock_edit_button,
|
||||||
|
bedrock_refresh_button,
|
||||||
bedrock_remove_button,
|
bedrock_remove_button,
|
||||||
provider_cards,
|
provider_cards,
|
||||||
acp_provider_cards,
|
acp_provider_cards,
|
||||||
@@ -7275,6 +7289,7 @@ impl ProviderSettingsWidget {
|
|||||||
.with_child(
|
.with_child(
|
||||||
Flex::row()
|
Flex::row()
|
||||||
.with_spacing(8.)
|
.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_edit_button).finish())
|
||||||
.with_child(ChildView::new(&self.bedrock_remove_button).finish())
|
.with_child(ChildView::new(&self.bedrock_remove_button).finish())
|
||||||
.finish(),
|
.finish(),
|
||||||
|
|||||||
@@ -687,10 +687,8 @@ impl ProviderSetupView {
|
|||||||
self.draft_bedrock = draft;
|
self.draft_bedrock = draft;
|
||||||
self.draft_models.clear();
|
self.draft_models.clear();
|
||||||
self.discovery_state = DiscoveryState::Idle;
|
self.discovery_state = DiscoveryState::Idle;
|
||||||
|
self.bedrock_region_request += 1;
|
||||||
self.sync_editors(ctx);
|
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_provider_type_buttons(ctx);
|
||||||
self.sync_bedrock_auth_buttons(ctx);
|
self.sync_bedrock_auth_buttons(ctx);
|
||||||
self.sync_model_switches(ctx);
|
self.sync_model_switches(ctx);
|
||||||
@@ -1146,6 +1144,7 @@ impl ProviderSetupView {
|
|||||||
|
|
||||||
fn begin_discovery(&mut self, ctx: &mut ViewContext<Self>) {
|
fn begin_discovery(&mut self, ctx: &mut ViewContext<Self>) {
|
||||||
self.cancel_acp_setup();
|
self.cancel_acp_setup();
|
||||||
|
self.bedrock_region_request += 1;
|
||||||
self.step = ProviderSetupStep::Discover;
|
self.step = ProviderSetupStep::Discover;
|
||||||
self.discovery_state = DiscoveryState::Loading;
|
self.discovery_state = DiscoveryState::Loading;
|
||||||
self.acp_setup_status.clear();
|
self.acp_setup_status.clear();
|
||||||
|
|||||||
Reference in New Issue
Block a user