1mod active_thread;
2mod assistant_panel;
3mod message_editor;
4mod thread;
5mod thread_store;
6
7use command_palette_hooks::CommandPaletteFilter;
8use feature_flags::{Assistant2FeatureFlag, FeatureFlagAppExt};
9use gpui::{actions, AppContext};
10
11pub use crate::assistant_panel::AssistantPanel;
12
13actions!(
14 assistant2,
15 [
16 ToggleFocus,
17 NewThread,
18 ToggleModelSelector,
19 OpenHistory,
20 Chat
21 ]
22);
23
24const NAMESPACE: &str = "assistant2";
25
26/// Initializes the `assistant2` crate.
27pub fn init(cx: &mut AppContext) {
28 assistant_panel::init(cx);
29 feature_gate_assistant2_actions(cx);
30}
31
32fn feature_gate_assistant2_actions(cx: &mut AppContext) {
33 const ASSISTANT1_NAMESPACE: &str = "assistant";
34
35 CommandPaletteFilter::update_global(cx, |filter, _cx| {
36 filter.hide_namespace(NAMESPACE);
37 });
38
39 cx.observe_flag::<Assistant2FeatureFlag, _>(move |is_enabled, cx| {
40 if is_enabled {
41 CommandPaletteFilter::update_global(cx, |filter, _cx| {
42 filter.show_namespace(NAMESPACE);
43 filter.hide_namespace(ASSISTANT1_NAMESPACE);
44 });
45 } else {
46 CommandPaletteFilter::update_global(cx, |filter, _cx| {
47 filter.hide_namespace(NAMESPACE);
48 filter.show_namespace(ASSISTANT1_NAMESPACE);
49 });
50 }
51 })
52 .detach();
53}