Files
paseo/plugin-examples/sidebar-views/client/agents.tsx
T
Mohamed Boudra 62bd21214b feat(plugin): add sidebar view examples and ref actions
Keep sidebar layout and gestures inside the plugin while routing entity handles to their owning hosts. Examples cover empty projects, pinned workspaces, task sections, nested agents and device-local label folders.
2026-11-06 09:22:19 +01:00

35 lines
1.2 KiB
TypeScript

import type { PluginAgentSnapshot } from "@getpaseo/plugin";
import { ScrollView, View } from "react-native";
import { useAgents, type PluginSidebarViewProps } from "@getpaseo/plugin/client";
import { AgentRow, Heading } from "./rows";
export function agentTask(agent: PluginAgentSnapshot) {
if (agent.attentionReason === "permission") return "Respond";
if (agent.requiresAttention || agent.status === "error") return "Review";
if (agent.status === "running" || agent.status === "initializing") return "Wait";
return "Start";
}
function Task({ title, view }: { title: string; view: PluginSidebarViewProps }) {
const agents = useAgents({
where: (item) => agentTask(item) === title,
orderBy: ["lastActivityAt", "desc"],
});
return (
<View>
<Heading title={title} view={view} />
{agents.map((reference) => (
<AgentRow key={reference.key} reference={reference} view={view} />
))}
</View>
);
}
export function Agents(view: PluginSidebarViewProps) {
return (
<ScrollView>
<Task title="Respond" view={view} />
<Task title="Review" view={view} />
<Task title="Wait" view={view} />
<Task title="Start" view={view} />
</ScrollView>
);
}