isker / neogrok

Neogrok is a frontend for zoekt, a fast and scalable code search engine.
https://neogrok-demo-web.fly.dev
MIT License
28 stars 2 forks source link

Asking for a feature to view files or shortcut to change context. #26

Open mehovc opened 5 months ago

mehovc commented 5 months ago

I'm loving neogrok! Such an amazing UI, much better than native zoekt. I've already written a comment on HN, but just in case you don't use HN very often I'm asking for a feature here:) Sometimes I need to see a more broad context of my search like 20 lines above and below of the match. I just simply open file in zoekt and read code from there. I can change context to more lines, but it kind feels terrible when you found your match you have to go to beginning of the page change context and then find the match again to see things around.

Sorry, it's my first time asking for a feature, not sure how it should be done properly. Also english is not my primary language:)

In case you don't have time I can try to implement it myself and create a PR, but it gonna get some time because I've never worked with typescript

isker commented 5 months ago

Hi, thanks for your interest. I agree that the ergonomics of the search UI are not great right now. I have no idea what I'm doing when it comes to building UI 🌞.

I am wondering whether the entire UI should be sticky so that it's always visible, as I mentioned in #23. A concern with that is that it might not work well on mobile devices (the search form is quite large relative to the screen size there). But mobile is not necessarily a big priority anyway; I just don't want to make it outright terrible.

I have not had a lot of time to work on this project lately so I can't say when I'd be able to get to this. If you want to try making changes, go for it. This is the relevant svelte component.

mehovc commented 5 months ago

thank you!

isker commented 5 months ago

As for your question on HN:

is there any way to open file like in zoekt? it's so much better than native zoekt ui except this:(

I didn't actually know the builtin web UI of zoekt-webserver could do that. I will have to take a look at it some time.

The zoekt-webserver API does not expose anything like this. They may just be doing something hacky in the web UI: making a search query for an exact file/repo match with very large context and hoping they get a single search result file for that query, and using it to render the "full" file.

I've considered doing something like that in neogrok that in the past, but I decided I didn't want to do it because of how weird it feels 🌞. Linking out to GitHub (or whatever other VCS "forge" is configured during zoekt indexing) felt better to me.

mehovc commented 5 months ago

wait, there's a way to open file in vcs?

mehovc commented 5 months ago

oh, i see links on demo, but I don't have them when I run it locally, what could be the cause? i'm running
zoekt-git-index -index index $repo zoekt-webserver --index index -rpc true

mehovc commented 5 months ago

running private gitlab repos. Strange, but this output of version commands zoekt-git-index --version zoekt-git-index version ""

zoekt-webserver --version zoekt-webserver version ""

mehovc commented 5 months ago

looks like zoekt-git-index problem, when i copied neogrok repo it gave me links to github. Gonna take a look at zoekt-git-index.

isker commented 5 months ago

https://github.com/sourcegraph/zoekt/blob/c39011a14191514737c52ab3f0e06348915c087e/gitindex/index.go#L209

Try running git config zoekt.web-url-type etc according to this code and seeing if you can make it work that way. If you look lower in that file, it seems to only autodetect a few things like github.com.

mehovc commented 5 months ago

hah, i already patched zoekt-git-index to handle my private gitlab url ahah. I'll checkout zoekt.web-url-type, thank you!

cpfeiffer commented 5 months ago

FWIW, see https://github.com/sourcegraph/zoekt/blob/main/doc/indexing.md for the the git config options that are read from the repository. The documented supported values for zoekt.web-url-type are not quite complete anymore though, see here for all possible values.

I made sure to set name, web-url and web-url-type in the repositories passed to zoekt-git-index, and links to the files in gitlab show up just fine in neogrok.

mehovc commented 5 months ago

hi! The problem was related to ssh. I'm using ssh to clone repo, it tries to treat ssh as url and fails to parse it. I actually hardcoded mapping from ssh -> https (here), also added my private gitlab url here

Probably there's a better way to handle it, but I just wanted a quick solution:)