Repository navigation
feat(tray): opt-in check for a newer qsv release - #51
Conversation
A "Check for qsv updates" check box in the tray menu, off by default. Ticked, the tray asks GitHub's API for qsv's latest release right away, then once a day by the wall clock (so a sleeping laptop still counts the day), retrying an hour after a failed check. When the release is newer than the qsv the daemon runs, the menu offers "qsv X.Y.Z is available…", which opens qsv's releases page, with one notification per release. The setting and the last release announced are kept in tray.json in the config directory. The request runs on its own daemon thread and hands its result to the worker thread; a failed check is only logged. Menu text comes from the parsed version and the page opened is a constant, never the reply's URL. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 104 |
| Duplication | 0 |
AI Reviewer: first review requested successfully. AI can make mistakes. Always validate suggestions.
TIP This summary will be updated as you push new changes.
There was a problem hiding this comment.
Pull Request Overview
Two logic issues should be addressed before merging: development-version comparisons can miss a stable release with the same numeric version, and a slowly streaming response can keep an update check active indefinitely. The update-check model also has elevated complexity, but this is a maintainability suggestion rather than a merge blocker.
Test suggestions
- Default settings are disabled, persist correctly, and use owner-only file permissions.
- GitHub requests include the expected endpoint, Accept header, and versioned User-Agent.
- HTTP errors, malformed JSON, invalid tags, oversized replies, and non-HTTP responses are rejected safely.
- The check runs immediately when enabled and at tray startup when already enabled.
- Successful checks repeat after the configured interval, failed checks retry sooner, and clock rollback triggers another check.
- A newer release is offered only when newer than the daemon's qsv version.
- Notifications occur once per release and persist across restarts.
- Disabling the feature or quitting discards an in-flight result.
- Opening the release offer uses the constant releases URL and reports browser failure.
- The network check does not block menu operations or place the tray in an error state.
TIP Add a Jira or Linear ticket key to the branch or title so the reviewer can check the PR against it. Using another tracker? Tell us.
TIP How was this review? Give us feedback
| ) | ||
| try: | ||
| with urllib.request.build_opener().open(req, timeout=_TIMEOUT) as resp: | ||
| body = resp.read(_MAX_BYTES + 1) |
There was a problem hiding this comment.
🟡 MEDIUM RISK
A slowly streaming response can keep _checking set indefinitely, preventing subsequent checks. Bound the total duration of an update check and ensure timeout cleanup allows a later retry.
TIP React 👍 if this review is right, or reply with what's wrong and how it could be better to help improve the reviewer.
| return None | ||
| version = (state.status.get("qsv") or {}).get("version") | ||
| try: | ||
| current = parse_version(version) if isinstance(version, str) else None |
There was a problem hiding this comment.
🟡 MEDIUM RISK
The update check will not offer a stable release when the daemon is a development build with the same numeric version (for example, 29.0.0-dev versus 29.0.0). Preserve prerelease information during comparison and cover this case with a test.
TIP React 👍 if this review is right, or reply with what's wrong and how it could be better to help improve the reviewer.
| return MenuSpec(ds.title, submenu=(*details, SEPARATOR, *actions, SEPARATOR, forget)) | ||
|
|
||
|
|
||
| def qsv_update(state: TrayState) -> str | None: |
There was a problem hiding this comment.
🟡 MEDIUM RISK
Suggestion: Consider extracting version parsing and eligibility checks into focused helpers so qsv_update has fewer independent decision paths.
TIP React 👍 if this review is right, or reply with what's wrong and how it could be better to help improve the reviewer.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #51 +/- ##
==========================================
+ Coverage 99.29% 99.32% +0.02%
==========================================
Files 30 31 +1
Lines 4282 4435 +153
Branches 560 574 +14
==========================================
+ Hits 4252 4405 +153
Misses 16 16
Partials 14 14
🚀 New features to boost your workflow:
|
Splits qsv_update so its cyclomatic complexity is under Codacy's limit (Lizard, 8). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Summary
Adds a Check for qsv updates check box to the tray menu, next to Start at login. It is off by default.
api.github.com(GET /repos/dathere/qsv/releases/latest, with aqsv-client/<version>User-Agent). Nothing about datasets or schematics goes with it.time.monotonic()doesn't count it on macOS or Linuxtray.jsonin the config directory, saved owner-only. It is not indaemon.toml, which rejects keys the daemon doesn't use.OSError,ValueError,http.client.HTTPException, and replies of the wrong shape or over 1 MiB.docs/DAEMON.md, the README, the CHANGELOG (Added) and the CLAUDE.md layout.Testing
tests/test_tray_updates.py(new): the settings file, pluslatest_releaseagainst a local HTTP server, including error statuses, odd JSON, oversized replies and a non-HTTP answer.tests/test_tray_controller.pyandtests/test_tray_model.py, new tests for:tray.jsonor call GitHub.🤖 Generated with Claude Code