feat: use conversations endpoint for default conversation (#1206)
This commit is contained in:
@@ -5690,10 +5690,11 @@ export default function App({
|
||||
// causing CONFLICT on the next user message.
|
||||
getClient()
|
||||
.then((client) => {
|
||||
if (conversationIdRef.current === "default") {
|
||||
return client.agents.messages.cancel(agentIdRef.current);
|
||||
}
|
||||
return client.conversations.cancel(conversationIdRef.current);
|
||||
const cancelId =
|
||||
conversationIdRef.current === "default"
|
||||
? agentIdRef.current
|
||||
: conversationIdRef.current;
|
||||
return client.conversations.cancel(cancelId);
|
||||
})
|
||||
.catch(() => {
|
||||
// Silently ignore - cancellation already happened client-side
|
||||
@@ -5808,11 +5809,11 @@ export default function App({
|
||||
// Don't wait for it or show errors since user already got feedback
|
||||
getClient()
|
||||
.then((client) => {
|
||||
// Use agents API for "default" conversation (primary message history)
|
||||
if (conversationIdRef.current === "default") {
|
||||
return client.agents.messages.cancel(agentIdRef.current);
|
||||
}
|
||||
return client.conversations.cancel(conversationIdRef.current);
|
||||
const cancelId =
|
||||
conversationIdRef.current === "default"
|
||||
? agentIdRef.current
|
||||
: conversationIdRef.current;
|
||||
return client.conversations.cancel(cancelId);
|
||||
})
|
||||
.catch(() => {
|
||||
// Silently ignore - cancellation already happened client-side
|
||||
@@ -5832,12 +5833,11 @@ export default function App({
|
||||
setInterruptRequested(true);
|
||||
try {
|
||||
const client = await getClient();
|
||||
// Use agents API for "default" conversation (primary message history)
|
||||
if (conversationIdRef.current === "default") {
|
||||
await client.agents.messages.cancel(agentIdRef.current);
|
||||
} else {
|
||||
await client.conversations.cancel(conversationIdRef.current);
|
||||
}
|
||||
const cancelId =
|
||||
conversationIdRef.current === "default"
|
||||
? agentIdRef.current
|
||||
: conversationIdRef.current;
|
||||
await client.conversations.cancel(cancelId);
|
||||
|
||||
if (abortControllerRef.current) {
|
||||
abortControllerRef.current.abort();
|
||||
@@ -7886,15 +7886,14 @@ export default function App({
|
||||
}
|
||||
: undefined;
|
||||
|
||||
// Use agent-level compact API for "default" conversation,
|
||||
// otherwise use conversation-level API
|
||||
const result =
|
||||
const compactId =
|
||||
conversationIdRef.current === "default"
|
||||
? await client.agents.messages.compact(agentId, compactParams)
|
||||
: await client.conversations.messages.compact(
|
||||
conversationIdRef.current,
|
||||
compactParams,
|
||||
);
|
||||
? agentId
|
||||
: conversationIdRef.current;
|
||||
const result = await client.conversations.messages.compact(
|
||||
compactId,
|
||||
compactParams,
|
||||
);
|
||||
|
||||
// Format success message with before/after counts and summary
|
||||
const outputLines = [
|
||||
|
||||
@@ -242,12 +242,14 @@ export function ConversationSelector({
|
||||
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;
|
||||
const defaultMessages = await client.conversations.messages.list(
|
||||
agentId,
|
||||
{
|
||||
limit: 20,
|
||||
order: "desc",
|
||||
},
|
||||
);
|
||||
const defaultMsgItems = defaultMessages.getPaginatedItems();
|
||||
if (defaultMsgItems.length > 0) {
|
||||
const defaultStats = getMessageStats(
|
||||
[...defaultMsgItems].reverse(),
|
||||
|
||||
@@ -159,14 +159,14 @@ export async function runMessagesSubcommand(argv: string[]): Promise<number> {
|
||||
return 1;
|
||||
}
|
||||
|
||||
const response = await client.agents.messages.list(agentId, {
|
||||
const response = await client.conversations.messages.list(agentId, {
|
||||
limit: parseLimit(parsed.values.limit, 20),
|
||||
after: parsed.values.after,
|
||||
before: parsed.values.before,
|
||||
order,
|
||||
});
|
||||
|
||||
const messages = response.items ?? [];
|
||||
const messages = response.getPaginatedItems() ?? [];
|
||||
const startDate = parsed.values["start-date"];
|
||||
const endDate = parsed.values["end-date"];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user