Fade-out outdated assistant replies.

The "outdated" concept is strictly for chain of assistant replies with
nothing in between, i.e.:

"I will check this..."      <- outdated
<tool call>                 <- not displayed
"Now I will do that..."     <- outdated
<tool call>                 <- not displayed
"Let me consider..."        <- outdated
<reasoning>                 <- not displayed
"Now I have the answer..."

The first three messages are at this point considered outdated, as the
model provided a more recent message.

Note that in chain such as below there are NO outdated messages:

"How can I help..."
<user input>
"Ah, I see..."
<user input>
"You may try to..."

Similarly, if the tool calls or reasoning sections are explicitly enabled
in the chat UI, the messages are also not considered outdated.
This commit is contained in:
Bartosz Taudul
2026-05-21 21:23:14 +02:00
parent efc33a09d9
commit 896cdc9462
3 changed files with 23 additions and 3 deletions

View File

@@ -615,7 +615,25 @@ void TracyLlm::Draw()
think = TracyLlmChat::Think::ToolCall;
}
const auto isLast = it + 1 == m_chat.end();
if( !m_chatUi->Turn( role, it, m_chat.end(), think, isLast ) )
bool fadeout = false;
if( role == TracyLlmChat::TurnRole::Assistant && !m_allThinkingRegions && !isLast )
{
auto nit = it + 1;
while( nit != m_chat.end() )
{
const auto& nline = *nit;
if( !nline.contains( "role" ) ) { nit++; continue; }
const auto& nroleStr = nline["role"].get_ref<const std::string&>();
if( nroleStr == "assistant" && nline.contains( "content" ) )
{
fadeout = true;
break;
}
if( nroleStr == "user" ) break;
nit++;
}
}
if( !m_chatUi->Turn( role, it, m_chat.end(), think, isLast, fadeout ) )
{
if( role == TracyLlmChat::TurnRole::Assistant )
{

View File

@@ -227,7 +227,7 @@ void TracyLlmChat::End()
}
}
bool TracyLlmChat::Turn( TurnRole role, std::vector<nlohmann::json>::iterator it, const std::vector<nlohmann::json>::iterator& end, Think think, bool last )
bool TracyLlmChat::Turn( TurnRole role, std::vector<nlohmann::json>::iterator it, const std::vector<nlohmann::json>::iterator& end, Think think, bool last, bool fadeout )
{
auto& json = *it;
if( json.contains( "role" ) && json["role"].get_ref<const std::string&>() == "tool" ) return true;
@@ -391,7 +391,9 @@ bool TracyLlmChat::Turn( TurnRole role, std::vector<nlohmann::json>::iterator it
if( ptr != end )
{
NormalScope();
if( fadeout ) ImGui::PushStyleColor( ImGuiCol_Text, ImGui::GetStyle().Colors[ImGuiCol_TextDisabled] );
m_markdown.Print( content.c_str(), content.size() );
if( fadeout ) ImGui::PopStyleColor();
if( roleStr == "assistant" ) ImGui::Spacing();
}
}

View File

@@ -43,7 +43,7 @@ public:
void Begin();
void End();
bool Turn( TurnRole role, std::vector<nlohmann::json>::iterator it, const std::vector<nlohmann::json>::iterator& end, Think think, bool last );
bool Turn( TurnRole role, std::vector<nlohmann::json>::iterator it, const std::vector<nlohmann::json>::iterator& end, Think think, bool last, bool fadeout );
void SetModelTimeLabel( const char* model, uint64_t duration_ns );
private: