Skip to content

Commit 7ab27d4

Browse files
committed
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
1 parent 74a35cb commit 7ab27d4

3 files changed

Lines changed: 18 additions & 3 deletions

File tree

src/cli/cli.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,4 +224,10 @@ export const main = async (argv: string[]) => {
224224

225225
// Telemetry notice already printed above; only run update check here.
226226
await printPostCommandNotices(false, updateCheck);
227+
228+
const exitMessage = getExitMessage();
229+
if (exitMessage) {
230+
console.log(`\n${exitMessage}`);
231+
clearExitMessage();
232+
}
227233
};

src/cli/commands/invoke/command.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,10 +168,10 @@ export const registerInvoke = (program: Command) => {
168168
});
169169
} else {
170170
// No CLI options - interactive TUI mode (headers still passed if provided)
171-
const { waitUntilExit } = render(
171+
const { waitUntilExit, unmount } = render(
172172
<InvokeScreen
173173
isInteractive={true}
174-
onExit={() => process.exit(0)}
174+
onExit={() => unmount()}
175175
initialSessionId={cliOptions.sessionId}
176176
initialUserId={cliOptions.userId}
177177
initialHeaders={headers}

src/cli/tui/screens/invoke/InvokeScreen.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { buildTraceConsoleUrl } from '../../../operations/traces';
22
import { GradientText, LogLink, Panel, Screen, SelectList, TextInput } from '../../components';
3+
import { setExitMessage } from '../../exit-message';
34
import { useInvokeFlow } from './useInvokeFlow';
45
import { Box, Text, useInput, useStdout } from 'ink';
56
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
@@ -145,6 +146,14 @@ export function InvokeScreen({
145146
const justCancelledRef = useRef(false);
146147
const mcpFetchTriggeredRef = useRef(false);
147148

149+
useEffect(() => {
150+
if (sessionId) {
151+
const cyan = '\x1b[36m';
152+
const reset = '\x1b[0m';
153+
setExitMessage(`To resume this session, run: ${cyan}agentcore invoke --session-id ${sessionId}${reset}`);
154+
}
155+
}, [sessionId]);
156+
148157
// Compute auth type early so hooks can reference it
149158
const currentAgent = config?.runtimes[selectedAgent];
150159
const isCustomJwt = currentAgent?.authorizerType === 'CUSTOM_JWT';
@@ -398,7 +407,7 @@ export function InvokeScreen({
398407
{mode !== 'select-agent' && (
399408
<Box>
400409
<Text>Session: </Text>
401-
<Text color="magenta">{sessionId?.slice(0, 8) ?? 'none'}</Text>
410+
<Text color="magenta">{sessionId ?? 'none'}</Text>
402411
</Box>
403412
)}
404413
{mode !== 'select-agent' && (

0 commit comments

Comments
 (0)