feat(ai-conversations): use conversations endpoint#106367
Merged
obostjancic merged 10 commits intomasterfrom Jan 20, 2026
Merged
feat(ai-conversations): use conversations endpoint#106367obostjancic merged 10 commits intomasterfrom
obostjancic merged 10 commits intomasterfrom
Conversation
static/app/views/insights/pages/conversations/hooks/useConversation.tsx
Outdated
Show resolved
Hide resolved
Contributor
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
static/app/views/insights/pages/agents/components/aiSpanList.tsx
Outdated
Show resolved
Hide resolved
ArthurKnaus
reviewed
Jan 19, 2026
Comment on lines
294
to
306
|
|
||
| interface CompressedTimeBounds extends TraceBounds { | ||
| getCompressedTimestamp: (timestamp: number) => number; | ||
| } | ||
|
|
||
| const MAX_GAP_SECONDS = 30; | ||
| const COMPRESSED_GAP_SECONDS = 1; | ||
|
|
||
| /** | ||
| * Compresses large time gaps between spans to make the timeline more readable. | ||
| * Gaps larger than MAX_GAP_SECONDS are compressed to COMPRESSED_GAP_SECONDS. | ||
| */ | ||
| function getCompressedTimeBounds(nodes: AITraceSpanNode[]): CompressedTimeBounds { |
Member
There was a problem hiding this comment.
I got a few problems with this function:
- Too complex and costly for what it does as it has to iterate the segments on each call of getCompressedTimestamp. Instead we could just loop over it once and store the new timestamp for each span in a map.
- It ignores nested spans, simply summing up all durations and inflating the total time span. This results in the last span not ending the timeline (see screenshot).
- A few more comments on such a complex logic would help me figure out what it does 😅
Something like this could better suit your needs:
function getCompressedTimeBounds(nodes: AITraceSpanNode[]): CompressedTimeBounds {
const emptyResult: CompressedTimeBounds = {
startTime: 0,
endTime: 0,
duration: 0,
compressedStartByNodeId: new Map(),
};
if (nodes.length === 0) {
return emptyResult;
}
const sortedNodes = [...nodes]
.filter(n => n.startTimestamp && n.endTimestamp)
.sort((a, b) => (a.startTimestamp ?? 0) - (b.startTimestamp ?? 0));
if (sortedNodes.length === 0) {
return emptyResult;
}
const compressedStartByNodeId = new Map<string, number>();
// Track current segment bounds
const firstNode = sortedNodes[0]!;
let segmentRealStart = firstNode.startTimestamp!;
let segmentRealEnd = firstNode.endTimestamp!;
let segmentCompressedStart = 0;
compressedStartByNodeId.set(firstNode.id, 0);
for (let i = 1; i < sortedNodes.length; i++) {
const node = sortedNodes[i]!;
const nodeStart = node.startTimestamp!;
const nodeEnd = node.endTimestamp!;
if (nodeStart > segmentRealEnd) {
// Gap detected - finish current segment and start new one
const gap = nodeStart - segmentRealEnd;
const compressedGap = gap > MAX_GAP_SECONDS ? COMPRESSED_GAP_SECONDS : gap;
const segmentDuration = segmentRealEnd - segmentRealStart;
// Advance compressed time by segment duration + gap
segmentCompressedStart += segmentDuration + compressedGap;
// Start new segment
segmentRealStart = nodeStart;
segmentRealEnd = nodeEnd;
} else {
// Overlapping - extend current segment
segmentRealEnd = Math.max(segmentRealEnd, nodeEnd);
}
// Calculate this node's compressed start
const offsetInSegment = nodeStart - segmentRealStart;
compressedStartByNodeId.set(node.id, segmentCompressedStart + offsetInSegment);
}
// Total duration is the compressed start of last segment + its duration
const totalDuration = segmentCompressedStart + (segmentRealEnd - segmentRealStart);
return {
startTime: 0,
endTime: totalDuration,
duration: totalDuration,
compressedStartByNodeId,
};
}
Comment on lines
260
to
268
| const TabContent = styled('div')` | ||
| flex: 1; | ||
| min-height: 0; | ||
| overflow-y: auto; | ||
| overflow-x: hidden; | ||
| `; | ||
|
|
||
| const TabContentPadded = styled(TabContent)` | ||
| padding: ${p => p.theme.space.md} ${p => p.theme.space.lg}; |
Member
There was a problem hiding this comment.
We should rather use the design system primitives like Flex.
Same goes for the other styled components.
static/app/views/insights/pages/conversations/components/conversationDrawer.tsx
Show resolved
Hide resolved
static/app/views/insights/pages/conversations/components/messagesPanel.tsx
Show resolved
Hide resolved
ArthurKnaus
approved these changes
Jan 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
closes TET-1720: Call new conversation endpoint