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