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
This commit is contained in:
Julius Marminge committed 2026-05-13 23:21:26 +02:00
1 parent 4beb69255b
commit b924b405fa
22 files changed
+925 -244

No files matched your search

@@ -174,7 +174,12 @@ export const ClaudeDriver: ProviderDriver<ClaudeSettings, ClaudeDriverEnv> = {
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,
@@ -174,7 +174,12 @@ export const CodexDriver: ProviderDriver<CodexSettings, CodexDriverEnv> = {
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,
@@ -153,7 +153,12 @@ export const OpenCodeDriver: ProviderDriver<OpenCodeSettings, OpenCodeDriverEnv>
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,
@@ -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)),
@@ -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/[email protected]",
});
});
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/[email protected]",
});
});
});
@@ -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" });
}),
);
});
@@ -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<typeof RemoteCompatibilityDocument.Type | null>;
readonly enrichSnapshot: (snapshot: ServerProvider) => Effect.Effect<ServerProvider>;
readonly enrichSnapshot: (
snapshot: ServerProvider,
maintenanceCapabilities?: ProviderMaintenanceCapabilities | undefined,
) => Effect.Effect<ServerProvider>;
}
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;
@@ -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/[email protected]",
args: ["i", "-g", "@example/[email protected]"],
});
});
it.effect(
"switches package-managed providers to vite-plus updates when the resolved binary lives in vite-plus global bin",
() =>
@@ -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 {
@@ -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<string> }> = [];
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/[email protected]"],
},
]);
}).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",
() => {
@@ -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<ServerProviderUpdatedPayload, ServerProviderUpdateError>;
}
@@ -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,
+192 -29
View File
@@ -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<string, PendingUserInputDraftAnswer> = {};
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 (
<Popover>
<PopoverTrigger
render={
<Button type="button" size="xs" variant="outline">
Install {recommendedVersion}
</Button>
}
/>
<PopoverPopup side="top" align="end" className="w-84">
<div className="grid gap-3">
<div className="grid gap-0.5">
<p className="text-[13px] font-semibold leading-tight text-foreground">
Install compatible {providerLabel}
</p>
<p className="text-xs leading-snug text-muted-foreground">
Install provider harness version {recommendedVersion}.
</p>
</div>
{canRunUpdate ? (
<Button
type="button"
size="xs"
variant="default"
className="w-full"
disabled={updating}
onClick={onRunUpdate}
>
{updating ? <LoaderIcon className="animate-spin" /> : <DownloadIcon />}
{updating ? "Installing" : "Install now"}
</Button>
) : null}
{updateCommand ? (
<div className="rounded-md border border-border/70 bg-muted/40 px-2 py-1.5">
<code className="block overflow-x-auto whitespace-nowrap font-mono text-[11px] text-foreground [scrollbar-width:none] [&::-webkit-scrollbar]:hidden">
{updateCommand}
</code>
</div>
) : null}
</div>
</PopoverPopup>
</Popover>
);
}
type EnvironmentUnavailableState = {
readonly environmentId: EnvironmentId;
readonly label: string;
@@ -1150,6 +1230,8 @@ export default function ChatView(props: ChatViewProps) {
const [dismissedVersionMismatchKey, setDismissedVersionMismatchKey] = useState<string | null>(
null,
);
const [compatibilityUpdatingProviderId, setCompatibilityUpdatingProviderId] =
useState<ProviderInstanceId | null>(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<ComposerBannerStackItem[]>(() => {
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: <CircleAlertIcon />,
title: `${providerLabel} provider status`,
description: (
<span className="line-clamp-3" title={message}>
{message}
</span>
),
actions:
hasCompatibilityInstallAction && recommendedVersion ? (
<ProviderCompatibilityBannerAction
providerLabel={providerLabel}
recommendedVersion={recommendedVersion}
updateCommand={compatibilityUpdateCommand}
canRunUpdate={canRunCompatibilityUpdate}
updating={compatibilityUpdating}
onRunUpdate={() => 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) {
/>
</header>
{/* Error banner */}
<ProviderStatusBanner status={activeProviderStatus} />
<ThreadErrorBanner
error={activeThread.error}
onDismiss={() => setThreadError(activeThread.id, null)}
+31 -5
View File
@@ -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<ReadonlyArray<ServerProvider["models"][number]>>(
() => 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}
@@ -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"}
</Button>
@@ -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"}
</Button>
@@ -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({
</MenuTrigger>
<MenuPopup align="end" side="top">
<MenuItem
disabled={isSendBusy || isConnecting || isEnvironmentUnavailable}
disabled={
isSendBusy || isConnecting || isEnvironmentUnavailable || isProviderUnavailable
}
onClick={() => 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 ? (
@@ -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 (
<div className="pt-3 mx-auto max-w-3xl">
<Alert variant={status.status === "error" ? "error" : "warning"}>
<CircleAlertIcon />
<AlertTitle>{title}</AlertTitle>
<AlertDescription className="line-clamp-3" title={status.message ?? defaultMessage}>
{status.message ?? defaultMessage}
</AlertDescription>
</Alert>
</div>
);
});
@@ -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 (
<div className="pt-3 mx-auto max-w-3xl">
<div className="mx-auto max-w-3xl pt-3">
<Alert variant="error">
<CircleAlertIcon />
<AlertDescription className="line-clamp-3" title={error}>
@@ -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<string>) => 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({
<div className="min-w-0 flex-1 space-y-1">
<div className="flex min-w-0 flex-wrap items-center gap-2">
{titleHeadNode}
{versionCodeNode}
{compatibilityAdvisory ? (
<Popover>
<PopoverTrigger
render={
<Button
type="button"
size="icon-xs"
variant="ghost"
className={cn(
"size-5 rounded-sm p-0",
compatibilityAdvisory.emphasis === "strong"
? "text-destructive hover:text-destructive"
: "text-warning hover:text-warning",
)}
aria-label={`${compatibilityAdvisory.title} — view details`}
>
<AlertTriangleIcon className="size-3.5" />
</Button>
}
/>
<PopoverPopup side="bottom" align="start" className="w-84">
<div className="grid gap-1">
<p className="text-[13px] font-semibold leading-tight text-foreground">
{compatibilityAdvisory.title}
</p>
<p
className={cn(
"text-xs leading-snug",
compatibilityAdvisory.emphasis === "strong"
? "text-destructive"
: "text-warning",
)}
>
{compatibilityAdvisory.detail}
</p>
</div>
</PopoverPopup>
</Popover>
) : null}
{versionAdvisory ? (
<Popover>
<PopoverTrigger
render={
<Button
type="button"
size="icon-xs"
variant="ghost"
className={cn(
"size-5 rounded-sm p-0",
versionAdvisory.emphasis === "strong"
? "text-warning hover:text-warning"
: "text-primary hover:text-primary",
)}
aria-label="Update available — view details"
>
<ArrowUpCircleIcon className="size-3.5 [animation:bounce_2.4s_ease-in-out_infinite] motion-reduce:animate-none" />
</Button>
}
/>
<PopoverPopup side="bottom" align="start" className="w-84">
<div className="grid gap-3">
<div className="grid gap-0.5">
<p className="text-[13px] font-semibold leading-tight text-foreground">
Update available
</p>
<p
className={cn(
"text-xs leading-snug",
versionAdvisory.emphasis === "strong"
? "text-warning"
: "text-muted-foreground",
)}
>
{versionAdvisory.detail}
</p>
</div>
{onRunUpdate ? (
<Button
type="button"
size="xs"
variant="default"
className="w-full"
disabled={isUpdating}
onClick={onRunUpdate}
>
{isUpdating ? <LoaderIcon className="animate-spin" /> : <DownloadIcon />}
{isUpdating ? "Updating" : "Update now"}
</Button>
) : null}
{onRunUpdate && updateCommand ? (
<div className="flex items-center gap-2 text-[10px] font-medium uppercase tracking-wider text-muted-foreground">
<span aria-hidden className="h-px flex-1 bg-border" />
or, update manually using
<span aria-hidden className="h-px flex-1 bg-border" />
</div>
) : null}
{updateCommand ? (
<div className="flex items-center gap-1 rounded-md border border-border/70 bg-muted/40 py-0.5 pr-0.5 pl-2">
<code className="min-w-0 flex-1 overflow-x-auto whitespace-nowrap font-mono text-[11px] text-foreground [scrollbar-width:none] [&::-webkit-scrollbar]:hidden">
{updateCommand}
</code>
<Tooltip>
<TooltipTrigger
render={
<Button
type="button"
size="icon-xs"
variant="ghost"
className="size-6 shrink-0 rounded-sm p-0 text-muted-foreground hover:text-foreground"
onClick={() =>
copyToClipboard(updateCommand, {
providerName: displayName,
})
}
aria-label="Copy update command"
>
<CopyIcon className="size-3" />
</Button>
}
/>
<TooltipPopup side="top">Copy command</TooltipPopup>
</Tooltip>
</div>
) : null}
</div>
</PopoverPopup>
</Popover>
{versionCodeNode || hasProviderAdvisoryIcons ? (
<span className={ADVISORY_ICON_CLUSTER_CLASS}>
{versionCodeNode}
{compatibilityAdvisory ? (
<span className={ADVISORY_ICON_SLOT_CLASS}>
<Popover>
<PopoverTrigger
render={
<Button
type="button"
size="icon-xs"
variant="ghost"
className={cn(
"size-5 rounded-sm p-0",
compatibilityAdvisory.emphasis === "strong"
? "text-destructive hover:text-destructive"
: "text-warning hover:text-warning",
)}
aria-label={`${compatibilityAdvisory.title} — view details`}
>
<AlertTriangleIcon className="size-3.5" />
</Button>
}
/>
<PopoverPopup side="bottom" align="start" className="w-84">
<div className="grid gap-3">
<div className="grid gap-0.5">
<p className="text-[13px] font-semibold leading-tight text-foreground">
{compatibilityAdvisory.title}
</p>
<p
className={cn(
"text-xs leading-snug",
compatibilityAdvisory.emphasis === "strong"
? "text-destructive"
: "text-warning",
)}
>
{compatibilityAdvisory.detail}
</p>
</div>
{onRunCompatibilityUpdate ? (
<Button
type="button"
size="xs"
variant="default"
className="w-full"
disabled={isCompatibilityUpdating}
onClick={onRunCompatibilityUpdate}
>
{isCompatibilityUpdating ? (
<LoaderIcon className="animate-spin" />
) : (
<DownloadIcon />
)}
{isCompatibilityUpdating ? "Updating" : "Update now"}
</Button>
) : null}
{onRunCompatibilityUpdate && compatibilityUpdateCommand ? (
<div className="flex items-center gap-2 text-[10px] font-medium uppercase tracking-wider text-muted-foreground">
<span aria-hidden className="h-px flex-1 bg-border" />
or, update manually using
<span aria-hidden className="h-px flex-1 bg-border" />
</div>
) : null}
{compatibilityUpdateCommand ? (
<div className="flex items-center gap-1 rounded-md border border-border/70 bg-muted/40 py-0.5 pr-0.5 pl-2">
<code className="min-w-0 flex-1 overflow-x-auto whitespace-nowrap font-mono text-[11px] text-foreground [scrollbar-width:none] [&::-webkit-scrollbar]:hidden">
{compatibilityUpdateCommand}
</code>
<Tooltip>
<TooltipTrigger
render={
<Button
type="button"
size="icon-xs"
variant="ghost"
className="size-6 shrink-0 rounded-sm p-0 text-muted-foreground hover:text-foreground"
onClick={() =>
copyToClipboard(compatibilityUpdateCommand, {
providerName: displayName,
})
}
aria-label="Copy compatibility update command"
>
<CopyIcon className="size-3" />
</Button>
}
/>
<TooltipPopup side="top">Copy command</TooltipPopup>
</Tooltip>
</div>
) : null}
</div>
</PopoverPopup>
</Popover>
</span>
) : null}
{versionAdvisory ? (
<span className={ADVISORY_ICON_SLOT_CLASS}>
<Popover>
<PopoverTrigger
render={
<Button
type="button"
size="icon-xs"
variant="ghost"
className={cn(
"size-5 rounded-sm p-0",
versionAdvisory.emphasis === "strong"
? "text-warning hover:text-warning"
: "text-primary hover:text-primary",
)}
aria-label="Update available — view details"
>
<ArrowUpCircleIcon className="size-3.5 [animation:bounce_2.4s_ease-in-out_infinite] motion-reduce:animate-none" />
</Button>
}
/>
<PopoverPopup side="bottom" align="start" className="w-84">
<div className="grid gap-3">
<div className="grid gap-0.5">
<p className="text-[13px] font-semibold leading-tight text-foreground">
Update available
</p>
<p
className={cn(
"text-xs leading-snug",
versionAdvisory.emphasis === "strong"
? "text-warning"
: "text-muted-foreground",
)}
>
{versionAdvisory.detail}
</p>
</div>
{onRunUpdate ? (
<Button
type="button"
size="xs"
variant="default"
className="w-full"
disabled={isUpdating}
onClick={onRunUpdate}
>
{isUpdating ? (
<LoaderIcon className="animate-spin" />
) : (
<DownloadIcon />
)}
{isUpdating ? "Updating" : "Update now"}
</Button>
) : null}
{onRunUpdate && updateCommand ? (
<div className="flex items-center gap-2 text-[10px] font-medium uppercase tracking-wider text-muted-foreground">
<span aria-hidden className="h-px flex-1 bg-border" />
or, update manually using
<span aria-hidden className="h-px flex-1 bg-border" />
</div>
) : null}
{updateCommand ? (
<div className="flex items-center gap-1 rounded-md border border-border/70 bg-muted/40 py-0.5 pr-0.5 pl-2">
<code className="min-w-0 flex-1 overflow-x-auto whitespace-nowrap font-mono text-[11px] text-foreground [scrollbar-width:none] [&::-webkit-scrollbar]:hidden">
{updateCommand}
</code>
<Tooltip>
<TooltipTrigger
render={
<Button
type="button"
size="icon-xs"
variant="ghost"
className="size-6 shrink-0 rounded-sm p-0 text-muted-foreground hover:text-foreground"
onClick={() =>
copyToClipboard(updateCommand, {
providerName: displayName,
})
}
aria-label="Copy update command"
>
<CopyIcon className="size-3" />
</Button>
}
/>
<TooltipPopup side="top">Copy command</TooltipPopup>
</Tooltip>
</div>
) : null}
</div>
</PopoverPopup>
</Popover>
</span>
) : null}
</span>
) : null}
{titleTailNode}
</div>
@@ -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<LocalApi["server"]["updateProvider"]>().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(
<AppAtomRegistryProvider>
<ProviderSettingsPanel />
</AppAtomRegistryProvider>,
);
await page
.getByRole("button", { name: "Incompatible provider version — view details" })
.click();
await expect
.element(page.getByText("npm install -g @openai/[email protected]"))
.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", () => {
@@ -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
}
/>
);
})}
@@ -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/[email protected]");
});
});
@@ -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<ServerProvider, "compatibilityAdvisory" | "versionAdvisory"> | 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<ServerProvider, "compatibilityAdvisory" | "versionAdvisory"> | 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",
};
}
+3
View File
@@ -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;
+4 -4
View File
@@ -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",