diff --git a/crates/assistant/src/inline_assistant.rs b/crates/assistant/src/inline_assistant.rs index 6552301e90..27345dd0d6 100644 --- a/crates/assistant/src/inline_assistant.rs +++ b/crates/assistant/src/inline_assistant.rs @@ -2562,6 +2562,7 @@ pub struct CodegenAlternative { line_operations: Vec, request: Option, elapsed_time: Option, + completion: Option, message_id: Option, } @@ -2637,6 +2638,7 @@ impl CodegenAlternative { range, request: None, elapsed_time: None, + completion: None, } } @@ -2849,6 +2851,9 @@ impl CodegenAlternative { self.diff = Diff::default(); self.status = CodegenStatus::Pending; let mut edit_start = self.range.start.to_offset(&snapshot); + let completion = Arc::new(Mutex::new(String::new())); + let completion_clone = completion.clone(); + self.generation = cx.spawn(|codegen, mut cx| { async move { let stream = stream.await; @@ -2880,6 +2885,7 @@ impl CodegenAlternative { response_latency = Some(request_start.elapsed()); } let chunk = chunk?; + completion_clone.lock().push_str(&chunk); let mut lines = chunk.split('\n').peekable(); while let Some(line) = lines.next() { @@ -3049,6 +3055,7 @@ impl CodegenAlternative { this.status = CodegenStatus::Done; } this.elapsed_time = Some(elapsed_time); + this.completion = Some(completion.lock().clone()); cx.emit(CodegenEvent::Finished); cx.notify(); })