-
Notifications
You must be signed in to change notification settings - Fork 3.3k
fix: Human in the Loop - Canvas labels don't work in Condition/Response blocks #2974
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
base: main
Are you sure you want to change the base?
fix: Human in the Loop - Canvas labels don't work in Condition/Response blocks #2974
Conversation
Inject block outputs as JavaScript variables by their normalized names, allowing users to reference blocks directly (e.g., `humanApproval.approved`) without requiring angle bracket syntax in condition expressions. This fixes Human in the Loop blocks where canvas labels like `humanApproval` were not accessible in Condition blocks, causing "humanApproval is not defined" errors. The fix includes safeguards to: - Skip JavaScript reserved words and built-in identifiers - Avoid overwriting existing context variables Fixes simstudioai#2962
|
@wingding12 is attempting to deploy a commit to the Sim Team on Vercel. A member of the Team first needs to authorize it. |
Greptile SummaryThis PR fixes a critical bug where Human in the Loop blocks couldn't be referenced by their canvas labels in Condition/Response blocks. The fix injects block outputs as JavaScript variables using their normalized names (e.g., Key changes:
The implementation properly handles edge cases with reserved word filtering and duplicate name checking. This enables the standard workflow pattern of HITL → Condition → downstream blocks that was previously broken. Confidence Score: 4/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant User as User Code
participant RCV as resolveCodeVariables()
participant RTV as resolveTagVariables()
participant IBV as injectBlockVariables()
participant Context as contextVariables
participant IVM as Isolated VM
User->>RCV: Execute condition code
RCV->>RTV: Resolve variables
RTV->>IBV: Inject block variables
IBV->>IBV: Check RESERVED_IDENTIFIERS
IBV->>IBV: Check existing context vars
IBV->>Context: Add humanApproval = blockData[blockId]
Context-->>RTV: Variables injected
RTV->>RTV: Resolve angle bracket tags
RTV-->>RCV: Code resolved
RCV->>IVM: Execute with contextVariables
IVM->>User: humanApproval.approved accessible
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 file reviewed, 1 comment
|
This is a great approach! The logic in this specific section lookg super clean! I am new to this language. Why was this technique chosen for this project? |
Summary
Inject block outputs as js variables by their normalized names, allowing users to reference blocks directly without requiring angle bracket syntax in condition expressions.
fixes hitl blocks where canvas labels like
humanApprovalwere not accessible in condition blocksFixes #2962
Type of Change
Testing
Checklist