mirror of
https://github.com/zed-industries/zed.git
synced 2026-06-01 03:14:56 +07:00
agent_ui: Show title edit for terminals in agent panel (#57005)
Self-Review Checklist: - [x] I've reviewed my own diff for quality, security, and reliability - [x] Unsafe blocks (if any) have justifying comments - [x] The content is consistent with the [UI/UX checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) - [x] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable Release Notes: - N/A
This commit is contained in:
parent
f7ca86e6ee
commit
ce38fd67a8
1 changed files with 59 additions and 20 deletions
|
|
@ -3953,6 +3953,14 @@ impl AgentPanel {
|
|||
}
|
||||
}
|
||||
|
||||
fn should_show_title_edit(&self, window: &Window, cx: &Context<Self>) -> bool {
|
||||
matches!(
|
||||
self.visible_surface(),
|
||||
VisibleSurface::AgentThread(_) | VisibleSurface::Terminal(_)
|
||||
) && self.has_open_project(cx)
|
||||
&& !self.is_title_editor_focused(window, cx)
|
||||
}
|
||||
|
||||
fn render_title_view(&self, window: &mut Window, cx: &Context<Self>) -> AnyElement {
|
||||
let content = match self.visible_surface() {
|
||||
VisibleSurface::AgentThread(conversation_view) => {
|
||||
|
|
@ -4096,11 +4104,7 @@ impl AgentPanel {
|
|||
.max_w_full()
|
||||
.overflow_x_hidden()
|
||||
.child(content)
|
||||
.when(
|
||||
matches!(self.visible_surface(), VisibleSurface::AgentThread(_))
|
||||
&& self.has_open_project(cx)
|
||||
&& !self.is_title_editor_focused(window, cx),
|
||||
|this| {
|
||||
.when(self.should_show_title_edit(window, cx), |this| {
|
||||
this.child(gradient_overlay).child(
|
||||
h_flex()
|
||||
.visible_on_hover("title_editor")
|
||||
|
|
@ -4114,8 +4118,7 @@ impl AgentPanel {
|
|||
.tooltip(Tooltip::text("Edit Thread Title")),
|
||||
),
|
||||
)
|
||||
},
|
||||
)
|
||||
})
|
||||
.into_any()
|
||||
}
|
||||
|
||||
|
|
@ -6824,6 +6827,42 @@ mod tests {
|
|||
});
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_title_edit_affordance_matches_threads_and_terminals(cx: &mut TestAppContext) {
|
||||
let (panel, mut cx) = setup_panel(cx).await;
|
||||
|
||||
panel.update_in(&mut cx, |panel, window, cx| {
|
||||
panel.activate_draft(false, AgentThreadSource::AgentPanel, window, cx);
|
||||
});
|
||||
cx.run_until_parked();
|
||||
|
||||
panel.update_in(&mut cx, |panel, window, cx| {
|
||||
assert!(matches!(
|
||||
panel.visible_surface(),
|
||||
VisibleSurface::AgentThread(_)
|
||||
));
|
||||
assert!(panel.should_show_title_edit(window, cx));
|
||||
});
|
||||
|
||||
let terminal_id = panel
|
||||
.update_in(&mut cx, |panel, window, cx| {
|
||||
panel.insert_test_terminal("Dev Server", true, window, cx)
|
||||
})
|
||||
.expect("test terminal should be inserted");
|
||||
cx.run_until_parked();
|
||||
|
||||
panel.update_in(&mut cx, |panel, window, cx| {
|
||||
assert!(matches!(
|
||||
panel.visible_surface(),
|
||||
VisibleSurface::Terminal(_)
|
||||
));
|
||||
assert!(panel.should_show_title_edit(window, cx));
|
||||
|
||||
panel.edit_terminal_title(terminal_id, window, cx);
|
||||
assert!(!panel.should_show_title_edit(window, cx));
|
||||
});
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_terminal_working_directory_uses_active_workspace_while_workspace_is_updating(
|
||||
cx: &mut TestAppContext,
|
||||
|
|
|
|||
Loading…
Reference in a new issue