Skip to content

Commit 2486f53

Browse files
obostjancicgeorge-sentry
authored andcommitted
fix(ai-conversations): use all projects for shared conversation links (#112343)
1 parent f0e2fd0 commit 2486f53

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

static/app/views/insights/pages/conversations/hooks/useConversation.spec.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,16 +228,23 @@ describe('useConversation', () => {
228228
expect(result.current.isLoading).toBe(false);
229229
});
230230

231-
// Verify the API was called with correct timestamps (with 1-hour padding)
231+
// Verify the API was called with correct timestamps (with 1-hour padding),
232+
// ALL_ACCESS_PROJECTS (-1) so it searches across all projects,
233+
// and no environment filter so it searches across all environments
232234
expect(mockRequest).toHaveBeenCalledWith(
233235
expect.stringContaining('/ai-conversations/conv-timestamps/'),
234236
expect.objectContaining({
235237
query: expect.objectContaining({
236238
start: new Date(startTimestamp - 60 * 60 * 1000).toISOString(),
237239
end: new Date(endTimestamp + 60 * 60 * 1000).toISOString(),
240+
project: [-1],
238241
}),
239242
})
240243
);
244+
245+
// Ensure environment is not included in the query when using conversation timestamps
246+
const queryArg = mockRequest.mock.calls[0]![1]!.query;
247+
expect(queryArg).not.toHaveProperty('environment');
241248
});
242249

243250
it('falls back to span.name when span.description is empty', async () => {

static/app/views/insights/pages/conversations/hooks/useConversation.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {useEffect, useMemo} from 'react';
22

3+
import {ALL_ACCESS_PROJECTS} from 'sentry/components/pageFilters/constants';
34
import {normalizeDateTimeParams} from 'sentry/components/pageFilters/parse';
45
import {usePageFilters} from 'sentry/components/pageFilters/usePageFilters';
56
import {getApiUrl} from 'sentry/utils/api/getApiUrl';
@@ -193,10 +194,12 @@ export function useConversation(
193194
const hasConversationTimestamps =
194195
conversation.startTimestamp !== undefined && conversation.endTimestamp !== undefined;
195196

197+
// When conversation timestamps are provided (e.g. from a shared link),
198+
// search across all projects and environments so the conversation is found
199+
// regardless of which project/environment the page filter is currently set to.
196200
const queryParams = hasConversationTimestamps
197201
? {
198-
project: selection.projects,
199-
environment: selection.environments,
202+
project: [ALL_ACCESS_PROJECTS],
200203
start: new Date(conversation.startTimestamp! - ONE_HOUR_MS).toISOString(),
201204
end: new Date(conversation.endTimestamp! + ONE_HOUR_MS).toISOString(),
202205
per_page: 1000,

0 commit comments

Comments
 (0)