Skip to content

Commit 069248b

Browse files
committed
fix(inference): restore unofficial overlay tooltips
Pass the portaled tooltip element through the shared D3 render context so unofficial-run points can render and pin the same tooltip as official points. 中文:通过共享 D3 渲染上下文传递 Portal 中的提示卡节点,使非正式运行数据点能够与正式运行数据点一样显示并固定提示卡。
1 parent 8b413e2 commit 069248b

4 files changed

Lines changed: 25 additions & 2 deletions

File tree

packages/app/cypress/e2e/unofficial-watermark.cy.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@ describe('Unofficial-run watermark', () => {
1919
],
2020
benchmarks: benchmarks.map((row: Record<string, unknown>) => ({
2121
...row,
22+
is_multinode: true,
23+
metrics: {
24+
...(row.metrics as Record<string, unknown> | undefined),
25+
kv_offloading: 'dram',
26+
kv_offload_backend: 'hicache',
27+
kv_p2p_transfer: 'nixl',
28+
server_gpu_cache_hit_rate: 0.875,
29+
},
2230
run_url: runUrl,
2331
})),
2432
evaluations: [],
@@ -58,6 +66,19 @@ describe('Unofficial-run watermark', () => {
5866
cy.wrap($image).parent('svg').find('.unofficial-watermark-image').should('have.length', 1);
5967
});
6068

69+
cy.get('[data-testid="scatter-graph"] .unofficial-overlay-pt')
70+
.first()
71+
.then(($point) => {
72+
$point[0].dispatchEvent(new MouseEvent('mouseenter'));
73+
const tooltip = $point[0].ownerDocument.querySelector<HTMLElement>('[data-chart-tooltip]');
74+
expect(tooltip).not.to.equal(null);
75+
expect(tooltip!.style.display).to.equal('block');
76+
expect(tooltip).to.contain.text('Offload Type: DRAM');
77+
expect(tooltip).to.contain.text('Offload Backend: HiCache');
78+
expect(tooltip).to.contain.text('KV Cache Transfer Engine: NIXL');
79+
expect(tooltip).to.contain.text('GPU Cache Hit Rate: 87.5%');
80+
});
81+
6182
cy.get('[data-testid="scatter-graph"]').first().scrollIntoView();
6283
cy.screenshot('unofficial-watermark', { capture: 'viewport' });
6384

packages/app/src/components/inference/ui/ScatterGraph.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1999,8 +1999,7 @@ const ScatterGraph = React.memo(
19991999
// Overlay tooltip handlers
20002000
const svgNode = ctx.layout.svg.node()!;
20012001
const container = svgNode.parentElement as HTMLDivElement;
2002-
const tooltipDiv = svgNode.nextElementSibling as HTMLDivElement;
2003-
const tooltip = d3.select(tooltipDiv);
2002+
const tooltip = d3.select(ctx.tooltipElement);
20042003

20052004
const createOverlayConfig = (d: InferenceData, pinned: boolean) => ({
20062005
data: d,

packages/app/src/lib/d3-chart/D3Chart/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,8 @@ export interface TooltipConfig<T = any> {
197197

198198
export interface RenderContext {
199199
layout: ChartLayout;
200+
/** Portaled tooltip node owned by the chart wrapper. */
201+
tooltipElement: HTMLDivElement;
200202
xScale: AnyScale | d3.ScaleTime<number, number>;
201203
yScale: AnyScale | d3.ScaleTime<number, number>;
202204
width: number;

packages/app/src/lib/d3-chart/D3Chart/useD3ChartRenderer.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ export function useD3ChartRenderer<T>(props: D3ChartProps<T>, deps: RendererDeps
182182
// ── Render context ──
183183
const ctx: RenderContext = {
184184
layout,
185+
tooltipElement: tooltipRef.current,
185186
xScale,
186187
yScale,
187188
width,

0 commit comments

Comments
 (0)