Skip to content

Commit 96d354a

Browse files
authored
fix(server): tell users how to update an install T3 cannot update (pingdotgg#18110)
1 parent 24c71eb commit 96d354a

6 files changed

Lines changed: 140 additions & 25 deletions

File tree

‎apps/web/src/components/ProviderUpdateLaunchNotification.logic.test.ts‎

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,15 +294,45 @@ describe("provider update launch notification logic", () => {
294294
it("describes settings-only updates without one-click support", () => {
295295
const view = getProviderUpdateInitialToastView({
296296
updateProviders: [
297-
updateCandidate({ driver: driver("codex"), canUpdate: false }),
298-
updateCandidate({ driver: driver("cursor"), canUpdate: false }),
297+
updateCandidate({ driver: driver("codex") }),
298+
updateCandidate({ driver: driver("cursor") }),
299299
],
300300
oneClickProviders: [],
301301
});
302302

303303
expect(view.description).toBe("Codex and Cursor can be updated from provider settings.");
304304
});
305305

306+
it("sends installs the server cannot update to the tool that installed them", () => {
307+
const manual = { canUpdate: false, updateCommand: null };
308+
expect(
309+
getProviderUpdateInitialToastView({
310+
updateProviders: [updateCandidate({ driver: driver("codex"), ...manual })],
311+
oneClickProviders: [],
312+
}).description,
313+
).toBe("Update Codex with the app or tool that installed it.");
314+
expect(
315+
getProviderUpdateInitialToastView({
316+
updateProviders: [
317+
updateCandidate({ driver: driver("codex"), ...manual }),
318+
updateCandidate({ driver: driver("cursor") }),
319+
],
320+
oneClickProviders: [],
321+
}).description,
322+
).toBe(
323+
"Cursor can be updated from provider settings. Update Codex with the app or tool that installed it.",
324+
);
325+
const oneClick = updateCandidate({ driver: driver("claudeAgent") });
326+
expect(
327+
getProviderUpdateInitialToastView({
328+
updateProviders: [oneClick, updateCandidate({ driver: driver("codex"), ...manual })],
329+
oneClickProviders: [oneClick],
330+
}).description,
331+
).toBe(
332+
"Install the update now or review provider settings. Update Codex with the app or tool that installed it.",
333+
);
334+
});
335+
306336
it("uses server update state for running progress", () => {
307337
const view = getProviderUpdateProgressToastView({
308338
providers: [

‎apps/web/src/components/ProviderUpdateLaunchNotification.logic.ts‎

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,33 @@ function formatProviderList(providers: ReadonlyArray<Pick<ServerProvider, "drive
234234
return `${names.slice(0, -1).join(", ")}, and ${names[names.length - 1]}`;
235235
}
236236

237+
/**
238+
* Install and provider settings reach only installs the server can update.
239+
* The rest are updated by the app or tool that installed them, so they get
240+
* their own sentence whatever else the notice offers.
241+
*/
242+
function describeInitialUpdates(input: {
243+
readonly updateProviders: ReadonlyArray<ProviderUpdateCandidate>;
244+
readonly oneClickProviders: ReadonlyArray<ProviderUpdateCandidate>;
245+
}): string {
246+
const fromSettings = input.updateProviders.filter(
247+
(provider) => provider.versionAdvisory.canUpdate,
248+
);
249+
const manual = input.updateProviders.filter((provider) => !provider.versionAdvisory.canUpdate);
250+
return [
251+
input.oneClickProviders.length > 0
252+
? "Install the update now or review provider settings."
253+
: fromSettings.length > 0
254+
? `${formatProviderList(fromSettings)} can be updated from provider settings.`
255+
: null,
256+
manual.length > 0
257+
? `Update ${formatProviderList(manual)} with the app or tool that installed ${manual.length === 1 ? "it" : "them"}.`
258+
: null,
259+
]
260+
.filter((sentence) => sentence !== null)
261+
.join(" ");
262+
}
263+
237264
export function getProviderUpdateInitialToastView(input: {
238265
readonly updateProviders: ReadonlyArray<ProviderUpdateCandidate>;
239266
readonly oneClickProviders: ReadonlyArray<ProviderUpdateCandidate>;
@@ -242,10 +269,7 @@ export function getProviderUpdateInitialToastView(input: {
242269
phase: "initial",
243270
type: "warning",
244271
title: getProviderUpdateInitialToastTitle(input.updateProviders),
245-
description:
246-
input.oneClickProviders.length > 0
247-
? "Install the update now or review provider settings."
248-
: `${formatProviderList(input.updateProviders)} can be updated from provider settings.`,
272+
description: describeInitialUpdates(input),
249273
};
250274
}
251275

‎apps/web/src/components/settings/ProviderInstanceCard.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -907,7 +907,7 @@ export function ProviderInstanceCard({
907907
</p>
908908
<p
909909
className={cn(
910-
"text-xs leading-snug",
910+
"text-xs leading-snug [overflow-wrap:anywhere]",
911911
versionAdvisory.emphasis === "strong" ? "text-warning" : "text-muted-foreground",
912912
)}
913913
>

‎packages/provider-core/src/server/maintenance.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ export interface ProviderMaintenanceCapabilities {
1111
*/
1212
readonly latestVersion?: string | null;
1313
readonly compareVersions?: (current: string, latest: string) => number;
14+
/**
15+
* The executable T3 Code runs, symlinks followed, when no update command is
16+
* proven for it. The version advisory names it so the user knows which
17+
* install to update.
18+
*/
19+
readonly installPath?: string;
1420
}
1521

1622
export interface ProviderMaintenanceCommandAction {

‎packages/provider-core/src/server/maintenanceResolver.test.ts‎

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -208,19 +208,44 @@ it.layer(NodeServices.layer)("providerMaintenance", (it) => {
208208
});
209209
});
210210

211-
it("keeps the manual update hint when the install is behind but unowned", () => {
211+
it("names the install to update when it is behind but unowned", () => {
212212
expect(
213213
createProviderVersionAdvisory({
214214
driver: driver("packageTool"),
215215
currentVersion: "2.1.110",
216216
latestVersion: "2.1.117",
217-
maintenanceCapabilities: manualPackageTool,
217+
maintenanceCapabilities: {
218+
...manualPackageTool,
219+
installPath: "/Applications/Tool.app/Contents/Resources/bin/package-tool",
220+
},
218221
}),
219222
).toMatchObject({
220223
status: "behind_latest",
221224
latestVersion: "2.1.117",
222225
updateCommand: null,
223226
canUpdate: false,
227+
message:
228+
"Version 2.1.117 is out. T3 Code runs /Applications/Tool.app/Contents/Resources/bin/package-tool; update it with the app or tool that installed it.",
229+
});
230+
});
231+
232+
it("offers the update when an owned install is behind", () => {
233+
expect(
234+
createProviderVersionAdvisory({
235+
driver: driver("packageTool"),
236+
currentVersion: "2.1.110",
237+
latestVersion: "2.1.117",
238+
maintenanceCapabilities: makeProviderMaintenanceCapabilities({
239+
provider: driver("packageTool"),
240+
packageName: "@example/package-tool",
241+
updateExecutable: "npm",
242+
updateArgs: ["install", "-g", "@example/package-tool@latest"],
243+
updateLockKey: "npm-global:/usr/local",
244+
}),
245+
}),
246+
).toMatchObject({
247+
status: "behind_latest",
248+
canUpdate: true,
224249
message: "Install the update now or review provider settings.",
225250
});
226251
});
@@ -898,7 +923,10 @@ it.layer(NodeServices.layer)("providerMaintenance", (it) => {
898923
),
899924
);
900925

901-
expect(capabilities).toEqual(manualPackageTool);
926+
expect(capabilities).toEqual({
927+
...manualPackageTool,
928+
installPath: NodeFS.realpathSync(kegBinary),
929+
});
902930
}),
903931
);
904932

@@ -931,7 +959,10 @@ it.layer(NodeServices.layer)("providerMaintenance", (it) => {
931959
},
932960
).pipe(Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, noSpawn));
933961

934-
expect(capabilities).toEqual(manualPackageTool);
962+
expect(capabilities).toEqual({
963+
...manualPackageTool,
964+
installPath: NodeFS.realpathSync(customPath),
965+
});
935966
}),
936967
);
937968

‎packages/provider-core/src/server/maintenanceResolver.ts‎

Lines changed: 38 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -179,14 +179,18 @@ export function makeTargetedProviderUpdateAction(
179179
export function makeManualOnlyProviderMaintenanceCapabilities(input: {
180180
readonly provider: ProviderDriverKind;
181181
readonly packageName: string | null;
182+
readonly installPath?: string;
182183
}): ProviderMaintenanceCapabilities {
183-
return makeProviderMaintenanceCapabilities({
184-
provider: input.provider,
185-
packageName: input.packageName,
186-
updateExecutable: null,
187-
updateArgs: [],
188-
updateLockKey: null,
189-
});
184+
return {
185+
...makeProviderMaintenanceCapabilities({
186+
provider: input.provider,
187+
packageName: input.packageName,
188+
updateExecutable: null,
189+
updateArgs: [],
190+
updateLockKey: null,
191+
}),
192+
...(input.installPath ? { installPath: input.installPath } : {}),
193+
};
190194
}
191195

192196
export function normalizeCommandPath(commandPath: string): string {
@@ -345,13 +349,17 @@ export const resolvePackageManagedProviderMaintenance = Effect.fn(
345349
definition: PackageManagedProviderMaintenanceDefinition,
346350
context: ProviderMaintenanceResolutionContext | null,
347351
) {
352+
if (!context) {
353+
return makeManualOnlyProviderMaintenanceCapabilities({
354+
provider: definition.provider,
355+
packageName: definition.npmPackageName,
356+
});
357+
}
348358
const manual = makeManualOnlyProviderMaintenanceCapabilities({
349359
provider: definition.provider,
350360
packageName: definition.npmPackageName,
361+
installPath: context.realCommandPath,
351362
});
352-
if (!context) {
353-
return manual;
354-
}
355363
const commandPaths = [context.resolvedCommandPath, context.realCommandPath];
356364
const packageName = definition.npmPackageName;
357365
// WinGet owns these files: `claude update` only reports "managed by winget"
@@ -647,10 +655,20 @@ export const makeCachedProviderMaintenanceResolution = Effect.fn(
647655
options?.fresh ? Cache.invalidate(cache, undefined).pipe(Effect.andThen(cached)) : cached;
648656
});
649657

658+
/**
659+
* An install T3 Code cannot update gets no Update button or command, so its
660+
* message names the version and the executable instead.
661+
*/
662+
function manualUpdateMessage(latestVersion: string, installPath: string | undefined): string {
663+
return installPath
664+
? `Version ${latestVersion} is out. T3 Code runs ${installPath}; update it with the app or tool that installed it.`
665+
: `Version ${latestVersion} is out. Update it with the app or tool that installed it.`;
666+
}
667+
650668
function deriveVersionAdvisory(input: {
651669
readonly currentVersion: string | null;
652670
readonly latestVersion: string | null;
653-
readonly compareVersions?: (current: string, latest: string) => number;
671+
readonly capabilities: ProviderMaintenanceCapabilities;
654672
}): Pick<ServerProviderVersionAdvisory, "status" | "message"> {
655673
if (!input.currentVersion) {
656674
return { status: "unknown", message: null };
@@ -659,11 +677,17 @@ function deriveVersionAdvisory(input: {
659677
return { status: "unknown", message: null };
660678
}
661679
if (
662-
(input.compareVersions ?? compareSemverVersions)(input.currentVersion, input.latestVersion) < 0
680+
(input.capabilities.compareVersions ?? compareSemverVersions)(
681+
input.currentVersion,
682+
input.latestVersion,
683+
) < 0
663684
) {
664685
return {
665686
status: "behind_latest",
666-
message: PROVIDER_UPDATE_ACTION_TOAST_MESSAGE,
687+
message:
688+
input.capabilities.update === null
689+
? manualUpdateMessage(input.latestVersion, input.capabilities.installPath)
690+
: PROVIDER_UPDATE_ACTION_TOAST_MESSAGE,
667691
};
668692
}
669693
return { status: "current", message: null };
@@ -682,7 +706,7 @@ export function createProviderVersionAdvisory(input: {
682706
const advisory = deriveVersionAdvisory({
683707
currentVersion: input.currentVersion,
684708
latestVersion,
685-
...(capabilities.compareVersions ? { compareVersions: capabilities.compareVersions } : {}),
709+
capabilities,
686710
});
687711

688712
return {

0 commit comments

Comments
 (0)