From 09cbc57b8cc1974446dc880d9059f4ea77c3ee01 Mon Sep 17 00:00:00 2001 From: Jessey van Offeren Date: Thu, 21 May 2026 18:42:29 +0200 Subject: [PATCH] feat: in-app uninstaller, changelog viewer, version automation (0.1.0) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit First milestone release — a complete, installable, self-updating RigDoctor: live monitoring, crash capture + health report, desktop GUI, user-local install/uninstall, and token-gated self-update with real release notes. - feat(gui): in-app uninstaller — Setup "Uninstall RigDoctor" button and `rigdoctor uninstall [--purge]`; removes venv/launchers/desktop entry (detached so it can delete its own venv), with optional purge of settings/token/logs (core/uninstall.py) - feat(gui): in-app changelog — sidebar "Changelog" link listing release history fetched from the update server (updates.list_releases) - chore: versioning rules + automation (D21) — git-cliff --bumped-version, packaging/bump.sh, cliff.toml [bump] (pre-1.0: breaking -> minor) - chore(release): stamp 0.1.0; milestone policy recorded in D19 Co-Authored-By: Claude Opus 4.7 (1M context) --- CHANGELOG.md | 10 +++++++ cliff.toml | 5 ++++ docs/DECISIONS.md | 21 +++++++++++++-- packaging/bump.sh | 25 ++++++++++++++++++ pyproject.toml | 2 +- src/rigdoctor/__init__.py | 2 +- src/rigdoctor/cli.py | 22 ++++++++++++++++ src/rigdoctor/core/uninstall.py | 41 +++++++++++++++++++++++++++++ src/rigdoctor/core/updates.py | 22 ++++++++++++++++ src/rigdoctor/gui/main_window.py | 45 +++++++++++++++++++++++++++++++- src/rigdoctor/gui/setup_page.py | 36 ++++++++++++++++++++++++- src/rigdoctor/gui/theme.py | 12 +++++++++ 12 files changed, 237 insertions(+), 6 deletions(-) create mode 100755 packaging/bump.sh create mode 100644 src/rigdoctor/core/uninstall.py diff --git a/CHANGELOG.md b/CHANGELOG.md index 24e4b8c..a404b76 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,16 @@ All notable changes to RigDoctor are recorded here. Format follows (`MAJOR.MINOR.PATCH`, pre-1.0). `__version__` and `pyproject.toml` must match the git release tag (so the auto-updater, D18, can compare versions). +## [0.1.0] - 2026-05-21 +_First milestone release — a complete, installable, self-updating RigDoctor: live monitoring, +crash capture + health report, desktop GUI, user-local install/uninstall, and updates._ +### Added +- **In-app uninstaller**: "Uninstall RigDoctor" button on the Setup page (and + `rigdoctor uninstall [--purge]`) — removes the venv, launchers, and desktop entry, with an + option to also wipe settings/token/logs. Runs detached so it can delete its own venv. +- **In-app changelog**: a "Changelog" link in the sidebar opens the release history (tags + + notes) fetched from the update server. + ## [0.0.10] - 2026-05-21 ### Added - **"Restart now" button** after a successful in-app update — relaunches RigDoctor for you diff --git a/cliff.toml b/cliff.toml index fdfe43e..1612c1d 100644 --- a/cliff.toml +++ b/cliff.toml @@ -35,3 +35,8 @@ commit_parsers = [ ] tag_pattern = "v[0-9]*" sort_commits = "oldest" + +[bump] +# Pre-1.0 rules (D21): feat -> minor, fix -> patch, breaking -> minor (not major). +features_always_bump_minor = true +breaking_always_bump_major = false diff --git a/docs/DECISIONS.md b/docs/DECISIONS.md index 6b893af..3a2ed62 100644 --- a/docs/DECISIONS.md +++ b/docs/DECISIONS.md @@ -191,7 +191,11 @@ desirable — access control is delegated to Gitea. PATCH for ordinary changes, MINOR for larger milestones). `__version__` (`rigdoctor/__init__.py`) and `pyproject.toml` are the single source of truth and **must match the git release tag** so the auto-updater (D18) can compare versions. Every change updates -`CHANGELOG.md` — now generated from **Conventional Commits** via git-cliff (see D20). *Note:* an early placeholder `0.1.0` was corrected to +`CHANGELOG.md` — now generated from **Conventional Commits** via git-cliff (see D20). +*Milestone policy (pre-1.0):* **0.0.x** = early development; **0.1.0** = first complete, +installable, self-updating release (reached 2026-05-21); **0.x.0** = each later milestone +(AMD/Intel, unattended logger auto-start, session sharing…); **1.0.0** = broadly stable +(multi-vendor/distro, no major caveats). PATCH (`0.x.PATCH`) for fixes/small changes. *Note:* an early placeholder `0.1.0` was corrected to follow the released **0.0.x** line — first release was **V0.0.1**; current is **0.0.2**. ### D20 — Automated changelog & release notes — *DECIDED 2026-05-21* @@ -206,9 +210,22 @@ follow the released **0.0.x** line — first release was **V0.0.1**; current is - *CI does not auto-commit the changelog* (avoids push loops) — it's regenerated by the dev via the script when cutting a version; CI only reads the section for the release body. +### D21 — Versioning rules & automation — *DECIDED 2026-05-21* +The next version is **determined by the Conventional Commit types** since the last release +(D20), so it can be auto-computed instead of guessed: +- `fix:` / `perf:` → bump **PATCH**. +- `feat:` → bump **MINOR** (pre-1.0: `0.MINOR.0`). +- breaking (`feat!:` / `BREAKING CHANGE:`) → pre-1.0: bump **MINOR** (not major); post-1.0: MAJOR. +- `docs:` / `chore:` / `refactor:` / `ci:` / `test:` / `style:` alone → **PATCH** (no feature release). +- Milestone overrides by hand are allowed (e.g., jumping to `1.0.0`); see the milestone policy in D19. + +*Automation:* `git-cliff --bumped-version` computes the next version from history; +`packaging/bump.sh` writes it into `__init__.py` + `pyproject.toml`. Rules live in +`cliff.toml [bump]` (pre-1.0: `breaking_always_bump_major = false`). + ## Open -None currently — all tracked decisions (D1–D20) are resolved. New questions will be added +None currently — all tracked decisions (D1–D21) are resolved. New questions will be added here as they arise. Remaining detail to flesh out during build: the tray's supporting-action set (D13), per-module apt package names, M12's tunnel/token specifics, and M13's update mechanism (APT repo vs. self-installed `.deb`). diff --git a/packaging/bump.sh b/packaging/bump.sh new file mode 100755 index 0000000..f9e7863 --- /dev/null +++ b/packaging/bump.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env sh +# Auto-set the next version from Conventional Commits (git-cliff), per D21. +# Run after committing your feat:/fix: changes; it updates __init__.py + pyproject.toml. +# Then update CHANGELOG.md, commit as `chore(release): vX.Y.Z`, and push (CI tags + releases). +set -eu + +ROOT=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd) +cd "$ROOT" + +command -v git-cliff >/dev/null 2>&1 || { echo "git-cliff not found. Install: pip install git-cliff"; exit 1; } + +NEXT=$(git-cliff --bumped-version | sed 's/^v//') +[ -n "$NEXT" ] || { echo "Could not compute the next version."; exit 1; } + +python3 - "$NEXT" <<'PY' +import pathlib, re, sys +version = sys.argv[1] +init = pathlib.Path("src/rigdoctor/__init__.py") +init.write_text(re.sub(r'__version__ = "[^"]+"', f'__version__ = "{version}"', init.read_text())) +proj = pathlib.Path("pyproject.toml") +proj.write_text(re.sub(r'(?m)^version = "[^"]+"', f'version = "{version}"', proj.read_text(), count=1)) +PY + +echo "Set version to $NEXT." +echo "Next: add a '## [$NEXT]' CHANGELOG section, then commit as 'chore(release): v$NEXT'." diff --git a/pyproject.toml b/pyproject.toml index bc49774..7d20eba 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "rigdoctor" -version = "0.0.10" +version = "0.1.0" description = "Modular hardware monitoring & crash diagnostics for Linux gamers." readme = "README.md" requires-python = ">=3.11" diff --git a/src/rigdoctor/__init__.py b/src/rigdoctor/__init__.py index 74eb972..460e6ed 100644 --- a/src/rigdoctor/__init__.py +++ b/src/rigdoctor/__init__.py @@ -1,3 +1,3 @@ """RigDoctor — modular hardware monitoring & crash diagnostics for Linux gamers.""" -__version__ = "0.0.10" +__version__ = "0.1.0" diff --git a/src/rigdoctor/cli.py b/src/rigdoctor/cli.py index c1af592..ce6d7d5 100644 --- a/src/rigdoctor/cli.py +++ b/src/rigdoctor/cli.py @@ -278,6 +278,23 @@ def cmd_update(args) -> int: return rc +def cmd_uninstall(args) -> int: + from .core import uninstall as uninstaller + + scope = "everything (app + settings, token, and logs)" if args.purge else "the app (settings/logs kept)" + if not args.yes: + try: + reply = input(f"Uninstall RigDoctor — remove {scope}? [y/N] ").strip().lower() + except EOFError: + reply = "n" + if reply not in ("y", "yes"): + print("Aborted.") + return 1 + uninstaller.uninstall(purge=args.purge) + print("Uninstalling… RigDoctor will be removed momentarily.") + return 0 + + def cmd_report(args) -> int: from dataclasses import asdict @@ -325,6 +342,11 @@ def build_parser() -> argparse.ArgumentParser: upd.add_argument("--check", action="store_true", help="only report, don't apply") upd.set_defaults(func=cmd_update) + unin = sub.add_parser("uninstall", help="remove the user-local install") + unin.add_argument("--purge", action="store_true", help="also remove settings, token, and logs") + unin.add_argument("-y", "--yes", action="store_true", help="don't ask for confirmation") + unin.set_defaults(func=cmd_uninstall) + rec = sub.add_parser("record", help="crash-capture logger (M3)") rec_sub = rec.add_subparsers(dest="record_cmd", required=True) diff --git a/src/rigdoctor/core/uninstall.py b/src/rigdoctor/core/uninstall.py new file mode 100644 index 0000000..6770ce7 --- /dev/null +++ b/src/rigdoctor/core/uninstall.py @@ -0,0 +1,41 @@ +"""Uninstall the user-local RigDoctor install (app files; optionally all data). + +Mirrors `install.sh --uninstall`. The removal runs in a detached shell so it can +delete the venv the current process is running from once we exit. +""" + +from __future__ import annotations + +import shlex +import subprocess +from pathlib import Path + +from .. import config +from . import reccontrol + + +def targets(purge: bool = False) -> list[Path]: + """Paths removed by an uninstall. With purge, also config/state/logs.""" + home = Path.home() + share = config.DATA_DIR.parent # ~/.local/share + items = [ + config.DATA_DIR / "venv", + home / ".local" / "bin" / "rigdoctor", + home / ".local" / "bin" / "rigdoctor-gui", + share / "applications" / "rigdoctor.desktop", + ] + if purge: + items += [config.CONFIG_DIR, config.STATE_DIR, config.DATA_DIR] + return items + + +def uninstall(purge: bool = False) -> None: + """Stop the recorder, clear the token if purging, and remove the install.""" + reccontrol.stop_background() + if purge: + config.clear_token() # removes keyring entry + any file fallback + paths = " ".join(shlex.quote(str(p)) for p in targets(purge)) + subprocess.Popen( + ["/bin/sh", "-c", f"sleep 1; rm -rf {paths}"], + start_new_session=True, + ) diff --git a/src/rigdoctor/core/updates.py b/src/rigdoctor/core/updates.py index 830dcb0..c00f7f1 100644 --- a/src/rigdoctor/core/updates.py +++ b/src/rigdoctor/core/updates.py @@ -77,6 +77,28 @@ def update_state(timeout: float = 5.0) -> tuple[str, str | None, str]: return (UP_TO_DATE, tag, notes) +def list_releases(limit: int = 15, timeout: float = 6.0) -> tuple[list[tuple[str, str, str]], str | None]: + """Return ([(tag, date, notes), …], error) for the in-app changelog.""" + token = load_token() + if not token: + return ([], NO_TOKEN) + req = urllib.request.Request( + f"{GITEA_BASE}/api/v1/repos/{REPO}/releases?limit={limit}", + headers={"Accept": "application/json", "Authorization": f"token {token}"}, + ) + try: + with urllib.request.urlopen(req, timeout=timeout) as resp: # noqa: S310 (https) + data = json.load(resp) + return ([ + (r.get("tag_name") or "?", (r.get("published_at") or "")[:10], (r.get("body") or "").strip()) + for r in data + ], None) + except urllib.error.HTTPError as exc: + return ([], AUTH if exc.code in (401, 403) else NETWORK) + except Exception: + return ([], NETWORK) + + def apply_update(tag: str) -> tuple[int, str]: """Self-update the current (user-local) install to `tag` via authenticated pip. diff --git a/src/rigdoctor/gui/main_window.py b/src/rigdoctor/gui/main_window.py index 7c4750e..81a6904 100644 --- a/src/rigdoctor/gui/main_window.py +++ b/src/rigdoctor/gui/main_window.py @@ -10,6 +10,7 @@ from PySide6.QtCore import Qt, QProcess, QTimer, Signal from PySide6.QtWidgets import ( QApplication, QButtonGroup, + QDialog, QFrame, QHBoxLayout, QLabel, @@ -17,6 +18,7 @@ from PySide6.QtWidgets import ( QMessageBox, QPushButton, QStackedWidget, + QTextEdit, QVBoxLayout, QWidget, ) @@ -38,8 +40,9 @@ _PLACEHOLDERS = { class MainWindow(QMainWindow): - _update_checked = Signal(object) # (state, tag) + _update_checked = Signal(object) # (state, tag, notes) _update_applied = Signal(int) # pip exit code + _changelog_ready = Signal(object) # ([(tag, date, notes)], error) def __init__(self, interval: float = 1.0) -> None: super().__init__() @@ -83,6 +86,7 @@ class MainWindow(QMainWindow): self._applied = False self._update_checked.connect(self._show_update_state) self._update_applied.connect(self._on_update_applied) + self._changelog_ready.connect(self._on_changelog) self._start_update_check() minutes = float(load_config().get("update_check_minutes", 30) or 0) if minutes > 0: @@ -125,6 +129,11 @@ class MainWindow(QMainWindow): version = QLabel(f"v{__version__}") version.setObjectName("Muted") v.addWidget(version) + changelog_btn = QPushButton("Changelog") + changelog_btn.setObjectName("LinkButton") + changelog_btn.setCursor(Qt.CursorShape.PointingHandCursor) + changelog_btn.clicked.connect(self._show_changelog) + v.addWidget(changelog_btn) # Update state (filled in by the background check). self._update_label = QLabel("checking for updates…") @@ -183,6 +192,40 @@ class MainWindow(QMainWindow): def _start_update_check(self) -> None: threading.Thread(target=self._check_updates, daemon=True).start() + def _show_changelog(self) -> None: + dialog = QDialog(self) + dialog.setWindowTitle("RigDoctor — Changelog") + dialog.resize(560, 540) + layout = QVBoxLayout(dialog) + view = QTextEdit() + view.setObjectName("Report") + view.setReadOnly(True) + view.setPlainText("Loading…") + layout.addWidget(view) + self._changelog_view = view + dialog.show() + threading.Thread(target=self._fetch_changelog, daemon=True).start() + + def _fetch_changelog(self) -> None: + self._changelog_ready.emit(updates.list_releases()) + + def _on_changelog(self, result) -> None: + view = getattr(self, "_changelog_view", None) + if view is None: + return + releases, error = result + if error == updates.NO_TOKEN: + view.setPlainText("Add an update token (Setup → Update access) to load the changelog.") + return + if error or not releases: + view.setPlainText("Couldn't load the changelog from the update server.") + return + blocks = [] + for tag, date, notes in releases: + head = tag + (f" ({date})" if date else "") + blocks.append(f"{head}\n{'─' * len(head)}\n{notes or '(no notes)'}") + view.setPlainText("\n\n".join(blocks)) + def _check_updates(self) -> None: self._update_checked.emit(updates.update_state()) diff --git a/src/rigdoctor/gui/setup_page.py b/src/rigdoctor/gui/setup_page.py index 58f0256..1ece46a 100644 --- a/src/rigdoctor/gui/setup_page.py +++ b/src/rigdoctor/gui/setup_page.py @@ -7,10 +7,12 @@ import threading from PySide6.QtCore import Qt, QUrl, Signal from PySide6.QtGui import QDesktopServices from PySide6.QtWidgets import ( + QApplication, QFrame, QHBoxLayout, QLabel, QLineEdit, + QMessageBox, QPushButton, QSizePolicy, QTextEdit, @@ -19,7 +21,7 @@ from PySide6.QtWidgets import ( ) from .. import config -from ..core import installer, sysenv, updates +from ..core import installer, sysenv, uninstall, updates from .theme import GOOD, MUTED, WARN @@ -113,9 +115,41 @@ class SetupPage(QWidget): root.addWidget(self._output) root.addStretch(1) + danger = QHBoxLayout() + danger.addStretch(1) + uninstall_btn = QPushButton("Uninstall RigDoctor") + uninstall_btn.setObjectName("DangerButton") + uninstall_btn.clicked.connect(self._uninstall) + danger.addWidget(uninstall_btn) + root.addLayout(danger) + self._refresh() self._refresh_update_status() + def _uninstall(self) -> None: + box = QMessageBox(self) + box.setIcon(QMessageBox.Icon.Warning) + box.setWindowTitle("Uninstall RigDoctor") + box.setText("Uninstall RigDoctor?") + box.setInformativeText( + "This removes the app. Choose “Remove all” to also delete your settings, " + "update token, and captured logs." + ) + remove_all = box.addButton("Remove all", QMessageBox.ButtonRole.DestructiveRole) + app_only = box.addButton("Uninstall", QMessageBox.ButtonRole.AcceptRole) + box.addButton("Cancel", QMessageBox.ButtonRole.RejectRole) + box.exec() + clicked = box.clickedButton() + if clicked is remove_all: + purge = True + elif clicked is app_only: + purge = False + else: + return + uninstall.uninstall(purge=purge) + QMessageBox.information(self, "RigDoctor", "Uninstalling… RigDoctor will close now.") + QApplication.instance().quit() + def _refresh(self) -> None: self._env.setText( f"Distro: {sysenv.distro_name()} " diff --git a/src/rigdoctor/gui/theme.py b/src/rigdoctor/gui/theme.py index 6279d7e..f0b9de3 100644 --- a/src/rigdoctor/gui/theme.py +++ b/src/rigdoctor/gui/theme.py @@ -107,4 +107,16 @@ QDoubleSpinBox, QSpinBox {{ QTextEdit#Report {{ background: #0d0f13; color: #cfd3da; border: 1px solid {CARD_BORDER}; border-radius: 8px; }} + +QPushButton#DangerButton {{ + background: transparent; color: {CRIT}; border: 1px solid {CRIT}; + border-radius: 8px; padding: 7px 14px; +}} +QPushButton#DangerButton:hover {{ background: {CRIT}; color: #1a0d0d; }} + +QPushButton#LinkButton {{ + background: transparent; border: none; color: {MUTED}; + text-align: left; padding: 0; text-decoration: underline; +}} +QPushButton#LinkButton:hover {{ color: {TEXT}; }} """