fix(extension): Chrome extension helper redirection#61
Open
shiv248 wants to merge 8 commits intolivekit:mainfrom
Open
fix(extension): Chrome extension helper redirection#61shiv248 wants to merge 8 commits intolivekit:mainfrom
shiv248 wants to merge 8 commits intolivekit:mainfrom
Conversation
…esolution - Fix ES module error in content script by moving all logic to background worker - Add dynamic branch detection using cached repo-default-branches.json - Add 404 detection with auto-retry using correct branch from GitHub API - Refactor to message-passing architecture between popup/content script and background - Rename files: composite-redirect.js → 404-detector.js, add background.js entry point - Remove web_accessible_resources (no longer needed)
- Replace regex with URL.pathname.split('/') for readability
- Add input/output sanity checks for livekit/livekit-examples URLs
- Use location.assign() instead of tabs.update() to preserve history
- Improve code clarity and documentation
- Add Security Considerations section to README documenting known issues - Add error handling (.catch) to async message handlers to prevent hangs - Bump version to 1.2.0
…nto shiv/bug-chrome-helper-redirect
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.
Issue:
Hello!
issuesare disabled from creation, so I'll briefly go over the issue here.Sometimes when a user navigates from deepwiki -> composite and uses the provided extension to
Go to Sourcewe get a stale or incorrect response from GitHub due to the nature of the extension being hardcoded to redirect specifically tomain, wheremasteror another default branch exists or an override exists which should be respected.for example if we ask deepwiki - "what is livekit? and what examples do they have for webrtc on esp32?"
And we select
ivekit/livekit/README.mdit takes us to the correct livekit_composite blob but using the extension redirect if we want to view the original codebase, due to livekit/livekit's default branch beingmasterthe README.md comes up as a 404, which is incorrect.This issue gets highlighted again when
livekit_composite/repo.confspecifics direct overridden repos during the livekit repos pull, referenced withinlivekit_composite/sync_livekit_repos.py, but getting ignored by the redirection extension.Fix:
This PR fixes this issue and adds QOL changes to the extension, which could be expanded upon further. I tried to keep the changes additive rather than removing existing functionality, cleanly.
some features:
repo-default-branches.jsonto store branch mappings for all repositories.repo-default-branches.jsonas hot cache, but check GitHub only when a 404 occurscomposite-redirect-bg.js) and share it across all tabs.chrome.storage.localversioning/hashingrepo-default-branches.jsonon service worker startup.?utm_source=livekit_extensionto all redirects.isOverride: truein the JSON cachelivekit_compositeURL.github.com/livekit/orgithub.com/livekit-examples/.?utm_source=livekit_extension.isOverride-> stop (trust JSON, real 404)404-detector.js) scoped togithub.com/livekit/*andgithub.com/livekit-examples/*in the manifest.Final Architecture
composite-redirect-bg.js(Background Service Worker)prefetchCache()– loads JSON once on extension startupgetBranchCachemessages from content scriptsupdateBranchCachemessages to update shared cachecomposite-redirect.js(Content Script)initializeCache()– retrieves cache from background workerconvertCompositeToSource()– applies correct branch and UTM paramhandle404Redirect()– detects 404s, checks overrides, compares APIrepo-default-branches.json(branch cache)isOverrideflagScenarios Covered
fix tested on firefox and chrome/edge.

future recommendations:
#ask-aior deepwiki.