LCOV - code coverage report
Current view: top level - src/stores - workflowTabActivityStore.ts Coverage Total Hit
Test: ComfyUI E2E Coverage Lines: 78.3 % 23 18
Test Date: 2026-11-17 04:17:53

            Line data    Source code
       1              : import { defineStore } from 'pinia'
       2              : import { computed, ref, shallowRef } from 'vue'
       3              : 
       4              : export interface AgentTurnTab {
       5              :   path: string
       6              :   awaitingApproval: boolean
       7              : }
       8              : 
       9              : /**
      10              :  * Cross-feature workflow-tab activity, keyed by tab path. Feature extensions
      11              :  * (the agent panel) write it; the topbar reads it, so the topbar never has to
      12              :  * import feature internals.
      13              :  */
      14         2355 : export const useWorkflowTabActivityStore = defineStore(
      15              :   'workflowTabActivity',
      16              :   () => {
      17         2355 :     const agentTurnTabs = shallowRef<readonly AgentTurnTab[]>([])
      18         2355 :     const creatingTab = ref(false)
      19         2355 :     const unseenModifiedPaths = ref<Set<string>>(new Set())
      20              : 
      21         2355 :     const editingPaths = computed(
      22              :       () => new Set(agentTurnTabs.value.map(({ path }) => path))
      23              :     )
      24         2355 :     const awaitingApprovalPaths = computed(
      25              :       () =>
      26              :         new Set(
      27              :           agentTurnTabs.value.flatMap(({ path, awaitingApproval }) =>
      28              :             awaitingApproval ? [path] : []
      29              :           )
      30              :         )
      31              :     )
      32              : 
      33            1 :     function setAgentTurnTabs(tabs: readonly AgentTurnTab[]): void {
      34            1 :       agentTurnTabs.value = tabs
      35              :     }
      36              : 
      37            0 :     function setCreating(creating: boolean): void {
      38            0 :       creatingTab.value = creating
      39              :     }
      40              : 
      41            0 :     function markModified(path: string): void {
      42            0 :       unseenModifiedPaths.value.add(path)
      43              :     }
      44              : 
      45            2 :     function markSeen(path: string): void {
      46            2 :       unseenModifiedPaths.value.delete(path)
      47              :     }
      48              : 
      49            2 :     function pruneClosed(openPaths: string[]): void {
      50            2 :       const open = new Set(openPaths)
      51            2 :       for (const path of unseenModifiedPaths.value)
      52            0 :         if (!open.has(path)) unseenModifiedPaths.value.delete(path)
      53              :     }
      54              : 
      55         2355 :     function clearAgentActivity(): void {
      56         2355 :       agentTurnTabs.value = []
      57         2355 :       creatingTab.value = false
      58         2355 :       unseenModifiedPaths.value.clear()
      59              :     }
      60              : 
      61         2355 :     return {
      62              :       editingPaths,
      63              :       awaitingApprovalPaths,
      64              :       creatingTab,
      65              :       unseenModifiedPaths,
      66              :       setAgentTurnTabs,
      67              :       setCreating,
      68              :       markModified,
      69              :       markSeen,
      70              :       pruneClosed,
      71              :       clearAgentActivity
      72              :     }
      73              :   }
      74              : )
        

Generated by: LCOV version 2.0-1