6#include "absl/strings/str_join.h"
10#include "imgui/imgui.h"
16 const Z3EDCommandCallbacks& callbacks,
17 ToastManager* toast_manager) {
18 auto& state = context->z3ed_command_state();
20 ImGui::PushID(
"Z3EDCmdPanel");
21 ImVec4 command_color = ImVec4(1.0f, 0.647f, 0.0f, 1.0f);
25 gui::StyledChild cmd_child(
"Z3ED_CommandsChild", ImVec2(0, 100),
26 {.bg = ImVec4(0.14f, 0.12f, 0.18f, 0.95f)},
32 ImGui::SetNextItemWidth(-60);
33 ImGui::InputTextWithHint(
"##z3ed_cmd",
"Command...",
34 state.command_input_buffer,
35 IM_ARRAYSIZE(state.command_input_buffer));
37 ImGui::BeginDisabled(state.command_running);
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) {
50 if (ImGui::IsItemHovered()) {
51 ImGui::SetTooltip(
"Run command");
56 if (callbacks.list_proposals) {
57 auto result = callbacks.list_proposals();
59 const auto& proposals = *result;
60 state.command_output = absl::StrJoin(proposals,
"\n");
64 if (ImGui::IsItemHovered())
65 ImGui::SetTooltip(
"List");
68 if (callbacks.diff_proposal) {
69 auto result = callbacks.diff_proposal(
"");
71 state.command_output = *result;
74 if (ImGui::IsItemHovered())
75 ImGui::SetTooltip(
"Diff");
78 if (callbacks.accept_proposal) {
79 callbacks.accept_proposal(
"");
82 if (ImGui::IsItemHovered())
83 ImGui::SetTooltip(
"Accept");
86 if (callbacks.reject_proposal) {
87 callbacks.reject_proposal(
"");
90 if (ImGui::IsItemHovered())
91 ImGui::SetTooltip(
"Reject");
93 if (!state.command_output.empty()) {
95 ImGui::TextDisabled(
"%s", state.command_output.substr(0, 100).c_str());
void Draw(AgentUIContext *context, const Z3EDCommandCallbacks &callbacks, ToastManager *toast_manager)
#define ICON_MD_PLAY_ARROW
#define ICON_MD_DIFFERENCE