Skip to content

[Bug]: Leaving Appearance lets a cancelled theme download install later #38020

Closed

Description

@StiensWout

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

apps/web

Steps to reproduce

  1. Open the web app, signed in, on the home screen, with a project already added.
  2. Choose Settings.
  3. Choose Appearance.
  4. Choose Add theme.
  5. Point Open VSX at a stand-in that answers a search for Nightfall with one theme that is not installed, and that withholds the theme package until you let the download finish.
  6. Search community themes for nightfall.
  7. Choose Install for Nightfall.
  8. While that package is still downloading, use the browser Back button so Appearance closes.
  9. Let the stand-in finish sending the package.
  10. Choose Settings, then Appearance, and look at the theme library.

Expected behavior

Nightfall is not in the theme library. Leaving Appearance cancelled the download, the same way Cancel does.

Actual behavior

Nightfall is in the theme library.

theme library

failure

Impact

Minor bug or occasional failure. Users navigating away during a slow community theme download can receive a saved theme installation from the dismissed import session.

Version or commit

main at 49c3ab8632. The cause is at apps/web/src/components/settings/ThemeImportDialog.tsx:164.

Environment

The web app in Chromium on Linux x64, a fresh checkout.

Logs or stack traces

expect leaving Appearance to cancel its pending theme installation: expected
Automated repro

Fails in 2 of 2 runs on main: apply the patch with git apply, then run the command.

diff --git a/apps/web/src/components/settings/ThemeImportDialog.browser.test.tsx b/apps/web/src/components/settings/ThemeImportDialog.browser.test.tsx
index 0cde5b8f1f..8711446231 100644
--- a/apps/web/src/components/settings/ThemeImportDialog.browser.test.tsx
+++ b/apps/web/src/components/settings/ThemeImportDialog.browser.test.tsx
@@ -2,7 +2,7 @@ import { StrictMode } from "react";
 import { describe, expect, it, vi } from "vite-plus/test";
 import { page, userEvent } from "vite-plus/test/browser";
 
-import { render } from "../../../test/render";
+import { act, render } from "../../../test/render";
 import {
   CUSTOM_THEMES_STORAGE_KEY,
   getCustomThemes,
@@ -12,7 +12,7 @@ import {
   themeColorToHex,
   THEME_FILE_VERSION,
 } from "../../themePalette";
-import type { OpenVsxThemeExtension } from "../../openVsxThemes";
+import { importOpenVsxThemeExtension, type OpenVsxThemeExtension } from "../../openVsxThemes";
 import { ThemeImportDialog } from "./ThemeImportDialog";
 
 const searchOpenVsxThemes = vi.hoisted(() => vi.fn());
@@ -222,3 +222,40 @@ describe("ThemeImportDialog JSONC imports", () => {
     ]);
   });
 });
+
+it.each(["Cancel", "navigation"])(
+  "does not install a pending community theme after %s",
+  async (exit) => {
+    using _themes = isolateThemes();
+    searchOpenVsxThemes.mockReset();
+    searchOpenVsxThemes.mockResolvedValue([extension]);
+    const download = Promise.withResolvers<ReturnType<typeof parseThemeFile>[]>();
+    vi.mocked(importOpenVsxThemeExtension).mockReset();
+    vi.mocked(importOpenVsxThemeExtension).mockReturnValue(download.promise);
+    await using screen = await render(
+      <ThemeImportDialog
+        open
+        onOpenChange={() => {}}
+        onImported={() => true}
+        onImportedMany={() => {}}
+      />,
+    );
+    await userEvent.fill(page.getByLabelText("Search Open VSX themes"), "night");
+    await page.getByRole("button", { name: "Install Nightfall" }).click();
+    if (exit === "Cancel") await page.getByRole("button", { name: "Cancel", exact: true }).click();
+    await screen.unmount();
+    await act(async () => {
+      download.resolve([
+        {
+          ...parseThemeFile(theme("Nightfall")),
+          collection: { id: extension.collectionId, label: extension.name },
+        },
+      ]);
+      await download.promise;
+    });
+    expect(
+      getCustomThemes(),
+      "expect leaving Appearance to cancel its pending theme installation",
+    ).toEqual([]);
+  },
+);
cd apps/web && pnpm exec vp test run src/components/settings/ThemeImportDialog.browser.test.tsx

Workaround

No response

Activity

  1. added
    vouch:trusted
    on Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    vouch:trusted

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions