Skip to content

The agent that grows with you

test(tui): cover idle compaction status retag and FaceTicker freeze

HexLab983d10a51afe5b
diff --git a/tests/tui_gateway/test_compaction_status.py b/tests/tui_gateway/test_compaction_status.py
index a676f70d4f0..7199e1b862c 100644
--- a/tests/tui_gateway/test_compaction_status.py
+++ b/tests/tui_gateway/test_compaction_status.py
@@ -1,9 +1,9 @@
-"""Auto-compaction status re-tagging for the desktop "Summarizing…" indicator.
+"""Auto-compaction status re-tagging for TUI/desktop summarizing indicators.
Auto-compaction reaches the gateway as a generic ``lifecycle`` status. The
-gateway re-tags it as ``kind="compacting"`` so drivers (the desktop app) can
-show an explicit summarizing indicator instead of the transcript appearing to
-silently reset mid-turn.
+gateway re-tags in-progress lines as ``kind="compacting"`` so drivers can
+show an explicit summarizing indicator instead of the turn looking hung
+(#97239). The marker-only match missed idle/preflight/retry wording.
"""
from __future__ import annotations
@@ -51,6 +51,40 @@ def test_compaction_lifecycle_is_retagged(server, monkeypatch):
assert events == [{"kind": "compacting", "text": COMPACTION_STATUS}]
+def test_idle_compaction_lifecycle_is_retagged(server, monkeypatch):
+ from agent.conversation_compression import IDLE_COMPACTION_STATUS_TEMPLATE
+
+ events = _capture(server, monkeypatch)
+ text = IDLE_COMPACTION_STATUS_TEMPLATE.format(idle_seconds=747, tokens=44_579)
+ server._status_update("sid", "lifecycle", text)
+
+ assert events == [{"kind": "compacting", "text": text}]
+
+
+def test_preflight_compaction_lifecycle_is_retagged(server, monkeypatch):
+ from agent.conversation_compression import PREFLIGHT_COMPRESSION_STATUS_TEMPLATE
+
+ events = _capture(server, monkeypatch)
+ text = PREFLIGHT_COMPRESSION_STATUS_TEMPLATE.format(
+ tokens=120_000, threshold=100_000
+ )
+ server._status_update("sid", "lifecycle", text)
+
+ assert events == [{"kind": "compacting", "text": text}]
+
+
+def test_compaction_done_is_not_retagged_as_compacting(server, monkeypatch):
+ from agent.conversation_compression import COMPACTION_DONE_STATUS
+
+ events = _capture(server, monkeypatch)
+ server._status_update("sid", "lifecycle", COMPACTION_DONE_STATUS)
+ assert events[0]["kind"] == "lifecycle"
+
+ events.clear()
+ server._status_update("sid", "compacted", COMPACTION_DONE_STATUS)
+ assert events[0]["kind"] == "compacted"
+
+
def test_other_lifecycle_status_stays_lifecycle(server, monkeypatch):
events = _capture(server, monkeypatch)
server._status_update("sid", "lifecycle", "❌ Rate limited after 5 retries")
@@ -58,6 +92,18 @@ def test_other_lifecycle_status_stays_lifecycle(server, monkeypatch):
assert events[0]["kind"] == "lifecycle"
+def test_overflow_blocked_warning_stays_lifecycle(server, monkeypatch):
+ from agent.conversation_compression import CONTEXT_OVERFLOW_BLOCKED_WARNING_TEMPLATE
+
+ events = _capture(server, monkeypatch)
+ text = CONTEXT_OVERFLOW_BLOCKED_WARNING_TEMPLATE.format(
+ tokens=85_000, threshold=72_000, reason="cooldown:30"
+ )
+ server._status_update("sid", "lifecycle", text)
+
+ assert events[0]["kind"] == "lifecycle"
+
+
def test_manual_compressing_kind_is_preserved(server, monkeypatch):
events = _capture(server, monkeypatch)
server._status_update("sid", "compressing", "⠋ compressing 40 messages…")
@@ -65,3 +111,24 @@ def test_manual_compressing_kind_is_preserved(server, monkeypatch):
assert events[0]["kind"] == "compressing"
+def test_is_compaction_progress_status_covers_routine_in_progress_lines():
+ from agent.conversation_compression import (
+ COMPACTION_DONE_STATUS,
+ CONTEXT_OVERFLOW_BLOCKED_WARNING_TEMPLATE,
+ ROUTINE_COMPRESSION_STATUS_SAMPLES,
+ is_compaction_progress_status,
+ )
+
+ for message in ROUTINE_COMPRESSION_STATUS_SAMPLES:
+ if message == COMPACTION_DONE_STATUS:
+ assert is_compaction_progress_status(message) is False
+ else:
+ assert is_compaction_progress_status(message) is True, message
+
+ assert is_compaction_progress_status(None) is False
+ assert is_compaction_progress_status("") is False
+ assert is_compaction_progress_status("❌ Rate limited after 5 retries") is False
+ overflow = CONTEXT_OVERFLOW_BLOCKED_WARNING_TEMPLATE.format(
+ tokens=85_000, threshold=72_000, reason="ineffective"
+ )
+ assert is_compaction_progress_status(overflow) is False
diff --git a/ui-tui/src/__tests__/appChromeBlockedTimers.test.tsx b/ui-tui/src/__tests__/appChromeBlockedTimers.test.tsx
index 56d80a350f0..c94ea908ccd 100644
--- a/ui-tui/src/__tests__/appChromeBlockedTimers.test.tsx
+++ b/ui-tui/src/__tests__/appChromeBlockedTimers.test.tsx
@@ -248,6 +248,15 @@ describe('status-chrome timers under an occluding overlay', () => {
expect(oneSecondTimers(intervalSpy)).toBeGreaterThan(0)
})
+ it('freezes the FaceTicker verb on compacting and skips verb rotation (#97239)', () => {
+ const { output } = mount({ ...busyProps, compacting: true })
+
+ expect(output()).toContain('compacting')
+ // Glyph still ticks at the kaomoji cadence; the rotating-verb timer does not.
+ expect(armedDelays(intervalSpy).filter(delay => delay === 2500)).toHaveLength(1)
+ expect(oneSecondTimers(intervalSpy)).toBeGreaterThan(0)
+ })
+
it('arms no FaceTicker timer mid-turn while the modal widget slot is open', () => {
patchOverlayState({ widget: { appId: 'demo', state: null } })
diff --git a/ui-tui/src/__tests__/createGatewayEventHandler.test.ts b/ui-tui/src/__tests__/createGatewayEventHandler.test.ts
index d36dbfa224a..5336cd1ad31 100644
--- a/ui-tui/src/__tests__/createGatewayEventHandler.test.ts
+++ b/ui-tui/src/__tests__/createGatewayEventHandler.test.ts
@@ -194,6 +194,40 @@ describe('createGatewayEventHandler', () => {
} as any)
expect(ctx.system.sys).toHaveBeenCalledWith('compressing 968 messages (~123,400 tok)…')
+ expect(getUiState().compacting).toBe(true)
+ })
+
+ it('keeps auto-compaction status visible until compaction finishes (#97239)', () => {
+ const ctx = buildCtx([])
+ const onEvent = createGatewayEventHandler(ctx)
+ const idleLine = '💤 Resumed after 747s idle — compacting ~44,579 tokens before continuing.'
+
+ vi.useFakeTimers()
+ patchUiState({ busy: true, status: 'running…' })
+
+ try {
+ onEvent({
+ payload: { kind: 'compacting', text: idleLine },
+ type: 'status.update'
+ } as any)
+
+ expect(ctx.system.sys).toHaveBeenCalledWith(idleLine)
+ expect(getUiState().compacting).toBe(true)
+ expect(getUiState().status).toBe(idleLine)
+
+ vi.advanceTimersByTime(4001)
+ expect(getUiState().status).toBe(idleLine)
+ expect(getUiState().compacting).toBe(true)
+
+ onEvent({
+ payload: { kind: 'compacted', text: '✓ Context compaction complete — continuing turn...' },
+ type: 'status.update'
+ } as any)
+
+ expect(getUiState().compacting).toBe(false)
+ } finally {
+ vi.useRealTimers()
+ }
})
it('keeps goal verdict text in transcript but shows a brief idle status (#goal statusbar)', () => {