…lines 1–72 unchanged (72 lines)
73mod zed_edit_prediction_delegate;
74pub mod zeta;
75
76#[cfg(test)]
77mod edit_prediction_tests;
78
79use crate::example_spec::ExampleSpec;
80use crate::license_detection::LicenseDetectionWatcher;
81use crate::mercury::Mercury;
82use crate::onboarding_modal::ZedPredictModal;
83pub use crate::prediction::EditPrediction;
84pub use crate::prediction::EditPredictionId;
85use crate::prediction::EditPredictionResult;
…lines 86–495 unchanged (410 lines)
496}
497
498#[derive(Clone)]
499struct PendingSettledPrediction {
500 request_id: EditPredictionId,
501 editable_anchor_range: Range<Anchor>,
502 example: Option<ExampleSpec>,
503 enqueued_at: Instant,
504 last_edit_at: Instant,
505}
506
507struct RegisteredBuffer {
508 file: Option<Arc<dyn File>>,
…lines 509–1570 unchanged (1062 lines)
1571 }
1572
1573 telemetry::event!(
1574 EDIT_PREDICTION_SETTLED_EVENT,
1575 request_id = pending_prediction.request_id.0.clone(),
1576 settled_editable_region,
1577 example = pending_prediction.example.take(),
1578 );
1579
1580 return false;
1581 }
1582
1583 if oldest_edited_at
…lines 1584–1599 unchanged (16 lines)
1600 &mut self,
1601 request_id: EditPredictionId,
1602 project: &Entity<Project>,
1603 edited_buffer: &Entity<Buffer>,
1604 edited_buffer_snapshot: &BufferSnapshot,
1605 editable_offset_range: Range<usize>,
1606 example: Option<ExampleSpec>,
1607 cx: &mut Context<Self>,
1608 ) {
1609 let this = &mut *self;
1610 let project_state = this.get_or_init_project(project, cx);
1611 if let Some(buffer) = project_state
1612 .registered_buffers
1613 .get_mut(&edited_buffer.entity_id())
1614 {
1615 let now = cx.background_executor().now();
1616 buffer.pending_predictions.push(PendingSettledPrediction {
1617 request_id: request_id,
1618 editable_anchor_range: edited_buffer_snapshot
1619 .anchor_range_around(editable_offset_range),
1620 example,
1621 enqueued_at: now,
1622 last_edit_at: now,
1623 });
1624 this.settled_predictions_tx.unbounded_send(now).ok();
1625 }
1626 }
1627
1628 fn reject_current_prediction(
1629 &mut self,
1630 reason: EditPredictionRejectReason,
…lines 1631–2228 unchanged (598 lines)
2229
2230 let can_collect_data = !cfg!(test)
2231 && is_open_source
2232 && self.is_data_collection_enabled(cx)
2233 && matches!(self.edit_prediction_model, EditPredictionModel::Zeta);
2234
2235 let recent_paths = project_state.recent_paths.clone();
2236
2237 let inputs = EditPredictionModelInput {
2238 project: project.clone(),
2239 buffer: active_buffer,
2240 snapshot,
2241 position,
2242 events,
2243 related_files,
2244 recent_paths,
2245 trigger,
2246 diagnostic_search_range: diagnostic_search_range,
2247 debug_tx,
2248 user_actions,
2249 can_collect_data,
2250 is_open_source,
2251 };
2252
2253 let capture_data = (can_collect_data && rand::random_ratio(1, 1000)).then(|| stored_events);
2254
2255 let task = match self.edit_prediction_model {
2256 EditPredictionModel::Zeta => {
2257 zeta::request_prediction_with_zeta(self, inputs, capture_data, cx)
2258 }
2259 EditPredictionModel::Fim { format } => fim::request_prediction(inputs, format, cx),
2260 EditPredictionModel::Sweep => self.sweep_ai.request_prediction_with_sweep(inputs, cx),
2261 EditPredictionModel::Mercury => self.mercury.request_prediction(inputs, cx),
2262 };
2263
2264 cx.spawn(async move |this, cx| {
…lines 2265–2933 unchanged (669 lines)