feat: add support for default conversation via --conv default (#580)

Co-authored-by: Letta <noreply@letta.com>
This commit is contained in:
Charles Packer
2026-01-17 20:06:36 -08:00
committed by GitHub
parent 5f5c0df18e
commit f2b242cdc5
7 changed files with 256 additions and 68 deletions

View File

@@ -79,7 +79,7 @@ export const AgentInfoBar = memo(function AgentInfoBar({
<Text dimColor>{" "}</Text>
{isCloudUser && (
<Link
url={`https://app.letta.com/agents/${agentId}${conversationId ? `?conversation=${conversationId}` : ""}`}
url={`https://app.letta.com/agents/${agentId}${conversationId && conversationId !== "default" ? `?conversation=${conversationId}` : ""}`}
>
<Text>Open in ADE </Text>
</Link>

View File

@@ -224,6 +224,37 @@ export function ConversationSelector({
const client = clientRef.current || (await getClient());
clientRef.current = client;
// Fetch default conversation data (agent's primary message history)
// Only fetch on initial load (not when paginating)
let defaultConversation: EnrichedConversation | null = null;
if (!afterCursor) {
try {
const defaultMessages = await client.agents.messages.list(agentId, {
limit: 20,
order: "desc",
conversation_id: "default", // Filter to default conversation only
});
const defaultMsgItems = defaultMessages.items;
if (defaultMsgItems.length > 0) {
const defaultStats = getMessageStats(
[...defaultMsgItems].reverse(),
);
defaultConversation = {
conversation: {
id: "default",
agent_id: agentId,
created_at: new Date().toISOString(),
} as Conversation,
previewLines: defaultStats.previewLines,
lastActiveAt: defaultStats.lastActiveAt,
messageCount: defaultStats.messageCount,
};
}
} catch {
// If we can't fetch default messages, just skip showing it
}
}
const result = await client.conversations.list({
agent_id: agentId,
limit: FETCH_PAGE_SIZE,
@@ -276,7 +307,11 @@ export function ConversationSelector({
if (isLoadingMore) {
setConversations((prev) => [...prev, ...nonEmptyConversations]);
} else {
setConversations(nonEmptyConversations);
// Prepend default conversation to the list (if it has messages)
const allConversations = defaultConversation
? [defaultConversation, ...nonEmptyConversations]
: nonEmptyConversations;
setConversations(allConversations);
setPage(0);
setSelectedIndex(0);
}
@@ -448,6 +483,8 @@ export function ConversationSelector({
);
};
const isDefault = conv.id === "default";
return (
<Box key={conv.id} flexDirection="column" marginBottom={1}>
<Box flexDirection="row">
@@ -461,8 +498,9 @@ export function ConversationSelector({
bold={isSelected}
color={isSelected ? colors.selector.itemHighlighted : undefined}
>
{conv.id}
{isDefault ? "default" : conv.id}
</Text>
{isDefault && <Text dimColor> (agent's default conversation)</Text>}
{isCurrent && (
<Text color={colors.selector.itemCurrent}> (current)</Text>
)}