Repository navigation
feat(studio): Add Agent Details tab #880
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
52 changes: 52 additions & 0 deletions
52
web/packages/studio/src/routes/agents/AgentDetailRoute/ConfigValue.test.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| // SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| import { humanizeKey } from '@studio/routes/agents/AgentDetailRoute/configFormat'; | ||
| import { ConfigValue } from '@studio/routes/agents/AgentDetailRoute/ConfigValue'; | ||
| import { render, screen } from '@studio/tests/util/render'; | ||
|
|
||
| describe('humanizeKey', () => { | ||
| it.each([ | ||
| ['_type', 'Type'], | ||
| ['model_name', 'Model Name'], | ||
| ['llm_name', 'LLM Name'], | ||
| ['base_url', 'Base URL'], | ||
| ['parseAgentResponseMaxRetries', 'Parse Agent Response Max Retries'], | ||
| ])('humanizes %s -> %s', (input, expected) => { | ||
| expect(humanizeKey(input)).toBe(expected); | ||
| }); | ||
| }); | ||
|
|
||
| describe('ConfigValue', () => { | ||
| it('renders a scalar as a single row', () => { | ||
| render(<ConfigValue label="verbose" value={false} />); | ||
| expect(screen.getByText('Verbose')).toBeInTheDocument(); | ||
| expect(screen.getByText('false')).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('joins a scalar array', () => { | ||
| render(<ConfigValue label="tool_names" value={['wiki', 'clock']} />); | ||
| expect(screen.getByText('Tool Names')).toBeInTheDocument(); | ||
| expect(screen.getByText('wiki, clock')).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('masks sensitive keys', () => { | ||
| render(<ConfigValue label="api_key" value="super-secret" />); | ||
| expect(screen.queryByText('super-secret')).not.toBeInTheDocument(); | ||
| expect(screen.getByText('••••••••')).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('does not mask allowlisted token-count keys', () => { | ||
| render(<ConfigValue label="max_tokens" value={4096} />); | ||
| expect(screen.getByText('Max Tokens')).toBeInTheDocument(); | ||
| expect(screen.getByText('4096')).toBeInTheDocument(); | ||
| expect(screen.queryByText('••••••••')).not.toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('recurses into nested objects', () => { | ||
| render(<ConfigValue label="llm" value={{ _type: 'openai', temperature: 0 }} />); | ||
| expect(screen.getByText('Type')).toBeInTheDocument(); | ||
| expect(screen.getByText('openai')).toBeInTheDocument(); | ||
| expect(screen.getByText('Temperature')).toBeInTheDocument(); | ||
| }); | ||
| }); |
92 changes: 92 additions & 0 deletions
92
web/packages/studio/src/routes/agents/AgentDetailRoute/ConfigValue.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| // SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| import { KVPair } from '@nemo/common/src/components/KVPair'; | ||
| import { Stack, Text } from '@nvidia/foundations-react-core'; | ||
| import { humanizeKey } from '@studio/routes/agents/AgentDetailRoute/configFormat'; | ||
| import type { FC } from 'react'; | ||
|
|
||
| const SENSITIVE_KEY = /(api[_-]?key|secret|token|password|passwd|credential)/i; | ||
| const MASK = '••••••••'; | ||
|
|
||
| /** Keys that match SENSITIVE_KEY on substring but are ordinary config, not secrets. */ | ||
| const NON_SENSITIVE_KEYS = new Set([ | ||
| 'max_tokens', | ||
| 'max_new_tokens', | ||
| 'max_input_tokens', | ||
| 'max_output_tokens', | ||
| 'max_completion_tokens', | ||
| 'max_prompt_tokens', | ||
| 'num_tokens', | ||
| 'token_limit', | ||
| 'context_window_tokens', | ||
| ]); | ||
|
|
||
| const isSensitiveKey = (key: string): boolean => | ||
| !NON_SENSITIVE_KEYS.has(key.toLowerCase()) && SENSITIVE_KEY.test(key); | ||
|
steramae-nvidia marked this conversation as resolved.
Resolved
|
||
|
|
||
| const isScalar = (value: unknown): boolean => | ||
| value === null || ['string', 'number', 'boolean'].includes(typeof value); | ||
|
|
||
| const formatScalar = (value: unknown): string => { | ||
| if (value === null || value === undefined) return '—'; | ||
| if (typeof value === 'boolean') return value ? 'true' : 'false'; | ||
| return String(value); | ||
| }; | ||
|
|
||
| interface ConfigValueProps { | ||
| label: string; | ||
| value: unknown; | ||
| } | ||
|
|
||
| /** | ||
| * Recursively renders an arbitrary config value as KVPair rows. Scalars (and | ||
| * scalar-only arrays) collapse to a single row; nested objects/arrays indent. | ||
| * Values under sensitive keys (api_key, token, secret, …) are masked. | ||
| */ | ||
| export const ConfigValue: FC<ConfigValueProps> = ({ label, value }) => { | ||
| const heading = humanizeKey(label); | ||
|
|
||
| if (isSensitiveKey(label) && value != null && value !== '') { | ||
| return <KVPair label={heading} value={MASK} />; | ||
| } | ||
|
|
||
| if (Array.isArray(value)) { | ||
| if (value.length === 0) return <KVPair label={heading} value="—" />; | ||
| if (value.every(isScalar)) { | ||
| return <KVPair label={heading} value={value.map(formatScalar).join(', ')} />; | ||
| } | ||
| return ( | ||
| <NestedBlock heading={heading}> | ||
| {value.map((item, index) => ( | ||
| <ConfigValue key={index} label={`${index + 1}`} value={item} /> | ||
| ))} | ||
| </NestedBlock> | ||
| ); | ||
| } | ||
|
|
||
| if (value !== null && typeof value === 'object') { | ||
| const entries = Object.entries(value as Record<string, unknown>); | ||
| if (entries.length === 0) return <KVPair label={heading} value="—" />; | ||
| return ( | ||
| <NestedBlock heading={heading}> | ||
| {entries.map(([childKey, childValue]) => ( | ||
| <ConfigValue key={childKey} label={childKey} value={childValue} /> | ||
| ))} | ||
| </NestedBlock> | ||
| ); | ||
| } | ||
|
|
||
| return <KVPair label={heading} value={formatScalar(value)} />; | ||
| }; | ||
|
|
||
| const NestedBlock: FC<{ heading: string; children: React.ReactNode }> = ({ heading, children }) => ( | ||
| <Stack gap="1"> | ||
| <Text kind="label/regular/sm" className="text-secondary"> | ||
| {heading} | ||
| </Text> | ||
| <Stack gap="2" className="border-l border-base pl-3"> | ||
| {children} | ||
| </Stack> | ||
| </Stack> | ||
| ); | ||
38 changes: 0 additions & 38 deletions
38
web/packages/studio/src/routes/agents/AgentDetailRoute/ConfigurationTab.tsx
This file was deleted.
Oops, something went wrong.
116 changes: 116 additions & 0 deletions
116
web/packages/studio/src/routes/agents/AgentDetailRoute/DetailsTab.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,116 @@ | ||
| // SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| import { KVPair } from '@nemo/common/src/components/KVPair'; | ||
| import { RelativeTime } from '@nemo/common/src/components/RelativeTime'; | ||
| import { isDefined } from '@nemo/common/src/utils/list'; | ||
| import type { Agent } from '@nemo/sdk/generated/agents/schema/Agent'; | ||
| import { Stack, Text } from '@nvidia/foundations-react-core'; | ||
| import type { AgentConfig } from '@studio/components/dataViews/AgentsDataView'; | ||
| import { getAgentModelNames } from '@studio/components/dataViews/AgentsDataView/utils'; | ||
| import { ConfigValue } from '@studio/routes/agents/AgentDetailRoute/ConfigValue'; | ||
| import { DetailPanel } from '@studio/routes/agents/AgentDetailRoute/overview/DetailPanel'; | ||
| import type { FC } from 'react'; | ||
|
|
||
| /** Config keys rendered by dedicated structured panels below. */ | ||
| const STRUCTURED_KEYS = ['workflow', 'llms', 'functions'] as const; | ||
|
|
||
| interface DetailsTabProps { | ||
| workspace: string; | ||
| agentName?: string; | ||
| agent?: Agent; | ||
| } | ||
|
|
||
| /** | ||
| * Read-only view of the exact spec an agent is built with: identity metadata | ||
| * plus every field of its config, grouped into structured panels with an | ||
| * "Additional configuration" fallback so nothing in the spec is hidden. | ||
| */ | ||
| export const DetailsTab: FC<DetailsTabProps> = ({ workspace, agentName, agent }) => { | ||
| const config = (agent?.config ?? {}) as Record<string, unknown>; | ||
| const models = getAgentModelNames(agent?.config as AgentConfig | undefined); | ||
|
|
||
| const workflow = asRecord(config['workflow']); | ||
| const llms = asRecord(config['llms']); | ||
| const functions = asRecord(config['functions']); | ||
| const extraEntries = Object.entries(config).filter( | ||
| ([key]) => !STRUCTURED_KEYS.includes(key as (typeof STRUCTURED_KEYS)[number]) | ||
| ); | ||
|
|
||
| return ( | ||
| <Stack gap="4" className="mx-auto w-full max-w-3xl pb-6"> | ||
| <DetailPanel title="Overview"> | ||
| <Stack gap="2"> | ||
| <KVPair label="Name" value={agent?.name ?? agentName} /> | ||
| <KVPair label="Workspace" value={agent?.workspace ?? workspace} /> | ||
| {isDefined(agent?.project) && agent.project && ( | ||
| <KVPair label="Project" value={agent.project} /> | ||
| )} | ||
| {isDefined(agent?.description) && agent.description && ( | ||
| <KVPair label="Description" value={agent.description} /> | ||
| )} | ||
| {models.length > 0 && <KVPair label="Model" value={models.join(', ')} />} | ||
| {isDefined(agent?.config_format) && ( | ||
| <KVPair label="Config format" value={agent.config_format} /> | ||
| )} | ||
| {isDefined(agent?.id) && <KVPair label="Agent ID" value={agent.id} truncate />} | ||
| {isDefined(agent?.created_at) && agent.created_at && ( | ||
| <KVPair label="Created" value={<RelativeTime datetime={agent.created_at} />} /> | ||
| )} | ||
| {isDefined(agent?.updated_at) && agent.updated_at && ( | ||
| <KVPair label="Updated" value={<RelativeTime datetime={agent.updated_at} />} /> | ||
| )} | ||
| </Stack> | ||
| </DetailPanel> | ||
|
|
||
| {workflow && ( | ||
| <DetailPanel title="Workflow"> | ||
| <ConfigEntries data={workflow} /> | ||
| </DetailPanel> | ||
| )} | ||
|
|
||
| {llms && ( | ||
| <DetailPanel title="Models"> | ||
| <ConfigEntries data={llms} /> | ||
| </DetailPanel> | ||
| )} | ||
|
|
||
| {functions && ( | ||
| <DetailPanel title="Tools"> | ||
| <ConfigEntries data={functions} /> | ||
| </DetailPanel> | ||
| )} | ||
|
|
||
| {extraEntries.length > 0 && ( | ||
| <DetailPanel title="Additional configuration"> | ||
| <Stack gap="2"> | ||
| {extraEntries.map(([key, value]) => ( | ||
| <ConfigValue key={key} label={key} value={value} /> | ||
| ))} | ||
| </Stack> | ||
| </DetailPanel> | ||
| )} | ||
|
|
||
| {Object.keys(config).length === 0 && ( | ||
| <DetailPanel title="Configuration"> | ||
| <Text kind="body/regular/sm" className="text-secondary"> | ||
| This agent has no stored configuration. | ||
| </Text> | ||
| </DetailPanel> | ||
| )} | ||
| </Stack> | ||
| ); | ||
| }; | ||
|
|
||
| const asRecord = (value: unknown): Record<string, unknown> | undefined => | ||
| value !== null && typeof value === 'object' && !Array.isArray(value) | ||
| ? (value as Record<string, unknown>) | ||
| : undefined; | ||
|
|
||
| const ConfigEntries: FC<{ data: Record<string, unknown> }> = ({ data }) => ( | ||
| <Stack gap="2"> | ||
| {Object.entries(data).map(([key, value]) => ( | ||
| <ConfigValue key={key} label={key} value={value} /> | ||
| ))} | ||
| </Stack> | ||
| ); |
22 changes: 22 additions & 0 deletions
22
web/packages/studio/src/routes/agents/AgentDetailRoute/configFormat.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| // SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| const ACRONYMS: Record<string, string> = { | ||
| llm: 'LLM', | ||
| llms: 'LLMs', | ||
| url: 'URL', | ||
| api: 'API', | ||
| id: 'ID', | ||
| uri: 'URI', | ||
| }; | ||
|
|
||
| /** Turns a snake_case / camelCase config key into a readable label. */ | ||
| export const humanizeKey = (key: string): string => | ||
| key | ||
| .replace(/([a-z\d])([A-Z])/g, '$1 $2') | ||
| .replace(/[_-]+/g, ' ') | ||
| .trim() | ||
| .split(' ') | ||
| .filter(Boolean) | ||
| .map((word) => ACRONYMS[word.toLowerCase()] ?? word.charAt(0).toUpperCase() + word.slice(1)) | ||
| .join(' '); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.