Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
fix: avoid error when AI usage is zero
Fixes a bug that prevents the managed AI agent usage from showing in the
licenses page of the dashboard when the usage is zero.
  • Loading branch information
deansheather committed Aug 18, 2025
commit d244315247f8f03a3386f53d96271a0711b76788
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,23 @@ type Story = StoryObj<typeof ManagedAgentsConsumption>;

export const Default: Story = {};

export const ZeroUsage: Story = {
args: {
managedAgentFeature: {
enabled: true,
actual: 0,
soft_limit: 60000,
limit: 120000,
usage_period: {
start: "February 27, 2025",
end: "February 27, 2026",
issued_at: "February 27, 2025",
},
entitlement: "entitled",
},
},
};

export const NearLimit: Story = {
args: {
managedAgentFeature: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,20 @@ export const ManagedAgentsConsumption: FC<ManagedAgentsConsumptionProps> = ({
);
}

const usage = managedAgentFeature.actual;
const included = managedAgentFeature.soft_limit;
const limit = managedAgentFeature.limit;
const valueOrZero = (value: number | undefined | null) =>
value === undefined || value === null ? 0 : value;

const usage = valueOrZero(managedAgentFeature.actual);
const included = valueOrZero(managedAgentFeature.soft_limit);
const limit = valueOrZero(managedAgentFeature.limit);
const startDate = managedAgentFeature.usage_period?.start;
const endDate = managedAgentFeature.usage_period?.end;

if (!usage || usage < 0) {
if (usage < 0) {
return <ErrorAlert error="Invalid usage data" />;
}

if (!included || included < 0 || !limit || limit < 0) {
if (included < 0 || limit < 0) {
return <ErrorAlert error="Invalid license usage limits" />;
}

Expand Down
Loading