fix: isolate delivered agent chats by project

This commit is contained in:
brother7 committed 2026-09-28 16:21:14 +08:00
1 parent a21a1f077c
commit 4b41c23a3a
15 files changed
+518 -165

No files matched your search

+9 -6
View File
@@ -20,6 +20,9 @@ export function teacherTopicsPath(projectId: string) {
? '/api/coding/teacher-preview/topics'
: `/api/coding/projects/${encodeURIComponent(projectId)}/agent-topics`;
}
export function teacherConversationsPath(projectId: string) {
return `/api/coding/projects/${encodeURIComponent(projectId)}/agent-conversations`;
}
/** Read old locally-generated friend histories without copying or rebinding them. */
export function legacyTopicBase(base: string, legacyFriend: boolean) {
return legacyFriend ? base.replace(/agent-topics$/, 'friend-topics') : base;
@@ -28,12 +31,12 @@ export const teacherApi = {
legacyHistory: (projectId: string) => hostApiFetch<TeacherTopicList>(`/api/coding/projects/${encodeURIComponent(projectId)}/agent-history`),
legacyRead: (projectId: string, item: TeacherTopicList['items'][number]) => hostApiFetch<TeacherTopic>(
`/api/coding/projects/${encodeURIComponent(projectId)}/agent-history/${encodeURIComponent(item.id)}?source=${encodeURIComponent(item.legacySourceId ?? 'project')}&friend=${item.legacyRole === 'friend'}`),
seenConversation: (agentId: string, requestId: string) => hostApiFetch<TeacherTopic>(
'/api/coding/agent-conversations/' + encodeURIComponent(agentId) + '/seen', { method: 'POST', body: JSON.stringify({ requestId }) }),
conversation: (agentId: string, before?: string) => hostApiFetch<TeacherConversationView>(
'/api/coding/agent-conversations/' + encodeURIComponent(agentId) + (before ? '?before=' + encodeURIComponent(before) : '')),
sendConversation: (agentId: string, input: TeacherSend) => hostApiFetch<TeacherTopic>(
'/api/coding/agent-conversations/' + encodeURIComponent(agentId) + '/messages', { method: 'POST', body: JSON.stringify(input) }),
seenConversation: (projectId: string, agentId: string, requestId: string) => hostApiFetch<TeacherTopic>(
teacherConversationsPath(projectId) + '/' + encodeURIComponent(agentId) + '/seen', { method: 'POST', body: JSON.stringify({ requestId }) }),
conversation: (projectId: string, agentId: string, before?: string) => hostApiFetch<TeacherConversationView>(
teacherConversationsPath(projectId) + '/' + encodeURIComponent(agentId) + (before ? '?before=' + encodeURIComponent(before) : '')),
sendConversation: (projectId: string, agentId: string, input: TeacherSend) => hostApiFetch<TeacherTopic>(
teacherConversationsPath(projectId) + '/' + encodeURIComponent(agentId) + '/messages', { method: 'POST', body: JSON.stringify(input) }),
catalog: () => hostApiFetch<TeacherCatalog>('/api/coding/teacher/teachers'),
checkIn: (projectId: string, input: TeacherCheckInInput) =>
hostApiFetch<TeacherCheckInResult>(`/api/coding/projects/${encodeURIComponent(projectId)}/teacher-check-in`, {