-
Notifications
You must be signed in to change notification settings - Fork 46
Bug RHOAIENG-39115: Preserve command order from frontmatter #535
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Bug RHOAIENG-39115: Preserve command order from frontmatter #535
Conversation
Fixes issue where slash commands render alphabetically instead of the order specified in the custom workflow template. Changes: - Added 'order' field parsing from command frontmatter - Implemented sorting logic to honor order field in command list - Commands without order field default to MaxInt (appear at end) - Alphabetical fallback when orders are equal for consistency - Fully backward compatible with existing workflows The backend now sorts commands by their 'order' field before returning them to the frontend, ensuring commands display in the intended sequence rather than filesystem/alphabetical order. Commands can now specify order in frontmatter like: --- displayName: "Create RFE" description: "Start RFE creation process" order: 1 --- Co-Authored-By: Claude (claude-sonnet-4-5) <noreply@anthropic.com>
Claude Code ReviewSummaryPR #535 adds support for ordering slash commands in the dashboard UI via an Issues by Severity🔴 Critical Issues1. MaxInt Calculation Could Be Simplified (Go 1.18+)
// Current (complex)
order := int(^uint(0) >> 1)
// Better (Go 1.17+)
import "math"
order := math.MaxInt🟡 Major Issues2. Redundant Type Assertions in Sort Function
// Current (unnecessary type checking)
sort.Slice(commands, func(i, j int) bool {
iOrder, iOk := commands[i]["order"].(int)
jOrder, jOk := commands[j]["order"].(int)
if !iOk {
iOrder = int(^uint(0) >> 1) // Dead code - always succeeds
}
if !jOk {
jOrder = int(^uint(0) >> 1) // Dead code - always succeeds
}
// ...
})
// Better (remove dead code)
sort.Slice(commands, func(i, j int) bool {
iOrder := commands[i]["order"].(int)
jOrder := commands[j]["order"].(int)
if iOrder == jOrder {
iID := commands[i]["id"].(string)
jID := commands[j]["id"].(string)
return iID < jID
}
return iOrder < jOrder
})3. Missing Error Logging for Invalid Order Values
if orderStr := metadata["order"]; orderStr != "" {
if parsed, err := strconv.Atoi(orderStr); err == nil {
order = parsed
} else {
log.Printf("ContentWorkflowMetadata: invalid order value %q for command %q: %v", orderStr, commandName, err)
}
}🔵 Minor Issues4. Inconsistent Comment Formatting
// Parse order field from frontmatter, default to MaxInt for unordered commands5. Missing Test Coverage for New Ordering Feature
6. API Response Includes Internal
Positive Highlights✅ Excellent Backward Compatibility - Commands without ✅ Robust Fallback Strategy - Using MaxInt for unordered commands ensures they appear at the end ✅ Alphabetical Tiebreaker - When orders are equal, alphabetical sorting provides deterministic ordering ✅ Good Problem Statement - PR description clearly explains the issue and solution ✅ Follows Established Patterns - Uses existing RecommendationsImmediate Actions (Before Merge)
Follow-up Actions (Can Be Separate PR)
Code Quality Assessment
Security Analysis✅ No security vulnerabilities detected
Final VerdictConditional Approval - The PR is functionally correct and solves the stated problem, but would benefit from the recommended improvements before merging. The critical issues are about code quality rather than correctness, so the decision to merge depends on project standards for code clarity. If immediate deployment is needed, the code can be merged as-is with the understanding that a follow-up PR will address the code quality issues. Review performed by: Claude Sonnet 4.5 with full context from:
🤖 Automated code review by Claude Code 🔍 View AI decision process (logs available for 90 days) 📋 View memory system files loaded (click to expand)What Amber Loaded for Code ReviewAmber automatically loaded these repository standards from the memory system:
Impact: This review used your repository's specific code quality standards, security patterns, and best practices from the memory system (PRs #359, #360) - not just generic code review guidelines. |
Summary
Fixes RHOAIENG-39115 - Slash commands now render in the order specified in the custom workflow template instead of alphabetically.
Problem
Slash commands were rendering alphabetically in the dashboard UI, ignoring the order specified in the custom workflow template. This occurred because the backend used
os.ReadDir()which returns files in filesystem order (typically alphabetical), with no mechanism to preserve intentional ordering.Solution
Added support for an
orderfield in command frontmatter:orderfield from YAML frontmatter in.claude/commands/*.mdfilesorderfield before being returned to the frontendorderfield default to MaxInt (appear at the end)Changes
File Modified:
components/backend/handlers/content.gosortandstrconvimportsContentWorkflowMetadata()to parseorderfield from frontmatterExample Usage
Commands can now specify order in their frontmatter:
Backward Compatibility
✅ Fully backward compatible:
orderfields continue to workTesting Notes
The implementation handles edge cases:
🤖 Generated with Claude Code