Skip to content

feat(update): harden auto-update lifecycle and resolve scoped npm registry#6

Merged
Chewji9875 merged 3 commits into
mainfrom
fix/tool-search-auto-update
Jul 17, 2026
Merged

feat(update): harden auto-update lifecycle and resolve scoped npm registry#6
Chewji9875 merged 3 commits into
mainfrom
fix/tool-search-auto-update

Conversation

@Chewji9875

@Chewji9875 Chewji9875 commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Scope

Harden the auto-update subsystem for reliable, scoped-npm-registry-aware upgrades.

Root Cause

Two gaps prevented auto-update from working reliably in environments using a scoped npm registry:

  1. Scoped registry endpoint: The resolver used a hardcoded https://registry.npmjs.org endpoint, which fails for scoped packages (@open-stellar/tool-search) hosted on private/regional registries.
  2. Lifecycle fragility: Missing explicit outcome states, overly broad invalidation (full electron-store wipe on update failure), and inconsistent toast contracts caused confusing UX and lost user state.

Key Changes

  • src/updater/updater.ts: Added explicit update outcome states (available/downloading/error/not-available), wrapper-only cache invalidation, download progress tracking, and fixed toast notification contract to always resolve or reject properly.
  • src/updater/resolver.ts: Dynamically resolves the npm registry endpoint from the package's publishConfig.registry or scoped registry config, with fallback to the public registry. Uses the resolved endpoint for all version checks and tarball downloads.

Validation Evidence

  • 189 tests passed, 1 skipped (intentionally skipped)
  • Typecheck: clean
  • Build: clean
  • Smoke: passing
  • npm pack: produces correct tarball

Issue

Closes #5

…pper-only invalidation, and toast contract

- Replace permanent hasCheckedForUpdate with in-flight sharing/retry behavior plus staged latch after successful cache invalidation.
- Introduce explicit outcomes: up-to-date, update-staged, invalidation-failed, check-failed.
- Only show restart toast after successful cache invalidation.
- Target exact @openstellar/tool-search and @openstellar/tool-search@latest wrappers; preserve sibling packages.
- Malformed semver returns check-failed.
- Add focused unit, lifecycle, and disposable-cache filesystem tests.
- Add src/hooks/npm-registry.ts: parseRegistryUrl validates http(s) URLs
  (no credentials, no query/fragment, no malformed input), buildDistTagsUrl
  preserves registry base path and percent-encodes the scoped package once,
  resolveRegistryUrl queries npm config get @openstellar:registry then
  registry with fallback to https://registry.npmjs.org.
- Inject execFile-style effects to keep resolver testable; production runs
  npm in the project directory with a bounded timeout.
- Wire getLatestVersion to use the resolved endpoint via the existing
  UpdateCheckEffects seam.
- Add focused unit tests for parse/build/resolve precedence and security
  rejections; verify getLatestVersion uses resolved URL.
@Chewji9875
Chewji9875 merged commit 66faa9f into main Jul 17, 2026
1 check passed
@Chewji9875
Chewji9875 deleted the fix/tool-search-auto-update branch July 17, 2026 01:51
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.

Implement dynamic NPM registry config resolver and fallback

1 participant