Conversation
Extract repeated pattern of action mode extraction into a helper function GetActionModeFromWorkflowData() to improve code clarity and reduce duplication across all four engine MCP renderers (Copilot, Claude, Codex, Custom). Changes: - Add GetActionModeFromWorkflowData() helper to action_mode.go - Simplify createRenderer closures in all four engine files - Reduce 4-line conditional blocks to single function calls - Maintain identical functionality with cleaner code This simplification reduces 16 lines of duplicate code across 4 files while preserving exact behavior and improving maintainability.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR simplifies code by extracting a repeated 4-line pattern into a single helper function, improving maintainability while preserving all functionality. The refactoring addresses code duplication introduced in PR #13974, which added ActionMode propagation to MCP renderers.
Changes:
- Added
GetActionModeFromWorkflowData()helper function to centralize action mode extraction logic - Updated all four engine MCP renderers (Copilot, Claude, Codex, Custom) to use the new helper
- Reduced 16 lines of duplicate code to 8 lines total (1 helper + 4 single-line calls)
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/workflow/action_mode.go | Added GetActionModeFromWorkflowData() helper function with nil-check and default to dev mode |
| pkg/workflow/copilot_mcp.go | Simplified createRenderer closure to use helper function instead of inline nil-check |
| pkg/workflow/claude_mcp.go | Simplified createRenderer closure to use helper function instead of inline nil-check |
| pkg/workflow/codex_mcp.go | Simplified createRenderer closure to use helper function instead of inline nil-check |
| pkg/workflow/custom_engine.go | Simplified createRenderer closure to use helper function instead of inline nil-check |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This was referenced Feb 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Code Simplification - 2026-02-05
This PR simplifies recently modified code to improve clarity, consistency, and maintainability while preserving all functionality.
Files Simplified
pkg/workflow/action_mode.go- AddedGetActionModeFromWorkflowData()helper functionpkg/workflow/copilot_mcp.go- SimplifiedcreateRendererclosure to use helperpkg/workflow/claude_mcp.go- SimplifiedcreateRendererclosure to use helperpkg/workflow/codex_mcp.go- SimplifiedcreateRendererclosure to use helperpkg/workflow/custom_engine.go- SimplifiedcreateRendererclosure to use helperImprovements Made
Reduced Duplication
Enhanced Clarity
createRendererclosuresApplied Project Standards
Changes Based On
Recent changes from:
Testing
The changes are purely structural and preserve exact functionality:
Review Focus
Please verify:
Context: This simplification addresses code duplication introduced in PR #13974, which added
ActionModepropagation to MCP renderers. All four engine files (Copilot, Claude, Codex, Custom) had identical 4-line blocks for extracting action mode from workflow data. This PR consolidates that logic into a single, reusable helper function.Benefits:
Testing Strategy: Since this is a pure refactoring with no behavioral changes, the existing test suite validates correctness. The helper function uses the same logic (nil check with default to
ActionModeDev) that was previously inline in each file.