Skip to content

Add knowledge tag ID canonical input - #5983

Open
BillLeoutsakosvl346 wants to merge 6 commits into
stagingfrom
feature/kb-tag-id-input
Open

Add knowledge tag ID canonical input#5983
BillLeoutsakosvl346 wants to merge 6 commits into
stagingfrom
feature/kb-tag-id-input

Conversation

@BillLeoutsakosvl346

Copy link
Copy Markdown
Contributor

What changed

  • adds a basic/advanced canonical pair for Knowledge block tag filters, preserving the existing tag-name selector and adding a manual Tag ID input
  • resolves tag IDs against the selected knowledge base server-side and validates invalid or cross-knowledge-base IDs
  • adds the standard copy-ID control to tag rows in the knowledge-base Tags modal
  • carries canonical tag filters through migration, display, search/replace, parameter resolution, and workspace-fork behavior
  • adds regression coverage across the UI, internal API, tool serialization, canonical migration, and workspace forking

Why

Knowledge tag filters previously required selecting a tag by name. Workflows need the same manual-ID alternative used by Slack and other canonical-pair inputs, especially when the ID comes from a workflow reference.

Impact

Users can switch a Knowledge block tag filter between its normal selector and a manual Tag ID input. Existing workflows remain in basic mode, and the public v1 search API is unchanged.

Validation

  • 303 focused Vitest tests
  • Biome checks for all changed files
  • API validation contract audit
  • block registry and canonical-ID checks
  • git diff --check
  • two independent implementation review passes

@vercel

vercel Bot commented Jul 27, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Jul 27, 2026 11:24pm

Request Review

@BillLeoutsakosvl346
BillLeoutsakosvl346 marked this pull request as ready for review July 27, 2026 21:11
@BillLeoutsakosvl346
BillLeoutsakosvl346 requested a review from a team as a code owner July 27, 2026 21:11
@cursor

cursor Bot commented Jul 27, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Changes knowledge search validation and structured filter resolution, plus fork remapping of stored tag-definition UUIDs—incorrect behavior could break searches or silently alter filters after workspace copy.

Overview
Adds a basic/advanced canonical pair for Knowledge tag filters: existing name-based selectors stay in basic mode; advanced mode uses a manual Tag ID field (including workflow references), wired through block config, tool param resolution, and nested tool rendering via scoped canonical dependency context.

The internal knowledge search route now accepts filters with exactly one of tagName or tagId, resolves IDs against the selected KB’s tag definitions (slot, type, operators), rejects multi-KB tag-ID searches and invalid/mismatched filters, and validates between bounds using the resolved type—not client-supplied metadata.

Workflow UX includes copy-tag-ID in the KB Tags modal, Tag ID editing behavior in the editor (preserve in-progress edits until an ID resolves), plus display, search/replace, and migration backfill for the new pair. Fork/promote remapping strips literal definition UUIDs from advanced filters when the KB mapping changes but keeps dynamic tag ID references.

Tool/shared parsing and search tool bodies emit tagId or tagName consistently for server resolution.

Reviewed by Cursor Bugbot for commit f3853ef. Bugbot is set up for automated code reviews on this repo. Configure here.

@BillLeoutsakosvl346
BillLeoutsakosvl346 changed the base branch from main to staging July 27, 2026 21:12
@BillLeoutsakosvl346

Copy link
Copy Markdown
Contributor Author

@greptile-apps please review the corrected feature diff after retargeting this PR to staging.

@cursor review

@greptile-apps

greptile-apps Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR adds canonical basic/advanced Knowledge tag filters and carries tag IDs through search, serialization, migration, workflow utilities, and workspace forks.

  • Adds a manual Tag ID alternative to the existing tag-name selector.
  • Resolves tag IDs against accessible knowledge-base definitions and validates IDs, operators, and values server-side.
  • Adds tag-ID copy controls and regression coverage for UI, API, tooling, migration, and fork behavior.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
apps/sim/app/api/knowledge/search/route.ts Resolves tag IDs from accessible knowledge-base definitions and validates resolved filter types, operators, and range values.
apps/sim/lib/api/contracts/knowledge/search.ts Extends the internal search contract with mutually exclusive tag-name and tag-ID filter identifiers.
apps/sim/blocks/blocks/knowledge.ts Defines the tag-name and manual Tag ID controls as a canonical basic/advanced parameter pair.
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/knowledge-tag-filters/knowledge-tag-filters.tsx Supports editing, resolving, and displaying Tag ID filters in the advanced canonical mode.
apps/sim/ee/workspace-forking/lib/remap/remap-references.ts Preserves dynamic tag-ID references while removing source-workspace literal tag IDs when knowledge bases move across fork boundaries.
apps/sim/tools/shared/tags.ts Parses both tag-name and tag-ID filter representations into the internal structured-filter shape.

Sequence Diagram

sequenceDiagram
  participant User as Workflow editor
  participant Serializer as Canonical serializer
  participant Tool as Knowledge search tool
  participant API as Knowledge search API
  participant Tags as KB tag definitions
  participant Search as Vector/tag search
  User->>Serializer: Configure tag name or manual tag ID
  Serializer->>Tool: Emit canonical tagFilters
  Tool->>API: Search request with tag filters
  API->>Tags: Resolve tag ID/name to slot and field type
  Tags-->>API: Tag definition
  API->>API: Validate operator and values
  API->>Search: Typed structured filters
  Search-->>User: Matching knowledge chunks
Loading

Reviews (4): Last reviewed commit: "Fix canonical tag filter edge cases" | Re-trigger Greptile

Comment thread apps/sim/app/api/knowledge/search/route.ts
@BillLeoutsakosvl346

Copy link
Copy Markdown
Contributor Author

@greptile-apps please re-review the latest changes addressing both BugBot findings.

@cursor review

@BillLeoutsakosvl346

Copy link
Copy Markdown
Contributor Author

@greptile-apps please perform a final review of the latest Tag ID editing refinement.

@cursor review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 5e89280. Configure here.

Comment thread apps/sim/tools/shared/tags.ts Outdated
Comment thread apps/sim/blocks/blocks/knowledge.ts
@BillLeoutsakosvl346

Copy link
Copy Markdown
Contributor Author

@greptile-apps please re-review commit 20a3941, which addresses both latest BugBot findings and adds focused regression coverage.

@cursor review

@BillLeoutsakosvl346

Copy link
Copy Markdown
Contributor Author

Demo:

Screen.Recording.2026-07-27.at.4.15.24.PM.mov

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