assistant2: Ensure errors are also displayed in populated new thread view (#27869)
Follow-up to https://github.com/zed-industries/zed/pull/27812 This PR makes sure these errors cases also show up in the panel's empty state even when there is past data. | No ToS | Missing Provider | |--------|--------| |  |  | Release Notes: - N/A
This commit is contained in:
parent
92059803fb
commit
192097f58f
4 changed files with 243 additions and 143 deletions
|
@ -401,56 +401,83 @@ fn render_accept_terms(
|
|||
|
||||
let accept_terms_disabled = state.read(cx).accept_terms.is_some();
|
||||
|
||||
let thread_fresh_start = matches!(view_kind, LanguageModelProviderTosView::ThreadFreshStart);
|
||||
let thread_empty_state = matches!(view_kind, LanguageModelProviderTosView::ThreadtEmptyState);
|
||||
|
||||
let terms_button = Button::new("terms_of_service", "Terms of Service")
|
||||
.style(ButtonStyle::Subtle)
|
||||
.icon(IconName::ArrowUpRight)
|
||||
.icon_color(Color::Muted)
|
||||
.icon_size(IconSize::XSmall)
|
||||
.when(thread_empty_state, |this| this.label_size(LabelSize::Small))
|
||||
.on_click(move |_, _window, cx| cx.open_url("https://zed.dev/terms-of-service"));
|
||||
|
||||
let thread_view = match view_kind {
|
||||
LanguageModelProviderTosView::ThreadEmptyState => true,
|
||||
LanguageModelProviderTosView::PromptEditorPopup => false,
|
||||
LanguageModelProviderTosView::Configuration => false,
|
||||
};
|
||||
|
||||
let form = v_flex()
|
||||
.w_full()
|
||||
.gap_2()
|
||||
.child(
|
||||
h_flex()
|
||||
.flex_wrap()
|
||||
.when(thread_view, |this| this.justify_center())
|
||||
.child(Label::new(
|
||||
"To start using Zed AI, please read and accept the",
|
||||
))
|
||||
.child(terms_button),
|
||||
)
|
||||
.child({
|
||||
let button_container = h_flex().w_full().child(
|
||||
Button::new("accept_terms", "I accept the Terms of Service")
|
||||
let button_container = h_flex().child(
|
||||
Button::new("accept_terms", "I accept the Terms of Service")
|
||||
.when(!thread_empty_state, |this| {
|
||||
this.full_width()
|
||||
.style(ButtonStyle::Tinted(TintColor::Accent))
|
||||
.icon(IconName::Check)
|
||||
.icon_position(IconPosition::Start)
|
||||
.icon_size(IconSize::Small)
|
||||
.full_width()
|
||||
.disabled(accept_terms_disabled)
|
||||
.on_click({
|
||||
let state = state.downgrade();
|
||||
move |_, _window, cx| {
|
||||
state
|
||||
.update(cx, |state, cx| state.accept_terms_of_service(cx))
|
||||
.ok();
|
||||
}
|
||||
}),
|
||||
);
|
||||
})
|
||||
.when(thread_empty_state, |this| {
|
||||
this.style(ButtonStyle::Tinted(TintColor::Warning))
|
||||
.label_size(LabelSize::Small)
|
||||
})
|
||||
.disabled(accept_terms_disabled)
|
||||
.on_click({
|
||||
let state = state.downgrade();
|
||||
move |_, _window, cx| {
|
||||
state
|
||||
.update(cx, |state, cx| state.accept_terms_of_service(cx))
|
||||
.ok();
|
||||
}
|
||||
}),
|
||||
);
|
||||
|
||||
match view_kind {
|
||||
LanguageModelProviderTosView::PromptEditorPopup => button_container.justify_end(),
|
||||
LanguageModelProviderTosView::Configuration => button_container.justify_start(),
|
||||
LanguageModelProviderTosView::ThreadEmptyState => button_container.justify_center(),
|
||||
}
|
||||
});
|
||||
let form = if thread_empty_state {
|
||||
h_flex()
|
||||
.w_full()
|
||||
.flex_wrap()
|
||||
.justify_between()
|
||||
.child(
|
||||
h_flex()
|
||||
.child(
|
||||
Label::new("To start using Zed AI, please read and accept the")
|
||||
.size(LabelSize::Small),
|
||||
)
|
||||
.child(terms_button),
|
||||
)
|
||||
.child(button_container)
|
||||
} else {
|
||||
v_flex()
|
||||
.w_full()
|
||||
.gap_2()
|
||||
.child(
|
||||
h_flex()
|
||||
.flex_wrap()
|
||||
.when(thread_fresh_start, |this| this.justify_center())
|
||||
.child(Label::new(
|
||||
"To start using Zed AI, please read and accept the",
|
||||
))
|
||||
.child(terms_button),
|
||||
)
|
||||
.child({
|
||||
match view_kind {
|
||||
LanguageModelProviderTosView::PromptEditorPopup => {
|
||||
button_container.w_full().justify_end()
|
||||
}
|
||||
LanguageModelProviderTosView::Configuration => {
|
||||
button_container.w_full().justify_start()
|
||||
}
|
||||
LanguageModelProviderTosView::ThreadFreshStart => {
|
||||
button_container.w_full().justify_center()
|
||||
}
|
||||
LanguageModelProviderTosView::ThreadtEmptyState => div().w_0(),
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
Some(form.into_any())
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue