From 8b2de04cd9371ee5da8014f0838cc40b15f18150 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Thu, 12 Jun 2025 20:45:45 +0200 Subject: [PATCH] Chat message removal UI. --- profiler/src/profiler/TracyLlmChat.cpp | 28 +++++++++++++++++++++----- profiler/src/profiler/TracyLlmChat.hpp | 6 ++++-- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/profiler/src/profiler/TracyLlmChat.cpp b/profiler/src/profiler/TracyLlmChat.cpp index 816b045d..fb2c8e4a 100644 --- a/profiler/src/profiler/TracyLlmChat.cpp +++ b/profiler/src/profiler/TracyLlmChat.cpp @@ -28,7 +28,8 @@ constexpr std::array roles = { RoleData { ICON_FA_TERMINAL, ImVec4( 1.f, 0.5f, 0.5f, 1.f ), ImVec4( 1.f, 0.65f, 0.65f, 1.f ) }, RoleData { ICON_FA_ROBOT, ImVec4( 0.4f, 0.5f, 1.f, 1.f ), ImVec4( 1.f, 1.f, 1.f, 1.f ) }, RoleData { ICON_FA_CODE, ImVec4( 1.0f, 0.5f, 1.f, 1.f ), ImVec4( 1.f, 0.65f, 1.f, 1.f ) }, - RoleData { ICON_FA_CIRCLE_EXCLAMATION, ImVec4( 1.f, 0.25f, 0.25f, 1.f ), ImVec4( 1.f, 0.25f, 0.25f, 1.f ) } + RoleData { ICON_FA_CIRCLE_EXCLAMATION, ImVec4( 1.f, 0.25f, 0.25f, 1.f ), ImVec4( 1.f, 0.25f, 0.25f, 1.f ) }, + RoleData { ICON_FA_TRASH, ImVec4( 1.0f, 0.25f, 0.25f, 1.f ), ImVec4( 1.f, 1.f, 1.f, 1.f ) }, }; constexpr size_t NumRoles = roles.size(); @@ -332,8 +333,9 @@ void TracyLlmChat::End() } } -void TracyLlmChat::Turn( TurnRole role, const std::string& content ) +bool TracyLlmChat::Turn( TurnRole role, const std::string& content ) { + bool keep = true; const auto& roleData = roles[(int)role]; if( role != m_role ) { @@ -347,13 +349,28 @@ void TracyLlmChat::Turn( TurnRole role, const std::string& content ) m_thinkActive = false; m_thinkOpen = false; - const auto diff = m_maxWidth - m_width[(int)role]; - const auto offset = diff / 2; + bool hover = false; ImGui::Spacing(); ImGui::PushID( m_roleIdx++ ); + auto diff = m_maxWidth - m_width[(int)role]; + if( ImGui::IsMouseHoveringRect( ImGui::GetCursorScreenPos(), ImGui::GetCursorScreenPos() + ImVec2( m_maxWidth, ImGui::GetTextLineHeight() ) ) ) + { + diff = m_maxWidth - m_width[(int)TurnRole::Trash]; + hover = true; + } + const auto offset = diff / 2; ImGui::Dummy( ImVec2( offset, 0 ) ); ImGui::SameLine( 0, 0 ); - ImGui::TextColored( roleData.iconColor, "%s", roleData.icon ); + if( hover ) + { + const auto& trash = roles[(int)TurnRole::Trash]; + ImGui::TextColored( trash.iconColor, "%s", trash.icon ); + if( IsMouseClicked( ImGuiMouseButton_Left ) ) keep = false; + } + else + { + ImGui::TextColored( roleData.iconColor, "%s", roleData.icon ); + } ImGui::SameLine( 0, 0 ); ImGui::Dummy( ImVec2( diff - offset, 0 ) ); ImGui::SameLine(); @@ -446,6 +463,7 @@ void TracyLlmChat::Turn( TurnRole role, const std::string& content ) } } ImGui::PopStyleColor(); + return keep; } void TracyLlmChat::NormalScope() diff --git a/profiler/src/profiler/TracyLlmChat.hpp b/profiler/src/profiler/TracyLlmChat.hpp index cd1a44e6..0c6c6d12 100644 --- a/profiler/src/profiler/TracyLlmChat.hpp +++ b/profiler/src/profiler/TracyLlmChat.hpp @@ -20,7 +20,9 @@ public: Assistant, AssistantDebug, Error, - None + // virtual roles below + Trash, + None, }; TracyLlmChat(); @@ -29,7 +31,7 @@ public: void Begin(); void End(); - void Turn( TurnRole role, const std::string& content ); + bool Turn( TurnRole role, const std::string& content ); private: void NormalScope();