diff --git a/apps/mana/apps/web/src/lib/components/workbench/scenes/SceneHeader.svelte b/apps/mana/apps/web/src/lib/components/workbench/scenes/SceneHeader.svelte index 1b9120ae3..fb49dcd86 100644 --- a/apps/mana/apps/web/src/lib/components/workbench/scenes/SceneHeader.svelte +++ b/apps/mana/apps/web/src/lib/components/workbench/scenes/SceneHeader.svelte @@ -12,12 +12,40 @@ import { workbenchScenesStore } from '$lib/stores/workbench-scenes.svelte'; import { Sparkle } from '@mana/shared-icons'; import { goto } from '$app/navigation'; + import { TagSelector, type Tag } from '@mana/shared-ui'; + import { useAllTags } from '@mana/shared-stores'; + import { useAgents } from '$lib/data/ai/agents/queries'; interface Props { scene: WorkbenchScene | null; } const { scene }: Props = $props(); + const allTags = $derived(useAllTags()); + const agents = $derived(useAgents()); + + // Auto-infer scopeTagIds from bound agent if scene has no explicit override + const effectiveScopeTagIds = $derived.by(() => { + if (!scene) return []; + if (scene.scopeTagIds?.length) return scene.scopeTagIds; + if (scene.viewingAsAgentId) { + const agent = agents.value.find((a) => a.id === scene.viewingAsAgentId); + return agent?.scopeTagIds ?? []; + } + return []; + }); + + const selectedScopeTags = $derived( + allTags.value.filter((t) => effectiveScopeTagIds.includes(t.id)) + ); + + async function handleScopeChange(tags: Tag[]) { + if (!scene) return; + const ids = tags.map((t) => t.id); + await workbenchScenesStore.updateScene(scene.id, { + scopeTagIds: ids.length > 0 ? ids : undefined, + }); + } // The seeded default scene is called "Home". Its empty-description // placeholder gets a welcoming line instead of the generic prompt. @@ -131,6 +159,20 @@ onblur={(e) => commitDescription(e.currentTarget, scene.description ?? '')} >

+ +
+ 0 ? '' : 'Bereiche filtern…'} + addTagLabel="Bereich hinzufügen" + /> + {#if !scene.scopeTagIds?.length && scene.viewingAsAgentId && effectiveScopeTagIds.length > 0} + via Agent + {/if} +
+