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
83 changes: 83 additions & 0 deletions apps/mobile/src/widgets/AgentActivity.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import type { LiveActivityLayout } from "expo-widgets";
import { describe, expect, it, vi } from "vite-plus/test";

vi.mock("@expo/ui/swift-ui", () => ({
HStack: "HStack",
Image: "Image",
Spacer: "Spacer",
Text: "Text",
VStack: "VStack",
ZStack: "ZStack",
}));

vi.mock("@expo/ui/swift-ui/modifiers", () => {
const modifier = (value: unknown) => value;
return {
accessibilityElement: modifier,
accessibilityLabel: modifier,
activityBackgroundTint: modifier,
font: modifier,
foregroundStyle: modifier,
frame: modifier,
layoutPriority: modifier,
lineLimit: modifier,
minimumScaleFactor: modifier,
padding: modifier,
resizable: modifier,
widgetURL: modifier,
};
});

// Hand back the layout function so the test can render it with a chosen environment.
vi.mock("expo-widgets", () => ({
createLiveActivity: (_name: string, layout: unknown) => layout,
}));

import AgentActivity, {
type AgentActivityProps,
type AgentActivityRowProps,
} from "./AgentActivity";

const render = AgentActivity as unknown as (
props: AgentActivityProps,
environment: unknown,
) => LiveActivityLayout;

function row(overrides: Partial<AgentActivityRowProps>): AgentActivityRowProps {
return {
environmentId: "env-1",
threadId: "thread-1",
projectTitle: "Project",
threadTitle: "Thread",
modelTitle: "Model",
phase: "running",
status: "Working",
updatedAt: "2026-01-01T00:00:00.000Z",
deepLink: "/threads/env-1/thread-1",
...overrides,
};
}

describe("AgentActivity", () => {
it("drops the agent count from the expanded Dynamic Island once the activity is stale", () => {
const layout = render(
{
title: "Agents",
subtitle: "",
activeCount: 2,
updatedAt: "2026-01-01T00:00:00.000Z",
activities: [row({}), row({ threadId: "thread-2", phase: "starting" })],
},
{
colorScheme: "dark",
isLuminanceReduced: false,
isLiquidGlassAvailable: false,
isStale: true,
widgetRenderingMode: "fullColor",
},
);
const expandedLeading = JSON.stringify(layout.expandedLeading);
expect(expandedLeading).not.toContain('"children":"2"');
expect(expandedLeading).toContain('"children":"Out of date"');
});
});
2 changes: 1 addition & 1 deletion apps/mobile/src/widgets/AgentActivity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ function AgentActivity(
<HStack spacing={5} alignment="center" modifiers={[padding({ leading: 4, vertical: 4 })]}>
{renderLogo(15, tint)}
<Text modifiers={[font({ weight: "bold", size: 13 }), foregroundStyle(tint)]}>
{allDone ? doneLabel : `${props.activeCount}`}
{allDone || environment.isStale ? activeLabel : `${props.activeCount}`}
</Text>
</HStack>
),
Expand Down
Loading