diff --git a/packages/app/e2e/browser/plugin-management.spec.ts b/packages/app/e2e/browser/plugin-management.spec.ts index 375c88d585..cfa6d83c75 100644 --- a/packages/app/e2e/browser/plugin-management.spec.ts +++ b/packages/app/e2e/browser/plugin-management.spec.ts @@ -2,7 +2,7 @@ import { existsSync } from "node:fs"; import overviewCorpus from "../../../protocol/tests/fixtures/plugin-overview.json"; import { pluginRequirements } from "../support/helpers/plugin-fixture"; import { execFileSync } from "node:child_process"; -import { mkdir, mkdtemp, rename, rm, writeFile } from "node:fs/promises"; +import { mkdir, mkdtemp, rm, writeFile } from "node:fs/promises"; import { tmpdir } from "node:os"; import path from "node:path"; import { pathToFileURL } from "node:url"; @@ -678,21 +678,21 @@ async function updateGitPlugin(page: Page, repository: string) { await expectPluginOn(page, "git-e2e-plugin"); } -/** An update that fails on the plugin's page says why there. */ +/** An update that fails on the plugin's page says why there, and offers Retry. */ async function failUpdateFromPluginPage(page: Page, repository: string) { await publishGitPluginChange(repository, "Git plugin v3"); await page.reload(); const update = page.getByTestId("plugin-update").filter({ visible: true }); await expect(update).toHaveText("Update"); - // The source disappears after the check, so applying the update cannot fetch it. - const moved = `${repository}-moved`; - await rename(repository, moved); - try { - await update.click(); - await expect(page.getByText(/Could not read from remote repository/)).toBeVisible(); - } finally { - await rename(moved, repository); - } + // Rewriting the commit the page checked leaves its update pointing at a commit the remote no + // longer serves. The next check offers the rewritten commit. + execFileSync("git", ["commit", "--amend", "-m", "Git plugin v3, amended"], { + cwd: repository, + stdio: "ignore", + }); + await update.click(); + await expect(update).toHaveText("Retry"); + await expect(page.getByText(/Git command failed/)).toBeVisible(); } async function expectCompactPluginMenuFits(page: Page, testInfo: TestInfo) { diff --git a/packages/app/src/plugins/gallery/actions.ts b/packages/app/src/plugins/gallery/actions.ts index 9a05a9f443..0647d85720 100644 --- a/packages/app/src/plugins/gallery/actions.ts +++ b/packages/app/src/plugins/gallery/actions.ts @@ -7,6 +7,7 @@ import { useHostRuntimeClient } from "@/runtime/host-runtime"; import { pluginDisplayName, pluginListQueryKey } from "@/plugins/plugin-list"; import { confirmDialog } from "@/utils/confirm-dialog"; import { pluginErrorText } from "./error-text"; +import { dismissFailedOperation } from "./operations"; export type PluginAction = "enable" | "disable" | "reload" | "remove"; @@ -51,6 +52,8 @@ export function usePluginActions(serverId: string) { try { if (action === "remove") { await client.removePlugin(plugin.id); + // A failed update belonged to this installation, not to a later one with the same ID. + dismissFailedOperation(serverId, plugin.id); queryClient.setQueryData(pluginListQueryKey(serverId), (plugins) => plugins?.filter((candidate) => candidate.id !== plugin.id), ); diff --git a/packages/app/src/plugins/gallery/plugin-page.tsx b/packages/app/src/plugins/gallery/plugin-page.tsx index dacba579b4..0e83ed5e49 100644 --- a/packages/app/src/plugins/gallery/plugin-page.tsx +++ b/packages/app/src/plugins/gallery/plugin-page.tsx @@ -6,7 +6,7 @@ import { useTranslation } from "react-i18next"; import { Image, ScrollView, Text, View } from "react-native"; import { AttachmentLightbox, type ImageLightboxSource } from "@/components/attachment-lightbox"; import { StyleSheet } from "react-native-unistyles"; -import type { PluginListItem } from "@getpaseo/protocol/messages"; +import type { PluginListItem, PluginUpdatePreview } from "@getpaseo/protocol/messages"; import { formatPluginInstallation } from "@getpaseo/protocol/plugin-source-reference"; import type { PluginListingIndex, @@ -270,7 +270,7 @@ interface PluginPageModel { authorAvatar?: string; /** Why the plugin failed to load, or why its install failed. */ error?: string; - /** Why the last update failed. The installed version keeps running. */ + /** Why the last update failed, while the update is still offered. The installed version keeps running. */ updateError?: string; /** The plugin's own settings screen, shown inline. */ screenId?: string; @@ -300,6 +300,7 @@ function usePluginPageModel({ const installedPlugin = useInstalledPlugin(serverId, pluginId); const evaluationError = usePluginEvaluationError(serverId, pluginId); const pluginOperation = usePluginOperation(serverId, pluginId); + const updates = usePluginUpdates(serverId); const text = listing ? listingText(listing, i18n.language) : undefined; const requestedScreen = subject.kind === "installed" ? subject.screenId : undefined; return { @@ -310,7 +311,7 @@ function usePluginPageModel({ : installedMetaLine(plugin), authorAvatar: listing && listingAuthorAvatar(listing), error: plugin ? (evaluationError ?? plugin.error) : failedError(installOperation), - updateError: failedUpdateError(pluginOperation), + updateError: failedUpdateError(pluginOperation, updates.data, pluginId), screenId: plugin ? (requestedScreen ?? installedPlugin?.settingsScreens[0]?.id) : undefined, overview: detail && listingOverview(detail, i18n.language), }; @@ -341,8 +342,15 @@ function failedError(operation: PluginOperation | undefined): string | undefined return operation?.status === "failed" ? operation.error : undefined; } -function failedUpdateError(operation: PluginOperation | undefined): string | undefined { - return operation?.kind === "update" ? failedError(operation) : undefined; +/** Shown with the Update button it belongs to, as on the Installed tab's Updates row. */ +function failedUpdateError( + operation: PluginOperation | undefined, + updates: PluginUpdatePreview[] | undefined, + pluginId: string, +): string | undefined { + if (operation?.kind !== "update" || !updates?.some((preview) => preview.id === pluginId)) + return undefined; + return failedError(operation); } function HeaderControl({