From c8d7eb35972eecf8338a9bb3199ffdc18af86c61 Mon Sep 17 00:00:00 2001 From: scawful Date: Sun, 5 Oct 2025 15:43:39 -0400 Subject: [PATCH] refactor: Replace PopStyleColor with PopPanelStyle in AgentChatWidget - Updated multiple rendering functions in AgentChatWidget to replace ImGui::PopStyleColor() with AgentUI::PopPanelStyle(), enhancing consistency in style management. - Introduced a new StatusBadge function in agent_ui_theme.cc for improved badge rendering with customizable colors, promoting better UI theming. - Added ButtonColor enum in agent_ui_theme.h to support various badge states, improving code clarity and maintainability. --- src/app/editor/agent/agent_chat_widget.cc | 16 ++++++++-------- src/app/editor/agent/agent_ui_theme.cc | 20 ++++++++++++++++++++ src/app/editor/agent/agent_ui_theme.h | 4 ++++ 3 files changed, 32 insertions(+), 8 deletions(-) diff --git a/src/app/editor/agent/agent_chat_widget.cc b/src/app/editor/agent/agent_chat_widget.cc index 29f0dcff..c00ffdfc 100644 --- a/src/app/editor/agent/agent_chat_widget.cc +++ b/src/app/editor/agent/agent_chat_widget.cc @@ -555,7 +555,7 @@ void AgentChatWidget::RenderHistory() { } } ImGui::EndChild(); - ImGui::PopStyleColor(); + AgentUI::PopPanelStyle(); last_history_size_ = history.size(); } @@ -1342,7 +1342,7 @@ void AgentChatWidget::RenderCollaborationPanel() { } ImGui::EndChild(); - ImGui::PopStyleColor(); + AgentUI::PopPanelStyle(); ImGui::PopStyleVar(2); ImGui::PopID(); // CollabPanel } @@ -1451,7 +1451,7 @@ void AgentChatWidget::RenderMultimodalPanel() { ImGui::EndDisabled(); ImGui::EndChild(); - ImGui::PopStyleColor(); + AgentUI::PopPanelStyle(); ImGui::PopID(); } @@ -1667,7 +1667,7 @@ void AgentChatWidget::RenderAgentConfigPanel() { } ImGui::EndChild(); - ImGui::PopStyleColor(); + AgentUI::PopPanelStyle(); } void AgentChatWidget::RenderZ3EDCommandPanel() { @@ -1750,7 +1750,7 @@ void AgentChatWidget::RenderZ3EDCommandPanel() { } ImGui::EndChild(); - ImGui::PopStyleColor(); + AgentUI::PopPanelStyle(); ImGui::PopID(); // FIX: Pop the Z3EDCmdPanel ID } @@ -1849,7 +1849,7 @@ void AgentChatWidget::RenderRomSyncPanel() { } ImGui::EndChild(); - ImGui::PopStyleColor(); + AgentUI::PopPanelStyle(); } void AgentChatWidget::RenderSnapshotPreviewPanel() { @@ -1899,7 +1899,7 @@ void AgentChatWidget::RenderSnapshotPreviewPanel() { } ImGui::EndChild(); - ImGui::PopStyleColor(); + AgentUI::PopPanelStyle(); } void AgentChatWidget::RenderProposalManagerPanel() { @@ -2095,7 +2095,7 @@ void AgentChatWidget::RenderHarnessPanel() { } ImGui::EndChild(); - ImGui::PopStyleColor(); + AgentUI::PopPanelStyle(); ImGui::PopID(); } diff --git a/src/app/editor/agent/agent_ui_theme.cc b/src/app/editor/agent/agent_ui_theme.cc index 581c8bf6..7691c08b 100644 --- a/src/app/editor/agent/agent_ui_theme.cc +++ b/src/app/editor/agent/agent_ui_theme.cc @@ -147,6 +147,26 @@ void RenderProviderBadge(const char* provider) { ImGui::PopStyleColor(); } +void StatusBadge(const char* text, ButtonColor color) { + const auto& theme = GetTheme(); + + ImVec4 badge_color; + switch (color) { + case ButtonColor::Success: badge_color = theme.status_success; break; + case ButtonColor::Warning: badge_color = theme.status_warning; break; + case ButtonColor::Error: badge_color = theme.status_error; break; + case ButtonColor::Info: badge_color = theme.accent_color; break; + default: badge_color = theme.status_inactive; break; + } + + ImGui::PushStyleColor(ImGuiCol_Button, badge_color); + ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 10.0f); + ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(6, 2)); + ImGui::SmallButton(text); + ImGui::PopStyleVar(2); + ImGui::PopStyleColor(); +} + void VerticalSpacing(float amount) { ImGui::Dummy(ImVec2(0, amount)); } diff --git a/src/app/editor/agent/agent_ui_theme.h b/src/app/editor/agent/agent_ui_theme.h index d4c208c7..f24f437a 100644 --- a/src/app/editor/agent/agent_ui_theme.h +++ b/src/app/editor/agent/agent_ui_theme.h @@ -81,6 +81,10 @@ void RenderSectionHeader(const char* icon, const char* label, const ImVec4& colo void RenderStatusIndicator(const char* label, bool active); void RenderProviderBadge(const char* provider); +// Status badge for tests/processes +enum class ButtonColor { Success, Warning, Error, Info, Default }; +void StatusBadge(const char* text, ButtonColor color); + // Spacing helpers void VerticalSpacing(float amount = 8.0f); void HorizontalSpacing(float amount = 8.0f);