Skip to main content

Update System

Automatic detection and installation of bundle updates.

Components

ComponentResponsibility
UpdateSchedulerTiming of checks (startup, daily/weekly)
UpdateCheckerCompare installed vs latest versions
AutoUpdateServiceBackground updates with rollback
UpdateCacheCache results with configurable TTL

Configuration

SettingDefaultDescription
promptregistry.updateCheck.enabledtrueEnable update checks
promptregistry.updateCheck.frequencydailydaily, weekly, manual
promptregistry.updateCheck.autoUpdatefalseGlobal gate for auto-updates
promptregistry.updateCheck.cacheTTL300000Cache TTL (5 min)
promptregistry.updateCheck.notificationPreferenceallall, major, none

Update Check Flow

flowchart TD
A[Extension activates] --> B[Wait 5 seconds]
B --> C[UpdateScheduler → UpdateChecker]
C --> D[Check cache UpdateCache]
D --> E{Cache status}
E -->|valid| F[Return cached]
E -->|expired| G[RegistryManager.checkUpdates]
G --> H[Compare installed vs latest]
H --> I[Cache results]
I --> J[Show notification if updates available]

Auto-Update Logic

Hybrid approach: Global autoUpdate setting + per-bundle opt-in

For auto-update to occur:

  1. Global updateCheck.autoUpdate = true
  2. Per-bundle auto-update enabled (via "Enable Auto-Update" command)

Concurrency Control

  • Batch Size: 3 concurrent updates
  • Active Updates Set: Prevents duplicate operations
  • Check-in-Progress Flag: Prevents overlapping cycles

Dependency Injection

Uses interfaces to avoid circular dependencies:

interface BundleOperations {
updateBundle(bundleId: string, version?: string): Promise<void>;
listInstalledBundles(): Promise<InstalledBundle[]>;
}

class AutoUpdateService {
constructor(
private readonly bundleOps: BundleOperations,
private readonly sourceOps: SourceOperations
) {}
}

Hub Sync Scheduler

Separate from bundle update checks, HubSyncScheduler keeps the active hub configuration fresh:

ComponentResponsibility
HubSyncScheduler24h periodic timer calling HubManager.syncActiveHub()
HubManager.onHubSyncedEvent fired after every hub sync (startup, manual, periodic)

Source sync is event-driven: a single onHubSynced listener in extension.ts triggers syncAllSources({ silent: true }) after any hub sync, ensuring sources stay in sync regardless of how the hub sync was initiated.

See Also