Skip to content

Conversation

SuaYoo
Copy link
Member

@SuaYoo SuaYoo commented Oct 1, 2025

Resolves #2846

Changes

  • Disables collection search in workflow form if org has no collections
  • Enables fuzzy searching by collection name
  • Improves performance of collection data loading

Manual testing

  1. Log in as crawler to org without collections
  2. Go to create or edit workflow
  3. Go to "Collections" section. Verify auto-add is disabled
  4. Go to org with collections
  5. Go to create or edit workflow
  6. Go to "Collections" section and type into auto-add. Verify search results show for collection as expected
  7. Select search result
  8. Type name of search result into search field. Verify added item is not displayed in search results

Screenshots

Page Image/video
Workflow editor / Collections (org without collections) Screenshot 2025-10-01 at 10 37 02 AM
Workflow editor / Collections Screenshot 2025-10-01 at 10 40 59 AM

@SuaYoo SuaYoo marked this pull request as ready for review October 1, 2025 18:05
@SuaYoo SuaYoo requested review from ikreymer, emma-sg and tw4l October 1, 2025 18:06
@SuaYoo SuaYoo force-pushed the frontend-workflow-collection-search-values branch from f6dfaa3 to a6ed3e3 Compare October 1, 2025 18:54
@SuaYoo SuaYoo force-pushed the frontend-workflow-collection-search-values branch from a6ed3e3 to 20d3c97 Compare October 2, 2025 00:07
Copy link
Member

@tw4l tw4l left a comment

Choose a reason for hiding this comment

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

Works brilliantly, great improvement!

@SuaYoo SuaYoo merged commit c8c59dd into main Oct 6, 2025
29 checks passed
@SuaYoo SuaYoo deleted the frontend-workflow-collection-search-values branch October 6, 2025 21:15
Copy link
Member

@emma-sg emma-sg left a comment

Choose a reason for hiding this comment

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

Overall this is an improvement for sure, but there's a few things I'm a little confused about and a couple of bugs/unexpected behaviours I was able to find.

Comment on lines +90 to +99
private readonly searchTask = new Task(this, {
task: async ([names], { signal }) => {
if (!names || signal.aborted) {
return;
}

return new Fuse(names, { threshold: 0.4, minMatchCharLength: 2 });
},
args: () => [this.searchValuesTask.value] as const,
});
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure I understand why this is a Task — it seems to me that this could go in a willUpdate, because all of the code here is synchronous. As such, the pending state on line 238 is never rendered, since the task always immediately successfully completes whenever it's run.

return;
}

return new Fuse(names, { threshold: 0.4, minMatchCharLength: 2 });
Copy link
Member

Choose a reason for hiding this comment

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

Should minMatchCharLength be MIN_SEARCH_LENGTH? As is, when starting to search for something, you don't get any results until you've typed more than two characters, even though when you've only typed one character you get both a) results back from the search prefix endpoint, if there's any collections starting with the character you've entered, and b) a message that says "no matching collections found", which isn't true.

Comment on lines 101 to 112
private readonly searchResultsTask = new Task(this, {
task: async ([searchByValue, hasSearchStr], { signal }) => {
if (!hasSearchStr) return [];
const data = await this.fetchCollectionsByPrefix(searchByValue, signal);
let searchResults: Collection[] = [];
if (data?.items.length) {
searchResults = this.filterOutSelectedCollections(data.items);
}
return searchResults;
},
args: () => [this.searchByValue, this.hasSearchStr] as const,
});
Copy link
Member

Choose a reason for hiding this comment

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

Correct me if I'm wrong, but I don't think the results of this are used anywhere, are they?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, it looks like currently onSearchInput serves to re-render the component, and nothing else, so it could functionally be replaced with this.requestUpdate()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Task]: Use search values in collection auto-add
3 participants