diff --git a/frontend/src/lib/components/runs/NoWorkerWithTagWarning.svelte b/frontend/src/lib/components/runs/NoWorkerWithTagWarning.svelte index 330d084fb7..a44dbc763f 100644 --- a/frontend/src/lib/components/runs/NoWorkerWithTagWarning.svelte +++ b/frontend/src/lib/components/runs/NoWorkerWithTagWarning.svelte @@ -2,7 +2,7 @@ import { WorkerService } from '$lib/gen' import { AlertTriangle } from 'lucide-svelte' import Popover from '../Popover.svelte' - import { onDestroy } from 'svelte' + import { onDestroy, untrack } from 'svelte' interface Props { tag: string tagLabel?: string @@ -15,10 +15,21 @@ let timeout: number | undefined = undefined let visible = true + + let customTag = $derived.by(() => { + if (tag.includes('$workspace') || tag.includes('$args')) return + + if (tag.includes('(')) { + return tag.split('(')[0] + } + return tag + }) + async function lookForTag(): Promise { try { - const existsWorkerWithTag = await WorkerService.existsWorkersWithTags({ tags: tag }) - noWorkerWithTag = !existsWorkerWithTag[tag] + if (!customTag) return + const existsWorkerWithTag = await WorkerService.existsWorkersWithTags({ tags: customTag }) + noWorkerWithTag = !existsWorkerWithTag[customTag] if (noWorkerWithTag) { timeout = setTimeout(() => { if (visible) { @@ -31,7 +42,10 @@ } } - lookForTag() + $effect(() => { + customTag + untrack(() => lookForTag()) + }) onDestroy(() => { visible = false @@ -45,7 +59,7 @@ {#snippet text()} - No worker with {tagLabel ?? 'tag'} {tag} is currently running. + No worker with {tagLabel ?? 'tag'} {customTag} is currently running. {/snippet} {/if}