feat: add timestamp and forking

This commit is contained in:
Zoe
2026-07-15 15:49:38 -05:00
parent 8ccaa824dd
commit 886f385835
7 changed files with 308 additions and 79 deletions
+32
View File
@@ -198,11 +198,43 @@ export const useAgents = async () => {
});
}
const forkTopic = async (topicId: string, messageId: string): Promise<string | null> => {
try {
const result = await $fetch<{ ok: boolean; topicId: string; name: string }>(`/api/topic/${topicId}/fork`, {
method: 'POST',
body: { messageId },
});
if (result.ok) {
const agent = agents.value.find(a => a.topics.some(t => t.id === topicId));
if (agent) {
const newTopic: Topic = {
id: result.topicId,
name: result.name,
agentId: agent.id,
userId: agent.userId,
renaming: false,
createdAt: new Date(),
};
agents.value = agents.value.map(a =>
a.id === agent.id ? { ...a, topics: [newTopic, ...a.topics] } as AgentWithTopics : a
);
}
return result.topicId;
}
return null;
} catch (error) {
console.error('Failed to fork topic:', error);
return null;
}
};
return {
agents,
refresh,
createAgent,
createTopic,
forkTopic,
getAgent,
patchAgentLocally,
patchTopicLocally,