Skip to content

armgit / cua

Public Imported from GitHub
0

Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.

fix(spaces-macos): uninstall-local.sh also removes the Local preferences, caches and web view data (CUA-2207) (#5880)

cua-agents[bot]929be2a67662
diff --git a/apps/cua-spaces-macos/scripts/_local-common.sh b/apps/cua-spaces-macos/scripts/_local-common.sh
index b0d3d64b10..1aefac906a 100644
--- a/apps/cua-spaces-macos/scripts/_local-common.sh
+++ b/apps/cua-spaces-macos/scripts/_local-common.sh
@@ -28,6 +28,17 @@ LOCAL_LUME_DIR_NAME=".lume-local" # CuaChannel::lume_dir
# CuaChannel::keychain_service(Prod) and (Staging). The sign-in and the device
# key live under these services, one item per account.
LOCAL_KEYCHAIN_SERVICES=("ai.cua.session.local" "ai.cua.session.local.staging")
+# What macOS keeps under ~/Library for the Local bundle id: preferences, caches,
+# web view data and saved window state. Every name carries the Local bundle id
+# (Stable's are the same folders with its own id, which are never listed here).
+LOCAL_LIBRARY_LEAVES=(
+ "Preferences/$LOCAL_BUNDLE_ID.plist"
+ "Caches/$LOCAL_BUNDLE_ID"
+ "HTTPStorages/$LOCAL_BUNDLE_ID"
+ "WebKit/$LOCAL_BUNDLE_ID"
+ "Cookies/$LOCAL_BUNDLE_ID.binarycookies"
+ "Saved Application State/$LOCAL_BUNDLE_ID.savedState"
+)
# --- Stable (what these scripts must never create, replace or remove) --------
# Only used to refuse a bundle that carries a Stable identity.
diff --git a/apps/cua-spaces-macos/scripts/tests/install-local-test.sh b/apps/cua-spaces-macos/scripts/tests/install-local-test.sh
index 6bd809c06a..64b7fe51a7 100755
--- a/apps/cua-spaces-macos/scripts/tests/install-local-test.sh
+++ b/apps/cua-spaces-macos/scripts/tests/install-local-test.sh
@@ -382,6 +382,9 @@ snap_all() { snap . | LC_ALL=C sort; }
STABLE_PATHS=(
".cua" ".lume" ".local/bin/cua" ".local/bin/lume"
"Library/Application Support/com.trycua.spaces.macos"
+ "Library/Preferences/com.trycua.spaces.macos.plist" "Library/Caches/com.trycua.spaces.macos"
+ "Library/HTTPStorages/com.trycua.spaces.macos" "Library/WebKit/com.trycua.spaces.macos"
+ "Library/Cookies/com.trycua.spaces.macos.binarycookies" "Library/Saved Application State/com.trycua.spaces.macos.savedState"
"Library/LaunchAgents/com.trycua.spacesd.host.plist"
"Library/LaunchAgents/com.trycua.lume_daemon.plist"
"Cua Volume" "Applications/Cua Spaces.app"
@@ -405,6 +408,9 @@ make_stable_install() {
local d
mkdir -p "$FAKE_HOME/.cua/helper" "$FAKE_HOME/.lume/vm1" "$FAKE_HOME/.local/bin" \
"$FAKE_HOME/Library/Application Support/com.trycua.spaces.macos" \
+ "$FAKE_HOME/Library/Preferences" "$FAKE_HOME/Library/Caches/com.trycua.spaces.macos" \
+ "$FAKE_HOME/Library/HTTPStorages/com.trycua.spaces.macos" "$FAKE_HOME/Library/WebKit/com.trycua.spaces.macos" \
+ "$FAKE_HOME/Library/Cookies" "$FAKE_HOME/Library/Saved Application State/com.trycua.spaces.macos.savedState" \
"$FAKE_HOME/Library/LaunchAgents" "$FAKE_HOME/Cua Volume" \
"$FAKE_HOME/Applications/Cua Spaces.app/Contents/MacOS"
echo '{"session":"stable"}' > "$FAKE_HOME/.cua/credentials.json"
@@ -414,6 +420,12 @@ make_stable_install() {
cp "$STUB_BIN" "$FAKE_HOME/.local/bin/cua"
cp "$STUB_BIN" "$FAKE_HOME/.local/bin/lume"
echo '{}' > "$FAKE_HOME/Library/Application Support/com.trycua.spaces.macos/settings.json"
+ echo '<plist/>' > "$FAKE_HOME/Library/Preferences/com.trycua.spaces.macos.plist"
+ echo 'cache' > "$FAKE_HOME/Library/Caches/com.trycua.spaces.macos/Cache.db"
+ echo 'http' > "$FAKE_HOME/Library/HTTPStorages/com.trycua.spaces.macos/httpstorages.sqlite"
+ echo 'web' > "$FAKE_HOME/Library/WebKit/com.trycua.spaces.macos/data"
+ echo 'cookies' > "$FAKE_HOME/Library/Cookies/com.trycua.spaces.macos.binarycookies"
+ echo 'state' > "$FAKE_HOME/Library/Saved Application State/com.trycua.spaces.macos.savedState/windows.plist"
echo '<plist/>' > "$FAKE_HOME/Library/LaunchAgents/com.trycua.spacesd.host.plist"
echo '<plist/>' > "$FAKE_HOME/Library/LaunchAgents/com.trycua.lume_daemon.plist"
echo 'my files' > "$FAKE_HOME/Cua Volume/note.txt"
@@ -1076,6 +1088,15 @@ echo '{}' > "$FAKE_HOME/.cua-local/helper/service.json"
echo '{}' > "$FAKE_HOME/.cua-local/credentials.json"
echo '{}' > "$FAKE_HOME/Library/Application Support/com.trycua.spaces.local/settings.json"
echo '<plist/>' > "$FAKE_HOME/Library/LaunchAgents/com.trycua.spacesd.host.local.plist"
+# What macOS keeps for the Local bundle id in ~/Library.
+mkdir -p "$FAKE_HOME/Library/Preferences" "$FAKE_HOME/Library/Caches/com.trycua.spaces.local" "$FAKE_HOME/Library/HTTPStorages/com.trycua.spaces.local" \
+ "$FAKE_HOME/Library/WebKit/com.trycua.spaces.local" "$FAKE_HOME/Library/Cookies" "$FAKE_HOME/Library/Saved Application State/com.trycua.spaces.local.savedState"
+echo '<plist/>' > "$FAKE_HOME/Library/Preferences/com.trycua.spaces.local.plist"
+echo 'cache' > "$FAKE_HOME/Library/Caches/com.trycua.spaces.local/Cache.db"
+echo 'http' > "$FAKE_HOME/Library/HTTPStorages/com.trycua.spaces.local/httpstorages.sqlite"
+echo 'web' > "$FAKE_HOME/Library/WebKit/com.trycua.spaces.local/data"
+echo 'cookies' > "$FAKE_HOME/Library/Cookies/com.trycua.spaces.local.binarycookies"
+echo 'state' > "$FAKE_HOME/Library/Saved Application State/com.trycua.spaces.local.savedState/windows.plist"
echo 'mine' > "$FAKE_HOME/Cua Volume Local/keep.txt"
BEFORE_UNINSTALL="$(snap_all)"
: > "$SHIM_LOG"; : > "$STUB_LOG"
@@ -1092,6 +1113,10 @@ uninstall
check "answering y removes Local (status $RC)" '[ "$RC" = 0 ] && [ ! -e "$LOCAL_APP" ] && [ ! -e "$LOCAL_CLI" ] && [ ! -L "$LOCAL_CLI" ]'
STDIN_FILE=/dev/null
check "the Local home and its app support folder are gone" '[ ! -e "$FAKE_HOME/.cua-local" ] && [ ! -e "$FAKE_HOME/Library/Application Support/com.trycua.spaces.local" ]'
+check "the Local bundle id's preferences, caches, web view data, cookies and window state are gone" \
+ '[ ! -e "$FAKE_HOME/Library/Preferences/com.trycua.spaces.local.plist" ] && [ ! -e "$FAKE_HOME/Library/Caches/com.trycua.spaces.local" ] && [ ! -e "$FAKE_HOME/Library/HTTPStorages/com.trycua.spaces.local" ] && [ ! -e "$FAKE_HOME/Library/WebKit/com.trycua.spaces.local" ] && [ ! -e "$FAKE_HOME/Library/Cookies/com.trycua.spaces.local.binarycookies" ] && [ ! -e "$FAKE_HOME/Library/Saved Application State/com.trycua.spaces.local.savedState" ]'
+check "and Stable's preferences, caches, web view data, cookies and window state of the same kinds are still there" \
+ '[ -f "$FAKE_HOME/Library/Preferences/com.trycua.spaces.macos.plist" ] && [ -f "$FAKE_HOME/Library/Caches/com.trycua.spaces.macos/Cache.db" ] && [ -f "$FAKE_HOME/Library/WebKit/com.trycua.spaces.macos/data" ] && [ -f "$FAKE_HOME/Library/Cookies/com.trycua.spaces.macos.binarycookies" ] && [ -f "$FAKE_HOME/Library/Saved Application State/com.trycua.spaces.macos.savedState/windows.plist" ]'
check "the Local host runner job file is gone" '[ ! -e "$FAKE_HOME/Library/LaunchAgents/com.trycua.spacesd.host.local.plist" ]'
check "the helper login item was unregistered by the Local app itself" 'grep >/dev/null -- "--service-helper unregister \[CUA_CHANNEL=local\]" "$STUB_LOG"'
check "launchctl was asked about the two Local labels only" \
diff --git a/apps/cua-spaces-macos/scripts/uninstall-local.sh b/apps/cua-spaces-macos/scripts/uninstall-local.sh
index 52976cc7a7..0e53f12515 100755
--- a/apps/cua-spaces-macos/scripts/uninstall-local.sh
+++ b/apps/cua-spaces-macos/scripts/uninstall-local.sh
@@ -21,6 +21,8 @@
# - ~/.local/bin/cua-local
# - ~/.cua-local (the Local sign-in, host and Spaces state)
# and ~/Library/Application Support/com.trycua.spaces.local
+# - what macOS keeps for the Local bundle id under ~/Library: its preferences,
+# caches, web view data, cookies and saved window state
# - the Local Keychain items (ai.cua.session.local, ai.cua.session.local.staging)
# - optionally lume-local (libs/lume/scripts/uninstall-local.sh)
# It keeps the Cua Volume Local folder and the permissions macOS granted the
@@ -111,6 +113,7 @@ echo " helper login item: $LOCAL_HELPER_LABEL"
echo " app: $APP_DEST"
echo " CLI: $CLI_LINK"
echo " state: $LOCAL_HOME and $LOCAL_APP_SUPPORT"
+echo " macOS leftovers: the $LOCAL_BUNDLE_ID preferences, caches, web view data and window state in ~/Library"
echo " Keychain items: ${LOCAL_KEYCHAIN_SERVICES[*]}"
if [ "$YES" != 1 ]; then
confirm "Remove them?" || { log "cancelled, nothing was removed"; exit 0; }
@@ -177,6 +180,21 @@ if [ -d "$LOCAL_APP_SUPPORT" ]; then
log "removed $LOCAL_APP_SUPPORT"
fi
+# What macOS keeps for the Local bundle id (every name carries it; Stable's
+# folders have its own id and are never listed). The app is stopped above, so
+# it cannot write them back.
+for leaf in "${LOCAL_LIBRARY_LEAVES[@]}"; do
+ case "$leaf" in
+ *"$LOCAL_BUNDLE_ID"*) ;;
+ *) die "internal error: $leaf is not a Local path" ;;
+ esac
+ leftover="$HOME/Library/$leaf"
+ if [ -e "$leftover" ] || [ -L "$leftover" ]; then
+ rm -rf "$leftover"
+ log "removed $leftover"
+ fi
+done
+
# The Keychain tool deletes one item per call and has no wildcard: repeat per
# service (one item per account) until none is left. Local services only.
if command -v security >/dev/null 2>&1; then