-
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: Add intent hover text #52029
Cody: Add intent hover text #52029
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.
Thanks for the contribution @deepak2431!
There are some internal discussions about the usefulness of the hallucination detection the way we have it right now but that aside, I think it would be helpful to add some form of a label in the meantime so we actually explain what this means to the user.
I noticed that it looks a bit janky to add the inline text in your video. Have you tried using position: absolute
and make it look more like a tooltip instead?
You also seem to be hardcoding some colors there. Since we have to support various VS Code color themes, it would be great if you can look up VS Code color theme variable names instead. There's a cool extension I use for this: https://marketplace.visualstudio.com/items?itemName=GitHubOCTO.spectrum
Another concern I have is accessibility but I doubt we'll be able to fix this without changing the markup 😢 and I really don't want to make the markup more complex because it already can leak in some scenarios
Thanks for the review again @philipp-spiess 😀. Haven’t tried with the absolute positioning but yeah let me try that and make it look much better more like a tooltip as you mentioned. I will update the color scheme, thanks for letting me know that we need to use vs code theme with the color as I used the one declared in the Cody-UI. Regarding the accessibility if you can let me know about some pointers to consider, I can look into if it can be possible using CSS styles. Again, A big thanks for looking into all of my PR’s and helping to get it reviewed! |
The issue is Normally in a website you'd want to make sure you can tab to the item and have an aria-label or so to have the screenreader explain this. We'll need to change the markup for this though which is something I don't want us to do right now without fixing the bug where the markup is not rendered in inline blocks at all 🙃 Consider the following result from Cody right:
Right now this will trigger the hallucination detection logic that will replace the content before the markdown is parsed to something like this:
This, however will result in the |
@philipp-spiess That makes sense. I was thinking of accessibility you mentioned previously in terms of the view of hover text, color etc. But yeah this hover can cause the issue in some devices. I have seen the story of your markdown when you was working with the HTMl entities bug. I hope down the line we would definitely be able to handle this too with a better markdown 😊 |
REC-20230518231904.mp4@philipp-spiess Updated the CSS. It looks much better now, I think. |
@deepak2431 Okay this is pretty slick indeed! 😮 Only thing I am wondering now is if we should include a bit more context in the text. Paging the rest of the cody reviewers to think about this too :) |
client/cody/webviews/Chat.module.css
Outdated
:global(.token-not-hallucinated):hover:after { | ||
content: "This file exists"; | ||
} | ||
|
||
:global(.token-hallucinated):hover:after { | ||
content: "This file does not exist"; | ||
} |
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 wonder if we should add more context here. Is "hallucination detection" a customer facing name we have for this feature? It's already really unclear what this is doing and just saying "file exists" is still confusing. cc @mrnugget
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.
@deepak2431 Okay this is pretty slick indeed! 😮
Only thing I am wondering now is if we should include a bit more context in the text. Paging the rest of the cody reviewers to think about this too :)
Thanks, @philipp-spiess . Sure, will wait for the comment from @mrnugget on what he thinks should be the updated content text.
Thanks so much for the PR @deepak2431! 🙏🏼 @philipp-spiess @mrnugget I've checked this out locally, and have a suggested design: Screen.Recording.2023-05-30.at.5.08.05.pm.movSome notes on what's included there:
Colors used:
|
@toolmantim Thanks for looking into this; the updated design looks awesome! Let me make the changes. |
…o deepak/cody-intent-highlight
@toolmantim For the hallucinated files, the colour you mentioned is white, but in the new UI video looks yellow. So, can I use this colour for the hallucinated files: |
…o deepak/cody-intent-highlight
@toolmantim Made all the suggested changes. Here's how the updated version looks: REC-20230530224537.mp4Edit: Tests are fixed!!! |
…o deepak/cody-intent-highlight
@toolmantim It's all good for final review now. |
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.
Thanks @deepak2431! I tested locally, and left some fixes in suggestions.
It won't make sense to use the word "Open file" and color them as links until they're actually linked properly (e.g. <a href="vscode://file/(path)">(token)</a>
). But that seems more involved, and we can get this PR out now to at least improve the styles and titles.
@@ -88,7 +88,10 @@ function highlightLine(line: string, tokens: HighlightedToken[]): string { | |||
|
|||
function getHighlightedTokenHTML(token: HighlightedToken): string { | |||
const isHallucinatedClassName = token.isHallucinated ? 'hallucinated' : 'not-hallucinated' | |||
return ` <span class="token-${token.type} token-${isHallucinatedClassName}">${token.outerValue.trim()}</span> ` | |||
const title = token.isHallucinated ? 'Hallucination detected: file does not exist' : 'Open file' |
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.
const title = token.isHallucinated ? 'Hallucination detected: file does not exist' : 'Open file' | |
const title = token.isHallucinated ? 'Hallucination detected: file does not exist' : 'No hallucination detected: file exists' |
If you could update the PR description to have some before and after screenshots too, that would be great for people understanding the changeset. Thank you! |
…o deepak/cody-intent-highlight
@toolmantim Thanks for the review. I have made all the changes as per your review. Also, I added the before and after screenshots in the PR description. |
@toolmantim Also, that makes sense to me about the href to non-hallucinated files you mentioned. Also, I feel that the current implementation for detecting hallucinated/non-hallucinated files needs improvement as it identifies the files that also exist as Hallucinated. But yeah, this would be part of other PR. |
Thanks so much 👏🏼 I'll review this for you shortly!
Is there an issue filed for this? Would love some repro steps if possible! |
Sure, Take your time! I don't think that there's any issue created for this. But the files mentioned it is present here. Shall I open an issue for this? |
Hrmm, that's not good. If you could open an issue that would be great. Thanks! |
Sure, will open an issue for it. |
@toolmantim Resolved the conflicts of this PR, can we get this merged if it's all good? |
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.
client/cody/webviews/Chat.module.css
Outdated
} | ||
|
||
:global(.token-not-hallucinated) { | ||
border-bottom: 2px solid var(--vscode-testing-iconPassed); | ||
word-break: break-all; | ||
text-decoration: 1px dashed underline var(--vscode-testing-iconPassed); |
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.
text-decoration: 1px dashed underline var(--vscode-testing-iconPassed); | |
text-decoration: underline |
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.
Now that main has updated to actually link files, we need to make one final switch.
I just checked this out locally, merged main, and made the suggested change… and it looks good. Once that's in, it's good to go! 🙌🏼
![]()
Thanks for having a look @toolmantim. I will make those changes soon, and update you!
@toolmantim Updated the CSS as per your suggestions. |
@toolmantim All good in this PR? As I can see the build falling again here! |
Addressed in the subsequent changes
This PR closes #51633. It added hover text to different intent detection files. ## Test plan Before: Just plain border for the hallucinated and non-hallucinated files. ![iScreen Shoter - Code - 230604104911](https://github.com/sourcegraph/sourcegraph/assets/44617923/0a5f6d51-dc41-492c-bf8f-228726bf068b) After: A nice border, with the title "Hallucination detected: file does not exist" for hallucination files and "No hallucination detected: file exists" for non-hallucinated files. https://github.com/sourcegraph/sourcegraph/assets/44617923/6e415e99-4d1a-48be-ae32-d683fd146b85 --------- Co-authored-by: Tim Lucas <t@toolmantim.com>
This PR closes #51633. It added hover text to different intent detection files.
Test plan
Before: Just plain border for the hallucinated and non-hallucinated files.
![iScreen Shoter - Code - 230604104911](https://private-user-images.githubusercontent.com/44617923/243154154-0a5f6d51-dc41-492c-bf8f-228726bf068b.jpg?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjE2MjA2OTAsIm5iZiI6MTcyMTYyMDM5MCwicGF0aCI6Ii80NDYxNzkyMy8yNDMxNTQxNTQtMGE1ZjZkNTEtZGM0MS00OTJjLWJmOGYtMjI4NzI2YmYwNjhiLmpwZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MjIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzIyVDAzNTMxMFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWUxM2QyNGU1MGRhY2UzN2NhYmRkYWQ0NzFjZWQzNTE3YTIxZTU2ODQyMTkzZjI3YjFkNTZkYTkyYmE5MDM3MmUmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0._V0zDlhfkkNXOlCiaTlpwBzkxByqliXcoh7Lcyn6EHQ)
After: A nice border, with the title "Hallucination detected: file does not exist" for hallucination files and "No hallucination detected: file exists" for non-hallucinated files.
REC-20230604104616.mp4