feat: integrate pixel teacher presence and resilient classroom preview

This commit is contained in:
鲨鱼辣椒
2026-09-23 18:23:53 +08:00
parent 12d800ec51
commit 7951cca700
60 changed files with 3313 additions and 180 deletions

View File

@@ -2,6 +2,8 @@ import { hostApiFetch, createHostEventSource, ensureHostApiToken } from './host-
import type {
ConsultationRole,
TeacherAvailability,
TeacherCheckInInput,
TeacherCheckInResult,
TeacherDefinition,
TeacherSend,
TeacherTopic,
@@ -14,6 +16,11 @@ export function teacherTopicsPath(projectId: string, sourceId: string, role?: Co
: `/api/coding/projects/${encodeURIComponent(projectId)}/conversations/${encodeURIComponent(sourceId)}/teacher-topics`;
}
export const teacherApi = {
checkIn: (projectId: string, input: TeacherCheckInInput) =>
hostApiFetch<TeacherCheckInResult>(`/api/coding/projects/${encodeURIComponent(projectId)}/teacher-check-in`, {
method: 'POST',
body: JSON.stringify(input),
}),
config: (role: ConsultationRole = 'teacher') =>
hostApiFetch<TeacherAvailability & { definition: TeacherDefinition | null }>(
`/api/coding/${role}/config`
@@ -28,8 +35,8 @@ export const teacherApi = {
method: 'POST',
body: JSON.stringify({ draftRevision, sampleContext }),
}),
read: (base: string, id: string) =>
hostApiFetch<TeacherTopic>(base + '/' + encodeURIComponent(id)),
read: (base: string, id: string, select = true) =>
hostApiFetch<TeacherTopic>(base + '/' + encodeURIComponent(id) + (select ? '' : '?select=false')),
send: (base: string, id: string, input: TeacherSend) =>
hostApiFetch<TeacherTopic>(base + '/' + encodeURIComponent(id) + '/messages', {
method: 'POST',