-
Notifications
You must be signed in to change notification settings - Fork 209
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: use selectionRange in edits when available #1429
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
CC @arafatkatze so we can work out the intent... Do we want to broaden selections, when there's an explicit selection? It is a bit surprising when it changes.
@dominiccooney @abeatrix Thanks for message and a PR. A couple of thoughts A. Original Problem & Intention: The primary intention behind the "Smart Selection" was to tackle some prevalent edge cases, as described in issues #585 and #223. The primary challenge was to ensure that the selection made by users encompassed the entirety of the code regions that required a fixup, ensuring comprehensiveness in the changes. Some of the pertinent edge cases included( From my original pr that used an LLM based selection algorithm): B. I understand that the new PR aims to respect user selection, especially when it's explicit. However, it seems like the new approach, in trying to rectify one problem, effectively negates the core functionality of the "Smart Selection" feature. Coz if user selection is made then smart selection is avoided and if user selection is NOT made then the add recipe is used. cody/vscode/src/non-stop/FixupController.ts Lines 205 to 219 in f8fc7e5
This could inadvertently reintroduce the original edge cases we were striving to eliminate coz the smart selection code is basically never run for fixup recipe. Possible Solutions:Given the above, I'd like to propose a couple of solutions to ensure we achieve a balanced outcome:
While I completely understand and respect the rationale behind the regression fix and it makes a lot of sense why it was done, tt would be nice to consider the original intent of smart selection. |
@arafatkatze thanks for the detail response and for clarifying, really appreciate it. I think the original problem was fix up with " Empty Selections don't work", and your PR addressed the issue perfectly, where we use Smart Selection when selection is empty. However, using user selection was never the issue iirc. As for the second issue you linked, it was referring to the edit action through code action, which has already been addressed by a separate PR released in last stable version. I like your second point though, maybe something we could add to the new "regenerate" code lens? Wdyt? |
@abeatrix Thanks for pointers, these are some good questions. I will try best to be concise here.
Right now, in the case of empty selection the intent of the fixup changes to cody/vscode/src/non-stop/FixupController.ts Lines 217 to 219 in f8fc7e5
You can see that incase of empty selection the 'add' intent is returned.
Makes sense
#1383 is a very interesting PR. I really liked the narrative behind it but I can understand why currently you folks decided not to support the error inclusions. My understanding that when users opt for a regenerate, it's predominantly due to dissatisfaction with the initial result, often expecting error resolutions or the result just didn't "understand" their intent. The causality for that could be
Personal opinion: I would find it unlikely if users just regenerate for no reason and expect LLM to give a different response which is "better" the next time around(See comment) In these cases, it might make a lot of sense to expand the selection. We could introduce a mechanism that quickly consults with a faster LLM, like Cloud Instant, just providing the error and its context or the user instruction + selected context for no errors. This could determine whether an expansion is feasible to address the error. This approach ensures we're not merely resending the same request but adapting and enhancing it for a better LLM output. That fast LLM check can potentially be used for other things as well, not just range expansion. @dominiccooney @abeatrix Is that something you folks would like to see? |
I think there's another causality, which is the prompt needs to be rewritten to clarify intent or to cater for a result from the LLM that the user hadn't anticipated. I'd suggest we investigate that in #1407 along with auto-apply first, and then investigate the idea of allowing users to include code errors from the file, or expanding the range. Or we look at solving the above causalities scoped only to "Ask Cody to Fix", and not to all fixups. |
Makes sense, that's a very common way to solve this problem.
Makes sense. Auto Apply would be a very useful feature coz the "friction" of pressing a button again AFTER having requested a fixup seems like an unwanted extra step. I would rather just get a result and undo it rather than press an extra button. I do have a question. When the auto apply fixup is working and people are using it. What needs to happen so that you folks consider the possibility of code error inclusion or range expansion? Coz that task seems unrelated to fixup codelenses changes discussed in #1407 Its more about UI experience rather than the quality of the results and the quality of results depends on the context included in the prompt(Code Expansion/Error inclusion matter in that).
Very fair point, "Ask cody to fix" already does error inclusion and range expansion to solve the problem so it's already taking all the cases into account. |
Fix regression caused by changes in #1317
The commit fixes an issue where getSmartSelection was always recalculating a selection even when a valid selectionRange was already provided.
Currently, the /edit command does not respect user selection when it's available:
broken_edit.mov
This becomes an issue as folding range is still in the experimental stage. It also cause the code lens to jump around, unless it's intended as I haven't read through the PR 馃槄
This PR adds a check to use selectionRange when it is available and not an empty range.
This provides a fallback in case where "smart" selection is not working for users.
Test plan
Select code in your editor and run the /edit command, the range should not be expanded for you.