From fa935548b06507551701bff5c9d9aab3adc78632 Mon Sep 17 00:00:00 2001 From: Tw93 Date: Wed, 18 Mar 2026 14:50:04 +0800 Subject: [PATCH] fix(optimize): warn before bluetooth refresh Show "Bluetooth devices may disconnect briefly during refresh" before actually restarting bluetoothd, so the user is not surprised by a momentary disconnect. --- lib/optimize/tasks.sh | 3 +++ tests/clean_system_maintenance.bats | 1 + 2 files changed, 4 insertions(+) diff --git a/lib/optimize/tasks.sh b/lib/optimize/tasks.sh index 0f69863..47e0903 100644 --- a/lib/optimize/tasks.sh +++ b/lib/optimize/tasks.sh @@ -641,6 +641,7 @@ opt_bluetooth_reset() { fi local spinner_started="false" + local disconnect_notice="Bluetooth devices may disconnect briefly during refresh" if [[ -t 1 ]]; then MOLE_SPINNER_PREFIX=" " start_inline_spinner "Checking Bluetooth..." spinner_started="true" @@ -688,6 +689,7 @@ opt_bluetooth_reset() { fi if sudo pkill -TERM bluetoothd > /dev/null 2>&1; then + echo -e " ${GRAY}${ICON_WARNING}${NC} ${GRAY}${disconnect_notice}${NC}" sleep 1 if pgrep -x bluetoothd > /dev/null 2>&1; then sudo pkill -KILL bluetoothd > /dev/null 2>&1 || true @@ -707,6 +709,7 @@ opt_bluetooth_reset() { if [[ "$spinner_started" == "true" ]]; then stop_inline_spinner fi + echo -e " ${YELLOW}${ICON_DRY_RUN}${NC} ${disconnect_notice}" opt_msg "Bluetooth module restarted" opt_msg "Connectivity issues resolved" fi diff --git a/tests/clean_system_maintenance.bats b/tests/clean_system_maintenance.bats index 64a647f..048fdeb 100644 --- a/tests/clean_system_maintenance.bats +++ b/tests/clean_system_maintenance.bats @@ -1520,6 +1520,7 @@ opt_bluetooth_reset EOF [ "$status" -eq 0 ] + [[ "$output" == *"Bluetooth devices may disconnect briefly during refresh"* ]] [[ "$output" == *"Bluetooth module restarted"* ]] }