Skip to content

Allow bext initialisation when cannot determine sourcegraph URL + fix background script always using cloud URL

Administrator requested to merge erzhtor/fix-bext-repo-not-found into main

Created by: erzhtor

Fixes https://github.com/sourcegraph/sourcegraph/issues/26217

Context

In https://github.com/sourcegraph/sourcegraph/pull/25185, I've added logic not to initialize Bext if the repo exists in neither Cloud nor Self-hosted sourcegraph instances (because this way, we will not interfere with GH native hover). However, it broke the logic of showing the "repo not found" button (existence of which I didn't know), so this PR fixes it.

Description

Issue 1 The logic when we fail to detect sourcegraph URL is following:

  • if the repo is in blocklist and a self-hosted URL exists => use self-hosted URL (this will end up showing Repo not found button)
  • if the repo is in blocklist and self-hosted URL DOES NOT exist => stop Bext
  • if the repo is NOT in blocklist => use cloud URL (this will end up showing Configure sourcegraph button)

Issue 2 Turned out that the background script always uses cloud URL, because SourcegraphUrlService (and state it uses) is intended to be a singleton, but turned out that the main thread and background thread have their own instances. So this PR fixes to pass sourcegraph URL from main thread whenever requests are needed because multiple tabs can use different sourcegraph instances whereas background script is a single for the next.

TL;DR;

  • fixes bext usage for self-hosted instance repos

Follow-up

Add integration tests. Created an issue to tackle https://github.com/sourcegraph/sourcegraph/pull/26258

Merge request reports

Loading