mirror of
https://github.com/tw93/Mole.git
synced 2026-03-22 16:45:07 +00:00
fix(ui): use system sleep for inline spinner
This commit is contained in:
@@ -342,7 +342,7 @@ start_inline_spinner() {
|
||||
# Output to stderr to avoid interfering with stdout
|
||||
printf "\r${MOLE_SPINNER_PREFIX:-}${BLUE}%s${NC} %s" "$c" "$display_message" >&2 || break
|
||||
i=$((i + 1))
|
||||
sleep 0.05
|
||||
/bin/sleep 0.05
|
||||
done
|
||||
|
||||
# Clean up stop file before exiting
|
||||
@@ -366,7 +366,7 @@ stop_inline_spinner() {
|
||||
# Wait briefly for cooperative exit
|
||||
local wait_count=0
|
||||
while kill -0 "$INLINE_SPINNER_PID" 2> /dev/null && [[ $wait_count -lt 5 ]]; do
|
||||
sleep 0.05 2> /dev/null || true
|
||||
/bin/sleep 0.05 2> /dev/null || true
|
||||
wait_count=$((wait_count + 1))
|
||||
done
|
||||
|
||||
|
||||
@@ -204,10 +204,30 @@ sleep 0.1
|
||||
stop_inline_spinner
|
||||
echo "done"
|
||||
EOF
|
||||
)
|
||||
)
|
||||
[[ "$result" == *"done"* ]]
|
||||
}
|
||||
|
||||
@test "start_inline_spinner ignores PATH-provided sleep in TTY mode" {
|
||||
local fake_bin="$HOME/fake-bin"
|
||||
local marker="$HOME/fake-sleep.marker"
|
||||
|
||||
mkdir -p "$fake_bin"
|
||||
cat > "$fake_bin/sleep" <<EOF
|
||||
#!/bin/bash
|
||||
echo "fake" >> "$marker"
|
||||
exec /bin/sleep "\$@"
|
||||
EOF
|
||||
chmod +x "$fake_bin/sleep"
|
||||
|
||||
PATH="$fake_bin:$PATH" PROJECT_ROOT="$PROJECT_ROOT" HOME="$HOME" \
|
||||
/usr/bin/script -q /dev/null /bin/bash --noprofile --norc -c \
|
||||
'source "$PROJECT_ROOT/lib/core/common.sh"; start_inline_spinner "Testing..."; /bin/sleep 0.15; stop_inline_spinner' \
|
||||
> /dev/null 2>&1
|
||||
|
||||
[ ! -f "$marker" ]
|
||||
}
|
||||
|
||||
@test "read_key maps j/k/h/l to navigation" {
|
||||
run bash -c "export MOLE_BASE_LOADED=1; source '$PROJECT_ROOT/lib/core/ui.sh'; echo -n 'j' | read_key"
|
||||
[ "$output" = "DOWN" ]
|
||||
|
||||
Reference in New Issue
Block a user