67 ImGuiIO& io = ImGui::GetIO();
68 ImGui::SetNextWindowPos(ImVec2(io.DisplaySize.x -
drawer_width_, 0),
70 ImGui::SetNextWindowSize(ImVec2(
drawer_width_, io.DisplaySize.y),
73 ImGuiWindowFlags flags = ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize |
74 ImGuiWindowFlags_NoCollapse;
76 if (ImGui::Begin(
"Agent Proposals", &
visible_, flags)) {
95 float list_height = ImGui::GetContentRegionAvail().y * 0.4f;
97 ImGui::BeginChild(
"ProposalList", ImVec2(0, list_height),
true);
103 ImGui::BeginChild(
"ProposalDetail", ImVec2(0, 0),
true);
112 ImGui::OpenPopup(
"Confirm Action");
116 if (ImGui::BeginPopupModal(
"Confirm Action",
nullptr,
117 ImGuiWindowFlags_AlwaysAutoResize)) {
118 ImGui::Text(
"Are you sure you want to %s this proposal?",
122 if (ImGui::Button(
"Yes", ImVec2(120, 0))) {
130 ImGui::CloseCurrentPopup();
134 if (ImGui::Button(
"No", ImVec2(120, 0))) {
135 ImGui::CloseCurrentPopup();
140#ifdef YAZE_ENABLE_POLICY_FRAMEWORK
143 ImGui::OpenPopup(
"Override Policy");
147 if (ImGui::BeginPopupModal(
"Override Policy",
nullptr,
148 ImGuiWindowFlags_AlwaysAutoResize)) {
152 ImGui::TextWrapped(
"This proposal has policy warnings.");
153 ImGui::TextWrapped(
"Do you want to override and accept anyway?");
156 "Note: This action will be logged.");
159 if (ImGui::Button(
"Override and Accept", ImVec2(150, 0))) {
162 ImGui::CloseCurrentPopup();
165 if (ImGui::Button(
"Cancel", ImVec2(150, 0))) {
166 ImGui::CloseCurrentPopup();
175 ImGui::TextWrapped(
"No proposals found.");
176 ImGui::TextWrapped(
"Run CLI command: z3ed agent run --prompt \"...\"");
180 ImGuiTableFlags flags =
181 ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg | ImGuiTableFlags_ScrollY;
183 if (ImGui::BeginTable(
"ProposalsTable", 3, flags)) {
184 ImGui::TableSetupColumn(
"ID", ImGuiTableColumnFlags_WidthFixed, 60.0f);
185 ImGui::TableSetupColumn(
"Status", ImGuiTableColumnFlags_WidthFixed, 80.0f);
186 ImGui::TableSetupColumn(
"Prompt", ImGuiTableColumnFlags_WidthStretch);
187 ImGui::TableSetupScrollFreeze(0, 1);
188 ImGui::TableHeadersRow();
191 ImGui::TableNextRow();
194 ImGui::TableSetColumnIndex(0);
196 if (ImGui::Selectable(proposal.id.c_str(), is_selected,
197 ImGuiSelectableFlags_SpanAllColumns)) {
202 ImGui::TableSetColumnIndex(1);
203 switch (proposal.status) {
216 ImGui::TableSetColumnIndex(2);
217 std::string truncated = proposal.prompt;
218 if (truncated.length() > 30) {
219 truncated = truncated.substr(0, 27) +
"...";
221 ImGui::TextWrapped(
"%s", truncated.c_str());
235 if (ImGui::CollapsingHeader(
"Metadata", ImGuiTreeNodeFlags_DefaultOpen)) {
236 ImGui::Text(
"ID: %s", p.id.c_str());
237 ImGui::Text(
"Sandbox: %s", p.sandbox_id.c_str());
238 ImGui::Text(
"Created: %s", absl::FormatTime(p.created_at).c_str());
239 if (p.reviewed_at.has_value()) {
240 ImGui::Text(
"Reviewed: %s", absl::FormatTime(*p.reviewed_at).c_str());
242 ImGui::Text(
"Commands: %d", p.commands_executed);
243 ImGui::Text(
"Bytes Changed: %d", p.bytes_changed);
245 ImGui::TextWrapped(
"Prompt: %s", p.prompt.c_str());
246 ImGui::TextWrapped(
"Description: %s", p.description.c_str());
250 if (ImGui::CollapsingHeader(
"Diff", ImGuiTreeNodeFlags_DefaultOpen)) {
251 if (
diff_content_.empty() && std::filesystem::exists(p.diff_path)) {
252 std::ifstream diff_file(p.diff_path);
253 if (diff_file.is_open()) {
254 std::stringstream buffer;
255 buffer << diff_file.rdbuf();
261 ImGui::BeginChild(
"DiffContent", ImVec2(0, 150),
true,
262 ImGuiWindowFlags_HorizontalScrollbar);
266 ImGui::TextWrapped(
"No diff available");
271 if (ImGui::CollapsingHeader(
"Execution Log")) {
272 if (
log_content_.empty() && std::filesystem::exists(p.log_path)) {
273 std::ifstream log_file(p.log_path);
274 if (log_file.is_open()) {
275 std::stringstream buffer;
278 while (std::getline(log_file, line) &&
280 buffer << line <<
"\n";
284 buffer <<
"... (truncated, see " << p.log_path.string() <<
")\n";
291 ImGui::BeginChild(
"LogContent", ImVec2(0, 150),
true,
292 ImGuiWindowFlags_HorizontalScrollbar);
296 ImGui::TextWrapped(
"No log available");
301#ifdef YAZE_ENABLE_POLICY_FRAMEWORK
322#ifdef YAZE_ENABLE_POLICY_FRAMEWORK
333 if (ImGui::CollapsingHeader(
"Policy Status",
334 ImGuiTreeNodeFlags_DefaultOpen)) {
337 if (!policy_eval.IsEnabled()) {
341 "Create .yaze/policies/agent.yaml to enable policy evaluation");
346 auto policy_result = policy_eval.EvaluateProposal(p.id);
348 if (!policy_result.ok()) {
351 ImGui::TextWrapped(
"%s", policy_result.status().message().data());
355 const auto& result = policy_result.value();
358 if (result.is_clean()) {
361 }
else if (result.passed) {
372 if (!result.critical_violations.empty()) {
375 for (
const auto& violation : result.critical_violations) {
377 ImGui::TextWrapped(
"%s: %s", violation.policy_name.c_str(),
378 violation.message.c_str());
379 if (!violation.details.empty()) {
382 violation.details.c_str());
390 if (!result.warnings.empty()) {
393 for (
const auto& violation : result.warnings) {
395 ImGui::TextWrapped(
"%s: %s", violation.policy_name.c_str(),
396 violation.message.c_str());
397 if (!violation.details.empty()) {
400 violation.details.c_str());
408 if (!result.info.empty()) {
411 for (
const auto& violation : result.info) {
413 ImGui::TextWrapped(
"%s: %s", violation.policy_name.c_str(),
414 violation.message.c_str());
555 auto proposal_or = registry.GetProposal(proposal_id);
556 if (!proposal_or.ok()) {
557 return proposal_or.status();
560 const auto& proposal = *proposal_or;
564 return absl::FailedPreconditionError(
565 "No ROM loaded. Cannot merge proposal changes.");
570 auto sandboxes = sandbox_mgr.ListSandboxes();
572 std::filesystem::path sandbox_rom_path;
573 for (
const auto& sandbox : sandboxes) {
574 if (sandbox.id == proposal.sandbox_id) {
575 sandbox_rom_path = sandbox.rom_path;
580 if (sandbox_rom_path.empty()) {
581 return absl::NotFoundError(
582 absl::StrFormat(
"Sandbox ROM not found for proposal %s (sandbox: %s)",
583 proposal_id, proposal.sandbox_id));
588 if (!std::filesystem::exists(sandbox_rom_path, ec)) {
589 return absl::NotFoundError(absl::StrFormat(
590 "Sandbox ROM file does not exist: %s", sandbox_rom_path.string()));
595 auto load_status = sandbox_rom.
LoadFromFile(sandbox_rom_path.string());
596 if (!load_status.ok()) {
597 return absl::InternalError(absl::StrFormat(
"Failed to load sandbox ROM: %s",
598 load_status.message()));
603 const auto& sandbox_data = sandbox_rom.
vector();
605 if (!merge_status.ok()) {
606 return absl::InternalError(absl::StrFormat(
607 "Failed to merge sandbox ROM data: %s", merge_status.message()));
611 auto status = registry.UpdateStatus(
623 return absl::UnimplementedError(
"AI features disabled");