diff --git a/src/cli/cli.ts b/src/cli/cli.ts index 82783679c..7b9eef675 100644 --- a/src/cli/cli.ts +++ b/src/cli/cli.ts @@ -224,4 +224,10 @@ export const main = async (argv: string[]) => { // Telemetry notice already printed above; only run update check here. await printPostCommandNotices(false, updateCheck); + + const exitMessage = getExitMessage(); + if (exitMessage) { + console.log(`\n${exitMessage}`); + clearExitMessage(); + } }; diff --git a/src/cli/commands/invoke/command.tsx b/src/cli/commands/invoke/command.tsx index c808aea53..6243d90f2 100644 --- a/src/cli/commands/invoke/command.tsx +++ b/src/cli/commands/invoke/command.tsx @@ -168,10 +168,10 @@ export const registerInvoke = (program: Command) => { }); } else { // No CLI options - interactive TUI mode (headers still passed if provided) - const { waitUntilExit } = render( + const { waitUntilExit, unmount } = render( process.exit(0)} + onExit={() => unmount()} initialSessionId={cliOptions.sessionId} initialUserId={cliOptions.userId} initialHeaders={headers} diff --git a/src/cli/tui/screens/invoke/InvokeScreen.tsx b/src/cli/tui/screens/invoke/InvokeScreen.tsx index f02e40e4e..341705205 100644 --- a/src/cli/tui/screens/invoke/InvokeScreen.tsx +++ b/src/cli/tui/screens/invoke/InvokeScreen.tsx @@ -1,5 +1,6 @@ import { buildTraceConsoleUrl } from '../../../operations/traces'; import { GradientText, LogLink, Panel, Screen, SelectList, TextInput } from '../../components'; +import { setExitMessage } from '../../exit-message'; import { useInvokeFlow } from './useInvokeFlow'; import { Box, Text, useInput, useStdout } from 'ink'; import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'; @@ -145,6 +146,14 @@ export function InvokeScreen({ const justCancelledRef = useRef(false); const mcpFetchTriggeredRef = useRef(false); + useEffect(() => { + if (sessionId && messages.length > 0) { + const cyan = '\x1b[36m'; + const reset = '\x1b[0m'; + setExitMessage(`To resume this session, run: ${cyan}agentcore invoke --session-id ${sessionId}${reset}`); + } + }, [sessionId, messages.length]); + // Compute auth type early so hooks can reference it const currentAgent = config?.runtimes[selectedAgent]; const isCustomJwt = currentAgent?.authorizerType === 'CUSTOM_JWT'; @@ -398,7 +407,7 @@ export function InvokeScreen({ {mode !== 'select-agent' && ( Session: - {sessionId?.slice(0, 8) ?? 'none'} + {sessionId ?? 'none'} )} {mode !== 'select-agent' && (