The best way to control Claude Code, Codex and more from any computer or phone
fix(azure-devops): read and edit a Bug's text in Repro Steps (#39738)
Julius Marminge committed
Nov 20, 2026 at 06:25 UTC
cf1032018680f36e813988e9fdf42ebe2b23303b
3 files changed
+85
-36
packages/source-control-azure-devops/src/server/AzureDevOpsIssueTracker.test.ts
+24
@@ -214,6 +214,30 @@ describe("AzureDevOpsIssueTracker", () => {
214
}),
215
);
216
217
+ it.effect("reads a Bug's text from Repro Steps when it has no Description", () =>
218
+ Effect.gen(function* () {
219
+ const { "System.Description": _description, ...fields } = WORK_ITEM.fields;
220
+ const bug = {
221
+ ...WORK_ITEM,
222
+ fields: { ...fields, "Microsoft.VSTS.TCM.ReproSteps": "<div>Open the composer.</div>" },
223
+ };
224
+ const writes: Array<string[]> = [];
225
+ const api = yield* tracker((args) => {
226
+ if (args[0] === "boards" && args[2] === "update") writes.push([...args]);
227
+ return args[0] === "boards" ? encode(bug) : answer(args);
228
+ });
229
+ const scope = { cwd: "/w", host: "dev.azure.com", scope: "acme/Web App", key: "7" };
230
+ const issue = yield* api.getIssue(scope);
231
+ expect(issue.body).toBe("<div>Open the composer.</div>");
232
+ yield* api.update!({ ...scope, body: "Close it.", labels: ["ui"] });
233
+ expect(
234
+ writes.map((args) =>
235
+ args.slice(args.indexOf("--id") + 2, args.indexOf("--only-show-errors")),
236
+ ),
237
+ ).toEqual([["--fields", "System.Tags=ui", "Microsoft.VSTS.TCM.ReproSteps=Close it."]]);
238
+ }),
239
+ );
240
+
241
it.effect("filters open work items by the project's own finished states", () =>
242
Effect.gen(function* () {
243
const fs = yield* FileSystem.FileSystem;
packages/source-control-azure-devops/src/server/AzureDevOpsIssueTracker.ts
+44
-35
@@ -564,13 +564,6 @@ export const make: Effect.Effect<
564
stdin: input.stdin,
565
}).pipe(Effect.asVoid);
566
567
- /** A write names its work item by id alone, so the item is first read to be the scope's own. */
568
- const owned = (
569
- operation: string,
570
- cwd: string,
571
- scope: { readonly organization: string; readonly project: string; readonly number: number },
572
- ) => workItem({ ...scope, cwd, operation, closed: new Set() }).pipe(Effect.as(scope));
573
-
567
/** Azure keeps tags as one `; `-joined field and takes exactly one assignee. */
568
const fieldArgs = (
569
operation: string,
@@ -594,9 +587,7 @@ export const make: Effect.Effect<
587
refused(operation, "Azure DevOps takes no label or assignee that starts with `@`."),
588
);
589
}
597
- return Effect.succeed(
598
- fields.length === 0 ? [] : ["--fields", ...fields.map(([name, value]) => `${name}=${value}`)],
599
- );
590
+ return Effect.succeed(fields.map(([name, value]) => `${name}=${value}`));
591
};
592
593
return {
@@ -792,7 +783,7 @@ export const make: Effect.Effect<
783
type,
784
title.arg,
785
...(body === undefined || bodyFollows ? [] : [body.arg]),
795
- ...fields,
786
+ ...(fields.length === 0 ? [] : ["--fields", ...fields]),
787
],
788
stdin: title.stdin ?? body?.stdin,
789
decode: (raw) => decodeWorkItemJson(raw, closed),
@@ -840,43 +831,61 @@ export const make: Effect.Effect<
831
Effect.asVoid,
832
),
833
843
- update: (input) => {
844
- const texts = [
845
- ...(input.title === undefined ? [] : [AzureDevOpsCli.textOption("--title", input.title)]),
846
- ...(input.body === undefined
847
- ? []
848
- : [AzureDevOpsCli.textOption("--description", input.body)]),
849
- ];
850
- // az has one stdin, so each value read from it needs its own call.
851
- const batches =
852
- texts.filter((text) => text.stdin !== undefined).length > 1
853
- ? texts.map((text) => [text])
854
- : [texts];
855
- return target("update", input).pipe(
834
+ update: (input) =>
835
+ target("update", input).pipe(
836
Effect.flatMap((scope) =>
837
fieldArgs("update", input).pipe(Effect.map((fields) => ({ scope, fields }))),
838
),
859
- Effect.tap(({ scope }) => owned("update", input.cwd, scope)),
839
+ // `az` names a work item by id alone, so the read proves the item is the scope's own; it
840
+ // also names the field the item keeps its text in.
841
Effect.flatMap(({ scope, fields }) =>
861
- Effect.forEach(
842
+ workItem({ ...scope, cwd: input.cwd, operation: "update", closed: new Set() }).pipe(
843
+ Effect.map((item) => ({ scope, fields, bodyField: item.bodyField })),
844
+ ),
845
+ ),
846
+ Effect.flatMap(({ scope, fields, bodyField }) => {
847
+ const texts = [
848
+ ...(input.title === undefined
849
+ ? []
850
+ : [{ ...AzureDevOpsCli.textOption("--title", input.title), field: false }]),
851
+ ...(input.body === undefined
852
+ ? []
853
+ : bodyField === "System.Description"
854
+ ? [{ ...AzureDevOpsCli.textOption("--description", input.body), field: false }]
855
+ : [{ ...AzureDevOpsCli.textOption(bodyField, input.body), field: true }]),
856
+ ];
857
+ // az has one stdin, so each value read from it needs its own call.
858
+ const batches =
859
+ texts.filter((text) => text.stdin !== undefined).length > 1
860
+ ? texts.map((text) => [text])
861
+ : [texts];
862
+ return Effect.forEach(
863
batches,
863
- (batch, index) =>
864
- update({
864
+ (batch, index) => {
865
+ // az keeps only the last `--fields`, so every field of a call goes in one.
866
+ const pairs = [
867
+ ...(index === 0 ? fields : []),
868
+ ...batch.flatMap((text) => (text.field ? [text.arg] : [])),
869
+ ];
870
+ return update({
871
...scope,
872
cwd: input.cwd,
873
operation: "update",
868
- args: [...batch.map((text) => text.arg), ...(index === 0 ? fields : [])],
874
+ args: [
875
+ ...batch.flatMap((text) => (text.field ? [] : [text.arg])),
876
+ ...(pairs.length === 0 ? [] : ["--fields", ...pairs]),
877
+ ],
878
stdin: batch.find((text) => text.stdin !== undefined)?.stdin,
870
- }),
879
+ });
880
+ },
881
{ discard: true },
872
- ),
873
- ),
874
- );
875
- },
882
+ );
883
+ }),
884
+ ),
885
886
setState: (input) =>
887
target("setState", input).pipe(
879
- // The read also proves the item is the scope's own, as `owned` does for other writes.
888
+ // `az` names a work item by id alone, so the read also proves the item is the scope's own.
889
Effect.flatMap((scope) =>
890
workItem({ ...scope, cwd: input.cwd, operation: "setState", closed: new Set() }).pipe(
891
Effect.flatMap((item) =>
packages/source-control-azure-devops/src/server/azureDevOpsIssueJson.ts
+17
-1
@@ -81,6 +81,7 @@ const Fields = Schema.Struct({
81
"System.ChangedDate": Schema.optional(Schema.NullOr(Schema.String)),
82
"Microsoft.VSTS.Common.ClosedDate": Schema.optional(Schema.NullOr(Schema.String)),
83
"System.Description": Schema.optional(Schema.NullOr(Schema.String)),
84
+ "Microsoft.VSTS.TCM.ReproSteps": Schema.optional(Schema.NullOr(Schema.String)),
85
"System.Tags": Schema.optional(Schema.NullOr(Schema.String)),
86
"System.TeamProject": Schema.optional(Schema.NullOr(Schema.String)),
87
"System.WorkItemType": Schema.optional(Schema.NullOr(Schema.String)),
@@ -160,13 +161,26 @@ function toLabels(tags: string | null | undefined): ReadonlyArray<IssueLabel> {
161
}));
162
}
163
164
+/** The field a work item keeps its text in, which is the one an edit of its body writes. */
165
+export type BodyField = "System.Description" | "Microsoft.VSTS.TCM.ReproSteps";
166
+
167
export interface AzureDevOpsWorkItem extends TrackerIssueSummary {
168
readonly body: string;
169
+ readonly bodyField: BodyField;
170
readonly project: string | null;
171
readonly workItemType: string | null;
172
readonly relations: ReadonlyArray<typeof Relation.Type>;
173
}
174
175
+/** A Bug has Repro Steps where other types have a Description, and in Agile and CMMI no Description. */
176
+function bodyFieldOf(fields: typeof Fields.Type): BodyField {
177
+ const bug = trimmed(fields["System.WorkItemType"])?.toLowerCase() === "bug";
178
+ return trimmed(fields["System.Description"]) === null &&
179
+ (bug || trimmed(fields["Microsoft.VSTS.TCM.ReproSteps"]) !== null)
180
+ ? "Microsoft.VSTS.TCM.ReproSteps"
181
+ : "System.Description";
182
+}
183
+
184
/** Null for a row this cannot place: no title, no dates, or no project to build a link from. */
185
function toWorkItem(raw: typeof WorkItem.Type, closed: ClosedStates): AzureDevOpsWorkItem | null {
186
const fields = raw.fields ?? {};
@@ -179,6 +193,7 @@ function toWorkItem(raw: typeof WorkItem.Type, closed: ClosedStates): AzureDevOp
193
return null;
194
}
195
const assignee = toActor(fields["System.AssignedTo"]);
196
+ const bodyField = bodyFieldOf(fields);
197
return {
198
key: String(raw.id),
199
displayKey: `#${raw.id}`,
@@ -192,7 +207,8 @@ function toWorkItem(raw: typeof WorkItem.Type, closed: ClosedStates): AzureDevOp
207
assignees: assignee === null ? [] : [assignee],
208
labels: toLabels(fields["System.Tags"]),
209
commentCount: Math.max(0, fields["System.CommentCount"] ?? 0),
195
- body: fields["System.Description"] ?? "",
210
+ body: fields[bodyField] ?? "",
211
+ bodyField,
212
project,
213
workItemType: trimmed(fields["System.WorkItemType"]),
214
relations: raw.relations ?? [],