feat(teacher): show a subtle hint action in the empty composer
This commit is contained in:
@@ -19,6 +19,8 @@ if (scenario === 'rich-text') {
|
||||
}];
|
||||
}
|
||||
let timer: ReturnType<typeof setTimeout> | undefined;
|
||||
const sentInputs: TeacherSend[] = [];
|
||||
Object.defineProperty(window, '__teacherReplyInputs', { value: sentInputs });
|
||||
const snapshot = () => { current.revision++; stream.dispatchEvent(new MessageEvent('snapshot', { data: JSON.stringify(current) })); };
|
||||
export const teacherApi = {
|
||||
catalog: async () => ({ items: [{ teacher_id: definition.teacher_id, version: 1, is_default: true, definition }] }),
|
||||
@@ -29,12 +31,14 @@ export const teacherApi = {
|
||||
events: async () => stream,
|
||||
send: async (_base: string, _id: string, input: TeacherSend) => {
|
||||
if ('presentation' in input || 'discussion' in input) throw new Error('Retired component fields must not be sent');
|
||||
current.requests.push({ id: input.requestId, text: input.text, references: [], createdAt: 'now', status: 'running', sourceCursor: { workerGeneration: 0, seq: 1 }, sourceCapturedAt: 'now', includedSourceMessageIds: [], omittedMessages: 0, response: '', presentation: 'reply-v1' });
|
||||
sentInputs.push(structuredClone(input));
|
||||
current.requests.push({ id: input.requestId, text: input.text, intent: input.intent, references: [], createdAt: 'now', status: 'running', sourceCursor: { workerGeneration: 0, seq: 1 }, sourceCapturedAt: 'now', includedSourceMessageIds: [], omittedMessages: 0, response: '', presentation: 'reply-v1' });
|
||||
snapshot();
|
||||
timer = setTimeout(() => {
|
||||
const request = current.requests.at(-1)!;
|
||||
request.status = 'completed';
|
||||
request.response = '好,我们就从这一个问题聊起。';
|
||||
request.response = input.intent === 'suggestions' ? '我们可以先从一个小地方开始。' : '好,我们就从这一个问题聊起。';
|
||||
if (input.intent === 'suggestions') request.suggestedQuestions = ['可以从哪个小地方开始?'];
|
||||
snapshot();
|
||||
}, 350);
|
||||
return structuredClone(current);
|
||||
|
||||
Reference in New Issue
Block a user