Skip to content
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

Use correct file sources instead of always showing 'embeddings' in chat context #2408

Merged
merged 12 commits into from
Jan 8, 2024

Conversation

DanTup
Copy link
Contributor

@DanTup DanTup commented Dec 15, 2023

Fixes #2244

Screenshot 2023-12-15 182047

Screenshot 2023-12-15 182154

fyi @kalanchan

Test plan

  • Select text in an editor and run a command like /explain that will include the context file from the editor
  • Hover and ensure the tooltip says the file was from the editor, not embeddings
  • Ask something that will cause the readme to be included automatically
  • However and ensure the tooltip does not say embeddings

Copy link
Contributor

@dominiccooney dominiccooney left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, but are we missing the 'search' source for symf?

@DanTup
Copy link
Contributor Author

DanTup commented Dec 22, 2023

Apparently I didn't submit my reply here.... Should there be a new entry in ContextFileSource?:

// tracked for telemetry purposes. Which context source provided this context file.
// embeddings: context file returned by the embeddings client
// user: context file provided by the user explicitly via chat input
// keyword: the context file returned from local keyword search
// editor: context file retrieved from the current editor
export type ContextFileSource = 'embeddings' | 'user' | 'keyword' | 'editor' | 'filename' | 'unified'

Or should it use an existing one like keyword?

This test was verifying the user-selected files showed up in the context widget, but this was not intended (see first line of #1858). They were still showing up because the source was not passed through correctly. Now it is, they don't show.
@DanTup
Copy link
Contributor Author

DanTup commented Dec 29, 2023

This change causes user-selected files to not show up in the context widget (before/after):

image

This seemed like a bug, but turns out to be deliberate (see first line of #1858) but wasn't working before because the source wasn't propagated to the chat correctly. Assuming the original reasoning still stands, I've removed the test that was trying to verify these appeared (which I added in another PR recently).

(@toolmantim @abeatrix let me know if I've made the right call here, or if you think we should include them here now)

Copy link
Contributor

@abeatrix abeatrix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think you've made the right call. Left a question regarding ContextFileSource for symf but other than that, looks good to me!

@@ -1187,6 +1187,8 @@ class ContextProvider implements IContextProvider {
return {
uri: displayUri,
range,
// TODO(dantup): Set source (a value from `ContextFileSource`) here.
// source: 'user',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we can create a new ContextFileSource called 'symf' since the results returned from symf is not determined by the user manually? wdyt?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that's what the comment above was about - do you know if a) it's safe for me to just add new values here (the type says they're used for analytics - I don't know if they need to match something at the other end), and b) whether any of the existing values are valid for symf or it needs a new one?

Thanks!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DanTup

a) it's safe for me to just add new values here (the type says they're used for analytics - I don't know if they need to match something at the other end)

That should be fine since the value can be any, i think the key is the important part haha

b) whether any of the existing values are valid for symf or it needs a new one?

I'd say we will need a new one because I don't see it fitting into any of the existing options: 'embeddings' | 'user' | 'keyword' | 'editor' | 'filename' | 'unified' , or do you find one they you think it'd match?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't, but I wasn't completely sure about the meaning of keyword and unified. I'll add symf, thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I just realised that Dominic suggested "search" and this shows up in the tooltip (plus some other things were renamed from "symf" to "search" according to the changelog), so I went with "search".

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yeah good points! For reference:

  • filename is referring to the results from the FilenameContextFetcher
  • keyword refers to the results from the keywordContextFetcher but i can't find it anymore, so I guess it's been removed and replaced by symf
  • unified refers to the results from the unifiedContextFetcher that I believe only Cody Web uses. We don't use it in VS Code.

@DanTup
Copy link
Contributor Author

DanTup commented Dec 29, 2023

@abeatrix let me know if using "search" (as noted above) seems reasonable, and if so (and the bots are green) I'll merge this. Thanks!

@abeatrix
Copy link
Contributor

@abeatrix let me know if using "search" (as noted above) seems reasonable, and if so (and the bots are green) I'll merge this. Thanks!

Yea I think that makes sense to me 👍

@DanTup
Copy link
Contributor Author

DanTup commented Dec 29, 2023

@dominiccooney merging is blocked on your review. I believe my recent change resolved your issue, but let me know if anything else needs changing. Thanks!

@DanTup
Copy link
Contributor Author

DanTup commented Dec 29, 2023

@abeatrix actually, now I'm a little confused.

In the top line at #1858 it says:

the context display widget should also include local context except the ones added by the user manually via @

And with my fix in this PR, the user-chosen files indeed don't show up. However, in the screenshots (eg. #1858 (comment)) it does still show the mentioned file - so I'm not certain what the intended functionality is now.

If the user types something like "Explain foo.dart", should the context widget show up with "foo.dart" listed in it?

@abeatrix
Copy link
Contributor

in the screenshots (eg. #1858 (comment)

@DanTup Oh that's because the screenshot you linked is context added for the explain command, which was not added by the user manually via @ . In those cases, I believe Tim wanted to include those under context last time we chatted on slack here: https://sourcegraph.slack.com/archives/C05AGQYD528/p1700638221936799?thread_ts=1700622656.385639&cid=C05AGQYD528

@abeatrix
Copy link
Contributor

But if the context was added via manual @ input, then i believe we do not want to include those in the context list if i'm not misunderstanding tim's message here: https://sourcegraph.slack.com/archives/C05AGQYD528/p1700631673836569?thread_ts=1700622656.385639&cid=C05AGQYD528

@DanTup
Copy link
Contributor Author

DanTup commented Jan 5, 2024

Great, thanks for confirming. I've re-merged main so it's all up-to-date. Needs @dominiccooney's stamp before it'll let me merge (I presume he's out this week).

@abeatrix
Copy link
Contributor

abeatrix commented Jan 8, 2024

Dismissed staled review request to unblock.

@abeatrix abeatrix merged commit b552a9a into main Jan 8, 2024
16 checks passed
@abeatrix abeatrix deleted the dantup/fix-missing-context-sources branch January 8, 2024 20:02
@DanTup
Copy link
Contributor Author

DanTup commented Jan 9, 2024

Thanks! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants