Allow opening callstack window from LLM attachment.

This commit is contained in:
Bartosz Taudul
2026-04-30 21:42:22 +02:00
parent 89bd8b2ba5
commit 460352d0d5
3 changed files with 19 additions and 1 deletions

View File

@@ -9,6 +9,7 @@
#include "TracyLlmChat.hpp"
#include "TracyMouse.hpp"
#include "TracyPrint.hpp"
#include "TracyView.hpp"
#include "../Fonts.hpp"
#include "../../public/common/TracyForceInline.hpp"
@@ -144,6 +145,7 @@ TracyLlmChat::TracyLlmChat( View& view, Worker& worker, const std::vector<LlmSki
: m_width( new float[NumRoles] )
, m_markdown( &view, &worker )
, m_skills( skills )
, m_view( view )
{
}
@@ -285,6 +287,20 @@ bool TracyLlmChat::Turn( TurnRole role, std::vector<nlohmann::json>::iterator it
const bool expand = ImGui::TreeNode( "Attachment" );
ImGui::SameLine();
ImGui::TextDisabled( "(%s)", type.c_str() );
if( type == "callstack" )
{
if( j.contains( "id" ) )
{
const auto id = j["id"].get<int64_t>();
assert( id >= 0 );
const auto thread = j.contains( "thread" ) ? j["thread"].get<uint32_t>() : 0;
ImGui::SameLine();
if( ImGui::SmallButton( ICON_FA_EYE ) )
{
m_view.ViewCallstack( id, thread );
}
}
}
if( expand )
{
ImGui::PushFont( g_fonts.mono, FontNormal );

View File

@@ -67,6 +67,7 @@ private:
std::string m_label;
const std::vector<LlmSkill>& m_skills;
View& m_view;
};
}

View File

@@ -113,7 +113,7 @@ void View::DrawCallstackTable( const CallstackFrameId* data, size_t size, uint64
}
if( s_config.llm )
{
auto Attach = [this, data, size, hasCrashed, thread]() {
auto Attach = [this, data, size, hasCrashed, thread, callstack]() {
auto json = GetCallstackJson( data, size );
if( hasCrashed )
{
@@ -130,6 +130,7 @@ void View::DrawCallstackTable( const CallstackFrameId* data, size_t size, uint64
if( strcmp( threadName, "???" ) != 0 ) json["thread_name"] = threadName;
json["thread_id"] = thread;
}
if( callstack >= 0 ) json["id"] = callstack;
AddLlmAttachment( json );
};