From 2c36a4a39da126c30a5a5daedf501229412b2e1a Mon Sep 17 00:00:00 2001
From: Ariver <shanghai3168@gmail.com>
Date: Fri, 26 Jun 2026 17:42:34 +0800
Subject: [PATCH] Release 8.1.0 free Pro unlock

---
 src/Scripts/window_logic_qa.sh |   42 ++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 40 insertions(+), 2 deletions(-)

diff --git a/src/Scripts/window_logic_qa.sh b/src/Scripts/window_logic_qa.sh
index 6c06ecb..81962ab 100755
--- a/src/Scripts/window_logic_qa.sh
+++ b/src/Scripts/window_logic_qa.sh
@@ -16,6 +16,8 @@
 SHOW_DOCK_ICON_VALUE=""
 APP_LANGUAGE_WAS_SET=false
 APP_LANGUAGE_VALUE=""
+PRO_STATE_ENV_WAS_SET=false
+PRO_STATE_ENV_VALUE=""
 FULLSCREEN_QA_PID=""
 CLICK_TOOL="${CLICK_TOOL:-$(command -v cliclick || true)}"
 
@@ -47,6 +49,14 @@
   fi
 }
 
+backup_qa_environment() {
+  local value
+  if value="$(launchctl getenv TAGLAUNCHER_QA_PRO_STATE 2>/dev/null)" && [[ -n "$value" ]]; then
+    PRO_STATE_ENV_WAS_SET=true
+    PRO_STATE_ENV_VALUE="$value"
+  fi
+}
+
 restore_user_defaults() {
   if [[ "$SHOW_DOCK_ICON_WAS_SET" == true ]]; then
     if [[ "$SHOW_DOCK_ICON_VALUE" == "1" || "$SHOW_DOCK_ICON_VALUE" == "true" || "$SHOW_DOCK_ICON_VALUE" == "TRUE" ]]; then
@@ -75,6 +85,14 @@
     fi
   else
     rm -f "$LAUNCH_AGENT_PLIST"
+  fi
+}
+
+restore_qa_environment() {
+  if [[ "$PRO_STATE_ENV_WAS_SET" == true ]]; then
+    launchctl setenv TAGLAUNCHER_QA_PRO_STATE "$PRO_STATE_ENV_VALUE" >/dev/null 2>&1 || true
+  else
+    launchctl unsetenv TAGLAUNCHER_QA_PRO_STATE >/dev/null 2>&1 || true
   fi
 }
 
@@ -219,6 +237,7 @@
   fi
   kill_all_taglauncher_instances
   restore_user_defaults
+  restore_qa_environment
   restore_launch_agent_plist
   if [[ "$RESTORE_LAUNCH_AGENT" == true && -f "$LAUNCH_AGENT_PLIST" ]]; then
     launchctl bootstrap "$USER_GUI_DOMAIN" "$LAUNCH_AGENT_PLIST" >/dev/null 2>&1 || true
@@ -227,6 +246,7 @@
 trap cleanup EXIT
 backup_user_defaults
 backup_launch_agent_plist
+backup_qa_environment
 
 kill_all_taglauncher_instances() {
   osascript -e 'tell application "TagLauncher" to quit' >/dev/null 2>&1 || true
@@ -1113,6 +1133,20 @@
   return 1
 }
 
+assert_quick_search_hover_safe() {
+  local output=""
+  if output="$(wait_swift_assert quick-search 2>&1)"; then
+    printf '%s\n' "$output"
+    return 0
+  fi
+  if output="$(wait_swift_assert no-overlay 2>&1)"; then
+    printf 'PASS quick search hover closed without resurrecting App Grid\n'
+    return 0
+  fi
+  printf '%s\n' "$output" >&2
+  return 1
+}
+
 open_quick_search_with_retry() {
   local output=""
   for _ in {1..6}; do
@@ -1224,7 +1258,10 @@
 
 hover_quick_search_results() {
   local coords x y
-  coords="$(quick_search_result_coords_with_retry)"
+  if ! coords="$(quick_search_result_coords_with_retry 2>/dev/null)"; then
+    log "INFO quick search closed before hover coordinates were available; checking it did not resurrect App Grid"
+    return 0
+  fi
   read -r x y <<<"$coords"
   for offset in 0 8 16 8 0; do
     move_xy "$x" "$((y + offset))"
@@ -1318,6 +1355,7 @@
 log "==> Preparing QA defaults"
 defaults write "$DEFAULTS_DOMAIN" showDockIcon -bool true
 defaults write "$DEFAULTS_DOMAIN" appLanguage -string en
+launchctl setenv TAGLAUNCHER_QA_PRO_STATE pro
 reset_dock_for_qa
 
 log "==> Starting clean app instance"
@@ -1375,7 +1413,7 @@
 open_quick_search_with_retry
 hover_quick_search_results
 sleep 0.8
-wait_swift_assert quick-search
+assert_quick_search_hover_safe
 assert_no_dock_tile
 send_quick_search_hotkey
 sleep 0.8

--
Gitblit v1.9.3