From 7ab27d47a0644cf8a4e2ae415eae1c8898e957da Mon Sep 17 00:00:00 2001 From: Aidan Daly Date: Tue, 21 Apr 2026 15:38:49 -0400 Subject: [PATCH 1/2] fix(invoke): show full session ID and print resume command on exit The invoke TUI truncated the session ID to 8 characters, making it impossible to copy the full UUID needed for --session-id. Additionally, there was no guidance on how to resume a session after exiting. - Display full session ID in the TUI header instead of truncating - Print a colored resume command after TUI exit (both Esc and Ctrl+C) - Use Ink's unmount() instead of process.exit(0) for clean shutdown, which also fixes the update notifier not showing on Esc exit --- src/cli/cli.ts | 6 ++++++ src/cli/commands/invoke/command.tsx | 4 ++-- src/cli/tui/screens/invoke/InvokeScreen.tsx | 11 ++++++++++- 3 files changed, 18 insertions(+), 3 deletions(-) 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..eac087589 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) { + const cyan = '\x1b[36m'; + const reset = '\x1b[0m'; + setExitMessage(`To resume this session, run: ${cyan}agentcore invoke --session-id ${sessionId}${reset}`); + } + }, [sessionId]); + // 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' && ( From 318f6902f901654579c0fd1e860d98efe11f141c Mon Sep 17 00:00:00 2001 From: Aidan Daly Date: Tue, 21 Apr 2026 15:54:58 -0400 Subject: [PATCH 2/2] fix: only show resume message when a session was actually used --- src/cli/tui/screens/invoke/InvokeScreen.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cli/tui/screens/invoke/InvokeScreen.tsx b/src/cli/tui/screens/invoke/InvokeScreen.tsx index eac087589..341705205 100644 --- a/src/cli/tui/screens/invoke/InvokeScreen.tsx +++ b/src/cli/tui/screens/invoke/InvokeScreen.tsx @@ -147,12 +147,12 @@ export function InvokeScreen({ const mcpFetchTriggeredRef = useRef(false); useEffect(() => { - if (sessionId) { + 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]); + }, [sessionId, messages.length]); // Compute auth type early so hooks can reference it const currentAgent = config?.runtimes[selectedAgent];