feat(agents): implement first-run experience for project-level sub-agents (#17266)

This commit is contained in:
Christian Gunderman
2026-01-26 19:49:32 +00:00
committed by GitHub
parent d745d86af1
commit 2271bbb339
18 changed files with 769 additions and 15 deletions

View File

@@ -32,6 +32,7 @@ import process from 'node:process';
import { type UseHistoryManagerReturn } from '../hooks/useHistoryManager.js';
import { AdminSettingsChangedDialog } from './AdminSettingsChangedDialog.js';
import { IdeTrustChangeDialog } from './IdeTrustChangeDialog.js';
import { NewAgentsNotification } from './NewAgentsNotification.js';
import { AgentConfigDialog } from './AgentConfigDialog.js';
interface DialogManagerProps {
@@ -58,6 +59,14 @@ export const DialogManager = ({
if (uiState.showIdeRestartPrompt) {
return <IdeTrustChangeDialog reason={uiState.ideTrustRestartReason} />;
}
if (uiState.newAgents) {
return (
<NewAgentsNotification
agents={uiState.newAgents}
onSelect={uiActions.handleNewAgentsSelect}
/>
);
}
if (uiState.proQuotaRequest) {
return (
<ProQuotaDialog

View File

@@ -0,0 +1,57 @@
/**
* @license
* Copyright 2026 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
import { describe, it, expect, vi } from 'vitest';
import { renderWithProviders as render } from '../../test-utils/render.js';
import { NewAgentsNotification } from './NewAgentsNotification.js';
describe('NewAgentsNotification', () => {
const mockAgents = [
{
name: 'Agent A',
description: 'Description A',
kind: 'remote' as const,
agentCardUrl: '',
inputConfig: { inputSchema: {} },
},
{
name: 'Agent B',
description: 'Description B',
kind: 'remote' as const,
agentCardUrl: '',
inputConfig: { inputSchema: {} },
},
];
const onSelect = vi.fn();
it('renders agent list', () => {
const { lastFrame, unmount } = render(
<NewAgentsNotification agents={mockAgents} onSelect={onSelect} />,
);
const frame = lastFrame();
expect(frame).toMatchSnapshot();
unmount();
});
it('truncates list if more than 5 agents', () => {
const manyAgents = Array.from({ length: 7 }, (_, i) => ({
name: `Agent ${i}`,
description: `Description ${i}`,
kind: 'remote' as const,
agentCardUrl: '',
inputConfig: { inputSchema: {} },
}));
const { lastFrame, unmount } = render(
<NewAgentsNotification agents={manyAgents} onSelect={onSelect} />,
);
const frame = lastFrame();
expect(frame).toMatchSnapshot();
unmount();
});
});

View File

@@ -0,0 +1,96 @@
/**
* @license
* Copyright 2026 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
import { Box, Text } from 'ink';
import { type AgentDefinition } from '@google/gemini-cli-core';
import { theme } from '../semantic-colors.js';
import {
RadioButtonSelect,
type RadioSelectItem,
} from './shared/RadioButtonSelect.js';
export enum NewAgentsChoice {
ACKNOWLEDGE = 'acknowledge',
IGNORE = 'ignore',
}
interface NewAgentsNotificationProps {
agents: AgentDefinition[];
onSelect: (choice: NewAgentsChoice) => void;
}
export const NewAgentsNotification = ({
agents,
onSelect,
}: NewAgentsNotificationProps) => {
const options: Array<RadioSelectItem<NewAgentsChoice>> = [
{
label: 'Acknowledge and Enable',
value: NewAgentsChoice.ACKNOWLEDGE,
key: 'acknowledge',
},
{
label: 'Do not enable (Ask again next time)',
value: NewAgentsChoice.IGNORE,
key: 'ignore',
},
];
// Limit display to 5 agents to avoid overflow, show count for rest
const MAX_DISPLAYED_AGENTS = 5;
const displayAgents = agents.slice(0, MAX_DISPLAYED_AGENTS);
const remaining = agents.length - MAX_DISPLAYED_AGENTS;
return (
<Box flexDirection="column" width="100%">
<Box
flexDirection="column"
borderStyle="round"
borderColor={theme.status.warning}
padding={1}
marginLeft={1}
marginRight={1}
>
<Box flexDirection="column" marginBottom={1}>
<Text bold color={theme.text.primary}>
New Agents Discovered
</Text>
<Text color={theme.text.primary}>
The following agents were found in this project. Please review them:
</Text>
<Box
flexDirection="column"
marginTop={1}
borderStyle="single"
padding={1}
>
{displayAgents.map((agent) => (
<Box key={agent.name}>
<Box flexShrink={0}>
<Text bold color={theme.text.primary}>
- {agent.name}:{' '}
</Text>
</Box>
<Text color={theme.text.secondary}> {agent.description}</Text>
</Box>
))}
{remaining > 0 && (
<Text color={theme.text.secondary}>
... and {remaining} more.
</Text>
)}
</Box>
</Box>
<RadioButtonSelect
items={options}
onSelect={onSelect}
isFocused={true}
/>
</Box>
</Box>
);
};

View File

@@ -0,0 +1,43 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
exports[`NewAgentsNotification > renders agent list 1`] = `
" ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ │
│ New Agents Discovered │
│ The following agents were found in this project. Please review them: │
│ │
│ ┌────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ │
│ │ │ │
│ │ - Agent A: Description A │ │
│ │ - Agent B: Description B │ │
│ │ │ │
│ └────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ │
│ │
│ ● 1. Acknowledge and Enable │
│ 2. Do not enable (Ask again next time) │
│ │
╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯"
`;
exports[`NewAgentsNotification > truncates list if more than 5 agents 1`] = `
" ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ │
│ New Agents Discovered │
│ The following agents were found in this project. Please review them: │
│ │
│ ┌────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ │
│ │ │ │
│ │ - Agent 0: Description 0 │ │
│ │ - Agent 1: Description 1 │ │
│ │ - Agent 2: Description 2 │ │
│ │ - Agent 3: Description 3 │ │
│ │ - Agent 4: Description 4 │ │
│ │ ... and 2 more. │ │
│ │ │ │
│ └────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ │
│ │
│ ● 1. Acknowledge and Enable │
│ 2. Do not enable (Ask again next time) │
│ │
╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯"
`;