Skip to content

fix: cache update-check result to avoid curl on every session start#15

Open
xiaolai wants to merge 1 commit into
Ibrahim-3d:masterfrom
xiaolai:fix/nlpm-cache-update-check
Open

fix: cache update-check result to avoid curl on every session start#15
xiaolai wants to merge 1 commit into
Ibrahim-3d:masterfrom
xiaolai:fix/nlpm-cache-update-check

Conversation

@xiaolai

@xiaolai xiaolai commented Apr 30, 2026

Copy link
Copy Markdown

Automated: drive-by fix from NLPM, an NL artifact linter. Reviewed and reproduced before submission.

Bug: hooks/session-start.sh calls the GitHub Releases API unconditionally on every Claude Code session start, adding network latency to each session with no caching.

Evidence: Line 24: curl -s --max-time 3 "https://api.github.com/repos/${REPO}/releases/latest" executes on every SessionStart hook invocation with no freshness check; confirmed by reading the file — no cache-file path, no age check, no skip logic.

Fix: Reads the cached version from ~/.cache/supaconductor/last-update-check when the file is under 24 hours old (find -mmin -1440); only runs curl when the cache is stale or absent, then writes the result back to the cache.

Previously, session-start.sh called the GitHub Releases API unconditionally
on every Claude Code session startup, adding network latency to each session.

Cache the latest-tag result in ~/.cache/supaconductor/last-update-check and
skip the outbound request if the cache file is under 24 hours old.

Co-Authored-By: Claude Code <noreply@anthropic.com>

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request implements a 24-hour caching mechanism for GitHub update checks in hooks/session-start.sh to improve performance and reduce API calls. Review feedback identifies an invalid -quiet flag in the find command that would cause the cache check to fail and suggests adhering to the XDG Base Directory Specification by using XDG_CACHE_HOME for the cache directory path.

Comment thread hooks/session-start.sh
| sed 's/^v//' | head -1) || true
latest_tag=""
# Skip network call if cache is less than 24 hours old
if [ -f "$CACHE_FILE" ] && find "$CACHE_FILE" -mmin -1440 -quiet 2>/dev/null | grep -q .; then

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

The -quiet flag is not a standard option for the find command in most common implementations (GNU, BSD/macOS, etc.). Including it will cause the find command to fail with an error. Due to pipefail being set at the top of the script, the entire condition will evaluate to false, meaning the cache will never be used and the script will perform a network request on every session start, defeating the purpose of this change.

Suggested change
if [ -f "$CACHE_FILE" ] && find "$CACHE_FILE" -mmin -1440 -quiet 2>/dev/null | grep -q .; then
if [ -f "$CACHE_FILE" ] && find "$CACHE_FILE" -mmin -1440 2>/dev/null | grep -q .; then

Comment thread hooks/session-start.sh
# Check for latest release on GitHub (non-blocking, 3s timeout)
# Check for latest release on GitHub (non-blocking, 3s timeout, cached 24h)
REPO="Ibrahim-3d/orchestrator-supaconductor"
CACHE_DIR="${HOME}/.cache/supaconductor"

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

It is recommended to respect the XDG_CACHE_HOME environment variable if it is set, falling back to ~/.cache otherwise. This adheres better to the XDG Base Directory Specification followed by many Linux distributions and CLI tools.

Suggested change
CACHE_DIR="${HOME}/.cache/supaconductor"
CACHE_DIR="${XDG_CACHE_HOME:-$HOME/.cache}/supaconductor"

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