Merge welcome dismissal while preserving continuous conversation entry
This commit is contained in:
@@ -286,6 +286,13 @@ export function useTeacherCompanion(options: Options) {
|
||||
return () => { alive = false; window.clearInterval(timer); window.removeEventListener('focus', refresh); };
|
||||
}, [account, state.agents]);
|
||||
|
||||
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;
|
||||
@@ -315,7 +322,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 {
|
||||
unreadAgentIds,
|
||||
|
||||
Reference in New Issue
Block a user