Title: fix(copilot): let edit_workflow set knowledge-base tag filters, and stop it clearing them by j15z · Pull Request #5546 · simstudioai/sim · GitHub
Open Graph Title: fix(copilot): let edit_workflow set knowledge-base tag filters, and stop it clearing them by j15z · Pull Request #5546 · simstudioai/sim
X Title: fix(copilot): let edit_workflow set knowledge-base tag filters, and stop it clearing them by j15z · Pull Request #5546 · simstudioai/sim
Description: Summary The copilot could not edit a Knowledge block's tag filter at all. Asking Sim to set or change a tag filter appeared to succeed, but the value never showed up in the block. edit_workflow persisted tagFilters and documentTags as raw arrays, while their UI components store and read a JSON string. The write landed in the database in a shape nothing downstream could render, so the filter silently stayed empty. The same was true on the nested-node edit path. Fixing that surfaced a second, worse bug underneath it. Once the agent could actually write a tag filter, it still could not read one back: sanitizeForCopilot stripped both keys out of the workflow state the agent sees. The field was write-only. So on a follow-up edit — "change it back" — the agent saw an absent field, concluded no filter was set, and cleared the user's filter. From the trace: The current state already shows no tagFilters field on the Knowledge block — but since the parent reported it was set, I'll explicitly clear it to be safe. It was telling the truth. That redaction came from #1628, which added it in two places for workflow export. Export is now independently protected by sanitizeWorkflowForSharing, so the copy in the copilot read path had become redundant — and destructive. This PR closes four gaps along the same read/write loop: Serialization (the original defect) — normalize tagFilters/documentTags to a JSON string on write via normalizeSubblockValue, on both the flat and nested-node edit paths, so an agent-authored filter actually renders and executes. parseJsonArrayValue keeps rows written by older builds readable, so no migration is needed. Read view — stop stripping the two keys from sanitizeForCopilot, so the agent can read back what it writes. Export/sharing redaction is untouched. null still omits the key, so absent now unambiguously means unset. Write validation — knowledge-tag-filters and document-tag-entry had no arm in the edit_workflow validator and fell through to a pass-through default. Any non-array value (a double-encoded string, an object, unparseable text) was coerced to [] by normalizeArrayWithIds and persisted as "[]" over the user's filter. condition-input/router-input already guarded against exactly this; the KB types now do too. Discoverability — meta.json exposed displayName, but a filter entry must carry tagName; an entry written with displayName validates, persists, and filters nothing. Renamed at the serializer boundary (DB column unchanged) and added the operators legal per fieldType, since between is valid for number/date but not text/boolean and the agent cannot infer that. Together: the first bullet makes editing a tag filter work, the next three make it keep working across turns. Reported by @justin. No linked issue. Type of Change Bug fix New feature Breaking change Documentation Other: tagFilters/documentTags now persist as JSON strings (readers accept both shapes; no migration) Testing Unit tests — 176 passing across 15 files, covering every touched path: validation.test.ts — 74/74, including 8 new cases pinning that a double-encoded string, an object, a number, and unparseable text are all rejected rather than coerced to "[]", while null and [] still clear the field json-sanitizer.test.ts (new) — tagFilters/documentTags survive sanitizeForCopilot; a null value still omits the key serializers.test.ts — tagName rename, and the between asymmetry pinned per field type; an unrecognized fieldType yields [] rather than throwing sub-block/utils.test.ts (new) — parseJsonArrayValue across JSON string, raw array, null, malformed JSON, and JSON parsing to a non-array builders.test.ts, operations.test.ts, mutations.test.ts — round-trip through both edit paths Static checks: tsc --noEmit exit 0; biome check clean on all changed files. Both re-run after rebasing onto current dev. Verified manually in the running app. Both halves of the bug: asking Sim to change a Knowledge block's tag filter to a different tag definition and value now actually applies it to the block, and asking it to change back restores the original rather than clearing it. This is the check that matters most here — an earlier pass on this bug looked correct statically and still had a second data-loss path underneath it, which the unit tests alone did not surface. Reviewers should focus on: json-sanitizer.ts — confirm sanitizeSubBlocks really is copilot-only (one caller, sanitizeForCopilot) and that removing the strip cannot widen what workflow export, sharing, or templates expose. Export redaction lives in credential-extractor.ts and is untouched. validation.ts — the new arm keys on subblock type, so the unrelated tagFilters short-input on the Algolia block is deliberately not affected. Worth confirming that intent. workspace-vfs.ts — loadKbTagDefinitions is now wrapped in try/catch. It runs inside the top-level Promise.all, so an unguarded failure would have rejected the entire workspace VFS materialize over an optional meta.json enrichment, leaving the agent unable to read any file. serializers.test.ts — resolved an add/add conflict during rebase; dev had independently added a file at this path. Both suites were kept. Known, pre-existing, and deliberately out of scope: ARRAY_WITH_ID_SUBBLOCK_TYPES and JSON_STRING_SUBBLOCK_KEYS key on the subblock id, not its type, and ids collide across blocks. PostHog and RDS both expose a conditions subblock that is not a condition-input, so a copilot edit still flattens them to "[]". That predates this branch (both keys were already in ARRAY_WITH_ID_SUBBLOCK_TYPES at the merge-base) and fixing it changes behavior for those blocks, so it belongs in its own PR. validateValueForSubBlockType already switches on type and is the working template. Checklist Code follows project style guidelines Self-reviewed my changes Tests added/updated and passing No new warnings introduced I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA) Screenshots/Videos No UI changes. The failure is observable in mothership traces and in whether a Knowledge block's tag filter survives a round trip through the copilot. 🤖 Generated with Claude Code
Open Graph Description: Summary The copilot could not edit a Knowledge block's tag filter at all. Asking Sim to set or change a tag filter appeared to succeed, but the value never showed up in the block. edit_workflow...
X Description: Summary The copilot could not edit a Knowledge block's tag filter at all. Asking Sim to set or change a tag filter appeared to succeed, but the value never showed up in the block. edit_work...
Opengraph URL: https://github.com/simstudioai/sim/pull/5546
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:b386c18e-e3f1-b0c8-9e13-a100f69fa1bb |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | D1D4:10EC7:3CE1C14:5544A59:6A635829 |
| html-safe-nonce | 2fb5b21c2089dc2fc78118cb5bf459ab7b852a92a5fb2919fcda8612671b9252 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMUQ0OjEwRUM3OjNDRTFDMTQ6NTU0NEE1OTo2QTYzNTgyOSIsInZpc2l0b3JfaWQiOiIxODkzNzg1NzM0MTEwOTkyNDI1IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 3e698b4ff54b8629525345c260543d18e50391395899c3aa4e9f5c5de61b3a98 |
| hovercard-subject-tag | pull_request:4025371870 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/simstudioai/sim/pull/5546/files |
| twitter:image | https://avatars.githubusercontent.com/u/96924014?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/96924014?s=400&v=4 |
| og:image:alt | Summary The copilot could not edit a Knowledge block's tag filter at all. Asking Sim to set or change a tag filter appeared to succeed, but the value never showed up in the block. edit_workflow... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 59e55daad7174ca59d63c6974d58276ccb5477442e550bebb3c035e1bef11c94 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/simstudioai/sim git https://github.com/simstudioai/sim.git |
| octolytics-dimension-user_id | 199344406 |
| octolytics-dimension-user_login | simstudioai |
| octolytics-dimension-repository_id | 912559512 |
| octolytics-dimension-repository_nwo | simstudioai/sim |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 912559512 |
| octolytics-dimension-repository_network_root_nwo | simstudioai/sim |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 990295d92a4cc7b63fbbd83a046217cd7d77d49c |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width