agent: Fix panel "go back" button (#31706)
Closes https://github.com/zed-industries/zed/issues/31652. Release Notes: - agent: Fixed a bug where the "go back" button wouldn't go back to the Text Thread after visiting another view from it.
This commit is contained in:
parent
ccb049bd97
commit
05692e298a
1 changed files with 26 additions and 6 deletions
|
@ -1084,9 +1084,23 @@ impl AgentPanel {
|
||||||
pub fn go_back(&mut self, _: &workspace::GoBack, window: &mut Window, cx: &mut Context<Self>) {
|
pub fn go_back(&mut self, _: &workspace::GoBack, window: &mut Window, cx: &mut Context<Self>) {
|
||||||
match self.active_view {
|
match self.active_view {
|
||||||
ActiveView::Configuration | ActiveView::History => {
|
ActiveView::Configuration | ActiveView::History => {
|
||||||
self.active_view =
|
if let Some(previous_view) = self.previous_view.take() {
|
||||||
ActiveView::thread(self.thread.read(cx).thread().clone(), window, cx);
|
self.active_view = previous_view;
|
||||||
self.message_editor.focus_handle(cx).focus(window);
|
|
||||||
|
match &self.active_view {
|
||||||
|
ActiveView::Thread { .. } => {
|
||||||
|
self.message_editor.focus_handle(cx).focus(window);
|
||||||
|
}
|
||||||
|
ActiveView::TextThread { context_editor, .. } => {
|
||||||
|
context_editor.focus_handle(cx).focus(window);
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
self.active_view =
|
||||||
|
ActiveView::thread(self.thread.read(cx).thread().clone(), window, cx);
|
||||||
|
self.message_editor.focus_handle(cx).focus(window);
|
||||||
|
}
|
||||||
cx.notify();
|
cx.notify();
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
|
@ -1347,6 +1361,12 @@ impl AgentPanel {
|
||||||
let current_is_history = matches!(self.active_view, ActiveView::History);
|
let current_is_history = matches!(self.active_view, ActiveView::History);
|
||||||
let new_is_history = matches!(new_view, ActiveView::History);
|
let new_is_history = matches!(new_view, ActiveView::History);
|
||||||
|
|
||||||
|
let current_is_config = matches!(self.active_view, ActiveView::Configuration);
|
||||||
|
let new_is_config = matches!(new_view, ActiveView::Configuration);
|
||||||
|
|
||||||
|
let current_is_special = current_is_history || current_is_config;
|
||||||
|
let new_is_special = new_is_history || new_is_config;
|
||||||
|
|
||||||
match &self.active_view {
|
match &self.active_view {
|
||||||
ActiveView::Thread { thread, .. } => {
|
ActiveView::Thread { thread, .. } => {
|
||||||
if let Some(thread) = thread.upgrade() {
|
if let Some(thread) = thread.upgrade() {
|
||||||
|
@ -1387,12 +1407,12 @@ impl AgentPanel {
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
if current_is_history && !new_is_history {
|
if current_is_special && !new_is_special {
|
||||||
self.active_view = new_view;
|
self.active_view = new_view;
|
||||||
} else if !current_is_history && new_is_history {
|
} else if !current_is_special && new_is_special {
|
||||||
self.previous_view = Some(std::mem::replace(&mut self.active_view, new_view));
|
self.previous_view = Some(std::mem::replace(&mut self.active_view, new_view));
|
||||||
} else {
|
} else {
|
||||||
if !new_is_history {
|
if !new_is_special {
|
||||||
self.previous_view = None;
|
self.previous_view = None;
|
||||||
}
|
}
|
||||||
self.active_view = new_view;
|
self.active_view = new_view;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue