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 <string>
6#include <vector>
7
8#include "absl/status/status.h"
9#include "absl/time/time.h"
13
14namespace yaze {
15class Rom;
16namespace editor {
17
18class ToastManager;
19class ProposalDrawer;
20
31class AgentChat {
32 public:
33 AgentChat();
34 ~AgentChat() = default;
35
36 // Initialization
37 void Initialize(ToastManager* toast_manager, ProposalDrawer* proposal_drawer);
38 void SetRomContext(Rom* rom);
39 void SetContext(AgentUIContext* context);
40
41 // Main Draw Loop
42 // available_height: 0 = auto-resize to fit container
43 void Draw(float available_height = 0.0f);
44
45 // Actions
46 void SendMessage(const std::string& message);
47 void ClearHistory();
48 void ScrollToBottom();
49
50 // History Persistence
51 absl::Status LoadHistory(const std::string& filepath);
52 absl::Status SaveHistory(const std::string& filepath);
53
54 // Accessors
56
57 // UI Options
58 bool auto_scroll() const { return auto_scroll_; }
59 void set_auto_scroll(bool v) { auto_scroll_ = v; }
60 bool show_timestamps() const { return show_timestamps_; }
62 bool show_reasoning() const { return show_reasoning_; }
63 void set_show_reasoning(bool v) { show_reasoning_ = v; }
64
65 // State
66 bool* active() { return &active_; }
67 void set_active(bool active) { active_ = active; }
68
69 // Automation Telemetry Support
71 std::string test_id;
72 std::string name;
73 std::string status;
74 std::string message;
75 absl::Time updated_at;
76 };
77
78 void UpdateHarnessTelemetry(const AutomationTelemetry& telemetry);
79 void SetLastPlanSummary(const std::string& summary);
80 const std::vector<AutomationTelemetry>& GetTelemetryHistory() const { return telemetry_history_; }
81 const std::string& GetLastPlanSummary() const { return last_plan_summary_; }
82
83 private:
84 // UI Rendering
85 void RenderToolbar();
86 void RenderHistory();
87 void RenderInputBox();
88 void RenderMessage(const cli::agent::ChatMessage& msg, int index);
90 void RenderProposalQuickActions(const cli::agent::ChatMessage& msg, int index);
91 void RenderCodeBlock(const std::string& code, const std::string& language, int msg_index);
94
95 // Helpers
96 struct ContentBlock {
97 enum class Type { kText, kCode };
99 std::string content;
100 std::string language;
101 };
102 std::vector<ContentBlock> ParseMessageContent(const std::string& content);
103 void HandleAgentResponse(const absl::StatusOr<cli::agent::ChatMessage>& response);
104
105 // Dependencies
109 Rom* rom_ = nullptr;
110
111 // Internal State
113 bool active_ = false;
116 char input_buffer_[4096] = {};
117 bool scroll_to_bottom_ = false;
118 bool history_loaded_ = false;
119
120 // UI Options (from legacy AgentChatWidget)
121 bool auto_scroll_ = true;
122 bool show_timestamps_ = true;
123 bool show_reasoning_ = false;
124 float message_spacing_ = 12.0f;
125
126 // Automation Telemetry State
127 std::vector<AutomationTelemetry> telemetry_history_;
129};
130
131} // namespace editor
132} // namespace yaze
133
134#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:24
Unified Agent Chat Component.
Definition agent_chat.h:31
std::vector< ContentBlock > ParseMessageContent(const std::string &content)
bool show_reasoning() const
Definition agent_chat.h:62
void RenderCodeBlock(const std::string &code, const std::string &language, int msg_index)
void set_auto_scroll(bool v)
Definition agent_chat.h:59
absl::Status LoadHistory(const std::string &filepath)
void SendMessage(const std::string &message)
Definition agent_chat.cc:57
void RenderTableData(const cli::agent::ChatMessage::TableData &table)
void SetContext(AgentUIContext *context)
Definition agent_chat.cc:38
void RenderToolTimeline(const cli::agent::ChatMessage &msg)
std::string last_plan_summary_
Definition agent_chat.h:128
void set_show_timestamps(bool v)
Definition agent_chat.h:61
const std::vector< AutomationTelemetry > & GetTelemetryHistory() const
Definition agent_chat.h:80
bool auto_scroll() const
Definition agent_chat.h:58
void Initialize(ToastManager *toast_manager, ProposalDrawer *proposal_drawer)
Definition agent_chat.cc:29
std::vector< AutomationTelemetry > telemetry_history_
Definition agent_chat.h:127
ToastManager * toast_manager_
Definition agent_chat.h:107
AgentUIContext * context_
Definition agent_chat.h:106
void UpdateHarnessTelemetry(const AutomationTelemetry &telemetry)
void set_show_reasoning(bool v)
Definition agent_chat.h:63
void SetRomContext(Rom *rom)
Definition agent_chat.cc:34
void SetLastPlanSummary(const std::string &summary)
void Draw(float available_height=0.0f)
Definition agent_chat.cc:81
cli::agent::ConversationalAgentService agent_service_
Definition agent_chat.h:112
void RenderMessage(const cli::agent::ChatMessage &msg, int index)
ProposalDrawer * proposal_drawer_
Definition agent_chat.h:108
void set_active(bool active)
Definition agent_chat.h:67
bool show_timestamps() const
Definition agent_chat.h:60
const std::string & GetLastPlanSummary() const
Definition agent_chat.h:81
void RenderProposalQuickActions(const cli::agent::ChatMessage &msg, int index)
void HandleAgentResponse(const absl::StatusOr< cli::agent::ChatMessage > &response)
Definition agent_chat.cc:69
cli::agent::ConversationalAgentService * GetAgentService()
Definition agent_chat.cc:42
absl::Status SaveHistory(const std::string &filepath)
Unified context for agent UI components.
ImGui drawer for displaying and managing agent proposals.