diff --git a/src/cli/App.tsx b/src/cli/App.tsx index d1ebe5e..30eb47b 100644 --- a/src/cli/App.tsx +++ b/src/cli/App.tsx @@ -1459,6 +1459,12 @@ export default function App({ // Track if we've sent the session context for this CLI session const hasSentSessionContextRef = useRef(false); + // Track if we've set the conversation summary for this new conversation + // Initialized to true for resumed conversations (they already have context) + const hasSetConversationSummaryRef = useRef(resumedExistingConversation); + // Store first user query for conversation summary + const firstUserQueryRef = useRef(null); + // Track skills injection state (LET-7353) const discoveredSkillsRef = useRef( null, @@ -3543,6 +3549,29 @@ export default function App({ setNeedsEagerApprovalCheck(false); } + // Set conversation summary from first user query for new conversations + if ( + !hasSetConversationSummaryRef.current && + firstUserQueryRef.current && + conversationIdRef.current !== "default" + ) { + hasSetConversationSummaryRef.current = true; + const client = await getClient(); + client.conversations + .update(conversationIdRef.current, { + summary: firstUserQueryRef.current, + }) + .catch((err) => { + // Silently ignore - not critical + if (process.env.DEBUG) { + console.error( + "[DEBUG] Failed to set conversation summary:", + err, + ); + } + }); + } + const trajectorySnapshot = sessionStatsRef.current.endTrajectory(); setTrajectoryTokenBase(0); setTrajectoryElapsedBaseMs(0); @@ -5501,6 +5530,18 @@ export default function App({ ); } + // Capture first user query for conversation summary (before any async work) + // Only for new conversations, non-commands, and if we haven't captured yet + if ( + !hasSetConversationSummaryRef.current && + firstUserQueryRef.current === null && + !isSystemOnly && + userTextForInput.length > 0 && + !userTextForInput.startsWith("/") + ) { + firstUserQueryRef.current = userTextForInput.slice(0, 100); + } + // Block submission if waiting for explicit user action (approvals) // In this case, input is hidden anyway, so this shouldn't happen if (pendingApprovals.length > 0) {