From b21c9cb8a4805e75100fe1ac3693a2977933becc Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Fri, 12 Sep 2025 13:24:08 +0000 Subject: [PATCH] custom tag helper --- .../runs/NoWorkerWithTagWarning.svelte | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) 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}