-
-
Notifications
You must be signed in to change notification settings - Fork 27
fix(doctor): report when a newer version exists and when auto-upgrade is blocked #69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -199,6 +199,50 @@ def run() -> int: | |
| except Exception as e: | ||
| _line("version", _red(str(e)), ok=False) | ||
|
|
||
| # --- update channel --- | ||
| # A version line that is always ✓ hid an install stuck for months: it was | ||
| # behind, and auto-upgrade was silently refusing to run. Mirror the gates | ||
| # in check_for_updates()/auto_upgrade(), and read the cache the updater | ||
| # already writes rather than hitting the network from here. | ||
| auto_on = False | ||
| try: | ||
| from .config import load_config | ||
| from .updater import _windows_in_place, is_shadow_install | ||
| if os.environ.get("CLAUDE_STATUSBAR_NO_UPDATE", "").lower() in ("1", "true", "yes"): | ||
| auto = ("off (CLAUDE_STATUSBAR_NO_UPDATE)", True) | ||
| elif not load_config().auto_upgrade: | ||
| auto = ("off (config auto_upgrade=false)", True) | ||
| elif is_shadow_install(): | ||
| auto = (_yellow("blocked — `cs` on PATH belongs to another install"), None) | ||
| elif _windows_in_place(): | ||
| auto = (_yellow("blocked — Windows pip/pipx can't upgrade in place; " | ||
| "run: cs upgrade"), None) | ||
| else: | ||
| auto, auto_on = ("on", True), True | ||
| except Exception as e: | ||
| auto = (_dim(f"check skipped: {e}"), True) | ||
| try: | ||
| import time as _time | ||
| from .updater import LATEST_VERSION_CACHE, compare_versions, get_current_version | ||
| data = json.loads(LATEST_VERSION_CACHE.read_text(encoding="utf-8")) | ||
| latest, current = str(data["version"]), get_current_version() | ||
| age_d = int((_time.time() - float(data.get("checked_at", 0))) // 86400) | ||
| if current == "0.0.0": | ||
| pass # source checkout without an installed dist: no real version | ||
| elif age_d > 7: | ||
| # Same cutoff as the bar's ↑ hint. A blocked updater stops | ||
| # refreshing this file, so an old "latest" is not evidence. | ||
| _line("latest", _yellow(f"unknown — last checked {age_d}d ago") | ||
| if auto_on else f"unknown — last checked {age_d}d ago", | ||
| ok=None if auto_on else True) | ||
|
Comment on lines
+235
to
+237
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win Mark a stale latest-version check as unknown. When auto-upgrade is off or blocked, this branch prints 🤖 Prompt for AI Agents |
||
| elif compare_versions(current, latest): | ||
| _line("latest", _yellow(f"{latest} available — run: cs upgrade"), ok=None) | ||
| else: | ||
| _line("latest", f"{latest} (up to date)") | ||
| except Exception: | ||
| pass # no cache yet or unreadable: say nothing rather than guess | ||
| _line("auto-upgrade", auto[0], ok=auto[1]) | ||
|
|
||
| # --- python --- | ||
| _line("python", f"{sys.version.split()[0]} ({sys.executable})") | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Apply the seven-day cutoff before rounding the cache age.
When the cache is seven days and one second old,
age_dis still7. Line 232 then treats the cache as fresh and can report its version as “up to date” for almost another day. Compare the age in seconds with seven days; use whole days only for the displayed age. Add a test just beyond the cutoff.🤖 Prompt for AI Agents