diff --git a/profiler/src/profiler/TracyLlm.cpp b/profiler/src/profiler/TracyLlm.cpp index e805b817..cc3d979f 100644 --- a/profiler/src/profiler/TracyLlm.cpp +++ b/profiler/src/profiler/TracyLlm.cpp @@ -338,7 +338,11 @@ void TracyLlm::Draw() } else { - if( ImGui::IsWindowAppearing() ) ImGui::SetKeyboardFocusHere( 0 ); + if( ImGui::IsWindowAppearing() || m_focusInput ) + { + ImGui::SetKeyboardFocusHere( 0 ); + m_focusInput = false; + } ImGui::PushItemWidth( -1 ); if( ImGui::InputTextWithHint( "##ollama_input", "Write your question here...", m_input, InputBufferSize, ImGuiInputTextFlags_EnterReturnsTrue ) ) { @@ -484,6 +488,7 @@ bool TracyLlm::OnResponse( const ollama::response& response ) { m_stop = false; m_responding = false; + m_focusInput = true; return false; } @@ -496,6 +501,7 @@ bool TracyLlm::OnResponse( const ollama::response& response ) if( json["done"] ) { m_responding = false; + m_focusInput = true; return false; } diff --git a/profiler/src/profiler/TracyLlm.hpp b/profiler/src/profiler/TracyLlm.hpp index 2e041fe1..137229ff 100644 --- a/profiler/src/profiler/TracyLlm.hpp +++ b/profiler/src/profiler/TracyLlm.hpp @@ -108,6 +108,7 @@ private: bool m_responding = false; bool m_stop = false; bool m_wasUpdated = false; + bool m_focusInput = false; char* m_input; std::unique_ptr m_chat;