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

code intel: Remove search context from search based code intel #58010

Merged
merged 2 commits into from Nov 1, 2023

Conversation

fkling
Copy link
Contributor

@fkling fkling commented Oct 31, 2023

Fixes #58006

Using search context is problematic when viewing a file/repo that is not part of the selected search context, which can happen when a custom default context is set.

It doesn't seem necessary to include the search context. The query I looked at now doesn't have the context set anymore. Example:

^append$ type:symbol patternType:regexp count:50 case:yes file:\.(go)$ repo:^github.com/sourcegraph/sourcegraph$ index:only

I wasn't able to verify all code paths though.

Test plan

Hover over append in https://sourcegraph.test:3443/github.com/sourcegraph/sourcegraph/-/blob/cmd/frontend/internal/own/resolvers/resolvers.go?L145:9 and see that the request doesn't contain a search context.

@fkling fkling requested review from olafurpg and a team October 31, 2023 10:40
@cla-bot cla-bot bot added the cla-signed label Oct 31, 2023
@olafurpg
Copy link
Member

Tagging @keynmol @varungandhi-src for review instead of myself

@fkling fkling removed the request for review from olafurpg October 31, 2023 10:43
@sourcegraph-bot
Copy link
Contributor

sourcegraph-bot commented Oct 31, 2023

📖 Storybook live preview

Using search context is problematic when viewing a file/repo that is not
part of the selected search context, which can happen when a custom
default context is set.

It doesn't seem necessary to include the context. The query I looked at
now doesn't have the context set anymore. Example:

    ^append$ type:symbol patternType:regexp count:50 case:yes file:\.(go)$ repo:^github.com/sourcegraph/sourcegraph$ index:only

I wasn't able to verify all code paths though.
@fkling fkling force-pushed the fkling/search-based-code-intel-default-context branch from 58754fd to c6deaa3 Compare October 31, 2023 10:47
@varungandhi-src
Copy link
Contributor

varungandhi-src commented Nov 1, 2023

Using search context is problematic when viewing a file/repo that is not part of the selected search context, which can happen when a custom default context is set.

So should we avoid setting the search context only in the specific situation when a custom default context is set?


Consider the situation where someone navigated to a file with an explicit search context where the search is limited only to certain subdirectories (say because they work in a large monorepo). Then they perform a hover on a symbol. Is your point that for code intel, we should ignore their context and show results in other directories too for the sake of completeness?

@fkling
Copy link
Contributor Author

fkling commented Nov 1, 2023

@varungandhi-src

Consider the situation where someone navigated to a file with an explicit search context where the search is limited only to certain subdirectories (say because they work in a large monorepo). Then they perform a hover on a symbol. Is your point that for code intel, we should ignore their context and show results in other directories too for the sake of completeness?

Yes, although it's less about completeness for me and more about predictability/reproducibility. E.g. in your scenario if I refreshed the page my default context would be set and I would get different search based code intel information. I think it's not obvious to users that their currently selected search context affects search based code intel results and that it's not too difficult to get into a situation where this can even lead to "not results".

Copy link
Member

@camdencheek camdencheek 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 to me! Thanks for the find and the fix

@fkling fkling merged commit 9f6eea0 into main Nov 1, 2023
11 of 12 checks passed
@fkling fkling deleted the fkling/search-based-code-intel-default-context branch November 1, 2023 19:44
vovakulikov pushed a commit that referenced this pull request Dec 12, 2023
Using search context is problematic when viewing a file/repo that is not
part of the selected search context, which can happen when a custom
default context is set.

It doesn't seem necessary to include the context. The query I looked at
now doesn't have the context set anymore. Example:

    ^append$ type:symbol patternType:regexp count:50 case:yes file:\.(go)$ repo:^github.com/sourcegraph/sourcegraph$ index:only

I wasn't able to verify all code paths though.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"No hover information available" for search based code intel and custom search context
5 participants