-
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: code smell command, display commands error in chat #602
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.
I gave the tab complete behaviour a go locally, and looks like it needs a small fix to allow you to hit enter after hitting tab to complete.
I noticed nothing happens if I execute /explain without anything selected. It seems intuitive to me to use the currently open file as context in this case.
I don't think we want to do this so generically — it looks like if you use /document
with no code selected (but a file open) it now tries to explain the whole file?
And if we scope it to explain: how good is the experience explaining a whole file, vs nudging them to select a specific bit of code? Should we consider cursor position too?
I think it makes sense to display any errors (like you need to have something selected) as a response in the chat, rather than as a separate error pop-up
Yeah, if you're triggering it from the chat window that is nice. Not sure if we want it as permanent part of the transcript though? More like a small error overlay that pops up above the compose box and hides after 5 seconds?
When you trigger stuff in-editor, without the chat window open, it would be nice if we didn't focus our chat pane if we didn't need to (add documentation, do an edit, etc). In that case, we'd want to keep the current behaviour of a native notification.
(Maybe worth breaking out the small tab completion fix from the rest?)
@toolmantim I think i used the wrong selection. Instead of selection or entire file, it should be selection or visible content, do you think that makes more sense? (Will take a look and make an update tomorrow if that sounds good to you) |
@toolmantim and what do you think about using visible content for i think what you said about (I just reread beyang's message and I think I misunderstood his message. Will continue tomorrow 🫠) |
( removing beyang as reviewer for now ) |
I'm not sure! I didn't meant to suggest the code in the PR was wrong… it definitely works as advertised. I was more just wanting to check if the results it was returning was good? I was getting mixed results when I quickly tested it locally, and wasn't sure if it was a default path we wanted to push people down. But I think what you've done matches what @beyang was suggesting, and it matches the context UI that's below the message box (the part that shows the current file) Maybe it would be better if we took into account editor cursor as well (and make sure the context UI updates when you move lines)? That would hugely help for |
With how the errors are displayed, we already have an in-chat error mechanism for when we executing multiple recipes at once: ![]() We should avoid adding yet another way of showing errors. We're still going to need to use VS Code native ones for in-editor experiences (if we keep the chat sidebar hidden). Here's a better in-chat error design for something we can use for both the above error message, a Screen.Recording.2023-08-08.at.5.53.39.pm.movThis avoids cleaning the input box, making it an expensive mistake for the user. Instead it keeps the input box and cursor unchanged, so you can go select code and easily try again… a nice fast & snappy feedback loop, helping people to just click around and try commands without it feeling too heavyweight if they make a mistake. |
Thanks for the thorough testing TIm! Much appreciated 🙇♀️
I will clarify with Beyang but I think I misunderstood his initial feedback. I think was talking about /explain specifically and not /doc and /test, so that was my bad 😅
@toolmantim P.S. We can update the existing error banner style to what you have in the design in another PR |
Yeah, I think the error banner is more appropriate in this context… even a terminal application might do smart things to not clear your REPL input buffer on validation fail. But definitely keen to hear any strong opinions otherwise! |
@beyang @toolmantim I've updated the PR so that:
I've also updated the walkthrough to replace recipes and commands. |
@@ -10,10 +10,9 @@ | |||
}, | |||
"Explain Code": { | |||
"slashCommand": "explain", | |||
"prompt": "Explain what the selected code does in simple terms. Assume the audience is a beginner programmer who has just learned the language features and basic syntax. Focus on explaining: 1) The purpose of the code 2) What input(s) it takes 3) What output(s) it produces 4) How it achieves its purpose through the logic and algorithm. 5) Any important logic flows or data transformations happening. Use simple language a beginner could understand. Include enough detail to give a full picture of what the code aims to accomplish without getting too technical. Format the explanation in coherent paragraphs, using proper punctuation and grammar. Write the explanation assuming no prior context about the code is known. Do not make assumptions about variables or functions not shown in the shared code.", | |||
"prompt": "Explain what the selected code does in simple terms. Assume the audience is a beginner programmer who has just learned the language features and basic syntax. Focus on explaining: 1) The purpose of the code 2) What input(s) it takes 3) What output(s) it produces 4) How it achieves its purpose through the logic and algorithm. 5) Any important logic flows or data transformations happening. Use simple language a beginner could understand. Include enough detail to give a full picture of what the code aims to accomplish without getting too technical. Format the explanation in coherent paragraphs, using proper punctuation and grammar. Write the explanation assuming no prior context about the code is known. Do not make assumptions about variables or functions not shown in the shared code. Start the answer with the name of the code that is being explained.", | |||
"context": { |
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.
s/context/requiredContext/
perhaps?
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.
Keeping this as it is for now if that's not an issue, as we already have users setting up commands with this field.
Co-authored-by: Beyang Liu <beyang@sourcegraph.com>
Co-authored-by: Beyang Liu <beyang@sourcegraph.com>
PR to move items from pull/602 to the unreleased section. I forgot to update the changelog before I merged #602, which was not included in 0.6.6 release. ## Test plan <!-- Required. See https://docs.sourcegraph.com/dev/background-information/testing_principles. --> changelog updated
RE feedback from beyang:
This PR includes the following change:
/explain
&/smell
command, run on visible content when there is no selection in the current text documentSome UI changes were moved to separate PRs
See moved to #606 & #648
alt+c
as it was using the same key ascody.fixup.new
Test plan
See the complete demo:
all.changes.covered.in.pull_602.mp4
/doc
without code selection - error expected/exit
- error expected/explain
andsmell
without code selection - both show work with visible contentCody Menu
button in the cody intro should open the command menu for youalt+c
should bring up the command menu