From 35ae0ee63644ea3ef48db80fab1631f67a2d1cff Mon Sep 17 00:00:00 2001 From: Scott Cooper Date: Wed, 15 Apr 2026 11:47:13 -0700 Subject: [PATCH 1/2] fix(issues): Don't send computed statsPeriod to group attachments endpoint MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The attachments hook was always forwarding `eventView.statsPeriod` to the API, even when no time filter was set by the user. This meant every request included a computed `?statsPeriod=Xh` derived from the issue's age — redundant since the backend returns all attachments when no time params are provided. Now only passes time params when the user has explicitly set them in the URL. Collapses the repetitive per-param ternaries into a single `filterParams` spread. Co-Authored-By: Claude Sonnet 4.6 --- .../useGroupEventAttachments.tsx | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/static/app/views/issueDetails/groupEventAttachments/useGroupEventAttachments.tsx b/static/app/views/issueDetails/groupEventAttachments/useGroupEventAttachments.tsx index 7cab4ca24505d0..20af9cde8337b3 100644 --- a/static/app/views/issueDetails/groupEventAttachments/useGroupEventAttachments.tsx +++ b/static/app/views/issueDetails/groupEventAttachments/useGroupEventAttachments.tsx @@ -14,8 +14,9 @@ interface UseGroupEventAttachmentsOptions { group: Group; options?: { /** - * If true, the query will fetch all available attachments for the group, ignoring the - * current filters (for environment, date, query, etc). + * If true, fetches all attachments for the group without applying any + * filters (environment, date range, query). Used by the header badge to + * determine whether the issue has any attachments at all. */ fetchAllAvailable?: boolean; placeholderData?: typeof keepPreviousData; @@ -116,7 +117,18 @@ export function useGroupEventAttachments({ const hasSetStatsPeriod = location.query.statsPeriod || location.query.start || location.query.end; - const fetchAllAvailable = options?.fetchAllAvailable; + + const filterParams = options?.fetchAllAvailable + ? {} + : { + environment: eventView.environment as string[], + eventQuery, + ...(hasSetStatsPeriod && { + start: eventView.start, + end: eventView.end, + statsPeriod: eventView.statsPeriod, + }), + }; const {data, isPending, isError, refetch} = useQuery({ ...fetchGroupEventAttachmentsApiOptions({ @@ -124,13 +136,7 @@ export function useGroupEventAttachments({ group, orgSlug: organization.slug, cursor: location.query.cursor as string | undefined, - // We only want to filter by date/query/environment if we're using the Streamlined UI - environment: fetchAllAvailable ? undefined : (eventView.environment as string[]), - start: fetchAllAvailable && !hasSetStatsPeriod ? undefined : eventView.start, - end: fetchAllAvailable && !hasSetStatsPeriod ? undefined : eventView.end, - statsPeriod: - fetchAllAvailable && !hasSetStatsPeriod ? undefined : eventView.statsPeriod, - eventQuery: fetchAllAvailable ? undefined : eventQuery, + ...filterParams, }), placeholderData: options?.placeholderData, select: selectJsonWithHeaders, From d51cf6b2bcac7b7c755baeb8878744cf045bc4aa Mon Sep 17 00:00:00 2001 From: Scott Cooper Date: Wed, 15 Apr 2026 12:07:07 -0700 Subject: [PATCH 2/2] fix(issues): Align handleDelete query key with fetch params The optimistic delete was using a different query key than the fetch because handleDelete always passed statsPeriod/start/end, but after the previous fix those are only included when explicitly set in the URL. This caused the cache update to miss and the deleted attachment stayed visible. Also removes the stale statsPeriod: '14d' from the screenshot filter test expectation. Co-Authored-By: Claude Sonnet 4.6 --- .../groupEventAttachments.spec.tsx | 1 - .../groupEventAttachments/groupEventAttachments.tsx | 11 ++++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/static/app/views/issueDetails/groupEventAttachments/groupEventAttachments.spec.tsx b/static/app/views/issueDetails/groupEventAttachments/groupEventAttachments.spec.tsx index 18f0a4f231763f..3b98d3ddfa5b4e 100644 --- a/static/app/views/issueDetails/groupEventAttachments/groupEventAttachments.spec.tsx +++ b/static/app/views/issueDetails/groupEventAttachments/groupEventAttachments.spec.tsx @@ -84,7 +84,6 @@ describe('GroupEventAttachments', () => { query: { screenshot: '1', environment: [], - statsPeriod: '14d', }, }) ); diff --git a/static/app/views/issueDetails/groupEventAttachments/groupEventAttachments.tsx b/static/app/views/issueDetails/groupEventAttachments/groupEventAttachments.tsx index decf5e1bb058a9..e5917768e86c51 100644 --- a/static/app/views/issueDetails/groupEventAttachments/groupEventAttachments.tsx +++ b/static/app/views/issueDetails/groupEventAttachments/groupEventAttachments.tsx @@ -74,6 +74,9 @@ export function GroupEventAttachments({project, group}: GroupEventAttachmentsPro const {mutate: deleteAttachment} = useDeleteGroupEventAttachment(); + const hasSetStatsPeriod = + location.query.statsPeriod || location.query.start || location.query.end; + const handleDelete = (attachment: IssueAttachment) => { deleteAttachment({ attachment, @@ -83,10 +86,12 @@ export function GroupEventAttachments({project, group}: GroupEventAttachmentsPro orgSlug: organization.slug, cursor: location.query.cursor as string | undefined, environment: eventView.environment as string[], - start: eventView.start, - end: eventView.end, - statsPeriod: eventView.statsPeriod, eventQuery, + ...(hasSetStatsPeriod && { + start: eventView.start, + end: eventView.end, + statsPeriod: eventView.statsPeriod, + }), }); };