Skip to content

feat: Make markdoc signal/start button params optional via page context#1251

Open
Bueller87 wants to merge 8 commits intocadence-workflow:masterfrom
Bueller87:make-context-optional
Open

feat: Make markdoc signal/start button params optional via page context#1251
Bueller87 wants to merge 8 commits intocadence-workflow:masterfrom
Bueller87:make-context-optional

Conversation

@Bueller87
Copy link
Copy Markdown
Contributor

@Bueller87 Bueller87 commented Apr 16, 2026

What changed

  • Added a MarkdownPageContext React context that carries domain, cluster, workflowId, and runId from the page into the Markdown renderer.
  • The Markdown component now accepts optional page param props and wraps its output in a MarkdownPageContextProvider.
  • SignalButton and StartWorkflowButton markdoc components fall back to page context when their tag attributes are omitted. Explicit attributes still take priority.
  • WorkflowQueriesResult now pass page params through to <Markdown>.
  • The markdoc schemas for {% start %} updated domain and cluster from required: true to required: false.
  • Updated /docs markdown guide: restructured with minimal-first examples, added attribute reference tables for both tags, and ensured code fence examples match their live rendered counterparts.
  • Added a "Markdown in Queries" section to README.md pointing to the /docs reference 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.md

Why

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 (see cadence-samples/new_samples/query/markdown_query.go).

With this change, a signal button simplifies from:

{% signal signalName="complete" label="Complete" domain="my-domain" cluster="cluster0" workflowId="wf-123" runId="run-456" input=true /%}

to:

{% signal signalName="complete" label="Complete" input=true /%}

How to test

  1. Run npx jest --watchman=false --no-coverage src/components/markdown/__tests__/markdoc.test.tsx — all 12 tests should pass (3 new context inheritance tests).
  2. Start the dev server (npm run dev) and visit http://localhost:8088/docs — verify the guide renders correctly with live buttons only on explicit examples and no disabled buttons.
  3. If you have a running Cadence backend with a workflow that returns markdown query results, navigate to a workflow's Queries tab and verify signal/start buttons work without explicit domain/cluster/workflowId/runId in the markdown.

Risks

  • Low: No API or route changes. The context defaults to an empty object {}, so existing markdoc tags with explicit attributes are unaffected — the ?? fallback only activates when a prop is undefined.
  • Low: The StartWorkflowButton markdoc schema changed domain/cluster from required: true to required: 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.
  • None: Backward-compatible. All existing markdown content that specifies explicit params continues to work identically.

Fixes #1141

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>
@gitar-bot
Copy link
Copy Markdown

gitar-bot Bot commented Apr 16, 2026

CI failed: The CI build failed due to an ESLint import ordering violation and a missing conventional commit prefix in the pull request title.

Overview

The 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.

Failures

Linting Violation (confidence: high)

  • Type: build
  • Affected jobs: 71653654865
  • Related to change: yes
  • Root cause: The import/order ESLint rule was violated in one of the modified files.
  • Suggested fix: Reorder the imports in the affected file to ensure correct positioning of local module imports, specifically ensuring standard paths precede relative ones as per project standards.

Invalid PR Title (confidence: high)

  • Type: configuration
  • Affected jobs: 71653652675
  • Related to change: yes
  • Root cause: The PR title "Make context optional" lacks a required semantic prefix (e.g., feat:, fix:, chore:).
  • Suggested fix: Rename the PR title to conform to the Conventional Commits specification (e.g., "feat: make context optional").

Summary

  • Change-related failures: 2 (one linting error, one PR configuration error).
  • Infrastructure/flaky failures: 0
  • Recommended action: Update the PR title with a valid semantic prefix and fix the import order in the source code to resolve the linting failure.
Code Review 👍 Approved with suggestions 0 resolved / 1 findings

Makes 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 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"
🤖 Prompt for agents
Code Review: Makes the context parameter optional as intended. Please correct the trailing double-quote typo found in the markdown guide label attribute.

1. 💡 Bug: Double-quote typo in markdown guide label attribute
   Files: src/views/docs/markdown/markdown-guide.ts:91

   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"

Tip

Comment Gitar fix CI or enable auto-apply: gitar auto-apply:on

Options

Auto-apply is off → Gitar will not commit updates to this branch.
Display: compact → Showing less information.

Comment with these commands to change:

Auto-apply Compact
gitar auto-apply:on         
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Gitar

{% start
workflowType="cadence_samples.ConfiguredWorkflow"
label="Start with Config"
label="Start Workflow""
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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

@Bueller87 Bueller87 changed the title Make context optional feat: Make markdoc signal/start button params optional via page context Apr 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve Markdown Queries

1 participant