From 4d34163adea3c8611bc4550b0ca0da3c1ab40121 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Fri, 8 May 2026 01:15:56 +0200 Subject: [PATCH] Allow accepting chat suggestion via Enter or Send button. --- profiler/src/profiler/TracyLlm.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/profiler/src/profiler/TracyLlm.cpp b/profiler/src/profiler/TracyLlm.cpp index a1d3f29a..b558ed34 100644 --- a/profiler/src/profiler/TracyLlm.cpp +++ b/profiler/src/profiler/TracyLlm.cpp @@ -704,11 +704,19 @@ void TracyLlm::Draw() const char* hint = m_suggestion.empty() ? "Write your question here…" : m_suggestion.c_str(); bool send = ImGui::InputTextWithHint( "##chat_input", hint, m_input, InputBufferSize, ImGuiInputTextFlags_EnterReturnsTrue ); ImGui::SameLine(); - if( *m_input == 0 ) ImGui::BeginDisabled(); + const bool inputEmpty = *m_input == 0; + const bool hasSuggestion = !m_suggestion.empty(); + if( inputEmpty && !hasSuggestion ) ImGui::BeginDisabled(); send |= ImGui::Button( buttonText ); - if( *m_input == 0 ) ImGui::EndDisabled(); + if( inputEmpty && !hasSuggestion ) ImGui::EndDisabled(); if( send ) { + if( inputEmpty && hasSuggestion ) + { + const auto sz = std::min( InputBufferSize - 1, m_suggestion.size() ); + memcpy( m_input, m_suggestion.data(), sz ); + m_input[sz] = 0; + } auto ptr = m_input; while( *ptr ) {