Away Summary

Description

The Away Summary service generates a 1-3 sentence re-orientation message when a user returns to Claude Code after being away. It uses terminal focus tracking via DECSET 1004 (a terminal escape sequence for focus reporting) to detect when the terminal has been blurred for 5 minutes, then produces a short recap of the session context. The summary is injected as a system message with subtype away_summary so the user can quickly re-orient without scrolling through the conversation history.

The service consists of two layers. The React hook useAwaySummary() in src/hooks/useAwaySummary.ts manages the timer and focus-change lifecycle. It subscribes to the terminal focus state module (src/ink/terminal-focus-state.ts) and starts a 5-minute timer (BLUR_DELAY_MS = 300,000ms) when the terminal state transitions to 'blurred'. If the timer fires while a model turn is in progress (isLoading === true), the generation is deferred via a pendingRef flag and fires when the turn ends. The generation is aborted if the user refocuses the terminal before it completes. Terminals that do not support DECSET 1004 report 'unknown' and no summary is ever generated (no-op).

The backend generation function generateAwaySummary() in src/services/awaySummary.ts takes the last 30 messages (RECENT_MESSAGE_WINDOW = 30) plus session memory content, appends a system-crafted prompt instructing the model to state the high-level task and the concrete next step, and queries a small fast model (getSmallFastModel()) without streaming, thinking, or tools. The result is returned as plain text or null on abort/error. A deduplication guard (hasSummarySinceLastUserTurn()) prevents multiple away summaries from stacking between user turns. The feature is gated behind both a compile-time feature flag (AWAY_SUMMARY) and a GrowthBook runtime flag (tengu_sedge_lantern, default false for 3P).

Key claims

Relations

Sources