Skip to content
Merged
Show file tree
Hide file tree
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
51 changes: 34 additions & 17 deletions src/ui/src/dashboard/CallFlow.css
Original file line number Diff line number Diff line change
Expand Up @@ -441,8 +441,6 @@
position: relative;
overflow: inherit;
opacity: 1;
margin-left: var(--flow-left-px, 12px);
margin-right: var(--flow-right-px, 12px);
min-width: 0;
min-height: 64px;
}
Expand All @@ -459,40 +457,49 @@
.item-flow-packet-container .bg-color-polygon {
position: absolute;
z-index: 0;
top: 0;
bottom: 0;
left: calc(-1 * var(--flow-left-px, 12px));
right: calc(-1 * var(--flow-right-px, 12px));
inset: 0;
opacity: 0.28;
filter: saturate(120%);
pointer-events: none;
}

.item-flow-packet-container .bg-color-tab {
position: absolute;
left: calc(-1 * var(--flow-left-px, 12px));
left: 0;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

.single-host used to keep this tab on the host centre, and the tint on the 280px loop only. The row was inset with --flow-left-px / --flow-right-px, and those rules set left / right back to 0 inside that inset.

The margins are gone, so left: 0 is the left edge of the whole row and inset: 0 paints the full width. With several hosts that is the same full-bleed as before. With one host the card is centered, and the tab ends up far from the loop.

The loop itself is unchanged: flowSegmentPx still starts at the measured centre and uses RADIAL_FALLBACK_PX (280). Please check a one-host call.

@MrM0bi MrM0bi Nov 19, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Checked a one-host call. I'd keep the full-width rows: they now match multi-host calls, where the tab already sits at the row edge. Putting the tint and tab back on the loop inside full-width rows (c) gives a narrow tinted column between full-width separators. Going back to a narrow row (a) would make one-host calls look different from every other call. What do you prefer?

a: homer11 b: this PR c: tint/tab on the loop

|
issue2-a-homer11-original
|
issue2-b-this-pr-full-width
|
issue2-c-tint-tab-restored
|

top: 0;
bottom: 0;
width: 5px;
border-radius: var(--radius-sm) 0 0 var(--radius-sm);
pointer-events: none;
}

/* One host: the message is only the loop, so keep the tint, tab, border and
hover on it. The container stays full width; FlowItem sets --loop-left and
--loop-width from the measured host centre. */
.item-flow-packet-container.single-host .bg-color-polygon {
left: 0;
right: 0;
left: var(--loop-left);
right: auto;
width: var(--loop-width);
}

.item-flow-packet-container.single-host .bg-color-tab {
left: 0;
left: var(--loop-left);
}

.item-flow-packet-container.single-host .item-flow-packet {
margin-left: var(--loop-left);
width: var(--loop-width);
/* No arrow has to end on a lifeline here, so keep the text clear of the tab. */
padding-inline: 6px;
}

.item-flow-packet {
position: relative;
z-index: 1;
width: 100%;
min-width: 0;
padding: 8px 6px 10px;
/* No horizontal padding: the track's x origin must match the host centres' origin. */
padding: 8px 0 10px;
border-bottom: 1px solid color-mix(in oklch, var(--color-border) 55%, transparent);
cursor: pointer;
transition: background-color 0.15s ease, box-shadow 0.15s ease;
Expand Down Expand Up @@ -601,18 +608,20 @@
.item-flow-packet .arrow::after {
content: '';
position: absolute;
right: -1px;
right: 0;
bottom: -6px;
border: 5px solid transparent;
border-left: 12px solid;
/* No trailing border, so the tip lands exactly on the line end (the host lifeline). */
border-style: solid;
border-color: transparent;
border-width: 5px 0 5px 12px;
border-left-color: currentColor;
}

.item-flow-packet .arrow.left::after {
right: initial;
left: -1px;
border: 5px solid transparent;
border-right: 12px solid;
left: 0;
border-color: transparent;
border-width: 5px 12px 5px 0;
border-right-color: currentColor;
}

Expand Down Expand Up @@ -716,6 +725,14 @@
margin-top: 2px;
}

/* Last-host loop sits at the segment's right edge, so the badges must too.
A block with width:auto would take the free space and zero margin-left:auto. */
.radial-port-labels.end {
width: max-content;
margin-left: auto;
gap: 4px;
}

.radial-port-labels .radial-port-src,
.radial-port-labels .radial-port-dst {
padding: 1px 6px;
Expand Down
23 changes: 8 additions & 15 deletions src/ui/src/dashboard/CallFlow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ export default function CallFlow({ items, timeZone, onClickMessage, onShowOtlpEv
const innerWidth = Math.max(hosts.length * 220, 560)

const innerRef = useRef<HTMLDivElement>(null)
const [gridLines, setGridLines] = useState<number[]>([])
// Host lifeline x-positions (px from the left of .callflow-inner). Both the
// grid lines and every arrow are positioned from these, so they cannot drift apart.
const [hostCenters, setHostCenters] = useState<number[]>([])

useLayoutEffect(() => {
const el = innerRef.current
Expand All @@ -87,18 +89,9 @@ export default function CallFlow({ items, timeZone, onClickMessage, onShowOtlpEv
const rect = wrapper.getBoundingClientRect()
positions.push(rect.left + rect.width / 2 - innerRect.left)
})
setGridLines(positions)

if (positions.length >= 2) {
el.style.setProperty('--flow-left-px', `${positions[0]}px`)
el.style.setProperty('--flow-right-px', `${innerRect.width - positions[positions.length - 1]}px`)
} else if (positions.length === 1) {
el.style.setProperty('--flow-left-px', `${positions[0]}px`)
el.style.setProperty('--flow-right-px', `${innerRect.width - positions[0] - 280}px`)
} else {
el.style.removeProperty('--flow-left-px')
el.style.removeProperty('--flow-right-px')
}
setHostCenters((prev) =>
prev.length === positions.length && prev.every((p, i) => p === positions[i]) ? prev : positions,
)
}

measure()
Expand Down Expand Up @@ -136,7 +129,7 @@ export default function CallFlow({ items, timeZone, onClickMessage, onShowOtlpEv
style={{ width: `max(100%, ${innerWidth}px)` }}
>
<div className="flow-grid-overlay">
{gridLines.map((px, i) => (
{hostCenters.map((px, i) => (
<div
key={hosts[i]?.key || i}
className="grid-line"
Expand All @@ -157,7 +150,7 @@ export default function CallFlow({ items, timeZone, onClickMessage, onShowOtlpEv
item={item}
isSimplify={filters.isSimplify}
isAbsoluteTime={filters.isAbsoluteTime}
singleHost={hosts.length === 1}
hostCenters={hostCenters}
onClickItem={onClickMessage}
expandedKey={expandedItemKey}
setExpandedKey={setExpandedItemKey}
Expand Down
60 changes: 59 additions & 1 deletion src/ui/src/dashboard/flow/FlowItem.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ function makeItem(direction: boolean, overrides: Partial<FlowItemData> = {}): Fl
payloadType: 'SIP',
start: 0,
middle: 1,
rightEnd: 0,
direction,
isRadial: false,
isLastHost: false,
Expand Down Expand Up @@ -115,3 +114,62 @@ describe('FlowItem consolidation', () => {
expect(onClickItem).not.toHaveBeenCalled()
})
})

describe('FlowItem geometry', () => {
it('places the arrow segment at the measured host centres', () => {
const { container } = render(
<FlowItem item={makeItem(false, { start: 1, middle: 1 })} isSimplify={false}
isAbsoluteTime={false} hostCenters={[85, 509, 910]} />,
)
const spacer = container.querySelector<HTMLElement>('.item-flow-track > div:first-child')!
const segment = container.querySelector<HTMLElement>('.item-flow-segment')!
expect(spacer.style.flex).toBe('0 0 509px')
expect(segment.style.flex).toBe('0 0 401px')
})
})

describe('FlowItem self-message loops', () => {
const radial = (o: Partial<FlowItemData>) => makeItem(false, { isRadial: true, middle: 1, ...o })

it('pins the port badges to the loop on the last host', () => {
const { container } = render(
<FlowItem item={radial({ start: 2, isLastHost: true, direction: true })} isSimplify={false}
isAbsoluteTime={false} hostCenters={[85, 509, 910]} />,
)
expect(container.querySelector('.radial-port-labels')?.classList.contains('end')).toBe(true)
})

it('keeps the badges left-aligned on other hosts', () => {
const { container } = render(
<FlowItem item={radial({ start: 1 })} isSimplify={false}
isAbsoluteTime={false} hostCenters={[85, 509, 910]} />,
)
expect(container.querySelector('.radial-port-labels')?.classList.contains('end')).toBe(false)
})
})

describe('FlowItem single host', () => {
const loop = makeItem(false, { isRadial: true, start: 0, middle: 1 })

it('sizes the row to the loop so tint, tab, border and hover stay on it', () => {
const { container } = render(
<FlowItem item={loop} isSimplify={false} isAbsoluteTime={false} hostCenters={[300]} />,
)
const row = container.querySelector<HTMLElement>('.item-flow-packet-container')!
expect(row.classList.contains('single-host')).toBe(true)
expect(row.style.getPropertyValue('--loop-left')).toBe('300px')
expect(row.style.getPropertyValue('--loop-width')).toBe('280px')
// The row itself is offset, so the track fills it instead of re-applying the offset.
expect(container.querySelector<HTMLElement>('.item-flow-track > div:first-child')!.style.flex).toBe('0 0 0px')
expect(container.querySelector<HTMLElement>('.item-flow-segment')!.style.flex).toBe('1 1 0%')
})

it('does not apply to calls with several hosts', () => {
const { container } = render(
<FlowItem item={{ ...loop, start: 1 }} isSimplify={false} isAbsoluteTime={false} hostCenters={[85, 509, 910]} />,
)
const row = container.querySelector<HTMLElement>('.item-flow-packet-container')!
expect(row.classList.contains('single-host')).toBe(false)
expect(row.style.getPropertyValue('--loop-left')).toBe('')
})
})
36 changes: 22 additions & 14 deletions src/ui/src/dashboard/flow/FlowItem.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import type { CSSProperties } from 'react'
import type { FlowItemData } from './flow-data'
import { flowSegmentPx } from './flow-data'

interface FlowItemProps {
item: FlowItemData
isSimplify: boolean
isAbsoluteTime: boolean
singleHost?: boolean
/** Measured host centres (px from the left edge of the flow), one per host. */
hostCenters?: readonly number[]
onClickItem?: (item: FlowItemData) => void
expandedKey?: string | null
setExpandedKey?: (key: string | null) => void
Expand All @@ -15,7 +18,7 @@ export function FlowItem({
item,
isSimplify,
isAbsoluteTime,
singleHost,
hostCenters,
onClickItem,
expandedKey,
setExpandedKey,
Expand All @@ -26,33 +29,39 @@ export function FlowItem({
const canToggleSubItems = hasSubItems && typeof setExpandedKey === 'function'
const showSubItems = canToggleSubItems && expandedKey === itemKey

const flexStart = item.start || 0.0000001
const flexMiddle = item.middle || 0.0000001
const flexRight = item.isRadial
? Math.max(0.0000001, item.rightEnd - (item.isLastHost ? 0 : 1))
: item.rightEnd || 0.0000001
// Until host centres are measured the segment just fills the row; the
// layout effect in CallFlow measures before the first paint.
const segment = hostCenters ? flowSegmentPx(item, hostCenters) : null
// With one host the message is only the loop, so the row's tint, tab, border
// and hover sit on the loop (.single-host) while the container stays full width.
const loop = hostCenters?.length === 1 ? segment : null
// A single-host row is itself sized to the loop, so its track just fills it.
const trackSegment = loop ? null : segment
const loopStyle = loop
? ({ '--loop-left': `${loop.left}px`, '--loop-width': `${loop.width}px` } as CSSProperties)
: undefined

const arrowColor = item.callidColors.arrowColor
const radialDottedClass = item.arrowStyleSolid ? '' : ' dotted'
const containerClass = `item-flow-packet-container${singleHost ? ' single-host' : ''}${
const containerClass = `item-flow-packet-container${loop ? ' single-host' : ''}${
hasSubItems ? ' consolidated-parent' : ''
}${isSubItem ? ' consolidated-subitem' : ''}`

return (
<>
<div className={containerClass}>
<div className={containerClass} style={loopStyle}>
<div className="bg-color-polygon" style={{ backgroundColor: item.callidColors.color }} />
<div className="bg-color-tab" style={{ backgroundColor: item.callidColors.tabColor }} />
<div
className="item-flow-packet"
onClick={() => onClickItem?.(item)}
>
<div className="item-flow-track">
<div style={{ flex: flexStart }} />
<div style={{ flex: `0 0 ${trackSegment?.left ?? 0}px` }} />
<div
className="item-flow-segment"
style={{
flex: flexMiddle,
flex: trackSegment ? `0 0 ${trackSegment.width}px` : '1 1 0%',
textAlign: item.direction ? 'right' : 'left',
}}
>
Expand Down Expand Up @@ -97,7 +106,7 @@ export function FlowItem({
)}

{item.isRadial ? (
<div className="radial-port-labels">
<div className={`radial-port-labels${item.isLastHost ? ' end' : ''}`}>
<span className="radial-port-src">{item.srcPort || ''}</span>
<span className="radial-port-dst">{item.dstPort || ''}</span>
</div>
Expand All @@ -117,7 +126,6 @@ export function FlowItem({
)}
{isSimplify && <div className="call-text-date">{item.diffStr}</div>}
</div>
<div style={{ flex: flexRight }} />
</div>
</div>
</div>
Expand All @@ -128,7 +136,7 @@ export function FlowItem({
item={subItem}
isSimplify={isSimplify}
isAbsoluteTime={isAbsoluteTime}
singleHost={singleHost}
hostCenters={hostCenters}
onClickItem={onClickItem}
expandedKey={expandedKey}
setExpandedKey={setExpandedKey}
Expand Down
31 changes: 29 additions & 2 deletions src/ui/src/dashboard/flow/flow-data.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { describe, expect, it } from 'vitest'
import {
buildFlow, buildHosts, endpointAlias, hostKey, hostKeyFromMessage,
runtimeFingerprintOf, captureIdOf, consolidateFlowItems, canConsolidateFlowItems,
payloadTypeOf,
payloadTypeOf, flowSegmentPx,
} from './flow-data'
import type { FlowItemData, RawMessage } from './flow-data'

Expand Down Expand Up @@ -101,7 +101,7 @@ function makeFlowItem(overrides: Partial<FlowItemData> & { ts?: number } = {}):
dstIp: '10.0.0.2', srcPort: 5060, dstPort: 5060, callid: 'c1',
callidColors: { color: '#000', tabColor: '#000', arrowColor: '#000' },
methodColor: '#000', timeStr: '', fullDateStr: '', diffStr: '',
protoLabel: '', payloadType: 'SIP', start: 0, middle: 1, rightEnd: 0,
protoLabel: '', payloadType: 'SIP', start: 0, middle: 1,
direction: false, isRadial: false, isLastHost: false, arrowStyleSolid: true,
raw: { timestamp: ts ?? new Date('2026-01-01T00:00:00Z').getTime() },
runtimeFingerprint: 'fp1',
Expand Down Expand Up @@ -282,3 +282,30 @@ describe('buildFlow RTCP rows', () => {
expect(flowItems[0].arrowStyleSolid).toBe(false)
})
})

describe('flowSegmentPx', () => {
// Unevenly spaced lifelines, as produced by host cards of different widths.
const centers = [85, 509, 910, 1314, 1755]
const seg = (o: Partial<FlowItemData>) =>
flowSegmentPx({ start: 0, middle: 1, isRadial: false, isLastHost: false, ...o }, centers)

it('spans exactly between the measured centres of the two hosts', () => {
expect(seg({ start: 1, middle: 1 })).toEqual({ left: 509, width: 401 })
expect(seg({ start: 2, middle: 2 })).toEqual({ left: 910, width: 845 })
})

it('loops a self-message towards the next host, or the previous one for the last host', () => {
expect(seg({ start: 2, isRadial: true })).toEqual({ left: 910, width: 404 })
expect(seg({ start: 4, isRadial: true, isLastHost: true })).toEqual({ left: 1314, width: 441 })
})

it('uses a fixed loop width when there is a single host', () => {
expect(flowSegmentPx({ start: 0, middle: 1, isRadial: true, isLastHost: false }, [300]))
.toEqual({ left: 300, width: 280 })
})

it('returns null until the needed centres are measured', () => {
expect(flowSegmentPx({ start: 0, middle: 1, isRadial: false, isLastHost: false }, [])).toBeNull()
expect(flowSegmentPx({ start: 0, middle: 2, isRadial: false, isLastHost: false }, [10, 20])).toBeNull()
})
})
Loading