From 207b35df82019e4b7d76edd19b7081c21192b1e6 Mon Sep 17 00:00:00 2001 From: scawful Date: Sat, 4 Oct 2025 13:48:01 -0400 Subject: [PATCH] feat: Refactor agent chat widget handling and remove unused state variable --- src/app/editor/editor_manager.cc | 17 +++++++++-------- src/app/editor/editor_manager.h | 1 - src/app/editor/system/agent_chat_widget.h | 1 + 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/app/editor/editor_manager.cc b/src/app/editor/editor_manager.cc index 3d3fa43f..8441ea33 100644 --- a/src/app/editor/editor_manager.cc +++ b/src/app/editor/editor_manager.cc @@ -713,7 +713,10 @@ void EditorManager::Initialize(const std::string& filename) { [&]() { proposal_drawer_.Toggle(); }}, #ifdef YAZE_WITH_GRPC {absl::StrCat(ICON_MD_CHAT, " Agent Chat"), "", - [&]() { show_agent_chat_widget_ = !show_agent_chat_widget_; }}, + [this]() { + agent_chat_widget_.set_active(!agent_chat_widget_.is_active()); + }, + [this]() { return agent_chat_widget_.is_active(); }}, #endif {gui::kSeparator, "", nullptr, []() { return true; }}, @@ -932,13 +935,11 @@ absl::Status EditorManager::Update() { proposal_drawer_.Draw(); } #ifdef YAZE_WITH_GRPC - if (show_agent_chat_widget_) { - Rom* rom_context = - (current_rom_ != nullptr && current_rom_->is_loaded()) ? current_rom_ - : nullptr; - agent_chat_widget_.SetRomContext(rom_context); - agent_chat_widget_.Draw(); - } + Rom* rom_context = + (current_rom_ != nullptr && current_rom_->is_loaded()) ? current_rom_ + : nullptr; + agent_chat_widget_.SetRomContext(rom_context); + agent_chat_widget_.Draw(); #endif return absl::OkStatus(); diff --git a/src/app/editor/editor_manager.h b/src/app/editor/editor_manager.h index 118832a7..c4addb44 100644 --- a/src/app/editor/editor_manager.h +++ b/src/app/editor/editor_manager.h @@ -185,7 +185,6 @@ class EditorManager { #ifdef YAZE_WITH_GRPC // Agent chat widget AgentChatWidget agent_chat_widget_; - bool show_agent_chat_widget_ = false; #endif std::string version_ = ""; diff --git a/src/app/editor/system/agent_chat_widget.h b/src/app/editor/system/agent_chat_widget.h index ccac164d..d083cc86 100644 --- a/src/app/editor/system/agent_chat_widget.h +++ b/src/app/editor/system/agent_chat_widget.h @@ -20,6 +20,7 @@ class AgentChatWidget { void SetRomContext(Rom* rom); bool* active() { return &active_; } + bool is_active() const { return active_; } void set_active(bool active) { active_ = active; } private: