zeta: Show keybinding in completion rating buttons in review modal (#22985)
This PR also removes the `ThumbsUp` action that wasn't being triggered correctly. We didn't have it's counterpart `ThumbsDown`, too, so I mostly assumed it would be harmless to remove `ThumbsUp` as well. <img width="800" alt="Screenshot 2025-01-10 at 6 18 44 PM" src="https://github.com/user-attachments/assets/9fd5da9f-9dff-454d-9f31-c02f1370b937" /> Release Notes: - N/A --------- Co-authored-by: Marshall Bowers <elliott.codes@gmail.com>
This commit is contained in:
parent
dad1a3bd31
commit
1e0ded4feb
2 changed files with 17 additions and 41 deletions
|
@ -806,7 +806,8 @@
|
||||||
"context": "RateCompletionModal",
|
"context": "RateCompletionModal",
|
||||||
"use_key_equivalents": true,
|
"use_key_equivalents": true,
|
||||||
"bindings": {
|
"bindings": {
|
||||||
"cmd-enter": "zeta::ThumbsUp",
|
"cmd-shift-enter": "zeta::ThumbsUpActiveCompletion",
|
||||||
|
"cmd-shift-backspace": "zeta::ThumbsDownActiveCompletion",
|
||||||
"shift-down": "zeta::NextEdit",
|
"shift-down": "zeta::NextEdit",
|
||||||
"shift-up": "zeta::PreviousEdit",
|
"shift-up": "zeta::PreviousEdit",
|
||||||
"right": "zeta::PreviewCompletion"
|
"right": "zeta::PreviewCompletion"
|
||||||
|
|
|
@ -15,8 +15,6 @@ actions!(
|
||||||
zeta,
|
zeta,
|
||||||
[
|
[
|
||||||
RateCompletions,
|
RateCompletions,
|
||||||
ThumbsUp,
|
|
||||||
ThumbsDown,
|
|
||||||
ThumbsUpActiveCompletion,
|
ThumbsUpActiveCompletion,
|
||||||
ThumbsDownActiveCompletion,
|
ThumbsDownActiveCompletion,
|
||||||
NextEdit,
|
NextEdit,
|
||||||
|
@ -57,6 +55,7 @@ impl RateCompletionModal {
|
||||||
|
|
||||||
pub fn new(zeta: Model<Zeta>, cx: &mut ViewContext<Self>) -> Self {
|
pub fn new(zeta: Model<Zeta>, cx: &mut ViewContext<Self>) -> Self {
|
||||||
let subscription = cx.observe(&zeta, |_, _, cx| cx.notify());
|
let subscription = cx.observe(&zeta, |_, _, cx| cx.notify());
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
zeta,
|
zeta,
|
||||||
selected_index: 0,
|
selected_index: 0,
|
||||||
|
@ -133,27 +132,6 @@ impl RateCompletionModal {
|
||||||
cx.notify();
|
cx.notify();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn thumbs_up(&mut self, _: &ThumbsUp, cx: &mut ViewContext<Self>) {
|
|
||||||
self.zeta.update(cx, |zeta, cx| {
|
|
||||||
let completion = zeta
|
|
||||||
.recent_completions()
|
|
||||||
.skip(self.selected_index)
|
|
||||||
.next()
|
|
||||||
.cloned();
|
|
||||||
|
|
||||||
if let Some(completion) = completion {
|
|
||||||
zeta.rate_completion(
|
|
||||||
&completion,
|
|
||||||
InlineCompletionRating::Positive,
|
|
||||||
"".to_string(),
|
|
||||||
cx,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
self.select_next_edit(&Default::default(), cx);
|
|
||||||
cx.notify();
|
|
||||||
}
|
|
||||||
|
|
||||||
fn thumbs_up_active(&mut self, _: &ThumbsUpActiveCompletion, cx: &mut ViewContext<Self>) {
|
fn thumbs_up_active(&mut self, _: &ThumbsUpActiveCompletion, cx: &mut ViewContext<Self>) {
|
||||||
self.zeta.update(cx, |zeta, cx| {
|
self.zeta.update(cx, |zeta, cx| {
|
||||||
if let Some(active) = &self.active_completion {
|
if let Some(active) = &self.active_completion {
|
||||||
|
@ -289,6 +267,7 @@ impl RateCompletionModal {
|
||||||
fn render_active_completion(&mut self, cx: &mut ViewContext<Self>) -> Option<impl IntoElement> {
|
fn render_active_completion(&mut self, cx: &mut ViewContext<Self>) -> Option<impl IntoElement> {
|
||||||
let active_completion = self.active_completion.as_ref()?;
|
let active_completion = self.active_completion.as_ref()?;
|
||||||
let completion_id = active_completion.completion.id;
|
let completion_id = active_completion.completion.id;
|
||||||
|
let focus_handle = &self.focus_handle(cx);
|
||||||
|
|
||||||
let mut diff = active_completion
|
let mut diff = active_completion
|
||||||
.completion
|
.completion
|
||||||
|
@ -343,6 +322,8 @@ impl RateCompletionModal {
|
||||||
font_style: settings.buffer_font.style,
|
font_style: settings.buffer_font.style,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
let border_color = cx.theme().colors().border;
|
||||||
|
let bg_color = cx.theme().colors().editor_background;
|
||||||
|
|
||||||
let rated = self.zeta.read(cx).is_completion_rated(completion_id);
|
let rated = self.zeta.read(cx).is_completion_rated(completion_id);
|
||||||
let was_shown = self.zeta.read(cx).was_completion_shown(completion_id);
|
let was_shown = self.zeta.read(cx).was_completion_shown(completion_id);
|
||||||
|
@ -352,9 +333,6 @@ impl RateCompletionModal {
|
||||||
.text(cx)
|
.text(cx)
|
||||||
.is_empty();
|
.is_empty();
|
||||||
|
|
||||||
let border_color = cx.theme().colors().border;
|
|
||||||
let bg_color = cx.theme().colors().editor_background;
|
|
||||||
|
|
||||||
let label_container = || h_flex().pl_1().gap_1p5();
|
let label_container = || h_flex().pl_1().gap_1p5();
|
||||||
|
|
||||||
Some(
|
Some(
|
||||||
|
@ -453,12 +431,6 @@ impl RateCompletionModal {
|
||||||
.gap_1()
|
.gap_1()
|
||||||
.child(
|
.child(
|
||||||
Button::new("bad", "Bad Completion")
|
Button::new("bad", "Bad Completion")
|
||||||
.key_binding(KeyBinding::for_action_in(
|
|
||||||
&ThumbsDown,
|
|
||||||
&self.focus_handle(cx),
|
|
||||||
cx,
|
|
||||||
))
|
|
||||||
.style(ButtonStyle::Filled)
|
|
||||||
.icon(IconName::ThumbsDown)
|
.icon(IconName::ThumbsDown)
|
||||||
.icon_size(IconSize::Small)
|
.icon_size(IconSize::Small)
|
||||||
.icon_position(IconPosition::Start)
|
.icon_position(IconPosition::Start)
|
||||||
|
@ -468,6 +440,11 @@ impl RateCompletionModal {
|
||||||
Tooltip::text("Explain what's bad about it before reporting it", cx)
|
Tooltip::text("Explain what's bad about it before reporting it", cx)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
.key_binding(KeyBinding::for_action_in(
|
||||||
|
&ThumbsDownActiveCompletion,
|
||||||
|
focus_handle,
|
||||||
|
cx,
|
||||||
|
))
|
||||||
.on_click(cx.listener(move |this, _, cx| {
|
.on_click(cx.listener(move |this, _, cx| {
|
||||||
this.thumbs_down_active(
|
this.thumbs_down_active(
|
||||||
&ThumbsDownActiveCompletion,
|
&ThumbsDownActiveCompletion,
|
||||||
|
@ -477,16 +454,15 @@ impl RateCompletionModal {
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
Button::new("good", "Good Completion")
|
Button::new("good", "Good Completion")
|
||||||
.key_binding(KeyBinding::for_action_in(
|
|
||||||
&ThumbsUp,
|
|
||||||
&self.focus_handle(cx),
|
|
||||||
cx,
|
|
||||||
))
|
|
||||||
.style(ButtonStyle::Filled)
|
|
||||||
.icon(IconName::ThumbsUp)
|
.icon(IconName::ThumbsUp)
|
||||||
.icon_size(IconSize::Small)
|
.icon_size(IconSize::Small)
|
||||||
.icon_position(IconPosition::Start)
|
.icon_position(IconPosition::Start)
|
||||||
.disabled(rated)
|
.disabled(rated)
|
||||||
|
.key_binding(KeyBinding::for_action_in(
|
||||||
|
&ThumbsUpActiveCompletion,
|
||||||
|
focus_handle,
|
||||||
|
cx,
|
||||||
|
))
|
||||||
.on_click(cx.listener(move |this, _, cx| {
|
.on_click(cx.listener(move |this, _, cx| {
|
||||||
this.thumbs_up_active(&ThumbsUpActiveCompletion, cx);
|
this.thumbs_up_active(&ThumbsUpActiveCompletion, cx);
|
||||||
})),
|
})),
|
||||||
|
@ -512,7 +488,6 @@ impl Render for RateCompletionModal {
|
||||||
.on_action(cx.listener(Self::select_next_edit))
|
.on_action(cx.listener(Self::select_next_edit))
|
||||||
.on_action(cx.listener(Self::select_first))
|
.on_action(cx.listener(Self::select_first))
|
||||||
.on_action(cx.listener(Self::select_last))
|
.on_action(cx.listener(Self::select_last))
|
||||||
.on_action(cx.listener(Self::thumbs_up))
|
|
||||||
.on_action(cx.listener(Self::thumbs_up_active))
|
.on_action(cx.listener(Self::thumbs_up_active))
|
||||||
.on_action(cx.listener(Self::thumbs_down_active))
|
.on_action(cx.listener(Self::thumbs_down_active))
|
||||||
.on_action(cx.listener(Self::focus_completions))
|
.on_action(cx.listener(Self::focus_completions))
|
||||||
|
@ -528,7 +503,7 @@ impl Render for RateCompletionModal {
|
||||||
v_flex()
|
v_flex()
|
||||||
.border_r_1()
|
.border_r_1()
|
||||||
.border_color(border_color)
|
.border_color(border_color)
|
||||||
.w_96()
|
.w_72()
|
||||||
.h_full()
|
.h_full()
|
||||||
.flex_shrink_0()
|
.flex_shrink_0()
|
||||||
.overflow_hidden()
|
.overflow_hidden()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue