feat(mothership): format generated function code#5742
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryMedium Risk Overview The workflow engine tracks block IDs whenever a Adds Reviewed by Cursor Bugbot for commit b625977. Bugbot is set up for automated code reviews on this repo. Configure here. |
Greptile SummaryThis PR formats Function block code after workflow operations resolve the final block state. The main changes are:
Confidence Score: 4/5The Python async formatting path and server packaging for Prettier need fixes before merging.
apps/sim/lib/workflows/blocks/format-function-code.ts and apps/sim/next.config.ts Important Files Changed
Reviews (1): Last reviewed commit: "feat(mothership): format generated funct..." | Re-trigger Greptile |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want higher recall? High effort reviews run extra passes and find more bugs. A team admin can switch effort levels in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit a5e1c3d. Configure here.
- Preserve Sim references adjacent to right-shift operators - Add regression coverage for signed and unsigned shifts Note: pre-existing type-check failures in audit exports and linked workspace dependencies were not addressed by this PR.
Not addressing these two summary-level concerns because they do not reproduce against the current head:
The formatter remains fail-open in either path, and the current focused suite passes all 103 tests. |

Summary
Mothership-created JavaScript and Python Function blocks now arrive formatted and readable instead of being persisted as dense single-line source. Formatting runs after workflow operations resolve the final block identity and language, preserves Sim workflow and environment references, and fails open so invalid source remains unchanged while the mothership receives a sanitized formatting result.
This uses Prettier for JavaScript and Ruff's WebAssembly formatter for Python, keeping formatting deterministic and independent of how the mothership writes its tool-call strings.
The safety suite now exercises broad JavaScript and Python syntax corpora, formatting idempotence, exact workflow/environment-reference restoration, real placeholder-token collisions, high-cardinality reference sets, invalid-source fail-open behavior, and synchronous and asynchronous JavaScript runtime equivalence.
Type of Change
Testing
DATABASE_URL=postgres://postgres:postgres@localhost:5432/sim bun test apps/sim/lib/workflows/blocks/format-function-code.test.ts apps/sim/lib/workflows/blocks/format-function-code.safety.test.ts apps/sim/lib/copilot/tools/server/workflow/edit-workflow/function-code-formatting.test.ts apps/sim/lib/copilot/tools/server/workflow/edit-workflow/operations.test.ts- 103 tests passed with 552 assertions in the cleanstaging-based worktree.bunx biome check apps/sim/lib/workflows/blocks/format-function-code.test.ts apps/sim/lib/workflows/blocks/format-function-code.safety.test.ts apps/sim/lib/workflows/blocks/format-function-code.ts- passed.bun run check:api-validation- passed with all 964 API routes Zod-backed and no baseline drift.bun run --cwd apps/sim type-check- passed in the authored checkout. The isolated worktree reuses dependencies from a divergent checkout, so its full-project type-check surfaces unrelated missing audit exports and@google-cloud/storage; CI should validate this again from a fresh install.Reviewers should focus on Sim-reference protection around comparison/shift syntax, the token-collision fixture, and Ruff WebAssembly tracing for standalone Next deployments.
No additional post-deploy monitoring is required for the safety-test follow-up because it changes no production runtime behavior.
Checklist
Screenshots/Videos
Not applicable - this changes server-side workflow code normalization and has no new visual surface.