Skip to content
Merged
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 .github/scripts/windows_test_assignments.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@
"tests/test_engine/test_reasoning_retry_and_deadline_thinking_levers.py",
"tests/test_engine/test_reliability_runtime_seams.py",
"tests/test_engine/test_request_execution_identity.py",
"tests/test_engine/test_request_window.py",
"tests/test_engine/test_resolve_turn_thinking.py",
"tests/test_engine/test_route_plan.py",
"tests/test_engine/test_router_calibration.py",
Expand All @@ -122,6 +123,7 @@
"tests/test_engine/test_runtime_agent_max_iterations.py",
"tests/test_engine/test_runtime_agent_max_provider_retries.py",
"tests/test_engine/test_runtime_meta_run_writer_wiring.py",
"tests/test_engine/test_runtime_request_window.py",
"tests/test_engine/test_runtime_tool_result_retrieval_surfacing.py",
"tests/test_engine/test_runtime_web_chat_timeout.py",
"tests/test_engine/test_selector_fallback_routed_model.py",
Expand Down Expand Up @@ -928,6 +930,7 @@
"tests/test_session/test_compaction.py",
"tests/test_session/test_compaction_dispatcher.py",
"tests/test_session/test_compaction_execution_plan.py",
"tests/test_session/test_compaction_integrity.py",
"tests/test_session/test_compaction_lifecycle.py",
"tests/test_session/test_compaction_media_budget.py",
"tests/test_session/test_compaction_provider_runtime.py",
Expand Down
3 changes: 3 additions & 0 deletions .github/scripts/windows_test_durations.json
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,7 @@
"tests/test_engine/test_reasoning_retry_and_deadline_thinking_levers.py": 0.183,
"tests/test_engine/test_reliability_runtime_seams.py": 0.01,
"tests/test_engine/test_render_volatile_block.py": 0.046,
"tests/test_engine/test_request_window.py": 0.01,
"tests/test_engine/test_resolve_turn_thinking.py": 0.035,
"tests/test_engine/test_route_plan.py": 0.01,
"tests/test_engine/test_router_budget_gate.py": 0.043,
Expand Down Expand Up @@ -431,6 +432,7 @@
"tests/test_engine/test_runtime_meta_invoke_surfacing.py": 1.103,
"tests/test_engine/test_runtime_meta_run_writer_wiring.py": 0.01,
"tests/test_engine/test_runtime_pending_input_provider_threading.py": 0.01,
"tests/test_engine/test_runtime_request_window.py": 0.01,
"tests/test_engine/test_runtime_router_fallback.py": 0.54,
"tests/test_engine/test_runtime_submit_surfacing.py": 0.231,
"tests/test_engine/test_runtime_tool_result_retrieval_surfacing.py": 0.171,
Expand Down Expand Up @@ -1244,6 +1246,7 @@
"tests/test_session/test_compaction.py": 0.282,
"tests/test_session/test_compaction_dispatcher.py": 0.03,
"tests/test_session/test_compaction_execution_plan.py": 0.044,
"tests/test_session/test_compaction_integrity.py": 0.01,
"tests/test_session/test_compaction_lifecycle.py": 0.025,
"tests/test_session/test_compaction_media_budget.py": 0.01,
"tests/test_session/test_compaction_provider_runtime.py": 0.579,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import type {
ChatStreamTimelineItem,
ChatToolCallRenderItem,
} from '@/types/chat'
import type { StatusPart } from '@/types/parts'
import { projectAssistantActivityTimeline } from '@/utils/chat/assistantActivity'
import AssistantActivityTimeline from './AssistantActivityTimeline.vue'
import timelineSource from './AssistantActivityTimeline.vue?raw'
Expand Down Expand Up @@ -59,7 +60,7 @@ function group(call: ChatToolCallRenderItem): ChatStreamTimelineItem {

async function mountTimeline(
timelineItems: ChatStreamTimelineItem[],
statusHistory: Array<{ action: string; label: string; at: number }> = [],
statusHistory: StatusPart[] = [],
lifecycle: 'working' | 'answering' | 'settled' = 'working',
) {
const root = document.createElement('div')
Expand Down Expand Up @@ -99,6 +100,30 @@ afterEach(() => {
})

describe('AssistantActivityTimeline', () => {
it.each(['working', 'settled'] as const)('distinguishes temporary reductions from saved summaries while %s', async lifecycle => {
const root = await mountTimeline([], [
{
action: 'context_compaction', label: '', at: 1_000,
id: 'cmp-temporary', category: 'maintenance', state: 'completed',
source: 'automatic', durability: 'request_scoped',
},
{
action: 'context_compaction', label: '', at: 2_000,
id: 'cmp-saved', category: 'maintenance', state: 'completed',
source: 'automatic', durability: 'durable',
},
], lifecycle)

const events = root.querySelectorAll<HTMLElement>('[data-testid="compaction-event"]')
expect(events).toHaveLength(2)
expect(events[0]?.textContent).toContain('History temporarily reduced; continuing')
expect(events[0]?.textContent).not.toContain('Summary saved')
expect(events[0]?.dataset.status).toBe('completed')
expect(events[0]?.dataset.durability).toBe('request_scoped')
expect(events[1]?.textContent).toContain('Summary saved')
expect(root.querySelector('.assistant-activity-status__row--current')).toBeNull()
})

it('inherits caller attributes on its semantic root without Vue fragment warnings', async () => {
const root = await mountTimeline([
group(toolCall('attribute-root', 'read_file')),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -744,6 +744,25 @@ describe('AssistantMessage activity disclosure', () => {
expect(el.querySelector('.tool-row--error')).not.toBeNull()
})

it.each([
['request_scoped', 'History temporarily reduced; continuing'],
['durable', 'Summary saved'],
])('keeps %s wording in the folded activity summary', async (durability, label) => {
const el = mountMessage(baseMessage({
timelineItems: [],
statusHistory: [{
action: 'context_compaction', label: '', at: 1_000,
id: 'cmp-folded', category: 'maintenance', state: 'completed',
source: 'automatic', durability,
}],
}))
await nextTick()

const summary = el.querySelector('.assistant-activity__summary')
expect(summary?.textContent).toContain(label)
if (durability === 'request_scoped') expect(summary?.textContent).not.toContain('Summary saved')
})

it('restores routine phase rows and reopens settled reasoning content', async () => {
const startedAt = Date.parse('2026-01-01T00:00:00.000Z')
const el = mountMessage(baseMessage({
Expand Down
21 changes: 9 additions & 12 deletions opensquilla-webui/src/components/chat/AssistantMessage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -1122,19 +1122,16 @@ const activityDetailLabel = computed(() => {
return parts.join(' · ')
})

const completedMaintenanceCount = computed(() =>
activityProjection.value.statusSteps.filter(step =>
step.category === 'maintenance' && step.state === 'completed',
).length,
)

function withMaintenanceSummary(label: string): string {
const count = completedMaintenanceCount.value
if (!count) return label
const maintenance = count > 1
? `${String(t('chat.compact.compacted'))} ×${count}`
: String(t('chat.compact.compacted'))
return [label, maintenance].filter(Boolean).join(' · ')
const counts = new Map<string, number>()
for (const step of activityProjection.value.statusSteps) {
if (step.category !== 'maintenance' || step.state !== 'completed') continue
counts.set(step.label.code, (counts.get(step.label.code) ?? 0) + 1)
}
const maintenance = [...counts].map(([code, count]) =>
count > 1 ? `${String(t(code))} ×${count}` : String(t(code)),
)
return [label, ...maintenance].filter(Boolean).join(' · ')
}

const activitySummaryLabel = computed(() => {
Expand Down
15 changes: 11 additions & 4 deletions opensquilla-webui/src/components/chat/CompactionEvent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
{{ maintenance.detail }}
</span>
<span
v-else-if="maintenance?.durability === 'request_scoped'"
v-else-if="detailLabelCode"
class="chat-compaction-event__detail"
>
{{ t('chat.compact.requestScoped') }}
{{ t(detailLabelCode) }}
</span>
<time v-if="message.timeStr" class="chat-compaction-event__detail">
{{ message.timeStr }}
Expand All @@ -36,7 +36,10 @@
import { computed } from 'vue'
import { useI18n } from 'vue-i18n'
import type { ChatRenderedMessage } from '@/types/chat'
import { compactionSkippedLabelCode } from '@/utils/chat/compactionStatus'
import {
compactionCompletedLabelCode,
compactionSkippedLabelCode,
} from '@/utils/chat/compactionStatus'

const props = defineProps<{
message: ChatRenderedMessage
Expand All @@ -53,12 +56,16 @@ const labelCode = computed(() => {
if (maintenance.value?.state === 'stale' || maintenance.value?.state === 'cancelled') {
return 'chat.compact.cancelled'
}
return compactionCompletedLabelCode(maintenance.value?.durability)
})
const detailLabelCode = computed(() => {
if (maintenance.value?.durability === 'request_scoped') return 'chat.compact.requestScoped'
if (maintenance.value?.historyArchived) {
if (maintenance.value.canonicalComplete === true) return 'chat.compact.historyPreserved'
if (maintenance.value.canonicalComplete === false) return 'chat.compact.historyIncomplete'
return 'chat.compact.historySummarized'
}
return 'chat.compact.compacted'
return ''
})
const liveRole = computed(() => {
if (props.message.restoredFromHistory) return undefined
Expand Down
27 changes: 24 additions & 3 deletions opensquilla-webui/src/composables/chat/useChatCompaction.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,18 +203,21 @@ describe('useChatCompaction replay compatibility', () => {
}
})

it('settles emergency_ephemeral without claiming durable completion in state', () => {
it.each([false, true])('settles emergency_ephemeral truthfully after replay=%s', replayed => {
const h = createHarness()
try {
h.api.showCompactionToast({ status: 'started', source: 'manual' })
h.api.showCompactionToast({ status: 'started', source: 'manual', compaction_id: 'cmp-temporary' })
h.api.showCompactionToast({
status: 'emergency_ephemeral',
source: 'automatic',
})
compaction_id: 'cmp-temporary',
}, { replayed })

expect(h.api.compactStatus.value).toMatchObject({
visible: true,
status: 'emergency_ephemeral',
message: 'History temporarily reduced; continuing',
durability: 'request_scoped',
tone: 'warn',
detail: 'Request-scoped; session history was not rewritten',
isBusy: false,
Expand All @@ -227,6 +230,24 @@ describe('useChatCompaction replay compatibility', () => {
}
})

it('labels a committed summary as saved', () => {
const h = createHarness()
try {
h.api.showCompactionToast({ status: 'started', source: 'manual' })
h.api.showCompactionToast({ status: 'completed', source: 'manual', durability: 'durable' })

expect(h.api.compactStatus.value).toMatchObject({
message: 'Summary saved',
status: 'completed',
durability: 'durable',
isBusy: false,
})
} finally {
h.api.cleanup()
h.stop()
}
})

it('does not let an older replayed terminal settle a newer compaction', () => {
const h = createHarness()
try {
Expand Down
5 changes: 3 additions & 2 deletions opensquilla-webui/src/composables/chat/useChatCompaction.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { ref, type Ref } from 'vue'
import i18n from '@/i18n'
import {
compactionCompletedLabelCode,
compactionSkippedLabelCode,
compactionSkipIsInformational,
} from '@/utils/chat/compactionStatus'
Expand Down Expand Up @@ -441,7 +442,7 @@ export function useChatCompaction(options: UseChatCompactionOptions) {
if (status === 'emergency_ephemeral') {
settleCompactInFlight(payload || {})
if (inActivity) return placement
showCompactStatus('emergency_ephemeral', i18n.global.t('chat.compact.compacted'), {
showCompactStatus('emergency_ephemeral', i18n.global.t('chat.compact.temporarilyReduced'), {
tone: 'warn',
detail: typeof payload.detail === 'string'
? payload.detail
Expand All @@ -455,7 +456,7 @@ export function useChatCompaction(options: UseChatCompactionOptions) {
if (status === 'completed') {
settleCompactInFlight(payload || {})
if (inActivity) return placement
showCompactStatus('completed', i18n.global.t('chat.compact.compacted'), {
showCompactStatus('completed', i18n.global.t(compactionCompletedLabelCode(payload.durability)), {
tone: 'ok',
source,
compactionId,
Expand Down
44 changes: 44 additions & 0 deletions opensquilla-webui/src/composables/chat/useChatHistory.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { describe, expect, it, vi } from 'vitest'
import { nextTick, ref, watch, type Ref } from 'vue'

import { useChatHistory } from './useChatHistory'
import { projectAssistantActivityTimeline } from '@/utils/chat/assistantActivity'
import type { ChatMessage, ChatTurnOutcome } from '@/types/chat'
import { RpcTimeoutError } from '@/lib/rpc'
import {
Expand Down Expand Up @@ -1338,6 +1339,49 @@ describe('useChatHistory canonical pagination', () => {
expect(messages.value[0]?.turnId).toBe('turn-1')
})

it.each([
['emergency_ephemeral', undefined],
['completed', 'request_scoped'],
])('restores a temporary %s reduction without claiming a saved summary', async (status, durability) => {
const { api, messages } = makeHistory(false, {
response: {
messages: [{
id: 'assistant-temporary',
role: 'assistant',
text: 'Continued after reducing the request context.',
turnContext: {
turnId: 'turn-temporary',
activityMarkers: [{
kind: 'context_compaction',
id: 'cmp-temporary',
status,
durability,
at: 1_720_000_000_000,
}],
},
}],
canonicalComplete: true,
hasMore: false,
},
})

await api.loadHistory()

expect(messages.value).toHaveLength(1)
expect(messages.value[0]).toMatchObject({
restoredFromHistory: true,
statusHistory: [{ state: 'completed', durability: 'request_scoped' }],
})
const projection = projectAssistantActivityTimeline([], {
lifecycle: 'settled',
statusHistory: messages.value[0]!.statusHistory,
})
expect(projection.statusSteps[0]).toMatchObject({
isCurrent: false,
label: { code: 'chat.compact.temporarilyReduced' },
})
})

it('prefers a durable summary boundary over duplicate activity metadata', async () => {
const { api, messages } = makeHistory(false, {
response: {
Expand Down
6 changes: 4 additions & 2 deletions opensquilla-webui/src/composables/chat/useChatHistory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ function historyActivityMarkers(
const id = String(data.id || '').trim()
if (!id || suppressedCompactionIds.has(id)) return []
const rawStatus = String(data.status || 'completed').toLowerCase()
const state = rawStatus === 'completed'
const state = rawStatus === 'completed' || rawStatus === 'emergency_ephemeral'
? 'completed'
: rawStatus === 'failed' ? 'failed' : 'running'
const at = Number(data.at)
Expand All @@ -181,7 +181,9 @@ function historyActivityMarkers(
category: 'maintenance',
state,
source: 'automatic',
durability: 'durable',
durability: rawStatus === 'emergency_ephemeral'
? 'request_scoped'
: String(data.durability || 'durable'),
}]
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1879,6 +1879,7 @@ describe('useChatRpcEventHandlers compaction ownership', () => {
status,
source: 'automatic',
compaction_id: 'cmp-committed',
...(status === 'completed' ? { durability: 'durable' } : {}),
}, { authoritativeLive: true })

expect(messages.value).toHaveLength(2)
Expand All @@ -1894,6 +1895,11 @@ describe('useChatRpcEventHandlers compaction ownership', () => {
expect(stream.startStreaming).not.toHaveBeenCalled()
expect(stream.recordCompactionActivity).not.toHaveBeenCalled()
expect(lastStreamSeq.value).toBe(31)
if (status === 'emergency_ephemeral' || status === 'completed') {
expect(messages.value[1]?.statusHistory?.[0]?.durability).toBe(
status === 'emergency_ephemeral' ? 'request_scoped' : 'durable',
)
}
} finally {
stop()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,9 @@ export function useChatRpcEventHandlers(options: UseChatRpcEventHandlersOptions)
message.statusHistory[statusIndex] = {
...marker,
state,
durability: compactionStatus(payload) === 'emergency_ephemeral'
? 'request_scoped'
: String(payload.durability || marker.durability || ''),
reason: String(payload.reason || payload.skip_reason || marker.reason || ''),
// The lifecycle stays anchored where its started frame first appeared.
at: marker.at,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -828,6 +828,7 @@ describe('useChatStream render coalescing', () => {

for (const [status, id] of [
['completed', 'cmp-completed'],
['emergency_ephemeral', 'cmp-temporary'],
['skipped', 'cmp-skipped'],
['stale', 'cmp-stale'],
['cancelled', 'cmp-cancelled'],
Expand All @@ -838,11 +839,13 @@ describe('useChatStream render coalescing', () => {

expect(api.foldedTurn.value.statusHistory.map(entry => [entry.id, entry.state])).toEqual([
['cmp-completed', 'completed'],
['cmp-temporary', 'completed'],
['cmp-skipped', 'skipped'],
['cmp-stale', 'stale'],
['cmp-cancelled', 'cancelled'],
['cmp-failed', 'failed'],
])
expect(api.foldedTurn.value.statusHistory[1]?.durability).toBe('request_scoped')
api.cleanup()
})

Expand Down
Loading
Loading