Skip to content

Commit c7c8200

Browse files
committed
fix(pull-requests): address Azure review feedback
Reset mobile refresh state in finally, use shared web form controls, and describe comment tasks in user guidance. Keep SDK and read failure text in causes while learning permission denials from bounded reasons. Run Azure SDK Python in isolated mode to block checkout and environment module injection while preserving installed extension discovery. Verified with focused regressions and a read-only installed-runtime check on the disposable PR. GPT-6.1 Sol through Codex.
1 parent 9114b41 commit c7c8200

14 files changed

Lines changed: 376 additions & 127 deletions

‎apps/mobile/src/features/pull-requests/PullRequestRouteScreen.tsx‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -383,8 +383,11 @@ export function PullRequestRouteScreen({ route }: StaticScreenProps<PullRequestP
383383
const refresh = async () => {
384384
if (invalidating) return;
385385
setInvalidating(true);
386-
await invalidate({ environmentId: target.environmentId, input: { reference: target.input } });
387-
setInvalidating(false);
386+
try {
387+
await invalidate({ environmentId: target.environmentId, input: { reference: target.input } });
388+
} finally {
389+
setInvalidating(false);
390+
}
388391
pullRefresh.onRefresh();
389392
if (guidesEnabled) refreshGuide();
390393
stack.refresh();

‎apps/web/src/components/pullRequest/AzureDevOpsPullRequestActions.tsx‎

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { Checkbox } from "../ui/checkbox";
2+
import { Select, SelectItem, SelectPopup, SelectTrigger } from "../ui/select";
13
import {
24
PullRequestPermissionButton,
35
PullRequestPermissionHint,
@@ -62,8 +64,6 @@ import {
6264
AlertDialogFooter,
6365
} from "../ui/alert-dialog";
6466

65-
const selectClass = "rounded border border-border bg-background px-2 py-1 text-xs text-foreground";
66-
6767
function settled<A, E>(result: AtomCommandResult<A, E>) {
6868
if (result._tag === "Failure") throw squashAtomCommandFailure(result);
6969
return result.value;
@@ -628,9 +628,8 @@ function AzureActionDialog({
628628
<div className="space-y-2">
629629
<label className="flex items-center gap-2">
630630
Target branch{" "}
631-
<input
631+
<Input
632632
aria-label="Target branch"
633-
className={selectClass}
634633
list="azure-target-branches"
635634
value={branch}
636635
onChange={(event) => setBranch(event.target.value)}
@@ -703,41 +702,42 @@ function AzureActionDialog({
703702
<div className="space-y-2">
704703
<label className="flex items-center gap-2">
705704
Merge strategy{" "}
706-
<select
707-
aria-label="Azure merge strategy"
708-
className={selectClass}
705+
<Select
709706
value={options.strategy}
710-
onChange={(event) => {
707+
onValueChange={(value) => {
711708
const strategy = AzureDevOpsMergeStrategy.literals.find(
712-
(value) => value === event.target.value,
709+
(candidate) => candidate === value,
713710
);
714711
if (strategy) setCompletion((current) => ({ ...current, strategy }));
715712
}}
716713
>
717-
{AzureDevOpsMergeStrategy.literals.map((value) => (
718-
<option
719-
key={value}
720-
value={value}
721-
disabled={
722-
!completion.bypassPolicy && allowedStrategies?.includes(value) === false
723-
}
724-
>
725-
{azureMergeStrategyLabels[value]}
726-
</option>
727-
))}
728-
</select>
714+
<SelectTrigger size="xs" aria-label="Azure merge strategy">
715+
{azureMergeStrategyLabels[options.strategy]}
716+
</SelectTrigger>
717+
<SelectPopup>
718+
{AzureDevOpsMergeStrategy.literals.map((value) => (
719+
<SelectItem
720+
key={value}
721+
value={value}
722+
disabled={
723+
!completion.bypassPolicy && allowedStrategies?.includes(value) === false
724+
}
725+
>
726+
{azureMergeStrategyLabels[value]}
727+
</SelectItem>
728+
))}
729+
</SelectPopup>
730+
</Select>
729731
</label>
730732
{azureCompletionToggles.map((toggle) => {
731733
const reason = toggle.permission ? denied[toggle.permission] : undefined;
732734
return (
733735
<PullRequestPermissionHint key={toggle.key} reason={reason}>
734736
<label className="flex items-center gap-2">
735-
<input
736-
type="checkbox"
737+
<Checkbox
737738
disabled={Boolean(reason) && !completion[toggle.key]}
738739
checked={completion[toggle.key]}
739-
onChange={(event) => {
740-
const checked = event.target.checked;
740+
onCheckedChange={(checked) => {
741741
setCompletion((current) => ({ ...current, [toggle.key]: checked }));
742742
}}
743743
/>

‎apps/web/src/components/pullRequest/PullRequestCodeTab.tsx‎

Lines changed: 41 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { Select, SelectItem, SelectPopup, SelectTrigger } from "../ui/select";
12
import { PullRequestPermissionHint } from "./PullRequestPermissionButton";
23
import type { CodeViewItem, DiffLineAnnotation, SelectedLineRange } from "@pierre/diffs";
34
import type { CodeViewDiffItem, CodeViewHandle } from "@pierre/diffs/react";
@@ -1227,47 +1228,51 @@ function PullRequestCodeTab({
12271228
) : null}
12281229
{latestUpdateId !== undefined ? (
12291230
<div className="flex items-center gap-1">
1230-
<label className="sr-only" htmlFor="pr-update-from">
1231-
Compare from update
1232-
</label>
1233-
<select
1234-
id="pr-update-from"
1235-
className="max-w-28 rounded border bg-background px-1 py-1"
1231+
<Select
12361232
value={updateComparison.comparison.from}
1237-
onChange={(event) => pickUpdates({ from: Number(event.target.value) })}
1233+
onValueChange={(value) => {
1234+
if (typeof value === "number") pickUpdates({ from: value });
1235+
}}
12381236
>
1239-
<option value={0}>Base</option>
1240-
{detail
1241-
.updates!.filter((update) => update.id < (iterationRange?.to ?? latestUpdateId))
1242-
.map((update) => (
1243-
<option key={update.id} value={update.id}>
1244-
Update {update.id}
1245-
</option>
1246-
))}
1247-
</select>
1237+
<SelectTrigger size="xs" aria-label="Compare from update">
1238+
{updateComparison.comparison.from === 0
1239+
? "Base"
1240+
: `Update ${updateComparison.comparison.from}`}
1241+
</SelectTrigger>
1242+
<SelectPopup>
1243+
<SelectItem value={0}>Base</SelectItem>
1244+
{detail
1245+
.updates!.filter((update) => update.id < (iterationRange?.to ?? latestUpdateId))
1246+
.map((update) => (
1247+
<SelectItem key={update.id} value={update.id}>
1248+
Update {update.id}
1249+
</SelectItem>
1250+
))}
1251+
</SelectPopup>
1252+
</Select>
12481253
<span>→</span>
1249-
<label className="sr-only" htmlFor="pr-update-to">
1250-
Compare to update
1251-
</label>
1252-
<select
1253-
id="pr-update-to"
1254-
className="max-w-28 rounded border bg-background px-1 py-1"
1254+
<Select<number | "latest">
12551255
value={updateComparison.comparison.to}
1256-
onChange={(event) =>
1257-
pickUpdates({
1258-
to: event.target.value === "latest" ? "latest" : Number(event.target.value),
1259-
})
1260-
}
1256+
onValueChange={(value) => {
1257+
if (value === "latest" || typeof value === "number") pickUpdates({ to: value });
1258+
}}
12611259
>
1262-
<option value="latest">Latest</option>
1263-
{detail
1264-
.updates!.filter((update) => update.id > updateComparison.comparison.from)
1265-
.map((update) => (
1266-
<option key={update.id} value={update.id}>
1267-
Update {update.id}
1268-
</option>
1269-
))}
1270-
</select>
1260+
<SelectTrigger size="xs" aria-label="Compare to update">
1261+
{updateComparison.comparison.to === "latest"
1262+
? "Latest"
1263+
: `Update ${updateComparison.comparison.to}`}
1264+
</SelectTrigger>
1265+
<SelectPopup>
1266+
<SelectItem value="latest">Latest</SelectItem>
1267+
{detail
1268+
.updates!.filter((update) => update.id > updateComparison.comparison.from)
1269+
.map((update) => (
1270+
<SelectItem key={update.id} value={update.id}>
1271+
Update {update.id}
1272+
</SelectItem>
1273+
))}
1274+
</SelectPopup>
1275+
</Select>
12711276
</div>
12721277
) : null}
12731278
{/* One count, and the caveats as icons that carry their own words. Spelled out they

‎apps/web/src/components/pullRequest/PullRequestDiscussionActions.test.tsx‎

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ vi.mock("~/state/pullRequests", () => ({
2323
},
2424
}));
2525
vi.mock("../ui/button", () => ({ Button: "button" }));
26+
vi.mock("../ui/select", () => ({
27+
Select: "select",
28+
SelectTrigger: "button",
29+
SelectPopup: "div",
30+
SelectItem: "option",
31+
}));
2632
vi.mock("../ui/tooltip", () => ({
2733
Tooltip: ({ children }: { children: ReactNode }) => children,
2834
TooltipTrigger: ({ render, children }: { render: ReactElement; children: ReactNode }) =>
@@ -91,26 +97,20 @@ it("preserves native states, reports failure, and refuses changes after permissi
9197
renderer = create(render());
9298
});
9399
for (const status of statuses.slice(1)) {
94-
await act(async () =>
95-
renderer!.root.findByType("select").props.onChange({ target: { value: status } }),
96-
);
100+
await act(async () => renderer!.root.findByType("select").props.onValueChange(status));
97101
expect(state.run).toHaveBeenLastCalledWith({
98102
environmentId: props.environmentId,
99103
input: { ...props.reference, threadId: "7734", status, resolved: status !== "pending" },
100104
});
101105
}
102106
state.run.mockResolvedValueOnce({ _tag: "Failure" });
103-
await act(async () =>
104-
renderer!.root.findByType("select").props.onChange({ target: { value: "fixed" } }),
105-
);
107+
await act(async () => renderer!.root.findByType("select").props.onValueChange("fixed"));
106108
expect(renderer!.root.findByType("select").props.value).toBe("byDesign");
107109
expect(renderer!.root.findByProps({ role: "alert" })).toBeDefined();
108110
state.allowed = false;
109111
act(() => renderer!.update(render()));
110112
state.run.mockClear();
111-
await act(async () =>
112-
renderer!.root.findByType("select").props.onChange({ target: { value: "fixed" } }),
113-
);
113+
await act(async () => renderer!.root.findByType("select").props.onValueChange("fixed"));
114114
expect(state.run).not.toHaveBeenCalled();
115115
});
116116
it("keeps a chosen status until activity reports it, then follows later changes", async () => {
@@ -128,7 +128,7 @@ it("keeps a chosen status until activity reports it, then follows later changes"
128128
});
129129
const change = deferred();
130130
state.run.mockReturnValueOnce(change.promise);
131-
act(() => select().onChange({ target: { value: "fixed" } }));
131+
act(() => select().onValueChange("fixed"));
132132
expect(select()).toMatchObject({ value: "fixed", disabled: true });
133133
await act(async () => change.resolve({ _tag: "Success" }));
134134
expect(select()).toMatchObject({ value: "fixed", disabled: false });
@@ -143,21 +143,21 @@ it("keeps a chosen status until activity reports it, then follows later changes"
143143

144144
const refused = deferred();
145145
state.run.mockReturnValueOnce(refused.promise);
146-
act(() => select().onChange({ target: { value: "wontFix" } }));
146+
act(() => select().onValueChange("wontFix"));
147147
expect(select().value).toBe("wontFix");
148148
await act(async () => refused.resolve({ _tag: "Failure" }));
149149
expect(select().value).toBe("active");
150150
expect(renderer!.root.findByProps({ role: "alert" })).toBeDefined();
151151

152152
const overtaken = deferred();
153153
state.run.mockReturnValueOnce(overtaken.promise);
154-
act(() => select().onChange({ target: { value: "closed" } }));
154+
act(() => select().onValueChange("closed"));
155155
act(() => renderer!.update(render("byDesign")));
156156
expect(select().value).toBe("byDesign");
157157
await act(async () => overtaken.resolve({ _tag: "Success" }));
158158
expect(select().value).toBe("byDesign");
159159

160-
await act(async () => select().onChange({ target: { value: "pending" } }));
160+
await act(async () => select().onValueChange("pending"));
161161
expect(select().value).toBe("pending");
162162
act(() => renderer!.update(render("byDesign", "other")));
163163
expect(select().value).toBe("byDesign");

‎apps/web/src/components/pullRequest/PullRequestDiscussionStatus.tsx‎

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { Select, SelectItem, SelectPopup, SelectTrigger } from "../ui/select";
12
import { PullRequestPermissionHint } from "./PullRequestPermissionButton";
23
import { usePullRequestDeniedActions } from "./PullRequestReviewContext";
34
import { pullRequestThreadStatusLabels as labels } from "@t3tools/client-runtime/pull-request-comment-replies";
@@ -78,22 +79,25 @@ export function PullRequestDiscussionStatus({
7879
<label className="flex items-center gap-2 text-muted-foreground">
7980
Status
8081
<PullRequestPermissionHint reason={reason}>
81-
<select
82-
aria-label="Discussion status"
83-
className="rounded border border-border bg-background px-2 py-1 text-foreground"
82+
<Select
8483
value={shown}
8584
disabled={!allowed || busy || Boolean(reason)}
86-
onChange={(event) => {
87-
const next = statuses.find((value) => value === event.target.value);
85+
onValueChange={(value) => {
86+
const next = statuses.find((candidate) => candidate === value);
8887
if (next) void change(next);
8988
}}
9089
>
91-
{statuses.map((value) => (
92-
<option key={value} value={value}>
93-
{labels[value]}
94-
</option>
95-
))}
96-
</select>
90+
<SelectTrigger size="xs" aria-label="Discussion status">
91+
{labels[shown]}
92+
</SelectTrigger>
93+
<SelectPopup>
94+
{statuses.map((value) => (
95+
<SelectItem key={value} value={value}>
96+
{labels[value]}
97+
</SelectItem>
98+
))}
99+
</SelectPopup>
100+
</Select>
97101
</PullRequestPermissionHint>
98102
</label>
99103
{error ? (

‎docs/user/source-control.md‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,7 @@ an uncertain result is never automatically retried elsewhere. Listings, diffs, a
192192
PR creation from Git actions continue to use the project's environment.
193193

194194
For Azure DevOps, comments stay grouped in discussions, including replies on lines of the diff.
195-
Use the icons beside a comment to like it or edit and delete your own comment. Its menu lets you
196-
copy a link to it. Resolve a discussion after replying, or choose another Azure status. Resolved discussions are hidden by
195+
You can like comments, edit or delete your own, and copy a comment’s link. Resolve a discussion after replying, or choose another Azure status. Resolved discussions are hidden by
197196
default; include them in the comment filter to reactivate one. Applying a code suggestion commits
198197
it to the source branch; refresh first if someone has pushed new changes.
199198

‎packages/source-control-azure-devops/src/server/AzureDevOpsCli.test.ts‎

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -494,8 +494,8 @@ describe("repository-scoped PR updates", () => {
494494
bodyFile: input.bodyFile,
495495
routeValues: input.routeValues,
496496
});
497-
expect(request?.args?.[1]).toContain("9946fd70-0d40-406e-b686-b4744cbbcc37");
498-
expect(request?.args?.[1]).toContain("get_git_client");
497+
expect(request?.args?.[2]).toContain("9946fd70-0d40-406e-b686-b4744cbbcc37");
498+
expect(request?.args?.[2]).toContain("get_git_client");
499499
}).pipe(Effect.provide(layer)),
500500
);
501501

@@ -534,6 +534,30 @@ it.effect("preserves the host's native operation refusal instead of reporting su
534534
const error = yield* az
535535
.notificationSubscriptions({ cwd: "/repo", method: "POST", bodyFile: "/tmp/body.json" })
536536
.pipe(Effect.flip);
537-
expect(error.detail).toBe("This credential lacks notification write permission.");
537+
expect(error).toMatchObject({ reason: "permission-denied", argumentCount: 3 });
538+
expect(error.detail).toBe(
539+
"Your Azure credential lacks the required scope or permission for this action.",
540+
);
541+
expect(error.cause).toBe("This credential lacks notification write permission.");
542+
}).pipe(Effect.provide(layer)),
543+
);
544+
545+
it.effect("keeps unexpected SDK error text in the cause without displaying it", () =>
546+
Effect.gen(function* () {
547+
const secret = "remote detail with a private project URL and token";
548+
mockRun.mockReturnValueOnce(
549+
Effect.succeed(processOutput("Python location '/opt/az/bin/python'")),
550+
);
551+
mockRun.mockReturnValueOnce(
552+
Effect.succeed(processOutput(JSON.stringify({ _t3SdkError: { message: secret } }))),
553+
);
554+
const az = yield* AzureDevOpsCli.AzureDevOpsCli;
555+
const error = yield* az
556+
.notificationSubscriptions({ cwd: "/repo", method: "POST" })
557+
.pipe(Effect.flip);
558+
expect(error).toMatchObject({ reason: "failed", cause: secret });
559+
expect(error.detail).toBe("Azure refused this operation.");
560+
expect(error.message).not.toContain(secret);
561+
expect(mockRun.mock.calls[1]?.[0].args?.slice(0, 2)).toEqual(["-I", "-c"]);
538562
}).pipe(Effect.provide(layer)),
539563
);

0 commit comments

Comments
 (0)