Skip to content

Commit c866043

Browse files
authored
feat(ai-insights): open traces drawer from conversation table (#102386)
1 parent 7a59e94 commit c866043

File tree

3 files changed

+32
-5
lines changed

3 files changed

+32
-5
lines changed

static/app/views/insights/agents/components/conversationsTable.tsx

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import {Fragment, memo, useCallback} from 'react';
22
import styled from '@emotion/styled';
33

4+
import {Flex} from '@sentry/scraps/layout';
5+
6+
import {Button} from 'sentry/components/core/button';
47
import Pagination from 'sentry/components/pagination';
58
import GridEditable, {
69
COL_WIDTH_UNDEFINED,
@@ -16,6 +19,7 @@ import {useApiQuery} from 'sentry/utils/queryClient';
1619
import useOrganization from 'sentry/utils/useOrganization';
1720
import usePageFilters from 'sentry/utils/usePageFilters';
1821
import {getExploreUrl} from 'sentry/views/explore/utils';
22+
import {useTraceViewDrawer} from 'sentry/views/insights/agents/components/drawer';
1923
import {LLMCosts} from 'sentry/views/insights/agents/components/llmCosts';
2024
import {useTableCursor} from 'sentry/views/insights/agents/hooks/useTableCursor';
2125
import {ErrorCell} from 'sentry/views/insights/agents/utils/cells';
@@ -52,9 +56,10 @@ export function ConversationsTable() {
5256
const EMPTY_ARRAY: never[] = [];
5357

5458
const defaultColumnOrder: Array<GridColumnOrder<string>> = [
55-
{key: 'conversationId', name: t('Conversation ID'), width: 150},
59+
{key: 'conversationId', name: t('Conversation ID'), width: 135},
60+
{key: 'traceIds', name: t('Traces'), width: 130},
5661
{key: 'flow', name: t('Flow'), width: COL_WIDTH_UNDEFINED}, // Containing summary of the conversation or list of agents
57-
{key: 'duration', name: t('Root Duration'), width: 130},
62+
{key: 'duration', name: t('Duration'), width: 130},
5863
{key: 'errors', name: t('Errors'), width: 100},
5964
{key: 'llmCalls', name: t('LLM Calls'), width: 110},
6065
{key: 'toolCalls', name: t('Tool Calls'), width: 110},
@@ -69,6 +74,8 @@ const rightAlignColumns = new Set([
6974
'toolCalls',
7075
'totalTokens',
7176
'totalCost',
77+
'timestamp',
78+
'duration',
7279
]);
7380

7481
function ConversationsTableInner() {
@@ -158,10 +165,26 @@ const BodyCell = memo(function BodyCell({
158165
}) {
159166
const organization = useOrganization();
160167
const {selection} = usePageFilters();
168+
const {openTraceViewDrawer} = useTraceViewDrawer();
161169

162170
switch (column.key) {
163171
case 'conversationId':
164-
return <span>{dataRow.conversationId}</span>;
172+
return dataRow.conversationId.slice(0, 8);
173+
case 'traceIds':
174+
return (
175+
<Flex align="start" direction="column" gap="sm">
176+
{dataRow.traceIds.length > 0 &&
177+
dataRow.traceIds.map(traceId => (
178+
<TraceIdButton
179+
key={traceId}
180+
priority="link"
181+
onClick={() => openTraceViewDrawer(traceId)}
182+
>
183+
{traceId.slice(0, 8)}
184+
</TraceIdButton>
185+
))}
186+
</Flex>
187+
);
165188
case 'flow':
166189
return <span>{dataRow.flow.join(' → ')}</span>;
167190
case 'duration':
@@ -220,3 +243,7 @@ const HeadCell = styled('div')<{align: 'left' | 'right'}>`
220243
gap: ${p => p.theme.space.xs};
221244
justify-content: ${p => (p.align === 'right' ? 'flex-end' : 'flex-start')};
222245
`;
246+
247+
const TraceIdButton = styled(Button)`
248+
font-weight: normal;
249+
`;

static/app/views/insights/agents/components/drawer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ const TraceViewDrawer = memo(function TraceViewDrawer({
105105
);
106106
});
107107

108-
export function useTraceViewDrawer({onClose = undefined}: UseTraceViewDrawerProps) {
108+
export function useTraceViewDrawer({onClose}: UseTraceViewDrawerProps = {}) {
109109
const organization = useOrganization();
110110
const {openDrawer, isDrawerOpen, drawerUrlState, closeDrawer} = useUrlTraceDrawer();
111111

static/app/views/insights/agents/components/tracesTable.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ const BodyCell = memo(function BodyCell({
232232
}) {
233233
const organization = useOrganization();
234234
const {selection} = usePageFilters();
235-
const {openTraceViewDrawer} = useTraceViewDrawer({});
235+
const {openTraceViewDrawer} = useTraceViewDrawer();
236236

237237
switch (column.key) {
238238
case 'traceId':

0 commit comments

Comments
 (0)