Files
ComfyUI_frontend/src/composables/useNewMenuItemIndicator.ts
pythongosssss b18a0713db feat: App mode enter builder menu item (#9341)
## Summary

Adds enter builder menu item for easier access to app builder. 
Fixes issues with seen item tracking

## Changes

- **What**: 
- add enter builder menu item
- change non visible items to still be returned as part of the array, so
they are not incorrectly removed from the seen-items tracking
- split toggle-app-mode into two stable items

## Screenshots (if applicable)

<img width="309" height="526" alt="image"
src="https://github.com/user-attachments/assets/69affc2c-34ab-45eb-b47b-efacb8a20b99"
/>

┆Issue is synchronized with this [Notion
page](https://www.notion.so/PR-9341-feat-App-mode-enter-builder-menu-item-3176d73d365081a9a7e7cf1a1986354f)
by [Unito](https://www.unito.io)
2026-03-03 08:35:47 -08:00

55 lines
1.5 KiB
TypeScript

import type { MaybeRefOrGetter } from 'vue'
import { computed, toValue } from 'vue'
import { useSettingStore } from '@/platform/settings/settingStore'
import type {
WorkflowMenuAction,
WorkflowMenuItem
} from '@/types/workflowMenuItem'
function getNewActions(items: WorkflowMenuItem[]): WorkflowMenuAction[] {
return items
.filter((i): i is WorkflowMenuAction => !('separator' in i && i.separator))
.filter((i) => i.isNew)
}
export function useNewMenuItemIndicator(
menuItems: MaybeRefOrGetter<WorkflowMenuItem[]>
) {
const settingStore = useSettingStore()
const newActions = computed(() => getNewActions(toValue(menuItems)))
const seenItems = computed<string[]>(
() => settingStore.get('Comfy.WorkflowActions.SeenItems') ?? []
)
const hasUnseenItems = computed(() => {
const seen = new Set(seenItems.value)
return newActions.value
.filter((i) => i.visible !== false)
.some((i) => !seen.has(i.id))
})
function markAsSeen() {
const actions = newActions.value
if (!actions.length) return
const seen = new Set(seenItems.value)
const visibleIds = actions
.filter((i) => i.visible !== false)
.map((i) => i.id)
const retainedIds = actions
.filter((i) => i.visible === false && seen.has(i.id))
.map((i) => i.id)
const nextSeen = [...visibleIds, ...retainedIds]
if (nextSeen.length === seen.size && nextSeen.every((id) => seen.has(id)))
return
void settingStore.set('Comfy.WorkflowActions.SeenItems', nextSeen)
}
return { hasUnseenItems, markAsSeen }
}