atlas-engineer / nyxt

Nyxt - the hacker's browser.
https://nyxt-browser.com/
9.79k stars 409 forks source link

Intelligently sorted prompt-buffer sources #2033

Open jmercouris opened 2 years ago

jmercouris commented 2 years ago

Pedro pointed out to me recently that when using set-url, what may happen is you are given many duck duck go search suggestions. However, at the same time, you may have something in your history that perfectly matches what you've typed in.

The result is that you have to jump or arrow down to the next source to find what you are looking for. A potential solution to this problem may be a way to dynamically sort sources in a prompt buffer based on some heuristic. For example; source A is 95% confident it has a match, and source B is only 80% confident it has a match, therefore source A should go first.

We could limit this dynamic sorting to the FIRST source in the prompt buffer, OR sort all sources by confidence/the heuristic.

What do you think? @Ambrevar

jmercouris commented 2 years ago

@pdelfino

Ambrevar commented 2 years ago

I've also been annoyed by this, but I'm a bit unsure about the proposed solution: I'd rather have reliable source order than something I don't control.

Allow me to propose something else. Add an option to trim some sources: only display 5 suggestions for the new-url-query source, then an ellipsis somewhere. When the user reaches the last suggestion or hit a special key, the rest of the source is expanded.

Does that make sense?

Another "fix" would be support for a vertical prompt buffer.

guojing0 commented 2 years ago

I also encountered this and gave it some thoughts as well: If we want to put more emphasis on the users' history, then "search query" should only be displaying when an user explicitly type ddg stuffs, wiki stuffs, or bing stuffs, and so on.

As for "dynamically sorting sources", I agree with Pierre: This way we could have stable behavior across all users and it may be easier for debug.

Ambrevar commented 2 years ago

I also encountered this and gave it some thoughts as well: If we want to put more emphasis on the users' history, then "search query" should only be displaying when an user explicitly type ddg stuffs, wiki stuffs, or bing stuffs, and so on.

This was the previous default behaviour and you can turn it back on by setting search-always-auto-complete-p to nil.

As for "dynamically sorting sources", I agree with Pierre: This way we could have stable behavior across all users and it may be easier for debug.

My point here was not only debugging but also muscle memory. Users quickly get used to pressing M-] to go to the next source and expect some specific source there. If the source order changes, this kind of habits quickly get in your way.

pdelfino commented 2 years ago

Allow me to propose something else. Add an option to trim some sources: only display 5 suggestions for the new-url-query source, then an ellipsis somewhere.

It seems better than what we have now.

Another "fix" would be support for a vertical prompt buffer.

I am curious to see this. It seems worse than your previous suggestion, though. A lot of people would probably complain. It would be different from Helm/Ivy...

I have two other suggestions:

1 - What about keeping what we have now, but, reversing the order?

First there would be the "Global History" menu of suggestions and, below it, there would be the "New URL or search query" suggestions. The past behavior of the user is probably a stronger suggestion than bets with similar words as search queries.

2 - What if we treated the the navigation between "Global History" and "New URL or search query" just like the navigation between headings on org-mode?

We could use TAB, M-p or M-n to "hide" and to move around the two menus (headings).

For instance, I would do:

(i) - execute set-url; (ii) - when I start typing "guix" there are 10 suggestions of similar words on the "New URL or search query" menu; (iii) - below the "Search query" menu, there is a "Global history" menu (iv) - I could use TAB binding on the heading of "New URL or search query", this would hide the suggestions; (v) - Or, I could just press M-n, and this would put the prompt-buffer on the "Global History" menu (the next heading).

What do you think? @Ambrevar @jmercouris @guojing0

Ambrevar commented 2 years ago

I am curious to see this. It seems worse than your previous suggestion, though. A lot of people would probably complain. It would be different from Helm/Ivy...

We may be misunderstood. What I meant here is is simply to display the prompt buffer in a frame that spans vertically. Helm can do that. It would only allow the user to see many more items on the list.

1 - What about keeping what we have now, but, reversing the order?

The first entry must be a search query because that's what the user expects by default, like in any browser.

We could use TAB, M-p or M-n to "hide" and to move around the two menus (headings).

We can already move around sources with M-[ and M-].

However the ability to collapse a source is a good one, aligned with my suggestion of having an ellipsis.

The binding could cycle between

jmercouris commented 2 years ago

Another proposal:

the first source is always "composite source" that combines the top matches from all of the sources. What do you think?

So you can imagine we'd have something like the following at the top:

Composite source: Result 1 from duck go Result 2 from global history Result 3 from bookmarks

Ambrevar commented 2 years ago

A composite source could do indeed!

misterreg commented 2 years ago

I've found a workaround here. You need to use nx-search-engines. You can define fake search engine, so it will not send all your keyboard strokes to remote site. If you REALLY want to search something you can input "ddg searchme" and it switches to non-default search engine.

search-engines.lisp

(in-package #:nx-search-engines)
(define-search-engine fake
    (:shortcut "fake"
     :fallback-url (quri:uri "http://localhost/")
     :base-search-url "http://localhost/?q=~a"))

(in-package #:nyxt-user)
(define-configuration (buffer web-buffer)
  ((search-engines (list 
                    (engines:google 
                     :shortcut "g"
                     :safe-search nil)
                    (engines:duckduckgo
                     :shortcut "ddg"
                     :instant-answers nil)
                    (engines:fake) ;;default engine
                         ))))
Ambrevar commented 2 years ago

@misterreg Isn't it simpler to just disable completion with search-auto-complete-p nil?

aadcg commented 11 months ago

This an important UI issue.