@devries-cameron20 / t3code-1 / commits / f1d64aa0b6
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(azure-devops): legacy and project-less remotes list their work items (#38263)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Julius Marminge <julius0216@outlook.com> Co-authored-by: shivam <91240327+shivamhwp@users.noreply.github.com>

Bilal Bakr committed Nov 19, 2026 at 00:00 UTC f1d64aa0b6dea2c5473bd5f45d62d8ebb6d7a133
6 files changed +103 -19
apps/server/src/issue/IssueService.test.ts
+33
@@ -293,6 +293,39 @@ describe("IssueService", () => {
293 }),
294 );
295
296 + it.effect("resolves both legacy Azure work item URLs through the bound project", () =>
297 + Effect.gen(function* () {
298 + const tracker = IssueTrackerKind.make("azure-devops");
299 + const host = "acme.visualstudio.com";
300 + const service = yield* makeService({
301 + projects: [
302 + project({ id: "api", repository: "Api/_git/api", provider: tracker, host }),
303 + project({
304 + id: "web",
305 + repository: "DefaultCollection/Web/_git/web",
306 + provider: tracker,
307 + host,
308 + }),
309 + ],
310 + trackers: [fakeTracker({ kind: tracker })],
311 + });
312 + for (const path of ["Web", "DefaultCollection/Web"]) {
313 + const ref = yield* service.resolveUrl(
314 + `https://${host}/${path}/_workitems/edit/9`,
315 + "api" as ProjectId,
316 + );
317 + expect(ref).toEqual({
318 + projectId: "web",
319 + tracker,
320 + host,
321 + scope: "DefaultCollection/Web",
322 + key: "9",
323 + writable: true,
324 + });
325 + }
326 + }),
327 + );
328 +
329 it.effect("sends writes as interactive requests and reads as background ones", () =>
330 Effect.gen(function* () {
331 const interactive: Array<readonly [string, boolean]> = [];
apps/server/src/issue/IssueService.ts
+6 -3
@@ -704,9 +704,12 @@ const make = Effect.gen(function* () {
704 const onTracker = onAuthority.length > 0 ? onAuthority : onHost;
705 const preferFirst = (projects: ReadonlyArray<SupportedProject>) =>
706 projects.find((project) => project.project.id === preferredProjectId) ?? projects[0];
707 - const own = preferFirst(
708 - onTracker.filter((project) => project.scope.toLowerCase() === link.scope.toLowerCase()),
709 - );
707 + const scope = link.scope.toLowerCase();
708 + const own =
709 + preferFirst(onTracker.filter((project) => project.scope.toLowerCase() === scope)) ??
710 + preferFirst(
711 + onTracker.filter((project) => project.scope.toLowerCase() === gitHost?.link.scopeAlias),
712 + );
713 const lender = own ?? preferFirst(onTracker);
714 if (lender === undefined) {
715 return yield* new IssueUnavailableError({ reason: "tracker-unsupported" });
packages/client-runtime/src/issueLinks.ts
+3 -1
@@ -78,7 +78,9 @@ export function resolveIssueLinkTarget<Project extends LinkProject>(input: {
78 const preferFirst = (candidates: typeof bound) =>
79 candidates.find((candidate) => candidate.project.id === input.preferredProjectId) ??
80 candidates[0];
81 - const own = preferFirst(bound.filter((candidate) => candidate.binding.scope === link.scope));
81 + const own =
82 + preferFirst(bound.filter((candidate) => candidate.binding.scope === link.scope)) ??
83 + preferFirst(bound.filter((candidate) => candidate.binding.scope === link.scopeAlias));
84 const lender = own ?? preferFirst(bound);
85 if (lender === undefined) return null;
86 return {
packages/source-control-azure-devops/src/shared/definition.test.ts
+27 -2
@@ -260,14 +260,39 @@ describe("Azure DevOps issue scope", () => {
260 definition.issueScope?.({ provider: kind, displayName: "acme/Web%20App/_git/web" }),
261 ).toBe("acme/Web App");
262 expect(definition.issueScope?.({ provider: kind, displayName: "web" })).toBeNull();
263 - // One segment before `_git` is a different thing on each kind of host, so it is not placed.
263 + // One segment before `_git` is a different thing on each kind of host, so it needs the host.
264 expect(definition.issueScope?.({ provider: kind, displayName: "acme/_git/web" })).toBeNull();
265 + const scopeOn = (canonicalKey: string, displayName: string) =>
266 + definition.issueScope?.({ provider: kind, canonicalKey, displayName });
267 + expect(scopeOn("dev.azure.com/acme/_git/web", "acme/_git/Web")).toBe("acme/Web");
268 + expect(scopeOn("acme.visualstudio.com/web/_git/web", "Web%20App/_git/web")).toBe("Web App");
269 + expect(scopeOn("acme.visualstudio.com/_git/web", "_git/Web")).toBe("Web");
270 + // Its work items are at `acme.visualstudio.com/Web/_workitems/...`, without the collection.
271 + expect(
272 + scopeOn("acme.visualstudio.com/defaultcollection/_git/web", "DefaultCollection/_git/Web"),
273 + ).toBe("Web");
274 + expect(scopeOn("dev.azure.com/_git/web", "_git/web")).toBeNull();
275 // A legacy host keeps the organization in its name, and so does its work item URL.
276 expect(
277 definition.parseIssueUrl?.(
278 new URL("https://acme.visualstudio.com/Web%20App/_workitems/edit/9"),
279 ),
270 - ).toEqual({ host: "acme.visualstudio.com", scope: "web app", key: "9" });
280 + ).toEqual({
281 + host: "acme.visualstudio.com",
282 + scope: "web app",
283 + scopeAlias: "defaultcollection/web app",
284 + key: "9",
285 + });
286 + expect(
287 + definition.parseIssueUrl?.(
288 + new URL("https://acme.visualstudio.com/DefaultCollection/Web%20App/_workitems/edit/9"),
289 + ),
290 + ).toEqual({
291 + host: "acme.visualstudio.com",
292 + scope: "defaultcollection/web app",
293 + scopeAlias: "web app",
294 + key: "9",
295 + });
296 expect(
297 definition.parseIssueUrl?.(new URL("https://dev.azure.com/acme/_workitems/edit/9")),
298 ).toBeNull();
packages/source-control-azure-devops/src/shared/definition.ts
+27 -11
@@ -124,14 +124,18 @@ export const definition = defineSourceControl({
124 },
125 // A project named with spaces arrives percent-encoded; the binding it is matched against is not.
126 parseIssueUrl: (url) => {
127 + const legacy = url.hostname.toLowerCase().endsWith(".visualstudio.com");
128 const link =
129 parseIssuePath(url, WORK_ITEM_PATH) ??
129 - (url.hostname.toLowerCase().endsWith(".visualstudio.com")
130 - ? parseIssuePath(url, LEGACY_WORK_ITEM_PATH)
131 - : null);
132 - return link === null
133 - ? null
134 - : { ...link, scope: link.scope.split("/").map(decodeUrlPathSegment).join("/").toLowerCase() };
130 + (legacy ? parseIssuePath(url, LEGACY_WORK_ITEM_PATH) : null);
131 + if (link === null) return null;
132 + const scope = link.scope.split("/").map(decodeUrlPathSegment).join("/").toLowerCase();
133 + if (!legacy) return { ...link, scope };
134 + // On legacy hosts the default collection is optional in a work item URL.
135 + const scopeAlias =
136 + /^defaultcollection\/([^/]+)$/u.exec(scope)?.[1] ??
137 + (scope.includes("/") ? undefined : `defaultcollection/${scope}`);
138 + return { ...link, scope, ...(scopeAlias === undefined ? {} : { scopeAlias }) };
139 },
140 changeRequestUrlFromReferenceAutolink: () => null,
141 changeRequestActions: new Set([
@@ -170,13 +174,25 @@ export const definition = defineSourceControl({
174 return name ? decodeUrlPathSegment(name) : null;
175 },
176 // Work items belong to the project: `organization/project` out of the remote's
173 - // `organization/project/_git/repository`. A shorter path is not placed: `acme/_git/web` is a
174 - // project named after its repository on dev.azure.com and a bare project on a legacy host, and
175 - // nothing here says which host the remote is on.
177 + // `organization/project/_git/repository`. A shorter path depends on the host: `acme/_git/web`
178 + // is a project named after its repository on dev.azure.com and a bare project on a legacy host.
179 issueScope: (identity) => {
177 - const segments = (identity.displayName ?? "").split("/").filter((part) => part !== "");
180 + const segments = (identity.displayName ?? "")
181 + .split("/")
182 + .filter((part) => part !== "")
183 + .map(decodeUrlPathSegment);
184 const at = segments.indexOf("_git");
179 - return at === 2 ? segments.slice(0, at).map(decodeUrlPathSegment).join("/") : null;
185 + if (at === 2) return segments.slice(0, at).join("/");
186 + const repository = segments[at + 1];
187 + if ((at !== 0 && at !== 1) || repository === undefined) return null;
188 + const host = identity.canonicalKey?.split("/", 1)[0]?.toLowerCase() ?? "";
189 + const legacy = host.endsWith(".visualstudio.com");
190 + const [first = ""] = segments;
191 + if (at === 0) return legacy ? repository : null;
192 + if (host === "dev.azure.com") return `${first}/${repository}`;
193 + if (!legacy) return null;
194 + // Work item URLs on a legacy host leave the collection out.
195 + return first.toLowerCase() === "defaultcollection" ? repository : first;
196 },
197 repositoryKeyFromRemote,
198 canonicalRepositoryKey,
packages/source-control-core/src/shared/definition.ts
+7 -2
@@ -39,6 +39,8 @@ export interface ChangeRequestLink {
39 export interface IssueLink {
40 readonly host: string;
41 readonly scope: string;
42 + /** An equivalent binding scope when the provider allows another spelling in URLs. */
43 + readonly scopeAlias?: string;
44 readonly key: string;
45 }
46
@@ -94,6 +96,9 @@ export type RepositorySelectorIdentity = Pick<
96 "provider" | "displayName" | "owner" | "name"
97 >;
98
99 +export type IssueScopeIdentity = RepositorySelectorIdentity &
100 + Partial<Pick<RepositoryIdentity, "canonicalKey">>;
101 +
102 /** A git remote's host, as `recognizeRemote` reads it. */
103 export interface GitRemoteHost {
104 /** Trimmed. */
@@ -362,7 +367,7 @@ export interface SourceControlDefinition {
367 * The container the project's issues live in, where that is not its repository: Azure DevOps
368 * keeps work items per project. Null when the repository cannot be placed.
369 */
365 - readonly issueScope?: (identity: RepositorySelectorIdentity) => string | null;
370 + readonly issueScope?: (identity: IssueScopeIdentity) => string | null;
371 /**
372 * The key of a remote's lower case `host/path`, `.git` suffix kept, for a host that spells it
373 * apart from `normalizeGitRemoteUrl`: over SSH and the web, or with `.git` as part of the name.
@@ -699,7 +704,7 @@ export interface SourceControlDefinitionRegistry {
704 identity: RepositorySelectorIdentity | null | undefined,
705 ) => string | null;
706 /** Where the project's issues live: the host's `issueScope`, else its repository. */
702 - readonly issueScope: (identity: RepositorySelectorIdentity | null | undefined) => string | null;
707 + readonly issueScope: (identity: IssueScopeIdentity | null | undefined) => string | null;
708 readonly changeRequestHost: <const Kind extends string | undefined>(
709 identity: ChangeRequestHostIdentity,
710 kind: Kind,