Skip to content

Commit 6ca2bf2

Browse files
committed
feat: Enhance update checker with async checking and better UX
Implemented key improvements from rxiv-maker's update checker: - Async background checking (non-blocking, eliminates CLI startup latency) - Environment opt-out variables (TASKREPO_NO_UPDATE_CHECK, NO_UPDATE_NOTIFIER) - Richer cache structure (update_available, latest_version, current_version) - Singleton pattern for consistent state - Enhanced notifications with installation method info and GitHub links - Force check via tsk upgrade --check All 152 unit tests pass.
1 parent 8fa10b2 commit 6ca2bf2

3 files changed

Lines changed: 269 additions & 116 deletions

File tree

src/taskrepo/cli/commands/upgrade.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
from taskrepo.__version__ import __version__
1010
from taskrepo.utils.install_detector import detect_install_method
11-
from taskrepo.utils.update_checker import check_for_updates
11+
from taskrepo.utils.update_checker import force_update_check
1212

1313

1414
def detect_installer() -> Tuple[str, list[str]]:
@@ -102,11 +102,11 @@ def upgrade(ctx, check, yes):
102102
"""
103103
# Check for updates
104104
click.echo("Checking for updates...")
105-
latest_version = check_for_updates()
105+
update_available, latest_version = force_update_check()
106106

107107
if check:
108108
# Just show version information
109-
if latest_version:
109+
if update_available and latest_version:
110110
click.echo(f"Current version: v{__version__}")
111111
click.secho(f"Latest version: v{latest_version}", fg="green", bold=True)
112112
click.secho("Update available!", fg="yellow")
@@ -116,7 +116,7 @@ def upgrade(ctx, check, yes):
116116
return
117117

118118
# No update available
119-
if not latest_version:
119+
if not update_available or not latest_version:
120120
click.secho(f"✓ You are already using the latest version (v{__version__})", fg="green")
121121
return
122122

src/taskrepo/cli/main.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
from taskrepo.cli.commands.upgrade import upgrade
2424
from taskrepo.core.config import Config
2525
from taskrepo.utils.banner import display_banner
26-
from taskrepo.utils.update_checker import check_and_notify_updates
26+
from taskrepo.utils.update_checker import check_and_notify_updates, show_update_notification
2727

2828

2929
class OrderedGroup(click.Group):
@@ -133,9 +133,12 @@ def process_result(ctx, result, **kwargs):
133133
134134
This runs after any command completes and checks for updates.
135135
"""
136-
# Check for updates after command completes
136+
# Start async update check in background (if due)
137137
check_and_notify_updates()
138138

139+
# Show any cached update notifications immediately
140+
show_update_notification()
141+
139142

140143
# Register commands
141144
cli.add_command(add)

0 commit comments

Comments
 (0)