-
Notifications
You must be signed in to change notification settings - Fork 47
Bug RHOAIENG-39117: Fix system messages checkbox rendering #536
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-39117: Fix system messages checkbox rendering #536
Conversation
This comment has been minimized.
This comment has been minimized.
…oles ## Problem System messages (like "Repository added", "End turn X", "Workflow loaded") were not appearing in the chat even when "Show system messages" was enabled. The issue was that the runner was not emitting them as proper AG-UI TextMessage events with the correct role field. ## Root Cause The adapter.py was emitting platform logs and system messages as RawEvent with type "system_log", rather than as proper AG-UI TextMessage events with role fields as specified in the AG-UI protocol. ## Changes ### Backend (adapter.py) - Added helper method _emit_developer_message() to emit proper AG-UI TextMessage events with role="developer" for platform logging - Converted all system_log RawEvent emissions to TextMessage events with roles: - Platform logs (repo cloning, workflow loading, etc.) → role="developer" - Claude system messages (turn info, etc.) remain as debug logs - Updated messages for: - Repository cloning and workspace preparation - Multi-repo workspace operations - Workflow initialization and cloning - Session continuation messages - Error messages ### Frontend Types (agentic-session.ts) - Added optional role field to UserMessage and AgentMessage types - Created new DeveloperMessage type for role="developer" messages - Created new SystemRoleMessage type for role="system" messages - Updated Message union type to include new message types ### Frontend Components (stream-message.tsx) - Updated message rendering to handle AG-UI role field - Added role-based display logic: - role="assistant" → displayed as Claude AI (bot) - role="developer" → displayed as Platform (system) - role="system" → displayed as System (system) - role="user" → displayed as You (user) ### UI Component (message.tsx) - Extended MessageRole type to include "system" - Updated avatar rendering for system role messages (gray "SYS" badge) - Added appropriate styling for system messages (muted background, muted text) - Updated layout logic to handle system role messages ### Message Filtering (MessagesTab.tsx) - Updated filter logic to check for AG-UI role field - Now filters messages by role="system" or role="developer" when showSystemMessages is false - Maintains backward compatibility with legacy type="system_message" ## Testing System messages should now: - Be emitted as proper AG-UI TextMessage events with roles - Appear in chat when "Show system messages" checkbox is enabled - Be hidden by default when checkbox is disabled - Render with appropriate styling (gray badge, muted background) Co-Authored-By: Claude (claude-sonnet-4-5) <noreply@anthropic.com>
dfabcc3 to
785fb6e
Compare
Claude Code ReviewSummaryThis PR correctly implements AG-UI protocol compliance for system/developer messages, enabling proper role-based filtering in the frontend. The changes properly convert platform logging from RawEvent emissions to TextMessage events with role fields, and the frontend correctly interprets these roles for display and filtering. Verdict: ✅ APPROVED - Code follows established patterns and correctly implements the AG-UI protocol. Issues by Severity🚫 Blocker IssuesNone found. 🔴 Critical IssuesNone found. 🟡 Major IssuesNone found. 🔵 Minor Issues1. Frontend: Potential Type Safety Issue
2. Backend: Verbose Message Emission Pattern
3. Frontend: Missing Type Annotations
Positive Highlights✅ Excellent AG-UI Protocol Compliance
✅ Consistent Error Handling
✅ Security Compliance
✅ Type Safety (Frontend)
✅ Code Organization
✅ UI/UX Improvements
Architecture & Patterns ReviewBackend (Python)✅ Async Generator Pattern: Correctly yields AG-UI events instead of returning Frontend (TypeScript)✅ Type Definitions: Proper union types with discriminated fields Compliance with Project Standards✅ CLAUDE.md: Follows Python formatting (black, double quotes) Testing CoverageWhat's Tested:
What Could Be Tested:
Recommendation: Add unit tests for the new helper method and message filtering logic in a follow-up PR. RecommendationsHigh PriorityNone - code is production-ready as-is. Medium Priority
Low Priority
Final Verdict✅ APPROVED This PR correctly implements the AG-UI protocol for system/developer messages and follows all established patterns from the project's memory system. The code is well-structured, secure, and maintains backward compatibility. Key Strengths:
Minor Improvements (non-blocking):
Merge Recommendation: ✅ Safe to merge after addressing any reviewer feedback on the minor issues above (all are optional/non-blocking). Review completed using memory system context:
🔍 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. |
Claude Code ReviewSummaryPR #536 fixes the "Show system messages" checkbox rendering issue while also introducing significant new functionality for handling system/developer role messages from the AG-UI protocol. The changes span frontend UI components and backend Python adapter code. Scope Analysis:
Issues by Severity🚫 Blocker Issues1. Missing Variable Definition in stream-message.tsx (Line 104) // Line 104 uses feedbackElement which is no longer defined
feedbackButtons={feedbackElement} // ❌ Reference ErrorImpact: This will cause a runtime error and break message rendering. 🔴 Critical Issues2. PR Violates Single Responsibility Principle
Why This Matters:
Recommendation: Split into 3 separate PRs:
3. Major Backend Logic Added Without Tests
Missing:
Impact: No automated verification that platform logging works correctly or that workspace prep handles edge cases. 4. TypeScript Type Safety Violations // agentic-session.ts - New types added to Message union
export type Message = UserMessage | AgentMessage | SystemMessage |
ResultMessage | ToolUseMessages | AgentRunningMessage |
AgentWaitingMessage | DeveloperMessage | SystemRoleMessage;
// But DeveloperMessage and SystemRoleMessage allow either type:
type: "user_message" | "agent_message" // ❌ Too permissiveIssue: These types don't enforce that Better approach: export type DeveloperMessage = {
type: "developer_message"; // Dedicated type
content: ContentBlock | string;
timestamp: string;
role: "developer";
}🟡 Major Issues5. Inconsistent Message Filtering Logic Three different places filter system messages:
Issue: Logic is duplicated and could diverge over time. Recommendation: Centralize filtering in a utility function: // utils/message-filters.ts
export function shouldShowMessage(msg: Message, showSystemMessages: boolean): boolean {
if (showSystemMessages) return true;
// Hide legacy system_message type
if ('type' in msg && msg.type === "system_message") return false;
// Hide AG-UI system/developer roles
if ('role' in msg && (msg.role === "system" || msg.role === "developer")) return false;
return true;
}6. No Documentation for AG-UI Role Protocol The PR introduces a new role-based message system (
Questions:
Recommendation: Add documentation to:
7. Workspace Preparation Logic Not Explained Lines 1231-1455 in adapter.py add significant new workspace preparation code, but:
Impact: Future maintainers won't understand the logic or when to use each path. 🔵 Minor Issues8. Removed Feedback Buttons Without Explanation
const feedbackElement = isAgent && !isStreaming ? (
<FeedbackButtons messageId={m.id} ... />
) : undefined;Now it's completely removed (lines 64-106 diff). PR description doesn't mention this. Question: Was this intentional or accidental? 9. Verbose Developer Messages
Issue: Using emoji in logs can cause encoding issues in some terminals. Also, these are quite verbose. Recommendation: Use structured logging levels: logger.info("Cloning repository", extra={"repo": name, "branch": branch})10. Type Annotation Missing
const filteredMessages = streamMessages.filter((msg) => { // msg type inferredBetter: const filteredMessages = streamMessages.filter((msg: MessageObject | ToolUseMessages) => {11. Ternary Expression Complexity
!borderless && ((isBot || isSystem) ? isSystem ? "bg-muted/50" : "bg-card" : "bg-border/30")Readability Issue: Nested ternaries are hard to parse. Better: const backgroundColor = borderless ? undefined :
isSystem ? "bg-muted/50" :
isBot ? "bg-card" :
"bg-border/30";
!borderless && backgroundColor12. Missing Return Type on Helper
async def _emit_developer_message(
self, message: str, thread_id: str, run_id: str
) -> AsyncIterator[BaseEvent]:Good! But other new functions lack return types:
Recommendation: Add return type annotations consistently. Positive Highlights✅ Good Type Additions - New MessageRole type properly extends existing ✅ Backward Compatibility - Filtering checks both legacy ✅ Proper Event Emission - ✅ User Experience - System message filtering improves UI clarity by hiding platform internals by default ✅ Clean UI Pattern - Avatar handling for system role ( RecommendationsImmediate (Before Merge):
Short-term (Next PR):
Long-term:
Checklist Review❌ CLAUDE.md Pre-Commit Checklist - Frontend:
❌ CLAUDE.md Pre-Commit Checklist - Python:
VerdictStatus: 🔴 Needs Changes Before Merge Critical Issues:
Recommendation: Fix the blocker issue, add basic tests, then merge with understanding that follow-up PRs should:
Risk Assessment:
Reviewed with: Memory context (CLAUDE.md, backend-development.md, frontend-development.md, security-standards.md, k8s-client-usage.md, error-handling.md, react-query-usage.md) 🔍 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. |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Summary
Fixes the rendering issue with the "Show system messages" checkbox in the MessagesTab component and all other dropdown menu checkboxes throughout the application.
Problem
The checkbox outline in the DropdownMenuCheckboxItem component was not visible against most backgrounds due to missing background color and border-radius styling. This made it difficult for users to see and interact with the checkbox.
Solution
Added
bg-backgroundandrounded-smTailwind classes to the checkbox span element (line 108 indropdown-menu.tsx) to:Changes
components/frontend/src/components/ui/dropdown-menu.tsx(line 108)Testing
Related Issue
Fixes: https://issues.redhat.com/browse/RHOAIENG-39117
Screenshots
Before: Checkbox outline was not visible
After: Checkbox has visible background and rounded corners
Generated with Claude Agent (claude-sonnet-4-5)