Skip to content

Commit 79e18d4

Browse files
committed
fix(server): tell users how to update an install T3 cannot update
A provider install that no package manager provably owns (the Codex CLI inside ChatGPT.app, a hand-placed binary) gets no Update button or command, but its popover said "Install the update now or review provider settings." and the launch notice said it "can be updated from provider settings." The popover now names the version and the executable T3 Code runs, and the launch notice says to update it with the app or tool that installed it.
1 parent d2c9281 commit 79e18d4

5 files changed

Lines changed: 119 additions & 19 deletions

File tree

‎apps/server/src/provider/providerMaintenance.test.ts‎

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

217-
it("keeps the manual update hint when the install is behind but unowned", () => {
217+
it("names the install to update when it is behind but unowned", () => {
218218
expect(
219219
createProviderVersionAdvisory({
220220
driver: driver("packageTool"),
221221
currentVersion: "2.1.110",
222222
latestVersion: "2.1.117",
223-
maintenanceCapabilities: manualPackageTool,
223+
maintenanceCapabilities: {
224+
...manualPackageTool,
225+
installPath: "/Applications/Tool.app/Contents/Resources/bin/package-tool",
226+
},
224227
}),
225228
).toMatchObject({
226229
status: "behind_latest",
227230
latestVersion: "2.1.117",
228231
updateCommand: null,
229232
canUpdate: false,
233+
message:
234+
"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.",
235+
});
236+
});
237+
238+
it("offers the update when an owned install is behind", () => {
239+
expect(
240+
createProviderVersionAdvisory({
241+
driver: driver("packageTool"),
242+
currentVersion: "2.1.110",
243+
latestVersion: "2.1.117",
244+
maintenanceCapabilities: makeProviderMaintenanceCapabilities({
245+
provider: driver("packageTool"),
246+
packageName: "@example/package-tool",
247+
updateExecutable: "npm",
248+
updateArgs: ["install", "-g", "@example/package-tool@latest"],
249+
updateLockKey: "npm-global:/usr/local",
250+
}),
251+
}),
252+
).toMatchObject({
253+
status: "behind_latest",
254+
canUpdate: true,
230255
message: "Install the update now or review provider settings.",
231256
});
232257
});
@@ -738,7 +763,10 @@ it.layer(NodeServices.layer)("providerMaintenance", (it) => {
738763
),
739764
);
740765

741-
expect(capabilities).toEqual(manualPackageTool);
766+
expect(capabilities).toEqual({
767+
...manualPackageTool,
768+
installPath: NodeFS.realpathSync(kegBinary),
769+
});
742770
}),
743771
);
744772

@@ -765,7 +793,10 @@ it.layer(NodeServices.layer)("providerMaintenance", (it) => {
765793
},
766794
).pipe(Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, noSpawn));
767795

768-
expect(capabilities).toEqual(manualPackageTool);
796+
expect(capabilities).toEqual({
797+
...manualPackageTool,
798+
installPath: NodeFS.realpathSync(customPath),
799+
});
769800
}),
770801
);
771802

‎apps/server/src/provider/providerMaintenance.ts‎

Lines changed: 40 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,12 @@ export interface ProviderMaintenanceCapabilities {
6565
* installer was asked and did not know.
6666
*/
6767
readonly latestVersion?: string | null;
68+
/**
69+
* The executable T3 Code runs, symlinks followed, when no update command is
70+
* proven for it. The version advisory names it so the user knows which
71+
* install to update.
72+
*/
73+
readonly installPath?: string;
6874
}
6975

7076
export interface ProviderMaintenanceCommandAction {
@@ -216,14 +222,18 @@ export function makeTargetedProviderUpdateAction(
216222
export function makeManualOnlyProviderMaintenanceCapabilities(input: {
217223
readonly provider: ProviderDriverKind;
218224
readonly packageName: string | null;
225+
readonly installPath?: string;
219226
}): ProviderMaintenanceCapabilities {
220-
return makeProviderMaintenanceCapabilities({
221-
provider: input.provider,
222-
packageName: input.packageName,
223-
updateExecutable: null,
224-
updateArgs: [],
225-
updateLockKey: null,
226-
});
227+
return {
228+
...makeProviderMaintenanceCapabilities({
229+
provider: input.provider,
230+
packageName: input.packageName,
231+
updateExecutable: null,
232+
updateArgs: [],
233+
updateLockKey: null,
234+
}),
235+
...(input.installPath ? { installPath: input.installPath } : {}),
236+
};
227237
}
228238

229239
export function normalizeCommandPath(commandPath: string): string {
@@ -381,13 +391,17 @@ export const resolvePackageManagedProviderMaintenance = Effect.fn(
381391
definition: PackageManagedProviderMaintenanceDefinition,
382392
context: ProviderMaintenanceResolutionContext | null,
383393
) {
394+
if (!context) {
395+
return makeManualOnlyProviderMaintenanceCapabilities({
396+
provider: definition.provider,
397+
packageName: definition.npmPackageName,
398+
});
399+
}
384400
const manual = makeManualOnlyProviderMaintenanceCapabilities({
385401
provider: definition.provider,
386402
packageName: definition.npmPackageName,
403+
installPath: context.realCommandPath,
387404
});
388-
if (!context) {
389-
return manual;
390-
}
391405
const commandPaths = [context.resolvedCommandPath, context.realCommandPath];
392406
const packageName = definition.npmPackageName;
393407

@@ -614,9 +628,20 @@ export const makeCachedProviderMaintenanceResolution = Effect.fn(
614628
options?.fresh ? invalidate.pipe(Effect.andThen(cached)) : cached;
615629
});
616630

631+
/**
632+
* An install T3 Code cannot update gets no Update button or command, so its
633+
* message names the version and the executable instead.
634+
*/
635+
function manualUpdateMessage(latestVersion: string, installPath: string | undefined): string {
636+
return installPath
637+
? `Version ${latestVersion} is out. T3 Code runs ${installPath}; update it with the app or tool that installed it.`
638+
: `Version ${latestVersion} is out. Update it with the app or tool that installed it.`;
639+
}
640+
617641
function deriveVersionAdvisory(input: {
618642
readonly currentVersion: string | null;
619643
readonly latestVersion: string | null;
644+
readonly capabilities: ProviderMaintenanceCapabilities;
620645
}): Pick<ServerProviderVersionAdvisory, "status" | "message"> {
621646
if (!input.currentVersion) {
622647
return { status: "unknown", message: null };
@@ -627,7 +652,10 @@ function deriveVersionAdvisory(input: {
627652
if (compareSemverVersions(input.currentVersion, input.latestVersion) < 0) {
628653
return {
629654
status: "behind_latest",
630-
message: PROVIDER_UPDATE_ACTION_TOAST_MESSAGE,
655+
message:
656+
input.capabilities.update === null
657+
? manualUpdateMessage(input.latestVersion, input.capabilities.installPath)
658+
: PROVIDER_UPDATE_ACTION_TOAST_MESSAGE,
631659
};
632660
}
633661
return { status: "current", message: null };
@@ -646,6 +674,7 @@ export function createProviderVersionAdvisory(input: {
646674
const advisory = deriveVersionAdvisory({
647675
currentVersion: input.currentVersion,
648676
latestVersion,
677+
capabilities,
649678
});
650679

651680
return {

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

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

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

305+
it("sends installs the server cannot update to the tool that installed them", () => {
306+
const manual = { canUpdate: false, updateCommand: null };
307+
expect(
308+
getProviderUpdateInitialToastView({
309+
updateProviders: [updateCandidate({ driver: driver("codex"), ...manual })],
310+
oneClickProviders: [],
311+
}).description,
312+
).toBe("Update Codex with the app or tool that installed it.");
313+
expect(
314+
getProviderUpdateInitialToastView({
315+
updateProviders: [
316+
updateCandidate({ driver: driver("codex"), ...manual }),
317+
updateCandidate({ driver: driver("cursor") }),
318+
],
319+
oneClickProviders: [],
320+
}).description,
321+
).toBe(
322+
"Cursor can be updated from provider settings. Update Codex with the app or tool that installed it.",
323+
);
324+
});
325+
305326
it("uses server update state for running progress", () => {
306327
const view = getProviderUpdateProgressToastView({
307328
providers: [

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

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

237+
/**
238+
* Provider settings has an Update button only for installs the server can
239+
* update. The rest are updated by the app or tool that installed them.
240+
*/
241+
function describeUpdatesWithoutOneClick(providers: ReadonlyArray<ProviderUpdateCandidate>): string {
242+
const fromSettings = providers.filter((provider) => provider.versionAdvisory.canUpdate);
243+
const manual = providers.filter((provider) => !provider.versionAdvisory.canUpdate);
244+
return [
245+
fromSettings.length > 0
246+
? `${formatProviderList(fromSettings)} can be updated from provider settings.`
247+
: null,
248+
manual.length > 0
249+
? `Update ${formatProviderList(manual)} with the app or tool that installed ${manual.length === 1 ? "it" : "them"}.`
250+
: null,
251+
]
252+
.filter((sentence) => sentence !== null)
253+
.join(" ");
254+
}
255+
237256
export function getProviderUpdateInitialToastView(input: {
238257
readonly updateProviders: ReadonlyArray<ProviderUpdateCandidate>;
239258
readonly oneClickProviders: ReadonlyArray<ProviderUpdateCandidate>;
@@ -245,7 +264,7 @@ export function getProviderUpdateInitialToastView(input: {
245264
description:
246265
input.oneClickProviders.length > 0
247266
? "Install the update now or review provider settings."
248-
: `${formatProviderList(input.updateProviders)} can be updated from provider settings.`,
267+
: describeUpdatesWithoutOneClick(input.updateProviders),
249268
};
250269
}
251270

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -780,7 +780,7 @@ export function ProviderInstanceCard({
780780
</p>
781781
<p
782782
className={cn(
783-
"text-xs leading-snug",
783+
"text-xs leading-snug [overflow-wrap:anywhere]",
784784
versionAdvisory.emphasis === "strong"
785785
? "text-warning"
786786
: "text-muted-foreground",

0 commit comments

Comments
 (0)