-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Cody Context: Better usage of editor selection and UI update #53742
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.
Love it!! Great work on making it feel so responsive too.
Looks like you might have an off-by-one error on the line number though:
Screen.Recording.2023-06-20.at.8.57.58.pm.mov
@toolmantim Thanks for testing, have just fixed that now! (think we caught it at the same time :D) |
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.
Working well for me! 👍🏼 from the UI & design side of things.
I do have a question though…
What's the difference between having my cursor on a line:
![Screenshot 2023-06-20 at 9 08 07 pm](https://private-user-images.githubusercontent.com/153/247096108-8762672d-3540-4bc3-9161-5f98e55ae1e3.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTkxNjg5OTEsIm5iZiI6MTcxOTE2ODY5MSwicGF0aCI6Ii8xNTMvMjQ3MDk2MTA4LTg3NjI2NzJkLTM1NDAtNGJjMy05MTYxLTVmOThlNTVhZTFlMy5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwNjIzJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDYyM1QxODUxMzFaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1jNzRiZWIyMzJiYTAyNjM3OTdhNzhlZjE0MjY2NmVmNDE5YTk2MGVjOTM1MGRlY2E5NjFhZTMzNDE0YTRlMmU2JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.yaip-7gjeANrtfysOGbUncP0uagcj-OOdUaRx2s9AB4)
and selecting the line:
![Screenshot 2023-06-20 at 9 08 21 pm](https://private-user-images.githubusercontent.com/153/247096154-cf3fe8a6-c635-4081-9d86-ce040595e640.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTkxNjg5OTEsIm5iZiI6MTcxOTE2ODY5MSwicGF0aCI6Ii8xNTMvMjQ3MDk2MTU0LWNmM2ZlOGE2LWM2MzUtNDA4MS05ZDg2LWNlMDQwNTk1ZTY0MC5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwNjIzJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDYyM1QxODUxMzFaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT0xNDZkMDNjZGM5N2Y1ZTYzN2M1ODNiMzQ5YmIxYTFjN2I2MzUwNGVmMTNhZWNkNDY5NDI2YTNlN2IyYTUyYzJhJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.DRt0XjS7xeorPJUv6HpPaFKqsqqj1_FPSVWnMNz4v7I)
I would have naively assumed it would be the same thing. But do they affect the results you get?
If this design makes sense though, I'm pondering if a tooltip on the context item could help them master using Cody… something like, "The whole of ${file}" and "Lines ${a}-${b} of ${file}" (or "Lines ${a}-${b} of ${file}, and some surrounding lines" if that's the case)
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.
NICE
@toolmantim Good question! Right now, we only provide Cody context when a user has explicitly selected some text. Having your cursor on a line, or over a variable doesn't have any effect right now. We could extend this to always use the current cursor position but I think that might be a bit too much. The cursor is almost always going to be somewhere, so we might over index on using that as useful context. I think the correct approach will be to use code intelligence to include the cursor position when it is on a useful symbol (e.g. a variable). This should be possible in the future, I believe #team-cody-context is working on improving this, but will check |
Description
This PR improves how Cody uses the current editor selection and displays it is part of the UI.
UI Changes:
We now display the selected lines against the file in the context footer. I went with
start.line-end.line
but happy to tweak if others feel a better UI would work.Alternatives I considered:
start.line:start.character-end.line:end.character
(feels too noisy/verbose)L(start.line)-L(end.line)
Prompt changes:
We have always included the editor selection if present, but now we include it as the last piece of context. Cody uses it a lot more consistently now. I think this makes sense: broad context (embeddings) -> file context (editor contents) -> selection context (selection contents).
Example improvement:
Test plan
Tested various prompts with different editor selections.