From 155fa92a3c54a004d2b44c9a1e091d0354904436 Mon Sep 17 00:00:00 2001 From: Devansh Jain <31609257+devanshrj@users.noreply.github.com> Date: Mon, 15 Dec 2025 17:19:41 -0800 Subject: [PATCH] fix: /pinned bugs (#222) --- src/cli/components/ProfileSelector.tsx | 62 ++++++++++++++------------ 1 file changed, 33 insertions(+), 29 deletions(-) diff --git a/src/cli/components/ProfileSelector.tsx b/src/cli/components/ProfileSelector.tsx index 79fc86f..cdcaaff 100644 --- a/src/cli/components/ProfileSelector.tsx +++ b/src/cli/components/ProfileSelector.tsx @@ -18,7 +18,7 @@ interface ProfileData { agentId: string; agent: AgentState | null; error: string | null; - isPinned: boolean; + isLocal: boolean; // true = project-level pin, false = global pin } const DISPLAY_PAGE_SIZE = 5; @@ -92,7 +92,6 @@ export const ProfileSelector = memo(function ProfileSelector({ setLoading(true); try { const mergedPinned = settingsManager.getMergedPinnedAgents(); - const localPinned = settingsManager.getLocalPinnedAgents(); if (mergedPinned.length === 0) { setProfiles([]); @@ -103,24 +102,25 @@ export const ProfileSelector = memo(function ProfileSelector({ const client = await getClient(); // Fetch agent data for each pinned agent - const profileDataPromises = mergedPinned.map(async ({ agentId }) => { - const isPinned = localPinned.includes(agentId); - try { - const agent = await client.agents.retrieve(agentId, { - include: ["agent.blocks"], - }); - // Use agent name from server - return { name: agent.name, agentId, agent, error: null, isPinned }; - } catch (_err) { - return { - name: agentId.slice(0, 12), - agentId, - agent: null, - error: "Agent not found", - isPinned, - }; - } - }); + const profileDataPromises = mergedPinned.map( + async ({ agentId, isLocal }) => { + try { + const agent = await client.agents.retrieve(agentId, { + include: ["agent.blocks"], + }); + // Use agent name from server + return { name: agent.name, agentId, agent, error: null, isLocal }; + } catch (_err) { + return { + name: agentId.slice(0, 12), + agentId, + agent: null, + error: "Agent not found", + isLocal, + }; + } + }, + ); const profileData = await Promise.all(profileDataPromises); setProfiles(profileData); @@ -198,11 +198,11 @@ export const ProfileSelector = memo(function ProfileSelector({ } } else if (input === "p" || input === "P") { if (selectedProfile) { - // Toggle pin/unpin for selected profile - if (selectedProfile.isPinned) { + // Unpin from current scope + if (selectedProfile.isLocal) { settingsManager.unpinLocal(selectedProfile.agentId); } else { - settingsManager.pinLocal(selectedProfile.agentId); + settingsManager.unpinGlobal(selectedProfile.agentId); } } else { // No profiles - pin the current agent @@ -292,7 +292,11 @@ export const ProfileSelector = memo(function ProfileSelector({ const displayId = truncateAgentId(profile.agentId, availableForId); return ( - + {/* Row 1: Selection indicator, profile name, and ID */} {profile.name} - {profile.isPinned && ( - (pinned) - )} - · {displayId} + + {" "} + · {profile.isLocal ? "project" : "global"} · {displayId} + {isCurrent && ( (current) )} @@ -360,7 +364,7 @@ export const ProfileSelector = memo(function ProfileSelector({ )} - ↑↓ navigate · Enter load · P pin/unpin · D unpin all · Esc close + ↑↓ navigate · Enter load · P unpin · D unpin all · Esc close