refactor(web): remove obsolete provider update helpers (#10015)
This commit is contained in:
1 parent
93d4dfa206
commit
c9b76e6f5d
2 files changed
-162
No files matched your search
@@ -18,17 +18,14 @@ import {
|
||||
environmentGroupsWithUpdates,
|
||||
firstFailedProviderUpdateMessage,
|
||||
firstRejectedProviderUpdateMessage,
|
||||
firstUnsuccessfulSecondaryProviderOutcome,
|
||||
getProviderUpdateInitialToastView,
|
||||
getProviderUpdateProgressToastView,
|
||||
getProviderUpdateRejectedToastView,
|
||||
getProviderUpdateSidebarPillView,
|
||||
getSingleProviderUpdateProgressToastView,
|
||||
hasOneClickUpdateProviderCandidate,
|
||||
isProviderUpdateCandidate,
|
||||
isTerminalProviderUpdatePhase,
|
||||
localEnvironmentUpdateNotificationKey,
|
||||
parseWslDistroFromInstanceId,
|
||||
providerUpdateNotificationKey,
|
||||
resolveEnvironmentUpdateRowStatus,
|
||||
shouldShowPrimaryProviderUpdateToast,
|
||||
@@ -368,28 +365,6 @@ describe("provider update launch notification logic", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("resolves a single-provider completion view from the returned provider snapshot", () => {
|
||||
const view = getSingleProviderUpdateProgressToastView(
|
||||
provider({
|
||||
driver: driver("codex"),
|
||||
updateState: {
|
||||
status: "failed",
|
||||
startedAt: checkedAt,
|
||||
finishedAt: checkedAt,
|
||||
message: "command failed",
|
||||
output: "stderr",
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
expect(view).toMatchObject({
|
||||
phase: "failed",
|
||||
type: "error",
|
||||
title: "Codex v1.1.0 update failed",
|
||||
description: "command failed",
|
||||
});
|
||||
});
|
||||
|
||||
it("keeps unchanged providers actionable from settings", () => {
|
||||
const view = getProviderUpdateProgressToastView({
|
||||
providers: [
|
||||
@@ -444,31 +419,6 @@ describe("provider update launch notification logic", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("uses the updated version in the single-provider success toast title", () => {
|
||||
const view = getSingleProviderUpdateProgressToastView(
|
||||
provider({
|
||||
driver: driver("codex"),
|
||||
version: "1.1.0",
|
||||
latestVersion: "1.1.0",
|
||||
advisoryStatus: "current",
|
||||
updateState: {
|
||||
status: "succeeded",
|
||||
startedAt: checkedAt,
|
||||
finishedAt: checkedAt,
|
||||
message: "Provider updated.",
|
||||
output: null,
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
expect(view).toMatchObject({
|
||||
phase: "succeeded",
|
||||
type: "success",
|
||||
title: "Codex updated: v1.1.0",
|
||||
description: "New sessions will use the updated provider.",
|
||||
});
|
||||
});
|
||||
|
||||
it("falls back to a rejected RPC message for transport-level failures", () => {
|
||||
const results = [AsyncResult.failure(Cause.die(new Error("WebSocket closed")))];
|
||||
|
||||
@@ -814,39 +764,6 @@ describe("provider update launch notification logic", () => {
|
||||
expect(snapshots).toEqual([primary]);
|
||||
});
|
||||
|
||||
it("flags the first unsuccessful secondary outcome, skipping the primary and successes", () => {
|
||||
const primaryFailed = provider({
|
||||
driver: driver("codex"),
|
||||
updateState: terminalState("failed", "primary boom"),
|
||||
});
|
||||
|
||||
expect(
|
||||
firstUnsuccessfulSecondaryProviderOutcome([
|
||||
fulfilledOutcome(true, primaryFailed),
|
||||
fulfilledOutcome(
|
||||
false,
|
||||
provider({
|
||||
driver: driver("codex"),
|
||||
updateState: terminalState("succeeded", "ok"),
|
||||
}),
|
||||
),
|
||||
]),
|
||||
).toBeNull();
|
||||
|
||||
expect(
|
||||
firstUnsuccessfulSecondaryProviderOutcome([
|
||||
fulfilledOutcome(true, primaryFailed),
|
||||
fulfilledOutcome(
|
||||
false,
|
||||
provider({
|
||||
driver: driver("codex"),
|
||||
updateState: terminalState("failed", "wsl boom"),
|
||||
}),
|
||||
),
|
||||
]),
|
||||
).toMatchObject({ status: "failed", provider: { updateState: { message: "wsl boom" } } });
|
||||
});
|
||||
|
||||
it("treats a rejected dispatch as not contributing a snapshot", () => {
|
||||
const primary = provider({
|
||||
driver: driver("codex"),
|
||||
@@ -995,14 +912,6 @@ describe("provider update launch notification logic", () => {
|
||||
}),
|
||||
).toBe("My Device");
|
||||
});
|
||||
|
||||
it("parses the WSL distro from the backend instance id", () => {
|
||||
expect(parseWslDistroFromInstanceId("wsl:ubuntu")).toBe("ubuntu");
|
||||
expect(parseWslDistroFromInstanceId("wsl:default")).toBeNull();
|
||||
expect(parseWslDistroFromInstanceId("wsl:")).toBeNull();
|
||||
expect(parseWslDistroFromInstanceId("ssh:host")).toBeNull();
|
||||
expect(parseWslDistroFromInstanceId(undefined)).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe("isTerminalProviderUpdatePhase", () => {
|
||||
|
||||
@@ -326,41 +326,6 @@ export function getProviderUpdateProgressToastView(input: {
|
||||
return getProviderUpdateRunningToastView(input.providerCount);
|
||||
}
|
||||
|
||||
export function getSingleProviderUpdateProgressToastView(
|
||||
provider: ServerProvider,
|
||||
): ProviderUpdateToastView {
|
||||
const view = getProviderUpdateProgressToastView({
|
||||
providers: [provider],
|
||||
providerCount: 1,
|
||||
});
|
||||
const providerName = PROVIDER_DISPLAY_NAMES[provider.driver] ?? provider.driver;
|
||||
|
||||
switch (view.phase) {
|
||||
case "running":
|
||||
return {
|
||||
...view,
|
||||
title: `Updating ${providerName}`,
|
||||
};
|
||||
case "failed":
|
||||
return {
|
||||
...view,
|
||||
title: getProviderFailedUpdateTitle(provider),
|
||||
};
|
||||
case "unchanged":
|
||||
return {
|
||||
...view,
|
||||
title: `${providerName} still needs an update`,
|
||||
};
|
||||
case "succeeded":
|
||||
return {
|
||||
...view,
|
||||
title: getProviderUpdatedTitle(provider),
|
||||
};
|
||||
default:
|
||||
return view;
|
||||
}
|
||||
}
|
||||
|
||||
export function collectUpdatedProviderSnapshots(input: {
|
||||
readonly results: ReadonlyArray<
|
||||
AtomCommandResult<{ readonly providers: ReadonlyArray<ServerProvider> }, unknown>
|
||||
@@ -649,42 +614,6 @@ export function collectProviderUpdateOutcomeSnapshots(
|
||||
return [...worstByDriver.values()];
|
||||
}
|
||||
|
||||
/**
|
||||
* The first secondary (non-primary) backend whose update resolved without
|
||||
* succeeding. The primary's own failed/unchanged state is already surfaced
|
||||
* inline in settings, so only secondaries (which have no inline row) need an
|
||||
* explicit callout.
|
||||
*/
|
||||
export function firstUnsuccessfulSecondaryProviderOutcome(
|
||||
results: ReadonlyArray<PromiseSettledResult<LocalProviderUpdateOutcome>>,
|
||||
): { readonly provider: ServerProvider; readonly status: "failed" | "unchanged" } | null {
|
||||
for (const result of results) {
|
||||
if (result.status !== "fulfilled") {
|
||||
continue;
|
||||
}
|
||||
const outcome = result.value;
|
||||
if (outcome.isPrimary || outcome.provider === null) {
|
||||
continue;
|
||||
}
|
||||
const status = outcome.provider.updateState?.status;
|
||||
if (status === "failed" || status === "unchanged") {
|
||||
return { provider: outcome.provider, status };
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
const WSL_INSTANCE_ID_PREFIX = "wsl:";
|
||||
|
||||
/** The distro name from a WSL backend instance id ("wsl:ubuntu" -> "ubuntu"), or null for the default. */
|
||||
export function parseWslDistroFromInstanceId(instanceId: string | undefined): string | null {
|
||||
if (!instanceId || !instanceId.startsWith(WSL_INSTANCE_ID_PREFIX)) {
|
||||
return null;
|
||||
}
|
||||
const distro = instanceId.slice(WSL_INSTANCE_ID_PREFIX.length).trim();
|
||||
return distro.length === 0 || distro === "default" ? null : distro;
|
||||
}
|
||||
|
||||
/**
|
||||
* A human label that distinguishes local environments by platform (so the
|
||||
* popover shows "Windows" / "WSL" rather than the account name twice). WSL is
|
||||
|
||||
Reference in new issue
Block a user