feat(workflows): support explicit tags and category in workflow YAML#1190
feat(workflows): support explicit tags and category in workflow YAML#1190lraphael wants to merge 3 commits intocoleam00:devfrom
Conversation
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
📝 WalkthroughWalkthroughThis PR adds optional explicit Changes
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
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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
📒 Files selected for processing (5)
packages/web/src/components/workflows/WorkflowCard.tsxpackages/web/src/components/workflows/WorkflowList.tsxpackages/web/src/lib/workflow-metadata.test.tspackages/web/src/lib/workflow-metadata.tspackages/workflows/src/schemas/workflow.ts
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.
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#GitHubbecause the keyword "issue" triggers the GitHub tag.Solution
Add optional
tagsandcategoryfields 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.Changes
packages/workflows/src/schemas/workflow.ts— Addtags: string[]andcategory: stringoptional fields toworkflowBaseSchemapackages/workflows/src/loader.ts— Passtagsandcategoryfrom parsed YAML through to the workflow object returned by the loaderpackages/web/src/lib/workflow-metadata.ts—getWorkflowTags()andgetWorkflowCategory()prefer explicit values, fall back to keyword inferencepackages/web/src/components/workflows/WorkflowCard.tsx— Pass explicit tags/category from workflow objectpackages/web/src/components/workflows/WorkflowList.tsx— Pass explicit category for filteringpackages/web/src/lib/workflow-metadata.test.ts— Tests for explicit values, fallback, empty array suppression, and deduplicationTest plan
tags: [GitLab, Review]→ shows those exact tags (verified in browser)tags: []→ suppresses inference, shows no tagstags/category→ inferred as before (backwards compatible)category: Automation→ filtered correctlycategory→ falls back to keyword inference