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