8#include "imgui/imgui.h"
17 if (!knowledge_service) {
18 ImGui::TextColored(ImVec4(1.0f, 0.5f, 0.0f, 1.0f),
19 "Knowledge service not available");
21 "The knowledge service is only available when built with Z3ED_AI "
81 ImVec4(0.6f, 0.2f, 0.2f, 1.0f));
83 ImGui::OpenPopup(
"Confirm Clear");
88 if (ImGui::BeginPopupModal(
"Confirm Clear",
nullptr,
89 ImGuiWindowFlags_AlwaysAutoResize)) {
90 ImGui::Text(
"Clear all learned knowledge?");
91 ImGui::Text(
"This action cannot be undone.");
94 if (ImGui::Button(
"Yes, Clear All", ImVec2(120, 0))) {
98 ImGui::CloseCurrentPopup();
101 if (ImGui::Button(
"Cancel", ImVec2(120, 0))) {
102 ImGui::CloseCurrentPopup();
115 {.bg = theme.panel_bg_color},
true);
118 float column_width = ImGui::GetContentRegionAvail().x / 4;
120 ImGui::Columns(4,
"##StatsColumns",
false);
121 ImGui::SetColumnWidth(0, column_width);
122 ImGui::SetColumnWidth(1, column_width);
123 ImGui::SetColumnWidth(2, column_width);
124 ImGui::SetColumnWidth(3, column_width);
126 ImGui::TextColored(theme.accent_color,
"%d", stats.preference_count);
127 ImGui::Text(
"Preferences");
130 ImGui::TextColored(theme.accent_color,
"%d", stats.pattern_count);
131 ImGui::Text(
"Patterns");
134 ImGui::TextColored(theme.accent_color,
"%d", stats.project_count);
135 ImGui::Text(
"Projects");
138 ImGui::TextColored(theme.accent_color,
"%d", stats.memory_count);
139 ImGui::Text(
"Memories");
149 ImGui::Text(
"Add Preference:");
150 ImGui::PushItemWidth(150);
152 ImGui::PopItemWidth();
154 ImGui::PushItemWidth(200);
156 ImGui::PopItemWidth();
173 ImGui::TextDisabled(
"No preferences stored");
175 ImGui::BeginChild(
"##PrefsList", ImVec2(0, 0),
true);
176 for (
const auto& [key, value] : prefs) {
177 ImGui::PushID(key.c_str());
180 ImGui::TextColored(ImVec4(0.7f, 0.9f, 1.0f, 1.0f),
"%s", key.c_str());
181 ImGui::SameLine(200);
184 ImGui::TextWrapped(
"%s", value.c_str());
185 ImGui::SameLine(ImGui::GetContentRegionAvail().x - 30);
205 if (patterns.empty()) {
206 ImGui::TextDisabled(
"No patterns learned yet");
208 "Patterns are learned automatically as you work with ROMs. "
209 "The agent remembers frequently accessed rooms, sprite "
210 "distributions, and tile usage patterns.");
214 ImGui::BeginChild(
"##PatternsList", ImVec2(0, 0),
true);
215 for (
size_t i = 0; i < patterns.size(); ++i) {
216 const auto& pattern = patterns[i];
217 ImGui::PushID(
static_cast<int>(i));
221 pattern.pattern_type.c_str());
224 ImGui::TextDisabled(
"ROM Hash: %s...",
225 pattern.rom_hash.substr(0, 16).c_str());
226 ImGui::TextDisabled(
"Confidence: %.0f%%", pattern.confidence * 100);
227 ImGui::TextDisabled(
"Access Count: %d", pattern.access_count);
230 if (pattern.pattern_data.size() > 100) {
231 ImGui::TextWrapped(
"Data: %s...",
232 pattern.pattern_data.substr(0, 100).c_str());
234 ImGui::TextWrapped(
"Data: %s", pattern.pattern_data.c_str());
249 if (projects.empty()) {
250 ImGui::TextDisabled(
"No project contexts saved");
252 "Project contexts store ROM-specific notes, goals, and custom labels. "
253 "They're saved automatically when working with a project.");
257 ImGui::BeginChild(
"##ProjectsList", ImVec2(0, 0),
true);
258 for (
size_t i = 0; i < projects.size(); ++i) {
259 const auto& project = projects[i];
260 ImGui::PushID(
static_cast<int>(i));
263 project.project_name.c_str());
266 ImGui::TextDisabled(
"ROM Hash: %s...",
267 project.rom_hash.substr(0, 16).c_str());
270 if (project.context_data.size() > 200) {
271 ImGui::TextWrapped(
"Context: %s...",
272 project.context_data.substr(0, 200).c_str());
274 ImGui::TextWrapped(
"Context: %s", project.context_data.c_str());
288 ImGui::Text(
"Search:");
290 ImGui::PushItemWidth(300);
291 bool search_changed =
293 ImGui::PopItemWidth();
298 std::vector<cli::agent::LearnedKnowledgeService::ConversationMemory> memories;
305 if (memories.empty()) {
309 ImGui::TextDisabled(
"No conversation memories stored");
311 "Conversation memories are summaries of past discussions with the "
312 "agent. They help maintain context across sessions.");
317 ImGui::BeginChild(
"##MemoriesList", ImVec2(0, 0),
true);
318 for (
size_t i = 0; i < memories.size(); ++i) {
319 const auto& memory = memories[i];
320 ImGui::PushID(
static_cast<int>(i));
323 memory.topic.c_str());
326 ImGui::TextWrapped(
"%s", memory.summary.c_str());
328 if (!memory.key_facts.empty()) {
329 ImGui::Text(
"Key Facts:");
330 for (
const auto& fact : memory.key_facts) {
331 ImGui::BulletText(
"%s", fact.c_str());
335 ImGui::TextDisabled(
"Access Count: %d", memory.access_count);
Manages persistent learned information across agent sessions.
std::vector< ProjectContext > GetAllProjects() const
std::vector< ConversationMemory > GetRecentMemories(int limit=10) const
std::vector< ConversationMemory > SearchMemories(const std::string &query) const
std::vector< ROMPattern > QueryPatterns(const std::string &type, const std::string &rom_hash="") const
std::map< std::string, std::string > GetAllPreferences() const
void RenderStatsSection(cli::agent::LearnedKnowledgeService *service)
void RenderPreferencesTab(cli::agent::LearnedKnowledgeService *service, const Callbacks &callbacks, ToastManager *toast_manager)
void RenderPatternsTab(cli::agent::LearnedKnowledgeService *service)
void Draw(AgentUIContext *context, cli::agent::LearnedKnowledgeService *knowledge_service, const Callbacks &callbacks, ToastManager *toast_manager)
void RenderProjectsTab(cli::agent::LearnedKnowledgeService *service)
void RenderMemoriesTab(cli::agent::LearnedKnowledgeService *service)
char new_pref_value_[256]
Unified context for agent UI components.
RAII guard for ImGui style colors.
RAII guard for ImGui child windows with optional styling.
#define ICON_MD_PSYCHOLOGY
#define ICON_MD_DELETE_FOREVER
const AgentUITheme & GetTheme()
bool BeginThemedTabBar(const char *id, ImGuiTabBarFlags flags)
A stylized tab bar with "Mission Control" branding.
std::function< void(const std::string &) remove_preference)
std::function< void()> refresh_knowledge
std::function< void()> clear_all_knowledge
std::function< void(const std::string &, const std::string &) set_preference)
std::function< void()> export_knowledge