@@ -2,8 +2,8 @@ import { createMemo, type Accessor } from "solid-js"
22import { useGlobal } from "@/context/global"
33import { useNotification } from "@/context/notification"
44import { usePermission } from "@/context/permission"
5+ import { sessionPermissionRequest , sessionQuestionRequest } from "@/pages/session/composer/session-request-tree"
56import { ServerConnection } from "@/context/server"
6- import { sessionPermissionRequest } from "@/pages/session/composer/session-request-tree"
77
88export function useSessionTabAvatarState (
99 server : Accessor < ServerConnection . Key > ,
@@ -26,15 +26,20 @@ export function useSessionTabAvatarState(
2626 return ! permission . autoResponds ( item , directory ( ) )
2727 } )
2828 } )
29- const unread = createMemo ( ( ) => {
30- if ( hasPermissions ( ) ) return true
31- if ( ! connection ( ) ) return false
32- return notification . ensureServerState ( server ( ) ) . session . unseenCount ( sessionId ( ) ) > 0
29+ const hasQuestions = createMemo ( ( ) => {
30+ const serverSync = sync ( )
31+ if ( ! serverSync ) return false
32+ const [ store ] = serverSync . child ( directory ( ) , { bootstrap : false } )
33+ return ! ! sessionQuestionRequest ( store . session , serverSync . session . data . question , sessionId ( ) )
3334 } )
35+ const needsAttention = createMemo ( ( ) => hasPermissions ( ) || hasQuestions ( ) )
36+ const unread = createMemo (
37+ ( ) => needsAttention ( ) || notification . ensureServerState ( server ( ) ) . session . unseenCount ( sessionId ( ) ) > 0 ,
38+ )
3439 const loading = createMemo ( ( ) => {
3540 const serverSync = sync ( )
3641 if ( ! serverSync ) return false
37- if ( hasPermissions ( ) ) return false
42+ if ( needsAttention ( ) ) return false
3843 return serverSync . session . data . session_working ( sessionId ( ) )
3944 } )
4045 return { unread, loading }
0 commit comments