provider update advisories #2312
Mergedjustsomelegs(GitHub profile, opens in a new tab)merged 36 commits into
main fromrefs/pull/2312/headmerged by juliusmarminge View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelssize:XXL
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
justsomelegs(GitHub profile, opens in a new tab) changed the title
- apps/server/src/provider/providerUpdater.ts lines 120 to 128OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +108,21 @@108+ next.add(provider);109+ return [true, next] as const;110+ });111+ });112+113+ const releaseProvider = (provider: ProviderDriverKind) =>114+ Ref.update(runningProvidersRef, (runningProviders) => {115+ const next = new Set(runningProviders);116+ next.delete(provider);117+ return next;118+ });119+120+ const getUpdateLock = Effect.fn("getUpdateLock")(function* (updateLockKey: string) {121+ const existing = updateLocks.get(updateLockKey);122+ if (existing) {123+ return existing;124+ }125+ const next = yield* Semaphore.make(1);126+ updateLocks.set(updateLockKey, next);127+ return next;128+ });
- apps/server/src/provider/providerUpdater.ts lines 270 to 276OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +256,21 @@256+ return yield* finish(257+ makeUpdateState({258+ status: stillOutdated ? "unchanged" : "succeeded",259+ startedAt,260+ finishedAt,261+ message: couldNotVerify262+ ? "Update command completed, but T3 Code could not verify the provider version."263+ : stillOutdated264+ ? "Update command completed, but T3 Code still detects an outdated provider version."265+ : "Provider updated.",266+ output: commandOutput(result),267+ }),268+ );269+ });270+ const lock = updateLocks.get(updateLockKey);271+ if (!lock) {272+ return yield* new ServerProviderUpdateError({273+ provider,274+ reason: `Unsupported provider update lock key: ${updateLockKey}`,275+ });276+ }
- apps/server/src/provider/providerUpdater.ts lines 271 to 277OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +257,21 @@257+ makeUpdateState({258+ status: stillOutdated ? "unchanged" : "succeeded",259+ startedAt,260+ finishedAt,261+ message: couldNotVerify262+ ? "Update command completed, but T3 Code could not verify the provider version."263+ : stillOutdated264+ ? "Update command completed, but T3 Code still detects an outdated provider version."265+ : "Provider updated.",266+ output: commandOutput(result),267+ }),268+ );269+ });270+ const lock = updateLocks.get(updateLockKey);271+ if (!lock) {272+ yield* releaseProvider(provider);273+ return yield* new ServerProviderUpdateError({274+ provider,275+ reason: `Unsupported provider update lock key: ${updateLockKey}`,276+ });277+ }
github-actions[bot](GitHub profile, opens in a new tab) removed labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
- apps/server/src/provider/providerUpdater.ts line 196OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +176,21 @@176+ Effect.as<VerifiedProviderRefresh>({177+ providers,178+ verifiedProviders: refreshedProviders,179+ }),180+ ),181+ ),182+ );183+ }),184+ );185+186+ const updateProvider: ProviderUpdaterShape["updateProvider"] = (provider) =>187+ Effect.gen(function* () {188+ const lifecycle = yield* input.providerRegistry.getProviderVersionLifecycle(provider);189+ const updateExecutable = lifecycle.updateExecutable;190+ const updateLockKey = lifecycle.updateLockKey;191+ if (!updateExecutable || !updateLockKey) {192+ return yield* new ServerProviderUpdateError({193+ provider,194+ reason: "This provider does not support one-click updates.",195+ });196+ }
- apps/web/src/components/ProviderUpdateLaunchNotification.logic.ts lines 152 to 161Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +124,21 @@124+): boolean {125+ if (126+ candidate.versionAdvisory.canUpdate !== true ||127+ candidate.versionAdvisory.updateCommand === null128+ ) {129+ return false;130+ }131+132+ const driverProviders = providers.filter((provider) => provider.driver === candidate.driver);133+ if (driverProviders.length === 0) {134+ return false;135+ }136+137+ const updateCommands = new Set<string>();138+ for (const provider of driverProviders) {139+ const advisory = provider.versionAdvisory;140+ if (!advisory || advisory.canUpdate !== true || advisory.updateCommand === null) {141+ return false;142+ }143+ updateCommands.add(advisory.updateCommand);144+ }
- @@ -320,0 +383,21 @@383+ next.delete(provider);384+ } else {385+ next.set(provider, state);386+ }387+ return next;388+ });389+390+ const existingProviders = yield* Ref.get(providersRef);391+ const matchingProviders = existingProviders.filter(392+ (candidate) => candidate.driver === provider,393+ );394+ if (matchingProviders.length === 0) {395+ return existingProviders;396+ }397+398+ const nextProviders = yield* Effect.forEach(matchingProviders, applyProviderUpdateState, {399+ concurrency: "unbounded",400+ });401+ return yield* upsertProviders(nextProviders, {402+ persist: false,403+ });@@ -488,3 +515,11 @@488515 const availableEditors = useServerAvailableEditors();489516 const observability = useServerObservability();490517 const serverProviders = useServerProviders();518+ const providerUpdateCandidates = useMemo(519+ () => collectProviderUpdateCandidates(serverProviders),520+ [serverProviders],521+ );522+ const providerUpdateCandidateByInstanceId = useMemo(523+ () => new Map(providerUpdateCandidates.map((candidate) => [candidate.instanceId, candidate])),524+ [providerUpdateCandidates],525+ );
- @@ -0,0 +28,21 @@28+29+function writeProviderUpdateDismissals(document: ProviderUpdateDismissals): void {30+ try {31+ setLocalStorageItem(32+ PROVIDER_UPDATE_DISMISSALS_STORAGE_KEY,33+ document,34+ ProviderUpdateDismissalsSchema,35+ );36+ } catch {37+ // Dismissal state is best-effort UI state; a storage failure should not block the toast.38+ }39+}40+41+export function isProviderUpdateNotificationDismissed(42+ dismissalKey: string | null | undefined,43+): boolean {44+ if (!dismissalKey) {45+ return false;46+ }47+ return readProviderUpdateDismissals().keys.includes(dismissalKey);48+}apps/server/src/provider/providerVersionLifecycle.ts lines 182 to 192OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +172,21 @@172+): ProviderVersionLifecycle {173+ return makeProviderVersionLifecycle({174+ provider: definition.provider,175+ packageName: definition.npmPackageName,176+ updateExecutable: "pnpm",177+ updateArgs: ["add", "-g", `${definition.npmPackageName}@latest`],178+ updateLockKey: "pnpm-global",179+ });180+}181+182+function makeVitePlusGlobalProviderVersionLifecycle(183+ definition: PackageManagedProviderVersionLifecycleDefinition,184+): ProviderVersionLifecycle {185+ return makeProviderVersionLifecycle({186+ provider: definition.provider,187+ packageName: definition.npmPackageName,188+ updateExecutable: "vp",189+ updateArgs: ["i", "-g", definition.npmPackageName],190+ updateLockKey: "vite-plus-global",191+ });192+}
- @@ -206,3 +215,4 @@206215 models: input.models,207216 slashCommands: [...(input.slashCommands ?? [])],208217 skills: [...(input.skills ?? [])],218+ ...(versionAdvisory ? { versionAdvisory } : {}),
- apps/server/src/provider/providerMaintenance.ts line 237Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -0,0 +206,21 @@206+207+function isNpmGlobalCommandPath(commandPath: string): boolean {208+ const normalized = normalizeCommandPath(commandPath);209+ return (210+ normalized.includes("/node_modules/.bin/") ||211+ normalized.includes("/lib/node_modules/") ||212+ normalized.includes("/npm/node_modules/")213+ );214+}215+216+function isHomebrewCommandPath(commandPath: string): boolean {217+ const normalized = normalizeCommandPath(commandPath);218+ return (219+ normalized.includes("/opt/homebrew/cellar/") ||220+ normalized.includes("/usr/local/cellar/") ||221+ normalized.includes("/homebrew/cellar/") ||222+ normalized.includes("/opt/homebrew/caskroom/") ||223+ normalized.includes("/usr/local/caskroom/") ||224+ normalized.includes("/homebrew/caskroom/") ||225+ normalized.startsWith("/opt/homebrew/bin/") ||226+ normalized.startsWith("/usr/local/bin/")apps/server/src/provider/Layers/CursorProvider.ts line 1226OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -1222,10 +1223,4 @@12221223 const { settings, snapshot, publishSnapshot } = input;12231224 const stampIdentity = input.stampIdentity ?? ((value) => value);122412251225- if (1226- !settings.enabled ||1227- snapshot.auth.status === "unauthenticated" ||1228- !hasUncapturedCursorModels(snapshot)1229- ) {1230- return Effect.void;1231- }1226+ const enrichVersionAdvisory = enrichProviderSnapshotWithVersionAdvisory(snapshot).pipe(
- apps/server/src/provider/providerUpdater.ts line 234OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -0,0 +214,21 @@214+215+ return yield* commandCoordinator216+ .withCommandLock({217+ targetKey,218+ lockKey: update.lockKey,219+ run: Effect.gen(function* () {220+ const setUpdateState = (state: ServerProviderUpdateState | null) =>221+ input.providerRegistry.setProviderMaintenanceActionState({222+ instanceId,223+ action: "update",224+ state,225+ });226+227+ yield* setUpdateState(228+ makeUpdateState({229+ status: "queued",230+ startedAt: null,231+ finishedAt: null,232+ message: "Waiting for another provider update to finish.",233+ }),234+ );apps/server/src/provider/providerMaintenance.ts line 333OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -0,0 +313,21 @@313+ right: ProviderMaintenanceCapabilities,314+): boolean {315+ return (316+ left.provider === right.provider &&317+ left.packageName === right.packageName &&318+ left.update?.command === right.update?.command &&319+ left.update?.executable === right.update?.executable &&320+ left.update?.lockKey === right.update?.lockKey &&321+ (left.update?.args.length ?? 0) === (right.update?.args.length ?? 0) &&322+ (left.update?.args.every((value, index) => value === right.update?.args[index]) ?? true)323+ );324+}325+326+export function disableProviderMaintenanceUpdates(327+ capabilities: ProviderMaintenanceCapabilities,328+): ProviderMaintenanceCapabilities {329+ return makeManualOnlyProviderMaintenanceCapabilities({330+ provider: capabilities.provider,331+ packageName: capabilities.packageName,332+ });333+}
- apps/server/src/provider/providerMaintenanceRunner.ts lines 30 to 33OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +13,21 @@13+import type { ProviderRegistryShape } from "./Services/ProviderRegistry.ts";14+import { makeProviderMaintenanceCommandCoordinator } from "./providerMaintenanceCommandCoordinator.ts";15+import { enrichProviderSnapshotWithVersionAdvisory } from "./providerMaintenance.ts";16+import type { ProviderMaintenanceCapabilities } from "./providerMaintenance.ts";17+18+const UPDATE_TIMEOUT_MS = 5 * 60_000;19+const UPDATE_OUTPUT_MAX_BYTES = 10_000;20+21+export interface ProviderMaintenanceCommandResult {22+ readonly stdout: string;23+ readonly stderr: string;24+ readonly exitCode: number | null;25+ readonly timedOut: boolean;26+ readonly stdoutTruncated: boolean;27+ readonly stderrTruncated: boolean;28+}29+30+export type ProviderMaintenanceCommandRunner = (31+ command: string,32+ args: ReadonlyArray<string>,33+) => Effect.Effect<ProviderMaintenanceCommandResult>;
- apps/server/src/provider/providerMaintenance.ts line 59Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -0,0 +39,21 @@39+ ) => ProviderMaintenanceCapabilities;40+}41+42+export interface PackageManagedProviderMaintenanceDefinition {43+ readonly provider: ProviderDriverKind;44+ readonly npmPackageName: string;45+ readonly homebrewFormula: string | null;46+ readonly nativeUpdate: {47+ readonly executable: string;48+ readonly args: ReadonlyArray<string>;49+ readonly lockKey: string;50+ readonly isCommandPath: (commandPath: string) => boolean;51+ } | null;52+}53+54+interface LatestVersionCacheEntry {55+ readonly expiresAt: number;56+ readonly version: string | null;57+}58+59+const latestVersionCache = new Map<string, LatestVersionCacheEntry>();
- @@ -0,0 +383,21 @@383+ const advisory = deriveVersionAdvisory({384+ currentVersion: input.currentVersion,385+ latestVersion,386+ });387+388+ return {389+ status: advisory.status,390+ currentVersion: input.currentVersion,391+ latestVersion,392+ updateCommand: capabilities.update?.command ?? null,393+ canUpdate: capabilities.update !== null,394+ checkedAt: input.checkedAt ?? null,395+ message: advisory.message,396+ };397+}398+399+const fetchNpmLatestVersion = Effect.fn("fetchNpmLatestVersion")(function* (packageName: string) {400+ const client = yield* HttpClient.HttpClient;401+ const request = HttpClientRequest.get(402+ `https://registry.npmjs.org/${encodeURIComponent(packageName)}/latest`,403+ ).pipe(HttpClientRequest.setHeader("accept", "application/json"));
- apps/server/src/provider/Layers/ProviderRegistry.ts line 356OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -296,4 +353,4 @@296353297354 if (haveProvidersChanged(previousProviders, providers)) {298355 if (options?.persist !== false) {299- yield* Effect.forEach(nextProviders, persistProvider, {356+ yield* Effect.forEach(nextProvidersWithUpdateState, persistProvider, {
- @@ -0,0 +52,21 @@52+ });53+ });54+55+ const withCommandLock: ProviderMaintenanceCommandCoordinatorShape<E>["withCommandLock"] = ({56+ targetKey,57+ lockKey,58+ onQueued,59+ run,60+ }) =>61+ Effect.gen(function* () {62+ const acquired = yield* acquireTarget(targetKey);63+ if (!acquired) {64+ return yield* Effect.fail(input.makeAlreadyRunningError(targetKey));65+ }66+67+ return yield* Effect.gen(function* () {68+ const lock = yield* getLock(lockKey);69+ if (onQueued) {70+ yield* onQueued;71+ }72+ return yield* lock.withPermits(1)(run);
juliusmarminge merged this9b604bc
juliusmarminge closed this
Sign in to join this conversation.


Important
Review skipped#
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID:
343c17c5-6351-43e2-9829-63a3c893691dYou can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
✨ Finishing Touches
🧪 Generate unit tests (beta)
Tip
💬 Introducing Slack Agent: The best way for teams to turn conversations into code.
Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack.
👉 Get started
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share