Emit WFWorkflow dict in run() codegen#193
Conversation
The runworkflow action requires a structured WFWorkflow dict (`workflowIdentifier`, `workflowName`, `isSelf`) to bind the target shortcut. Without it the action silently halts every subsequent action. Cherri previously emitted only `WFInput` + `WFWorkflowName` from the DSL-defined `run` action. Moves `run` to a Go-side definition with an `appendParamsFunc` that injects the WFWorkflow dict at compile time, sourcing `workflowName` from the first argument. Adds a compile-only regression test asserting the dict appears in the output plist with the expected shape. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
electrikmilk
left a comment
There was a problem hiding this comment.
Thanks for tackling this! This is a pretty sore spot and makes me want to focus on improving our Shortcuts actions.
Just a few changes, otherwise this looks good.
| resetParser() | ||
| } | ||
|
|
||
| func TestRunWorkflowEmitsWFWorkflowDict(t *testing.T) { |
There was a problem hiding this comment.
Please remove this test and only keep the Cherri one; it matters more that the raw action compiles correctly.
| }, | ||
| }, | ||
| // The runtime requires a WFWorkflow dict to bind the target shortcut; | ||
| // without it the action silently halts every subsequent action. |
There was a problem hiding this comment.
We don't include this elsewhere when adding params, please remove the "what" comment per CONTRIBUTING.md:
Only put comments in code to explain why something does something, not what it is doing. Your code should be readable enough that it is obvious to anyone reading it.
You may have written this using Claude before the more recent updates to the project, where CLAUDE.md or AGENTS.md were added. In the future, make sure they read them, as they explain the quirks of the project and require them to read the CONTRIBUTING document.
| var name = getArgValue(args[0]).(string) | ||
| return map[string]any{ | ||
| "WFWorkflow": map[string]any{ | ||
| "workflowIdentifier": uuid.New().String(), | ||
| "isSelf": false, | ||
| "workflowName": name, | ||
| }, | ||
| } |
There was a problem hiding this comment.
We need to account for the fact that Shortcuts allows variables for this parameter.
| var name = getArgValue(args[0]).(string) | |
| return map[string]any{ | |
| "WFWorkflow": map[string]any{ | |
| "workflowIdentifier": uuid.New().String(), | |
| "isSelf": false, | |
| "workflowName": name, | |
| }, | |
| } | |
| if args[0].valueType == Variable { | |
| return map[string]any{ | |
| "WFWorkflow": argumentValue(args, 0), | |
| } | |
| } | |
| var name = getArgValue(args[0]).(string) | |
| return map[string]any{ | |
| "WFWorkflow": map[string]any{ | |
| "workflowIdentifier": uuid.New().String(), | |
| "isSelf": false, | |
| "workflowName": name, | |
| }, | |
| } |
| return | ||
| }, | ||
| }, | ||
| "run": { |
There was a problem hiding this comment.
Can you please move this action to be next to the runSelf() action for convenience sake?
| }, | ||
| // The runtime requires a WFWorkflow dict to bind the target shortcut; | ||
| // without it the action silently halts every subsequent action. | ||
| appendParamsFunc: func(args []actionArgument) map[string]any { |
There was a problem hiding this comment.
Please additionally apply this fix to runSelf(). That should probably be unified into a function that returns parameters that they both use similarly to other actions in this file.
Summary
The
runworkflowaction requires a structuredWFWorkflowdict to bind the target shortcut. Without it the action silently halts every subsequent action in the workflow.Cherri previously emitted only
WFInput+WFWorkflowNamefrom the DSL-definedrunaction. This PR movesrunto a Go-side definition with anappendParamsFuncthat injects theWFWorkflowdict at compile time, sourcingworkflowNamefrom the first argument.Changes
actions_std.go: Newrunentry withappendParamsFuncemitting{workflowIdentifier, workflowName, isSelf}actions/shortcuts.cherri: Remove the now-redundant DSL definition forruntests/zz-run-workflow.cherri: New compile-only test inputcherri_test.go: NewTestRunWorkflowEmitsWFWorkflowDictasserting the dict appears in the output plist with the expected shapeTest plan
go test -run TestRunWorkflowEmitsWFWorkflowDictpassesgo test -run TestCherriNoSignpasses (no regressions across 50+ test files)🤖 Generated with Claude Code