Skip to content

Conversation

@k-fish
Copy link
Member

@k-fish k-fish commented Nov 25, 2025

Summary

This fixes draw scrollTo for log exceptions to not infinitely scroll, and fixes both metrics and logs to have a query param to have it open for linking.

This fixes draw scrollTo for log exceptions to not infinitely scroll, and fixes both metrics and logs to have a query param to have it open for linking.
@k-fish k-fish requested a review from a team as a code owner November 25, 2025 17:22
@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Nov 25, 2025
Comment on lines 140 to -108
},
onClose: () => {
navigate(
{
...location,
query: {
...location.query,
[LOGS_DRAWER_QUERY_PARAM]: undefined,
expandedLogId: undefined,
},
},
{replace: true}
);
},
}
);
},
[group, event, project, openDrawer, organization, traceId]
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Race condition in onOpenLogsDrawer can cause expandedLogId to persist in URL due to stale location.query after drawer close.
Severity: HIGH | Confidence: High

🔍 Detailed Analysis

When onOpenLogsDrawer is called after onClose has been triggered but before the location object has fully updated to reflect expandedLogId: undefined, the ...location.query spread will include the stale expandedLogId from the previous navigation. This occurs if a user closes the drawer and immediately clicks "View more" again. The drawer then opens with scrollToDisabled: true even though no specific log was selected, breaking the intended scroll behavior for the pseudo event.

💡 Suggested Fix

Modify onOpenLogsDrawer to explicitly set expandedLogId: undefined in the new query object when no expandedLogId is passed, instead of relying on ...location.query to implicitly remove it. This ensures the parameter is cleared regardless of location object staleness.

🤖 Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: static/app/components/events/ourlogs/ourlogsSection.tsx#L104-L108

Potential issue: When `onOpenLogsDrawer` is called after `onClose` has been triggered
but before the `location` object has fully updated to reflect `expandedLogId:
undefined`, the `...location.query` spread will include the stale `expandedLogId` from
the previous navigation. This occurs if a user closes the drawer and immediately clicks
"View more" again. The drawer then opens with `scrollToDisabled: true` even though no
specific log was selected, breaking the intended scroll behavior for the pseudo event.

Did we get this right? 👍 / 👎 to inform future reviews.
Reference ID: 3557864

[onOpenLogsDrawer]
);
}
}, [location.query, traceId, group, event, project, openDrawer, navigate, location]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Drawer opens even when feature flag is disabled

The useEffect that opens the logs drawer checks shouldOpenDrawer && traceId but doesn't check the ourlogs-enabled feature flag. The feature flag check at line 158 happens after the effect is defined, but React hooks run regardless of what the component returns. This means if someone shares a URL with logsDrawer=true to an organization that doesn't have ourlogs-enabled, the drawer will still open, bypassing the feature gate. The effect's condition needs to include feature (e.g., shouldOpenDrawer && traceId && feature).

Fix in Cursor Fix in Web

@k-fish k-fish merged commit e033a48 into master Nov 25, 2025
49 checks passed
@k-fish k-fish deleted the fix/ourlogs/fix-jump-bottom branch November 25, 2025 21:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants