Skip to content

fix(pou): show return type selector for graphical function POUs#954

Open
emerson-d-lopes wants to merge 2 commits into
Autonomy-Logic:developmentfrom
emerson-d-lopes:bugfix/gh-696-function-return-type-graphical
Open

fix(pou): show return type selector for graphical function POUs#954
emerson-d-lopes wants to merge 2 commits into
Autonomy-Logic:developmentfrom
emerson-d-lopes:bugfix/gh-696-function-return-type-graphical

Conversation

@emerson-d-lopes

@emerson-d-lopes emerson-d-lopes commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Pull request info

References

This PR resolves #696.

Link to Jira task

External contribution — no Jira access; branch follows the bugfix/gh-<n>-<slug> convention from CONTRIBUTING.md.

Description of the changes proposed

  • The return type selector in the variables editor was rendered only when editor.type === 'plc-textual', so functions written in FBD, LD, or SFC had no way to select their return type (the field simply never appeared, as reported in Function Definition - Return Type Cannot Be Selected in FDB #696).
  • Everything below the UI already supports graphical function return types: projectActions.updatePouReturnType is language-agnostic, createPouObject defaults new functions to BOOL, and the ST transpiler emits FUNCTION <name> : <returnType> for graphical POUs (emit/pou-graphical.ts). The selector's render condition was the only gap.
  • Extended the condition to (editor.type === 'plc-textual' || editor.type === 'plc-graphical') && editor.meta.pouType === 'function'. Both editor model variants carry the same meta.pouType shape, so TypeScript narrowing is unaffected.
  • Added a component test (return-type-visibility.test.tsx, 5 cases): selector visible for FBD, LD, and ST functions; absent for an FBD program and an FBD function block. The FBD and LD cases fail without the fix and pass with it.

DOD checklist

  • The code is complete and according to developers' standards.
  • I have performed a self-review of my code.
  • Meet the acceptance criteria.
  • Unit tests are written and green.
  • Test coverage: components are outside the enforced coverage directories; full suite passes (5324 tests, the 4 pre-existing board-info-resolver failures on Windows are unrelated and fail on a clean checkout too).
  • Integration tests are written and green. (N/A — UI-only change; no integration surface.)
  • Changes were communicated and updated in the ticket description. (External contribution — GitHub issue referenced instead.)
  • Reviewed and accepted by the Product Owner.
  • End-to-end test are successful. (Repo's Playwright setup currently contains only the example spec.)

🤖 Generated with Claude Code

https://claude.ai/code/session_01U5TQ1y3yBEDx73tYTHoUBj

Summary by CodeRabbit

  • New Features

    • The Variables Editor now displays the Return type selector for function POUs in both textual and graphical programming editors.
  • Bug Fixes

    • Return type selector visibility is corrected (hidden for non-function POUs where it doesn’t apply).
  • Tests

    • Added automated coverage verifying Return type visibility across supported language modes and POU types, including accessibility labeling/trigger behavior.

The return type selector in the variables editor was gated on
editor.type === 'plc-textual', so functions written in FBD, LD, or SFC
had no way to select their return type even though the store action,
POU creation defaults, and the ST transpiler already fully support
return types for graphical functions.

Extend the condition to include 'plc-graphical'. Add a component test
covering the selector's visibility for FBD/LD/ST functions and its
absence for programs and function blocks.

Fixes Autonomy-Logic#696

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01U5TQ1y3yBEDx73tYTHoUBj
@coderabbitai

coderabbitai Bot commented Jul 22, 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: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: d095bae0-d1a6-423b-9807-7970203a16a6

📥 Commits

Reviewing files that changed from the base of the PR and between 130585a and 48dd93a.

📒 Files selected for processing (2)
  • src/frontend/components/_organisms/variables-editor/__tests__/return-type-visibility.test.tsx
  • src/frontend/components/_organisms/variables-editor/index.tsx
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/frontend/components/_organisms/variables-editor/tests/return-type-visibility.test.tsx
  • src/frontend/components/_organisms/variables-editor/index.tsx

Walkthrough

The VariablesEditor now shows the “Return type” control for function POUs in graphical editors. Tests cover visibility across supported languages and confirm it remains hidden for programs and function blocks.

Changes

Return type selector visibility

Layer / File(s) Summary
Return type control and coverage
src/frontend/components/_organisms/variables-editor/index.tsx, src/frontend/components/_organisms/variables-editor/__tests__/return-type-visibility.test.tsx
Function POUs now expose the return type control in textual and graphical editors, with updated selector identifiers and visibility tests.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested labels: enhancement

Suggested reviewers: joaogsp

Poem

A rabbit hops through FBD,
Return types now appear with glee.
LD and ST join the cheer,
Hidden for programs far and near.
Tests nibble bugs away—
Hoppy coding day!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly states the main change: showing the return type selector for graphical function POUs.
Description check ✅ Passed The description follows the template with issue reference, change summary, and a DOD checklist.
Linked Issues check ✅ Passed The code addresses #696 by making the return type selector visible for function POUs, including graphical editors.
Out of Scope Changes check ✅ Passed The added tests and ID/label alignment are directly related to the selector visibility fix and its accessibility.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ 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.

ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration.


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.

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@src/frontend/components/_organisms/variables-editor/__tests__/return-type-visibility.test.tsx`:
- Around line 11-14: Extend the createPou helper and its language type to accept
sfc, then add a separate SFC fixture/test covering return-type visibility
alongside the existing FBD and LD cases. Preserve the ST test independently
rather than replacing it, so both textual and SFC coverage remain.

In `@src/frontend/components/_organisms/variables-editor/index.tsx`:
- Line 1055: Update the return-type selector rendered by the
plc-textual/plc-graphical function branch to use a dedicated matching ID, such
as return-type, on its SelectTrigger and associated label htmlFor; preserve the
existing class-filter ID for the class filter, and add a test assertion
verifying the return-type control is correctly associated.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 9342d035-fa1a-414d-ab53-0cdf1ea9a2a5

📥 Commits

Reviewing files that changed from the base of the PR and between 9e6e025 and 130585a.

📒 Files selected for processing (2)
  • src/frontend/components/_organisms/variables-editor/__tests__/return-type-visibility.test.tsx
  • src/frontend/components/_organisms/variables-editor/index.tsx

Comment thread src/frontend/components/_organisms/variables-editor/index.tsx
@emerson-d-lopes

emerson-d-lopes commented Jul 22, 2026

Copy link
Copy Markdown
Contributor Author

Verified the fix end-to-end in the running app (production build, Playwright driving the real Electron window): created a project, created a Function POU with FBD language, and confirmed the Return type : selector now renders in the variables panel, opens with the full IEC type list, and persists a selection (changed BOOL to INT). Before the fix the same flow shows no return type field, matching the issue report.

Return type selector visible for the FBD function (the field this issue reports missing):
return type visible

Dropdown opens with the full IEC type list:
dropdown open

Selection persists (INT):
int selected

Address review feedback: the return type SelectTrigger reused the
class filter's id ("class-filter"), producing duplicate ids when both
render, and the label's htmlFor pointed at nothing. Use a dedicated
"return-type" id wired to the label, assert the association in a test,
and add an SFC function case alongside FBD/LD/ST.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01U5TQ1y3yBEDx73tYTHoUBj
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.

Function Definition - Return Type Cannot Be Selected in FDB

1 participant