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> { function indexRequestBoundaryRuns(records: readonly TableRecord[]): ReadonlyMap<number, number> {
const indexes = new Map<number, number>() const indexes = new Map<number, number>()
let previous: TableRecord | undefined let runLength = 0
let runIndex = 0
for (const record of records) { for (const record of records) {
if (record.cell.requestOnly !== true) { if (record.cell.requestOnly === true) {
previous = record indexes.set(record.cell.index, runLength++)
runIndex = 0
continue continue
} }
runIndex = previous?.cell.requestOnly === true ? runIndex + 1 : 0 if (runLength > 0 && record.groupStart && requestStep(record.group) !== undefined) {
indexes.set(record.cell.index, runIndex) indexes.set(record.cell.index, runLength)
previous = record }
runLength = 0
} }
return indexes return indexes
} }

View File

@@ -225,7 +225,7 @@ describe('TrajectoryTable', () => {
it('marks failed requests and lays coincident request markers left to right', () => { it('marks failed requests and lays coincident request markers left to right', () => {
const turns: readonly TrajectoryTurnModel[] = [ const turns: readonly TrajectoryTurnModel[] = [
{ {
turn: null, turn: 1,
groups: [{ groups: [{
title: 'Step 1', title: 'Step 1',
cells: [{ cells: [{
@@ -239,14 +239,27 @@ describe('TrajectoryTable', () => {
}], }],
}, },
{ {
turn: null, turn: 2,
groups: [{ groups: [{
title: 'Step 2', title: 'Step 1',
cells: [{ cells: [{
index: 2, index: 2,
kind: 'message', kind: 'message',
text: '', text: '',
requestOnly: true, requestOnly: true,
isError: true,
timeSeconds: 0.1,
}],
}],
},
{
turn: 3,
groups: [{
title: 'Step 1',
cells: [{
index: 3,
kind: 'message',
text: 'Recovered response',
timeSeconds: 0.1, timeSeconds: 0.1,
}], }],
}], }],
@@ -256,11 +269,14 @@ describe('TrajectoryTable', () => {
const failed = screen.getByRole('button', { name: 'Request #1' }) const failed = screen.getByRole('button', { name: 'Request #1' })
const retry = screen.getByRole('button', { name: 'Request #2' }) 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-status')).toBe('error')
expect(failed.getAttribute('data-request-run-index')).toBe('0') expect(failed.getAttribute('data-request-run-index')).toBe('0')
expect(failed.style.getPropertyValue('--request-boundary-offset')).toBe('0px') expect(failed.style.getPropertyValue('--request-boundary-offset')).toBe('0px')
expect(retry.getAttribute('data-request-run-index')).toBe('1') expect(retry.getAttribute('data-request-run-index')).toBe('1')
expect(retry.style.getPropertyValue('--request-boundary-offset')).toBe('8px') 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', () => { it('shows the custom role tooltip only from the responsive icon', () => {