Skip to content

Commit be4cdd0

Browse files
authored
fix(autofix): Fix comment thread x-position and make it easier to add solution items (#87229)
1. Fix comment thread's x-position 2. If you click anywhere on a disabled solution item, it enables it
1 parent 6a85d2c commit be4cdd0

File tree

2 files changed

+34
-8
lines changed

2 files changed

+34
-8
lines changed

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

+4-3
Original file line numberDiff line numberDiff line change
@@ -316,11 +316,12 @@ function AutofixHighlightPopupContent({
316316
);
317317
}
318318

319-
function getOptimalPosition(referenceRect: DOMRect, popupRect: DOMRect, spacing = 36) {
319+
function getOptimalPosition(referenceRect: DOMRect, popupRect: DOMRect) {
320320
const viewportHeight = window.innerHeight;
321+
const viewportWidth = window.innerWidth;
321322

322-
// Try positioning to the left first (default)
323-
const left = referenceRect.left - popupRect.width - spacing;
323+
// Fixed position from the right edge of the viewport
324+
const left = viewportWidth / 2 - popupRect.width + 8;
324325
let top = referenceRect.top;
325326

326327
// Ensure the popup stays within the viewport vertically

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

+30-5
Original file line numberDiff line numberDiff line change
@@ -218,9 +218,9 @@ function SolutionEventList({
218218
return [];
219219
}
220220

221-
// For 3 or fewer items, find the first highlighted item or default to first item
221+
// For 3 or fewer items, find the first highlighted and active item or default to first item
222222
const firstHighlightedIndex = events.findIndex(
223-
event => event.is_most_important_event
223+
event => event.is_most_important_event && event.is_active !== false
224224
);
225225
return [firstHighlightedIndex === -1 ? 0 : firstHighlightedIndex];
226226
});
@@ -231,6 +231,20 @@ function SolutionEventList({
231231
);
232232
}, []);
233233

234+
// Wrap onToggleActive to also handle expanded state
235+
const handleToggleActive = useCallback(
236+
(index: number) => {
237+
onToggleActive(index);
238+
// If we're disabling an item (toggling from active to inactive),
239+
// we need to remove it from expanded items
240+
const event = events[index];
241+
if (event && event.is_active !== false) {
242+
setExpandedItems(current => current.filter(i => i !== index));
243+
}
244+
},
245+
[events, onToggleActive]
246+
);
247+
234248
if (!events?.length) {
235249
return null;
236250
}
@@ -243,12 +257,23 @@ function SolutionEventList({
243257
const isExpanded = expandedItems.includes(index);
244258
const isHumanAction = event.timeline_item_type === 'human_instruction';
245259

260+
const handleItemClick = () => {
261+
if (!isSelected) {
262+
// If item is disabled, re-enable it instead of toggling expansion
263+
handleToggleActive(index);
264+
return;
265+
}
266+
if (!isHumanAction && event.code_snippet_and_analysis) {
267+
toggleItem(index);
268+
}
269+
};
270+
246271
return (
247272
<Timeline.Item
248273
key={index}
249274
title={
250275
<StyledTimelineHeader
251-
onClick={() => toggleItem(index)}
276+
onClick={handleItemClick}
252277
isActive={isActive}
253278
isSelected={isSelected}
254279
data-test-id={`autofix-solution-timeline-item-${index}`}
@@ -259,7 +284,7 @@ function SolutionEventList({
259284
}}
260285
/>
261286
<IconWrapper>
262-
{!isHumanAction && event.code_snippet_and_analysis && (
287+
{!isHumanAction && event.code_snippet_and_analysis && isSelected && (
263288
<StyledIconChevron
264289
direction={isExpanded ? 'down' : 'right'}
265290
size="xs"
@@ -272,7 +297,7 @@ function SolutionEventList({
272297
if (isHumanAction) {
273298
onDeleteItem(index);
274299
} else {
275-
onToggleActive(index);
300+
handleToggleActive(index);
276301
}
277302
}}
278303
aria-label={isSelected ? t('Deselect item') : t('Select item')}

0 commit comments

Comments
 (0)