UI: show recently selected items at the top of searches #110828

Merged
Jacques Lucke merged 24 commits from JacquesLucke/blender:recent-searches into main 2023-09-25 10:56:20 +02:00
Member

The goal is to make the search faster to use by dynamically adapting to the user. This can be achieved using the simple but common approach of showing recently selected items at the top. Note, that the "matching score" between the query and each search item still has precedence when determining the order. So the last used item is only at the top, if there is no other search item that matches the query better.

Besides making the search generally faster to use, my hope is that this can also reduce the need for manually weighting search items in some places. This is because while the ordering might not be perfect the first time, it will always be once the user selected the element that should be at the top once.

This patch currently includes:

  • Support for taking recent searches into account in string searching.
  • Keep track of a global list of recent searches.
  • Store recent searches on disk similar to recently opened files.

Things that we might want to include:

  • Add a setting somewhere to enable this feature because it might potentially break tests. Note, that if a test types in the fully correct query, the result is always deterministic.
  • Add a separator in the search list to make it more obvious how the order of elements came to be. To me this would be a nice to have, but does not actually improve anyone's workflow in practice and makes this whole patch much more complex. Also, after a while, most elements at the top will be the ones you recently searched for, making the separator less useful.
  • Give searches an identifier so that one search does not affect another. While nice, this was never an issue in practice for me. It's something we can also add separately later. Giving every search a different id would bloat up the patch quite a bit.

This topic has been discussed in the past on phabricator.

The goal is to make the search faster to use by dynamically adapting to the user. This can be achieved using the simple but common approach of showing recently selected items at the top. Note, that the "matching score" between the query and each search item still has precedence when determining the order. So the last used item is only at the top, if there is no other search item that matches the query better. Besides making the search generally faster to use, my hope is that this can also reduce the need for manually weighting search items in some places. This is because while the ordering might not be perfect the first time, it will always be once the user selected the element that should be at the top once. This patch currently includes: * Support for taking recent searches into account in string searching. * Keep track of a global list of recent searches. * Store recent searches on disk similar to recently opened files. Things that we might want to include: * Add a setting somewhere to enable this feature because it might potentially break tests. Note, that if a test types in the fully correct query, the result is always deterministic. * Add a separator in the search list to make it more obvious how the order of elements came to be. To me this would be a nice to have, but does not actually improve anyone's workflow in practice and makes this whole patch much more complex. Also, after a while, most elements at the top will be the ones you recently searched for, making the separator less useful. * Give searches an identifier so that one search does not affect another. While nice, this was never an issue in practice for me. It's something we can also add separately later. Giving every search a different id would bloat up the patch quite a bit. This topic has been discussed in the past on [phabricator](https://archive.blender.org/developer/differential/0013/0013739/index.html).
Jacques Lucke added 5 commits 2023-08-05 12:22:57 +02:00
Jacques Lucke changed title from UI: sort recently used search items to the top to UI: show recently selected items at the top of searches 2023-08-05 12:25:01 +02:00
Jacques Lucke added 1 commit 2023-08-05 12:43:13 +02:00
buildbot/vexp-code-patch-coordinator Build done. Details
0b02527190
add comments
Author
Member

@blender-bot build

@blender-bot build
Jacques Lucke requested review from Campbell Barton 2023-08-05 12:45:02 +02:00
Jacques Lucke requested review from Julian Eisel 2023-08-05 12:45:02 +02:00
Jacques Lucke requested review from Hans Goudey 2023-08-05 12:45:02 +02:00

Would it work well if we show the latest item(s) with the Recover Last Session icon?

Would it work well if we show the latest item(s) with the Recover Last Session icon?
Author
Member

Would it work well if we show the latest item(s) with the Recover Last Session icon?

Hm, not sure if that would help too much. Especially since over time, most entries at the top would likely have this icon. (not to mention that I don't know how to add an icon there right now)

For reference, this is how e.g. the menu search looks like. I guess the icon would be shown on the left side, but then there would be an empty space for other entries.
image

> Would it work well if we show the latest item(s) with the Recover Last Session icon? Hm, not sure if that would help too much. Especially since over time, most entries at the top would likely have this icon. (not to mention that I don't know how to add an icon there right now) For reference, this is how e.g. the menu search looks like. I guess the icon would be shown on the left side, but then there would be an empty space for other entries. ![image](/attachments/57461ea3-090b-4b22-b888-d818f2cf8d98)
Hans Goudey reviewed 2023-08-23 13:47:29 +02:00
Hans Goudey left a comment
Member

I wonder if it makes more sense to add the search that takes the cache into account to the UI module, with a new file like UI_string_search.hh. It feels a bit high level for blenkernel, since it's really about user interaction.

I wonder if it makes more sense to add the search that takes the cache into account to the UI module, with a new file like `UI_string_search.hh`. It feels a bit high level for blenkernel, since it's really about user interaction.
@ -0,0 +14,4 @@
*/
void add_recent_search(StringRef choosen_str);
const blender::string_search::RecentCache *get_recent_cache();
Member

Unnecessary blender:: here I think, same below

Unnecessary `blender::` here I think, same below
Author
Member

That's actually necessary here because otherwise there is an ambiguity.

That's actually necessary here because otherwise there is an ambiguity.
HooglyBoogly marked this conversation as resolved
@ -0,0 +20,4 @@
void read_recent_searches_file();
/**
* Wrapper for the lower level #StringSearch in blenlib, that takes recent searches into account
Member

Unnecessary comma after blenlib

Unnecessary comma after `blenlib`
JacquesLucke marked this conversation as resolved
@ -19,0 +23,4 @@
struct RecentCache {
/**
* Stores a logical time stamp for each previously choosen search item. The higher the time
* stamp, the more recent the item has been selected.
Member

the more recent -> the more recently

`the more recent` -> `the more recently`
JacquesLucke marked this conversation as resolved
Jacques Lucke added 2 commits 2023-09-01 11:58:38 +02:00
Jacques Lucke added 4 commits 2023-09-01 19:32:49 +02:00
Jacques Lucke requested review from Pablo Vazquez 2023-09-04 15:10:11 +02:00
Jacques Lucke added 2 commits 2023-09-04 15:11:30 +02:00
Jacques Lucke added 1 commit 2023-09-06 15:43:49 +02:00
Pablo Vazquez added the
Module
User Interface
label 2023-09-13 11:55:09 +02:00
Pablo Vazquez added this to the User Interface project 2023-09-13 11:55:13 +02:00
Pablo Vazquez approved these changes 2023-09-15 18:24:30 +02:00
Pablo Vazquez left a comment
Member

After using this for a while it just becomes natural and expected. The order of items becomes irrelevant because I was simply scanning for names of operators I used prior.

Yes, a separator would be a nice touch but even without it's not that important because after a while most items shown as you open the dialog will be recent searches anyway.

+1 looks wise.

After using this for a while it just becomes natural and expected. The order of items becomes irrelevant because I was simply scanning for names of operators I used prior. Yes, a separator would be a nice touch but even without it's not that important because after a while most items shown as you open the dialog will be recent searches anyway. +1 looks wise.
Jacques Lucke added 1 commit 2023-09-15 18:38:31 +02:00
Hans Goudey approved these changes 2023-09-18 23:41:03 +02:00
Hans Goudey left a comment
Member

This works well in my testing too, and I find the diff straightforward and even elegant :)

This works well in my testing too, and I find the diff straightforward and even elegant :)
@ -0,0 +31,4 @@
return storage;
}
void add_recent_search(const StringRef choosen_str)
Member

Spelling: choosen -> chosen. Same in the header.

Spelling: `choosen` -> `chosen`. Same in the header.
JacquesLucke marked this conversation as resolved
Jacques Lucke added 2 commits 2023-09-20 10:27:26 +02:00
Author
Member

@blender-bot build

@blender-bot build

While the feature is handy, I think there should be a preference to disable it.

  • So users who prefer predictable actions on key-stokes can disable it.
  • So automation can use menu search without depending on files in the home directory.
While the feature is handy, I think there should be a preference to disable it. - So users who prefer predictable actions on key-stokes can disable it. - So automation can use menu search without depending on files in the home directory.
Author
Member

Ok, I'll add the option. Do you have any opinion on where it should be shown in the user preferences?

Ok, I'll add the option. Do you have any opinion on where it should be shown in the user preferences?
Jacques Lucke added 2 commits 2023-09-21 09:40:28 +02:00
Author
Member

I added the option in a fairly random place in the user preferences right now. I'm not sure where to put it, should it be in a new panel for search related stuff?

I added the option in a fairly random place in the user preferences right now. I'm not sure where to put it, should it be in a new panel for search related stuff?
Member

I'm not sure where to put it, should it be in a new panel for search related stuff?

There are no other search options yet so it's probably okay to put it in there.

How about adding a separator, column heading, and change the label to something more descriptive:

mockup

diff --git a/scripts/startup/bl_ui/space_userpref.py b/scripts/startup/bl_ui/space_userpref.py
index e40898ae458..25bc312d349 100644
--- a/scripts/startup/bl_ui/space_userpref.py
+++ b/scripts/startup/bl_ui/space_userpref.py
@@ -216,7 +216,10 @@ class USERPREF_PT_interface_display(InterfacePanel, CenterAlignMixIn, Panel):
         sub.active = view.show_tooltips
         sub.prop(view, "show_tooltips_python")
 
-        layout.prop(prefs, "use_recent_searches")
+        col.separator()
+
+        col = layout.column(heading="Search", align=True)
+        col.prop(prefs, "use_recent_searches", text="Sort by Most Recent")
 
 
 class USERPREF_PT_interface_text(InterfacePanel, CenterAlignMixIn, Panel):
> I'm not sure where to put it, should it be in a new panel for search related stuff? There are no other search options yet so it's probably okay to put it in there. How about adding a separator, column heading, and change the label to something more descriptive: ![mockup](/attachments/66bb5bd6-1b68-4ce8-99f6-0ff1c3e663ab) ```diff diff --git a/scripts/startup/bl_ui/space_userpref.py b/scripts/startup/bl_ui/space_userpref.py index e40898ae458..25bc312d349 100644 --- a/scripts/startup/bl_ui/space_userpref.py +++ b/scripts/startup/bl_ui/space_userpref.py @@ -216,7 +216,10 @@ class USERPREF_PT_interface_display(InterfacePanel, CenterAlignMixIn, Panel): sub.active = view.show_tooltips sub.prop(view, "show_tooltips_python") - layout.prop(prefs, "use_recent_searches") + col.separator() + + col = layout.column(heading="Search", align=True) + col.prop(prefs, "use_recent_searches", text="Sort by Most Recent") class USERPREF_PT_interface_text(InterfacePanel, CenterAlignMixIn, Panel): ```
Jacques Lucke added 2 commits 2023-09-22 22:09:56 +02:00
Member

Thank you! UI-wise this is good to go, and a great addition especially for the Add menu search.

Thank you! UI-wise this is good to go, and a great addition especially for the Add menu search.
Campbell Barton reviewed 2023-09-25 08:10:39 +02:00
@ -16,3 +18,3 @@
int length;
void *user_data;
int weight;
int recent_time;

Worth noting what units this is in & if it can ever be negative.

Worth noting what units this is in & if it can ever be negative.
JacquesLucke marked this conversation as resolved
Campbell Barton approved these changes 2023-09-25 08:10:57 +02:00
Jacques Lucke added 2 commits 2023-09-25 10:48:23 +02:00
Julian Eisel reviewed 2023-09-25 10:52:45 +02:00
Julian Eisel left a comment
Member

Do we really need a new preference option for this? I feel like with every new usability feature we add, we start having this discussion. It's easy to bloat the preferences this way, just because "there might be some people who prefer to disable this". Then I rather take the time to evaluate things first. I would say this feature can just be disabled in background mode?

Scrolled over the code briefly, looks fine.

Do we really need a new preference option for this? I feel like with every new usability feature we add, we start having this discussion. It's easy to bloat the preferences this way, just because "there _might_ be some people who prefer to disable this". Then I rather take the time to evaluate things first. I would say this feature can just be disabled in background mode? Scrolled over the code briefly, looks fine.
Jacques Lucke merged commit 8362563949 into main 2023-09-25 10:56:20 +02:00
Jacques Lucke deleted branch recent-searches 2023-09-25 10:56:21 +02:00

Do we really need a new preference option for this? I feel like with every new usability feature we add, we start having this discussion. It's easy to bloat the preferences this way, just because "there might be some people who prefer to disable this". Then I rather take the time to evaluate things first. I would say this feature can just be disabled in background mode?

Scrolled over the code briefly, looks fine.

Menu search is used in undo tests that don't run in background mode, in general I think it's reasonable to have functionality run predictably without depending on previous executions.

Without a way to disable this option, automated actions will manipulate the users history too.

> Do we really need a new preference option for this? I feel like with every new usability feature we add, we start having this discussion. It's easy to bloat the preferences this way, just because "there _might_ be some people who prefer to disable this". Then I rather take the time to evaluate things first. I would say this feature can just be disabled in background mode? > > Scrolled over the code briefly, looks fine. Menu search is used in undo tests that don't run in background mode, in general I think it's reasonable to have functionality run predictably without depending on previous executions. Without a way to disable this option, automated actions will manipulate the users history too.
Member

I just realised the title is UI: show recently selected items at the top of searches, yet it seems that only items that have been searched for are added to the top, not the ones I clicked on. This issue was brought up by Julien Kaspar as well.

@JacquesLucke Should I open a report on this, is it out of scope? I mentioned this once in person I think, but forgot to ask again.

I just realised the title is _UI: show recently **selected** items at the top of searches_, yet it seems that only items that have been searched for are added to the top, not the ones I clicked on. This issue was brought up by Julien Kaspar as well. @JacquesLucke Should I open a report on this, is it out of scope? I mentioned this once in person I think, but forgot to ask again. <video src="/attachments/c91789d9-7c52-42f6-b060-b089b0a1a42e" title="Screen Recording 2024-01-31 at 17.48.34.mov" controls></video>
Author
Member

The recent-searches thing only applies to the search indeed. We can also make it work when clicking on things in a menu I guess, can't say how difficult it will be yet. It's not really a bug currently.

The recent-searches thing only applies to the search indeed. We can also make it work when clicking on things in a menu I guess, can't say how difficult it will be yet. It's not really a bug currently.
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
6 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#110828
No description provided.