fix(ui-trajectory): offset recovered request boundaries

This commit is contained in:
_Kerman
2026-08-03 15:31:36 +08:00
parent ad6858b6d3
commit 0e05bb81a3
2 changed files with 26 additions and 11 deletions

View File

@@ -459,17 +459,16 @@ function indexRequestNumbers(
function indexRequestBoundaryRuns(records: readonly TableRecord[]): ReadonlyMap<number, number> {
const indexes = new Map<number, number>()
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
}

View File

@@ -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', () => {