Skip to content

feat(workflows): support explicit tags and category in workflow YAML#1190

Open
lraphael wants to merge 3 commits intocoleam00:devfrom
lraphael:feat/workflow-custom-tags-categories
Open

feat(workflows): support explicit tags and category in workflow YAML#1190
lraphael wants to merge 3 commits intocoleam00:devfrom
lraphael:feat/workflow-custom-tags-categories

Conversation

@lraphael
Copy link
Copy Markdown

@lraphael lraphael commented Apr 13, 2026

Problem

Workflow tags and categories are currently derived from hardcoded keyword matching in workflow-metadata.ts. This means community adapters (GitLab, Gitea, etc.) and custom workflows cannot control their own tags without modifying core code. For example, a GitLab review workflow gets tagged #GitHub because the keyword "issue" triggers the GitHub tag.

Solution

Add optional tags and category fields to the workflow YAML schema. Explicit values take precedence over keyword-based inference, which remains as the fallback for backwards compatibility. An explicit empty array (tags: []) suppresses inference entirely.

name: review-gitlab-mr
tags: [GitLab, Review]
category: Code Review
description: ...

Changes

  • packages/workflows/src/schemas/workflow.ts — Add tags: string[] and category: string optional fields to workflowBaseSchema
  • packages/workflows/src/loader.ts — Pass tags and category from parsed YAML through to the workflow object returned by the loader
  • packages/web/src/lib/workflow-metadata.tsgetWorkflowTags() and getWorkflowCategory() prefer explicit values, fall back to keyword inference
  • packages/web/src/components/workflows/WorkflowCard.tsx — Pass explicit tags/category from workflow object
  • packages/web/src/components/workflows/WorkflowList.tsx — Pass explicit category for filtering
  • packages/web/src/lib/workflow-metadata.test.ts — Tests for explicit values, fallback, empty array suppression, and deduplication

Test plan

  • All existing tests pass (123 tests, 0 failures)
  • Type-check passes across all packages
  • Lint + format clean (pre-commit hooks)
  • Workflow with tags: [GitLab, Review] → shows those exact tags (verified in browser)
  • Workflow with tags: [] → suppresses inference, shows no tags
  • Workflow without tags/category → inferred as before (backwards compatible)
  • Workflow with category: Automation → filtered correctly
  • Workflow with invalid category → falls back to keyword inference

Allow workflow authors to define custom tags and category directly in
their YAML files. This enables community adapters (e.g. GitLab, Gitea)
and custom workflows to control their own metadata without requiring
changes to the core keyword-detection logic.

Explicit values take precedence; keyword-based inference remains as
the fallback for workflows without these fields.

Example usage:
  tags: [GitLab, Review]
  category: Code Review
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 13, 2026

📝 Walkthrough

Walkthrough

This PR adds optional explicit category and tags metadata to workflow schemas and parsing, updates loader to extract and sanitize them, extends metadata utilities to accept explicit overrides, updates UI components to pass explicit values, and adds tests for override and fallback behaviors.

Changes

Cohort / File(s) Summary
Workflow Schema Extension
packages/workflows/src/schemas/workflow.ts
Added optional tags?: string[] and category?: string to workflowBaseSchema.
Manifest Parsing / Loader
packages/workflows/src/loader.ts
Parse raw.tags (filter non-strings, warn on invalid entries) and raw.category (only accept string); include sanitized tags and category on returned workflow objects.
Metadata Utility Functions
packages/web/src/lib/workflow-metadata.ts
getWorkflowCategory(name, description, explicitCategory?) and getWorkflowTags(name, parsed, explicitTags?) now accept explicit overrides; explicit values short-circuit inference, tags are deduplicated when provided.
Component Updates
packages/web/src/components/workflows/WorkflowCard.tsx, packages/web/src/components/workflows/WorkflowList.tsx
Extract category and tags from workflow objects (via record cast) and pass them into getWorkflowCategory / getWorkflowTags.
Test Coverage
packages/web/src/lib/workflow-metadata.test.ts
Added tests for explicit-category and explicit-tags: valid overrides, invalid overrides falling back to inference, explicit empty array suppresses inference, and tag deduplication/preservation of order.

Sequence Diagram(s)

sequenceDiagram
  participant Loader as Workflow Loader
  participant Parser as YAML Parser
  participant Utils as workflow-metadata.ts
  participant UI as WorkflowCard / WorkflowList

  Loader->>Parser: read file & parse frontmatter/raw
  Parser-->>Loader: raw.name, raw.description, raw.tags?, raw.category?
  Loader->>Loader: sanitize/filter `tags`, validate `category`
  Loader->>Utils: getWorkflowCategory(name, description, explicitCategory?)
  Loader->>Utils: getWorkflowTags(name, parsed, explicitTags?)
  Utils-->>Loader: return category, tags (explicit or inferred)
  Loader-->>UI: return workflow object including category & tags
  UI->>Utils: pass name/desc/parsed + explicit fields to utils at render-time
  Utils-->>UI: resolved category & tags used for rendering
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 A tiny schema, a tidy tweak,
Tags and category now speak,
Parsed with care, explicit or guessed,
Deduped and validated, then expressed,
Workflows hop forward, neat and sleek! 🥕

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning The PR description covers the problem, solution, and specific changes, but is missing several required template sections like UX Journey, Architecture Diagram, Label Snapshot, Validation Evidence, Security Impact, Compatibility, Human Verification, Side Effects, and Rollback Plan. Add the missing required sections from the description template: UX Journey flows (Before/After), Architecture Diagram with module connections, Label Snapshot with risk/size/scope labels, Validation Evidence with command outputs, Security Impact assessment, Compatibility/Migration details, Human Verification beyond CI, Side Effects/Blast Radius analysis, and Rollback Plan.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main feature: adding support for explicit tags and category fields in workflow YAML, which is the primary focus of all changes.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/web/src/lib/workflow-metadata.test.ts`:
- Around line 216-233: Add a unit test to cover the explicit empty-array case so
that getWorkflowTags('...', parsed, []) returns [] (i.e., suppresses inference).
In the same test file use parseWorkflowDescription to build the parsed input
(e.g., parseWorkflowDescription('...')), call getWorkflowTags with an empty
array for the explicitTags argument, and assert the result strictly equals an
empty array; reference getWorkflowTags and parseWorkflowDescription to locate
where to add this new test case alongside the existing tests.

In `@packages/web/src/lib/workflow-metadata.ts`:
- Around line 183-185: The current guard (explicitTags && explicitTags.length >
0) ignores an explicit empty array and falls back to inference; change the check
to detect whether explicitTags was provided (e.g., explicitTags !== undefined /
explicitTags != null) so an explicit [] is honored and still returned
(deduplicated) by the existing return path; update the condition around the
explicitTags check (the variable explicitTags in this block) so the function
returns the Set-deduplicated explicitTags even when it's an empty array.

In `@packages/workflows/src/schemas/workflow.ts`:
- Around line 43-44: The loader is dropping tags and category because loader.ts
reconstructs the returned workflow object without copying raw.tags or
raw.category; update the code in the function that builds the returned workflow
(the place that reads the raw variable and returns the workflow object) to
include raw.tags (as an optional string array) and raw.category (optional
string) onto the returned workflow object so the fields defined in
workflowBaseSchema are passed through to the UI (ensure you respect their
optional types when assigning).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 32162798-d1af-46ce-b8b9-75dcd2fb6d42

📥 Commits

Reviewing files that changed from the base of the PR and between b5c5f81 and 2a13ff9.

📒 Files selected for processing (5)
  • packages/web/src/components/workflows/WorkflowCard.tsx
  • packages/web/src/components/workflows/WorkflowList.tsx
  • packages/web/src/lib/workflow-metadata.test.ts
  • packages/web/src/lib/workflow-metadata.ts
  • packages/workflows/src/schemas/workflow.ts

Comment thread packages/web/src/lib/workflow-metadata.test.ts
Comment thread packages/web/src/lib/workflow-metadata.ts Outdated
Comment thread packages/workflows/src/schemas/workflow.ts
Raphael Lechner added 2 commits April 13, 2026 15:24
The workflow loader manually constructs the result object and was not
including the new tags and category fields from parsed YAML. Add them
to the loader output so they flow through to the API response.
An explicit `tags: []` in YAML should suppress keyword inference,
allowing authors to clear mis-inferred tags. Previously the empty
array fell through to the fallback logic.
@lraphael lraphael marked this pull request as draft April 13, 2026 16:38
@lraphael lraphael marked this pull request as ready for review April 13, 2026 16:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant