From cd5ee84da79cf8bdaac1d85de0415f5cd6ad649c Mon Sep 17 00:00:00 2001 From: anaxios Date: Wed, 7 Aug 2024 03:31:14 -0700 Subject: [PATCH] Title: Add spin functionality to resetting AI history Content: Implement a spinner for visual feedback when resetting AI history. Fix issues with killing the spinner process after its completion and reset conversation request failure. URL: https://infer.x64.world/chat --- aicommit | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/aicommit b/aicommit index 43c5a75..b0af910 100755 --- a/aicommit +++ b/aicommit @@ -4,9 +4,10 @@ set -o pipefail ARGS=("${@-}") -pushd "$(pwd)" >/dev/null - TMP_FILE="/tmp/aicommit" +system="You are an expert programmer that values clear, unambiguous communication and are specialized in generating concise and informative git commit messages. Only reply with the commit message and nothing else." + +pushd "$(pwd)" >/dev/null hasFlag() { local flags=("$@") @@ -21,7 +22,17 @@ hasFlag() { echo 'false' } -system="You are an expert programmer that values clear, unambiguous communication and are specialized in generating concise and informative git commit messages. Only reply with the commit message and nothing else." +spin() { + echo "${@}" + while true; do + spinner=('-' '\' '|' '/') + for i in "${spinner[@]}"; do + echo -ne "\r${i}" + sleep .05 + done + done + echo "" +} if ! diff=$(git diff --cached); then echo "Failed to get diff." @@ -38,11 +49,14 @@ message=$( # trunk-ignore(shellcheck/SC2091) # trunk-ignore(shellcheck/SC2310) if $(hasFlag -r --reset); then - echo "resetting AI history." + spin "resetting AI history." & + SPINNER="$!" if ! curl -s -X POST https://infer.x64.world/reset-conversation >/dev/null; then echo "Failed to reset conversation." + kill ${SPINNER} exit 1 fi + kill "${SPINNER}" fi curl -s "https://infer.x64.world/chat" \