Away Summary
- Entity ID:
ent-20260410-6c5fad5780a9 - Type:
service - Scope:
shared - Status:
active - Aliases: 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
- The blur delay before generating a summary is exactly 5 minutes:
const BLUR_DELAY_MS = 5 * 60_000insrc/hooks/useAwaySummary.ts(line 13). - The model receives only the last 30 messages for context:
const RECENT_MESSAGE_WINDOW = 30insrc/services/awaySummary.ts(line 15). - The prompt instructs: "Start by stating the high-level task -- what they are building or debugging, not implementation details. Next: the concrete next step. Skip status reports and commit recaps." (
buildAwaySummaryPrompt()at line 18-23 ofawaySummary.ts). - Terminal focus state is tracked via a module-level signal in
src/ink/terminal-focus-state.tswith three states:'focused','blurred','unknown'. The'unknown'state (no DECSET 1004 support) is a no-op for the away summary feature. - Generation is skipped if an away_summary already exists since the last user turn, checked by
hasSummarySinceLastUserTurn()which scans messages backward (line 17-23 ofuseAwaySummary.ts).
Relations
- implemented-by:
src/hooks/useAwaySummary.ts-- React hook managing timer, focus tracking, and deferred generation - implemented-by:
src/services/awaySummary.ts-- backend generation function using small fast model - depends-on:
src/ink/terminal-focus-state.ts-- terminal focus signal (DECSET 1004) - depends-on:
src/services/SessionMemory/sessionMemoryUtils.ts--getSessionMemoryContent()for broader context - creates:
systemmessage withsubtype: 'away_summary'viacreateAwaySummaryMessage()insrc/utils/messages.ts - related-to:
src/components/IdleReturnDialog.tsx-- separate UI dialog shown after inactivity offering to clear/continue
Sources
src/hooks/useAwaySummary.tssrc/services/awaySummary.tssrc/ink/terminal-focus-state.tssrc/utils/messages.ts