feat: prompt to resume global pinned agent in fresh directories (#358) (#383)

Co-authored-by: Letta <noreply@letta.com>
This commit is contained in:
Charles Packer
2025-12-24 10:44:44 -08:00
committed by GitHub
parent 25950133b8
commit 50598233f0
3 changed files with 80 additions and 13 deletions

View File

@@ -51,6 +51,7 @@ type LoadingState =
| "importing"
| "initializing"
| "checking"
| "selecting_global"
| "ready";
/**

View File

@@ -53,21 +53,23 @@ function formatModel(agent: AgentState): string {
return agent.llm_config?.model || "unknown";
}
function getLabel(option: ProfileOption): string {
function getLabel(option: ProfileOption, freshRepoMode?: boolean): string {
const parts: string[] = [];
if (option.isLru) parts.push("last used");
if (option.isLocal) parts.push("pinned");
else if (!option.isLru) parts.push("global"); // Pinned globally but not locally
else if (!option.isLru && !freshRepoMode) parts.push("global"); // Pinned globally but not locally
return parts.length > 0 ? ` (${parts.join(", ")})` : "";
}
function ProfileSelectionUI({
lruAgentId,
externalLoading,
externalFreshRepoMode,
onComplete,
}: {
lruAgentId: string | null;
externalLoading?: boolean;
externalFreshRepoMode?: boolean;
onComplete: (result: ProfileSelectionResult) => void;
}) {
const [options, setOptions] = useState<ProfileOption[]>([]);
@@ -175,9 +177,11 @@ function ProfileSelectionUI({
});
const hasLocalDir = settingsManager.hasLocalLettaDir();
const contextMessage = hasLocalDir
? "Existing `.letta` folder detected."
: `${options.length} agent profile${options.length !== 1 ? "s" : ""} detected.`;
const contextMessage = externalFreshRepoMode
? `${options.length} pinned agent${options.length !== 1 ? "s" : ""} available.`
: hasLocalDir
? "Existing `.letta` folder detected."
: `${options.length} agent profile${options.length !== 1 ? "s" : ""} detected.`;
return (
<Box flexDirection="column">
@@ -202,7 +206,7 @@ function ProfileSelectionUI({
const isSelected = index === selectedIndex;
const displayName =
option.agent?.name || option.agentId.slice(0, 20);
const label = getLabel(option);
const label = getLabel(option, externalFreshRepoMode);
return (
<Box key={option.agentId} flexDirection="column">
@@ -290,12 +294,14 @@ function ProfileSelectionUI({
export function ProfileSelectionInline({
lruAgentId,
loading: externalLoading,
freshRepoMode,
onSelect,
onCreateNew,
onExit,
}: {
lruAgentId: string | null;
loading?: boolean;
freshRepoMode?: boolean;
onSelect: (agentId: string) => void;
onCreateNew: () => void;
onExit: () => void;
@@ -313,6 +319,7 @@ export function ProfileSelectionInline({
return React.createElement(ProfileSelectionUI, {
lruAgentId,
externalLoading,
externalFreshRepoMode: freshRepoMode,
onComplete: handleComplete,
});
}