diff --git a/src/cli/commands/status/__tests__/action.test.ts b/src/cli/commands/status/__tests__/action.test.ts index 1c3a089dc..a2c5c0930 100644 --- a/src/cli/commands/status/__tests__/action.test.ts +++ b/src/cli/commands/status/__tests__/action.test.ts @@ -631,6 +631,20 @@ describe('handleProjectStatus — live enrichment', () => { expect(evalEntry!.deploymentState).toBe('local-only'); expect(mockGetEvaluator).not.toHaveBeenCalled(); }); + + it('returns empty targetName when no targets are configured (regression for #985)', async () => { + const ctx = makeContext({ + awsTargets: [] as unknown as StatusContext['awsTargets'], + deployedState: { + targets: {}, + } as unknown as StatusContext['deployedState'], + }); + + const result = await handleProjectStatus(ctx); + + expect(result.success).toBe(true); + expect(result.targetName).toBe(''); + }); }); describe('buildRuntimeInvocationUrl', () => { diff --git a/src/cli/commands/status/command.tsx b/src/cli/commands/status/command.tsx index 506ad10ec..505b289a8 100644 --- a/src/cli/commands/status/command.tsx +++ b/src/cli/commands/status/command.tsx @@ -113,7 +113,8 @@ export const registerStatus = (program: Command) => { render( - AgentCore Status - {result.runtimeId} (target: {result.targetName}) + AgentCore Status - {result.runtimeId} (target:{' '} + {result.targetName && result.targetName.length > 0 ? result.targetName : 'No target configured'}) {runtimeStatus ? ` - ${runtimeStatus}` : ''} );