Skip to content

Commit dbe9b2e

Browse files
authored
feat(autofix): Show error message when drafting PR (#97867)
If drafting a PR or checking out locally fails, we currently just do nothing. Now, we'll show an error message so users can debug their permissions set up. <img width="620" height="400" alt="Screenshot 2025-08-14 at 10 26 21 AM" src="https://github.com/user-attachments/assets/eb8a64c8-5637-4fd1-9460-fa53525daf5b" />
1 parent 3643c57 commit dbe9b2e

File tree

1 file changed

+82
-63
lines changed

1 file changed

+82
-63
lines changed

static/app/components/events/autofix/autofixChanges.tsx

Lines changed: 82 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -323,73 +323,78 @@ export function AutofixChanges({
323323
))}
324324
</ClippedBox>
325325
<BottomDivider />
326-
<BottomButtonContainer>
327-
{!prsMade && (
328-
<ButtonBar>
329-
{branchesMade ? (
330-
step.changes.length === 1 && step.changes[0] ? (
331-
<BranchButton change={step.changes[0]} />
326+
<BottomButtonContainer hasTerminationReason={!!step.termination_reason}>
327+
{step.termination_reason && (
328+
<TerminationReasonText>{step.termination_reason}</TerminationReasonText>
329+
)}
330+
<ButtonContainer>
331+
{!prsMade && (
332+
<ButtonBar>
333+
{branchesMade ? (
334+
step.changes.length === 1 && step.changes[0] ? (
335+
<BranchButton change={step.changes[0]} />
336+
) : (
337+
<ScrollCarousel aria-label={t('Check out branches')}>
338+
{step.changes.map(
339+
(change, idx) =>
340+
change.branch_name && (
341+
<BranchButton
342+
key={`${change.repo_external_id}-${idx}`}
343+
change={change}
344+
/>
345+
)
346+
)}
347+
</ScrollCarousel>
348+
)
332349
) : (
333-
<ScrollCarousel aria-label={t('Check out branches')}>
334-
{step.changes.map(
335-
(change, idx) =>
336-
change.branch_name && (
337-
<BranchButton
338-
key={`${change.repo_external_id}-${idx}`}
339-
change={change}
340-
/>
341-
)
342-
)}
343-
</ScrollCarousel>
344-
)
345-
) : (
346-
<SetupAndCreateBranchButton
350+
<SetupAndCreateBranchButton
351+
changes={step.changes}
352+
groupId={groupId}
353+
runId={runId}
354+
isBusy={isBusy || isPrProcessing}
355+
onProcessingChange={setIsBranchProcessing}
356+
/>
357+
)}
358+
<SetupAndCreatePRsButton
347359
changes={step.changes}
348360
groupId={groupId}
349361
runId={runId}
350-
isBusy={isBusy || isPrProcessing}
351-
onProcessingChange={setIsBranchProcessing}
362+
isBusy={isBusy || isBranchProcessing}
363+
onProcessingChange={setIsPrProcessing}
352364
/>
353-
)}
354-
<SetupAndCreatePRsButton
355-
changes={step.changes}
356-
groupId={groupId}
357-
runId={runId}
358-
isBusy={isBusy || isBranchProcessing}
359-
onProcessingChange={setIsPrProcessing}
360-
/>
361-
</ButtonBar>
362-
)}
363-
{prsMade &&
364-
(step.changes.length === 1 && step.changes[0]?.pull_request?.pr_url ? (
365-
<LinkButton
366-
size="xs"
367-
priority="primary"
368-
icon={<IconOpen size="xs" />}
369-
href={step.changes[0].pull_request.pr_url}
370-
external
371-
>
372-
View PR in {step.changes[0].repo_name}
373-
</LinkButton>
374-
) : (
375-
<ScrollCarousel aria-label={t('View pull requests')}>
376-
{step.changes.map(
377-
(change, idx) =>
378-
change.pull_request?.pr_url && (
379-
<LinkButton
380-
key={`${change.repo_external_id}-${idx}`}
381-
size="xs"
382-
priority="primary"
383-
icon={<IconOpen size="xs" />}
384-
href={change.pull_request.pr_url}
385-
external
386-
>
387-
View PR in {change.repo_name}
388-
</LinkButton>
389-
)
390-
)}
391-
</ScrollCarousel>
392-
))}
365+
</ButtonBar>
366+
)}
367+
{prsMade &&
368+
(step.changes.length === 1 && step.changes[0]?.pull_request?.pr_url ? (
369+
<LinkButton
370+
size="xs"
371+
priority="primary"
372+
icon={<IconOpen size="xs" />}
373+
href={step.changes[0].pull_request.pr_url}
374+
external
375+
>
376+
View PR in {step.changes[0].repo_name}
377+
</LinkButton>
378+
) : (
379+
<ScrollCarousel aria-label={t('View pull requests')}>
380+
{step.changes.map(
381+
(change, idx) =>
382+
change.pull_request?.pr_url && (
383+
<LinkButton
384+
key={`${change.repo_external_id}-${idx}`}
385+
size="xs"
386+
priority="primary"
387+
icon={<IconOpen size="xs" />}
388+
href={change.pull_request.pr_url}
389+
external
390+
>
391+
View PR in {change.repo_name}
392+
</LinkButton>
393+
)
394+
)}
395+
</ScrollCarousel>
396+
))}
397+
</ButtonContainer>
393398
</BottomButtonContainer>
394399
</ChangesContainer>
395400
</AnimationWrapper>
@@ -488,7 +493,21 @@ const BottomDivider = styled('div')`
488493
margin-bottom: ${p => p.theme.space.xl};
489494
`;
490495

491-
const BottomButtonContainer = styled('div')`
496+
const BottomButtonContainer = styled('div')<{hasTerminationReason?: boolean}>`
497+
display: flex;
498+
justify-content: ${p => (p.hasTerminationReason ? 'space-between' : 'flex-end')};
499+
align-items: center;
500+
gap: ${p => p.theme.space.xl};
501+
`;
502+
503+
const TerminationReasonText = styled('div')`
504+
color: ${p => p.theme.errorText};
505+
font-size: ${p => p.theme.fontSize.sm};
506+
flex: 1;
507+
min-width: 0;
508+
`;
509+
510+
const ButtonContainer = styled('div')`
492511
display: flex;
493512
justify-content: flex-end;
494513
`;

0 commit comments

Comments
 (0)