feat: Implement ProposalDrawer for managing agent proposals with UI controls
This commit is contained in:
@@ -14,7 +14,7 @@ This plan decomposes the design additions (Sections 11–15 of `E6-z3ed-cli-desi
|
||||
| Verification Pipeline | Build layered testing + CI coverage. | Phase 6+ | Integrates with harness + CLI suites. |
|
||||
| Telemetry & Learning | Capture signals to improve prompts + heuristics. | Phase 8 | Optional/opt-in features. |
|
||||
|
||||
### Progress snapshot — 2025-10-01 final update (Phase 6 + Agent Diff & List Complete)
|
||||
### Progress snapshot — 2025-10-01 final update (Phase 6 + AW-03 Complete)
|
||||
|
||||
- ✅ CLI global flag passthrough now preserves subcommand options, letting `agent describe` and palette routines accept both space-separated and `--flag=value` styles alongside the updated help text.
|
||||
- ✅ `agent describe --format yaml` writes catalog data end-to-end; JSON format also working correctly.
|
||||
@@ -30,6 +30,8 @@ This plan decomposes the design additions (Sections 11–15 of `E6-z3ed-cli-desi
|
||||
- ✅ **Implemented `agent list` command** to enumerate all proposals with status filtering and metadata display.
|
||||
- ✅ **Updated resource catalog** with agent list and diff actions including comprehensive argument and return schemas.
|
||||
- ✅ **Regenerated API documentation** (`docs/api/z3ed-resources.yaml`) with all new agent commands.
|
||||
- ✅ **Implemented ProposalDrawer ImGui component** with proposal list, detail view, and accept/reject/delete actions (AW-03).
|
||||
- ✅ **Fixed linker errors** by adding CLI service sources to app/emu/lib build targets in CMake configuration.
|
||||
|
||||
## 2. Task Backlog
|
||||
|
||||
@@ -42,7 +44,7 @@ This plan decomposes the design additions (Sections 11–15 of `E6-z3ed-cli-desi
|
||||
| RC-05 | Harden CLI command routing/flag parsing to unblock agent automation. | Resource Catalogue | Code | Done | Fixed rom info handler to use FLAGS_rom |
|
||||
| AW-01 | Implement sandbox ROM cloning and tracking (`RomSandboxManager`). | Acceptance Workflow | Code | Done | ROM sandbox manager operational with lifecycle management |
|
||||
| AW-02 | Build proposal registry service storing diffs, logs, screenshots. | Acceptance Workflow | Code | Done | ProposalRegistry implemented and integrated with agent run workflow |
|
||||
| AW-03 | Add ImGui drawer for proposals with accept/reject controls. | Acceptance Workflow | UX | Planned | AW-02 |
|
||||
| AW-03 | Add ImGui drawer for proposals with accept/reject controls. | Acceptance Workflow | UX | Done | ProposalDrawer GUI complete with list, detail, and action buttons |
|
||||
| AW-04 | Implement policy evaluation for gating accept buttons. | Acceptance Workflow | Code | Planned | AW-03 |
|
||||
| AW-05 | Draft `.z3ed-diff` hybrid schema (binary deltas + JSON metadata). | Acceptance Workflow | Design | Planned | AW-01 |
|
||||
| IT-01 | Create `ImGuiTestHarness` IPC service embedded in `yaze_test`. | ImGuiTest Bridge | Code | Planned | Harness transport decision |
|
||||
@@ -168,15 +170,38 @@ The foundational infrastructure for proposal tracking and review is now operatio
|
||||
- Updated agent resource description to include listing and diffing capabilities
|
||||
- Regenerated `docs/api/z3ed-resources.yaml` with new agent actions
|
||||
|
||||
**ProposalDrawer GUI Component** (Completed Oct 1, 2025):
|
||||
- ImGui right-side drawer for proposal review (AW-03)
|
||||
- Split view: proposal list (top) + detail view (bottom)
|
||||
- List view: table with ID, status, prompt columns; colored status indicators
|
||||
- Detail view: collapsible sections for metadata/diff/log; syntax-aware display
|
||||
- Action buttons: Accept, Reject, Delete with confirmation dialogs
|
||||
- Status filtering (All/Pending/Accepted/Rejected)
|
||||
- Integrated into EditorManager with Debug → Agent Proposals menu
|
||||
- Accept/Reject updates ProposalRegistry status
|
||||
- Delete removes proposal from registry and filesystem
|
||||
- TODO: Implement actual ROM merging in AcceptProposal method
|
||||
|
||||
**CMake Build Integration**:
|
||||
- Added `cli/service/proposal_registry.cc` and `cli/service/rom_sandbox_manager.cc` to all app targets
|
||||
- Fixed linker errors by including CLI service sources in:
|
||||
- `yaze` (main GUI app)
|
||||
- `yaze_emu` (emulator standalone)
|
||||
- `yaze_core` (testing library)
|
||||
- `yaze_c` (C API library)
|
||||
- All targets now build successfully with ProposalDrawer dependencies
|
||||
|
||||
**Architecture Benefits**:
|
||||
- Clean separation: RomSandboxManager (file ops) ↔ ProposalRegistry (metadata)
|
||||
- Thread-safe with mutex protection for concurrent access
|
||||
- Extensible design ready for ImGui review UI (AW-03)
|
||||
- Proposal persistence enables post-session review and auditing
|
||||
- Proposal-centric workflow enables human-in-the-loop review
|
||||
- GUI and CLI both have full access to proposal system
|
||||
|
||||
**Next Steps for AW Workstream**:
|
||||
- AW-03: ImGui drawer with accept/reject controls
|
||||
- Test ProposalDrawer in running application
|
||||
- Complete ROM merging in AcceptProposal method
|
||||
- AW-04: Policy evaluation for gating mutations
|
||||
- AW-05: `.z3ed-diff` hybrid format design
|
||||
|
||||
@@ -193,6 +218,22 @@ The foundational infrastructure for proposal tracking and review is now operatio
|
||||
6. `src/cli/service/proposal_registry.h` - New proposal tracking service interface
|
||||
7. `src/cli/service/proposal_registry.cc` - Implementation with full lifecycle management
|
||||
8. `src/cli/handlers/agent.cc` - Integrated ProposalRegistry into agent run workflow
|
||||
|
||||
**Agent Diff & List Enhancement**:
|
||||
9. `src/cli/handlers/agent.cc` - Enhanced HandleDiffCommand with proposal reading, added HandleListCommand
|
||||
10. `src/cli/service/resource_catalog.cc` - Added agent list/diff actions with schemas
|
||||
11. `docs/api/z3ed-resources.yaml` - Regenerated with new agent commands
|
||||
12. `docs/E6-z3ed-cli-design.md` - Updated Section 8.1 with list/diff documentation
|
||||
|
||||
**AW-03 (ProposalDrawer GUI)**:
|
||||
13. `src/app/editor/system/proposal_drawer.h` - Complete drawer interface with Draw/Accept/Reject/Delete
|
||||
14. `src/app/editor/system/proposal_drawer.cc` - Full implementation (~350 lines) with list/detail views
|
||||
15. `src/app/editor/editor_manager.h` - Added ProposalDrawer member and include
|
||||
16. `src/app/editor/editor_manager.cc` - Added menu item and Draw() call in Update loop
|
||||
17. `src/CMakeLists.txt` - Added proposal_drawer files to System Editor source group
|
||||
18. `src/app/app.cmake` - Added CLI service sources to yaze target (both Apple and non-Apple builds)
|
||||
19. `src/app/emu/emu.cmake` - Added CLI service sources to yaze_emu target
|
||||
20. `src/CMakeLists.txt` - Added CLI service sources to yaze_core library sources
|
||||
9. `src/cli/z3ed.cmake` - Added proposal_registry.cc to build
|
||||
10. `docs/E6-z3ed-implementation-plan.md` - Updated progress and task statuses
|
||||
|
||||
|
||||
@@ -169,6 +169,9 @@ if (YAZE_BUILD_LIB)
|
||||
${YAZE_APP_EMU_SRC}
|
||||
${YAZE_GUI_SRC}
|
||||
${YAZE_UTIL_SRC}
|
||||
# CLI service sources (needed for ProposalDrawer)
|
||||
cli/service/proposal_registry.cc
|
||||
cli/service/rom_sandbox_manager.cc
|
||||
)
|
||||
|
||||
# Create full library for C API
|
||||
@@ -434,6 +437,8 @@ source_group("Application\\Editor\\System" FILES
|
||||
app/editor/system/log_viewer.h
|
||||
app/editor/system/memory_editor.cc
|
||||
app/editor/system/memory_editor.h
|
||||
app/editor/system/proposal_drawer.cc
|
||||
app/editor/system/proposal_drawer.h
|
||||
app/editor/system/rom_analyzer.cc
|
||||
app/editor/system/rom_analyzer.h
|
||||
)
|
||||
|
||||
@@ -18,6 +18,9 @@ if (APPLE)
|
||||
${YAZE_UTIL_SRC}
|
||||
${YAZE_GUI_SRC}
|
||||
${IMGUI_SRC}
|
||||
# CLI service sources (needed for ProposalDrawer)
|
||||
cli/service/proposal_registry.cc
|
||||
cli/service/rom_sandbox_manager.cc
|
||||
# Bundled Resources
|
||||
${YAZE_RESOURCE_FILES}
|
||||
)
|
||||
@@ -52,6 +55,9 @@ else()
|
||||
${YAZE_UTIL_SRC}
|
||||
${YAZE_GUI_SRC}
|
||||
${IMGUI_SRC}
|
||||
# CLI service sources (needed for ProposalDrawer)
|
||||
cli/service/proposal_registry.cc
|
||||
cli/service/rom_sandbox_manager.cc
|
||||
)
|
||||
|
||||
# Add asset files for Windows/Linux builds
|
||||
|
||||
@@ -35,4 +35,5 @@ set(
|
||||
app/test/integrated_test_suite.h
|
||||
app/test/rom_dependent_test_suite.h
|
||||
app/test/unit_test_suite.h
|
||||
app/editor/system/proposal_drawer.cc
|
||||
)
|
||||
|
||||
@@ -700,6 +700,15 @@ void EditorManager::Initialize(const std::string& filename) {
|
||||
[&]() { show_asm_editor_ = true; }},
|
||||
{absl::StrCat(ICON_MD_SETTINGS, " Feature Flags"), "",
|
||||
[&]() { popup_manager_->Show("Feature Flags"); }},
|
||||
|
||||
{gui::kSeparator, "", nullptr, []() { return true; }},
|
||||
|
||||
// Agent Proposals
|
||||
{absl::StrCat(ICON_MD_PREVIEW, " Agent Proposals"), "",
|
||||
[&]() { proposal_drawer_.Toggle(); }},
|
||||
|
||||
{gui::kSeparator, "", nullptr, []() { return true; }},
|
||||
|
||||
{absl::StrCat(ICON_MD_PALETTE, " Graphics Debugging"), "", []() {}, []() { return true; },
|
||||
std::vector<gui::MenuItem>{
|
||||
{absl::StrCat(ICON_MD_REFRESH, " Clear Graphics Cache"), "",
|
||||
@@ -1136,6 +1145,9 @@ void EditorManager::DrawMenuBar() {
|
||||
}
|
||||
#endif
|
||||
|
||||
// Agent proposal drawer
|
||||
proposal_drawer_.Draw();
|
||||
|
||||
// Welcome screen (accessible from View menu)
|
||||
if (show_welcome_screen_) {
|
||||
DrawWelcomeScreen();
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include "app/editor/overworld/overworld_editor.h"
|
||||
#include "app/editor/sprite/sprite_editor.h"
|
||||
#include "app/editor/system/popup_manager.h"
|
||||
#include "app/editor/system/proposal_drawer.h"
|
||||
#include "app/editor/system/settings_editor.h"
|
||||
#include "app/editor/system/toast_manager.h"
|
||||
#include "app/emu/emulator.h"
|
||||
@@ -173,6 +174,10 @@ class EditorManager {
|
||||
// Testing interface
|
||||
bool show_test_dashboard_ = false;
|
||||
bool show_performance_dashboard_ = false;
|
||||
|
||||
// Agent proposal drawer
|
||||
ProposalDrawer proposal_drawer_;
|
||||
bool show_proposal_drawer_ = false;
|
||||
|
||||
std::string version_ = "";
|
||||
std::string settings_filename_ = "settings.ini";
|
||||
|
||||
360
src/app/editor/system/proposal_drawer.cc
Normal file
360
src/app/editor/system/proposal_drawer.cc
Normal file
@@ -0,0 +1,360 @@
|
||||
#include "app/editor/system/proposal_drawer.h"
|
||||
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
|
||||
#include "absl/strings/str_format.h"
|
||||
#include "absl/time/time.h"
|
||||
#include "imgui/imgui.h"
|
||||
#include "app/gui/icons.h"
|
||||
|
||||
namespace yaze {
|
||||
namespace editor {
|
||||
|
||||
ProposalDrawer::ProposalDrawer() {
|
||||
RefreshProposals();
|
||||
}
|
||||
|
||||
void ProposalDrawer::Draw() {
|
||||
if (!visible_) return;
|
||||
|
||||
// Set drawer position on the right side
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
ImGui::SetNextWindowPos(ImVec2(io.DisplaySize.x - drawer_width_, 0),
|
||||
ImGuiCond_Always);
|
||||
ImGui::SetNextWindowSize(ImVec2(drawer_width_, io.DisplaySize.y),
|
||||
ImGuiCond_Always);
|
||||
|
||||
ImGuiWindowFlags flags = ImGuiWindowFlags_NoMove |
|
||||
ImGuiWindowFlags_NoResize |
|
||||
ImGuiWindowFlags_NoCollapse;
|
||||
|
||||
if (ImGui::Begin("Agent Proposals", &visible_, flags)) {
|
||||
if (needs_refresh_) {
|
||||
RefreshProposals();
|
||||
needs_refresh_ = false;
|
||||
}
|
||||
|
||||
// Header with refresh button
|
||||
if (ImGui::Button(ICON_MD_REFRESH " Refresh")) {
|
||||
RefreshProposals();
|
||||
}
|
||||
ImGui::SameLine();
|
||||
DrawStatusFilter();
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
// Split view: proposal list on top, details on bottom
|
||||
float list_height = ImGui::GetContentRegionAvail().y * 0.4f;
|
||||
|
||||
ImGui::BeginChild("ProposalList", ImVec2(0, list_height), true);
|
||||
DrawProposalList();
|
||||
ImGui::EndChild();
|
||||
|
||||
if (selected_proposal_) {
|
||||
ImGui::Separator();
|
||||
ImGui::BeginChild("ProposalDetail", ImVec2(0, 0), true);
|
||||
DrawProposalDetail();
|
||||
ImGui::EndChild();
|
||||
}
|
||||
}
|
||||
ImGui::End();
|
||||
|
||||
// Confirmation dialog
|
||||
if (show_confirm_dialog_) {
|
||||
ImGui::OpenPopup("Confirm Action");
|
||||
show_confirm_dialog_ = false;
|
||||
}
|
||||
|
||||
if (ImGui::BeginPopupModal("Confirm Action", nullptr,
|
||||
ImGuiWindowFlags_AlwaysAutoResize)) {
|
||||
ImGui::Text("Are you sure you want to %s this proposal?",
|
||||
confirm_action_.c_str());
|
||||
ImGui::Separator();
|
||||
|
||||
if (ImGui::Button("Yes", ImVec2(120, 0))) {
|
||||
if (confirm_action_ == "accept") {
|
||||
AcceptProposal(confirm_proposal_id_);
|
||||
} else if (confirm_action_ == "reject") {
|
||||
RejectProposal(confirm_proposal_id_);
|
||||
} else if (confirm_action_ == "delete") {
|
||||
DeleteProposal(confirm_proposal_id_);
|
||||
}
|
||||
ImGui::CloseCurrentPopup();
|
||||
RefreshProposals();
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("No", ImVec2(120, 0))) {
|
||||
ImGui::CloseCurrentPopup();
|
||||
}
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
}
|
||||
|
||||
void ProposalDrawer::DrawProposalList() {
|
||||
if (proposals_.empty()) {
|
||||
ImGui::TextWrapped("No proposals found.");
|
||||
ImGui::TextWrapped("Run CLI command: z3ed agent run --prompt \"...\"");
|
||||
return;
|
||||
}
|
||||
|
||||
ImGuiTableFlags flags = ImGuiTableFlags_Borders |
|
||||
ImGuiTableFlags_RowBg |
|
||||
ImGuiTableFlags_ScrollY;
|
||||
|
||||
if (ImGui::BeginTable("ProposalsTable", 3, flags)) {
|
||||
ImGui::TableSetupColumn("ID", ImGuiTableColumnFlags_WidthFixed, 60.0f);
|
||||
ImGui::TableSetupColumn("Status", ImGuiTableColumnFlags_WidthFixed, 80.0f);
|
||||
ImGui::TableSetupColumn("Prompt", ImGuiTableColumnFlags_WidthStretch);
|
||||
ImGui::TableSetupScrollFreeze(0, 1);
|
||||
ImGui::TableHeadersRow();
|
||||
|
||||
for (const auto& proposal : proposals_) {
|
||||
ImGui::TableNextRow();
|
||||
|
||||
// ID column
|
||||
ImGui::TableSetColumnIndex(0);
|
||||
bool is_selected = (proposal.id == selected_proposal_id_);
|
||||
if (ImGui::Selectable(proposal.id.c_str(), is_selected,
|
||||
ImGuiSelectableFlags_SpanAllColumns)) {
|
||||
SelectProposal(proposal.id);
|
||||
}
|
||||
|
||||
// Status column
|
||||
ImGui::TableSetColumnIndex(1);
|
||||
switch (proposal.status) {
|
||||
case cli::ProposalRegistry::ProposalStatus::kPending:
|
||||
ImGui::TextColored(ImVec4(1.0f, 0.8f, 0.0f, 1.0f), "Pending");
|
||||
break;
|
||||
case cli::ProposalRegistry::ProposalStatus::kAccepted:
|
||||
ImGui::TextColored(ImVec4(0.0f, 1.0f, 0.0f, 1.0f), "Accepted");
|
||||
break;
|
||||
case cli::ProposalRegistry::ProposalStatus::kRejected:
|
||||
ImGui::TextColored(ImVec4(1.0f, 0.0f, 0.0f, 1.0f), "Rejected");
|
||||
break;
|
||||
}
|
||||
|
||||
// Prompt column (truncated)
|
||||
ImGui::TableSetColumnIndex(2);
|
||||
std::string truncated = proposal.prompt;
|
||||
if (truncated.length() > 30) {
|
||||
truncated = truncated.substr(0, 27) + "...";
|
||||
}
|
||||
ImGui::TextWrapped("%s", truncated.c_str());
|
||||
}
|
||||
|
||||
ImGui::EndTable();
|
||||
}
|
||||
}
|
||||
|
||||
void ProposalDrawer::DrawProposalDetail() {
|
||||
if (!selected_proposal_) return;
|
||||
|
||||
const auto& p = *selected_proposal_;
|
||||
|
||||
// Metadata section
|
||||
if (ImGui::CollapsingHeader("Metadata", ImGuiTreeNodeFlags_DefaultOpen)) {
|
||||
ImGui::Text("ID: %s", p.id.c_str());
|
||||
ImGui::Text("Sandbox: %s", p.sandbox_id.c_str());
|
||||
ImGui::Text("Created: %s", absl::FormatTime(p.created_at).c_str());
|
||||
if (p.reviewed_at.has_value()) {
|
||||
ImGui::Text("Reviewed: %s", absl::FormatTime(*p.reviewed_at).c_str());
|
||||
}
|
||||
ImGui::Text("Commands: %d", p.commands_executed);
|
||||
ImGui::Text("Bytes Changed: %d", p.bytes_changed);
|
||||
ImGui::Separator();
|
||||
ImGui::TextWrapped("Prompt: %s", p.prompt.c_str());
|
||||
ImGui::TextWrapped("Description: %s", p.description.c_str());
|
||||
}
|
||||
|
||||
// Diff section
|
||||
if (ImGui::CollapsingHeader("Diff", ImGuiTreeNodeFlags_DefaultOpen)) {
|
||||
if (diff_content_.empty() && std::filesystem::exists(p.diff_path)) {
|
||||
std::ifstream diff_file(p.diff_path);
|
||||
if (diff_file.is_open()) {
|
||||
std::stringstream buffer;
|
||||
buffer << diff_file.rdbuf();
|
||||
diff_content_ = buffer.str();
|
||||
}
|
||||
}
|
||||
|
||||
if (!diff_content_.empty()) {
|
||||
ImGui::BeginChild("DiffContent", ImVec2(0, 150), true,
|
||||
ImGuiWindowFlags_HorizontalScrollbar);
|
||||
ImGui::TextUnformatted(diff_content_.c_str());
|
||||
ImGui::EndChild();
|
||||
} else {
|
||||
ImGui::TextWrapped("No diff available");
|
||||
}
|
||||
}
|
||||
|
||||
// Log section
|
||||
if (ImGui::CollapsingHeader("Execution Log")) {
|
||||
if (log_content_.empty() && std::filesystem::exists(p.log_path)) {
|
||||
std::ifstream log_file(p.log_path);
|
||||
if (log_file.is_open()) {
|
||||
std::stringstream buffer;
|
||||
std::string line;
|
||||
int line_count = 0;
|
||||
while (std::getline(log_file, line) && line_count < log_display_lines_) {
|
||||
buffer << line << "\n";
|
||||
line_count++;
|
||||
}
|
||||
if (line_count >= log_display_lines_) {
|
||||
buffer << "... (truncated, see " << p.log_path.string() << ")\n";
|
||||
}
|
||||
log_content_ = buffer.str();
|
||||
}
|
||||
}
|
||||
|
||||
if (!log_content_.empty()) {
|
||||
ImGui::BeginChild("LogContent", ImVec2(0, 150), true,
|
||||
ImGuiWindowFlags_HorizontalScrollbar);
|
||||
ImGui::TextUnformatted(log_content_.c_str());
|
||||
ImGui::EndChild();
|
||||
} else {
|
||||
ImGui::TextWrapped("No log available");
|
||||
}
|
||||
}
|
||||
|
||||
// Action buttons
|
||||
ImGui::Separator();
|
||||
DrawActionButtons();
|
||||
}
|
||||
|
||||
void ProposalDrawer::DrawStatusFilter() {
|
||||
const char* filter_labels[] = {"All", "Pending", "Accepted", "Rejected"};
|
||||
int current_filter = static_cast<int>(status_filter_);
|
||||
|
||||
ImGui::SetNextItemWidth(120.0f);
|
||||
if (ImGui::Combo("Filter", ¤t_filter, filter_labels, 4)) {
|
||||
status_filter_ = static_cast<StatusFilter>(current_filter);
|
||||
RefreshProposals();
|
||||
}
|
||||
}
|
||||
|
||||
void ProposalDrawer::DrawActionButtons() {
|
||||
if (!selected_proposal_) return;
|
||||
|
||||
const auto& p = *selected_proposal_;
|
||||
bool is_pending = p.status == cli::ProposalRegistry::ProposalStatus::kPending;
|
||||
|
||||
// Accept button (only for pending proposals)
|
||||
if (is_pending) {
|
||||
if (ImGui::Button(ICON_MD_CHECK " Accept", ImVec2(-1, 0))) {
|
||||
confirm_action_ = "accept";
|
||||
confirm_proposal_id_ = p.id;
|
||||
show_confirm_dialog_ = true;
|
||||
}
|
||||
|
||||
// Reject button (only for pending proposals)
|
||||
if (ImGui::Button(ICON_MD_CLOSE " Reject", ImVec2(-1, 0))) {
|
||||
confirm_action_ = "reject";
|
||||
confirm_proposal_id_ = p.id;
|
||||
show_confirm_dialog_ = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Delete button (for all proposals)
|
||||
if (ImGui::Button(ICON_MD_DELETE " Delete", ImVec2(-1, 0))) {
|
||||
confirm_action_ = "delete";
|
||||
confirm_proposal_id_ = p.id;
|
||||
show_confirm_dialog_ = true;
|
||||
}
|
||||
}
|
||||
|
||||
void ProposalDrawer::RefreshProposals() {
|
||||
auto& registry = cli::ProposalRegistry::Instance();
|
||||
|
||||
std::optional<cli::ProposalRegistry::ProposalStatus> filter;
|
||||
switch (status_filter_) {
|
||||
case StatusFilter::kPending:
|
||||
filter = cli::ProposalRegistry::ProposalStatus::kPending;
|
||||
break;
|
||||
case StatusFilter::kAccepted:
|
||||
filter = cli::ProposalRegistry::ProposalStatus::kAccepted;
|
||||
break;
|
||||
case StatusFilter::kRejected:
|
||||
filter = cli::ProposalRegistry::ProposalStatus::kRejected;
|
||||
break;
|
||||
case StatusFilter::kAll:
|
||||
filter = std::nullopt;
|
||||
break;
|
||||
}
|
||||
|
||||
proposals_ = registry.ListProposals(filter);
|
||||
|
||||
// Clear selection if proposal no longer exists
|
||||
if (!selected_proposal_id_.empty()) {
|
||||
bool found = false;
|
||||
for (const auto& p : proposals_) {
|
||||
if (p.id == selected_proposal_id_) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
selected_proposal_id_.clear();
|
||||
selected_proposal_ = nullptr;
|
||||
diff_content_.clear();
|
||||
log_content_.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ProposalDrawer::SelectProposal(const std::string& proposal_id) {
|
||||
selected_proposal_id_ = proposal_id;
|
||||
selected_proposal_ = nullptr;
|
||||
diff_content_.clear();
|
||||
log_content_.clear();
|
||||
|
||||
// Find the proposal in our list
|
||||
for (auto& p : proposals_) {
|
||||
if (p.id == proposal_id) {
|
||||
selected_proposal_ = &p;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
absl::Status ProposalDrawer::AcceptProposal(const std::string& proposal_id) {
|
||||
auto& registry = cli::ProposalRegistry::Instance();
|
||||
auto status = registry.UpdateStatus(
|
||||
proposal_id, cli::ProposalRegistry::ProposalStatus::kAccepted);
|
||||
|
||||
if (status.ok()) {
|
||||
// TODO: Merge changes into main ROM
|
||||
// This will require integration with the ROM editor
|
||||
}
|
||||
|
||||
needs_refresh_ = true;
|
||||
return status;
|
||||
}
|
||||
|
||||
absl::Status ProposalDrawer::RejectProposal(const std::string& proposal_id) {
|
||||
auto& registry = cli::ProposalRegistry::Instance();
|
||||
auto status = registry.UpdateStatus(
|
||||
proposal_id, cli::ProposalRegistry::ProposalStatus::kRejected);
|
||||
|
||||
needs_refresh_ = true;
|
||||
return status;
|
||||
}
|
||||
|
||||
absl::Status ProposalDrawer::DeleteProposal(const std::string& proposal_id) {
|
||||
auto& registry = cli::ProposalRegistry::Instance();
|
||||
auto status = registry.RemoveProposal(proposal_id);
|
||||
|
||||
if (proposal_id == selected_proposal_id_) {
|
||||
selected_proposal_id_.clear();
|
||||
selected_proposal_ = nullptr;
|
||||
diff_content_.clear();
|
||||
log_content_.clear();
|
||||
}
|
||||
|
||||
needs_refresh_ = true;
|
||||
return status;
|
||||
}
|
||||
|
||||
} // namespace editor
|
||||
} // namespace yaze
|
||||
86
src/app/editor/system/proposal_drawer.h
Normal file
86
src/app/editor/system/proposal_drawer.h
Normal file
@@ -0,0 +1,86 @@
|
||||
#ifndef YAZE_APP_EDITOR_SYSTEM_PROPOSAL_DRAWER_H
|
||||
#define YAZE_APP_EDITOR_SYSTEM_PROPOSAL_DRAWER_H
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "absl/status/status.h"
|
||||
#include "cli/service/proposal_registry.h"
|
||||
|
||||
namespace yaze {
|
||||
namespace editor {
|
||||
|
||||
/**
|
||||
* @class ProposalDrawer
|
||||
* @brief ImGui drawer for displaying and managing agent proposals
|
||||
*
|
||||
* Provides a UI for reviewing agent-generated ROM modification proposals,
|
||||
* including:
|
||||
* - List of all proposals with status indicators
|
||||
* - Detailed view of selected proposal (metadata, diff, logs)
|
||||
* - Accept/Reject controls
|
||||
* - Filtering by status (Pending/Accepted/Rejected)
|
||||
*
|
||||
* Integrates with the CLI ProposalRegistry service to enable
|
||||
* human-in-the-loop review of agentic modifications.
|
||||
*/
|
||||
class ProposalDrawer {
|
||||
public:
|
||||
ProposalDrawer();
|
||||
~ProposalDrawer() = default;
|
||||
|
||||
// Render the proposal drawer UI
|
||||
void Draw();
|
||||
|
||||
// Show/hide the drawer
|
||||
void Show() { visible_ = true; }
|
||||
void Hide() { visible_ = false; }
|
||||
void Toggle() { visible_ = !visible_; }
|
||||
bool IsVisible() const { return visible_; }
|
||||
|
||||
private:
|
||||
void DrawProposalList();
|
||||
void DrawProposalDetail();
|
||||
void DrawStatusFilter();
|
||||
void DrawActionButtons();
|
||||
|
||||
absl::Status AcceptProposal(const std::string& proposal_id);
|
||||
absl::Status RejectProposal(const std::string& proposal_id);
|
||||
absl::Status DeleteProposal(const std::string& proposal_id);
|
||||
|
||||
void RefreshProposals();
|
||||
void SelectProposal(const std::string& proposal_id);
|
||||
|
||||
bool visible_ = false;
|
||||
bool needs_refresh_ = true;
|
||||
|
||||
// Filter state
|
||||
enum class StatusFilter {
|
||||
kAll,
|
||||
kPending,
|
||||
kAccepted,
|
||||
kRejected
|
||||
};
|
||||
StatusFilter status_filter_ = StatusFilter::kAll;
|
||||
|
||||
// Proposal state
|
||||
std::vector<cli::ProposalRegistry::ProposalMetadata> proposals_;
|
||||
std::string selected_proposal_id_;
|
||||
cli::ProposalRegistry::ProposalMetadata* selected_proposal_ = nullptr;
|
||||
|
||||
// Diff display state
|
||||
std::string diff_content_;
|
||||
std::string log_content_;
|
||||
int log_display_lines_ = 50;
|
||||
|
||||
// UI state
|
||||
float drawer_width_ = 400.0f;
|
||||
bool show_confirm_dialog_ = false;
|
||||
std::string confirm_action_;
|
||||
std::string confirm_proposal_id_;
|
||||
};
|
||||
|
||||
} // namespace editor
|
||||
} // namespace yaze
|
||||
|
||||
#endif // YAZE_APP_EDITOR_SYSTEM_PROPOSAL_DRAWER_H
|
||||
@@ -14,6 +14,9 @@ if (NOT YAZE_MINIMAL_BUILD AND APPLE)
|
||||
${YAZE_UTIL_SRC}
|
||||
${YAZE_GUI_SRC}
|
||||
${IMGUI_SRC}
|
||||
# CLI service sources (needed for ProposalDrawer)
|
||||
cli/service/proposal_registry.cc
|
||||
cli/service/rom_sandbox_manager.cc
|
||||
)
|
||||
target_link_libraries(yaze_emu PUBLIC ${COCOA_LIBRARY})
|
||||
elseif(NOT YAZE_MINIMAL_BUILD)
|
||||
@@ -29,6 +32,9 @@ elseif(NOT YAZE_MINIMAL_BUILD)
|
||||
${YAZE_UTIL_SRC}
|
||||
${YAZE_GUI_SRC}
|
||||
${IMGUI_SRC}
|
||||
# CLI service sources (needed for ProposalDrawer)
|
||||
cli/service/proposal_registry.cc
|
||||
cli/service/rom_sandbox_manager.cc
|
||||
)
|
||||
endif()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user