From dff02adc45cf53830cf138f918771713e805df55 Mon Sep 17 00:00:00 2001 From: GigabiteStudios Date: Thu, 18 Jun 2026 23:06:50 -0500 Subject: [PATCH] fix(toolbar): show progress state for pull and push --- src/ui/gitree_ui.cpp | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/src/ui/gitree_ui.cpp b/src/ui/gitree_ui.cpp index 57566a7..d985ae6 100644 --- a/src/ui/gitree_ui.cpp +++ b/src/ui/gitree_ui.cpp @@ -111,6 +111,10 @@ ImFont* g_bold_font = nullptr; ImFont* g_code_font = nullptr; float g_outline_icon_size = 15.0f; +enum class ToolbarActionRequest { none, pull, push }; +ToolbarActionRequest g_pending_toolbar_action = ToolbarActionRequest::none; +ToolbarActionRequest g_running_toolbar_action = ToolbarActionRequest::none; + float ui(float value) { return value * g_ui_scale; } RepositoryView& repo() { return *g_tabs.at(g_active_tab); } @@ -3037,6 +3041,12 @@ void draw_app() { return; } + const ToolbarActionRequest toolbar_action_to_execute = g_pending_toolbar_action; + if (toolbar_action_to_execute != ToolbarActionRequest::none) { + g_running_toolbar_action = toolbar_action_to_execute; + g_pending_toolbar_action = ToolbarActionRequest::none; + } + const bool code_viewer_open = g_diff_viewer.isOpen(); if (code_viewer_open && ImGui::IsKeyPressed(ImGuiKey_Escape, false)) { g_diff_viewer.close(); @@ -3115,6 +3125,7 @@ void draw_app() { const float action_spacing = ui(3.0f); const float action_group_width = ui(418.0f); const float centered_x = (ImGui::GetWindowWidth() - action_group_width) * 0.5f; + const bool toolbar_busy = g_running_toolbar_action != ToolbarActionRequest::none; ImGui::SetCursorPos({std::max(selectors_right + ui(10.0f), centered_x), ui(2.0f)}); if (toolbar_action("undo", "Undo", ICON_TB_ROTATE_LEFT, "Undo last Git action", true, false, 54)) @@ -3124,14 +3135,18 @@ void draw_app() { g_git_manager->redoCommit(repo(), g_notice); ImGui::SameLine(0, action_spacing); bool pull_dropdown_clicked = false; - if (toolbar_action("pull", "Pull", ICON_TB_DOWNLOAD, pull_mode_name(g_user_data->pullMode()), - true, true, 58, &pull_dropdown_clicked)) - g_git_manager->pull(repo(), g_user_data->pullMode(), g_notice); + const bool pull_running = g_running_toolbar_action == ToolbarActionRequest::pull; + if (toolbar_action("pull", "Pull", pull_running ? ICON_TB_ROTATE_RIGHT : ICON_TB_DOWNLOAD, + pull_running ? "Pull in progress..." : pull_mode_name(g_user_data->pullMode()), + !toolbar_busy, true, 58, &pull_dropdown_clicked)) + g_pending_toolbar_action = ToolbarActionRequest::pull; if (pull_dropdown_clicked) ImGui::OpenPopup("pull_options"); draw_pull_options(); ImGui::SameLine(0, action_spacing); - if (toolbar_action("push", "Push", ICON_TB_UPLOAD, "Push to remote", true, false, 58)) - g_git_manager->push(repo(), g_notice); + const bool push_running = g_running_toolbar_action == ToolbarActionRequest::push; + if (toolbar_action("push", "Push", push_running ? ICON_TB_ROTATE_RIGHT : ICON_TB_UPLOAD, + push_running ? "Push in progress..." : "Push to remote", !toolbar_busy, false, 58)) + g_pending_toolbar_action = ToolbarActionRequest::push; ImGui::SameLine(0, action_spacing); if (toolbar_action("branch_action", "Branch", ICON_TB_CODE_BRANCH, "Create branch", true, false, 64)) { begin_inline_branch(repo().selected_commit >= 0 ? repo().selected_commit : 0); @@ -3201,6 +3216,13 @@ void draw_app() { draw_footer(); draw_popups(); ImGui::End(); + + if (toolbar_action_to_execute == ToolbarActionRequest::pull) + g_git_manager->pull(repo(), g_user_data->pullMode(), g_notice); + else if (toolbar_action_to_execute == ToolbarActionRequest::push) + g_git_manager->push(repo(), g_notice); + if (toolbar_action_to_execute != ToolbarActionRequest::none) + g_running_toolbar_action = ToolbarActionRequest::none; } } // namespace