From 0e05bb81a31ddfed80da7fe52737aac598e4e446 Mon Sep 17 00:00:00 2001 From: _Kerman Date: Mon, 3 Aug 2026 15:31:36 +0800 Subject: [PATCH] fix(ui-trajectory): offset recovered request boundaries --- .../src/client/TrajectoryTable.tsx | 15 ++++++------- .../client/ui-trajectory/tests/table.spec.tsx | 22 ++++++++++++++++--- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/packages/client/ui-trajectory/src/client/TrajectoryTable.tsx b/packages/client/ui-trajectory/src/client/TrajectoryTable.tsx index 7f314b6a40..89154626f0 100644 --- a/packages/client/ui-trajectory/src/client/TrajectoryTable.tsx +++ b/packages/client/ui-trajectory/src/client/TrajectoryTable.tsx @@ -459,17 +459,16 @@ function indexRequestNumbers( function indexRequestBoundaryRuns(records: readonly TableRecord[]): ReadonlyMap { const indexes = new Map() - let previous: TableRecord | undefined - let runIndex = 0 + let runLength = 0 for (const record of records) { - if (record.cell.requestOnly !== true) { - previous = record - runIndex = 0 + if (record.cell.requestOnly === true) { + indexes.set(record.cell.index, runLength++) continue } - runIndex = previous?.cell.requestOnly === true ? runIndex + 1 : 0 - indexes.set(record.cell.index, runIndex) - previous = record + if (runLength > 0 && record.groupStart && requestStep(record.group) !== undefined) { + indexes.set(record.cell.index, runLength) + } + runLength = 0 } return indexes } diff --git a/packages/client/ui-trajectory/tests/table.spec.tsx b/packages/client/ui-trajectory/tests/table.spec.tsx index 794fd8ca09..7ad4d79b6b 100644 --- a/packages/client/ui-trajectory/tests/table.spec.tsx +++ b/packages/client/ui-trajectory/tests/table.spec.tsx @@ -225,7 +225,7 @@ describe('TrajectoryTable', () => { it('marks failed requests and lays coincident request markers left to right', () => { const turns: readonly TrajectoryTurnModel[] = [ { - turn: null, + turn: 1, groups: [{ title: 'Step 1', cells: [{ @@ -239,14 +239,27 @@ describe('TrajectoryTable', () => { }], }, { - turn: null, + turn: 2, groups: [{ - title: 'Step 2', + title: 'Step 1', cells: [{ index: 2, kind: 'message', text: '', requestOnly: true, + isError: true, + timeSeconds: 0.1, + }], + }], + }, + { + turn: 3, + groups: [{ + title: 'Step 1', + cells: [{ + index: 3, + kind: 'message', + text: 'Recovered response', timeSeconds: 0.1, }], }], @@ -256,11 +269,14 @@ describe('TrajectoryTable', () => { const failed = screen.getByRole('button', { name: 'Request #1' }) const retry = screen.getByRole('button', { name: 'Request #2' }) + const recovered = screen.getByRole('button', { name: 'Request #3' }) expect(failed.getAttribute('data-request-status')).toBe('error') expect(failed.getAttribute('data-request-run-index')).toBe('0') expect(failed.style.getPropertyValue('--request-boundary-offset')).toBe('0px') expect(retry.getAttribute('data-request-run-index')).toBe('1') expect(retry.style.getPropertyValue('--request-boundary-offset')).toBe('8px') + expect(recovered.getAttribute('data-request-run-index')).toBe('2') + expect(recovered.style.getPropertyValue('--request-boundary-offset')).toBe('16px') }) it('shows the custom role tooltip only from the responsive icon', () => {