Add inline #question syntax for import questions#154
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds support for inline #question "prompt" import-question arguments (with optional default) so App Intent entity parameters can trigger native pickers at install time, while preserving legacy #question var syntax. It also adjusts third-party action identifier handling to avoid incorrectly prefixing identifiers that already include a bundle-style namespace.
Changes:
- Parse inline
#question "prompt"(and optional"default") as an argument value type and collect those questions during generation. - Make legacy
#questiondefault values optional and omitDefaultValuefrom plist when absent. - Fix action identifier dot-threshold logic for deciding when to treat a quoted identifier as a full override.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| token.go | Introduces InlineQuestion value type and inlineQuestionValue container. |
| parser.go | Adds inline #question parsing in collectValue() and makes legacy #question default optional. |
| action.go | Collects inline questions during action generation; skips emitting params for question-backed arguments; adjusts dot-threshold. |
| shortcutgen.go | Generates import questions after actions; merges legacy+inline; omits DefaultValue when empty; resets inlineQuestions. |
| cherri_test.go | Resets inlineQuestions between tests to avoid cross-test leakage. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
I touched on this in another comment, but it would be more efficient to modify the existing import question implementation to allow generating the definition and using it it then and there. We have a global |
|
This is a neat idea! Makes me wonder if we should consider refactoring import questions to only support argument syntax since they can only ever be used once in one action argument based on their action index configuration. |
| shortcut.WFWorkflowOutputContentItemClasses = generateOutputContentItems() | ||
| }, | ||
| func() { | ||
| shortcut.WFWorkflowImportQuestions = generateImportQuestions() |
There was a problem hiding this comment.
I think I understand we need to generate actions first, I'd prefer if we didn't need to, though
There was a problem hiding this comment.
Yeah, inline questions were being collected during makeAction() so it had to run after. I'm moving the resolution into questionArg() now which is cleaner. The ordering might still need to stay this way since questionArg() runs during the same pass, but I'll see if I can avoid it 🙌
There was a problem hiding this comment.
We should be able to move this back now that we derive the action index in questionArg().
There was a problem hiding this comment.
I tested this with your branch, and putting this back into the concurrent generation is fine since we already have the actionIndex from questionArg().
@electrikmilk Thanks! Yeah I'd be down to explore deprecating the variable syntax in a follow-up if you want to go that direction 🚀 |
530c10b to
353abac
Compare
353abac to
1dec942
Compare
|
Should all be resolved now. Take a look whenever you aren't busy. :) |
1dec942 to
7cfe667
Compare
|
@electrikmilk Bump :) |
7cfe667 to
0179346
Compare
electrikmilk
left a comment
There was a problem hiding this comment.
The questions can be generated concurrently before the actions due to the index being set on the argument collection.
0179346 to
1c270ca
Compare
1c270ca to
c02427c
Compare
Summary
Adds support for declaring import questions directly inside action arguments using inline
#question "prompt"syntax. This is useful for third-party App Intent entity parameters (Notion databases, Slack channels, WhatsApp contacts, etc.) where Shortcuts shows the app's native picker at install time.Before — only variable-style questions with required default:
After — inline syntax, default value optional:
The compiler resolves the correct
ActionIndexandParameterKeyautomatically since the question is positionally bound to the parameter. The legacy#questionvariable syntax continues to work, and default values are now optional for both forms.Also fixes third-party action identifiers like
notion.id.CreatePageWithoutOpenIntentbeing incorrectly prefixed withis.workflow.actions.(dot-count threshold changed from< 4to< 3).Changes
token.go— AddInlineQuestionvalue type andinlineQuestionValuestructparser.go— Parse inline#question "prompt"incollectValue(), make default value optional for legacy#questionaction.go— Collect inline questions inmakeAction()with correct action index from generated output; skip inmakeActionParams(); fix identifier dot thresholdshortcutgen.go— MovegenerateImportQuestions()aftergenerateActions(); merge legacy and inline questions; addomitemptyonDefaultValue; resetinlineQuestionsinresetShortcutGen()cherri_test.go— ResetinlineQuestionsinresetParser()Testing
#questionfor the database parameter — produced correct plist withActionIndex: 6,ParameterKey: "database", noDefaultValue