Skip to content
Draft
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
3 changes: 3 additions & 0 deletions .trivyignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
CVE-2026-73088
CVE-2026-73089
CVE-2026-40345
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/** @vitest-environment jsdom */
import React from 'react'
import { cleanup, render } from '@testing-library/react'
import { afterEach, describe, expect, it, vi } from 'vitest'
import type { SessionTimelineUsage } from '@argos/shared'
import { SessionTimelineChart } from './session-timeline-chart'

vi.mock('recharts', async () => {
const originalModule = await vi.importActual('recharts')
return {
...originalModule,
ResponsiveContainer: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
ComposedChart: () => null,
}
})

describe('SessionTimelineChart timestamp admission', () => {
afterEach(() => {
cleanup()
vi.restoreAllMocks()
})

it('bounds usage timestamp parsing independently of sort comparisons', () => {
const usageTimeline: SessionTimelineUsage[] = [
{
timestamp: '2026-09-07T00:04:00.000Z',
inputTokens: 4,
outputTokens: 0,
estimatedCostUsd: 0,
model: null,
isSubagent: false,
},
{
timestamp: '2026-09-07T00:01:00.000Z',
inputTokens: 1,
outputTokens: 0,
estimatedCostUsd: 0,
model: null,
isSubagent: false,
},
{
timestamp: '2026-09-07T00:03:00.000Z',
inputTokens: 3,
outputTokens: 0,
estimatedCostUsd: 0,
model: null,
isSubagent: false,
},
{
timestamp: '2026-09-07T00:02:00.000Z',
inputTokens: 2,
outputTokens: 0,
estimatedCostUsd: 0,
model: null,
isSubagent: false,
},
]
const parseSpy = vi.spyOn(Date, 'parse')

render(
<SessionTimelineChart
usageTimeline={usageTimeline}
messages={[]}
sessionStartedAt="2026-09-07T00:00:00.000Z"
/>
)

expect(parseSpy.mock.calls.length).toBeLessThanOrEqual(usageTimeline.length * 2)
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,17 @@ function buildChartData(
toolCalls: ToolCallPoint[],
sessionStartedAt: string
): ChartDataItem[] {
const sortedUsage = [...usageTimeline].sort(
(a, b) => Date.parse(a.timestamp) - Date.parse(b.timestamp)
)
const sortedUsage = usageTimeline
.map(usage => ({ usage, parsedTs: Date.parse(usage.timestamp) }))
.sort((a, b) => a.parsedTs - b.parsedTs)
const sortedTools = [...toolCalls].sort(
(a, b) => a.parsedTimestamp - b.parsedTimestamp
)

let toolIndex = 0
const cumulativeToolCounts = new Map<string, number>()

return sortedUsage.map((usage) => {
const currentTimestamp = Date.parse(usage.timestamp)
return sortedUsage.map(({ usage, parsedTs: currentTimestamp }) => {

while (
toolIndex < sortedTools.length &&
Expand Down
Loading