Fix multiple bugs and refactor scoring/debounce logic - #92
Open
circleci-app[bot] wants to merge 1 commit into
Open
Fix multiple bugs and refactor scoring/debounce logic#92circleci-app[bot] wants to merge 1 commit into
circleci-app[bot] wants to merge 1 commit into
Conversation
- Fix "Open Twitter" action dispatching OPEN_FACEBOOK instead of OPEN_TWITTER - Fix cleanTabUrl corrupting URLs with query strings but no hash (slice(-1) bug) - Fix isBrowserURL returning undefined on non-Chrome/Firefox browsers - Fix indexOfSelected useMemo missing resultList in dependency array - Fix onInputChange debounce recreated every render (wrap in useRef) - Fix bookmark.url non-null assertion on nodes without a url field - Remove console.log debugging artifacts from background service worker - Refactor scoreData to eliminate duplicated single-key/multi-key branches - Remove redundant `=== 0` check subsumed by threshold comparison AI-Generated: true
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bugs fixed
Correctness bugs (confirmed):
src/background/search/actions.ts:68— "Open Twitter" action dispatchedMessage.OPEN_FACEBOOKinstead ofMessage.OPEN_TWITTER. Clicking "Open Twitter" opened Facebook.src/background/utils.ts:29—cleanTabUrlcorrupted the overwhelming majority of URLs. For any URL with a?query string but no#hash (e.g.https://example.com/search?q=foo),url.indexOf("#")returns-1, sourl.slice(-1)appended the last character of the original URL instead of nothing.https://example.com/search?q=foo→https://example.com/searcho.src/common/common.ts:7—isBrowserURLfell off the end without returning on non-Chrome/Firefox browsers, returningundefined. Callers doing!isBrowserURL(url)evaluated!undefined === true, allowing the extension to act on internal browser tabs on Edge/Opera/Safari. Added explicitreturn falseand abooleanreturn type annotation.src/content/ui/components/SearchModal.tsx:55—indexOfSelecteduseMemowas missingresultListfrom its dependency array. After new search results arrived, the memo returned a stale index, breaking keyboard navigation (Arrow keys and Enter acted on the wrong result).src/content/ui/components/SearchModal.tsx:190—onInputChangewas declared as a bareconst debounce(...)in the component body, so a new debounce instance (with a fresh timer) was created on every render. Rapid typing that triggered re-renders reset the 300 ms window each time, defeating debouncing entirely. Wrapped inuseRef(...).current.src/background/utils.ts:103—bookmark.url!non-null asserted on bookmark nodes that passed only the!bookmark.childrencheck. Separator/folder nodes can have neitherchildrennorurl; changed toelse if (bookmark.url)guard.Cleanup:
console.logdebugging artifacts from the background service worker (4 calls leaking tab URLs and message payloads to DevTools).scoreDatato eliminate the duplicate single-key/multi-key loop by normalizingkeysto an array at the top. ~20 lines of duplicated logic removed.maxScore === 0check that was fully subsumed bymaxScore < DEFAULT_SCORE_THRESHOLD.https://app.circleci.com/agents/circleci/977715b4-c847-474d-bc08-01d21c55ef7e/chat/5cd8a7fd-f95e-494e-81a5-30fc4a2f5105