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

search: highlight repository matches in RepoSearchJob#41470

Merged
tbliu98 merged 7 commits into
mainfrom
tl/repo-match-ranges
Sep 8, 2022
Merged

search: highlight repository matches in RepoSearchJob#41470
tbliu98 merged 7 commits into
mainfrom
tl/repo-match-ranges

Conversation

@tbliu98

@tbliu98 tbliu98 commented Sep 7, 2022

Copy link
Copy Markdown
Contributor

Part of #18374

As part of RepoSearchJob execution, get the ranges of the repo name that match any of RepoOpts.RepoFilters, and return those ranges to the client to be highlighted on repository match results.

Screen Shot 2022-09-07 at 4 37 17 PM

Screen Shot 2022-09-07 at 4 37 46 PM

Screen Shot 2022-09-07 at 4 39 30 PM

Test plan

Added unit test
Manual testing to feel good about the addition
CI

@cla-bot cla-bot Bot added the cla-signed label Sep 7, 2022
@tbliu98 tbliu98 requested review from a team, camdencheek and rvantonder September 7, 2022 21:42
@sourcegraph-bot

sourcegraph-bot commented Sep 7, 2022

Copy link
Copy Markdown
Contributor

Codenotify: Notifying subscribers in CODENOTIFY files for diff aa0b3fe...9d076e4.

Notify File(s)
@beyang internal/search/job/jobutil/job.go
internal/search/job/jobutil/repos.go
internal/search/job/jobutil/repos_test.go
internal/search/result/merger.go
internal/search/result/repo.go
internal/search/streaming/http/events.go
@camdencheek cmd/frontend/internal/search/search.go
internal/search/job/jobutil/job.go
internal/search/job/jobutil/repos.go
internal/search/job/jobutil/repos_test.go
internal/search/result/merger.go
internal/search/result/repo.go
internal/search/streaming/http/events.go
@fkling client/search-ui/src/components/RepoSearchResult.tsx
client/shared/src/search/stream.ts
@keegancsmith cmd/frontend/internal/search/search.go
internal/search/job/jobutil/job.go
internal/search/job/jobutil/repos.go
internal/search/job/jobutil/repos_test.go
internal/search/result/merger.go
internal/search/result/repo.go
internal/search/streaming/http/events.go
@limitedmage client/search-ui/src/components/RepoSearchResult.tsx

@limitedmage limitedmage left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Frontend changes look good!

Comment thread CHANGELOG.md Outdated
Comment thread internal/search/job/jobutil/repos.go Outdated

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.

Agree that it's not ideal 😄 Seems really strange for the ranges returned from the API to not actually be directly applicable to the repo names. How difficult would it be to change the ranges when we trim the code host in the client?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

How difficult would it be to change the ranges when we trim the code host in the client?

I don't know, I thought about it briefly, but it seemed like it would be potentially more intrusive than just doing this. 🙈 I don't expect that we're going to change how we display repo names anytime soon which made me feel better about going this route

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.

I don't think this should be a blocker, but I do think it's worth looking into. If you're not going to dig into this immediately, could you open a github issue for it? This feels like it's happening on the wrong layer, and that becomes more important if we ever have other consumers like Code Insights using this. We're running into issues like this left and right with code insights right now, so I'd rather not add more 🙂

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Comment thread internal/search/job/jobutil/repos_test.go Outdated
Comment thread internal/search/result/repo.go Outdated

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.

Is this condition correct? Consider repo:contains.path(abc) and repo:def. Don't we still want to highlight def?

@tbliu98 tbliu98 Sep 7, 2022

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think it is correct, for something like repo:contains.path(abc) and repo:def there will only be one RepoSearchJob and path will be appended to RepoOptions.HasFileContent for that job. So there shouldn't need to be merging of results since that repo will only be found once

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

oh wait, maybe not. stand by

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Okay never mind, this condition should be right, but there are some other places in the search backend outside of RepoSearchJob where we return a RepoMatch and if one of those paths is hit, that repo match will not be highlighted. Will follow up to address that

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.

for something like repo:contains.path(abc) and repo:def there will only be one RepoSearchJob

Yes, you're right -- bad example 😄

But what about repo:contains.path(abc) or repo:def (which also uses the merger)? I think we still want the highlights from repo:def even if the result we're merging into has no highlights.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes indeed, removed the if check

@tbliu98 tbliu98 force-pushed the tl/repo-match-ranges branch from 5d77148 to 7fdde69 Compare September 7, 2022 23:19
@tbliu98 tbliu98 changed the title search: highlight repository matches search: highlight repository matches in RepoSearchJob Sep 7, 2022
@tbliu98 tbliu98 merged commit b7b9d52 into main Sep 8, 2022
@tbliu98 tbliu98 deleted the tl/repo-match-ranges branch September 8, 2022 13:50
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.

4 participants