Skip to content

feat: api response block and implementation #510

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Jun 23, 2025

Conversation

adiologydev
Copy link
Collaborator

@adiologydev adiologydev commented Jun 17, 2025

Description

Added a new Response block, which lets users add an ending to their workflows and send a structured API response back.
Reinstated the old input fields block. I tried using JSON schema, but this UX is much better (IMHO).

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Security enhancement
  • Performance improvement
  • Code refactoring (no functional changes)

How Has This Been Tested?

Locally by running API calls on deployed workflows

image

image

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added tests that prove my fix is effective or that my feature works
  • All tests pass locally and in CI (bun run test)
  • My changes generate no new warnings
  • Any dependent changes have been merged and published in downstream modules
  • I have updated version numbers as needed (if needed)
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

Security Considerations:

  • My changes do not introduce any new security vulnerabilities
  • I have considered the security implications of my changes

Additional Information:

Any additional information, configuration or data that might be necessary to reproduce the issue or use the feature.

Copy link

vercel bot commented Jun 17, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 23, 2025 6:25pm
sim ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 23, 2025 6:25pm

Copy link

vercel bot commented Jun 17, 2025

@adiologydev is attempting to deploy a commit to the Sim Studio Team on Vercel.

A member of the Team first needs to authorize it.

@emir-karabeg
Copy link
Collaborator

emir-karabeg commented Jun 18, 2025

@adiologydev please address the test errors and also add information in the PR description for testing, and check all relevant boxes. Then, add something at the end for additional information or delete it if unnecessary whenever you're done with your changes

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

Implements a new Response block feature enabling structured API responses in workflows, with comprehensive HTTP response control and documentation.

  • Added apps/sim/blocks/blocks/response.ts implementing Response block with configurable data, status codes, and headers
  • Enhanced apps/sim/executor/handlers/response/response-handler.ts to process response blocks with proper status codes (default 200) and Content-Type headers
  • Modified apps/sim/app/w/[id]/components/workflow-block/workflow-block.tsx to make Response blocks terminal nodes (no output connections)
  • Added support for 'json-object' generation type in apps/sim/app/api/codegen/route.ts for structured JSON responses
  • Improved input format handling in apps/sim/blocks/blocks/starter.ts for better API request validation

21 files reviewed, 6 comments
Edit PR Review Bot Settings | Greptile

@adiologydev adiologydev added feature New feature or request documentation Improvements or updates to documentation labels Jun 20, 2025
@@ -0,0 +1,300 @@
import { useRef, useState } from 'react'
Copy link
Collaborator

Choose a reason for hiding this comment

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

need to wrap handleDragOver, handleInputChange, handleTagSelect, and handleEnvVarSelect in useCallbacks. Not blocking, can be done in a follow up PR.

// layout: 'full',
// condition: { field: 'startWorkflow', value: 'manual' },
// },
{
Copy link
Collaborator

Choose a reason for hiding this comment

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

Minor issue with this -- the variables are not correctly matching up. And the autocomplete / dropdown doesn't show them.

Screen.Recording.2025-06-21.at.11.05.38.AM.mov

Copy link
Collaborator

Choose a reason for hiding this comment

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

Second question -- it doesn't let me delete all the fields after adding them. E.g. I can't delete Name and Joke after adding them. The trash can becomes disabled.

Copy link
Collaborator Author

@adiologydev adiologydev Jun 23, 2025

Choose a reason for hiding this comment

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

Minor issue with this -- the variables are not correctly matching up. And the autocomplete / dropdown doesn't show them.
Screen.Recording.2025-06-21.at.11.05.38.AM.mov

This is happening with all blocks which have tag input and variable input; it worked 50/50 of the time for me.
It's those specific components which need to be addressed in another PR.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Second question -- it doesn't let me delete all the fields after adding them. E.g. I can't delete Name and Joke after adding them. The trash can becomes disabled.

Pushing a fix for this.

@icecrasher321
Copy link
Collaborator

A few issues.

  1. When I directly connect start to response it doesn't recognize for some reason?
Screen.Recording.2025-06-21.at.11.16.29.AM.mov
  1. More important -- not returning the response with the params I specific for this workflow I made. Am I missing something here?
Screen.Recording.2025-06-21.at.11.19.32.AM.mov

@adiologydev
Copy link
Collaborator Author

adiologydev commented Jun 23, 2025

A few issues.

1. When I directly connect start to response it doesn't recognize for some reason?

Screen.Recording.2025-06-21.at.11.16.29.AM.mov

2. More important -- not returning the response with the params I specific for this workflow I made. Am I missing something here?

Screen.Recording.2025-06-21.at.11.19.32.AM.mov

  1. I'm unable to replicate this. Maybe the workflow didn't save/deploy properly.
  2. This is specific to the function clause handler, it overwrites the output to {}, needs to be investigated and fixed in another PR.

Here's an example of it working with other blocks:
image

image

@icecrasher321 icecrasher321 merged commit bdf316e into simstudioai:main Jun 23, 2025
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or updates to documentation feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants