Skip to content

feat(vcs): expose the installation's organization URL - #13875

Merged
HarshMN2345 merged 6 commits into
mainfrom
feat/vcs-installation-organization-url
Sep 24, 2026
Merged

HarshMN2345 merged 6 commits into
mainfrom
feat/vcs-installation-organization-url

Conversation

@HarshMN2345

@HarshMN2345 HarshMN2345 commented Sep 24, 2026 •

Copy link
Copy Markdown
Member

What does this PR do?

The installation response carries provider and organization but no URL, so anything linking to the organization has to assemble one from a hardcoded provider domain. On a self-hosted GitLab or Gitea that produces a gitlab.com link for an organization that only exists on the customer's own instance.

The console does exactly this today: getProviderOwnerUrl() in vibes' src/lib/vcs/providers.tsx builds https://gitlab.com/${organization}, and both of its callers, GitConfigurationCard.tsx and GitInstallationContextMenu.tsx, already hold the installation, so they can read this field instead.

This adds organizationUrl to MODEL_INSTALLATION, built by the adapter from the configured host:

$provider = $installation->getAttribute('provider', '');
if ($vcsFactory->isConfigured($provider)) {
    $installation->setAttribute('organizationUrl', $vcsFactory->fromProviderForBrowser($provider)->getOrganizationUrl($installation->getAttribute('organization', '')));
}

Browser-facing host

The link is opened by a browser, which can reach the provider on a different host from the server. Gitea already models this with _APP_VCS_GITEA_BROWSER_ENDPOINT, used by Gitea/Authorize/Get.php for the login redirect. Resolving the adapter with fromProvider() would pick the server-side endpoint and hand the console a link such as http://gitea:3000/appwrite, which only the server can reach.

Factory::fromProviderForBrowser() builds the adapter as fromProvider() does, then applies the provider's browserEndpoint from the registry when one is set. Only Gitea declares one; every other provider falls through to its API endpoint unchanged.

Building the adapter this way needs no credentials and makes no network call, so the list endpoint does it per row without touching stored tokens. A provider that is no longer configured leaves the field at its empty default rather than failing the read.

Depends on utopia-php/vcs 5.5.1 for getOrganizationUrl() (utopia-php/monorepo#345). The existing 5.5.* constraint already allowed it, so only the lock moves.

Test Plan

  • tests/unit/Vcs/FactoryTest.php — which host is chosen. With both endpoints set, fromProvider() yields http://gitea:3000/owner and fromProviderForBrowser() yields https://git.example.com/owner; a provider with no browser endpoint falls back to its API endpoint. Ran locally: 14 tests, 55 assertions, passing.
  • tests/e2e/Services/VCSGitea/VCSGiteaConsoleClientTest.php::testInstallationOrganizationUrl — against the real Gitea in CI, both the list and get routes return the field, it addresses the installation's owner, and the two routes agree. It deliberately does not assert or fetch the host: the browser-facing host need not be reachable from the container running the tests, which is the case a separate browser endpoint exists for.
  • composer lint and PHPStan level 4 clean on the changed files.

Related PRs and Issues

  • Reported against self-hosted GitLab, where project settings shows a gitlab.com owner link.
  • The console still has to render this field for the reported bug to close. The same file also hardcodes gitlab.com for commit, branch and merge request links, and several deployment views detect the provider by matching gitlab.com in a URL; neither is addressed here.

Brings getOrganizationUrl, which resolves an owner's browser URL from the
adapter's configured host. The constraint already allowed it, so only the
lock moves.
The installation response carried the provider name and the organization
name but no URL, so a client linking to the organization had to assemble
one from a hardcoded provider domain. That is wrong for every self-hosted
GitLab and Gitea instance, where the host is whatever the install is
configured with.

Add organizationUrl to the installation model, resolved through the
adapter, which already knows the configured host. Reading it needs no
credentials or network, so the list endpoint builds it per row from the
provider registry rather than from the installation's stored tokens.

Providers that are no longer configured leave the field at its empty
default rather than failing the read.
@greptile-apps

greptile-apps Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

The PR appears safe to merge; no new actionable issue or outstanding previous finding remains.

Summary

The PR adds organizationUrl to installation responses, using a browser-facing Gitea endpoint when configured, and updates the VCS dependency. The latest revision replaces a container-side reachability assertion with URL-path and GET/list consistency checks and adds factory tests for endpoint selection.

Reviews (5) · Last reviewed commit: "test(vcs): cover the browser endpoint wh..."

@github-actions

github-actions Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → feat/vcs-installation-organization-url (after).

Metric Before After Change
🚀 Requests/sec 181.78 192.1 🟢 +5.7%
⏱️ Latency P50 93.86 ms 91.06 ms ⚪ -3%
⏱️ Latency P95 227.57 ms 211.05 ms 🟢 -7.3%
Per-scenario breakdown & investigation details

Metrics below reflect the current branch (after). Δ P95 compares against the base.

Scenario P50 (ms) P95 (ms) Requests RPS Δ P95 (ms)
API total 91.06 211.05 12,483 192.1 -16.52
Account 185.99 333.33 657 10.88 -11.29
TablesDB 87.99 162.22 6,789 108.36 -13.73
Storage 83.74 174.24 3,285 53.43 -22.32
Functions 129.27 264.03 1,752 29.03 -32.4

Top API waits (after)

API request Max wait (ms)
account.name.update 568.23
tablesdb.rows.increment 509.22
account.prefs.update 479.94
tablesdb.rows.delete 474.78
functions.variables.update 421.94

Gitea can be reachable on a different host from the browser than from the
server, which is what _APP_VCS_GITEA_BROWSER_ENDPOINT exists for. Resolving
the adapter through fromProvider() picked the server-side endpoint, so the
organization link could point at a host only the server can reach, such as
an internal Docker name.

Resolve browser-facing links through their own endpoint, kept in the
provider registry next to the API one, and cover the field on both the get
and list routes.
The expectation rebuilt the URL from the same environment variables and
trimming as the endpoint under test, so it asserted that the test agreed
with the implementation rather than that the response was right.

Ask Gitea for the owner's page instead, which it derives from its own
configured root, so a hardcoded provider domain or a mangled host fails
the assertion.
…ames

Expecting the html_url from Gitea's API tied the assertion to the
server-side root, so a deployment whose browser host differs would fail the
test even though the response was right.

Assert what holds under either arrangement: the link addresses the owner,
it answers, and both routes agree on it.
Fetching the organization URL from the e2e test assumed the browser-facing
host is reachable from the container running the tests, which is the one
thing a separate browser endpoint exists to allow. That test could fail on
a correct response.

Cover which host is chosen in FactoryTest, where both endpoints can be set
and neither has to be reachable, and leave the e2e asserting what holds
under any arrangement: the link addresses the owner and both routes agree.
@HarshMN2345
HarshMN2345 merged commit 172992c into main Sep 24, 2026
49 checks passed
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.

2 participants