agent: Simplify user message design more (#29326)
Follow-up to https://github.com/zed-industries/zed/pull/29165 where the user message design is simplified even more. The edit button is not visible anymore, and you can click on the whole message block to edit a message. Release Notes: - N/A
This commit is contained in:
parent
ea5ce2a1a4
commit
e70d8d4dfd
1 changed files with 58 additions and 83 deletions
|
@ -1518,8 +1518,6 @@ impl ActiveThread {
|
||||||
return Empty.into_any();
|
return Empty.into_any();
|
||||||
}
|
}
|
||||||
|
|
||||||
let allow_editing_message = message.role == Role::User;
|
|
||||||
|
|
||||||
let edit_message_editor = self
|
let edit_message_editor = self
|
||||||
.editing_message
|
.editing_message
|
||||||
.as_ref()
|
.as_ref()
|
||||||
|
@ -1752,93 +1750,70 @@ impl ActiveThread {
|
||||||
.pb_4()
|
.pb_4()
|
||||||
.child(
|
.child(
|
||||||
v_flex()
|
v_flex()
|
||||||
|
.id(("user-message", ix))
|
||||||
.bg(editor_bg_color)
|
.bg(editor_bg_color)
|
||||||
.rounded_lg()
|
.rounded_lg()
|
||||||
|
.shadow_md()
|
||||||
.border_1()
|
.border_1()
|
||||||
.border_color(colors.border)
|
.border_color(colors.border)
|
||||||
.shadow_md()
|
.hover(|hover| hover.border_color(colors.text_accent.opacity(0.5)))
|
||||||
.child(div().p_2().children(message_content))
|
.cursor_pointer()
|
||||||
.child(
|
.child(div().p_2().pt_2p5().children(message_content))
|
||||||
h_flex()
|
.when_some(edit_message_editor.clone(), |this, edit_editor| {
|
||||||
.p_1()
|
let focus_handle = edit_editor.focus_handle(cx);
|
||||||
.border_t_1()
|
|
||||||
.border_color(colors.border_variant)
|
this.child(
|
||||||
.justify_end()
|
h_flex()
|
||||||
.child(
|
.p_1()
|
||||||
h_flex()
|
.border_t_1()
|
||||||
.gap_1()
|
.border_color(colors.border_variant)
|
||||||
.when_some(
|
.gap_1()
|
||||||
edit_message_editor.clone(),
|
.justify_end()
|
||||||
|this, edit_message_editor| {
|
.child(
|
||||||
let focus_handle =
|
Button::new("cancel-edit-message", "Cancel")
|
||||||
edit_message_editor.focus_handle(cx);
|
.label_size(LabelSize::Small)
|
||||||
this.child(
|
.key_binding(
|
||||||
Button::new("cancel-edit-message", "Cancel")
|
KeyBinding::for_action_in(
|
||||||
.label_size(LabelSize::Small)
|
&menu::Cancel,
|
||||||
.key_binding(
|
&focus_handle,
|
||||||
KeyBinding::for_action_in(
|
window,
|
||||||
&menu::Cancel,
|
cx,
|
||||||
&focus_handle,
|
|
||||||
window,
|
|
||||||
cx,
|
|
||||||
)
|
|
||||||
.map(|kb| kb.size(rems_from_px(12.))),
|
|
||||||
)
|
|
||||||
.on_click(
|
|
||||||
cx.listener(Self::handle_cancel_click),
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
.child(
|
.map(|kb| kb.size(rems_from_px(12.))),
|
||||||
Button::new(
|
)
|
||||||
"confirm-edit-message",
|
.on_click(cx.listener(Self::handle_cancel_click)),
|
||||||
"Regenerate",
|
)
|
||||||
)
|
.child(
|
||||||
.disabled(
|
Button::new("confirm-edit-message", "Regenerate")
|
||||||
edit_message_editor.read(cx).is_empty(cx),
|
.disabled(edit_editor.read(cx).is_empty(cx))
|
||||||
)
|
.label_size(LabelSize::Small)
|
||||||
.label_size(LabelSize::Small)
|
.key_binding(
|
||||||
.key_binding(
|
KeyBinding::for_action_in(
|
||||||
KeyBinding::for_action_in(
|
&menu::Confirm,
|
||||||
&menu::Confirm,
|
&focus_handle,
|
||||||
&focus_handle,
|
window,
|
||||||
window,
|
cx,
|
||||||
cx,
|
|
||||||
)
|
|
||||||
.map(|kb| kb.size(rems_from_px(12.))),
|
|
||||||
)
|
|
||||||
.on_click(
|
|
||||||
cx.listener(Self::handle_regenerate_click),
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
},
|
.map(|kb| kb.size(rems_from_px(12.))),
|
||||||
)
|
)
|
||||||
.when(
|
.on_click(cx.listener(Self::handle_regenerate_click)),
|
||||||
edit_message_editor.is_none() && allow_editing_message,
|
),
|
||||||
|this| {
|
)
|
||||||
this.child(
|
})
|
||||||
Button::new("edit-message", "Edit Message")
|
.when(edit_message_editor.is_none(), |this| {
|
||||||
.label_size(LabelSize::Small)
|
this.tooltip(Tooltip::text("Click To Edit"))
|
||||||
.icon(IconName::Pencil)
|
})
|
||||||
.icon_size(IconSize::XSmall)
|
.on_click(cx.listener({
|
||||||
.icon_color(Color::Muted)
|
let message_segments = message.segments.clone();
|
||||||
.icon_position(IconPosition::Start)
|
move |this, _, window, cx| {
|
||||||
.on_click(cx.listener({
|
this.start_editing_message(
|
||||||
let message_segments =
|
message_id,
|
||||||
message.segments.clone();
|
&message_segments,
|
||||||
move |this, _, window, cx| {
|
window,
|
||||||
this.start_editing_message(
|
cx,
|
||||||
message_id,
|
);
|
||||||
&message_segments,
|
}
|
||||||
window,
|
})),
|
||||||
cx,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
})),
|
|
||||||
)
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
Role::Assistant => v_flex()
|
Role::Assistant => v_flex()
|
||||||
.id(("message-container", ix))
|
.id(("message-container", ix))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue