Skip to content

Round-trip the prompt action type through the flow builder - #4481

Merged
madurangasiriwardena merged 1 commit into
thunder-id:mainfrom
madurangasiriwardena:flows/action-type-round-trip
Aug 1, 2026
Merged

Round-trip the prompt action type through the flow builder#4481
madurangasiriwardena merged 1 commit into
thunder-id:mainfrom
madurangasiriwardena:flows/action-type-round-trip

Conversation

@madurangasiriwardena

@madurangasiriwardena madurangasiriwardena commented Jul 31, 2026

Copy link
Copy Markdown
Member

Purpose

prompts[].action.type is write-only in the console. Serialization emits it from the button element's actionType, but the load path never reads it back, and FlowNodeAction does not even declare the field. A flow definition authored outside the flow builder therefore loses its action type the first time the flow is saved, and the Action selector shows the wrong option for it in the meantime.

That makes a hand-authored sign-out flow silently regress into an endless confirmation loop after an unrelated edit in the builder, and it discards the SUBMIT and REJECT action types the API documents.

Approach

Restore the type on load. restoreButtonAction already receives the matching prompt action, so it backfills actionType onto the element, and FlowNodeAction now declares type. The element wins when it already carries a type: an unwired button holds the only copy, because a prompt action is emitted only once the button has a nextNode.

Clear only the type the selector owns. Picking a plain action previously wiped any actionType, so an action type with no option in the dropdown was discarded on the next save. It is now cleared only when it was the sign-out value.

Key the option on the persisted value. The Sign out option used a UI-only SIGN_OUT sentinel that never left the component, while the flow definition stored SIGN_OUT_CONFIRM. The option is now keyed on PromptActionTypes.SignOutConfirm, so the value selected in the editor and the value in the flow definition are one vocabulary.

Align the option label. Trigger Signout becomes Sign Out Action, matching the Submit Form and Trigger Action options beside it.

Related Issues

  • N/A

Related PRs

Checklist

  • Followed the contribution guidelines.
  • Manual test round performed and verified.
  • Documentation provided. (Add links if there are any)
    • Ran Vale and fixed all errors and warnings
  • Tests provided. (Add links if there are any)
    • Unit Tests
    • Integration Tests
  • Breaking changes. (Fill if applicable)
    • Breaking changes section filled.
    • breaking change label added.

Security checks

  • Followed secure coding standards in WSO2 Secure Coding Guidelines
  • Confirmed that this PR doesn't commit any keys, passwords, tokens, usernames, or other secrets.

Summary by CodeRabbit

  • Bug Fixes

    • Preserved existing button actions when changing trigger types.
    • Restored button action types correctly when loading and serializing flows.
    • Ensured sign-out actions retain their correct value across flow edits and reloads.
  • UI Updates

    • Renamed the button action label from “Trigger Signout” to “Sign Out Action.”
  • Tests

    • Added coverage for action preservation and flow round-trip behavior.

@madurangasiriwardena madurangasiriwardena added Type/Improvement trigger-pr-builder Add when the PR is ready for CI; starts the PR Builder for this and all later pushes labels Jul 31, 2026
@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: c4c71a70-7347-4770-8fae-e19273e4933f

📥 Commits

Reviewing files that changed from the base of the PR and between 293335b and d8972e7.

📒 Files selected for processing (6)
  • frontend/apps/console/src/features/flows/components/resource-property-panel/extended-properties/ButtonExtendedProperties.tsx
  • frontend/apps/console/src/features/flows/components/resource-property-panel/extended-properties/__tests__/ButtonExtendedProperties.test.tsx
  • frontend/apps/console/src/features/flows/models/responses.ts
  • frontend/apps/console/src/features/flows/utils/__tests__/flowToCanvasTransformer.test.ts
  • frontend/apps/console/src/features/flows/utils/flowToCanvasTransformer.ts
  • frontend/packages/i18n/src/locales/en-US.ts
🚧 Files skipped from review as they are similar to previous changes (6)
  • frontend/apps/console/src/features/flows/models/responses.ts
  • frontend/packages/i18n/src/locales/en-US.ts
  • frontend/apps/console/src/features/flows/utils/flowToCanvasTransformer.ts
  • frontend/apps/console/src/features/flows/components/resource-property-panel/extended-properties/tests/ButtonExtendedProperties.test.tsx
  • frontend/apps/console/src/features/flows/components/resource-property-panel/extended-properties/ButtonExtendedProperties.tsx
  • frontend/apps/console/src/features/flows/utils/tests/flowToCanvasTransformer.test.ts

📝 Walkthrough

Walkthrough

Adds semantic action type persistence and restoration for flow buttons. Plain action changes preserve unrelated action types. The sign-out selector value and label are updated. Transformation and component tests cover the behavior.

Changes

Button action type preservation

Layer / File(s) Summary
Model and transformation restoration
frontend/apps/console/src/features/flows/models/responses.ts, frontend/apps/console/src/features/flows/utils/flowToCanvasTransformer.ts, frontend/apps/console/src/features/flows/utils/__tests__/flowToCanvasTransformer.test.ts
FlowNodeAction now carries an optional type. Button restoration backfills missing actionType values and preserves existing values. Tests cover omission, precedence, and round-trip serialization.
Selector value and preservation rules
frontend/apps/console/src/features/flows/components/resource-property-panel/extended-properties/ButtonExtendedProperties.tsx, frontend/apps/console/src/features/flows/components/resource-property-panel/extended-properties/__tests__/ButtonExtendedProperties.test.tsx, frontend/packages/i18n/src/locales/en-US.ts
The sign-out option uses PromptActionTypes.SignOutConfirm. Plain actions clear only sign-out confirmation types. The menu label changes to “Sign Out Action”. Tests verify preservation of REJECT.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

Suggested reviewers: jeradrutnam, brionmario, thamindudilshan

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes preserving prompt action types through flow builder round trips.
Description check ✅ Passed The description includes the required purpose, approach, related links, checklist, and security sections, with clear implementation details.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

frontend/apps/console/src/features/flows/components/resource-property-panel/extended-properties/ButtonExtendedProperties.tsx

ESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox.

frontend/apps/console/src/features/flows/components/resource-property-panel/extended-properties/__tests__/ButtonExtendedProperties.test.tsx

ESLint skipped: the ESLint configuration for this file references a package that is not available in the sandbox.

frontend/apps/console/src/features/flows/models/responses.ts

ESLint skipped: the ESLint configuration for this file references a package that is not available in the sandbox.

  • 3 others

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Jul 31, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

// it from and where serialization projects it back out of. Only when the element does not
// already carry one: an unwired button keeps its type on the element alone, since a prompt
// action is only emitted once the button has a nextNode.
...(matchingAction.type && component.actionType === undefined ? {actionType: matchingAction.type} : {}),

@DonOmalVindula DonOmalVindula Aug 1, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
...(matchingAction.type && component.actionType === undefined ? {actionType: matchingAction.type} : {}),
...(matchingAction.type && !component.actionType ? {actionType: matchingAction.type} : {}),

The selector clears with onChange('actionType', '', resource), and since the component cleaner here doesn't strip actionType, the '' gets persisted into meta.components. The new guard here checks component.actionType === undefined, so a component loaded with actionType: '' blocks the backfill even though the empty string means no type.

The prompt action's type was write-only in the console: serialization emitted
prompts[].action.type from the button element's actionType, but the load path
never read it back and FlowNodeAction did not even declare the field. A flow
definition authored outside the builder therefore lost its action type on the
first save, and the Action selector showed the wrong option for it.

Restore the type onto the element when a definition is loaded, so the property
panel can display it and serialization emits it again. The element wins when it
already carries a type, because an unwired button holds the only copy: a prompt
action is emitted only once the button has a nextNode.

Clear only the type the selector owns when the author picks a plain action.
SUBMIT and REJECT are documented prompt action types with no option in the
dropdown, and blanket clearing discarded them.

Key the Sign out option on SIGN_OUT_CONFIRM rather than a UI-only SIGN_OUT
sentinel, so the value selected in the editor and the value in the flow
definition are one vocabulary, and label it Sign Out Action to match the
Submit Form and Trigger Action options beside it.

Refs thunder-id#4299
@madurangasiriwardena
madurangasiriwardena force-pushed the flows/action-type-round-trip branch from 293335b to d8972e7 Compare August 1, 2026 09:35
@madurangasiriwardena
madurangasiriwardena added this pull request to the merge queue Aug 1, 2026
Merged via the queue into thunder-id:main with commit 1b65c96 Aug 1, 2026
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

trigger-pr-builder Add when the PR is ready for CI; starts the PR Builder for this and all later pushes Type/Improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants