LCOV - code coverage report
Current view: top level - src/platform/onboarding - onboardingOverlayStore.ts Coverage Total Hit
Test: ComfyUI E2E Coverage Lines: 30.8 % 13 4
Test Date: 2026-11-17 04:17:53

            Line data    Source code
       1              : import { defineStore } from 'pinia'
       2              : import { computed, getCurrentScope, onScopeDispose, shallowRef } from 'vue'
       3              : 
       4              : /**
       5              :  * Signals onboarding overlays that live outside the tour store (the agent
       6              :  * onboarding coach is the first), so the What's New popup can defer to them as
       7              :  * it already does to `activeTour`. A source registers a getter and drops it on
       8              :  * teardown, so an unmounted overlay cannot leak as permanently active.
       9              :  */
      10         2355 : export const useOnboardingOverlayStore = defineStore(
      11              :   'onboardingOverlay',
      12              :   () => {
      13         2353 :     const sources = shallowRef(new Set<() => boolean>())
      14              : 
      15         2353 :     const active = computed(() =>
      16              :       [...sources.value].some((isActive) => isActive())
      17              :     )
      18              : 
      19            0 :     function registerSource(isActive: () => boolean): () => void {
      20              :       // Wrap so each call owns a unique entry; two callers passing the same
      21              :       // getter reference must not collapse to one, or one stop() drops both.
      22            0 :       const source = () => isActive()
      23            0 :       sources.value = new Set(sources.value).add(source)
      24            0 :       const stop = () => {
      25            0 :         const next = new Set(sources.value)
      26            0 :         next.delete(source)
      27            0 :         sources.value = next
      28              :       }
      29              :       // Drop the source with the caller's scope, so a component consumer cannot
      30              :       // forget teardown and leak it. Direct callers outside a scope stop by hand.
      31            0 :       if (getCurrentScope()) onScopeDispose(stop)
      32            0 :       return stop
      33              :     }
      34              : 
      35         2353 :     return { active, registerSource }
      36              :   }
      37              : )
        

Generated by: LCOV version 2.0-1