fix: dismiss teacher welcome on consultation entry

This commit is contained in:
鲨鱼辣椒
2026-09-28 16:08:29 +08:00
parent 4495345fb0
commit c96bb45d09
5 changed files with 167 additions and 2 deletions

View File

@@ -234,6 +234,13 @@ export function useTeacherCompanion(options: Options) {
};
}, [account, options.projectId, scope, storageKey, noteTopic]);
useEffect(() => {
if (!options.teacherOpen || !options.projectId) return;
// Entering consultation consumes the greeting, but leaves real invitations unread.
writeLocal(storageKey + ':welcome-dismissed', true);
setState((current) => current.welcomeDismissed ? current : { ...current, welcomeDismissed: true });
}, [options.teacherOpen, options.projectId, storageKey]);
const topic = stateScope.current === scope ? state.topic : null;
const topicId = topic?.id;
const topicProjectId = topic?.projectId;
@@ -262,7 +269,7 @@ export function useTeacherCompanion(options: Options) {
const selectedAgentId = visibleState.selectedAgent?.teacher_id ?? selectedDefinition?.config_id;
const selectedAgent = visibleState.selectedAgent === null ? undefined
: visibleState.agents.find((item) => item.teacher_id === selectedAgentId) ?? visibleState.selectedAgent;
const welcome = topic?.role !== 'friend' && !visibleState.loading && visibleState.enabled && !visibleState.welcomeDismissed
const welcome = topic?.role !== 'friend' && !options.teacherOpen && !visibleState.loading && visibleState.enabled && !visibleState.welcomeDismissed
? selectedDefinition?.welcome_message.trim() || null : null;
return {
...visibleState,