Skip to content

Commit 7929eea

Browse files
committed
Fix auto-update to use uv tool upgrade for cleaner detection
Switch from `uv tool install --force --upgrade` to `uv tool upgrade` which provides consistent output for detecting update status: - "Nothing to upgrade" when already on latest - "Updated" with version info when upgraded
1 parent 2534264 commit 7929eea

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

forestui/app.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -178,15 +178,16 @@ def _set_title_suffix(self, suffix: str | None) -> None:
178178
def _auto_update(self) -> None:
179179
"""Auto-update via PyPI with status in title bar.
180180
181-
Uses `uv tool install forestui --force --upgrade` to check PyPI for updates.
181+
Uses `uv tool upgrade forestui` to check PyPI for updates.
182182
183-
IMPORTANT: We use `install --force --upgrade` instead of `upgrade` because
184-
`uv tool upgrade` rebuilds from the original install source. For users who
185-
installed via the old git-clone method, that would rebuild from the local
186-
~/.forestui-install directory instead of fetching from PyPI.
183+
Output on successful update:
184+
Updated forestui v0.9.3 -> v0.9.4
185+
- forestui==0.9.3
186+
+ forestui==0.9.4
187+
Installed 1 executable: forestui
187188
188-
The `--upgrade` flag ensures we only reinstall if a newer version exists.
189-
The `--force` flag ensures we overwrite the existing installation.
189+
Output when already up to date:
190+
Nothing to upgrade
190191
"""
191192
import os
192193
import re
@@ -197,23 +198,22 @@ def _auto_update(self) -> None:
197198
try:
198199
self._set_title_suffix("checking for updates...")
199200

200-
# Install from PyPI if newer version available
201-
# MUST use "install --force --upgrade", NOT "upgrade"
202-
# See docstring for explanation
203201
result = subprocess.run(
204-
["uv", "tool", "install", "forestui", "--force", "--upgrade"],
202+
["uv", "tool", "upgrade", "forestui"],
205203
capture_output=True,
206204
text=True,
207205
timeout=120,
208206
)
209207

210208
if result.returncode == 0:
209+
output = result.stdout + result.stderr
211210
# Check if we actually upgraded (vs already up to date)
212-
# Output contains "Installed forestui v0.9.1" when installed/upgraded
213-
# Output contains "forestui is already installed" when up to date
214-
if "Installed" in result.stdout or "Upgraded" in result.stdout:
215-
# Try to extract version from output
216-
match = re.search(r"v(\d+\.\d+\.\d+)", result.stdout)
211+
# "Nothing to upgrade" means already on latest
212+
if "Nothing to upgrade" in output:
213+
self._set_title_suffix(None)
214+
elif "Updated" in output:
215+
# Extract version from "+ forestui==X.Y.Z" line
216+
match = re.search(r"\+ forestui==(\d+\.\d+\.\d+)", output)
217217
if match:
218218
new_version = match.group(1)
219219
self._set_title_suffix(
@@ -222,7 +222,7 @@ def _auto_update(self) -> None:
222222
else:
223223
self._set_title_suffix("updated - restart to apply")
224224
else:
225-
# Already up to date
225+
# Unknown output format, assume no update
226226
self._set_title_suffix(None)
227227
else:
228228
# Command failed - might not be on PyPI yet or network issue

0 commit comments

Comments
 (0)