feat: Make markdoc signal/start button params optional via page context#1251
feat: Make markdoc signal/start button params optional via page context#1251Bueller87 wants to merge 8 commits intocadence-workflow:masterfrom
Conversation
Introduce a React context that allows markdoc components (signal/start buttons) to inherit domain, cluster, workflowId, and runId from the page instead of requiring them as explicit tag attributes. Signed-off-by: “Kevin” <kevlar_ksb@yahoo.com>
Accept optional domain, cluster, workflowId, and runId props and provide them to child markdoc components via MarkdownPageContextProvider. Signed-off-by: “Kevin” <kevlar_ksb@yahoo.com>
Use useMarkdownPageParams() so signal buttons inherit domain, cluster, workflowId, and runId from the page when not specified as tag attributes. Signed-off-by: “Kevin” <kevlar_ksb@yahoo.com>
Make domain and cluster optional in the markdoc schema, types, and component, using useMarkdownPageParams() as the fallback source. Signed-off-by: “Kevin” <kevlar_ksb@yahoo.com>
Provide domain, cluster, workflowId, and runId to <Markdown> from WorkflowQueriesResult and Blocks so markdoc buttons can inherit context. Signed-off-by: “Kevin” <kevlar_ksb@yahoo.com>
Verify signal and start workflow buttons receive page params from Markdown context, and that explicit tag attributes take priority. Signed-off-by: “Kevin” <kevlar_ksb@yahoo.com>
Signed-off-by: “Kevin” <kevlar_ksb@yahoo.com>
Signed-off-by: “Kevin” <kevlar_ksb@yahoo.com>
CI failed: The CI build failed due to an ESLint import ordering violation and a missing conventional commit prefix in the pull request title.OverviewThe build failed due to two distinct issues: a linting error triggered by incorrect import ordering and a configuration error because the PR title does not comply with conventional commit standards. FailuresLinting Violation (confidence: high)
Invalid PR Title (confidence: high)
Summary
Code Review 👍 Approved with suggestions 0 resolved / 1 findingsMakes the context parameter optional as intended. Please correct the trailing double-quote typo found in the markdown guide label attribute. 💡 Bug: Double-quote typo in markdown guide label attribute📄 src/views/docs/markdown/markdown-guide.ts:91 Line 91 of the markdown guide has Suggested fix🤖 Prompt for agentsTip Comment OptionsAuto-apply is off → Gitar will not commit updates to this branch. Comment with these commands to change:
Was this helpful? React with 👍 / 👎 | Gitar |
| {% start | ||
| workflowType="cadence_samples.ConfiguredWorkflow" | ||
| label="Start with Config" | ||
| label="Start Workflow"" |
There was a problem hiding this comment.
💡 Bug: Double-quote typo in markdown guide label attribute
Line 91 of the markdown guide has label="Start Workflow"" with an extra trailing double-quote. Markdoc may fail to parse this tag correctly or render it with an unexpected label, which would break the live example on the /docs page.
Suggested fix:
Change:
label="Start Workflow""
To:
label="Start Workflow"
Was this helpful? React with 👍 / 👎 | Reply gitar fix to apply this suggestion
What changed
MarkdownPageContextReact context that carriesdomain,cluster,workflowId, andrunIdfrom the page into the Markdown renderer.Markdowncomponent now accepts optional page param props and wraps its output in aMarkdownPageContextProvider.SignalButtonandStartWorkflowButtonmarkdoc components fall back to page context when their tag attributes are omitted. Explicit attributes still take priority.WorkflowQueriesResultnow pass page params through to<Markdown>.{% start %}updateddomainandclusterfromrequired: truetorequired: false./docsmarkdown guide: restructured with minimal-first examples, added attribute reference tables for both tags, and ensured code fence examples match their live rendered counterparts.README.mdpointing to the/docsreference page.Files changed (12):
markdown-page-context.tsx(new),markdown.tsx,markdown.types.tsx,signal-button.tsx,start-workflow-button.tsx,start-workflow-button.types.ts,start-workflow-button.markdoc.ts,blocks.tsx,workflow-queries-result.tsx,markdoc.test.tsx,markdown-guide.ts,README.mdWhy
Workflow queries can return markdown with
{% signal %}and{% start %}buttons, but previously all params (domain,cluster,workflowId,runId) had to be explicitly specified in every tag — even though the page already knows them from the URL. This forced workflow authors to cache and template these values into their query responses (seecadence-samples/new_samples/query/markdown_query.go).With this change, a signal button simplifies from:
to:
How to test
npx jest --watchman=false --no-coverage src/components/markdown/__tests__/markdoc.test.tsx— all 12 tests should pass (3 new context inheritance tests).npm run dev) and visithttp://localhost:8088/docs— verify the guide renders correctly with live buttons only on explicit examples and no disabled buttons.domain/cluster/workflowId/runIdin the markdown.Risks
{}, so existing markdoc tags with explicit attributes are unaffected — the??fallback only activates when a prop isundefined.StartWorkflowButtonmarkdoc schema changeddomain/clusterfromrequired: truetorequired: false. Markdoc validates at parse time, so existing tags that already specify these attributes are unaffected. Tags that omit them will now parse successfully instead of erroring.Fixes #1141