Files
ComfyUI_frontend/src/composables/useNewMenuItemIndicator.ts
pythongosssss 0ab3fdc2c9 Add indicator circle when new unseen menu items are available (#9220)
## Summary

Adds a little indicator circle when new workflow menu items are added
that the user has not seen

## Changes

- **What**: Adds a hidden setting to track menu items flagged as new
that have been seen

## Screenshots (if applicable)

<img width="164" height="120" alt="image"
src="https://github.com/user-attachments/assets/ac36673d-fbf1-42ff-9a9e-1371eb96115b"
/>

┆Issue is synchronized with this [Notion
page](https://www.notion.so/PR-9220-Add-indicator-circle-when-new-unseen-menu-items-are-available-3126d73d3650819cb8cde854d6b6510b)
by [Unito](https://www.unito.io)
2026-02-28 12:53:26 -08:00

42 lines
1.1 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 getNewItemIds(items: WorkflowMenuItem[]): string[] {
return items
.filter((i): i is WorkflowMenuAction => !('separator' in i && i.separator))
.filter((i) => i.isNew)
.map((i) => i.id)
}
export function useNewMenuItemIndicator(
menuItems: MaybeRefOrGetter<WorkflowMenuItem[]>
) {
const settingStore = useSettingStore()
const newItemIds = computed(() => getNewItemIds(toValue(menuItems)))
const seenItems = computed<string[]>(
() => settingStore.get('Comfy.WorkflowActions.SeenItems') ?? []
)
const hasUnseenItems = computed(() => {
const seen = new Set(seenItems.value)
return newItemIds.value.some((id) => !seen.has(id))
})
function markAsSeen() {
if (!newItemIds.value.length) return
void settingStore.set('Comfy.WorkflowActions.SeenItems', [
...newItemIds.value
])
}
return { hasUnseenItems, markAsSeen }
}