The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(tui): show status while idle/auto compaction runs
HexLab983a542bbef4d1
diff --git a/agent/conversation_compression.py b/agent/conversation_compression.pyindex b6f6549870c..11337d3b33c 100644--- a/agent/conversation_compression.py+++ b/agent/conversation_compression.py@@ -103,7 +103,8 @@ _SPLIT_FAILURE_COOLDOWN_SECONDS = 60# status as ``kind="compacting"`` (tui_gateway/server.py::_status_update), so# drivers like the desktop app can show an explicit "Summarizing…" indicator# instead of the transcript appearing to silently reset. Keep the marker phrase-# intact if you reword COMPACTION_STATUS.+# intact if you reword COMPACTION_STATUS. Idle/preflight/retry lines do not+# contain this marker — ``is_compaction_progress_status`` covers those too.COMPACTION_STATUS_MARKER = "Compacting context"COMPACTION_STATUS = (f"🗜️ {COMPACTION_STATUS_MARKER} — summarizing earlier conversation so I can continue..."@@ -213,6 +214,40 @@ ROUTINE_COMPRESSION_STATUS_SAMPLES = ()+def is_compaction_progress_status(text: str | None) -> bool:+ """True for in-progress auto-compaction lifecycle lines (not the done edge).++ ``tui_gateway.server._status_update`` re-tags matching ``lifecycle``+ statuses as ``kind="compacting"`` so TUI and desktop can show a summarizing+ indicator for the whole pause. Matching only ``COMPACTION_STATUS_MARKER``+ left idle/preflight/retry lines looking like a hung turn (#97239).++ The terminal ``COMPACTION_DONE_STATUS`` is emitted as ``kind="compacted"``+ and must not match here.+ """+ if not isinstance(text, str):+ return False+ body = text.strip()+ if not body:+ return False+ if COMPACTION_STATUS_MARKER in body:+ return True+ if body == COMPACTION_DONE_STATUS:+ return False+ lowered = body.lower()+ if "compaction complete" in lowered:+ return False+ # Failure-class overflow warning mentions compression but is a blocked+ # notice, not progress — keep it lifecycle so chat gateways stay loud.+ if "compression is currently blocked" in lowered:+ return False+ return (+ "compact" in lowered+ or "compress" in lowered+ or "context reduced to" in lowered+ )++def _builtin_memory_prompt_snapshot(agent: Any) -> Optional[Tuple[str, str]]:"""Return the built-in memory text that can affect a system prompt.@@ -5705,6 +5740,7 @@ __all__ = ["COMPACTION_STATUS","COMPACTION_DONE_STATUS","COMPACTION_STATUS_MARKER",+ "is_compaction_progress_status","check_compression_model_feasibility","replay_compression_warning","compress_context",diff --git a/tui_gateway/server.py b/tui_gateway/server.pyindex e0de9e1fa1d..b3896f7ebab 100644--- a/tui_gateway/server.py+++ b/tui_gateway/server.py@@ -2849,12 +2849,12 @@ def _status_update(sid: str, kind: str, text: str | None = None):returnout_kind = kind if text is not None else "status"# Auto-compaction reaches us as a generic "lifecycle" status. Re-tag it so- # drivers (desktop app) can show an explicit "Summarizing…" indicator —- # otherwise a mid-turn compaction looks like the transcript reset itself.+ # drivers (TUI / desktop) can show an explicit summarizing indicator —+ # otherwise idle/preflight compaction looks like a hung turn (#97239).if out_kind == "lifecycle":- from agent.conversation_compression import COMPACTION_STATUS_MARKER+ from agent.conversation_compression import is_compaction_progress_status- if COMPACTION_STATUS_MARKER in body:+ if is_compaction_progress_status(body):out_kind = "compacting"_emit("status.update", sid, {"kind": out_kind, "text": body})diff --git a/ui-tui/src/app/createGatewayEventHandler.ts b/ui-tui/src/app/createGatewayEventHandler.tsindex 61c4d4a2261..33f8096bd05 100644--- a/ui-tui/src/app/createGatewayEventHandler.ts+++ b/ui-tui/src/app/createGatewayEventHandler.ts@@ -852,12 +852,18 @@ export function createGatewayEventHandler(ctx: GatewayEventHandlerContext): (ev:setStatus(p.text)- if (p.kind === 'compressing') {+ if (p.kind === 'compressing' || p.kind === 'compacting') {sys(p.text)+ turnController.clearStatusTimer()+ patchUiState({ compacting: true })return}+ if (p.kind === 'compacted') {+ patchUiState({ compacting: false })+ }+if (!p.kind || p.kind === 'status') {return}diff --git a/ui-tui/src/app/interfaces.ts b/ui-tui/src/app/interfaces.tsindex f0c8ef0c2b2..0f4b9cb6ac8 100644--- a/ui-tui/src/app/interfaces.ts+++ b/ui-tui/src/app/interfaces.ts@@ -322,6 +322,9 @@ export interface UiState {busy: booleanbusyInputMode: BusyInputModecompact: boolean+ // Context compaction in progress (idle/preflight/auto). Distinct from+ // `compact`, which is the /compact layout-density flag.+ compacting: booleandestructiveSlashConfirm: booleandetailsMode: DetailsModedetailsModeCommandOverride: booleandiff --git a/ui-tui/src/app/turnController.ts b/ui-tui/src/app/turnController.tsindex edd67e5281e..ac7f5ca5411 100644--- a/ui-tui/src/app/turnController.ts+++ b/ui-tui/src/app/turnController.ts@@ -297,7 +297,7 @@ class TurnController {tools: [],turnTrail: []})- patchUiState({ busy: false })+ patchUiState({ busy: false, compacting: false })resetFlowOverlays()}diff --git a/ui-tui/src/app/uiStore.ts b/ui-tui/src/app/uiStore.tsindex e924708c069..415cf991dcb 100644--- a/ui-tui/src/app/uiStore.ts+++ b/ui-tui/src/app/uiStore.ts@@ -14,6 +14,7 @@ const buildUiState = (): UiState => ({busy: false,busyInputMode: 'queue',compact: false,+ compacting: false,destructiveSlashConfirm: true,detailsMode: 'collapsed',detailsModeCommandOverride: false,diff --git a/ui-tui/src/app/useMainApp.ts b/ui-tui/src/app/useMainApp.tsindex b25588885c1..b42c77470f5 100644--- a/ui-tui/src/app/useMainApp.ts+++ b/ui-tui/src/app/useMainApp.ts@@ -909,7 +909,7 @@ export function useMainApp(gw: GatewayClient) {// dead/respawning gateway. recoverSidRef carries the session forward, and// resumeById restores sid once the fresh gateway is ready.recoveryAtRef.current = plan.attempts- patchUiState({ busy: false, sid: null, status: 'gateway exited' })+ patchUiState({ busy: false, compacting: false, sid: null, status: 'gateway exited' })if (plan.recover && plan.sid) {recoverSidRef.current = plan.siddiff --git a/ui-tui/src/components/appChrome.tsx b/ui-tui/src/components/appChrome.tsxindex c989678f2ac..6d12ea8b21a 100644--- a/ui-tui/src/components/appChrome.tsx+++ b/ui-tui/src/components/appChrome.tsx@@ -119,7 +119,17 @@ export const busyIndicatorWidth = (style: IndicatorStyle, hasDuration: boolean):return indicatorFrameWidth(style) + verb + duration}-function FaceTicker({ color, startedAt, style }: { color: string; startedAt?: null | number; style: IndicatorStyle }) {+function FaceTicker({+ color,+ startedAt,+ style,+ verbOverride+}: {+ color: string+ startedAt?: null | number+ style: IndicatorStyle+ verbOverride?: string+}) {const [tick, setTick] = useState(() => Math.floor(Math.random() * 1000))const [verbTick, setVerbTick] = useState(() => Math.floor(Math.random() * VERBS.length))const [now, setNow] = useState(() => Date.now())@@ -128,8 +138,11 @@ function FaceTicker({ color, startedAt, style }: { color: string; startedAt?: nu// Pre-compute cadence + verb-visibility for the active style so an// `/indicator` switch re-arms the interval (and skips the verb timer// for verb-less styles like `unicode`) without leaving the previous- // timer dangling.+ // timer dangling. A frozen override (idle compaction) always shows the+ // verb so "compacting…" is visible even in unicode style (#97239).const { intervalMs, showVerb } = renderIndicator(style, 0)+ const freezeVerb = Boolean(verbOverride)+ const displayVerb = freezeVerb || showVerbuseEffect(() => {// An overlay is painted OVER the status rule (the modal widget slot, or a@@ -147,9 +160,10 @@ function FaceTicker({ color, startedAt, style }: { color: string; startedAt?: nuconst glyph = setInterval(() => setTick(n => n + 1), intervalMs)const clock = setInterval(() => setNow(Date.now()), 1000)- // Verb timer is gated on `showVerb` — `unicode` style hides the verb- // entirely, so cycling `verbTick` would be an avoidable re-render.- const verb = showVerb ? setInterval(() => setVerbTick(n => n + 1), FACE_TICK_MS) : null+ // Verb timer is gated on `displayVerb` — `unicode` style hides the verb+ // entirely, so cycling `verbTick` would be an avoidable re-render. A+ // frozen override does not rotate.+ const verb = displayVerb && !freezeVerb ? setInterval(() => setVerbTick(n => n + 1), FACE_TICK_MS) : nullreturn () => {clearInterval(glyph)@@ -159,11 +173,11 @@ function FaceTicker({ color, startedAt, style }: { color: string; startedAt?: nuclearInterval(verb)}}- }, [intervalMs, isOccluded, showVerb])+ }, [displayVerb, freezeVerb, intervalMs, isOccluded])const { frame } = renderIndicator(style, tick)- const verb = VERBS[verbTick % VERBS.length] ?? ''- const verbSegment = showVerb ? ` ${padVerb(verb)}` : ''+ const verb = verbOverride ?? VERBS[verbTick % VERBS.length] ?? ''+ const verbSegment = displayVerb ? ` ${padVerb(verb)}` : ''// Leading space keeps a gap between the frame and the duration when the// verb segment is hidden (e.g. `unicode` spinner style). When the verb// IS shown, its trailing padding already provides the gap, so the extra@@ -475,6 +489,7 @@ export function StatusRule({cwdLabel,cols,busy,+ compacting = false,status,statusBarFields = null,statusColor,@@ -666,7 +681,12 @@ export function StatusRule({</Text>) : null}{busy ? (- <FaceTicker color={statusColor} startedAt={turnStartedAt} style={indicatorStyle} />+ <FaceTicker+ color={statusColor}+ startedAt={turnStartedAt}+ style={indicatorStyle}+ verbOverride={compacting ? 'compacting' : undefined}+ />) : showNotice ? null : (<Text color={statusColor} wrap="truncate-end">{status}@@ -918,6 +938,8 @@ interface StatusRuleProps {lastTurnEndedAt?: null | numberliveSessionCount: numberbusy: boolean+ // Context compaction in progress — FaceTicker freezes on "compacting".+ compacting?: booleancols: numbercwdLabel: stringmodel: stringdiff --git a/ui-tui/src/components/appLayout.tsx b/ui-tui/src/components/appLayout.tsxindex 47eef82a262..d651a00e77e 100644--- a/ui-tui/src/components/appLayout.tsx+++ b/ui-tui/src/components/appLayout.tsx@@ -492,6 +492,7 @@ const StatusRulePane = memo(function StatusRulePane({battery={ui.battery ? ui.batteryStatus : null}bgCount={ui.bgTasks.size}busy={ui.busy}+ compacting={ui.compacting}cols={composer.cols}cwdLabel={status.cwdLabel}focusView={ui.focusView}