2024-08-15 19:46:19 +00:00
<overview>
Your task is to map a step from a workflow to locations in source code where code needs to be changed to fulfill that step.
Given a workflow containing background context plus a series of <step> tags, you will resolve *one* of these step tags to resolve to one or more locations in the code.
With each location, you will produce a brief, one-line description of the changes to be made.
2024-07-19 09:13:15 +00:00
2024-08-15 19:46:19 +00:00
<guidelines>
2024-07-19 09:13:15 +00:00
- There's no need to describe *what* to do, just *where* to do it.
2024-08-15 19:46:19 +00:00
- Only reference locations that actually exist (unless you're creating a file).
2024-07-19 09:13:15 +00:00
- If creating a file, assume any subsequent updates are included at the time of creation.
2024-08-15 19:46:19 +00:00
- Don't create and then update a file. Always create new files in shot.
2024-07-19 09:13:15 +00:00
- Prefer updating symbols lower in the syntax tree if possible.
Open workflow step editors as preview tabs (#15928)
This PR opens workflow step editors as preview tabs and closes them upon
exiting the step if they are still in preview mode and they weren't
already open before entering the step.
Making this work was tricky, because we often edit the buffer as part of
displaying the workflow step suggestions to create empty lines where we
can generate. We undo these edits if the transformation is not applied,
but they were causing the preview to be dismissed.
After trying a few approaches, I decided to give workspace `Item`s a
`preserve_preview` method that defaults to false. When the workspace
sees an edit event for the item, it checks if the item wants to preserve
its preview. For buffers, after editing, you can call `refresh_preview`,
which sets a preview version to the current version of the buffer. Any
edits after this version will cause preview to not be preserved.
One final issue is with async auto-indent. To ensure these async edits
don't dismiss the preview, I automatically refresh the preview version
if preview was preserved prior to performing the auto-indent. The
assumption is that these are edits created by other edits, and if we
didn't want to dismiss the preview with the originating edits, then the
auto-indent edits shouldn't dismiss it either.
Release Notes:
- N/A
---------
Co-authored-by: Jason <jason@zed.dev>
2024-08-08 01:33:58 +00:00
- Never include suggestions on a parent symbol and one of its children in the same suggestions block.
- Never nest an operation with another operation or include CDATA or other content. All suggestions are leaf nodes.
- Descriptions are required for all suggestions except delete.
- When generating multiple suggestions, ensure the descriptions are specific to each individual operation.
2024-07-19 09:13:15 +00:00
- Avoid referring to the location in the description. Focus on the change to be made, not the location where it's made. That's implicit with the symbol you provide.
Open workflow step editors as preview tabs (#15928)
This PR opens workflow step editors as preview tabs and closes them upon
exiting the step if they are still in preview mode and they weren't
already open before entering the step.
Making this work was tricky, because we often edit the buffer as part of
displaying the workflow step suggestions to create empty lines where we
can generate. We undo these edits if the transformation is not applied,
but they were causing the preview to be dismissed.
After trying a few approaches, I decided to give workspace `Item`s a
`preserve_preview` method that defaults to false. When the workspace
sees an edit event for the item, it checks if the item wants to preserve
its preview. For buffers, after editing, you can call `refresh_preview`,
which sets a preview version to the current version of the buffer. Any
edits after this version will cause preview to not be preserved.
One final issue is with async auto-indent. To ensure these async edits
don't dismiss the preview, I automatically refresh the preview version
if preview was preserved prior to performing the auto-indent. The
assumption is that these are edits created by other edits, and if we
didn't want to dismiss the preview with the originating edits, then the
auto-indent edits shouldn't dismiss it either.
Release Notes:
- N/A
---------
Co-authored-by: Jason <jason@zed.dev>
2024-08-08 01:33:58 +00:00
- Don't generate multiple suggestions at the same location. Instead, combine them together in a single operation with a succinct combined description.
2024-08-19 17:01:45 +00:00
- To add imports respond with a suggestion where the `"symbol"` key is set to `"#imports"`
2024-08-15 19:46:19 +00:00
</guidelines>
</overview>
2024-07-19 09:13:15 +00:00
2024-08-15 19:46:19 +00:00
<examples>
<example>
<workflow_context>
<message role="user">
2024-07-29 18:21:19 +00:00
```rs src/rectangle.rs
struct Rectangle {
width: f64,
height: f64,
}
2024-07-19 09:13:15 +00:00
2024-07-29 18:21:19 +00:00
impl Rectangle {
fn new(width: f64, height: f64) -> Self {
Rectangle { width, height }
}
}
```
2024-07-19 09:13:15 +00:00
2024-08-15 19:46:19 +00:00
We need to add methods to calculate the area and perimeter of the rectangle. Can you help with that?
</message>
<message role="assistant">
Sure, I can help with that!
2024-07-29 18:21:19 +00:00
<step>Add new methods 'calculate_area' and 'calculate_perimeter' to the Rectangle struct</step>
<step>Implement the 'Display' trait for the Rectangle struct</step>
2024-08-15 19:46:19 +00:00
</message>
</workflow_context>
2024-07-19 09:13:15 +00:00
2024-08-15 19:46:19 +00:00
<step_to_resolve>
Add new methods 'calculate_area' and 'calculate_perimeter' to the Rectangle struct
</step_to_resolve>
2024-07-29 18:21:19 +00:00
2024-08-15 19:46:19 +00:00
<incorrect_output reason="NEVER append multiple children at the same location.">
2024-07-29 18:21:19 +00:00
{
2024-08-01 15:48:56 +00:00
"title": "Add Rectangle methods",
Open workflow step editors as preview tabs (#15928)
This PR opens workflow step editors as preview tabs and closes them upon
exiting the step if they are still in preview mode and they weren't
already open before entering the step.
Making this work was tricky, because we often edit the buffer as part of
displaying the workflow step suggestions to create empty lines where we
can generate. We undo these edits if the transformation is not applied,
but they were causing the preview to be dismissed.
After trying a few approaches, I decided to give workspace `Item`s a
`preserve_preview` method that defaults to false. When the workspace
sees an edit event for the item, it checks if the item wants to preserve
its preview. For buffers, after editing, you can call `refresh_preview`,
which sets a preview version to the current version of the buffer. Any
edits after this version will cause preview to not be preserved.
One final issue is with async auto-indent. To ensure these async edits
don't dismiss the preview, I automatically refresh the preview version
if preview was preserved prior to performing the auto-indent. The
assumption is that these are edits created by other edits, and if we
didn't want to dismiss the preview with the originating edits, then the
auto-indent edits shouldn't dismiss it either.
Release Notes:
- N/A
---------
Co-authored-by: Jason <jason@zed.dev>
2024-08-08 01:33:58 +00:00
"suggestions": [
2024-07-29 18:21:19 +00:00
{
"kind": "AppendChild",
"path": "src/shapes.rs",
"symbol": "impl Rectangle",
"description": "Add calculate_area method"
},
{
"kind": "AppendChild",
"path": "src/shapes.rs",
"symbol": "impl Rectangle",
"description": "Add calculate_perimeter method"
}
]
}
2024-08-15 19:46:19 +00:00
</incorrect_output>
2024-07-19 09:13:15 +00:00
2024-08-15 19:46:19 +00:00
<correct_output>
2024-07-29 18:21:19 +00:00
{
2024-08-01 15:48:56 +00:00
"title": "Add Rectangle methods",
Open workflow step editors as preview tabs (#15928)
This PR opens workflow step editors as preview tabs and closes them upon
exiting the step if they are still in preview mode and they weren't
already open before entering the step.
Making this work was tricky, because we often edit the buffer as part of
displaying the workflow step suggestions to create empty lines where we
can generate. We undo these edits if the transformation is not applied,
but they were causing the preview to be dismissed.
After trying a few approaches, I decided to give workspace `Item`s a
`preserve_preview` method that defaults to false. When the workspace
sees an edit event for the item, it checks if the item wants to preserve
its preview. For buffers, after editing, you can call `refresh_preview`,
which sets a preview version to the current version of the buffer. Any
edits after this version will cause preview to not be preserved.
One final issue is with async auto-indent. To ensure these async edits
don't dismiss the preview, I automatically refresh the preview version
if preview was preserved prior to performing the auto-indent. The
assumption is that these are edits created by other edits, and if we
didn't want to dismiss the preview with the originating edits, then the
auto-indent edits shouldn't dismiss it either.
Release Notes:
- N/A
---------
Co-authored-by: Jason <jason@zed.dev>
2024-08-08 01:33:58 +00:00
"suggestions": [
2024-07-29 18:21:19 +00:00
{
"kind": "AppendChild",
"path": "src/shapes.rs",
"symbol": "impl Rectangle",
"description": "Add calculate area and perimeter methods"
}
]
}
2024-08-15 19:46:19 +00:00
</correct_output>
2024-07-19 09:13:15 +00:00
2024-08-15 19:46:19 +00:00
<step_to_resolve>
Implement the 'Display' trait for the Rectangle struct
</step_to_resolve>
2024-07-19 09:13:15 +00:00
2024-08-15 19:46:19 +00:00
<output>
2024-07-29 18:21:19 +00:00
{
2024-08-01 15:48:56 +00:00
"title": "Implement Display for Rectangle",
Open workflow step editors as preview tabs (#15928)
This PR opens workflow step editors as preview tabs and closes them upon
exiting the step if they are still in preview mode and they weren't
already open before entering the step.
Making this work was tricky, because we often edit the buffer as part of
displaying the workflow step suggestions to create empty lines where we
can generate. We undo these edits if the transformation is not applied,
but they were causing the preview to be dismissed.
After trying a few approaches, I decided to give workspace `Item`s a
`preserve_preview` method that defaults to false. When the workspace
sees an edit event for the item, it checks if the item wants to preserve
its preview. For buffers, after editing, you can call `refresh_preview`,
which sets a preview version to the current version of the buffer. Any
edits after this version will cause preview to not be preserved.
One final issue is with async auto-indent. To ensure these async edits
don't dismiss the preview, I automatically refresh the preview version
if preview was preserved prior to performing the auto-indent. The
assumption is that these are edits created by other edits, and if we
didn't want to dismiss the preview with the originating edits, then the
auto-indent edits shouldn't dismiss it either.
Release Notes:
- N/A
---------
Co-authored-by: Jason <jason@zed.dev>
2024-08-08 01:33:58 +00:00
"suggestions": [
2024-07-29 18:21:19 +00:00
{
"kind": "InsertSiblingAfter",
"path": "src/shapes.rs",
"symbol": "impl Rectangle",
"description": "Implement Display trait for Rectangle"
}
]
}
2024-08-15 19:46:19 +00:00
</output>
2024-07-19 09:13:15 +00:00
2024-08-15 19:46:19 +00:00
<example>
<workflow_context>
<message role="user">
2024-07-19 09:13:15 +00:00
```rs src/user.rs
struct User {
pub name: String,
age: u32,
email: String,
}
impl User {
fn new(name: String, age: u32, email: String) -> Self {
User { name, age, email }
}
pub fn print_info(&self) {
println!("Name: { }, Age: { }, Email: { }", self.name, self.age, self.email);
}
}
```
2024-08-15 19:46:19 +00:00
</message>
<message role="assistant">
Certainly!
2024-07-19 09:13:15 +00:00
<step>Update the 'print_info' method to use formatted output</step>
<step>Remove the 'email' field from the User struct</step>
2024-08-15 19:46:19 +00:00
</message>
</workflow_context>
2024-07-19 09:13:15 +00:00
2024-08-15 19:46:19 +00:00
<step_to_resolve>
Update the 'print_info' method to use formatted output
</step_to_resolve>
2024-07-19 09:13:15 +00:00
2024-08-15 19:46:19 +00:00
<output>
2024-07-29 18:21:19 +00:00
{
2024-08-01 15:48:56 +00:00
"title": "Use formatted output",
Open workflow step editors as preview tabs (#15928)
This PR opens workflow step editors as preview tabs and closes them upon
exiting the step if they are still in preview mode and they weren't
already open before entering the step.
Making this work was tricky, because we often edit the buffer as part of
displaying the workflow step suggestions to create empty lines where we
can generate. We undo these edits if the transformation is not applied,
but they were causing the preview to be dismissed.
After trying a few approaches, I decided to give workspace `Item`s a
`preserve_preview` method that defaults to false. When the workspace
sees an edit event for the item, it checks if the item wants to preserve
its preview. For buffers, after editing, you can call `refresh_preview`,
which sets a preview version to the current version of the buffer. Any
edits after this version will cause preview to not be preserved.
One final issue is with async auto-indent. To ensure these async edits
don't dismiss the preview, I automatically refresh the preview version
if preview was preserved prior to performing the auto-indent. The
assumption is that these are edits created by other edits, and if we
didn't want to dismiss the preview with the originating edits, then the
auto-indent edits shouldn't dismiss it either.
Release Notes:
- N/A
---------
Co-authored-by: Jason <jason@zed.dev>
2024-08-08 01:33:58 +00:00
"suggestions": [
2024-07-29 18:21:19 +00:00
{
"kind": "Update",
"path": "src/user.rs",
"symbol": "impl User pub fn print_info",
"description": "Use formatted output"
}
]
}
2024-08-15 19:46:19 +00:00
</output>
2024-07-19 09:13:15 +00:00
2024-08-15 19:46:19 +00:00
<step_to_resolve>
Remove the 'email' field from the User struct
</step_to_resolve>
2024-07-19 09:13:15 +00:00
2024-08-15 19:46:19 +00:00
<output>
2024-07-29 18:21:19 +00:00
{
2024-08-01 15:48:56 +00:00
"title": "Remove email field",
Open workflow step editors as preview tabs (#15928)
This PR opens workflow step editors as preview tabs and closes them upon
exiting the step if they are still in preview mode and they weren't
already open before entering the step.
Making this work was tricky, because we often edit the buffer as part of
displaying the workflow step suggestions to create empty lines where we
can generate. We undo these edits if the transformation is not applied,
but they were causing the preview to be dismissed.
After trying a few approaches, I decided to give workspace `Item`s a
`preserve_preview` method that defaults to false. When the workspace
sees an edit event for the item, it checks if the item wants to preserve
its preview. For buffers, after editing, you can call `refresh_preview`,
which sets a preview version to the current version of the buffer. Any
edits after this version will cause preview to not be preserved.
One final issue is with async auto-indent. To ensure these async edits
don't dismiss the preview, I automatically refresh the preview version
if preview was preserved prior to performing the auto-indent. The
assumption is that these are edits created by other edits, and if we
didn't want to dismiss the preview with the originating edits, then the
auto-indent edits shouldn't dismiss it either.
Release Notes:
- N/A
---------
Co-authored-by: Jason <jason@zed.dev>
2024-08-08 01:33:58 +00:00
"suggestions": [
2024-08-01 15:48:56 +00:00
{
"kind": "Delete",
"path": "src/user.rs",
"symbol": "struct User email"
}
]
2024-07-29 18:21:19 +00:00
}
2024-08-15 19:46:19 +00:00
</output>
</example>
2024-07-19 09:13:15 +00:00
2024-08-15 19:46:19 +00:00
<example>
<workflow_context>
<message role="user">
2024-07-19 09:13:15 +00:00
```rs src/vehicle.rs
struct Vehicle {
make: String,
model: String,
year: u32,
}
impl Vehicle {
fn new(make: String, model: String, year: u32) -> Self {
Vehicle { make, model, year }
}
fn print_year(&self) {
println!("Year: { }", self.year);
}
}
```
2024-08-15 19:46:19 +00:00
</message>
<message role="assistant">
2024-07-19 09:13:15 +00:00
<step>Add a 'use std::fmt;' statement at the beginning of the file</step>
<step>Add a new method 'start_engine' in the Vehicle impl block</step>
2024-08-15 19:46:19 +00:00
</message>
</workflow_context>
2024-07-19 09:13:15 +00:00
2024-08-15 19:46:19 +00:00
<step_to_resolve>
Add a 'use std::fmt;' statement at the beginning of the file
</step_to_resolve>
2024-07-19 09:13:15 +00:00
2024-08-15 19:46:19 +00:00
<output>
2024-07-29 18:21:19 +00:00
{
2024-08-01 15:48:56 +00:00
"title": "Add use std::fmt statement",
Open workflow step editors as preview tabs (#15928)
This PR opens workflow step editors as preview tabs and closes them upon
exiting the step if they are still in preview mode and they weren't
already open before entering the step.
Making this work was tricky, because we often edit the buffer as part of
displaying the workflow step suggestions to create empty lines where we
can generate. We undo these edits if the transformation is not applied,
but they were causing the preview to be dismissed.
After trying a few approaches, I decided to give workspace `Item`s a
`preserve_preview` method that defaults to false. When the workspace
sees an edit event for the item, it checks if the item wants to preserve
its preview. For buffers, after editing, you can call `refresh_preview`,
which sets a preview version to the current version of the buffer. Any
edits after this version will cause preview to not be preserved.
One final issue is with async auto-indent. To ensure these async edits
don't dismiss the preview, I automatically refresh the preview version
if preview was preserved prior to performing the auto-indent. The
assumption is that these are edits created by other edits, and if we
didn't want to dismiss the preview with the originating edits, then the
auto-indent edits shouldn't dismiss it either.
Release Notes:
- N/A
---------
Co-authored-by: Jason <jason@zed.dev>
2024-08-08 01:33:58 +00:00
"suggestions": [
2024-07-29 18:21:19 +00:00
{
"kind": "PrependChild",
"path": "src/vehicle.rs",
2024-08-19 17:01:45 +00:00
"symbol": "#imports",
2024-07-29 18:21:19 +00:00
"description": "Add 'use std::fmt' statement"
}
]
}
2024-08-15 19:46:19 +00:00
</output>
2024-07-19 09:13:15 +00:00
2024-08-15 19:46:19 +00:00
<step_to_resolve>
Add a new method 'start_engine' in the Vehicle impl block
</step_to_resolve>
2024-07-19 09:13:15 +00:00
2024-08-15 19:46:19 +00:00
<output>
2024-07-29 18:21:19 +00:00
{
2024-08-01 15:48:56 +00:00
"title": "Add start_engine method",
Open workflow step editors as preview tabs (#15928)
This PR opens workflow step editors as preview tabs and closes them upon
exiting the step if they are still in preview mode and they weren't
already open before entering the step.
Making this work was tricky, because we often edit the buffer as part of
displaying the workflow step suggestions to create empty lines where we
can generate. We undo these edits if the transformation is not applied,
but they were causing the preview to be dismissed.
After trying a few approaches, I decided to give workspace `Item`s a
`preserve_preview` method that defaults to false. When the workspace
sees an edit event for the item, it checks if the item wants to preserve
its preview. For buffers, after editing, you can call `refresh_preview`,
which sets a preview version to the current version of the buffer. Any
edits after this version will cause preview to not be preserved.
One final issue is with async auto-indent. To ensure these async edits
don't dismiss the preview, I automatically refresh the preview version
if preview was preserved prior to performing the auto-indent. The
assumption is that these are edits created by other edits, and if we
didn't want to dismiss the preview with the originating edits, then the
auto-indent edits shouldn't dismiss it either.
Release Notes:
- N/A
---------
Co-authored-by: Jason <jason@zed.dev>
2024-08-08 01:33:58 +00:00
"suggestions": [
2024-07-29 18:21:19 +00:00
{
"kind": "InsertSiblingAfter",
"path": "src/vehicle.rs",
"symbol": "impl Vehicle fn new",
"description": "Add start_engine method"
}
]
}
2024-08-15 19:46:19 +00:00
</output>
</example>
2024-07-19 09:13:15 +00:00
2024-08-15 19:46:19 +00:00
<example>
<workflow_context>
<message role="user">
2024-07-19 09:13:15 +00:00
```rs src/employee.rs
struct Employee {
name: String,
position: String,
salary: u32,
department: String,
}
impl Employee {
fn new(name: String, position: String, salary: u32, department: String) -> Self {
Employee { name, position, salary, department }
}
fn print_details(&self) {
println!("Name: { }, Position: { }, Salary: { }, Department: { }",
self.name, self.position, self.salary, self.department);
}
fn give_raise(&mut self, amount: u32) {
self.salary += amount;
}
}
```
2024-08-15 19:46:19 +00:00
</message>
<message role="assistant">
2024-07-19 09:13:15 +00:00
<step>Make salary an f32</step>
2024-08-15 19:46:19 +00:00
<step>Remove the 'department' field and update the 'print_details' method</step>
</message>
</workflow_context>
2024-07-19 09:13:15 +00:00
2024-08-15 19:46:19 +00:00
<step_to_resolve>
Make salary an f32
</step_to_resolve>
2024-07-19 09:13:15 +00:00
2024-08-15 19:46:19 +00:00
<incorrect_output reason="NEVER include suggestions on a parent symbol and one of its children in the same suggestions block.">
2024-07-29 18:21:19 +00:00
{
2024-08-01 15:48:56 +00:00
"title": "Change salary to f32",
Open workflow step editors as preview tabs (#15928)
This PR opens workflow step editors as preview tabs and closes them upon
exiting the step if they are still in preview mode and they weren't
already open before entering the step.
Making this work was tricky, because we often edit the buffer as part of
displaying the workflow step suggestions to create empty lines where we
can generate. We undo these edits if the transformation is not applied,
but they were causing the preview to be dismissed.
After trying a few approaches, I decided to give workspace `Item`s a
`preserve_preview` method that defaults to false. When the workspace
sees an edit event for the item, it checks if the item wants to preserve
its preview. For buffers, after editing, you can call `refresh_preview`,
which sets a preview version to the current version of the buffer. Any
edits after this version will cause preview to not be preserved.
One final issue is with async auto-indent. To ensure these async edits
don't dismiss the preview, I automatically refresh the preview version
if preview was preserved prior to performing the auto-indent. The
assumption is that these are edits created by other edits, and if we
didn't want to dismiss the preview with the originating edits, then the
auto-indent edits shouldn't dismiss it either.
Release Notes:
- N/A
---------
Co-authored-by: Jason <jason@zed.dev>
2024-08-08 01:33:58 +00:00
"suggestions": [
2024-07-29 18:21:19 +00:00
{
"kind": "Update",
"path": "src/employee.rs",
"symbol": "struct Employee",
"description": "Change the type of salary to an f32"
},
{
"kind": "Update",
"path": "src/employee.rs",
"symbol": "struct Employee salary",
"description": "Change the type to an f32"
}
]
}
2024-08-15 19:46:19 +00:00
</incorrect_output>
2024-07-19 09:13:15 +00:00
2024-08-15 19:46:19 +00:00
<correct_output>
2024-07-29 18:21:19 +00:00
{
2024-08-01 15:48:56 +00:00
"title": "Change salary to f32",
Open workflow step editors as preview tabs (#15928)
This PR opens workflow step editors as preview tabs and closes them upon
exiting the step if they are still in preview mode and they weren't
already open before entering the step.
Making this work was tricky, because we often edit the buffer as part of
displaying the workflow step suggestions to create empty lines where we
can generate. We undo these edits if the transformation is not applied,
but they were causing the preview to be dismissed.
After trying a few approaches, I decided to give workspace `Item`s a
`preserve_preview` method that defaults to false. When the workspace
sees an edit event for the item, it checks if the item wants to preserve
its preview. For buffers, after editing, you can call `refresh_preview`,
which sets a preview version to the current version of the buffer. Any
edits after this version will cause preview to not be preserved.
One final issue is with async auto-indent. To ensure these async edits
don't dismiss the preview, I automatically refresh the preview version
if preview was preserved prior to performing the auto-indent. The
assumption is that these are edits created by other edits, and if we
didn't want to dismiss the preview with the originating edits, then the
auto-indent edits shouldn't dismiss it either.
Release Notes:
- N/A
---------
Co-authored-by: Jason <jason@zed.dev>
2024-08-08 01:33:58 +00:00
"suggestions": [
2024-07-29 18:21:19 +00:00
{
"kind": "Update",
"path": "src/employee.rs",
"symbol": "struct Employee salary",
"description": "Change the type to an f32"
}
]
}
2024-08-15 19:46:19 +00:00
</correct_output>
2024-07-29 18:21:19 +00:00
2024-08-15 19:46:19 +00:00
<step_to_resolve>
Remove the 'department' field and update the 'print_details' method
</step_to_resolve>
2024-07-29 18:21:19 +00:00
2024-08-15 19:46:19 +00:00
<output>
2024-07-29 18:21:19 +00:00
{
2024-08-01 15:48:56 +00:00
"title": "Remove department",
Open workflow step editors as preview tabs (#15928)
This PR opens workflow step editors as preview tabs and closes them upon
exiting the step if they are still in preview mode and they weren't
already open before entering the step.
Making this work was tricky, because we often edit the buffer as part of
displaying the workflow step suggestions to create empty lines where we
can generate. We undo these edits if the transformation is not applied,
but they were causing the preview to be dismissed.
After trying a few approaches, I decided to give workspace `Item`s a
`preserve_preview` method that defaults to false. When the workspace
sees an edit event for the item, it checks if the item wants to preserve
its preview. For buffers, after editing, you can call `refresh_preview`,
which sets a preview version to the current version of the buffer. Any
edits after this version will cause preview to not be preserved.
One final issue is with async auto-indent. To ensure these async edits
don't dismiss the preview, I automatically refresh the preview version
if preview was preserved prior to performing the auto-indent. The
assumption is that these are edits created by other edits, and if we
didn't want to dismiss the preview with the originating edits, then the
auto-indent edits shouldn't dismiss it either.
Release Notes:
- N/A
---------
Co-authored-by: Jason <jason@zed.dev>
2024-08-08 01:33:58 +00:00
"suggestions": [
2024-07-29 18:21:19 +00:00
{
"kind": "Delete",
"path": "src/employee.rs",
"symbol": "struct Employee department"
},
{
"kind": "Update",
"path": "src/employee.rs",
"symbol": "impl Employee fn print_details",
"description": "Don't print the 'department' field"
}
]
}
2024-08-15 19:46:19 +00:00
</output>
</example>
2024-07-29 18:21:19 +00:00
2024-08-15 19:46:19 +00:00
<example>
<workflow_context>
<message role="user">
2024-07-29 18:21:19 +00:00
```rs src/game.rs
struct Player {
name: String,
health: i32,
pub score: u32,
}
impl Player {
pub fn new(name: String) -> Self {
Player { name, health: 100, score: 0 }
}
}
struct Game {
players: Vec<Player>,
}
impl Game {
fn new() -> Self {
Game { players: Vec::new() }
}
}
```
2024-08-15 19:46:19 +00:00
</message>
<message role="assistant">
2024-07-29 18:21:19 +00:00
<step>Add a 'level' field to Player and update the 'new' method</step>
2024-08-15 19:46:19 +00:00
</message>
</workflow_context>
<step_to_resolve>
Add a 'level' field to Player and update the 'new' method
</step_to_resolve>
2024-07-29 18:21:19 +00:00
2024-08-15 19:46:19 +00:00
<output>
2024-07-29 18:21:19 +00:00
{
2024-08-01 15:48:56 +00:00
"title": "Add level field to Player",
Open workflow step editors as preview tabs (#15928)
This PR opens workflow step editors as preview tabs and closes them upon
exiting the step if they are still in preview mode and they weren't
already open before entering the step.
Making this work was tricky, because we often edit the buffer as part of
displaying the workflow step suggestions to create empty lines where we
can generate. We undo these edits if the transformation is not applied,
but they were causing the preview to be dismissed.
After trying a few approaches, I decided to give workspace `Item`s a
`preserve_preview` method that defaults to false. When the workspace
sees an edit event for the item, it checks if the item wants to preserve
its preview. For buffers, after editing, you can call `refresh_preview`,
which sets a preview version to the current version of the buffer. Any
edits after this version will cause preview to not be preserved.
One final issue is with async auto-indent. To ensure these async edits
don't dismiss the preview, I automatically refresh the preview version
if preview was preserved prior to performing the auto-indent. The
assumption is that these are edits created by other edits, and if we
didn't want to dismiss the preview with the originating edits, then the
auto-indent edits shouldn't dismiss it either.
Release Notes:
- N/A
---------
Co-authored-by: Jason <jason@zed.dev>
2024-08-08 01:33:58 +00:00
"suggestions": [
2024-07-29 18:21:19 +00:00
{
"kind": "InsertSiblingAfter",
"path": "src/game.rs",
"symbol": "struct Player pub score",
"description": "Add level field to Player"
},
{
"kind": "Update",
"path": "src/game.rs",
"symbol": "impl Player pub fn new",
"description": "Initialize level in new method"
}
]
}
2024-08-15 19:46:19 +00:00
</output>
</example>
2024-07-29 18:21:19 +00:00
2024-08-15 19:46:19 +00:00
<example>
<workflow_context>
<message role="user">
2024-07-29 18:21:19 +00:00
```rs src/config.rs
use std::collections::HashMap;
struct Config {
settings: HashMap<String, String>,
}
impl Config {
fn new() -> Self {
Config { settings: HashMap::new() }
}
}
```
2024-08-15 19:46:19 +00:00
</message>
<message role="assistant">
2024-07-29 18:21:19 +00:00
<step>Add a 'load_from_file' method to Config and import necessary modules</step>
2024-08-15 19:46:19 +00:00
</message>
</workflow_context>
<step_to_resolve>
Add a 'load_from_file' method to Config and import necessary modules
</step_to_resolve>
2024-07-29 18:21:19 +00:00
2024-08-15 19:46:19 +00:00
<output>
2024-07-29 18:21:19 +00:00
{
2024-08-01 15:48:56 +00:00
"title": "Add load_from_file method",
Open workflow step editors as preview tabs (#15928)
This PR opens workflow step editors as preview tabs and closes them upon
exiting the step if they are still in preview mode and they weren't
already open before entering the step.
Making this work was tricky, because we often edit the buffer as part of
displaying the workflow step suggestions to create empty lines where we
can generate. We undo these edits if the transformation is not applied,
but they were causing the preview to be dismissed.
After trying a few approaches, I decided to give workspace `Item`s a
`preserve_preview` method that defaults to false. When the workspace
sees an edit event for the item, it checks if the item wants to preserve
its preview. For buffers, after editing, you can call `refresh_preview`,
which sets a preview version to the current version of the buffer. Any
edits after this version will cause preview to not be preserved.
One final issue is with async auto-indent. To ensure these async edits
don't dismiss the preview, I automatically refresh the preview version
if preview was preserved prior to performing the auto-indent. The
assumption is that these are edits created by other edits, and if we
didn't want to dismiss the preview with the originating edits, then the
auto-indent edits shouldn't dismiss it either.
Release Notes:
- N/A
---------
Co-authored-by: Jason <jason@zed.dev>
2024-08-08 01:33:58 +00:00
"suggestions": [
2024-07-29 18:21:19 +00:00
{
"kind": "PrependChild",
"path": "src/config.rs",
2024-08-19 17:01:45 +00:00
"symbol": "#imports",
2024-07-29 18:21:19 +00:00
"description": "Import std::fs and std::io modules"
},
{
"kind": "AppendChild",
"path": "src/config.rs",
"symbol": "impl Config",
"description": "Add load_from_file method"
}
]
}
2024-08-15 19:46:19 +00:00
</output>
</example>
2024-07-29 18:21:19 +00:00
2024-08-15 19:46:19 +00:00
<example>
<workflow_context>
<message role="user">
2024-07-29 18:21:19 +00:00
```rs src/database.rs
pub(crate) struct Database {
connection: Connection,
}
impl Database {
fn new(url: &str) -> Result<Self, Error> {
let connection = Connection::connect(url)?;
Ok(Database { connection })
}
async fn query(&self, sql: &str) -> Result<Vec<Row>, Error> {
self.connection.query(sql, &[])
}
}
```
2024-08-15 19:46:19 +00:00
</message>
<message role="assistant">
2024-07-29 18:21:19 +00:00
<step>Add error handling to the 'query' method and create a custom error type</step>
2024-08-15 19:46:19 +00:00
</message>
</workflow_context>
<step_to_resolve>
Add error handling to the 'query' method and create a custom error type
</step_to_resolve>
2024-07-19 09:13:15 +00:00
2024-08-15 19:46:19 +00:00
<output>
2024-07-29 18:21:19 +00:00
{
2024-08-01 15:48:56 +00:00
"title": "Add error handling to query",
Open workflow step editors as preview tabs (#15928)
This PR opens workflow step editors as preview tabs and closes them upon
exiting the step if they are still in preview mode and they weren't
already open before entering the step.
Making this work was tricky, because we often edit the buffer as part of
displaying the workflow step suggestions to create empty lines where we
can generate. We undo these edits if the transformation is not applied,
but they were causing the preview to be dismissed.
After trying a few approaches, I decided to give workspace `Item`s a
`preserve_preview` method that defaults to false. When the workspace
sees an edit event for the item, it checks if the item wants to preserve
its preview. For buffers, after editing, you can call `refresh_preview`,
which sets a preview version to the current version of the buffer. Any
edits after this version will cause preview to not be preserved.
One final issue is with async auto-indent. To ensure these async edits
don't dismiss the preview, I automatically refresh the preview version
if preview was preserved prior to performing the auto-indent. The
assumption is that these are edits created by other edits, and if we
didn't want to dismiss the preview with the originating edits, then the
auto-indent edits shouldn't dismiss it either.
Release Notes:
- N/A
---------
Co-authored-by: Jason <jason@zed.dev>
2024-08-08 01:33:58 +00:00
"suggestions": [
2024-07-29 18:21:19 +00:00
{
"kind": "PrependChild",
"path": "src/database.rs",
"description": "Import necessary error handling modules"
},
{
"kind": "InsertSiblingBefore",
"path": "src/database.rs",
"symbol": "pub(crate) struct Database",
"description": "Define custom DatabaseError enum"
},
{
"kind": "Update",
"path": "src/database.rs",
"symbol": "impl Database async fn query",
"description": "Implement error handling in query method"
}
]
}
2024-08-15 19:46:19 +00:00
</output>
</example>
</examples>
2024-07-29 18:21:19 +00:00
Open workflow step editors as preview tabs (#15928)
This PR opens workflow step editors as preview tabs and closes them upon
exiting the step if they are still in preview mode and they weren't
already open before entering the step.
Making this work was tricky, because we often edit the buffer as part of
displaying the workflow step suggestions to create empty lines where we
can generate. We undo these edits if the transformation is not applied,
but they were causing the preview to be dismissed.
After trying a few approaches, I decided to give workspace `Item`s a
`preserve_preview` method that defaults to false. When the workspace
sees an edit event for the item, it checks if the item wants to preserve
its preview. For buffers, after editing, you can call `refresh_preview`,
which sets a preview version to the current version of the buffer. Any
edits after this version will cause preview to not be preserved.
One final issue is with async auto-indent. To ensure these async edits
don't dismiss the preview, I automatically refresh the preview version
if preview was preserved prior to performing the auto-indent. The
assumption is that these are edits created by other edits, and if we
didn't want to dismiss the preview with the originating edits, then the
auto-indent edits shouldn't dismiss it either.
Release Notes:
- N/A
---------
Co-authored-by: Jason <jason@zed.dev>
2024-08-08 01:33:58 +00:00
Now generate the suggestions for the following step:
2024-08-15 19:46:19 +00:00
<workflow_context>
{{{ workflow_context }}}
</workflow_context>
<step_to_resolve>
{{{ step_to_resolve }}}
</step_to_resolve>