Skip to content

fix: version-check toast timing, remove terminal output, add cache path constant - #79

Merged
lloydsk merged 1 commit into
mainfrom
fix/version-check-toast-cleanup
Jul 27, 2026
Merged

fix: version-check toast timing, remove terminal output, add cache path constant#79
lloydsk merged 1 commit into
mainfrom
fix/version-check-toast-cleanup

Conversation

@lloydsk

@lloydsk lloydsk commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes the version-check notification behavior so the update toast appears correctly on startup without leaking into the terminal or the first user prompt.

Changes

Bug Fixes

  • Toast timing — previously then inside the callback meant a slow npm registry fetch could suspend until after the user's first prompt. The delay now runs after the promise resolves: _versionCheckPromise.then(async (result) => { await sleep(2000); showToast() })
  • Remove terminal outputwarnIfStale previously printed a multi-line console.warn to stderr on every startup when outdated. Removed — the UI toast is the sole notification channel
  • Remove system prompt injection — removed experimental.chat.system.transform hook that was injecting update notices into the agent system prompt on the first turn

Improvements

  • PLUGIN_CACHE_PATH constant — exported from src/version-check.ts as a single source of truth for the opencode plugin cache path (cross-platform). Used by both startup check and cursor_update_plugin tool
  • warnIfStale accepts pre-fetched versionwarnIfStale(prefetchedLatest?) skips the registry call when the caller has already resolved it
  • Single registry fetch — one _latestVersionPromise shared across all startup paths; only one npm fetch per launch regardless of how many paths consume it

New

  • scripts/opencode-plugins-refresh — helper script for checking/clearing stale plugin caches; supports --check (CI-friendly) and --force flags

Tests

12 new tests added to test/version-check.test.ts:

  • PLUGIN_CACHE_PATH shape and path segment assertions
  • warnIfStale with pre-fetched version skips registry fetch
  • warnIfStale without pre-fetched version calls registry exactly once

356 tests, all passing.

Screenshot

Screenshot 2026-07-27 at 12 43 14

… constant

- Toast now fires after version fetch resolves + 2s delay, preventing slow
  network fetches from suspending into the user's first prompt
- Remove console.warn from warnIfStale; toast is the sole notification channel
- Remove system prompt injection of update notice (experimental.chat.system.transform)
- Export PLUGIN_CACHE_PATH constant as single source of truth for cache path
- warnIfStale accepts optional prefetchedLatest to avoid duplicate registry fetches
- Single _latestVersionPromise shared across startup paths (one fetch per launch)
- Add scripts/opencode-plugins-refresh helper for checking/clearing stale plugin caches
- Add 12 new tests covering PLUGIN_CACHE_PATH and warnIfStale prefetch behavior
@lloydsk
lloydsk requested a review from justin-carper July 27, 2026 17:31

@justin-carper justin-carper left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Amazing, thank you!

@lloydsk
lloydsk merged commit 8a0b53a into main Jul 27, 2026
6 checks passed
@lloydsk
lloydsk deleted the fix/version-check-toast-cleanup branch July 27, 2026 18:16
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.

2 participants