yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
agent_z3ed_command_panel.cc
Go to the documentation of this file.
2
3#include <string>
4#include <vector>
5
6#include "absl/strings/str_join.h"
9#include "imgui/imgui.h"
10
11namespace yaze {
12namespace editor {
13
15 const Z3EDCommandCallbacks& callbacks,
16 ToastManager* toast_manager) {
17 auto& state = context->z3ed_command_state();
18
19 ImGui::PushID("Z3EDCmdPanel");
20 ImVec4 command_color = ImVec4(1.0f, 0.647f, 0.0f, 1.0f);
21
22 // Dense header (no collapsing)
23 ImGui::PushStyleColor(ImGuiCol_ChildBg, ImVec4(0.14f, 0.12f, 0.18f, 0.95f));
24 ImGui::BeginChild("Z3ED_CommandsChild", ImVec2(0, 100), true);
25
26 ImGui::TextColored(command_color, ICON_MD_TERMINAL " Commands");
27 ImGui::Separator();
28
29 ImGui::SetNextItemWidth(-60);
30 ImGui::InputTextWithHint(
31 "##z3ed_cmd", "Command...", state.command_input_buffer,
32 IM_ARRAYSIZE(state.command_input_buffer));
33 ImGui::SameLine();
34 ImGui::BeginDisabled(state.command_running);
35 if (ImGui::Button(ICON_MD_PLAY_ARROW "##z3ed_run", ImVec2(50, 0))) {
36 if (callbacks.run_agent_task) {
37 std::string command = state.command_input_buffer;
38 state.command_running = true;
39 auto status = callbacks.run_agent_task(command);
40 state.command_running = false;
41 if (status.ok() && toast_manager) {
42 toast_manager->Show("Task started", ToastType::kSuccess, 2.0f);
43 }
44 }
45 }
46 ImGui::EndDisabled();
47 if (ImGui::IsItemHovered()) {
48 ImGui::SetTooltip("Run command");
49 }
50
51 // Compact action buttons (inline)
52 if (ImGui::SmallButton(ICON_MD_PREVIEW)) {
53 if (callbacks.list_proposals) {
54 auto result = callbacks.list_proposals();
55 if (result.ok()) {
56 const auto& proposals = *result;
57 state.command_output = absl::StrJoin(proposals, "\n");
58 }
59 }
60 }
61 if (ImGui::IsItemHovered())
62 ImGui::SetTooltip("List");
63 ImGui::SameLine();
64 if (ImGui::SmallButton(ICON_MD_DIFFERENCE)) {
65 if (callbacks.diff_proposal) {
66 auto result = callbacks.diff_proposal("");
67 if (result.ok())
68 state.command_output = *result;
69 }
70 }
71 if (ImGui::IsItemHovered())
72 ImGui::SetTooltip("Diff");
73 ImGui::SameLine();
74 if (ImGui::SmallButton(ICON_MD_CHECK)) {
75 if (callbacks.accept_proposal) {
76 callbacks.accept_proposal("");
77 }
78 }
79 if (ImGui::IsItemHovered())
80 ImGui::SetTooltip("Accept");
81 ImGui::SameLine();
82 if (ImGui::SmallButton(ICON_MD_CLOSE)) {
83 if (callbacks.reject_proposal) {
84 callbacks.reject_proposal("");
85 }
86 }
87 if (ImGui::IsItemHovered())
88 ImGui::SetTooltip("Reject");
89
90 if (!state.command_output.empty()) {
91 ImGui::Separator();
92 ImGui::TextDisabled(
93 "%s", state.command_output.substr(0, 100).c_str());
94 }
95
96 ImGui::EndChild();
97 ImGui::PopStyleColor();
98
99 ImGui::PopID();
100}
101
102} // namespace editor
103} // namespace yaze
Unified context for agent UI components.
Z3EDCommandState & z3ed_command_state()
void Draw(AgentUIContext *context, const Z3EDCommandCallbacks &callbacks, ToastManager *toast_manager)
void Show(const std::string &message, ToastType type=ToastType::kInfo, float ttl_seconds=3.0f)
#define ICON_MD_PLAY_ARROW
Definition icons.h:1479
#define ICON_MD_CHECK
Definition icons.h:397
#define ICON_MD_DIFFERENCE
Definition icons.h:559
#define ICON_MD_TERMINAL
Definition icons.h:1951
#define ICON_MD_PREVIEW
Definition icons.h:1512
#define ICON_MD_CLOSE
Definition icons.h:418
Callbacks for Z3ED command operations.
std::function< absl::StatusOr< std::vector< std::string > >()> list_proposals
std::function< absl::Status(const std::string &) reject_proposal)
std::function< absl::Status(const std::string &) run_agent_task)
std::function< absl::Status(const std::string &) accept_proposal)
std::function< absl::StatusOr< std::string >(const std::string &) diff_proposal)