yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
agent_chat.h
Go to the documentation of this file.
1#ifndef YAZE_APP_EDITOR_AGENT_AGENT_CHAT_H_
2#define YAZE_APP_EDITOR_AGENT_AGENT_CHAT_H_
3
4#include <filesystem>
5#include <functional>
6#include <string>
7#include <vector>
8
9#include "absl/status/status.h"
10#include "absl/time/time.h"
14
15namespace yaze {
16class Rom;
17namespace editor {
18
19class ToastManager;
20class ProposalDrawer;
21
32class AgentChat {
33 public:
34 AgentChat();
35 ~AgentChat() = default;
36
37 // Initialization
38 void Initialize(ToastManager* toast_manager, ProposalDrawer* proposal_drawer);
39 void SetRomContext(Rom* rom);
40 void SetContext(AgentUIContext* context);
41 void SetPanelOpener(std::function<void(const std::string&)> opener) {
42 panel_opener_ = std::move(opener);
43 }
44
45 // Main Draw Loop
46 // available_height: 0 = auto-resize to fit container
47 void Draw(float available_height = 0.0f);
48
49 // Actions
50 void SendMessage(const std::string& message);
51 void ClearHistory();
52 void ScrollToBottom();
53
54 // History Persistence
55 absl::Status LoadHistory(const std::string& filepath);
56 absl::Status SaveHistory(const std::string& filepath);
57
58 // Accessors
60
61 // UI Options
62 bool auto_scroll() const { return auto_scroll_; }
63 void set_auto_scroll(bool v) { auto_scroll_ = v; }
64 bool show_timestamps() const { return show_timestamps_; }
66 bool show_reasoning() const { return show_reasoning_; }
67 void set_show_reasoning(bool v) { show_reasoning_ = v; }
68
69 // State
70 bool* active() { return &active_; }
71 void set_active(bool active) { active_ = active; }
72
73 // Automation Telemetry Support
75 std::string test_id;
76 std::string name;
77 std::string status;
78 std::string message;
79 absl::Time updated_at;
80 };
81
82 void UpdateHarnessTelemetry(const AutomationTelemetry& telemetry);
83 void SetLastPlanSummary(const std::string& summary);
84 const std::vector<AutomationTelemetry>& GetTelemetryHistory() const { return telemetry_history_; }
85 const std::string& GetLastPlanSummary() const { return last_plan_summary_; }
86
87 private:
88 // UI Rendering
89 void RenderToolbar(bool compact);
90 void RenderConversationSidebar(float height);
91 void RenderHistory();
92 void RenderInputBox(float height);
93 void RenderMessage(const cli::agent::ChatMessage& msg, int index);
95 void RenderProposalQuickActions(const cli::agent::ChatMessage& msg, int index);
96 void RenderCodeBlock(const std::string& code, const std::string& language, int msg_index);
99
100 // Helpers
102 enum class Type { kText, kCode };
104 std::string content;
105 std::string language;
106 };
107 std::vector<ContentBlock> ParseMessageContent(const std::string& content);
108 void HandleAgentResponse(const absl::StatusOr<cli::agent::ChatMessage>& response);
109 void RefreshConversationList(bool force = false);
110 void SelectConversation(const std::filesystem::path& path);
111
112 // Dependencies
116 Rom* rom_ = nullptr;
117
118 // Internal State
120 bool active_ = false;
123 char input_buffer_[4096] = {};
124 bool scroll_to_bottom_ = false;
125 bool history_loaded_ = false;
126
128 std::string title;
129 std::filesystem::path path;
130 absl::Time last_updated = absl::InfinitePast();
132 bool is_active = false;
133 };
134 std::vector<ConversationEntry> conversations_;
135 absl::Time last_conversation_refresh_ = absl::InfinitePast();
136 std::filesystem::path active_history_path_;
137 char conversation_filter_[128] = {};
138
139 // UI Options (from legacy AgentChatWidget)
140 bool auto_scroll_ = true;
141 bool show_timestamps_ = true;
142 bool show_reasoning_ = false;
143 float message_spacing_ = 12.0f;
144
145 // Automation Telemetry State
146 std::vector<AutomationTelemetry> telemetry_history_;
148 std::function<void(const std::string&)> panel_opener_;
149};
150
151} // namespace editor
152} // namespace yaze
153
154#endif // YAZE_APP_EDITOR_AGENT_AGENT_CHAT_H_
The Rom class is used to load, save, and modify Rom data. This is a generic SNES ROM container and do...
Definition rom.h:28
Unified Agent Chat Component.
Definition agent_chat.h:32
std::vector< ContentBlock > ParseMessageContent(const std::string &content)
bool show_reasoning() const
Definition agent_chat.h:66
void RenderCodeBlock(const std::string &code, const std::string &language, int msg_index)
void set_auto_scroll(bool v)
Definition agent_chat.h:63
absl::Status LoadHistory(const std::string &filepath)
std::function< void(const std::string &) panel_opener_)
Definition agent_chat.h:148
void RenderConversationSidebar(float height)
void SendMessage(const std::string &message)
void RenderTableData(const cli::agent::ChatMessage::TableData &table)
void SetContext(AgentUIContext *context)
void RenderToolTimeline(const cli::agent::ChatMessage &msg)
void RenderToolbar(bool compact)
std::string last_plan_summary_
Definition agent_chat.h:147
void set_show_timestamps(bool v)
Definition agent_chat.h:65
const std::vector< AutomationTelemetry > & GetTelemetryHistory() const
Definition agent_chat.h:84
bool auto_scroll() const
Definition agent_chat.h:62
void RefreshConversationList(bool force=false)
void Initialize(ToastManager *toast_manager, ProposalDrawer *proposal_drawer)
std::vector< AutomationTelemetry > telemetry_history_
Definition agent_chat.h:146
ToastManager * toast_manager_
Definition agent_chat.h:114
AgentUIContext * context_
Definition agent_chat.h:113
std::filesystem::path active_history_path_
Definition agent_chat.h:136
void UpdateHarnessTelemetry(const AutomationTelemetry &telemetry)
void set_show_reasoning(bool v)
Definition agent_chat.h:67
void SetPanelOpener(std::function< void(const std::string &)> opener)
Definition agent_chat.h:41
void SetRomContext(Rom *rom)
void SetLastPlanSummary(const std::string &summary)
void Draw(float available_height=0.0f)
char conversation_filter_[128]
Definition agent_chat.h:137
void RenderInputBox(float height)
void SelectConversation(const std::filesystem::path &path)
std::vector< ConversationEntry > conversations_
Definition agent_chat.h:134
cli::agent::ConversationalAgentService agent_service_
Definition agent_chat.h:119
void RenderMessage(const cli::agent::ChatMessage &msg, int index)
ProposalDrawer * proposal_drawer_
Definition agent_chat.h:115
void set_active(bool active)
Definition agent_chat.h:71
absl::Time last_conversation_refresh_
Definition agent_chat.h:135
bool show_timestamps() const
Definition agent_chat.h:64
const std::string & GetLastPlanSummary() const
Definition agent_chat.h:85
void RenderProposalQuickActions(const cli::agent::ChatMessage &msg, int index)
void HandleAgentResponse(const absl::StatusOr< cli::agent::ChatMessage > &response)
cli::agent::ConversationalAgentService * GetAgentService()
absl::Status SaveHistory(const std::string &filepath)
Unified context for agent UI components.
ImGui drawer for displaying and managing agent proposals.