Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

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

Merged
fkling merged 2 commits into
mainfrom
fkling/search-based-code-intel-default-context
Nov 1, 2023
Merged

code intel: Remove search context from search based code intel#58010
fkling merged 2 commits into
mainfrom
fkling/search-based-code-intel-default-context

Conversation

@fkling

@fkling fkling commented Oct 31, 2023

Copy link
Copy Markdown
Contributor

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 a team and olafurpg October 31, 2023 10:40
@cla-bot cla-bot Bot added the cla-signed label Oct 31, 2023
@olafurpg

Copy link
Copy Markdown
Contributor

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

sourcegraph-bot commented Oct 31, 2023

Copy link
Copy Markdown
Contributor

📖 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

varungandhi-src commented Nov 1, 2023

Copy link
Copy Markdown
Contributor

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

fkling commented Nov 1, 2023

Copy link
Copy Markdown
Contributor Author

@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".

@camdencheek camdencheek left a comment

Copy link
Copy Markdown
Member

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
@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 subscribe to this conversation on GitHub. Already have an account? Sign in.

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