Skip to content

feat(tray): opt-in check for a newer qsv release - #51

Merged
jqnatividad merged 2 commits into
mainfrom
feat/tray-qsv-update-check
Nov 16, 2026
Merged

jqnatividad merged 2 commits into
mainfrom
feat/tray-qsv-update-check

Conversation

@jqnatividad

Copy link
Copy Markdown
Contributor

Summary

Adds a Check for qsv updates check box to the tray menu, next to Start at login. It is off by default.

  • What it sends: ticked, the tray makes one HTTPS request to api.github.com (GET /repos/dathere/qsv/releases/latest, with a qsv-client/<version> User-Agent). Nothing about datasets or schematics goes with it.
  • When it checks:
    • right away when the box is ticked, or at tray start if it's already on
    • then once a day by the wall clock, so time a laptop spends asleep counts; time.monotonic() doesn't count it on macOS or Linux
    • an hour after a failed check, for example one run before the network was up at login
  • What you see:
    • 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.
    • One notification per release, remembered across restarts.
    • The tray installs nothing.
  • Where the setting lives: the box's state and the last release announced are kept in tray.json in the config directory, saved owner-only. It is not in daemon.toml, which rejects keys the daemon doesn't use.
  • Safety:
    • The request runs on its own daemon thread and hands its result to the worker thread, so a slow network can't hold up the menu or Quit.
    • A failed check is only logged and never puts the tray in its error state. That covers OSError, ValueError, http.client.HTTPException, and replies of the wrong shape or over 1 MiB.
    • Menu text is built from the parsed version, and the page opened is a constant URL, never one taken from the reply.
  • Docs: docs/DAEMON.md, the README, the CHANGELOG (Added) and the CLAUDE.md layout.

Testing

  • tests/test_tray_updates.py (new): the settings file, plus latest_release against a local HTTP server, including error statuses, odd JSON, oversized replies and a non-HTTP answer.
  • tests/test_tray_controller.py and tests/test_tray_model.py, new tests for:
    • one announcement per release
    • ticking and unticking the box
    • a setting that can't be saved
    • failed checks
    • a reply that arrives after the box was unticked
    • Quit during a check
    • the interval, the retry, and a clock set back
    • opening the releases page
  • Existing tray tests pass offline fakes, so they never read the developer's tray.json or call GitHub.
  • Full suite: 843 passed. The tray files have 100% coverage. ruff, mypy (all three platforms) and Bandit are clean.
  • A live call returned qsv 29.0.0.
  • Not done: the menu hasn't been clicked in a real menu bar; the tests use a fake pystray.

🤖 Generated with Claude Code

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>
@codacy-production

codacy-production Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 104 complexity · 0 duplication

Metric Results
Complexity 104
Duplication 0

View in Codacy

AI Reviewer: first review requested successfully. AI can make mistakes. Always validate suggestions.

Run reviewer

TIP This summary will be updated as you push new changes.

@codacy-production codacy-production Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

⚠️ Resolve issues before merging

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)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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.

Comment thread src/qsv_client/tray/model.py Outdated
return None
version = (state.status.get("qsv") or {}).get("version")
try:
current = parse_version(version) if isinstance(version, str) else None

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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.

Comment thread src/qsv_client/tray/model.py Outdated
return MenuSpec(ds.title, submenu=(*details, SEPARATOR, *actions, SEPARATOR, forget))


def qsv_update(state: TrayState) -> str | None:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 MEDIUM RISK

Suggestion: Consider extracting version parsing and eligibility checks into focused helpers so qsv_update has fewer independent decision paths.

See Issue in Codacy

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

codecov Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.32%. Comparing base (8e66ff0) to head (32608f8).

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              
Files with missing lines Coverage Δ
src/qsv_client/tray/controller.py 100.00% <100.00%> (ø)
src/qsv_client/tray/model.py 100.00% <100.00%> (ø)
src/qsv_client/tray/updates.py 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Splits qsv_update so its cyclomatic complexity is under Codacy's limit
(Lizard, 8).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jqnatividad
jqnatividad merged commit 391112c into main Nov 16, 2026
23 checks passed
@jqnatividad
jqnatividad deleted the feat/tray-qsv-update-check branch November 16, 2026 04:30
@jqnatividad jqnatividad mentioned this pull request Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant