Add edit events for assistant panel and inline assist (#20418)

Release Notes:

- N/A
This commit is contained in:
Joseph T. Lyons 2024-11-08 10:37:10 -05:00 committed by GitHub
parent 01e12c0d3c
commit 7142d3777f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 47 additions and 21 deletions

View file

@ -1084,7 +1084,21 @@ impl AssistantPanel {
self.show_updated_summary(&context_editor, cx); self.show_updated_summary(&context_editor, cx);
cx.notify() cx.notify()
} }
EditorEvent::Edited { .. } => cx.emit(AssistantPanelEvent::ContextEdited), EditorEvent::Edited { .. } => {
self.workspace
.update(cx, |workspace, cx| {
let is_via_ssh = workspace
.project()
.update(cx, |project, _| project.is_via_ssh());
workspace
.client()
.telemetry()
.log_edit_event("assistant panel", is_via_ssh);
})
.log_err();
cx.emit(AssistantPanelEvent::ContextEdited)
}
_ => {} _ => {}
} }
} }

View file

@ -86,7 +86,7 @@ pub struct InlineAssistant {
confirmed_assists: HashMap<InlineAssistId, Model<CodegenAlternative>>, confirmed_assists: HashMap<InlineAssistId, Model<CodegenAlternative>>,
prompt_history: VecDeque<String>, prompt_history: VecDeque<String>,
prompt_builder: Arc<PromptBuilder>, prompt_builder: Arc<PromptBuilder>,
telemetry: Option<Arc<Telemetry>>, telemetry: Arc<Telemetry>,
fs: Arc<dyn Fs>, fs: Arc<dyn Fs>,
} }
@ -107,7 +107,7 @@ impl InlineAssistant {
confirmed_assists: HashMap::default(), confirmed_assists: HashMap::default(),
prompt_history: VecDeque::default(), prompt_history: VecDeque::default(),
prompt_builder, prompt_builder,
telemetry: Some(telemetry), telemetry,
fs, fs,
} }
} }
@ -243,8 +243,7 @@ impl InlineAssistant {
codegen_ranges.push(start..end); codegen_ranges.push(start..end);
if let Some(model) = LanguageModelRegistry::read_global(cx).active_model() { if let Some(model) = LanguageModelRegistry::read_global(cx).active_model() {
if let Some(telemetry) = self.telemetry.as_ref() { self.telemetry.report_assistant_event(AssistantEvent {
telemetry.report_assistant_event(AssistantEvent {
conversation_id: None, conversation_id: None,
kind: AssistantKind::Inline, kind: AssistantKind::Inline,
phase: AssistantPhase::Invoked, phase: AssistantPhase::Invoked,
@ -257,7 +256,6 @@ impl InlineAssistant {
}); });
} }
} }
}
let assist_group_id = self.next_assist_group_id.post_inc(); let assist_group_id = self.next_assist_group_id.post_inc();
let prompt_buffer = let prompt_buffer =
@ -818,7 +816,7 @@ impl InlineAssistant {
error_message: None, error_message: None,
language_name: language_name.map(|name| name.to_proto()), language_name: language_name.map(|name| name.to_proto()),
}, },
self.telemetry.clone(), Some(self.telemetry.clone()),
cx.http_client(), cx.http_client(),
model.api_key(cx), model.api_key(cx),
cx.background_executor(), cx.background_executor(),
@ -1759,6 +1757,20 @@ impl PromptEditor {
) { ) {
match event { match event {
EditorEvent::Edited { .. } => { EditorEvent::Edited { .. } => {
if let Some(workspace) = cx.window_handle().downcast::<Workspace>() {
workspace
.update(cx, |workspace, cx| {
let is_via_ssh = workspace
.project()
.update(cx, |project, _| project.is_via_ssh());
workspace
.client()
.telemetry()
.log_edit_event("inline assist", is_via_ssh);
})
.log_err();
}
let prompt = self.editor.read(cx).text(cx); let prompt = self.editor.read(cx).text(cx);
if self if self
.prompt_history_ix .prompt_history_ix
@ -2337,7 +2349,7 @@ pub struct Codegen {
buffer: Model<MultiBuffer>, buffer: Model<MultiBuffer>,
range: Range<Anchor>, range: Range<Anchor>,
initial_transaction_id: Option<TransactionId>, initial_transaction_id: Option<TransactionId>,
telemetry: Option<Arc<Telemetry>>, telemetry: Arc<Telemetry>,
builder: Arc<PromptBuilder>, builder: Arc<PromptBuilder>,
is_insertion: bool, is_insertion: bool,
} }
@ -2347,7 +2359,7 @@ impl Codegen {
buffer: Model<MultiBuffer>, buffer: Model<MultiBuffer>,
range: Range<Anchor>, range: Range<Anchor>,
initial_transaction_id: Option<TransactionId>, initial_transaction_id: Option<TransactionId>,
telemetry: Option<Arc<Telemetry>>, telemetry: Arc<Telemetry>,
builder: Arc<PromptBuilder>, builder: Arc<PromptBuilder>,
cx: &mut ModelContext<Self>, cx: &mut ModelContext<Self>,
) -> Self { ) -> Self {
@ -2356,7 +2368,7 @@ impl Codegen {
buffer.clone(), buffer.clone(),
range.clone(), range.clone(),
false, false,
telemetry.clone(), Some(telemetry.clone()),
builder.clone(), builder.clone(),
cx, cx,
) )
@ -2447,7 +2459,7 @@ impl Codegen {
self.buffer.clone(), self.buffer.clone(),
self.range.clone(), self.range.clone(),
false, false,
self.telemetry.clone(), Some(self.telemetry.clone()),
self.builder.clone(), self.builder.clone(),
cx, cx,
) )