Skip to content
Merged
Show file tree
Hide file tree
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
48 changes: 34 additions & 14 deletions termua/src/footbar/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use crate::{
globals::{ensure_ctx_global, ensure_ctx_global_with},
lock_screen, notification,
right_sidebar::{RightSidebarState, RightSidebarTab},
settings::AssistantSettings,
};

mod transfers;
Expand Down Expand Up @@ -93,6 +94,7 @@ impl FootbarView {
lock_enabled: bool,
lock_tooltip: SharedString,
messages_selected: bool,
assistant_enabled: bool,
assistant_selected: bool,
) -> gpui::AnyElement {
h_flex()
Expand Down Expand Up @@ -152,19 +154,24 @@ impl FootbarView {
crate::menu::toggle_messages_sidebar(&crate::ToggleMessagesSidebar, cx)
}),
)
.child(
Button::new("termua-footbar-assistant-button")
.xsmall()
.compact()
.ghost()
.icon(Icon::default().path(TermuaIcon::Bot))
.tooltip(t!("Footbar.Tooltip.Assistant").to_string())
.selected(assistant_selected)
.debug_selector(|| "termua-footbar-assistant".to_string())
.on_click(|_, _, cx| {
crate::menu::toggle_assistant_sidebar(&crate::ToggleAssistantSidebar, cx)
}),
)
.when(assistant_enabled, |this| {
this.child(
Button::new("termua-footbar-assistant-button")
.xsmall()
.compact()
.ghost()
.icon(Icon::default().path(TermuaIcon::Bot))
.tooltip(t!("Footbar.Tooltip.Assistant").to_string())
.selected(assistant_selected)
.debug_selector(|| "termua-footbar-assistant".to_string())
.on_click(|_, _, cx| {
crate::menu::toggle_assistant_sidebar(
&crate::ToggleAssistantSidebar,
cx,
)
}),
)
})
.into_any_element()
}
}
Expand All @@ -189,7 +196,19 @@ impl Render for FootbarView {
let sessions_visible = cx.global::<TermuaAppState>().sessions_sidebar_visible;
let right = cx.global::<RightSidebarState>();
let messages_selected = right.visible && right.active_tab == RightSidebarTab::Notifications;
let assistant_selected = right.visible && right.active_tab == RightSidebarTab::Assistant;
let assistant_enabled = cx
.try_global::<AssistantSettings>()
.map(|s| s.enabled)
.unwrap_or(true);
let assistant_selected =
assistant_enabled && right.visible && right.active_tab == RightSidebarTab::Assistant;

// When assistant is disabled while the AI panel is open, close the panel.
if !assistant_enabled && right.visible && right.active_tab == RightSidebarTab::Assistant {
cx.defer(|cx| {
crate::menu::toggle_assistant_sidebar(&crate::ToggleAssistantSidebar, cx);
});
}

let icon_path = Self::multi_exec_icon_path(enabled);
let lock_state = cx.global::<lock_screen::LockState>();
Expand Down Expand Up @@ -217,6 +236,7 @@ impl Render for FootbarView {
lock_enabled,
lock_tooltip,
messages_selected,
assistant_enabled,
assistant_selected,
);

Expand Down
13 changes: 13 additions & 0 deletions termua/src/menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,22 @@ pub(crate) fn toggle_messages_sidebar(_: &ToggleMessagesSidebar, cx: &mut App) {
}

pub(crate) fn toggle_assistant_sidebar(_: &ToggleAssistantSidebar, cx: &mut App) {
let assistant_enabled = cx
.try_global::<crate::settings::AssistantSettings>()
.map(|s| s.enabled)
.unwrap_or(true);

if cx.try_global::<RightSidebarState>().is_none() {
cx.set_global(RightSidebarState::default());
}

// Block opening the assistant panel when the feature is disabled,
// but allow closing it if it was already open (e.g. after a settings change).
let state = cx.global::<RightSidebarState>();
if !assistant_enabled && !(state.visible && state.active_tab == RightSidebarTab::Assistant) {
return;
}

cx.global_mut::<RightSidebarState>()
.toggle_tab(RightSidebarTab::Assistant);
cx.refresh_windows();
Expand Down
1 change: 1 addition & 0 deletions termua/src/window/settings/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1266,6 +1266,7 @@ impl SettingsWindow {
this.settings.assistant.enabled = checked;
this.settings.apply_assistant_settings(cx);
this.save_only(window, cx);
cx.refresh_windows();

if checked {
// If enabled and zeroclaw isn't running, pull it up.
Expand Down
Loading