Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/deep-ocean-thrive.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@giantswarm/backstage-plugin-agent-platform': patch
---

Hide unavailable deployment details on agent pages while preserving the agent's readiness.
76 changes: 76 additions & 0 deletions e2e/agentlab/agents.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
expect,
expectNoHorizontalScroll,
expectWizardStep,
open,
openWizardMoreOptions,
Expand All @@ -24,6 +25,81 @@ import { lab } from './lab';
*/
const rosterWait = 2 * 60_000;

test('an agent omits unavailable deployment details and keeps its readiness at desktop and phone widths', async ({
admin,
}) => {
test.setTimeout(rosterWait + 60_000);
await open(admin, '/customize/agents');
const agentLink = admin
.locator(`a[href^="/customize/agents/${lab.installation}/"]`)
.first();
await expect(agentLink).toBeVisible({ timeout: rosterWait });
const detailPath = await agentLink.getAttribute('href');
expect(detailPath).toBeTruthy();
const [, , , , namespace, name] = detailPath!.split('/');
const releaseWithheld =
'Reading the release details needs the agent-platform:editor role.';
let answered = 0;
await admin.route('**/api/muster/call**', async route => {
const call = route.request().postDataJSON() as {
name?: string;
arguments?: { name?: string };
} | null;
if (
call?.name !== 'x_agent-manager_get_agent' ||
call.arguments?.name !== name
) {
await route.fallback();
return;
}
answered++;
await route.fulfill({
json: {
name,
namespace,
exists: true,
ready: true,
managed: 'unknown',
releaseWithheld,
},
});
});

await agentLink.click();
await expect(admin).toHaveURL(new RegExp(`${detailPath}$`));
const details = admin.getByRole('button', {
name: 'Technical details',
exact: true,
});
await expect(details).toBeVisible({ timeout: rosterWait });
if ((await details.getAttribute('aria-expanded')) !== 'true') {
await details.click();
}
await expect.poll(() => answered).toBeGreaterThan(0);

const readiness = admin
.getByRole('main')
.getByText('Ready', { exact: true })
.first();
for (const width of [1440, 375]) {
await admin.setViewportSize({ width, height: 900 });
await expect(readiness).toBeVisible();
await expect(admin.getByText(releaseWithheld, { exact: true })).toHaveCount(
0,
);
await expect(admin.getByText('Deployed by', { exact: true })).toHaveCount(
0,
);
await expect(
admin.getByText("Reconciling this agent's chart", { exact: true }),
).toHaveCount(0);
await expectNoHorizontalScroll(
admin,
`Withheld release details at ${width}px`,
);
}
});

test('the roster lists the agent under Customize · Agents', async ({
admin,
labAgent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ export type AgentConfigurationCardProps = {
failure?: AgentFailure;
/** The Tools tab, which resolves the toolset this card summarises. */
toolsHref?: string;
releaseDetailsUnavailable?: boolean;
};

/**
Expand All @@ -331,6 +332,7 @@ export function AgentConfigurationCard({
modelServing,
failure,
toolsHref,
releaseDetailsUnavailable,
}: AgentConfigurationCardProps) {
const namespace = agent.getNamespace();
const egress = agent.getEgress();
Expand Down Expand Up @@ -375,7 +377,9 @@ export function AgentConfigurationCard({
</Flex>
),
}),
'Deployed by': <DeployedByValue agent={agent} />,
...(!releaseDetailsUnavailable && {
'Deployed by': <DeployedByValue agent={agent} />,
}),
};

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ jest.mock('../../hooks/useAgentManager', () => ({
// `get_agent`, which the page reads for one thing only: whether agent-manager
// can write to this agent at all (`managed`). Undefined is the unread case —
// not connected, refused, still in flight — where the actions stay offered.
let managerAgent: { managed: string } | undefined;
let managerAgent: { managed: string; releaseWithheld?: string } | undefined;
let isReadingManagerAgent = false;

jest.mock('../../hooks/useAgentManagerAgent', () => ({
Expand Down Expand Up @@ -2371,6 +2371,37 @@ describe('AgentDetailPage: the frame and the plain Overview', () => {
});

describe('the frame', () => {
it('omits unavailable deployment details without changing the Agent readiness', async () => {
const releaseWithheld =
'Reading the release details needs the agent-platform:editor role.';
withAgentManager('unknown');
managerAgent = { managed: 'unknown', releaseWithheld };
stubResources({ resource: makeAgent() }, { resource: makeModelConfig() });

await renderShell();
expectHeaderReadiness('Ready');
await openTechnicalDetails();

expect(screen.queryByText(releaseWithheld)).toBeNull();
expect(screen.queryByText('Deployed by')).toBeNull();
expect(screen.queryByText("Reconciling this agent's chart")).toBeNull();
expect(screen.queryByText(/^HelmRelease /)).toBeNull();
});

it('omits deployment details for unknown management without a permission notice', async () => {
withAgentManager('unknown');
stubResources({ resource: makeAgent() }, { resource: makeModelConfig() });

await renderShell();
await openTechnicalDetails();

expect(screen.queryByText('Deployed by')).toBeNull();
expect(
screen.queryByText(/Release details are not available/),
).toBeNull();
expect(screen.queryByText("Reconciling this agent's chart")).toBeNull();
});

it('heads the page with the platform-standard frame, once', async () => {
stubResources({ resource: makeAgent() }, { resource: makeModelConfig() });

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1083,6 +1083,10 @@ function AgentDetailPageContent() {
onAddSkills={canEditAgent ? openEdit : undefined}
isGitOpsOwned={agentManagerGate.isGitOpsOwned}
isPlatformOwned={isPlatformOwned}
releaseDetailsUnavailable={
managerAgent?.managed === 'unknown' ||
Boolean(managerAgent?.releaseWithheld)
}
/>
}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
Harness,
ModelConfig,
} from '@giantswarm/backstage-plugin-kubernetes-react';
// eslint-disable-next-line @backstage/no-mixed-plugin-imports -- Connector identity is owned by the Muster plugin.
import { ConnectorLogo } from '@giantswarm/backstage-plugin-muster';
import {
CollapsibleMarkdown,
Expand Down Expand Up @@ -501,6 +502,7 @@ export type AgentPlainOverviewProps = {
isGitOpsOwned: boolean;
/** The platform's own agent (`managed: 'platform'`): read-only. */
isPlatformOwned?: boolean;
releaseDetailsUnavailable?: boolean;
};

/**
Expand All @@ -524,6 +526,7 @@ export function AgentPlainOverview({
onAddSkills,
isGitOpsOwned,
isPlatformOwned,
releaseDetailsUnavailable,
}: AgentPlainOverviewProps) {
const classes = useStyles();
const failure = agent.getFailure();
Expand Down Expand Up @@ -575,6 +578,7 @@ export function AgentPlainOverview({
modelServing={modelServing}
failure={failure}
toolsHref={toolsHref}
releaseDetailsUnavailable={releaseDetailsUnavailable}
/>
</TechnicalDetailsFoldOut>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,19 +129,21 @@ export function AgentTechnicalDetails({
modelServing,
failure,
toolsHref,
releaseDetailsUnavailable,
}: {
agent: Agent;
installation: string;
modelConfig: ModelConfig | undefined;
modelServing: ClientServingSummary | undefined;
failure: AgentFailure | undefined;
toolsHref?: string;
releaseDetailsUnavailable?: boolean;
}) {
return (
<Flex direction="column" gap="4">
{/* A cheap pre-check only: whether the agent is *actually* applied from
Git is the card's own decision — see AgentOverviewTab. */}
{isGitOpsManaged(agent) && (
{!releaseDetailsUnavailable && isGitOpsManaged(agent) && (
<GitOpsCard resource={agent} installationName={installation} />
)}
<ResourceFacts agent={agent} />
Expand All @@ -154,6 +156,7 @@ export function AgentTechnicalDetails({
modelServing={modelServing}
failure={failure}
toolsHref={toolsHref}
releaseDetailsUnavailable={releaseDetailsUnavailable}
/>
<AgentStatusCard agent={agent} />
</Flex>
Expand Down
9 changes: 7 additions & 2 deletions plugins/agent-platform/src/lib/agentManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
parseToolErrorCode,
AGENT_MANAGER_SERVER,
} from '@giantswarm/backstage-plugin-gs-common';
// eslint-disable-next-line @backstage/no-mixed-plugin-imports -- Agent-manager calls share Muster's connection and sign-in contract.
import {
type MusterServerPresence,
musterSignInRequiredOf,
Expand Down Expand Up @@ -285,6 +286,7 @@ export type AgentStatus = {
namespace: string;
verdict: AgentStatusVerdict;
summary: string;
releaseWithheld?: string;
agent?: AgentObjectStatus;
helmRelease?: {
exists: boolean;
Expand Down Expand Up @@ -665,9 +667,11 @@ export function helmInstallCommand(
* desired state lives in git and a live write is refused; `platform` — the
* platform's own agent (labelled `agent-platform.giantswarm.io/managed-by:
* agent-platform`), refused in every mode, a pull request too; `none` — a bare
* `Agent` object with no release behind it, refused as well.
* `Agent` object with no release behind it, refused as well; `unknown` means
* Flux details are withheld, with the reason in `releaseWithheld`.
*/
export type AgentManagedBy = 'helmrelease' | 'gitops' | 'platform' | 'none';
export type AgentManagedBy =
'helmrelease' | 'gitops' | 'platform' | 'none' | 'unknown';

/** What `get_agent` says about the release that owns the agent. */
export type AgentHelmReleaseRef = {
Expand Down Expand Up @@ -720,6 +724,7 @@ export type AgentManagerAgent = {
/** The installation's default agent (`get_info`'s `defaultAgent`). */
default?: boolean;
helmRelease?: AgentHelmReleaseRef;
releaseWithheld?: string;
/** The HelmRelease's inline values, when a release owns the agent. */
values?: Record<string, unknown>;
};
Expand Down
Loading