Fix chat input focus.

This commit is contained in:
Bartosz Taudul
2025-05-13 02:27:36 +02:00
parent b901544fb4
commit 10decca063
2 changed files with 8 additions and 1 deletions

View File

@@ -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;
}

View File

@@ -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<ollama::messages> m_chat;