From b924b405fa276c393d0e73cc339fe06365fc31ea Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Wed, 13 May 2026 23:21:26 +0200 Subject: [PATCH] Add targeted provider compatibility updates - Generate provider-specific install commands from compatibility advisories - Surface provider update actions in the chat UI and block sends when unavailable - Skip stale advisories for disabled providers before version probing --- .../src/provider/Drivers/ClaudeDriver.ts | 7 +- .../src/provider/Drivers/CodexDriver.ts | 7 +- .../src/provider/Drivers/OpenCodeDriver.ts | 7 +- .../src/provider/Layers/CursorProvider.ts | 7 +- .../provider/ProviderCompatibility.test.ts | 80 ++++- .../src/provider/ProviderCompatibility.ts | 64 +++- .../src/provider/providerMaintenance.test.ts | 19 + .../src/provider/providerMaintenance.ts | 26 ++ .../providerMaintenanceRunner.test.ts | 30 ++ .../src/provider/providerMaintenanceRunner.ts | 11 +- apps/web/src/components/ChatView.tsx | 221 ++++++++++-- apps/web/src/components/chat/ChatComposer.tsx | 36 +- .../chat/ComposerPrimaryActions.tsx | 43 ++- .../components/chat/ProviderStatusBanner.tsx | 34 -- .../src/components/chat/ThreadErrorBanner.tsx | 5 +- .../settings/ProviderInstanceCard.tsx | 331 +++++++++++------- .../settings/SettingsPanels.browser.tsx | 59 +++- .../components/settings/SettingsPanels.tsx | 83 +++++ .../settings/providerStatus.test.ts | 32 +- .../src/components/settings/providerStatus.ts | 56 +++ packages/contracts/src/server.ts | 3 + provider-compatibility.v1.json | 8 +- 22 files changed, 925 insertions(+), 244 deletions(-) delete mode 100644 apps/web/src/components/chat/ProviderStatusBanner.tsx diff --git a/apps/server/src/provider/Drivers/ClaudeDriver.ts b/apps/server/src/provider/Drivers/ClaudeDriver.ts index 5d761c3dae..5f92e70a36 100644 --- a/apps/server/src/provider/Drivers/ClaudeDriver.ts +++ b/apps/server/src/provider/Drivers/ClaudeDriver.ts @@ -174,7 +174,12 @@ export const ClaudeDriver: ProviderDriver = { checkProvider, enrichSnapshot: ({ snapshot, publishSnapshot }) => enrichProviderSnapshotWithVersionAdvisory(snapshot, maintenanceCapabilities).pipe( - Effect.flatMap(ProviderCompatibility.enrichProviderSnapshotWithCompatibilityAdvisory), + Effect.flatMap((snapshot) => + ProviderCompatibility.enrichProviderSnapshotWithTargetedCompatibilityAdvisory( + snapshot, + maintenanceCapabilities, + ), + ), Effect.provideService(HttpClient.HttpClient, httpClient), Effect.provideService( ProviderCompatibility.ProviderCompatibilityService, diff --git a/apps/server/src/provider/Drivers/CodexDriver.ts b/apps/server/src/provider/Drivers/CodexDriver.ts index 5549826de8..33d6b8558a 100644 --- a/apps/server/src/provider/Drivers/CodexDriver.ts +++ b/apps/server/src/provider/Drivers/CodexDriver.ts @@ -174,7 +174,12 @@ export const CodexDriver: ProviderDriver = { checkProvider, enrichSnapshot: ({ snapshot, publishSnapshot }) => enrichProviderSnapshotWithVersionAdvisory(snapshot, maintenanceCapabilities).pipe( - Effect.flatMap(ProviderCompatibility.enrichProviderSnapshotWithCompatibilityAdvisory), + Effect.flatMap((snapshot) => + ProviderCompatibility.enrichProviderSnapshotWithTargetedCompatibilityAdvisory( + snapshot, + maintenanceCapabilities, + ), + ), Effect.provideService(HttpClient.HttpClient, httpClient), Effect.provideService( ProviderCompatibility.ProviderCompatibilityService, diff --git a/apps/server/src/provider/Drivers/OpenCodeDriver.ts b/apps/server/src/provider/Drivers/OpenCodeDriver.ts index 371672ae1a..910779dd29 100644 --- a/apps/server/src/provider/Drivers/OpenCodeDriver.ts +++ b/apps/server/src/provider/Drivers/OpenCodeDriver.ts @@ -153,7 +153,12 @@ export const OpenCodeDriver: ProviderDriver checkProvider, enrichSnapshot: ({ snapshot, publishSnapshot }) => enrichProviderSnapshotWithVersionAdvisory(snapshot, maintenanceCapabilities).pipe( - Effect.flatMap(ProviderCompatibility.enrichProviderSnapshotWithCompatibilityAdvisory), + Effect.flatMap((snapshot) => + ProviderCompatibility.enrichProviderSnapshotWithTargetedCompatibilityAdvisory( + snapshot, + maintenanceCapabilities, + ), + ), Effect.provideService(HttpClient.HttpClient, httpClient), Effect.provideService( ProviderCompatibility.ProviderCompatibilityService, diff --git a/apps/server/src/provider/Layers/CursorProvider.ts b/apps/server/src/provider/Layers/CursorProvider.ts index 84e91967eb..29479cc818 100644 --- a/apps/server/src/provider/Layers/CursorProvider.ts +++ b/apps/server/src/provider/Layers/CursorProvider.ts @@ -1247,7 +1247,12 @@ export const enrichCursorSnapshot = (input: { snapshot, input.maintenanceCapabilities, ).pipe( - Effect.flatMap(ProviderCompatibility.enrichProviderSnapshotWithCompatibilityAdvisory), + Effect.flatMap((enrichedSnapshot) => + ProviderCompatibility.enrichProviderSnapshotWithTargetedCompatibilityAdvisory( + enrichedSnapshot, + input.maintenanceCapabilities, + ), + ), Effect.provideService(HttpClient.HttpClient, input.httpClient), Effect.flatMap((enrichedSnapshot) => publishSnapshot(stampIdentity(enrichedSnapshot)).pipe(Effect.as(enrichedSnapshot)), diff --git a/apps/server/src/provider/ProviderCompatibility.test.ts b/apps/server/src/provider/ProviderCompatibility.test.ts index fa04bfbac0..aac01d5600 100644 --- a/apps/server/src/provider/ProviderCompatibility.test.ts +++ b/apps/server/src/provider/ProviderCompatibility.test.ts @@ -5,6 +5,7 @@ import * as Layer from "effect/Layer"; import { HttpClient, HttpClientResponse } from "effect/unstable/http"; import * as ProviderCompatibility from "./ProviderCompatibility.ts"; +import { makeProviderMaintenanceCapabilities } from "./providerMaintenance.ts"; const codexDriver = ProviderDriverKind.make("codex"); const claudeDriver = ProviderDriverKind.make("claudeAgent"); @@ -26,6 +27,14 @@ const baseProvider: ServerProvider = { skills: [], }; +const codexNpmUpdateCapabilities = makeProviderMaintenanceCapabilities({ + provider: codexDriver, + packageName: "@openai/codex", + updateExecutable: "npm", + updateArgs: ["install", "-g", "@openai/codex@latest"], + updateLockKey: "npm-global", +}); + function jsonHttpClient( responseForUrl: (url: string) => { readonly payload: unknown; readonly status?: number }, ): HttpClient.HttpClient { @@ -87,12 +96,57 @@ describe("provider compatibility", () => { }); }); - it("classifies the initial hosted compatibility policies for T3 Code 0.0.24+", () => { + it("adds a targeted compatibility update command when a recommended version is available", () => { const document: ProviderCompatibility.ProviderCompatibilityDocument = { version: 1, policies: [ { - t3CodeRange: ">=0.0.24", + t3CodeRange: ">=0.0.0", + driver: codexDriver, + recommendedRange: ">=0.129.0", + recommendedVersion: "0.129.0", + ranges: [{ status: "broken", range: "<0.129.0" }], + }, + ], + }; + + expect( + ProviderCompatibility.createProviderCompatibilityAdvisory({ + driver: codexDriver, + currentVersion: "0.128.0", + document, + maintenanceCapabilities: codexNpmUpdateCapabilities, + }), + ).toMatchObject({ + status: "broken", + canUpdate: true, + updateCommand: "npm install -g @openai/codex@0.129.0", + }); + }); + + it("does not warn on disabled providers before their version has been probed", () => { + const enriched = ProviderCompatibility.applyBundledProviderCompatibilityAdvisory({ + snapshot: { + ...baseProvider, + driver: cursorDriver, + enabled: false, + version: null, + status: "disabled", + }, + driver: cursorDriver, + currentVersion: null, + }); + + expect(enriched.compatibilityAdvisory).toBeUndefined(); + expect(enriched.status).toBe("disabled"); + }); + + it("classifies the bundled compatibility policies for current T3 Code builds", () => { + const document: ProviderCompatibility.ProviderCompatibilityDocument = { + version: 1, + policies: [ + { + t3CodeRange: ">=0.0.0", driver: codexDriver, recommendedRange: ">=0.129.0", recommendedVersion: "0.129.0", @@ -102,14 +156,14 @@ describe("provider compatibility", () => { ], }, { - t3CodeRange: ">=0.0.24", + t3CodeRange: ">=0.0.0", driver: claudeDriver, recommendedRange: ">=0.2.111", recommendedVersion: "0.2.111", ranges: [{ status: "supported", range: ">=0.2.111" }], }, { - t3CodeRange: ">=0.0.24", + t3CodeRange: ">=0.0.0", driver: opencodeDriver, recommendedRange: ">=1.14.19", recommendedVersion: "1.14.19", @@ -119,7 +173,7 @@ describe("provider compatibility", () => { ], }, { - t3CodeRange: ">=0.0.24", + t3CodeRange: ">=0.0.0", driver: cursorDriver, recommendedRange: ">=2026.05.09", recommendedVersion: "2026.05.09", @@ -136,7 +190,7 @@ describe("provider compatibility", () => { driver, currentVersion, document, - t3CodeVersion: "0.0.24", + t3CodeVersion: "0.0.22", })?.status; expect(classify(codexDriver, "0.129.0")).toBe("supported"); @@ -188,14 +242,18 @@ describe("provider compatibility", () => { }; return Effect.gen(function* () { - const enriched = yield* ProviderCompatibility.enrichProviderSnapshotWithCompatibilityAdvisory( - baseProvider, - ).pipe(provideCompatibility(() => ({ payload: remoteDocument }))); + const enriched = + yield* ProviderCompatibility.enrichProviderSnapshotWithTargetedCompatibilityAdvisory( + baseProvider, + codexNpmUpdateCapabilities, + ).pipe(provideCompatibility(() => ({ payload: remoteDocument }))); expect(enriched.status).toBe("error"); expect(enriched.compatibilityAdvisory).toMatchObject({ status: "broken", recommendedVersion: "0.129.0", + canUpdate: true, + updateCommand: "npm install -g @openai/codex@0.129.0", }); }); }); @@ -355,8 +413,8 @@ describe("provider compatibility", () => { }, ).pipe(provideCompatibility(() => ({ payload: {}, status: 404 }))); - expect(enriched.status).toBe("ready"); - expect(enriched.compatibilityAdvisory).toBeUndefined(); + expect(enriched.status).toBe("error"); + expect(enriched.compatibilityAdvisory).toMatchObject({ status: "broken" }); }), ); }); diff --git a/apps/server/src/provider/ProviderCompatibility.ts b/apps/server/src/provider/ProviderCompatibility.ts index d7e1eb6d4d..0673bbd7fc 100644 --- a/apps/server/src/provider/ProviderCompatibility.ts +++ b/apps/server/src/provider/ProviderCompatibility.ts @@ -17,6 +17,10 @@ import { HttpClient, HttpClientRequest } from "effect/unstable/http"; import bundledCompatibilityDocumentJson from "../../../../provider-compatibility.v1.json" with { type: "json" }; import packageJson from "../../package.json" with { type: "json" }; +import { + makeTargetedProviderUpdateAction, + type ProviderMaintenanceCapabilities, +} from "./providerMaintenance.ts"; const T3_CODE_VERSION = packageJson.version; const REMOTE_COMPATIBILITY_CACHE_TTL = Duration.minutes(15); @@ -145,6 +149,7 @@ function createProviderCompatibilityAdvisoryFromDocument(input: { readonly document: typeof RemoteCompatibilityDocument.Type; readonly driver: ProviderDriverKind; readonly currentVersion: string | null; + readonly maintenanceCapabilities?: ProviderMaintenanceCapabilities | undefined; readonly t3CodeVersion?: string; }): ServerProviderCompatibilityAdvisory | undefined { const policy = compatibilityPolicyForDriver({ @@ -163,6 +168,9 @@ function createProviderCompatibilityAdvisoryFromDocument(input: { : policy.ranges.find((range) => satisfiesSemverRange(currentVersion, range.range)); const status = matchedRange?.status ?? (currentVersion === null ? "unknown" : "unsupported"); const recommendedVersion = policy.recommendedVersion ?? null; + const targetedUpdateAction = input.maintenanceCapabilities + ? makeTargetedProviderUpdateAction(input.maintenanceCapabilities, recommendedVersion) + : null; return { status, @@ -176,20 +184,31 @@ function createProviderCompatibilityAdvisoryFromDocument(input: { }), recommendedRange: policy.recommendedRange, recommendedVersion, + updateCommand: targetedUpdateAction?.command ?? null, + canUpdate: targetedUpdateAction !== null, ranges: [...policy.ranges], }; } +function shouldSkipCompatibilityAdvisory(input: { + readonly snapshot: ProviderCompatibilitySnapshot; + readonly currentVersion: string | null; +}): boolean { + return !input.snapshot.enabled && input.currentVersion === null; +} + export function createProviderCompatibilityAdvisory(input: { readonly driver: ProviderDriverKind; readonly currentVersion: string | null; readonly document?: typeof RemoteCompatibilityDocument.Type; + readonly maintenanceCapabilities?: ProviderMaintenanceCapabilities | undefined; readonly t3CodeVersion?: string; }): ServerProviderCompatibilityAdvisory | undefined { return createProviderCompatibilityAdvisoryFromDocument({ document: input.document ?? bundledProviderCompatibilityDocument, driver: input.driver, currentVersion: input.currentVersion, + maintenanceCapabilities: input.maintenanceCapabilities, ...(input.t3CodeVersion ? { t3CodeVersion: input.t3CodeVersion } : {}), }); } @@ -300,12 +319,23 @@ export function applyBundledProviderCompatibilityAdvisory< readonly snapshot: Snapshot; readonly driver: ProviderDriverKind; readonly currentVersion: string | null; + readonly maintenanceCapabilities?: ProviderMaintenanceCapabilities | undefined; }): Snapshot { + if ( + shouldSkipCompatibilityAdvisory({ + snapshot: input.snapshot, + currentVersion: input.currentVersion, + }) + ) { + return removeExistingCompatibilityAdvisory(input.snapshot); + } + return applyCompatibilityAdvisory( input.snapshot, createProviderCompatibilityAdvisory({ driver: input.driver, currentVersion: input.currentVersion, + maintenanceCapabilities: input.maintenanceCapabilities, }), ); } @@ -317,9 +347,19 @@ export const enrichProviderSnapshotWithCompatibilityAdvisory = Effect.fn( return yield* compatibility.enrichSnapshot(snapshot); }); +export const enrichProviderSnapshotWithTargetedCompatibilityAdvisory = Effect.fn( + "enrichProviderSnapshotWithTargetedCompatibilityAdvisory", +)(function* (snapshot: ServerProvider, maintenanceCapabilities: ProviderMaintenanceCapabilities) { + const compatibility = yield* ProviderCompatibilityService; + return yield* compatibility.enrichSnapshot(snapshot, maintenanceCapabilities); +}); + export interface ProviderCompatibilityServiceShape { readonly resolveRemoteDocument: Effect.Effect; - readonly enrichSnapshot: (snapshot: ServerProvider) => Effect.Effect; + readonly enrichSnapshot: ( + snapshot: ServerProvider, + maintenanceCapabilities?: ProviderMaintenanceCapabilities | undefined, + ) => Effect.Effect; } export class ProviderCompatibilityService extends Context.Service< @@ -347,17 +387,23 @@ export const makeProviderCompatibilityService = Effect.fn("makeProviderCompatibi return { resolveRemoteDocument, - enrichSnapshot: (snapshot) => + enrichSnapshot: (snapshot, maintenanceCapabilities) => resolveRemoteDocument.pipe( Effect.map((remoteDocument) => - applyCompatibilityAdvisory( + shouldSkipCompatibilityAdvisory({ snapshot, - createProviderCompatibilityAdvisory({ - driver: snapshot.driver, - currentVersion: snapshot.version, - ...(remoteDocument ? { document: remoteDocument } : {}), - }), - ), + currentVersion: snapshot.version, + }) + ? removeExistingCompatibilityAdvisory(snapshot) + : applyCompatibilityAdvisory( + snapshot, + createProviderCompatibilityAdvisory({ + driver: snapshot.driver, + currentVersion: snapshot.version, + maintenanceCapabilities, + ...(remoteDocument ? { document: remoteDocument } : {}), + }), + ), ), ), } satisfies ProviderCompatibilityServiceShape; diff --git a/apps/server/src/provider/providerMaintenance.test.ts b/apps/server/src/provider/providerMaintenance.test.ts index e032b87a4d..12151322c0 100644 --- a/apps/server/src/provider/providerMaintenance.test.ts +++ b/apps/server/src/provider/providerMaintenance.test.ts @@ -13,6 +13,7 @@ import { makePackageManagedProviderMaintenanceResolver, makeProviderMaintenanceCapabilities, makeStaticProviderMaintenanceResolver, + makeTargetedProviderUpdateAction, normalizeCommandPath, resolveProviderMaintenanceCapabilitiesEffect, } from "./providerMaintenance.ts"; @@ -132,6 +133,24 @@ describe("providerMaintenance", () => { }); }); + it("targets package install commands that omit an explicit latest suffix", () => { + expect( + makeTargetedProviderUpdateAction( + makeProviderMaintenanceCapabilities({ + provider: driver("packageTool"), + packageName: "@example/package-tool", + updateExecutable: "vp", + updateArgs: ["i", "-g", "@example/package-tool"], + updateLockKey: "vite-plus-global", + }), + "1.2.3", + ), + ).toMatchObject({ + command: "vp i -g @example/package-tool@1.2.3", + args: ["i", "-g", "@example/package-tool@1.2.3"], + }); + }); + it.effect( "switches package-managed providers to vite-plus updates when the resolved binary lives in vite-plus global bin", () => diff --git a/apps/server/src/provider/providerMaintenance.ts b/apps/server/src/provider/providerMaintenance.ts index 7f5e9d94dc..c850cc3631 100644 --- a/apps/server/src/provider/providerMaintenance.ts +++ b/apps/server/src/provider/providerMaintenance.ts @@ -108,6 +108,32 @@ export function makeManualOnlyProviderMaintenanceCapabilities(input: { }); } +export function makeTargetedProviderUpdateAction( + capabilities: ProviderMaintenanceCapabilities, + targetVersion: string | null, +): ProviderMaintenanceCommandAction | null { + if (!capabilities.update || !capabilities.packageName || !targetVersion) { + return null; + } + + const versionedPackageArg = `${capabilities.packageName}@latest`; + const targetPackageArg = `${capabilities.packageName}@${targetVersion}`; + const packageArgIndex = capabilities.update.args.findIndex( + (arg) => arg === versionedPackageArg || arg === capabilities.packageName, + ); + if (packageArgIndex < 0) { + return null; + } + + const args = [...capabilities.update.args]; + args[packageArgIndex] = targetPackageArg; + return { + ...capabilities.update, + args, + command: [capabilities.update.executable, ...args].join(" "), + }; +} + function makeNpmGlobalProviderMaintenanceCapabilities( definition: PackageManagedProviderMaintenanceDefinition, ): ProviderMaintenanceCapabilities { diff --git a/apps/server/src/provider/providerMaintenanceRunner.test.ts b/apps/server/src/provider/providerMaintenanceRunner.test.ts index 5f5f975a4e..ca9f5a00d3 100644 --- a/apps/server/src/provider/providerMaintenanceRunner.test.ts +++ b/apps/server/src/provider/providerMaintenanceRunner.test.ts @@ -288,6 +288,36 @@ describe("providerMaintenanceRunner", () => { ); }); + it.effect("runs a targeted package update when a target version is supplied", () => { + const calls: Array<{ command: string; args: ReadonlyArray }> = []; + return Effect.gen(function* () { + const { registry } = yield* makeRegistry(baseProvider); + const updater = yield* makeTestRunner(registry); + + yield* updater.updateProvider({ + provider: CODEX_DRIVER, + targetVersion: "0.129.0", + }); + + assert.deepStrictEqual(calls, [ + { + command: "npm", + args: ["install", "-g", "@openai/codex@0.129.0"], + }, + ]); + }).pipe( + Effect.provide( + Layer.mergeAll( + latestVersionHttpClient("0.0.0"), + mockSpawnerLayer((command, args) => { + calls.push({ command, args }); + return { stdout: "updated" }; + }), + ), + ), + ); + }); + it.effect( "runs update commands through Effect ChildProcess when no test runner is injected", () => { diff --git a/apps/server/src/provider/providerMaintenanceRunner.ts b/apps/server/src/provider/providerMaintenanceRunner.ts index 5f76afb34d..40be630051 100644 --- a/apps/server/src/provider/providerMaintenanceRunner.ts +++ b/apps/server/src/provider/providerMaintenanceRunner.ts @@ -22,7 +22,10 @@ import { ChildProcess, ChildProcessSpawner } from "effect/unstable/process"; import { ProviderRegistry } from "./Services/ProviderRegistry.ts"; import { makeProviderMaintenanceCommandCoordinator } from "./providerMaintenanceCommandCoordinator.ts"; -import { enrichProviderSnapshotWithVersionAdvisory } from "./providerMaintenance.ts"; +import { + enrichProviderSnapshotWithVersionAdvisory, + makeTargetedProviderUpdateAction, +} from "./providerMaintenance.ts"; import type { ProviderMaintenanceCapabilities } from "./providerMaintenance.ts"; import { collectUint8StreamText } from "../stream/collectUint8StreamText.ts"; const isServerProviderUpdateError = Schema.is(ServerProviderUpdateError); @@ -46,6 +49,7 @@ export interface ProviderMaintenanceRunnerShape { | { readonly provider: ProviderDriverKind; readonly instanceId?: ProviderInstanceId | undefined; + readonly targetVersion?: string | undefined; }, ) => Effect.Effect; } @@ -283,12 +287,15 @@ export const make = Effect.fn("ProviderMaintenanceRunner.make")(function* () { typeof target === "string" ? defaultInstanceIdForDriver(provider) : (target.instanceId ?? defaultInstanceIdForDriver(provider)); + const targetVersion = typeof target === "string" ? undefined : target.targetVersion; const targetKey = `instance:${instanceId}`; const capabilities = yield* providerRegistry.getProviderMaintenanceCapabilitiesForInstance( instanceId, provider, ); - const update = capabilities.update; + const update = targetVersion + ? makeTargetedProviderUpdateAction(capabilities, targetVersion) + : capabilities.update; if (!update) { return yield* new ServerProviderUpdateError({ provider, diff --git a/apps/web/src/components/ChatView.tsx b/apps/web/src/components/ChatView.tsx index 6b84aa11ca..5c9231dda7 100644 --- a/apps/web/src/components/ChatView.tsx +++ b/apps/web/src/components/ChatView.tsx @@ -42,7 +42,7 @@ import { useGitStatus } from "~/lib/gitStatusState"; import { usePrimaryEnvironmentId } from "../environments/primary"; import { readEnvironmentApi } from "../environmentApi"; import { isElectron } from "../env"; -import { readLocalApi } from "../localApi"; +import { ensureLocalApi, readLocalApi } from "../localApi"; import { parseDiffRouteSearch, stripDiffSearchParams } from "../diffRouteSearch"; import { collapseExpandedComposerCursor, @@ -104,7 +104,14 @@ import { BranchToolbar } from "./BranchToolbar"; import { resolveShortcutCommand, shortcutLabelForCommand } from "../keybindings"; import PlanSidebar from "./PlanSidebar"; import ThreadTerminalDrawer from "./ThreadTerminalDrawer"; -import { ChevronDownIcon, TriangleAlertIcon, WifiOffIcon } from "lucide-react"; +import { + ChevronDownIcon, + CircleAlertIcon, + DownloadIcon, + LoaderIcon, + TriangleAlertIcon, + WifiOffIcon, +} from "lucide-react"; import { cn, randomUUID } from "~/lib/utils"; import { stackedThreadToast, toastManager } from "./ui/toast"; import { decodeProjectScriptKeybindingRule } from "~/lib/projectScriptKeybindings"; @@ -147,7 +154,6 @@ import { ChatHeader } from "./chat/ChatHeader"; import { type ExpandedImagePreview } from "./chat/ExpandedImagePreview"; import { NoActiveThreadState } from "./NoActiveThreadState"; import { resolveEffectiveEnvMode, resolveEnvironmentOptionLabel } from "./BranchToolbar.logic"; -import { ProviderStatusBanner } from "./chat/ProviderStatusBanner"; import { ThreadErrorBanner } from "./chat/ThreadErrorBanner"; import { ComposerBannerStack, type ComposerBannerStackItem } from "./chat/ComposerBannerStack"; import { @@ -183,6 +189,11 @@ import { sanitizeThreadErrorMessage } from "~/rpc/transportError"; import { retainThreadDetailSubscription } from "../environments/runtime/service"; import { RightPanelSheet } from "./RightPanelSheet"; import { Button } from "./ui/button"; +import { Popover, PopoverPopup, PopoverTrigger } from "./ui/popover"; +import { + canRunProviderCompatibilityUpdate, + getProviderCompatibilityUpdateCommand, +} from "./settings/providerStatus"; import { buildVersionMismatchDismissalKey, dismissVersionMismatch, @@ -197,6 +208,75 @@ const EMPTY_PROPOSED_PLANS: Thread["proposedPlans"] = []; const EMPTY_PROVIDERS: ServerProvider[] = []; const EMPTY_PROVIDER_SKILLS: ServerProvider["skills"] = []; const EMPTY_PENDING_USER_INPUT_ANSWERS: Record = {}; + +function stripProviderCompatibilityInstallHint(message: string, recommendedVersion: string | null) { + if (!recommendedVersion) { + return message; + } + const escapedVersion = recommendedVersion.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); + return message.replace(new RegExp(`\\s*Use\\s+${escapedVersion}\\.?\\s*$`, "i"), "").trim(); +} + +function ProviderCompatibilityBannerAction({ + providerLabel, + recommendedVersion, + updateCommand, + canRunUpdate, + updating, + onRunUpdate, +}: { + readonly providerLabel: string; + readonly recommendedVersion: string; + readonly updateCommand: string | null; + readonly canRunUpdate: boolean; + readonly updating: boolean; + readonly onRunUpdate: () => void; +}) { + return ( + + + Install {recommendedVersion} + + } + /> + +
+
+

+ Install compatible {providerLabel} +

+

+ Install provider harness version {recommendedVersion}. +

+
+ {canRunUpdate ? ( + + ) : null} + {updateCommand ? ( +
+ + {updateCommand} + +
+ ) : null} +
+
+
+ ); +} + type EnvironmentUnavailableState = { readonly environmentId: EnvironmentId; readonly label: string; @@ -1150,6 +1230,8 @@ export default function ChatView(props: ChatViewProps) { const [dismissedVersionMismatchKey, setDismissedVersionMismatchKey] = useState( null, ); + const [compatibilityUpdatingProviderId, setCompatibilityUpdatingProviderId] = + useState(null); const versionMismatchDismissed = versionMismatchDismissKey === dismissedVersionMismatchKey || isVersionMismatchDismissed(versionMismatchDismissKey); @@ -1178,8 +1260,112 @@ export default function ChatView(props: ChatViewProps) { savedEnvironmentRuntimeById, serverConfig?.environment.label, ]); + const providerStatuses = serverConfig?.providers ?? EMPTY_PROVIDERS; + const unlockedSelectedProvider = resolveSelectableProvider( + providerStatuses, + selectedProviderByThreadId ?? threadProvider ?? ProviderDriverKind.make("codex"), + ); + const selectedProvider: ProviderDriverKind = lockedProvider ?? unlockedSelectedProvider; + // Prefer an instance-id match so a custom Codex instance (e.g. + // `codex_personal`) surfaces its own status/message in the banner rather + // than the default Codex's. Falls back to first-match-by-kind when no + // saved instance id is available or the instance no longer exists. + const activeProviderInstanceId = + composerActiveProvider ?? + activeThread?.session?.providerInstanceId ?? + activeThread?.modelSelection.instanceId ?? + activeProject?.defaultModelSelection?.instanceId ?? + null; + const activeProviderStatus = useMemo(() => { + if (activeProviderInstanceId) { + return ( + providerStatuses.find((status) => status.instanceId === activeProviderInstanceId) ?? null + ); + } + const defaultInstanceId = defaultInstanceIdForDriver(selectedProvider); + return providerStatuses.find((status) => status.instanceId === defaultInstanceId) ?? null; + }, [activeProviderInstanceId, providerStatuses, selectedProvider]); + const runActiveProviderCompatibilityUpdate = useCallback(async () => { + const provider = activeProviderStatus; + const targetVersion = provider?.compatibilityAdvisory?.recommendedVersion ?? null; + if (!provider || !targetVersion) { + return; + } + + setCompatibilityUpdatingProviderId(provider.instanceId); + try { + await ensureLocalApi().server.updateProvider({ + provider: provider.driver, + instanceId: provider.instanceId, + targetVersion, + }); + } catch (error) { + toastManager.add( + stackedThreadToast({ + type: "error", + title: `Could not update ${provider.displayName ?? provider.driver}`, + description: + error instanceof Error + ? error.message + : "The provider update command could not be started.", + }), + ); + } finally { + setCompatibilityUpdatingProviderId((current) => + current === provider.instanceId ? null : current, + ); + } + }, [activeProviderStatus]); const composerBannerItems = useMemo(() => { const items: ComposerBannerStackItem[] = []; + if ( + activeProviderStatus && + activeProviderStatus.status !== "ready" && + activeProviderStatus.status !== "disabled" + ) { + const defaultMessage = + activeProviderStatus.status === "error" + ? "Provider is unavailable." + : "Provider needs attention."; + const recommendedVersion = + activeProviderStatus.compatibilityAdvisory?.recommendedVersion ?? null; + const compatibilityUpdateCommand = + getProviderCompatibilityUpdateCommand(activeProviderStatus); + const canRunCompatibilityUpdate = canRunProviderCompatibilityUpdate(activeProviderStatus); + const compatibilityUpdating = + compatibilityUpdatingProviderId === activeProviderStatus.instanceId; + const hasCompatibilityInstallAction = + activeProviderStatus.compatibilityAdvisory?.status !== "supported" && + recommendedVersion !== null && + (canRunCompatibilityUpdate || compatibilityUpdateCommand !== null); + const rawMessage = activeProviderStatus.message ?? defaultMessage; + const message = hasCompatibilityInstallAction + ? stripProviderCompatibilityInstallHint(rawMessage, recommendedVersion) + : rawMessage; + const providerLabel = activeProviderStatus.displayName ?? activeProviderStatus.driver; + items.push({ + id: `provider-status:${activeProviderStatus.instanceId}:${activeProviderStatus.status}`, + variant: activeProviderStatus.status === "error" ? "error" : "warning", + icon: , + title: `${providerLabel} provider status`, + description: ( + + {message} + + ), + actions: + hasCompatibilityInstallAction && recommendedVersion ? ( + void runActiveProviderCompatibilityUpdate()} + /> + ) : undefined, + }); + } if (activeEnvironmentUnavailableState) { items.push({ id: `environment-unavailable:${activeEnvironmentUnavailableState.environmentId}`, @@ -1248,20 +1434,17 @@ export default function ChatView(props: ChatViewProps) { return items; }, [ activeEnvironmentUnavailableState, + activeProviderStatus, + compatibilityUpdatingProviderId, handleReconnectActiveEnvironment, navigate, reconnectingEnvironmentId, + runActiveProviderCompatibilityUpdate, showVersionMismatchBanner, versionMismatch, versionMismatchDismissKey, versionMismatchServerLabel, ]); - const providerStatuses = serverConfig?.providers ?? EMPTY_PROVIDERS; - const unlockedSelectedProvider = resolveSelectableProvider( - providerStatuses, - selectedProviderByThreadId ?? threadProvider ?? ProviderDriverKind.make("codex"), - ); - const selectedProvider: ProviderDriverKind = lockedProvider ?? unlockedSelectedProvider; const phase = derivePhase(activeThread?.session ?? null); const threadActivities = activeThread?.activities ?? EMPTY_ACTIVITIES; const workLogEntries = useMemo( @@ -1633,24 +1816,6 @@ export default function ChatView(props: ChatViewProps) { const gitStatusQuery = useGitStatus({ environmentId, cwd: gitCwd }); const keybindings = useServerKeybindings(); const availableEditors = useServerAvailableEditors(); - // Prefer an instance-id match so a custom Codex instance (e.g. - // `codex_personal`) surfaces its own status/message in the banner rather - // than the default Codex's. Falls back to first-match-by-kind when no - // saved instance id is available or the instance no longer exists. - const activeProviderInstanceId = - activeThread?.session?.providerInstanceId ?? - activeThread?.modelSelection.instanceId ?? - activeProject?.defaultModelSelection?.instanceId ?? - null; - const activeProviderStatus = useMemo(() => { - if (activeProviderInstanceId) { - return ( - providerStatuses.find((status) => status.instanceId === activeProviderInstanceId) ?? null - ); - } - const defaultInstanceId = defaultInstanceIdForDriver(selectedProvider); - return providerStatuses.find((status) => status.instanceId === defaultInstanceId) ?? null; - }, [activeProviderInstanceId, providerStatuses, selectedProvider]); const activeProjectCwd = activeProject?.cwd ?? null; const activeThreadWorktreePath = activeThread?.worktreePath ?? null; const activeWorkspaceRoot = activeThreadWorktreePath ?? activeProjectCwd ?? undefined; @@ -3540,8 +3705,6 @@ export default function ChatView(props: ChatViewProps) { /> - {/* Error banner */} - setThreadError(activeThread.id, null)} diff --git a/apps/web/src/components/chat/ChatComposer.tsx b/apps/web/src/components/chat/ChatComposer.tsx index 2c4743de3c..b4feb7870a 100644 --- a/apps/web/src/components/chat/ChatComposer.tsx +++ b/apps/web/src/components/chat/ChatComposer.tsx @@ -302,6 +302,7 @@ const ComposerFooterPrimaryActions = memo(function ComposerFooterPrimaryActions( isSendBusy: boolean; isConnecting: boolean; isEnvironmentUnavailable: boolean; + isProviderUnavailable: boolean; hasSendableContent: boolean; preserveComposerFocusOnPointerDown?: boolean; onPreviousPendingQuestion: () => void; @@ -323,6 +324,7 @@ const ComposerFooterPrimaryActions = memo(function ComposerFooterPrimaryActions( isSendBusy={props.isSendBusy} isConnecting={props.isConnecting} isEnvironmentUnavailable={props.isEnvironmentUnavailable} + isProviderUnavailable={props.isProviderUnavailable} isPreparingWorktree={props.isPreparingWorktree} hasSendableContent={props.hasSendableContent} preserveComposerFocusOnPointerDown={props.preserveComposerFocusOnPointerDown ?? false} @@ -716,6 +718,11 @@ export const ChatComposer = memo( () => selectedProviderEntry?.snapshot ?? null, [selectedProviderEntry], ); + const selectedProviderUnavailableMessage = + selectedProviderStatus?.status === "error" + ? (selectedProviderStatus.message ?? "Selected provider is unavailable.") + : null; + const isSelectedProviderUnavailable = selectedProviderUnavailableMessage !== null; const selectedProviderModels = useMemo>( () => selectedProviderEntry?.models ?? [], [selectedProviderEntry], @@ -1053,7 +1060,11 @@ export const ChatComposer = memo( [activePendingIsResponding, activePendingProgress, activePendingResolvedAnswers], ); const collapsedComposerPrimaryActionDisabled = - phase === "running" || isSendBusy || isConnecting || !composerSendState.hasSendableContent; + phase === "running" || + isSendBusy || + isConnecting || + isSelectedProviderUnavailable || + !composerSendState.hasSendableContent; const collapsedComposerPrimaryActionLabel = "Send message"; const showMobilePendingAnswerActions = isMobileViewport && !isComposerCollapsedMobile && pendingPrimaryAction !== null; @@ -1619,12 +1630,21 @@ export const ChatComposer = memo( const submitComposer = useCallback( (event?: { preventDefault: () => void }) => { + if (isSelectedProviderUnavailable) { + event?.preventDefault(); + return; + } onSend(event); if (shouldBlurMobileComposerOnSubmit()) { blurMobileComposerAfterSend(); } }, - [blurMobileComposerAfterSend, onSend, shouldBlurMobileComposerOnSubmit], + [ + blurMobileComposerAfterSend, + isSelectedProviderUnavailable, + onSend, + shouldBlurMobileComposerOnSubmit, + ], ); const expandMobileComposer = useCallback(() => { if (composerBlurFrameRef.current !== null) { @@ -2079,6 +2099,7 @@ export const ChatComposer = memo( isSendBusy={isSendBusy} isConnecting={isConnecting} isEnvironmentUnavailable={environmentUnavailable !== null} + isProviderUnavailable={isSelectedProviderUnavailable} isPreparingWorktree={false} hasSendableContent={false} preserveComposerFocusOnPointerDown @@ -2265,12 +2286,15 @@ export const ChatComposer = memo( ? "connecting" : "disconnected" }` - : phase === "disconnected" - ? "Ask for follow-up changes or attach images" - : "Ask anything, @tag files/folders, $use skills, or / for commands" + : selectedProviderUnavailableMessage + ? selectedProviderUnavailableMessage + : phase === "disconnected" + ? "Ask for follow-up changes or attach images" + : "Ask anything, @tag files/folders, $use skills, or / for commands" } disabled={ isConnecting || + isSelectedProviderUnavailable || isComposerApprovalState || (environmentUnavailable !== null && activePendingProgress === null) } @@ -2289,6 +2313,7 @@ export const ChatComposer = memo( isSendBusy={isSendBusy} isConnecting={isConnecting} isEnvironmentUnavailable={environmentUnavailable !== null} + isProviderUnavailable={isSelectedProviderUnavailable} isPreparingWorktree={false} hasSendableContent={false} preserveComposerFocusOnPointerDown @@ -2405,6 +2430,7 @@ export const ChatComposer = memo( isSendBusy={isSendBusy} isConnecting={isConnecting} isEnvironmentUnavailable={environmentUnavailable !== null} + isProviderUnavailable={isSelectedProviderUnavailable} isPreparingWorktree={isPreparingWorktree} hasSendableContent={composerSendState.hasSendableContent} preserveComposerFocusOnPointerDown={isMobileViewport} diff --git a/apps/web/src/components/chat/ComposerPrimaryActions.tsx b/apps/web/src/components/chat/ComposerPrimaryActions.tsx index fbeb9de30b..e6dbc74daa 100644 --- a/apps/web/src/components/chat/ComposerPrimaryActions.tsx +++ b/apps/web/src/components/chat/ComposerPrimaryActions.tsx @@ -21,6 +21,7 @@ interface ComposerPrimaryActionsProps { isSendBusy: boolean; isConnecting: boolean; isEnvironmentUnavailable: boolean; + isProviderUnavailable: boolean; isPreparingWorktree: boolean; hasSendableContent: boolean; preserveComposerFocusOnPointerDown?: boolean; @@ -60,6 +61,7 @@ export const ComposerPrimaryActions = memo(function ComposerPrimaryActions({ isSendBusy, isConnecting, isEnvironmentUnavailable, + isProviderUnavailable, isPreparingWorktree, hasSendableContent, preserveComposerFocusOnPointerDown = false, @@ -107,6 +109,7 @@ export const ComposerPrimaryActions = memo(function ComposerPrimaryActions({ {...pointerFocusProps} disabled={ isEnvironmentUnavailable || + isProviderUnavailable || pendingAction.isResponding || (pendingAction.isLastQuestion ? !pendingAction.isComplete : !pendingAction.canAdvance) } @@ -146,7 +149,7 @@ export const ComposerPrimaryActions = memo(function ComposerPrimaryActions({ size="sm" className={cn("rounded-full", compact ? "h-9 px-3 sm:h-8" : "h-9 px-4 sm:h-8")} {...pointerFocusProps} - disabled={isSendBusy || isConnecting || isEnvironmentUnavailable} + disabled={isSendBusy || isConnecting || isEnvironmentUnavailable || isProviderUnavailable} > {isConnecting || isSendBusy ? "Sending..." : "Refine"} @@ -160,7 +163,7 @@ export const ComposerPrimaryActions = memo(function ComposerPrimaryActions({ size="sm" className="h-9 rounded-l-full rounded-r-none px-4 sm:h-8" {...pointerFocusProps} - disabled={isSendBusy || isConnecting || isEnvironmentUnavailable} + disabled={isSendBusy || isConnecting || isEnvironmentUnavailable || isProviderUnavailable} > {isConnecting || isSendBusy ? "Sending..." : "Implement"} @@ -173,7 +176,9 @@ export const ComposerPrimaryActions = memo(function ComposerPrimaryActions({ className="h-9 rounded-l-none rounded-r-full border-l-white/12 px-2 sm:h-8" aria-label="Implementation actions" {...pointerFocusProps} - disabled={isSendBusy || isConnecting || isEnvironmentUnavailable} + disabled={ + isSendBusy || isConnecting || isEnvironmentUnavailable || isProviderUnavailable + } /> } > @@ -181,7 +186,9 @@ export const ComposerPrimaryActions = memo(function ComposerPrimaryActions({ void onImplementPlanInNewThread()} > Implement in a new thread @@ -197,17 +204,25 @@ export const ComposerPrimaryActions = memo(function ComposerPrimaryActions({ type="submit" className="flex h-9 w-9 enabled:cursor-pointer items-center justify-center rounded-full bg-primary/90 text-primary-foreground transition-all duration-150 hover:bg-primary hover:scale-105 disabled:pointer-events-none disabled:opacity-30 disabled:hover:scale-100 sm:h-8 sm:w-8" {...pointerFocusProps} - disabled={isSendBusy || isConnecting || isEnvironmentUnavailable || !hasSendableContent} + disabled={ + isSendBusy || + isConnecting || + isEnvironmentUnavailable || + isProviderUnavailable || + !hasSendableContent + } aria-label={ - isEnvironmentUnavailable - ? "Environment disconnected" - : isConnecting - ? "Connecting" - : isPreparingWorktree - ? "Preparing worktree" - : isSendBusy - ? "Sending" - : "Send message" + isProviderUnavailable + ? "Provider unavailable" + : isEnvironmentUnavailable + ? "Environment disconnected" + : isConnecting + ? "Connecting" + : isPreparingWorktree + ? "Preparing worktree" + : isSendBusy + ? "Sending" + : "Send message" } > {isConnecting || isSendBusy ? ( diff --git a/apps/web/src/components/chat/ProviderStatusBanner.tsx b/apps/web/src/components/chat/ProviderStatusBanner.tsx deleted file mode 100644 index a882942585..0000000000 --- a/apps/web/src/components/chat/ProviderStatusBanner.tsx +++ /dev/null @@ -1,34 +0,0 @@ -import { type ServerProvider } from "@t3tools/contracts"; -import { memo } from "react"; -import { Alert, AlertDescription, AlertTitle } from "../ui/alert"; -import { CircleAlertIcon } from "lucide-react"; -import { formatProviderDriverKindLabel } from "../../providerModels"; - -export const ProviderStatusBanner = memo(function ProviderStatusBanner({ - status, -}: { - status: ServerProvider | null; -}) { - if (!status || status.status === "ready" || status.status === "disabled") { - return null; - } - - const providerLabel = status.displayName?.trim() || formatProviderDriverKindLabel(status.driver); - const defaultMessage = - status.status === "error" - ? `${providerLabel} provider is unavailable.` - : `${providerLabel} provider has limited availability.`; - const title = `${providerLabel} provider status`; - - return ( -
- - - {title} - - {status.message ?? defaultMessage} - - -
- ); -}); diff --git a/apps/web/src/components/chat/ThreadErrorBanner.tsx b/apps/web/src/components/chat/ThreadErrorBanner.tsx index b48412453c..53bf4acca7 100644 --- a/apps/web/src/components/chat/ThreadErrorBanner.tsx +++ b/apps/web/src/components/chat/ThreadErrorBanner.tsx @@ -1,7 +1,8 @@ import { memo } from "react"; -import { Alert, AlertAction, AlertDescription } from "../ui/alert"; import { CircleAlertIcon, XIcon } from "lucide-react"; +import { Alert, AlertAction, AlertDescription } from "../ui/alert"; + export const ThreadErrorBanner = memo(function ThreadErrorBanner({ error, onDismiss, @@ -11,7 +12,7 @@ export const ThreadErrorBanner = memo(function ThreadErrorBanner({ }) { if (!error) return null; return ( -
+
diff --git a/apps/web/src/components/settings/ProviderInstanceCard.tsx b/apps/web/src/components/settings/ProviderInstanceCard.tsx index 67515ce65a..2a12b39803 100644 --- a/apps/web/src/components/settings/ProviderInstanceCard.tsx +++ b/apps/web/src/components/settings/ProviderInstanceCard.tsx @@ -39,6 +39,7 @@ import { ProviderModelsSection } from "./ProviderModelsSection"; import { ProviderInstanceIcon } from "../chat/ProviderInstanceIcon"; import { RedactedSensitiveText } from "./RedactedSensitiveText"; import { + getProviderCompatibilityUpdateCommand, getProviderVersionAdvisoryPresentation, PROVIDER_STATUS_STYLES, getProviderCompatibilityAdvisoryPresentation, @@ -57,6 +58,8 @@ const PROVIDER_ACCENT_SWATCHES = [ ] as const; const ENVIRONMENT_VARIABLE_NAME_PATTERN = /^[a-zA-Z_][a-zA-Z0-9_]*$/; +const ADVISORY_ICON_CLUSTER_CLASS = "-my-0.5 inline-flex h-5 shrink-0 items-center gap-2"; +const ADVISORY_ICON_SLOT_CLASS = "inline-flex size-5 shrink-0 items-center justify-center"; let environmentVariableDraftId = 0; const nextEnvironmentVariableDraftId = () => `provider-env-${environmentVariableDraftId++}`; @@ -422,6 +425,8 @@ interface ProviderInstanceCardProps { readonly onModelOrderChange: (next: ReadonlyArray) => void; readonly onRunUpdate?: (() => void) | undefined; readonly isUpdating?: boolean | undefined; + readonly onRunCompatibilityUpdate?: (() => void) | undefined; + readonly isCompatibilityUpdating?: boolean | undefined; } /** @@ -466,6 +471,8 @@ export function ProviderInstanceCard({ onModelOrderChange, onRunUpdate, isUpdating = false, + onRunCompatibilityUpdate, + isCompatibilityUpdating = false, }: ProviderInstanceCardProps) { const enabled = instance.enabled ?? true; // The server-reported status wins when present; otherwise fall back to @@ -487,7 +494,9 @@ export function ProviderInstanceCard({ liveProvider?.compatibilityAdvisory, ); const versionAdvisory = getProviderVersionAdvisoryPresentation(liveProvider?.versionAdvisory); + const hasProviderAdvisoryIcons = compatibilityAdvisory !== null || versionAdvisory !== null; const updateCommand = versionAdvisory?.updateCommand ?? null; + const compatibilityUpdateCommand = getProviderCompatibilityUpdateCommand(liveProvider); const FallbackIconComponent = driverOption?.icon; const displayName = instance.displayName?.trim() || driverOption?.label || String(instance.driver); @@ -681,134 +690,200 @@ export function ProviderInstanceCard({
{titleHeadNode} - {versionCodeNode} - {compatibilityAdvisory ? ( - - - - - } - /> - -
-

- {compatibilityAdvisory.title} -

-

- {compatibilityAdvisory.detail} -

-
-
-
- ) : null} - {versionAdvisory ? ( - - - - - } - /> - -
-
-

- Update available -

-

- {versionAdvisory.detail} -

-
- {onRunUpdate ? ( - - ) : null} - {onRunUpdate && updateCommand ? ( -
- - or, update manually using - -
- ) : null} - {updateCommand ? ( -
- - {updateCommand} - - - - copyToClipboard(updateCommand, { - providerName: displayName, - }) - } - aria-label="Copy update command" - > - - - } - /> - Copy command - -
- ) : null} -
-
-
+ {versionCodeNode || hasProviderAdvisoryIcons ? ( + + {versionCodeNode} + {compatibilityAdvisory ? ( + + + + + + } + /> + +
+
+

+ {compatibilityAdvisory.title} +

+

+ {compatibilityAdvisory.detail} +

+
+ {onRunCompatibilityUpdate ? ( + + ) : null} + {onRunCompatibilityUpdate && compatibilityUpdateCommand ? ( +
+ + or, update manually using + +
+ ) : null} + {compatibilityUpdateCommand ? ( +
+ + {compatibilityUpdateCommand} + + + + copyToClipboard(compatibilityUpdateCommand, { + providerName: displayName, + }) + } + aria-label="Copy compatibility update command" + > + + + } + /> + Copy command + +
+ ) : null} +
+
+
+
+ ) : null} + {versionAdvisory ? ( + + + + + + } + /> + +
+
+

+ Update available +

+

+ {versionAdvisory.detail} +

+
+ {onRunUpdate ? ( + + ) : null} + {onRunUpdate && updateCommand ? ( +
+ + or, update manually using + +
+ ) : null} + {updateCommand ? ( +
+ + {updateCommand} + + + + copyToClipboard(updateCommand, { + providerName: displayName, + }) + } + aria-label="Copy update command" + > + + + } + /> + Copy command + +
+ ) : null} +
+
+
+
+ ) : null} +
) : null} {titleTailNode}
diff --git a/apps/web/src/components/settings/SettingsPanels.browser.tsx b/apps/web/src/components/settings/SettingsPanels.browser.tsx index 4abefc5425..1b800efd64 100644 --- a/apps/web/src/components/settings/SettingsPanels.browser.tsx +++ b/apps/web/src/components/settings/SettingsPanels.browser.tsx @@ -255,7 +255,7 @@ function createOutdatedProvider(driver: string): ServerProvider { latestVersion: "1.1.0", message: "Update available.", checkedAt: "2026-05-04T10:00:00.000Z", - updateCommand: "npm install -g openai/codex@latest", + updateCommand: "npm install -g @openai/codex@latest", canUpdate: true, }, }; @@ -1155,6 +1155,63 @@ describe("GeneralSettingsPanel observability", () => { instanceId: ProviderInstanceId.make("codex"), }); }); + + it("runs targeted compatibility updates from the provider card", async () => { + const updateProvider = vi.fn().mockResolvedValue({ + providers: [], + }); + window.nativeApi = { + persistence: { + getClientSettings: vi.fn().mockResolvedValue(null), + setClientSettings: vi.fn().mockResolvedValue(undefined), + }, + server: { + updateProvider, + }, + } as unknown as LocalApi; + const incompatibleProvider: ServerProvider = { + ...createOutdatedProvider("codex"), + version: "0.128.0", + status: "error", + message: + "This provider harness version 0.128.0 is known to be incompatible with this T3 Code release. Use 0.129.0.", + compatibilityAdvisory: { + status: "broken", + severity: "error", + currentVersion: "0.128.0", + message: + "This provider harness version 0.128.0 is known to be incompatible with this T3 Code release. Use 0.129.0.", + recommendedRange: ">=0.129.0", + recommendedVersion: "0.129.0", + ranges: [{ status: "broken", range: "<0.129.0" }], + }, + }; + + setServerConfigSnapshot({ + ...createBaseServerConfig(), + providers: [incompatibleProvider], + }); + + mounted = await render( + + + , + ); + + await page + .getByRole("button", { name: "Incompatible provider version — view details" }) + .click(); + await expect + .element(page.getByText("npm install -g @openai/codex@0.129.0")) + .toBeInTheDocument(); + await page.getByRole("button", { name: "Update now" }).click(); + + expect(updateProvider).toHaveBeenCalledWith({ + provider: ProviderDriverKind.make("codex"), + instanceId: ProviderInstanceId.make("codex"), + targetVersion: "0.129.0", + }); + }); }); describe("SourceControlSettingsPanel discovery states", () => { diff --git a/apps/web/src/components/settings/SettingsPanels.tsx b/apps/web/src/components/settings/SettingsPanels.tsx index 505be5c73f..2de02fe1ba 100644 --- a/apps/web/src/components/settings/SettingsPanels.tsx +++ b/apps/web/src/components/settings/SettingsPanels.tsx @@ -10,6 +10,7 @@ import { type ProviderInstanceConfig, type ProviderInstanceId, type ScopedThreadRef, + type ServerProvider, } from "@t3tools/contracts"; import { scopeThreadRef } from "@t3tools/client-runtime"; import { DEFAULT_UNIFIED_SETTINGS } from "@t3tools/contracts/settings"; @@ -63,6 +64,10 @@ import { type ProviderUpdateCandidate, } from "../ProviderUpdateLaunchNotification.logic"; import { ProviderInstanceCard } from "./ProviderInstanceCard"; +import { + canRunProviderCompatibilityUpdate, + getProviderCompatibilityUpdateCommand, +} from "./providerStatus"; import { DRIVER_OPTIONS, getDriverOption } from "./providerDriverMeta"; import { buildProviderInstanceUpdatePatch, @@ -1010,6 +1015,55 @@ export function ProviderSettingsPanel() { } }, []); + const runProviderCompatibilityUpdate = useCallback(async (provider: ServerProvider) => { + const targetVersion = provider.compatibilityAdvisory?.recommendedVersion ?? null; + if (!targetVersion) { + return; + } + + let started = false; + setUpdatingProviderDrivers((previous) => { + if (previous.has(provider.driver)) { + return previous; + } + started = true; + const next = new Set(previous); + next.add(provider.driver); + return next; + }); + if (!started) { + return; + } + + try { + await ensureLocalApi().server.updateProvider({ + provider: provider.driver, + instanceId: provider.instanceId, + targetVersion, + }); + } catch (error) { + toastManager.add( + stackedThreadToast({ + type: "error", + title: `Could not update ${PROVIDER_DISPLAY_NAMES[provider.driver] ?? provider.driver}`, + description: + error instanceof Error + ? error.message + : "The provider update command could not be started.", + }), + ); + } finally { + setUpdatingProviderDrivers((previous) => { + if (!previous.has(provider.driver)) { + return previous; + } + const next = new Set(previous); + next.delete(provider.driver); + return next; + }); + } + }, []); + interface InstanceRow { readonly instanceId: ProviderInstanceId; readonly instance: ProviderInstanceConfig; @@ -1245,6 +1299,22 @@ export function ProviderSettingsPanel() { updateCandidate !== undefined && canOneClickUpdateProviderCandidate(updateCandidate, serverProviders) && !updatingProviderDrivers.has(updateCandidate.driver); + const compatibilityUpdateCommand = getProviderCompatibilityUpdateCommand(liveProvider); + const showInlineCompatibilityUpdateButton = + canRunProviderCompatibilityUpdate(liveProvider) && + compatibilityUpdateCommand !== null && + Boolean(liveProvider?.compatibilityAdvisory?.recommendedVersion); + const isCompatibilityUpdateRunning = + liveProvider !== undefined && + (updatingProviderDrivers.has(liveProvider.driver) || + serverProviders.some( + (provider) => + provider.driver === liveProvider.driver && isProviderUpdateActive(provider), + )); + const canRunInlineCompatibilityUpdate = + showInlineCompatibilityUpdateButton && + liveProvider !== undefined && + !updatingProviderDrivers.has(liveProvider.driver); const modelPreferences = settings.providerModelPreferences?.[row.instanceId] ?? { hiddenModels: [], modelOrder: [], @@ -1318,6 +1388,19 @@ export function ProviderSettingsPanel() { : undefined } isUpdating={showInlineUpdateButton ? isDriverUpdateRunning : undefined} + onRunCompatibilityUpdate={ + showInlineCompatibilityUpdateButton && liveProvider + ? () => { + if (!canRunInlineCompatibilityUpdate) { + return; + } + void runProviderCompatibilityUpdate(liveProvider); + } + : undefined + } + isCompatibilityUpdating={ + showInlineCompatibilityUpdateButton ? isCompatibilityUpdateRunning : undefined + } /> ); })} diff --git a/apps/web/src/components/settings/providerStatus.test.ts b/apps/web/src/components/settings/providerStatus.test.ts index 203e6251e3..75af979c9e 100644 --- a/apps/web/src/components/settings/providerStatus.test.ts +++ b/apps/web/src/components/settings/providerStatus.test.ts @@ -1,6 +1,9 @@ import { describe, expect, it } from "vitest"; -import { getProviderCompatibilityAdvisoryPresentation } from "./providerStatus"; +import { + getProviderCompatibilityAdvisoryPresentation, + getProviderCompatibilityUpdateCommand, +} from "./providerStatus"; describe("getProviderCompatibilityAdvisoryPresentation", () => { it("hides supported compatibility advisories", () => { @@ -29,7 +32,34 @@ describe("getProviderCompatibilityAdvisoryPresentation", () => { ).toEqual({ title: "Incompatible provider version", detail: "Known incompatible.", + updateCommand: null, + canUpdate: false, emphasis: "strong", }); }); + + it("derives targeted compatibility update commands from package install commands", () => { + expect( + getProviderCompatibilityUpdateCommand({ + compatibilityAdvisory: { + status: "broken", + severity: "error", + currentVersion: "0.128.0", + message: "Known incompatible.", + recommendedRange: ">=0.129.0", + recommendedVersion: "0.129.0", + ranges: [], + }, + versionAdvisory: { + status: "behind_latest", + currentVersion: "0.128.0", + latestVersion: "0.130.0", + checkedAt: "2026-05-13T00:00:00.000Z", + message: "Update available.", + updateCommand: "vp i -g @openai/codex", + canUpdate: true, + }, + }), + ).toBe("vp i -g @openai/codex@0.129.0"); + }); }); diff --git a/apps/web/src/components/settings/providerStatus.ts b/apps/web/src/components/settings/providerStatus.ts index 915cb702e3..bef3d14e5b 100644 --- a/apps/web/src/components/settings/providerStatus.ts +++ b/apps/web/src/components/settings/providerStatus.ts @@ -120,11 +120,65 @@ export function getProviderVersionAdvisoryPresentation( }; } +function makeTargetedUpdateCommand(input: { + readonly updateCommand: string | null | undefined; + readonly recommendedVersion: string | null | undefined; +}): string | null { + if (!input.updateCommand || !input.recommendedVersion) { + return null; + } + if (!input.updateCommand.includes("@latest")) { + const packageNameMatch = input.updateCommand.match( + /(?:^|\s)(@[^\s]+\/[^\s@]+|[^\s@]+)(?=\s*$)/, + ); + if (!packageNameMatch?.[1]) { + return null; + } + return input.updateCommand.replace( + packageNameMatch[1], + `${packageNameMatch[1]}@${input.recommendedVersion}`, + ); + } + return input.updateCommand.replace("@latest", `@${input.recommendedVersion}`); +} + +export function getProviderCompatibilityUpdateCommand( + provider: Pick | null | undefined, +): string | null { + const compatibilityAdvisory = provider?.compatibilityAdvisory; + if (!compatibilityAdvisory || compatibilityAdvisory.status === "supported") { + return null; + } + return ( + compatibilityAdvisory.updateCommand ?? + makeTargetedUpdateCommand({ + updateCommand: provider.versionAdvisory?.updateCommand, + recommendedVersion: compatibilityAdvisory.recommendedVersion, + }) + ); +} + +export function canRunProviderCompatibilityUpdate( + provider: Pick | null | undefined, +): boolean { + const compatibilityAdvisory = provider?.compatibilityAdvisory; + if (!compatibilityAdvisory || compatibilityAdvisory.status === "supported") { + return false; + } + return ( + compatibilityAdvisory.canUpdate === true || + (provider?.versionAdvisory?.canUpdate === true && + getProviderCompatibilityUpdateCommand(provider) !== null) + ); +} + export function getProviderCompatibilityAdvisoryPresentation( advisory: ServerProviderCompatibilityAdvisory | undefined, ): { readonly title: string; readonly detail: string; + readonly updateCommand: string | null; + readonly canUpdate: boolean; readonly emphasis: "normal" | "strong"; } | null { if (!advisory || advisory.status === "supported") { @@ -142,6 +196,8 @@ export function getProviderCompatibilityAdvisoryPresentation( title: advisory.status === "broken" ? "Incompatible provider version" : "Provider version warning", detail: advisory.message ?? fallback, + updateCommand: advisory.updateCommand ?? null, + canUpdate: advisory.canUpdate === true, emphasis: advisory.severity === "error" ? "strong" : "normal", }; } diff --git a/packages/contracts/src/server.ts b/packages/contracts/src/server.ts index 93e9630562..32fc4ec619 100644 --- a/packages/contracts/src/server.ts +++ b/packages/contracts/src/server.ts @@ -160,6 +160,8 @@ export const ServerProviderCompatibilityAdvisory = Schema.Struct({ message: Schema.NullOr(TrimmedNonEmptyString), recommendedRange: Schema.NullOr(TrimmedNonEmptyString), recommendedVersion: Schema.optionalKey(Schema.NullOr(TrimmedNonEmptyString)), + updateCommand: Schema.optionalKey(Schema.NullOr(TrimmedNonEmptyString)), + canUpdate: Schema.optionalKey(Schema.Boolean), ranges: Schema.Array(ServerProviderCompatibilityRange).pipe( Schema.withDecodingDefault(Effect.succeed([])), ), @@ -523,6 +525,7 @@ export type ServerProviderUpdatedPayload = typeof ServerProviderUpdatedPayload.T export const ServerProviderUpdateInput = Schema.Struct({ provider: ProviderDriverKind, instanceId: Schema.optionalKey(ProviderInstanceId), + targetVersion: Schema.optionalKey(TrimmedNonEmptyString), }); export type ServerProviderUpdateInput = typeof ServerProviderUpdateInput.Type; diff --git a/provider-compatibility.v1.json b/provider-compatibility.v1.json index 1d98408393..883b8f74a0 100644 --- a/provider-compatibility.v1.json +++ b/provider-compatibility.v1.json @@ -2,7 +2,7 @@ "version": 1, "policies": [ { - "t3CodeRange": ">=0.0.24", + "t3CodeRange": ">=0.0.0", "driver": "codex", "recommendedRange": ">=0.129.0", "recommendedVersion": "0.129.0", @@ -20,7 +20,7 @@ ] }, { - "t3CodeRange": ">=0.0.24", + "t3CodeRange": ">=0.0.0", "driver": "claudeAgent", "recommendedRange": ">=0.2.111", "recommendedVersion": "0.2.111", @@ -33,7 +33,7 @@ ] }, { - "t3CodeRange": ">=0.0.24", + "t3CodeRange": ">=0.0.0", "driver": "opencode", "recommendedRange": ">=1.14.19", "recommendedVersion": "1.14.19", @@ -51,7 +51,7 @@ ] }, { - "t3CodeRange": ">=0.0.24", + "t3CodeRange": ">=0.0.0", "driver": "cursor", "recommendedRange": ">=2026.05.09", "recommendedVersion": "2026.05.09",