Enable edit prediction and Copilot for untitled buffers - #45764
Conversation
There was a problem hiding this comment.
Pull request overview
Enables edit predictions (including Copilot) to work for buffers that have no on-disk file association (e.g., buffers created via workspace: new file), addressing the regression described in #45631.
Changes:
- Register singleton buffers with Copilot even when the buffer has no associated file.
- Use a unique synthetic path (
untitled-{remote_id}) for Zeta requests when the buffer has no file, avoiding collisions between multiple untitled buffers.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
crates/zed/src/zed/edit_prediction_registry.rs |
Removes the “must have a file” gate so Copilot can register untitled buffers. |
crates/edit_prediction/src/zeta.rs |
Changes Zeta’s fallback excerpt path from a constant to a per-buffer synthetic path based on remote_id. |
Comments suppressed due to low confidence (1)
crates/zed/src/zed/edit_prediction_registry.rs:267
- The Copilot provider behavior was changed to register singleton buffers even when they have no associated file. There’s no regression test covering this untitled-buffer path (this file already has gpui tests), so it’s easy for the original
file().is_some()guard to accidentally come back. Consider adding a test that constructs an editor with a singleton buffer without a file handle and asserts that Copilot registration still happens when the provider is Copilot.
Some(EditPredictionProviderConfig::Copilot) => {
let ep_store = edit_prediction::EditPredictionStore::global(client, &user_store, cx);
let Some(project) = editor.project().cloned() else {
return;
};
let copilot =
ep_store.update(cx, |this, cx| this.start_copilot_for_project(&project, cx));
if let Some(copilot) = copilot {
if let Some(buffer) = singleton_buffer {
copilot.update(cx, |copilot, cx| {
copilot.register_buffer(&buffer, cx);
});
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
5b8cdc3 to
7bcbd8a
Compare
|
We require contributors to sign our Contributor License Agreement, and we don't have @tacshi on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'. |
|
@cla-bot check |
|
We require contributors to sign our Contributor License Agreement, and we don't have @tacshi on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'. |
|
The cla-bot has been summoned, and re-checked this pull request! |
|
@cla-bot check |
|
The cla-bot has been summoned, and re-checked this pull request! |
|
The previous account was deleted due to a login issue, so a cla recheck is needed. |
|
Thank you! Sorry for keeping you waiting. |
Closes [#45631](#45631) Recording: https://github.com/user-attachments/assets/a5143eb4-fae3-42a7-9d64-fb7c42ee97c2 Release Notes: - copilot: Edit predictions now work in temporary files --------- Co-authored-by: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com>
…es#45764) Closes [zed-industries#45631](zed-industries#45631) Recording: https://github.com/user-attachments/assets/a5143eb4-fae3-42a7-9d64-fb7c42ee97c2 Release Notes: - copilot: Edit predictions now work in temporary files --------- Co-authored-by: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com>
…es#45764) Closes [zed-industries#45631](zed-industries#45631) Recording: https://github.com/user-attachments/assets/a5143eb4-fae3-42a7-9d64-fb7c42ee97c2 Release Notes: - copilot: Edit predictions now work in temporary files --------- Co-authored-by: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com>
…es#45764) Closes [zed-industries#45631](zed-industries#45631) Recording: https://github.com/user-attachments/assets/a5143eb4-fae3-42a7-9d64-fb7c42ee97c2 Release Notes: - copilot: Edit predictions now work in temporary files --------- Co-authored-by: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com>
…es#45764) Closes [zed-industries#45631](zed-industries#45631) Recording: https://github.com/user-attachments/assets/a5143eb4-fae3-42a7-9d64-fb7c42ee97c2 Release Notes: - copilot: Edit predictions now work in temporary files --------- Co-authored-by: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com>
Closes #45631
Recording:
buffer_prediction.mp4
Release Notes: