Automate browser based workflows with AI
Python aiapiautomationbrowserbrowser-automationcomputergptllmplaywrightpowerautomatepuppeteerpythonrpaseleniumvisionworkflow
feat(SKY-11144): color grouped workflow tags with a curated palette (#6801)
Aaron Perez838bb19bf400
diff --git a/skyvern-frontend/src/routes/workflows/WorkflowPage.test.tsx b/skyvern-frontend/src/routes/workflows/WorkflowPage.test.tsxindex 1a355b0cb..98e8f0b2b 100644--- a/skyvern-frontend/src/routes/workflows/WorkflowPage.test.tsx+++ b/skyvern-frontend/src/routes/workflows/WorkflowPage.test.tsx@@ -72,6 +72,10 @@ vi.mock("./hooks/useTagKeysQuery", () => ({useTagKeysQuery: () => ({ data: [] }),}));+vi.mock("./hooks/useTagValuesQuery", () => ({+ useTagValuesQuery: () => ({ data: new Map() }),+}));+vi.mock("./hooks/useKeywordSearch", () => ({useKeywordSearch: () => ({matchesParameter: () => false,diff --git a/skyvern-frontend/src/routes/workflows/WorkflowPage.tsx b/skyvern-frontend/src/routes/workflows/WorkflowPage.tsxindex 7ae43c0fb..58402039e 100644--- a/skyvern-frontend/src/routes/workflows/WorkflowPage.tsx+++ b/skyvern-frontend/src/routes/workflows/WorkflowPage.tsx@@ -54,6 +54,7 @@ import {import { useWorkflowQuery } from "./hooks/useWorkflowQuery";import { useWorkflowRunsQuery } from "./hooks/useWorkflowRunsQuery";import { useTagKeysQuery } from "./hooks/useTagKeysQuery";+import { useTagValuesQuery } from "./hooks/useTagValuesQuery";import { useWorkflowTagsBatchQuery } from "./hooks/useWorkflowTagsBatchQuery";import { TagChipList } from "./components/tagging/TagChipList";import { WorkflowActions } from "./WorkflowActions";@@ -155,6 +156,7 @@ function WorkflowPage() {),[tagKeys],);+ const { data: tagColors } = useTagValuesQuery({ enabled: taggingEnabled });if (!workflowPermanentId) {return null; // this should never happen@@ -184,6 +186,7 @@ function WorkflowPage() {<TagChipListtags={workflowTags}descriptions={tagDescriptions}+ colors={tagColors}maxVisible={6}/>) : null}diff --git a/skyvern-frontend/src/routes/workflows/WorkflowsFlat.tsx b/skyvern-frontend/src/routes/workflows/WorkflowsFlat.tsxindex e1f91c13f..cf43a949b 100644--- a/skyvern-frontend/src/routes/workflows/WorkflowsFlat.tsx+++ b/skyvern-frontend/src/routes/workflows/WorkflowsFlat.tsx@@ -91,6 +91,7 @@ import { HighlightText } from "./components/HighlightText";import { useCreateWorkflowMutation } from "./hooks/useCreateWorkflowMutation";import { useFoldersQuery } from "./hooks/useFoldersQuery";import { useTagKeysQuery } from "./hooks/useTagKeysQuery";+import { useTagValuesQuery } from "./hooks/useTagValuesQuery";import { useWorkflowTagsBatchQuery } from "./hooks/useWorkflowTagsBatchQuery";import { useActiveImportsPolling } from "./hooks/useActiveImportsPolling";import { TagChipList } from "./components/tagging/TagChipList";@@ -416,6 +417,8 @@ function WorkflowsFlat() {),[tagKeys],);+ // (key, value) -> palette color for grouped tag chips.+ const { data: tagColors } = useTagValuesQuery({ enabled: taggingEnabled });// One batch fetch of current tags for every workflow on the page (no N+1).const workflowIds = useMemo(@@ -787,6 +790,7 @@ function WorkflowsFlat() {onChange={setTagFilters}labelSuggestions={labelSuggestions}valueSuggestionsByKey={valueSuggestionsByKey}+ colors={tagColors}/>) : null}</div>@@ -1038,6 +1042,7 @@ function WorkflowsFlat() {<TagChipListtags={workflowTags}descriptions={tagDescriptions}+ colors={tagColors}/>) : null}</div>@@ -1119,6 +1124,7 @@ function WorkflowsFlat() {valueSuggestionsByKey={valueSuggestionsByKey}+ colorMap={tagColors}/>) : null}</>diff --git a/skyvern-frontend/src/routes/workflows/WorkflowsTree.tsx b/skyvern-frontend/src/routes/workflows/WorkflowsTree.tsxindex d9c72c086..80dbb5d45 100644--- a/skyvern-frontend/src/routes/workflows/WorkflowsTree.tsx+++ b/skyvern-frontend/src/routes/workflows/WorkflowsTree.tsx@@ -69,6 +69,7 @@ import {import { useCreateWorkflowMutation } from "./hooks/useCreateWorkflowMutation";import { useInfiniteFoldersQuery } from "./hooks/useInfiniteFoldersQuery";import { useTagKeysQuery } from "./hooks/useTagKeysQuery";+import { useTagValuesQuery } from "./hooks/useTagValuesQuery";import { useWorkflowTagsBatchQuery } from "./hooks/useWorkflowTagsBatchQuery";import { useActiveImportsPolling } from "./hooks/useActiveImportsPolling";import { WorkflowTagFilter } from "./components/tagging/WorkflowTagFilter";@@ -373,6 +374,7 @@ function WorkflowsTree() {),[tagKeys],);+ const { data: tagColors } = useTagValuesQuery();// One batch fetch of current tags for every workflow on screen (no N+1) -// the main page list plus the contents of every expanded folder.@@ -687,6 +689,7 @@ function WorkflowsTree() {foldersMap,workflowTagsMap,tagDescriptions,+ tagColors,tagKeys,labelSuggestions,valueSuggestionsByKey,@@ -923,6 +926,7 @@ function WorkflowsTree() {onChange={setTagFilters}labelSuggestions={labelSuggestions}valueSuggestionsByKey={valueSuggestionsByKey}+ colors={tagColors}/></div><div className="flex items-center gap-4">diff --git a/skyvern-frontend/src/routes/workflows/components/tagging/TagChip.tsx b/skyvern-frontend/src/routes/workflows/components/tagging/TagChip.tsxindex 1cdb4d94d..0ef7c3aff 100644--- a/skyvern-frontend/src/routes/workflows/components/tagging/TagChip.tsx+++ b/skyvern-frontend/src/routes/workflows/components/tagging/TagChip.tsx@@ -7,19 +7,30 @@ import {} from "@/components/ui/tooltip";import { badgeVariants } from "@/components/ui/badge-variants";import { cn } from "@/util/utils";+import { paletteDotClass } from "../../types/tagColors";type Props = {// null = a standalone label (no group); rendered as just the value.tagKey: string | null;value: string;description?: string | null;+ // Palette color name for grouped tags. Ignored for standalone labels (which+ // stay neutral) and for names outside the curated palette.+ color?: string | null;onRemove?: () => void;className?: string;};// Generic single-tag chip: a styled span (not Badge div) so it can be a Radix// TooltipTrigger `asChild` target. Grouped shows `key: value`, standalone the value.-function TagChip({ tagKey, value, description, onRemove, className }: Props) {+function TagChip({+ tagKey,+ value,+ description,+ color,+ onRemove,+ className,+}: Props) {// Last line of defense against payload shape skew: a non-string child here// is React error #31, which unmounts the route through the error boundary.if (@@ -30,6 +41,9 @@ function TagChip({ tagKey, value, description, onRemove, className }: Props) {return null;}const label = tagKey === null ? value : `${tagKey}: ${value}`;+ // Only grouped tags with a curated palette color get a leading dot; standalone+ // labels and out-of-palette colors render no dot. The chip surface stays neutral.+ const dotClass = tagKey !== null ? paletteDotClass(color) : "";const chip = (<spanclassName={cn(@@ -38,6 +52,12 @@ function TagChip({ tagKey, value, description, onRemove, className }: Props) {className,)}>+ {dotClass ? (+ <span+ aria-hidden="true"+ className={cn("inline-block h-2 w-2 shrink-0 rounded-full", dotClass)}+ />+ ) : null}<span className="truncate">{tagKey !== null ? (<>diff --git a/skyvern-frontend/src/routes/workflows/components/tagging/TagChipList.shape.test.tsx b/skyvern-frontend/src/routes/workflows/components/tagging/TagChipList.shape.test.tsxindex 045abe872..7fd3ed4b7 100644--- a/skyvern-frontend/src/routes/workflows/components/tagging/TagChipList.shape.test.tsx+++ b/skyvern-frontend/src/routes/workflows/components/tagging/TagChipList.shape.test.tsx@@ -2,6 +2,7 @@import { cleanup, render, screen } from "@testing-library/react";import { afterEach, describe, expect, it, vi } from "vitest";import type { Tag } from "../../types/tagTypes";+import { buildTagColorMap } from "../../types/tagColors";import { TagChipList } from "./TagChipList";import { TagChip } from "./TagChip";@@ -44,3 +45,55 @@ describe("TagChip shape tolerance", () => {expect(warn).toHaveBeenCalledTimes(1);});});++describe("TagChip color", () => {+ it("renders a leading color dot for a grouped tag and keeps the surface neutral", () => {+ const { container } = render(+ <TagChip tagKey="env" value="prod" color="blue" />,+ );+ const chip = container.querySelector("span");+ expect(chip?.className).toContain("bg-badge-neutral");+ expect(chip?.className).not.toContain("bg-blue-100");+ const dot = container.querySelector(".rounded-full");+ expect(dot?.className).toContain("bg-blue-500");+ });++ it("renders no dot on a standalone label", () => {+ const { container } = render(+ <TagChip tagKey={null} value="prod" color="blue" />,+ );+ expect(container.querySelector(".rounded-full")).toBeNull();+ const chip = container.querySelector("span");+ expect(chip?.className).not.toContain("bg-blue-500");+ });++ it("renders no dot when the color is outside the palette", () => {+ const { container } = render(+ <TagChip tagKey="env" value="prod" color="chartreuse" />,+ );+ expect(container.querySelector(".rounded-full")).toBeNull();+ const chip = container.querySelector("span");+ expect(chip?.className).not.toContain("chartreuse");+ expect(chip?.className).toContain("bg-badge-neutral");+ });+});++describe("TagChipList colors", () => {+ it("shows a color dot on grouped chips and leaves labels neutral", () => {+ const colors = buildTagColorMap([+ { key: "env", value: "prod", color: "green" },+ ]);+ const { container } = render(+ <TagChipList+ tags={[+ { key: "env", value: "prod" },+ { key: null, value: "standalone" },+ ]}+ colors={colors}+ />,+ );+ const html = container.innerHTML;+ expect(html).toContain("bg-green-500");+ expect(screen.getByText("standalone")).toBeTruthy();+ });+});diff --git a/skyvern-frontend/src/routes/workflows/components/tagging/TagChipList.tsx b/skyvern-frontend/src/routes/workflows/components/tagging/TagChipList.tsxindex 643408f53..54b276e15 100644--- a/skyvern-frontend/src/routes/workflows/components/tagging/TagChipList.tsx+++ b/skyvern-frontend/src/routes/workflows/components/tagging/TagChipList.tsx@@ -12,6 +12,7 @@ import {tagElementKey,type Tag,} from "../../types/tagTypes";+import { tagColorFor, type TagColorMap } from "../../types/tagColors";import { TagChip } from "./TagChip";type Props = {@@ -19,13 +20,21 @@ type Props = {// Group (key) -> description. A Map (not a plain object) so user-controlled keys// can't hit Object prototype members (e.g. a key named "constructor").descriptions?: Map<string, string | null>;+ // (key, value) -> palette color for grouped tags. Standalone labels stay neutral.+ colors?: TagColorMap;maxVisible?: number;className?: string;};// Generic list of tag chips with a "+N" overflow affordance. Standalone labels// sort first, then grouped by key, for stable ordering across renders.-function TagChipList({ tags, descriptions, maxVisible = 3, className }: Props) {+function TagChipList({+ tags,+ descriptions,+ colors,+ maxVisible = 3,+ className,+}: Props) {// Re-validate at render time: callers feed this straight from API payloads,// and a shape skew here previously killed the whole route via React #31.const safeTags = normalizeWorkflowTags(tags);@@ -46,6 +55,7 @@ function TagChipList({ tags, descriptions, maxVisible = 3, className }: Props) {description={tag.key !== null ? descriptions?.get(tag.key) : undefined}+ color={tagColorFor(colors, tag.key, tag.value)}/>))}{hidden.length > 0 ? (diff --git a/skyvern-frontend/src/routes/workflows/components/tagging/TagColorSwatchPicker.tsx b/skyvern-frontend/src/routes/workflows/components/tagging/TagColorSwatchPicker.tsxnew file mode 100644index 000000000..d8f279070--- /dev/null+++ b/skyvern-frontend/src/routes/workflows/components/tagging/TagColorSwatchPicker.tsx@@ -0,0 +1,50 @@+import { CheckIcon } from "@radix-ui/react-icons";+import { cn } from "@/util/utils";+import {+ TAG_COLOR_PALETTE,+ paletteSwatchClass,+ type PaletteColorName,+} from "../../types/tagColors";++type Props = {+ value: PaletteColorName;+ onChange: (color: PaletteColorName) => void;+ className?: string;+};++// A row of palette swatches for choosing a grouped tag's color. The selected+// swatch shows a ring and a check.+function TagColorSwatchPicker({ value, onChange, className }: Props) {+ return (+ <div className={cn("flex flex-wrap gap-1.5", className)}>+ {TAG_COLOR_PALETTE.map((color) => {+ const selected = color === value;+ return (+ <button+ key={color}+ type="button"+ aria-label={color}+ aria-pressed={selected}+ title={color}+ onClick={() => onChange(color)}+ className={cn(+ "flex h-5 w-5 items-center justify-center rounded-full ring-offset-background transition-shadow focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",+ paletteSwatchClass(color),+ selected+ ? "ring-2 ring-ring ring-offset-2"+ : "hover:ring-2 hover:ring-ring/40 hover:ring-offset-1",+ )}+ >+ {selected ? (+ // Dark halo keeps the white check legible on the lightest swatches+ // (yellow/amber) as well as the dark ones.+ <CheckIcon className="h-3.5 w-3.5 text-white [filter:drop-shadow(0_0_1.5px_rgba(0,0,0,0.65))]" />+ ) : null}+ </button>+ );+ })}+ </div>+ );+}++export { TagColorSwatchPicker };diff --git a/skyvern-frontend/src/routes/workflows/components/tagging/TagFilterControl.tsx b/skyvern-frontend/src/routes/workflows/components/tagging/TagFilterControl.tsxindex 34d40fc29..74ffc7dc8 100644--- a/skyvern-frontend/src/routes/workflows/components/tagging/TagFilterControl.tsx+++ b/skyvern-frontend/src/routes/workflows/components/tagging/TagFilterControl.tsx@@ -31,6 +31,11 @@ import {type TagFilterTerm,type TagKey,} from "../../types/tagTypes";+import {+ paletteDotClass,+ tagColorFor,+ type TagColorMap,+} from "../../types/tagColors";type Props = {tagKeys: Array<TagKey>;@@ -51,6 +56,9 @@ type Props = {// literally (the analytics summary endpoint), where those broader forms// would silently return unfiltered/empty data.exactValuesOnly?: boolean;+ // (key, value) -> palette color; only exact group:value chips are colored.+ // Omit on surfaces that don't load colors (chips stay neutral).+ colors?: TagColorMap;};// Group identity used for display + dedupe: exact terms sharing a key OR@@ -81,6 +89,7 @@ function TagFilterControl({triggerLabel = "Tags",onDeleteKey,exactValuesOnly = false,+ colors,}: Props) {const [open, setOpen] = React.useState(false);const [query, setQuery] = React.useState("");@@ -245,6 +254,13 @@ function TagFilterControl({termGroupId(previous) !== termGroupId(term);const unknownKey =term.key !== null && !knownKeys.has(term.key);+ // Only exact group:value terms carry a color, shown as a leading+ // dot; the chip surface stays neutral. A warning border (unknown+ // group) is independent of the color dot.+ const dotClass =+ !unknownKey && term.value !== null+ ? paletteDotClass(tagColorFor(colors, term.key, term.value))+ : "";return (<React.Fragment key={termDedupeKey(term)}>{startsNewConjunct ? (@@ -264,6 +280,15 @@ function TagFilterControl({: undefined}>+ {dotClass ? (+ <span+ aria-hidden="true"+ className={cn(+ "inline-block h-2 w-2 shrink-0 rounded-full",+ dotClass,+ )}+ />+ ) : null}<span className="truncate">{termLabel(term)}</span><buttontype="button"diff --git a/skyvern-frontend/src/routes/workflows/components/tagging/WorkflowTagEditor.tsx b/skyvern-frontend/src/routes/workflows/components/tagging/WorkflowTagEditor.tsxindex d58972383..dbf6216d2 100644--- a/skyvern-frontend/src/routes/workflows/components/tagging/WorkflowTagEditor.tsx+++ b/skyvern-frontend/src/routes/workflows/components/tagging/WorkflowTagEditor.tsx@@ -35,7 +35,14 @@ import {type TagKey,} from "../../types/tagTypes";import { useApplyWorkflowTagsMutation } from "../../hooks/useWorkflowTagMutations";+import {+ randomPaletteColor,+ tagColorFor,+ type PaletteColorName,+ type TagColorMap,+} from "../../types/tagColors";import { TagChip } from "./TagChip";+import { TagColorSwatchPicker } from "./TagColorSwatchPicker";type Props = {workflowPermanentId: string;@@ -46,6 +53,9 @@ type Props = {labelSuggestions?: Array<string>;// Grouped values observed per key, suggested after typing `group:`.valueSuggestionsByKey?: Map<string, Array<string>>;+ // (key, value) -> palette color, to color existing chips and preselect the+ // swatch when re-adding an already-colored grouped tag.+ colorMap?: TagColorMap;};// Inline tag editor: type a bare `label` for a standalone tag or `group:label`@@ -56,10 +66,15 @@ function WorkflowTagEditor({tagKeys,labelSuggestions = [],valueSuggestionsByKey,+ colorMap,}: Props) {const [open, setOpen] = React.useState(false);const [query, setQuery] = React.useState("");const [error, setError] = React.useState<string | null>(null);+ // Default a new grouped tag to a random swatch (re-seeded after each add); the+ // user can override, or it syncs to the existing color when re-adding one.+ const [selectedColor, setSelectedColor] =+ React.useState<PaletteColorName>(randomPaletteColor);const applyMutation = useApplyWorkflowTagsMutation();const isPending = applyMutation.isPending;@@ -73,7 +88,7 @@ function WorkflowTagEditor({const sortedTags = React.useMemo(() => sortTags(tags), [tags]);- function addTag(tag: Tag) {+ function addTag(tag: Tag, color?: PaletteColorName) {// A write is in flight; ignore further adds so a quick double Enter/click// can't queue racing POSTs whose arrival order would decide the final tag.if (isPending) {@@ -106,12 +121,19 @@ function WorkflowTagEditor({applyMutation.mutate({workflowPermanentId,- data: { tags: [{ key: tag.key, value: tag.value }] },+ data: {+ tags: [{ key: tag.key, value: tag.value }],+ // Color is key-scoped and only applies to grouped tags.+ ...(tag.key !== null && color+ ? { colors: { [tag.key]: color } }+ : {}),+ },},{onSuccess: () => {setQuery("");setError(null);+ setSelectedColor(randomPaletteColor());if (isOverwrite && previousInGroup) {toast({title: "Tag overwritten",@@ -143,6 +165,19 @@ function WorkflowTagEditor({candidate !== null &&tags.some((t) => t.key === candidate.key && t.value === candidate.value);const showAdd = candidate !== null && !candidateExists;+ const isGroupedCandidate = candidate !== null && candidate.key !== null;++ // Re-adding an already-colored (key, value) should keep its color, so sync the+ // swatch to it; brand-new values keep the random/user-picked selection.+ const candidateExistingColor =+ candidate !== null+ ? tagColorFor(colorMap, candidate.key, candidate.value)+ : undefined;+ React.useEffect(() => {+ if (candidateExistingColor) {+ setSelectedColor(candidateExistingColor);+ }+ }, [candidateExistingColor]);// When the user has typed `group:partial`, suggest existing values for that// group; otherwise suggest groups (to start a grouped tag) and labels.@@ -199,6 +234,7 @@ function WorkflowTagEditor({key={tagElementKey(tag)}tagKey={tag.key}value={tag.value}+ color={tagColorFor(colorMap, tag.key, tag.value)}onRemove={() => removeTag(tag)}/>))}@@ -221,17 +257,34 @@ function WorkflowTagEditor({onKeyDown={(event) => {if (event.key === "Enter" && candidate && showAdd) {event.preventDefault();- addTag(candidate);+ addTag(+ candidate,+ isGroupedCandidate ? selectedColor : undefined,+ );}}}/>+ {showAdd && isGroupedCandidate ? (+ <div className="border-b px-3 py-2">+ <div className="mb-1.5 text-xs text-muted-foreground">Color</div>+ <TagColorSwatchPicker+ value={selectedColor}+ onChange={setSelectedColor}+ />+ </div>+ ) : null}<CommandList><CommandEmpty>Type a label or group:label.</CommandEmpty>{showAdd && candidate ? (<CommandGroup><CommandItemvalue={`__add__,${trimmedQuery}`}- onSelect={() => addTag(candidate)}+ onSelect={() =>+ addTag(+ candidate,+ isGroupedCandidate ? selectedColor : undefined,+ )+ }>{isPending ? (<ReloadIcon className="mr-2 h-4 w-4 animate-spin" />diff --git a/skyvern-frontend/src/routes/workflows/components/tagging/WorkflowTagFilter.tsx b/skyvern-frontend/src/routes/workflows/components/tagging/WorkflowTagFilter.tsxindex b5fdbc635..57fe01856 100644--- a/skyvern-frontend/src/routes/workflows/components/tagging/WorkflowTagFilter.tsx+++ b/skyvern-frontend/src/routes/workflows/components/tagging/WorkflowTagFilter.tsx@@ -10,6 +10,7 @@ import {DialogTitle,} from "@/components/ui/dialog";import { type TagFilterTerm, type TagKey } from "../../types/tagTypes";+import { type TagColorMap } from "../../types/tagColors";import { useDeleteTagKeyMutation } from "../../hooks/useWorkflowTagMutations";import { TagFilterControl } from "./TagFilterControl";@@ -21,6 +22,9 @@ type Props = {labelSuggestions?: Array<string>;// Grouped values observed per key (for exact suggestions after `group:`).valueSuggestionsByKey?: Map<string, Array<string>>;+ // (key, value) -> palette color; forwarded to the filter control to color+ // exact group:value chips.+ colors?: TagColorMap;};// Tag filter pill for the workflows list. Wraps the shared TagFilterControl anddiff --git a/skyvern-frontend/src/routes/workflows/components/tree/FolderTreeNode.test.tsx b/skyvern-frontend/src/routes/workflows/components/tree/FolderTreeNode.test.tsxindex 411471835..0ab044877 100644--- a/skyvern-frontend/src/routes/workflows/components/tree/FolderTreeNode.test.tsx+++ b/skyvern-frontend/src/routes/workflows/components/tree/FolderTreeNode.test.tsx@@ -63,6 +63,7 @@ const contextValue: WorkflowsListContextValue = {foldersMap: new Map(),workflowTagsMap: {},tagDescriptions: new Map(),+ tagColors: new Map(),tagKeys: [],labelSuggestions: [],valueSuggestionsByKey: new Map(),diff --git a/skyvern-frontend/src/routes/workflows/components/tree/WorkflowRow.tsx b/skyvern-frontend/src/routes/workflows/components/tree/WorkflowRow.tsxindex 9296a5b3b..f9cd4ded5 100644--- a/skyvern-frontend/src/routes/workflows/components/tree/WorkflowRow.tsx+++ b/skyvern-frontend/src/routes/workflows/components/tree/WorkflowRow.tsx@@ -58,6 +58,7 @@ function WorkflowRow({ workflow, depth = 0 }: WorkflowRowProps) {foldersMap,workflowTagsMap,tagDescriptions,+ tagColors,tagKeys,labelSuggestions,valueSuggestionsByKey,@@ -186,7 +187,11 @@ function WorkflowRow({ workflow, depth = 0 }: WorkflowRowProps) {)}</div>{workflowTags && workflowTags.length > 0 ? (- <TagChipList tags={workflowTags} descriptions={tagDescriptions} />+ <TagChipList+ tags={workflowTags}+ descriptions={tagDescriptions}+ colors={tagColors}+ />) : null}</div></TableCell>@@ -252,6 +257,7 @@ function WorkflowRow({ workflow, depth = 0 }: WorkflowRowProps) {tagKeys={tagKeys}labelSuggestions={labelSuggestions}valueSuggestionsByKey={valueSuggestionsByKey}+ colorMap={tagColors}/></>)}diff --git a/skyvern-frontend/src/routes/workflows/components/tree/WorkflowsListContext.ts b/skyvern-frontend/src/routes/workflows/components/tree/WorkflowsListContext.tsindex 0d1ef732d..262a2ebec 100644--- a/skyvern-frontend/src/routes/workflows/components/tree/WorkflowsListContext.ts+++ b/skyvern-frontend/src/routes/workflows/components/tree/WorkflowsListContext.ts@@ -2,6 +2,7 @@ import { createContext, useContext, type MouseEvent } from "react";import type { ParameterDisplayItem } from "../ParameterDisplayInline";import type { Folder } from "../../types/folderTypes";import type { Tag, TagKey } from "../../types/tagTypes";+import type { TagColorMap } from "../../types/tagColors";// Shared, read-only state and handlers consumed by every workflow row, whether// the row is rendered flat (search results) or nested under a folder node. Lives@@ -16,6 +17,8 @@ export interface WorkflowsListContextValue {foldersMap: ReadonlyMap<string, Folder>;workflowTagsMap: Record<string, Array<Tag>>;tagDescriptions: Map<string, string | null>;+ // (key, value) -> palette color for grouped tag chips; undefined until loaded.+ tagColors: TagColorMap | undefined;tagKeys: Array<TagKey>;labelSuggestions: Array<string>;valueSuggestionsByKey: Map<string, Array<string>>;diff --git a/skyvern-frontend/src/routes/workflows/hooks/useTagValuesQuery.ts b/skyvern-frontend/src/routes/workflows/hooks/useTagValuesQuery.tsnew file mode 100644index 000000000..e676fe441--- /dev/null+++ b/skyvern-frontend/src/routes/workflows/hooks/useTagValuesQuery.ts@@ -0,0 +1,26 @@+import { getClient } from "@/api/AxiosClient";+import { useCredentialGetter } from "@/hooks/useCredentialGetter";+import { useQuery } from "@tanstack/react-query";+import type { TagValue } from "../types/tagTypes";+import { buildTagColorMap, type TagColorMap } from "../types/tagColors";++// Per-org grouped-tag color registry. Returns a (key, value) -> palette color Map+// (built in `select`, so the transform is memoized and the map reference is stable+// across renders). Mirrors useTagKeysQuery's join of the key registry.+function useTagValuesQuery({ enabled = true }: { enabled?: boolean } = {}) {+ const credentialGetter = useCredentialGetter();++ return useQuery<Array<TagValue>, Error, TagColorMap>({+ queryKey: ["tag-values"],+ enabled,+ queryFn: async () => {+ const client = await getClient(credentialGetter);+ return client+ .get<Array<TagValue>>("/tag-values")+ .then((response) => response.data);+ },+ select: buildTagColorMap,+ });+}++export { useTagValuesQuery };diff --git a/skyvern-frontend/src/routes/workflows/hooks/useWorkflowTagMutations.ts b/skyvern-frontend/src/routes/workflows/hooks/useWorkflowTagMutations.tsindex 509dc81ae..a022094e1 100644--- a/skyvern-frontend/src/routes/workflows/hooks/useWorkflowTagMutations.ts+++ b/skyvern-frontend/src/routes/workflows/hooks/useWorkflowTagMutations.ts@@ -38,6 +38,9 @@ function useApplyWorkflowTagsMutation() {queryClient.invalidateQueries({ queryKey: ["workflow-tags"] });// A first-time key registers a new tag-key row, so refresh the registry.queryClient.invalidateQueries({ queryKey: ["tag-keys"] });+ // The apply request can set/change a grouped tag's color, so refresh the+ // color registry or new colors won't render until a hard refetch.+ queryClient.invalidateQueries({ queryKey: ["tag-values"] });// The workflows list is filterable by tags, so a changed tag can change// which rows match the active ?tags= filter.queryClient.invalidateQueries({ queryKey: ["workflows"] });diff --git a/skyvern-frontend/src/routes/workflows/types/tagColors.test.ts b/skyvern-frontend/src/routes/workflows/types/tagColors.test.tsnew file mode 100644index 000000000..0401ddcbd--- /dev/null+++ b/skyvern-frontend/src/routes/workflows/types/tagColors.test.ts@@ -0,0 +1,96 @@+import { describe, expect, it } from "vitest";+import type { TagValue } from "./tagTypes";+import {+ TAG_COLOR_PALETTE,+ buildTagColorMap,+ isPaletteColorName,+ paletteDotClass,+ randomPaletteColor,+ tagColorFor,+ tagColorKey,+} from "./tagColors";++// The palette is the frontend mirror of the backend TAG_COLOR_PALETTE in+// skyvern/forge/sdk/workflow/models/validators.py — names AND order must match+// (order is the random-pick pool). Any drift would render an uncolored chip or+// let the editor offer a swatch the backend would 422.+const BACKEND_PALETTE = [+ "gray",+ "red",+ "orange",+ "amber",+ "yellow",+ "green",+ "teal",+ "blue",+ "cyan",+ "indigo",+ "purple",+ "pink",+];++describe("tag color palette", () => {+ it("mirrors the backend palette names and order exactly", () => {+ expect([...TAG_COLOR_PALETTE]).toEqual(BACKEND_PALETTE);+ });++ it("recognizes palette names and rejects non-members", () => {+ expect(isPaletteColorName("blue")).toBe(true);+ expect(isPaletteColorName("BLUE")).toBe(false);+ expect(isPaletteColorName("chartreuse")).toBe(false);+ expect(isPaletteColorName(undefined)).toBe(false);+ expect(isPaletteColorName(null)).toBe(false);+ });++ it("returns the solid dot class for a palette name and '' otherwise", () => {+ expect(paletteDotClass("green")).toBe("bg-green-500");+ expect(paletteDotClass("not-a-color")).toBe("");+ expect(paletteDotClass(null)).toBe("");+ expect(paletteDotClass(undefined)).toBe("");+ });++ it("always picks a palette member at random", () => {+ for (let i = 0; i < 50; i++) {+ expect(isPaletteColorName(randomPaletteColor())).toBe(true);+ }+ });+});++describe("buildTagColorMap", () => {+ it("joins (key, value) rows and drops out-of-palette colors", () => {+ const rows: Array<TagValue> = [+ { key: "env", value: "prod", color: "blue" },+ { key: "env", value: "staging", color: "amber" },+ { key: "team", value: "growth", color: "not-a-color" },+ ];+ const map = buildTagColorMap(rows);+ expect(map.get(tagColorKey("env", "prod"))).toBe("blue");+ expect(map.get(tagColorKey("env", "staging"))).toBe("amber");+ expect(map.has(tagColorKey("team", "growth"))).toBe(false);+ });++ it("does not resolve prototype keys (real Map, not object)", () => {+ const map = buildTagColorMap([+ { key: "constructor", value: "x", color: "red" },+ ]);+ expect(map.get(tagColorKey("toString", "x"))).toBeUndefined();+ expect(map.get(tagColorKey("constructor", "x"))).toBe("red");+ });+});++describe("tagColorFor", () => {+ const map = buildTagColorMap([{ key: "env", value: "prod", color: "blue" }]);++ it("returns the color for a grouped tag", () => {+ expect(tagColorFor(map, "env", "prod")).toBe("blue");+ });++ it("never colors a standalone label (null key)", () => {+ expect(tagColorFor(map, null, "prod")).toBeUndefined();+ });++ it("returns undefined when the map is absent or has no entry", () => {+ expect(tagColorFor(undefined, "env", "prod")).toBeUndefined();+ expect(tagColorFor(map, "env", "dev")).toBeUndefined();+ });+});diff --git a/skyvern-frontend/src/routes/workflows/types/tagColors.ts b/skyvern-frontend/src/routes/workflows/types/tagColors.tsnew file mode 100644index 000000000..9ca47b32a--- /dev/null+++ b/skyvern-frontend/src/routes/workflows/types/tagColors.ts@@ -0,0 +1,103 @@+import type { TagValue } from "./tagTypes";++// Mirror of skyvern/forge/sdk/workflow/models/validators.py TAG_COLOR_PALETTE.+// Keep the names AND order in sync with the backend: the order is the random-pick+// pool, and any name the backend would 422 must be one the frontend can render.+export const TAG_COLOR_PALETTE = [+ "gray",+ "red",+ "orange",+ "amber",+ "yellow",+ "green",+ "teal",+ "blue",+ "cyan",+ "indigo",+ "purple",+ "pink",+] as const;++export type PaletteColorName = (typeof TAG_COLOR_PALETTE)[number];++// Solid swatch fill per name, for the color picker dots.+const SWATCH_CLASSES: Record<PaletteColorName, string> = {+ gray: "bg-gray-400",+ red: "bg-red-500",+ orange: "bg-orange-500",+ amber: "bg-amber-500",+ yellow: "bg-yellow-400",+ green: "bg-green-500",+ teal: "bg-teal-500",+ blue: "bg-blue-500",+ cyan: "bg-cyan-500",+ indigo: "bg-indigo-500",+ purple: "bg-purple-500",+ pink: "bg-pink-500",+};++const PALETTE_SET = new Set<string>(TAG_COLOR_PALETTE);++export function isPaletteColorName(value: unknown): value is PaletteColorName {+ return typeof value === "string" && PALETTE_SET.has(value);+}++export function paletteSwatchClass(color: PaletteColorName): string {+ return SWATCH_CLASSES[color];+}++// Solid dot class (bg-X-500) for a grouped tag's palette color; "" for anything+// outside the palette so the caller renders no dot. The chip surface stays neutral+// per the AC — a leading color indicator, not a tinted badge fill.+export function paletteDotClass(color: string | null | undefined): string {+ return isPaletteColorName(color) ? paletteSwatchClass(color) : "";+}++export function randomPaletteColor(): PaletteColorName {+ const index = Math.floor(Math.random() * TAG_COLOR_PALETTE.length);+ return TAG_COLOR_PALETTE[index] ?? TAG_COLOR_PALETTE[0];+}++// Color identity is per grouped (key, value). Standalone labels have no key and+// are never colored, so they never produce a map entry. The space separator is+// unambiguous: keys match ^[A-Za-z0-9][A-Za-z0-9_.-]*$ and can't contain a space,+// so everything up to the first space is the key (matches termDedupeKey).+export function tagColorKey(key: string, value: string): string {+ return `${key} ${value}`;+}++// Map of (key, value) -> palette color name. A real Map (not an object) so a+// user-controlled key like "constructor" can't resolve to an Object prototype+// member on lookup.+export type TagColorMap = Map<string, PaletteColorName>;++// Join GET /tag-values rows into a lookup map, dropping any row whose color isn't+// in the curated palette (defensive against payload skew, mirroring how the tag+// chips re-validate their shape before render).+export function buildTagColorMap(tagValues: Array<TagValue>): TagColorMap {+ const map: TagColorMap = new Map();+ for (const row of tagValues) {+ if (+ typeof row.key !== "string" ||+ typeof row.value !== "string" ||+ !isPaletteColorName(row.color)+ ) {+ continue;+ }+ map.set(tagColorKey(row.key, row.value), row.color);+ }+ return map;+}++// Resolve a tag's color from the map. Only grouped tags (non-null key) carry a+// color; standalone labels always return undefined.+export function tagColorFor(+ colors: TagColorMap | undefined,+ tagKey: string | null,+ value: string,+): PaletteColorName | undefined {+ if (colors === undefined || tagKey === null) {+ return undefined;+ }+ return colors.get(tagColorKey(tagKey, value));+}diff --git a/skyvern-frontend/src/routes/workflows/types/tagTypes.ts b/skyvern-frontend/src/routes/workflows/types/tagTypes.tsindex 20c2949c1..ffd8fd7b4 100644--- a/skyvern-frontend/src/routes/workflows/types/tagTypes.ts+++ b/skyvern-frontend/src/routes/workflows/types/tagTypes.ts@@ -28,6 +28,14 @@ export interface TagKey {workflow_count: number;}+// Palette color assigned to a grouped (key, value) pair (from GET /tag-values).+// Standalone labels have no key and are not colored, so never appear here.+export interface TagValue {+ key: string;+ value: string;+ color: string;+}+// Batch endpoint returns a list of {key, value} per workflow (no per-tag// metadata). Descriptions come from the tag-key registry (GET /tag-keys).export interface WorkflowTagsBatchResponse {@@ -48,6 +56,9 @@ export type TagDeleteInput =export interface TagApplyRequest {tags?: Array<TagInput>;tags_to_delete?: Array<TagDeleteInput>;+ // Map of grouped tag key -> palette color name for the value being set. Keys+ // absent here keep their existing color or get a random palette color server-side.+ colors?: Record<string, string>;}// Mirror skyvern/forge/sdk/workflow/models/validators.py so the editor rejects