Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {Tooltip} from '@sentry/scraps/tooltip';
import {Count} from 'sentry/components/count';
import {usePageFilters} from 'sentry/components/pageFilters/usePageFilters';
import {Placeholder} from 'sentry/components/placeholder';
import {TimeSince} from 'sentry/components/timeSince';
import {IconCopy} from 'sentry/icons';
import {t} from 'sentry/locale';
import {normalizeUrl} from 'sentry/utils/url/normalizeUrl';
Expand Down Expand Up @@ -99,6 +100,25 @@ export function ConversationSummary({
const organization = useOrganization();
const {selection} = usePageFilters();
const aggregates = useMemo(() => calculateAggregates(nodes), [nodes]);
const lastMessageDate = useMemo(() => {
if (nodes.length === 0) {
return null;
}

let endTimestamp = Number.NEGATIVE_INFINITY;

for (const node of nodes) {
if (typeof node.endTimestamp === 'number') {
endTimestamp = Math.max(endTimestamp, node.endTimestamp);
}
}

if (!Number.isFinite(endTimestamp)) {
return null;
}

return new Date(endTimestamp * 1e3);
}, [nodes]);

const handleCopyConversationId = useCallback(() => {
copyToClipboard(conversationId, {
Expand Down Expand Up @@ -186,6 +206,19 @@ export function ConversationSummary({
value={formatLLMCosts(aggregates.totalCost)}
isLoading={isLoading}
/>
<AggregateItem
label={t('Last message')}
value={
lastMessageDate ? (
<TimeSince date={lastMessageDate} />
) : (
<Text size="sm" variant="muted">
{'\u2014'}
</Text>
)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Bug: The "Last message" timestamp in the summary reflects the last span's activity, not necessarily the last actual message, which can be misleading.
Severity: LOW

Suggested Fix

To ensure the "Last message" timestamp accurately reflects the last conversational turn, filter the nodes array to only include spans that represent user or assistant messages before finding the maximum end_timestamp. This will align the summary data with the user-facing messages.

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/views/insights/pages/conversations/components/conversationSummary.tsx#L218

Potential issue: The UI displays a field labeled "Last message", but the value is
calculated from the end timestamp of the last span in the conversation, regardless of
its type. If the last span is a tool execution or another non-message activity that
finishes after the final user or assistant message, the displayed timestamp will not
correspond to the last actual message. This creates a discrepancy between the summary
header and the content of the messages panel, which could mislead users about when the
conversation's last communication occurred.

Did we get this right? 👍 / 👎 to inform future reviews.

}
isLoading={isLoading}
/>
{isLoading ? (
<Flex align="center" gap="xs" flexShrink={0}>
<Text size="sm" bold variant="muted">
Expand Down
Loading