Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion crates/ui/src/chat/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,8 @@ pub struct ChatView {
composer: Entity<Composer>,
#[cfg(feature = "terminal")]
terminal_drawer: Entity<TerminalDrawer>,
#[cfg(feature = "terminal")]
terminal_was_open: bool,
list_state: ListState,
turn_items: Vec<TurnListItem>,
turn_index_cache: TurnIndexCache,
Expand Down Expand Up @@ -399,20 +401,40 @@ impl ChatView {
this.list_state.scroll_to_end();
cx.notify();
}),
cx.observe(&workspace_store, |this, _, cx| {
cx.observe_in(&workspace_store, window, |this, store, window, cx| {
#[cfg(not(feature = "terminal"))]
let _ = (&store, &window);
this.sync_markdown_states(cx);
// Opening the terminal (button, palette, or any other route
// through the store) should hand keyboard focus to it, so the
// user can type a command without clicking into the panel.
#[cfg(feature = "terminal")]
{
let open = store.read(cx).panel_state().terminal_open;
if open && !this.terminal_was_open {
let drawer = this.terminal_drawer.clone();
window.defer(cx, move |window, cx| {
gpui::Focusable::focus_handle(drawer.read(cx), cx).focus(window, cx);
});
}
this.terminal_was_open = open;
}
cx.notify();
}),
];
#[cfg(feature = "terminal")]
let terminal_drawer = cx.new(|cx| TerminalDrawer::new(workspace_store.clone(), window, cx));
#[cfg(feature = "terminal")]
let terminal_was_open = workspace_store.read(cx).panel_state().terminal_open;

let mut this = Self {
workspace_store,
window_state,
composer,
#[cfg(feature = "terminal")]
terminal_drawer,
#[cfg(feature = "terminal")]
terminal_was_open,
list_state,
turn_items: Vec::new(),
turn_index_cache: TurnIndexCache::default(),
Expand Down
Loading