agent_ui: Show keybindings for NewThread and NewTextThread in new thread button (#34967)

I believe in this PR: #34829 we moved to context menu entry from action
but the side effect of that was we also removed the Keybindings from
showing it in the new thread button dropdown. This PR fixes that. cc
@danilo-leal

| Before | After |
|--------|--------|
| <img width="900" height="1962" alt="CleanShot 2025-07-23 at 23 36
28@2x"
src="https://github.com/user-attachments/assets/760cbe75-09b9-404b-9d33-1db73785234f"
/> | <img width="850" height="1964" alt="CleanShot 2025-07-23 at 23 37
17@2x"
src="https://github.com/user-attachments/assets/24a7e871-aebc-475c-845f-b76f02527b8f"
/> |

Release Notes:

- N/A
This commit is contained in:
Umesh Yadav 2025-07-23 23:58:05 +05:30 committed by GitHub
parent a48247a313
commit 9863c8a44e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1901,85 +1901,96 @@ impl AgentPanel {
) )
.anchor(Corner::TopRight) .anchor(Corner::TopRight)
.with_handle(self.new_thread_menu_handle.clone()) .with_handle(self.new_thread_menu_handle.clone())
.menu(move |window, cx| { .menu({
let active_thread = active_thread.clone(); let focus_handle = focus_handle.clone();
Some(ContextMenu::build(window, cx, |mut menu, _window, cx| { move |window, cx| {
menu = menu let active_thread = active_thread.clone();
.when(cx.has_flag::<feature_flags::AcpFeatureFlag>(), |this| { Some(ContextMenu::build(window, cx, |mut menu, _window, cx| {
this.header("Zed Agent") menu = menu
}) .context(focus_handle.clone())
.item( .when(cx.has_flag::<feature_flags::AcpFeatureFlag>(), |this| {
ContextMenuEntry::new("New Thread") this.header("Zed Agent")
.icon(IconName::NewThread) })
.icon_color(Color::Muted) .item(
.handler(move |window, cx| { ContextMenuEntry::new("New Thread")
window.dispatch_action(NewThread::default().boxed_clone(), cx); .icon(IconName::NewThread)
}), .icon_color(Color::Muted)
) .action(NewThread::default().boxed_clone())
.item( .handler(move |window, cx| {
ContextMenuEntry::new("New Text Thread") window.dispatch_action(
.icon(IconName::NewTextThread) NewThread::default().boxed_clone(),
.icon_color(Color::Muted) cx,
.handler(move |window, cx| { );
window.dispatch_action(NewTextThread.boxed_clone(), cx); }),
}), )
) .item(
.when_some(active_thread, |this, active_thread| { ContextMenuEntry::new("New Text Thread")
let thread = active_thread.read(cx); .icon(IconName::NewTextThread)
.icon_color(Color::Muted)
.action(NewTextThread.boxed_clone())
.handler(move |window, cx| {
window.dispatch_action(NewTextThread.boxed_clone(), cx);
}),
)
.when_some(active_thread, |this, active_thread| {
let thread = active_thread.read(cx);
if !thread.is_empty() { if !thread.is_empty() {
let thread_id = thread.id().clone(); let thread_id = thread.id().clone();
this.item( this.item(
ContextMenuEntry::new("New From Summary") ContextMenuEntry::new("New From Summary")
.icon(IconName::NewFromSummary) .icon(IconName::NewFromSummary)
.icon_color(Color::Muted) .icon_color(Color::Muted)
.handler(move |window, cx| { .handler(move |window, cx| {
window.dispatch_action( window.dispatch_action(
Box::new(NewThread { Box::new(NewThread {
from_thread_id: Some(thread_id.clone()), from_thread_id: Some(thread_id.clone()),
}), }),
cx, cx,
); );
}), }),
) )
} else { } else {
this this
} }
}) })
.when(cx.has_flag::<feature_flags::AcpFeatureFlag>(), |this| { .when(cx.has_flag::<feature_flags::AcpFeatureFlag>(), |this| {
this.separator() this.separator()
.header("External Agents") .header("External Agents")
.item( .item(
ContextMenuEntry::new("New Gemini Thread") ContextMenuEntry::new("New Gemini Thread")
.icon(IconName::AiGemini) .icon(IconName::AiGemini)
.icon_color(Color::Muted) .icon_color(Color::Muted)
.handler(move |window, cx| { .handler(move |window, cx| {
window.dispatch_action( window.dispatch_action(
NewExternalAgentThread { NewExternalAgentThread {
agent: Some(crate::ExternalAgent::Gemini), agent: Some(crate::ExternalAgent::Gemini),
} }
.boxed_clone(), .boxed_clone(),
cx, cx,
); );
}), }),
) )
.item( .item(
ContextMenuEntry::new("New Claude Code Thread") ContextMenuEntry::new("New Claude Code Thread")
.icon(IconName::AiClaude) .icon(IconName::AiClaude)
.icon_color(Color::Muted) .icon_color(Color::Muted)
.handler(move |window, cx| { .handler(move |window, cx| {
window.dispatch_action( window.dispatch_action(
NewExternalAgentThread { NewExternalAgentThread {
agent: Some(crate::ExternalAgent::ClaudeCode), agent: Some(
} crate::ExternalAgent::ClaudeCode,
.boxed_clone(), ),
cx, }
); .boxed_clone(),
}), cx,
) );
}); }),
menu )
})) });
menu
}))
}
}); });
let agent_panel_menu = PopoverMenu::new("agent-options-menu") let agent_panel_menu = PopoverMenu::new("agent-options-menu")