Skip to content

Fix multiple bugs and refactor scoring/debounce logic - #92

Open
circleci-app[bot] wants to merge 1 commit into
circleci-project-setupfrom
chunk/fix-bugs-and-refactor
Open

Fix multiple bugs and refactor scoring/debounce logic#92
circleci-app[bot] wants to merge 1 commit into
circleci-project-setupfrom
chunk/fix-bugs-and-refactor

Conversation

@circleci-app

@circleci-app circleci-app Bot commented Aug 3, 2026

Copy link
Copy Markdown

Bugs fixed

Correctness bugs (confirmed):

  • src/background/search/actions.ts:68 — "Open Twitter" action dispatched Message.OPEN_FACEBOOK instead of Message.OPEN_TWITTER. Clicking "Open Twitter" opened Facebook.

  • src/background/utils.ts:29cleanTabUrl corrupted 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, so url.slice(-1) appended the last character of the original URL instead of nothing. https://example.com/search?q=foohttps://example.com/searcho.

  • src/common/common.ts:7isBrowserURL fell off the end without returning on non-Chrome/Firefox browsers, returning undefined. Callers doing !isBrowserURL(url) evaluated !undefined === true, allowing the extension to act on internal browser tabs on Edge/Opera/Safari. Added explicit return false and a boolean return type annotation.

  • src/content/ui/components/SearchModal.tsx:55indexOfSelected useMemo was missing resultList from 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:190onInputChange was declared as a bare const 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 in useRef(...).current.

  • src/background/utils.ts:103bookmark.url! non-null asserted on bookmark nodes that passed only the !bookmark.children check. Separator/folder nodes can have neither children nor url; changed to else if (bookmark.url) guard.

Cleanup:

  • Removed console.log debugging artifacts from the background service worker (4 calls leaking tab URLs and message payloads to DevTools).
  • Refactored scoreData to eliminate the duplicate single-key/multi-key loop by normalizing keys to an array at the top. ~20 lines of duplicated logic removed.
  • Removed redundant maxScore === 0 check that was fully subsumed by maxScore < DEFAULT_SCORE_THRESHOLD.

https://app.circleci.com/agents/circleci/977715b4-c847-474d-bc08-01d21c55ef7e/chat/5cd8a7fd-f95e-494e-81a5-30fc4a2f5105

- 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
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.

0 participants