Skip to content

Feature/autocomplete#149#165

Open
saikarthikbattula wants to merge 19 commits into
developfrom
feature/Autocomplete#149
Open

Feature/autocomplete#149#165
saikarthikbattula wants to merge 19 commits into
developfrom
feature/Autocomplete#149

Conversation

@saikarthikbattula
Copy link
Copy Markdown
Contributor

@saikarthikbattula saikarthikbattula commented Apr 8, 2026

Enhanced autocomplete to indicate whether a course or professor has notes available before navigation. This improves user experience by making it clear which results already contain notes and routing users appropriately when they don’t. Each autocomplete result now reflects note availability and guides users either to existing notes or directly to the note creation flow with prefilled context.
Changes

Extended autocomplete logic to include note existence information for each course/professor result
Added backend support to determine whether a course/professor has associated notes
Updated autocomplete response format to include a hasNotes flag per result

Introduced UI indicators in autocomplete:
Note icon for items with existing notes
Plus icon for items without notes

Updated navigation behavior:
If notes exist → route to notes page
If no notes exist → route to create note page
Added query param support to prefill course/professor fields on the create note page

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 8, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
utd-notebook Error Error May 13, 2026 1:28am

Request Review

@TyHil TyHil linked an issue Apr 8, 2026 that may be closed by this pull request
Copy link
Copy Markdown
Contributor

@ShriramJana ShriramJana left a comment

Choose a reason for hiding this comment

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

Hey @saikarthikbattula, nice work on this! A few things to address before we can merge:

1. Performance: DB query on every autocomplete request
The autocomplete route now hits the database (joining section + file) on every keystroke search. This could introduce lag as data grows, since autocomplete needs to feel instant. Consider caching this data (a set of course/professor combos that have notes, refreshed periodically) instead of querying live on every request.

2. Professor redirect passes wrong value
When a professor has no notes and the user clicks it, the redirect goes to /notes/create?course=John Smith. The NoteForm then pre-fills this into the section field, which expects a course format like CS 3341, not a professor name. This will either show an invalid value or confuse the user.

Please also add a description explaining what the PR does and how to test it. This helps reviewers and keeps our PR history useful.

@saikarthikbattula
Copy link
Copy Markdown
Contributor Author

Hey @ShriramJana, thank you for your comment and I have made the proposed changes. Please let me know if there is anything else I need to do.

Copy link
Copy Markdown
Member

@TyHil TyHil left a comment

Choose a reason for hiding this comment

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

Looking really good! Just a few small changes and waiting on a look from Ethan

Comment thread src/components/header/SearchBar.tsx Outdated
Comment thread src/components/header/SearchBar.tsx Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What're the goals of the changes in this file? I don't think I saw them in the description

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I was working on Issue #154 before it was resolved and I thought I had fully restored the file.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Gotcha, looks like there's still one line addition in the file

Comment thread src/app/api/autocomplete/route.ts Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I really like the idea of the caching in this file. I don't know if I'm doing a great job of reviewing it tho because I haven't really seen anything like this before. @nl32 do you think you might be able to take a look

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looking into this further myself, I like the caching idea. It does have a very large first load time of like 4 of so seconds for me which I am guessing is mostly fetching all the sections. Do you think we could combine your original approach and this new one by fetching hasNotes for only the results being returned and caching only those results instead of the whole DB? This would require each result to have it's own TTL. Can we also do a TTL of 1 minute so it's quicker to let you search for a course after uploading a note? Lmk if that makes sense

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yep that makes sense sorry for the delay got caught in studying for exams

- Change from global cache to per-result caching
- Reduce TTL from 5 minutes to 1 minute for faster updates
- Add targeted database queries for better performance
- Add generateSectionsData script for build process
 While testing the new autocomplete features, the build was failing due to missing type definitions and unhandled props across two files: FormFile.tsx and SearchQuery.tsx.

1. Why FormFile.tsx was updated: NoteForm.tsx was passing existingFile and isError props to the <FormFile> component to handle edit-mode states, but the component didn't actually accept or handle those props. To fix the type errors and support the UI, I expanded FormFileProps to accept them. FormFile now properly displays the currently uploaded file name during edits and shows a red border when validation fails.

2. Why SearchQuery.tsx was updated: The new SearchBar component relies on the removeDuplicates function to filter recent searches, and the SearchQueryWithTitle type for its autocomplete options. However, these were either missing or had syntax errors in the SearchQuery.tsx file on this branch. I implemented the removeDuplicates utility function and exported the SearchQueryWithTitle type so SearchBar can compile and function correctly.
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.

Autocomplete show if we have notes

3 participants