bound inactive subagent timing to projection cut
This commit is contained in:
@@ -69,9 +69,11 @@ function activityDuration(
|
||||
const timing: SessionProjectionMap['subagentTiming'] | undefined
|
||||
= summary.projectionValues?.subagentTiming
|
||||
if (timing === undefined) return undefined
|
||||
if (timing.activeSince === undefined) return timing.settledMs
|
||||
const end = activity === 'running' ? now : summary.updatedAt
|
||||
return timing.settledMs + Math.max(0, end - timing.activeSince)
|
||||
if (timing.active === undefined) return timing.settledMs
|
||||
const end = activity === 'running'
|
||||
? now
|
||||
: timing.active.through
|
||||
return timing.settledMs + Math.max(0, end - timing.active.since)
|
||||
}
|
||||
|
||||
/** Format a non-negative duration to seconds without dropping larger units. */
|
||||
|
||||
@@ -245,9 +245,9 @@ describe('SubagentCatalogAction', () => {
|
||||
vi.useFakeTimers()
|
||||
vi.setSystemTime(now)
|
||||
const rows = [
|
||||
['running', 'running', 65_000, now - 5_000, now],
|
||||
['finished', 'inactive', 3_723_000, undefined, now - 60_000],
|
||||
['interrupted', 'inactive', 2_000, now - 7_000, now - 3_000],
|
||||
['running', 'running', 65_000, now - 5_000, now - 1_000, now],
|
||||
['finished', 'inactive', 3_723_000, undefined, undefined, now - 60_000],
|
||||
['interrupted', 'inactive', 2_000, now - 7_000, now - 3_000, now + 60_000],
|
||||
] as const
|
||||
const entries = rows.map(([id, activity]) => ({
|
||||
kind: 'child' as const,
|
||||
@@ -257,7 +257,9 @@ describe('SubagentCatalogAction', () => {
|
||||
activity,
|
||||
hasChildren: false,
|
||||
}))
|
||||
const summaries = Object.fromEntries(rows.map(([id, activity, settledMs, activeSince, updatedAt]) => {
|
||||
const summaries = Object.fromEntries(rows.map(([
|
||||
id, activity, settledMs, activeSince, activeThrough, updatedAt,
|
||||
]) => {
|
||||
const childId = id as SessionId
|
||||
return [id, {
|
||||
...summary(childId, updatedAt),
|
||||
@@ -267,7 +269,9 @@ describe('SubagentCatalogAction', () => {
|
||||
projectionValues: {
|
||||
subagentTiming: {
|
||||
settledMs,
|
||||
...(activeSince === undefined ? {} : { activeSince }),
|
||||
...(activeSince === undefined || activeThrough === undefined
|
||||
? {}
|
||||
: { active: { since: activeSince, through: activeThrough } }),
|
||||
},
|
||||
},
|
||||
}]
|
||||
|
||||
Reference in New Issue
Block a user