From 1469ffd3a7513363d46950e6bc3a7c4c3ed26486 Mon Sep 17 00:00:00 2001 From: "claude[bot]" <41898282+claude[bot]@users.noreply.github.com> Date: Thu, 16 Jul 2026 19:44:00 +0000 Subject: [PATCH 1/2] feat(gitlab): add optional webUrl field to derive projectUrl Adds an optional `webUrl` field to the GitLab connection config schema. When set, it is used to construct repository links in the GitLab web UI, letting the API host (`url`) differ from the browsable host (`webUrl`). Fixes #1456 Co-authored-by: Brendan Kellam <10233483+brendan-kellam@users.noreply.github.com> --- CHANGELOG.md | 1 + docs/snippets/schemas/v3/connection.schema.mdx | 9 +++++++++ docs/snippets/schemas/v3/gitlab.schema.mdx | 9 +++++++++ docs/snippets/schemas/v3/index.schema.mdx | 9 +++++++++ packages/backend/src/repoCompileUtils.ts | 3 ++- packages/schemas/src/v3/connection.schema.ts | 9 +++++++++ packages/schemas/src/v3/connection.type.ts | 4 ++++ packages/schemas/src/v3/gitlab.schema.ts | 9 +++++++++ packages/schemas/src/v3/gitlab.type.ts | 4 ++++ packages/schemas/src/v3/index.schema.ts | 9 +++++++++ packages/schemas/src/v3/index.type.ts | 4 ++++ schemas/v3/gitlab.json | 9 +++++++++ 12 files changed, 78 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 31da4d167..910cb71e1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Added an opt-in `SOURCEBOT_LLM_USER_EMAIL_HEADER_ENABLED` environment variable that sends the authenticated user's lower-cased email to language model providers in the `X-Sourcebot-User-Email` header. [#1455](https://github.com/sourcebot-dev/sourcebot/pull/1455) +- Added an optional `webUrl` field to the GitLab connection config, used to build links to repositories in the GitLab web UI when the API host differs from the browsable host. [#1457](https://github.com/sourcebot-dev/sourcebot/pull/1457) ### Fixed - [EE] Verified signed online license assertions before granting paid feature entitlements. [#1442](https://github.com/sourcebot-dev/sourcebot/pull/1442) diff --git a/docs/snippets/schemas/v3/connection.schema.mdx b/docs/snippets/schemas/v3/connection.schema.mdx index 4671abf74..2d4607b9d 100644 --- a/docs/snippets/schemas/v3/connection.schema.mdx +++ b/docs/snippets/schemas/v3/connection.schema.mdx @@ -272,6 +272,15 @@ ], "pattern": "^https?:\\/\\/[^\\s/$.?#].[^\\s]*$" }, + "webUrl": { + "type": "string", + "format": "url", + "description": "The base URL used to construct links to repositories in the GitLab web UI. Useful when the API is served from a different host than the one users browse (e.g. `https://api.gitlab.example.com` for `url` and `https://gitlab.example.com` for `webUrl`). Defaults to the value of `url`.", + "examples": [ + "https://gitlab.example.com" + ], + "pattern": "^https?:\\/\\/[^\\s/$.?#].[^\\s]*$" + }, "all": { "type": "boolean", "default": false, diff --git a/docs/snippets/schemas/v3/gitlab.schema.mdx b/docs/snippets/schemas/v3/gitlab.schema.mdx index f911c68a7..017e5fc5e 100644 --- a/docs/snippets/schemas/v3/gitlab.schema.mdx +++ b/docs/snippets/schemas/v3/gitlab.schema.mdx @@ -51,6 +51,15 @@ ], "pattern": "^https?:\\/\\/[^\\s/$.?#].[^\\s]*$" }, + "webUrl": { + "type": "string", + "format": "url", + "description": "The base URL used to construct links to repositories in the GitLab web UI. Useful when the API is served from a different host than the one users browse (e.g. `https://api.gitlab.example.com` for `url` and `https://gitlab.example.com` for `webUrl`). Defaults to the value of `url`.", + "examples": [ + "https://gitlab.example.com" + ], + "pattern": "^https?:\\/\\/[^\\s/$.?#].[^\\s]*$" + }, "all": { "type": "boolean", "default": false, diff --git a/docs/snippets/schemas/v3/index.schema.mdx b/docs/snippets/schemas/v3/index.schema.mdx index 864359251..172d04988 100644 --- a/docs/snippets/schemas/v3/index.schema.mdx +++ b/docs/snippets/schemas/v3/index.schema.mdx @@ -763,6 +763,15 @@ ], "pattern": "^https?:\\/\\/[^\\s/$.?#].[^\\s]*$" }, + "webUrl": { + "type": "string", + "format": "url", + "description": "The base URL used to construct links to repositories in the GitLab web UI. Useful when the API is served from a different host than the one users browse (e.g. `https://api.gitlab.example.com` for `url` and `https://gitlab.example.com` for `webUrl`). Defaults to the value of `url`.", + "examples": [ + "https://gitlab.example.com" + ], + "pattern": "^https?:\\/\\/[^\\s/$.?#].[^\\s]*$" + }, "all": { "type": "boolean", "default": false, diff --git a/packages/backend/src/repoCompileUtils.ts b/packages/backend/src/repoCompileUtils.ts index 04632a796..6888f2510 100644 --- a/packages/backend/src/repoCompileUtils.ts +++ b/packages/backend/src/repoCompileUtils.ts @@ -167,12 +167,13 @@ export const compileGitlabConfig = async ( const warnings = gitlabReposResult.warnings; const hostUrl = (config.url ?? 'https://gitlab.com').replace(/\/+$/, ''); + const webUrl = (config.webUrl ?? hostUrl).replace(/\/+$/, ''); const repoNameRoot = new URL(hostUrl) .toString() .replace(/^https?:\/\//, ''); const repos = gitlabRepos.map((project) => { - const projectUrl = `${hostUrl}/${project.path_with_namespace}`; + const projectUrl = `${webUrl}/${project.path_with_namespace}`; const cloneUrl = new URL(project.http_url_to_repo); cloneUrl.protocol = new URL(hostUrl).protocol; const isFork = project.forked_from_project !== undefined; diff --git a/packages/schemas/src/v3/connection.schema.ts b/packages/schemas/src/v3/connection.schema.ts index c539e918d..15d80600d 100644 --- a/packages/schemas/src/v3/connection.schema.ts +++ b/packages/schemas/src/v3/connection.schema.ts @@ -271,6 +271,15 @@ const schema = { ], "pattern": "^https?:\\/\\/[^\\s/$.?#].[^\\s]*$" }, + "webUrl": { + "type": "string", + "format": "url", + "description": "The base URL used to construct links to repositories in the GitLab web UI. Useful when the API is served from a different host than the one users browse (e.g. `https://api.gitlab.example.com` for `url` and `https://gitlab.example.com` for `webUrl`). Defaults to the value of `url`.", + "examples": [ + "https://gitlab.example.com" + ], + "pattern": "^https?:\\/\\/[^\\s/$.?#].[^\\s]*$" + }, "all": { "type": "boolean", "default": false, diff --git a/packages/schemas/src/v3/connection.type.ts b/packages/schemas/src/v3/connection.type.ts index fbfb16570..7d85e86e7 100644 --- a/packages/schemas/src/v3/connection.type.ts +++ b/packages/schemas/src/v3/connection.type.ts @@ -131,6 +131,10 @@ export interface GitlabConnectionConfig { * The URL of the GitLab host. Defaults to https://gitlab.com */ url?: string; + /** + * The base URL used to construct links to repositories in the GitLab web UI. Useful when the API is served from a different host than the one users browse (e.g. `https://api.gitlab.example.com` for `url` and `https://gitlab.example.com` for `webUrl`). Defaults to the value of `url`. + */ + webUrl?: string; /** * Sync all projects visible to the provided `token` (if any) in the GitLab instance. This option is ignored if `url` is either unset or set to https://gitlab.com . */ diff --git a/packages/schemas/src/v3/gitlab.schema.ts b/packages/schemas/src/v3/gitlab.schema.ts index 78412a054..1c5819c90 100644 --- a/packages/schemas/src/v3/gitlab.schema.ts +++ b/packages/schemas/src/v3/gitlab.schema.ts @@ -50,6 +50,15 @@ const schema = { ], "pattern": "^https?:\\/\\/[^\\s/$.?#].[^\\s]*$" }, + "webUrl": { + "type": "string", + "format": "url", + "description": "The base URL used to construct links to repositories in the GitLab web UI. Useful when the API is served from a different host than the one users browse (e.g. `https://api.gitlab.example.com` for `url` and `https://gitlab.example.com` for `webUrl`). Defaults to the value of `url`.", + "examples": [ + "https://gitlab.example.com" + ], + "pattern": "^https?:\\/\\/[^\\s/$.?#].[^\\s]*$" + }, "all": { "type": "boolean", "default": false, diff --git a/packages/schemas/src/v3/gitlab.type.ts b/packages/schemas/src/v3/gitlab.type.ts index b73372105..63eea72b5 100644 --- a/packages/schemas/src/v3/gitlab.type.ts +++ b/packages/schemas/src/v3/gitlab.type.ts @@ -25,6 +25,10 @@ export interface GitlabConnectionConfig { * The URL of the GitLab host. Defaults to https://gitlab.com */ url?: string; + /** + * The base URL used to construct links to repositories in the GitLab web UI. Useful when the API is served from a different host than the one users browse (e.g. `https://api.gitlab.example.com` for `url` and `https://gitlab.example.com` for `webUrl`). Defaults to the value of `url`. + */ + webUrl?: string; /** * Sync all projects visible to the provided `token` (if any) in the GitLab instance. This option is ignored if `url` is either unset or set to https://gitlab.com . */ diff --git a/packages/schemas/src/v3/index.schema.ts b/packages/schemas/src/v3/index.schema.ts index 8c1d64b52..2112b3d5b 100644 --- a/packages/schemas/src/v3/index.schema.ts +++ b/packages/schemas/src/v3/index.schema.ts @@ -762,6 +762,15 @@ const schema = { ], "pattern": "^https?:\\/\\/[^\\s/$.?#].[^\\s]*$" }, + "webUrl": { + "type": "string", + "format": "url", + "description": "The base URL used to construct links to repositories in the GitLab web UI. Useful when the API is served from a different host than the one users browse (e.g. `https://api.gitlab.example.com` for `url` and `https://gitlab.example.com` for `webUrl`). Defaults to the value of `url`.", + "examples": [ + "https://gitlab.example.com" + ], + "pattern": "^https?:\\/\\/[^\\s/$.?#].[^\\s]*$" + }, "all": { "type": "boolean", "default": false, diff --git a/packages/schemas/src/v3/index.type.ts b/packages/schemas/src/v3/index.type.ts index 7fa7f5a17..088b6829f 100644 --- a/packages/schemas/src/v3/index.type.ts +++ b/packages/schemas/src/v3/index.type.ts @@ -358,6 +358,10 @@ export interface GitlabConnectionConfig { * The URL of the GitLab host. Defaults to https://gitlab.com */ url?: string; + /** + * The base URL used to construct links to repositories in the GitLab web UI. Useful when the API is served from a different host than the one users browse (e.g. `https://api.gitlab.example.com` for `url` and `https://gitlab.example.com` for `webUrl`). Defaults to the value of `url`. + */ + webUrl?: string; /** * Sync all projects visible to the provided `token` (if any) in the GitLab instance. This option is ignored if `url` is either unset or set to https://gitlab.com . */ diff --git a/schemas/v3/gitlab.json b/schemas/v3/gitlab.json index c76a545ea..080f42cd3 100644 --- a/schemas/v3/gitlab.json +++ b/schemas/v3/gitlab.json @@ -22,6 +22,15 @@ ], "pattern": "^https?:\\/\\/[^\\s/$.?#].[^\\s]*$" }, + "webUrl": { + "type": "string", + "format": "url", + "description": "The base URL used to construct links to repositories in the GitLab web UI. Useful when the API is served from a different host than the one users browse (e.g. `https://api.gitlab.example.com` for `url` and `https://gitlab.example.com` for `webUrl`). Defaults to the value of `url`.", + "examples": [ + "https://gitlab.example.com" + ], + "pattern": "^https?:\\/\\/[^\\s/$.?#].[^\\s]*$" + }, "all": { "type": "boolean", "default": false, From cd6848ea90033430c3b34e7f0c90c13b19235acb Mon Sep 17 00:00:00 2001 From: Brendan Kellam Date: Thu, 16 Jul 2026 12:58:16 -0700 Subject: [PATCH 2/2] Update CHANGELOG --- CHANGELOG.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 39400e8ae..a104b7dc7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,11 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added +- Added an optional `webUrl` field to the GitLab connection config, used to build links to repositories in the GitLab web UI when the API host differs from the browsable host. [#1457](https://github.com/sourcebot-dev/sourcebot/pull/1457) + ## [5.1.2] - 2026-07-16 ### Added - Added an opt-in `SOURCEBOT_LLM_USER_EMAIL_HEADER_ENABLED` environment variable that sends the authenticated user's lower-cased email to language model providers in the `X-Sourcebot-User-Email` header. [#1455](https://github.com/sourcebot-dev/sourcebot/pull/1455) -- Added an optional `webUrl` field to the GitLab connection config, used to build links to repositories in the GitLab web UI when the API host differs from the browsable host. [#1457](https://github.com/sourcebot-dev/sourcebot/pull/1457) ### Fixed - [EE] Verified signed online license assertions before granting paid feature entitlements. [#1442](https://github.com/sourcebot-dev/sourcebot/pull/1442)