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"
10#include "imgui/imgui.h"
11
12namespace yaze {
13namespace editor {
14
16 const Z3EDCommandCallbacks& callbacks,
17 ToastManager* toast_manager) {
18 auto& state = context->z3ed_command_state();
19
20 ImGui::PushID("Z3EDCmdPanel");
21 ImVec4 command_color = ImVec4(1.0f, 0.647f, 0.0f, 1.0f);
22
23 // Dense header (no collapsing)
24 {
25 gui::StyledChild cmd_child(
26 "Z3ED_CommandsChild", ImVec2(0, 100),
27 {.bg = ImVec4(0.14f, 0.12f, 0.18f, 0.95f)}, true);
28
29 ImGui::TextColored(command_color, ICON_MD_TERMINAL " Commands");
30 ImGui::Separator();
31
32 ImGui::SetNextItemWidth(-60);
33 ImGui::InputTextWithHint(
34 "##z3ed_cmd", "Command...", state.command_input_buffer,
35 IM_ARRAYSIZE(state.command_input_buffer));
36 ImGui::SameLine();
37 ImGui::BeginDisabled(state.command_running);
38 if (ImGui::Button(ICON_MD_PLAY_ARROW "##z3ed_run", ImVec2(50, 0))) {
39 if (callbacks.run_agent_task) {
40 std::string command = state.command_input_buffer;
41 state.command_running = true;
42 auto status = callbacks.run_agent_task(command);
43 state.command_running = false;
44 if (status.ok() && toast_manager) {
45 toast_manager->Show("Task started", ToastType::kSuccess, 2.0f);
46 }
47 }
48 }
49 ImGui::EndDisabled();
50 if (ImGui::IsItemHovered()) {
51 ImGui::SetTooltip("Run command");
52 }
53
54 // Compact action buttons (inline)
55 if (ImGui::SmallButton(ICON_MD_PREVIEW)) {
56 if (callbacks.list_proposals) {
57 auto result = callbacks.list_proposals();
58 if (result.ok()) {
59 const auto& proposals = *result;
60 state.command_output = absl::StrJoin(proposals, "\n");
61 }
62 }
63 }
64 if (ImGui::IsItemHovered())
65 ImGui::SetTooltip("List");
66 ImGui::SameLine();
67 if (ImGui::SmallButton(ICON_MD_DIFFERENCE)) {
68 if (callbacks.diff_proposal) {
69 auto result = callbacks.diff_proposal("");
70 if (result.ok())
71 state.command_output = *result;
72 }
73 }
74 if (ImGui::IsItemHovered())
75 ImGui::SetTooltip("Diff");
76 ImGui::SameLine();
77 if (ImGui::SmallButton(ICON_MD_CHECK)) {
78 if (callbacks.accept_proposal) {
79 callbacks.accept_proposal("");
80 }
81 }
82 if (ImGui::IsItemHovered())
83 ImGui::SetTooltip("Accept");
84 ImGui::SameLine();
85 if (ImGui::SmallButton(ICON_MD_CLOSE)) {
86 if (callbacks.reject_proposal) {
87 callbacks.reject_proposal("");
88 }
89 }
90 if (ImGui::IsItemHovered())
91 ImGui::SetTooltip("Reject");
92
93 if (!state.command_output.empty()) {
94 ImGui::Separator();
95 ImGui::TextDisabled(
96 "%s", state.command_output.substr(0, 100).c_str());
97 }
98 }
99
100 ImGui::PopID();
101}
102
103} // namespace editor
104} // 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)
RAII guard for ImGui child windows with optional styling.
#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)