refactor(uninstall): resolve desktop userData path at print time

_perform_uninstall seeded desktop_userdata = None before the try and
guarded the keep-data completion message with `is not None`, only so
the path computed inside the try survived an import failure. The path
is a pure computation, so resolve it where it is printed (as
run_uninstall and the dry-run already do) and keep the try scoped to
uninstall_gui(). Output is unchanged.

Co-authored-by: Yuan Li <dskwelmcy@163.com>
This commit is contained in:
kshitijk4poor
2026-09-26 21:34:34 +05:30
committed by kshitij
parent da810d0b8e
commit c437bab069

View File

@@ -952,10 +952,8 @@ def _perform_uninstall(
# The userData dir is user configuration (connections.json, OAuth partitions, renderer
# state), so keep-data preserves it — only the full wipe removes it.
log_info("Removing desktop Chat GUI artifacts...")
desktop_userdata = None
try:
from hermes_cli.gui_uninstall import desktop_userdata_dir, uninstall_gui
desktop_userdata = desktop_userdata_dir()
from hermes_cli.gui_uninstall import uninstall_gui
if not uninstall_gui(hermes_home, remove_userdata=full_uninstall):
log_info("No desktop GUI artifacts found")
except Exception as e:
@@ -1020,7 +1018,8 @@ def _perform_uninstall(
if not full_uninstall:
print(color("Your configuration and data have been preserved:", Colors.CYAN))
print(f" {hermes_home}/")
if desktop_userdata is not None and desktop_userdata.exists():
from hermes_cli.gui_uninstall import desktop_userdata_dir
if (desktop_userdata := desktop_userdata_dir()).exists():
print(f" {desktop_userdata} (desktop app data)")
print()
print("To reinstall later with your existing settings:")