fix: resume project-specific conversation on bare letta startup (#1457)
Co-authored-by: Letta Code <noreply@letta.com>
This commit is contained in:
26
src/index.ts
26
src/index.ts
@@ -66,7 +66,7 @@ Letta Code is a general purpose CLI for interacting with Letta agents
|
|||||||
|
|
||||||
USAGE
|
USAGE
|
||||||
# interactive TUI
|
# interactive TUI
|
||||||
letta Resume default conversation (OG single-threaded experience)
|
letta Resume last conversation for this project
|
||||||
letta --new Create a new conversation (for concurrent sessions)
|
letta --new Create a new conversation (for concurrent sessions)
|
||||||
letta --continue Resume last session (agent + conversation) directly
|
letta --continue Resume last session (agent + conversation) directly
|
||||||
letta --resume Open agent selector UI to pick agent/conversation
|
letta --resume Open agent selector UI to pick agent/conversation
|
||||||
@@ -1374,9 +1374,10 @@ async function main(): Promise<void> {
|
|||||||
const { resolveStartupTarget } = await import(
|
const { resolveStartupTarget } = await import(
|
||||||
"./agent/resolve-startup-agent"
|
"./agent/resolve-startup-agent"
|
||||||
);
|
);
|
||||||
|
const localSession = settingsManager.getLocalLastSession(process.cwd());
|
||||||
const target = resolveStartupTarget({
|
const target = resolveStartupTarget({
|
||||||
localAgentId,
|
localAgentId,
|
||||||
localConversationId: null, // DEFAULT PATH always uses default conv
|
localConversationId: localSession?.conversationId ?? null,
|
||||||
localAgentExists,
|
localAgentExists,
|
||||||
globalAgentId,
|
globalAgentId,
|
||||||
globalAgentExists,
|
globalAgentExists,
|
||||||
@@ -1391,8 +1392,9 @@ async function main(): Promise<void> {
|
|||||||
if (cachedAgent && cachedAgent.id === target.agentId) {
|
if (cachedAgent && cachedAgent.id === target.agentId) {
|
||||||
setValidatedAgent(cachedAgent);
|
setValidatedAgent(cachedAgent);
|
||||||
}
|
}
|
||||||
// Don't set selectedConversationId — DEFAULT PATH uses default conv.
|
if (target.conversationId && !forceNewConversation) {
|
||||||
// Conversation restoration is handled by --continue path instead.
|
setSelectedConversationId(target.conversationId);
|
||||||
|
}
|
||||||
setLoadingState("assembling");
|
setLoadingState("assembling");
|
||||||
return;
|
return;
|
||||||
case "select":
|
case "select":
|
||||||
@@ -1918,7 +1920,7 @@ async function main(): Promise<void> {
|
|||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
} else if (selectedConversationId) {
|
} else if (selectedConversationId) {
|
||||||
// User selected a specific conversation from the --resume selector
|
// Conversation selected from --resume selector or auto-restored from local project settings
|
||||||
try {
|
try {
|
||||||
setLoadingState("checking");
|
setLoadingState("checking");
|
||||||
const data = await getResumeData(
|
const data = await getResumeData(
|
||||||
@@ -1934,10 +1936,18 @@ async function main(): Promise<void> {
|
|||||||
error instanceof APIError &&
|
error instanceof APIError &&
|
||||||
(error.status === 404 || error.status === 422)
|
(error.status === 404 || error.status === 422)
|
||||||
) {
|
) {
|
||||||
console.error(`Conversation ${selectedConversationId} not found`);
|
// Conversation no longer exists — fall back to default conversation
|
||||||
process.exit(1);
|
console.warn(
|
||||||
|
`Previous conversation ${selectedConversationId} not found, falling back to default`,
|
||||||
|
);
|
||||||
|
conversationIdToUse = "default";
|
||||||
|
setLoadingState("checking");
|
||||||
|
const data = await getResumeData(client, agent, "default");
|
||||||
|
setResumeData(data);
|
||||||
|
setResumedExistingConversation(data.messageHistory.length > 0);
|
||||||
|
} else {
|
||||||
|
throw error;
|
||||||
}
|
}
|
||||||
throw error;
|
|
||||||
}
|
}
|
||||||
} else if (forceNewConversation) {
|
} else if (forceNewConversation) {
|
||||||
// --new flag: create a new conversation (for concurrent sessions)
|
// --new flag: create a new conversation (for concurrent sessions)
|
||||||
|
|||||||
Reference in New Issue
Block a user