assistant.rs

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