From 8fefd793f0c0704017a20209b7a2b216de142a65 Mon Sep 17 00:00:00 2001 From: Bennet Bo Fenner Date: Tue, 23 Sep 2025 18:45:37 +0200 Subject: [PATCH] zeta2: Include edit events in cloud request (#38724) Release Notes: - N/A Co-authored-by: Agus Zubiaga Co-authored-by: Michael Sloan --- crates/zeta2/src/zeta2.rs | 42 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/crates/zeta2/src/zeta2.rs b/crates/zeta2/src/zeta2.rs index 4ecc0fa3acf9bc04935d3e7e443e0e610b907589..159173493668754eb87f159699694b43c76798c4 100644 --- a/crates/zeta2/src/zeta2.rs +++ b/crates/zeta2/src/zeta2.rs @@ -305,6 +305,44 @@ impl Zeta { .collect::>(); let debug_tx = self.debug_tx.clone(); + let events = project_state + .map(|state| { + state + .events + .iter() + .map(|event| match event { + Event::BufferChange { + old_snapshot, + new_snapshot, + .. + } => { + let path = new_snapshot.file().map(|f| f.path().to_path_buf()); + + let old_path = old_snapshot.file().and_then(|f| { + let old_path = f.path().as_ref(); + if Some(old_path) != path.as_deref() { + Some(old_path.to_path_buf()) + } else { + None + } + }); + + predict_edits_v3::Event::BufferChange { + old_path, + path, + diff: language::unified_diff( + &old_snapshot.text(), + &new_snapshot.text(), + ), + //todo: Actually detect if this edit was predicted or not + predicted: false, + } + } + }) + .collect::>() + }) + .unwrap_or_default(); + let request_task = cx.background_spawn({ let snapshot = snapshot.clone(); let buffer = buffer.clone(); @@ -337,8 +375,8 @@ impl Zeta { let request = make_cloud_request( excerpt_path.clone(), context, - // TODO pass everything - Vec::new(), + events, + // TODO data collection false, Vec::new(), None,