Skip to content

Conversation

@Yabtse
Copy link

@Yabtse Yabtse commented Sep 4, 2025

Context

This PR implements a search bar that allows users to search across all projects(and source files) - owned, shared, and archived helping users organize / and navigate large number of projects

Related Issues

Verification

  • Verified on Chrome and Safari that the search bar appears on top of the project page with proper styling
  • confirmed that the real-time search updates results as you type, without requiring form submission
  • Tested that search works across all project categories (owned, shared, & archived)
  • Verified that fuzzy search finds projects despite typos and partial matches
  • checked that search highlighting works correctly for exact matches
  • confirmed that error handling displays "no result" message
  • Tested that clearing the search input returns to showing all projects
  • Accessibility:
    • Search input has proper placeholder text and is keyboard accessible
    • Search results maintain proper focus management and screen reader compatibility

Checklist

-## Checklist

  • Added visible search bar with magnifying glass icon to src/routes/projects/+page.svelte
  • Implemented fuzzy search algorithm (Fuse.js) with 0.4 threshold for typo tolerance
  • Set search scope to cover project names and source file names in src/routes/projects/+page.svelte
  • Added archived projects to search scope with proper user ownership filtering
  • Implemented real-time search that updates results as you type (no submit button needed)
  • Added "No projects found" error message with helpful suggestions when search returns no results
  • Updated src/components/app/ProjectPreview.svelte to highlight search matches with <mark> tags
  • Ensured search results are ranked by relevance score (best matches first)
  • Updated unit tests in src/routes/projects/search.test.ts to validate all search functionality

Screenshot

Screenshot 2025-09-03 at 6 51 15 PM

Copy link
Collaborator

@amyjko amyjko left a comment

Choose a reason for hiding this comment

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

Thanks for a wonderful start to this feature! I think it's close, but there are several things to clean up before its ready for merging:

  • This PR is proposing to merge your branch into wordplaydev:Somali, which is the wrong branch. You want to merge it into main. That should clean up the 1000+ files being modified here and make it easier to review this PR.
  • I'd like to learn more about the value of adding the fuse.js dependency. It adds 10-20 kb to our bundle size. How much value is it adding, versus some more basic fuzzy matching that we build ourselves, such as a simple Levenstein distance check? We want to keep this as small as possible, as students use very underpowered computers at school, with slow internet and low memory.
  • It appears you're not using the standard TextField component from the platform, and instead bringing in a third party text field. (I can't quite tell, since there are 1001 files changed in this PR, so cleaning it up will help clarify). Why not use the standard component on the platform, for consistency?

@Yabtse
Copy link
Author

Yabtse commented Sep 7, 2025

Hey @amyjko ,

  • Thank you for pointing out that merging mistakes I'll merge my branch into main

  • I started by experimenting with different fuzzy search algorithms, and Levenshtein distance was actually one of the first I tested. I found it too rigid—it only worked well when the input was off by a single character or so. That’s when I came across Fuse.js, which proved far more forgiving. In my tests, it handled typos and small mistakes with much greater precision. As you mentioned, I imagined a student making a typo, and Levenshtein just wasn’t the best solution in that scenario. I hadn’t realized Fuse.js added 10–20 KB to the bundle size, but I still see its value, especially for users managing a large number of projects.

  • also You're absolutely right! I was using a custom HTML input instead of the platform's standard TextField component. I've updated the implementation to use TextField

@Yabtse Yabtse changed the base branch from Somali to main September 7, 2025 02:01
Copy link
Collaborator

@amyjko amyjko left a comment

Choose a reason for hiding this comment

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

I've added a few other comments based on review; there are some test and CSS things to clean up and conflicts in the package.json and package-lock.json dependencies to clean up.

Also, I don't see your TextField updates yet. Are you sure they're included in the PR? I'm still seeing the custom text field.

Related to the text field, there is hard coded English in the implementation. It needs to use our localization infrastructure, including an update to the English locale file, so that this works across languages. (I can generate the draft machine translations for the other languages).

/**
* Console Testing Script for Search Functionality
*
* This script allows you to test the search functionality from the command line
Copy link
Collaborator

Choose a reason for hiding this comment

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

This test should be integrated into the vitest infrastructure we have, rather than creating a standalone script. Write this using the test APIs so it's included in the standard test suite.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I see that there is a vitest test. What is this for then? Is this redundant? If so, remove it.

row-gap: var(--wordplay-spacing);
}
:global(.search-highlight) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Don't use global CSS for a local style class. Instead of returning raw HTML and. using an @html directive, just use a Svelte 5 snippet.

@Yabtse
Copy link
Author

Yabtse commented Sep 13, 2025

@amyjko What's the path to the English Locale file again?

@amyjko
Copy link
Collaborator

amyjko commented Sep 13, 2025

See the documentation for locales. The key things to update are:

  • The relevant part of UITexts.ts and more specifically ui.page.projects.
  • Run npm run schemas to update the locale schemas based on the changes
  • Update en-US.json with the strings added to the type

I can machine translate those before deployment so we have placeholders for other supported languages.

@Yabtse
Copy link
Author

Yabtse commented Sep 26, 2025

@amyjko I've made some changes

Copy link
Collaborator

@amyjko amyjko left a comment

Choose a reason for hiding this comment

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

This is pretty close. Just a little bit too clean up:

  • Resolve conflicts with package.json, package-lock.json. You should be using the latest of both from main. The only change should be the addition of the fuse.js dependency.
  • Resolve the type errors reported by npm run check, including missing Playwright APIs and an invalid use of {@const} in ProjectPreviewWithHighlight.svelte.

I committed one fix to the test fail that was causing .DS_Store to be included as a test project.

@Yabtse
Copy link
Author

Yabtse commented Sep 30, 2025

@amyjko ok thanks could you take a look

@amyjko
Copy link
Collaborator

amyjko commented Oct 2, 2025

I should be able to check on Saturday.

Copy link
Collaborator

@amyjko amyjko left a comment

Choose a reason for hiding this comment

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

There are still several issues:

  • Three conflicts to resolve
  • 1 Svelte error to resolve (still an invalid @const)
  • 4 Typescript errors in the new test
  • I'm still seeing a reference to "files" in the search prompt, even though there's no such thing as a "file" in Wordplay, and the search feature is not searching files.

@amyjko
Copy link
Collaborator

amyjko commented Dec 19, 2025

@Yabtse Are you still working on this PR?

@Yabtse
Copy link
Author

Yabtse commented Dec 19, 2025

@amyjko Yes, I am sorry for the delay. I’ve been out of the country. I’m actively working on resolving the issue now, and I’ve removed the reference to files from the search bar’s placeholder text.

@amyjko
Copy link
Collaborator

amyjko commented Dec 19, 2025

Thanks for the update! I'm just cleaning up stale PRs and issues, but glad to you know you plan to wrap this.

@amyjko
Copy link
Collaborator

amyjko commented Dec 19, 2025 via email

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.

Organize large number of projects

2 participants