This PR sketches in the toolbar for `assistant2`. <img width="1136" alt="Screenshot 2024-11-23 at 12 39 49 PM" src="https://github.com/user-attachments/assets/ed56fc36-54c8-48d4-8446-6c1f182fcef2"> Release Notes: - N/A
41 lines
1.2 KiB
Rust
41 lines
1.2 KiB
Rust
mod assistant_panel;
|
|
|
|
use command_palette_hooks::CommandPaletteFilter;
|
|
use feature_flags::{Assistant2FeatureFlag, FeatureFlagAppExt};
|
|
use gpui::{actions, AppContext};
|
|
|
|
pub use crate::assistant_panel::AssistantPanel;
|
|
|
|
actions!(assistant2, [ToggleFocus, NewChat, ToggleModelSelector]);
|
|
|
|
const NAMESPACE: &str = "assistant2";
|
|
|
|
/// Initializes the `assistant2` crate.
|
|
pub fn init(cx: &mut AppContext) {
|
|
assistant_panel::init(cx);
|
|
feature_gate_assistant2_actions(cx);
|
|
}
|
|
|
|
fn feature_gate_assistant2_actions(cx: &mut AppContext) {
|
|
const ASSISTANT1_NAMESPACE: &str = "assistant";
|
|
|
|
CommandPaletteFilter::update_global(cx, |filter, _cx| {
|
|
filter.hide_namespace(NAMESPACE);
|
|
});
|
|
|
|
cx.observe_flag::<Assistant2FeatureFlag, _>(move |is_enabled, cx| {
|
|
if is_enabled {
|
|
CommandPaletteFilter::update_global(cx, |filter, _cx| {
|
|
filter.show_namespace(NAMESPACE);
|
|
filter.hide_namespace(ASSISTANT1_NAMESPACE);
|
|
});
|
|
} else {
|
|
CommandPaletteFilter::update_global(cx, |filter, _cx| {
|
|
filter.hide_namespace(NAMESPACE);
|
|
filter.show_namespace(ASSISTANT1_NAMESPACE);
|
|
});
|
|
}
|
|
})
|
|
.detach();
|
|
}
|