diff --git a/apps/web/src/components/settings/ThemeSearchDialog.tsx b/apps/web/src/components/settings/ThemeSearchDialog.tsx index e26039b366..329c989c17 100644 --- a/apps/web/src/components/settings/ThemeSearchDialog.tsx +++ b/apps/web/src/components/settings/ThemeSearchDialog.tsx @@ -1,4 +1,4 @@ -import { CheckCircle2Icon, PlusIcon, SearchIcon, ShieldCheckIcon } from "lucide-react"; +import { CheckCircle2Icon, PaletteIcon, PlusIcon, SearchIcon, ShieldCheckIcon } from "lucide-react"; import type { FormEvent } from "react"; import { useCallback, useEffect, useRef, useState } from "react"; import { @@ -223,17 +223,9 @@ export function ThemeSearchDialog({ key={extension.id} >
diff --git a/apps/web/src/openVsxThemes.test.ts b/apps/web/src/openVsxThemes.test.ts
index 4a74bb91c7..531f43e32f 100644
--- a/apps/web/src/openVsxThemes.test.ts
+++ b/apps/web/src/openVsxThemes.test.ts
@@ -80,6 +80,25 @@ describe("Open VSX themes", () => {
expect(searchUrl.searchParams.get("size")).toBe("16");
});
+ it("reports an unavailable search when every detail request fails", async () => {
+ vi.stubGlobal(
+ "fetch",
+ vi.fn(async (input: RequestInfo | URL) => {
+ if (String(input).includes("/-/search?")) {
+ return new Response(
+ JSON.stringify({ extensions: [{ namespace: "demo", name: "theme" }] }),
+ { status: 200 },
+ );
+ }
+ return new Response(null, { status: 429 });
+ }),
+ );
+
+ await expect(searchOpenVsxThemes("dracula")).rejects.toThrow(
+ "Open VSX theme details are unavailable",
+ );
+ });
+
it("downloads a verified VSIX, reads JSONC includes, and pairs contributed variants", async () => {
const zip = new JSZip();
zip.file(
@@ -140,7 +159,6 @@ describe("Open VSX themes", () => {
publisher: "demo",
description: "",
downloadCount: 1,
- iconUrl: null,
license: "MIT",
manifestUrl: `${ASSET_ROOT}/package.json`,
sha256Url: `${ASSET_ROOT}/demo.theme-1.0.0.sha256`,
@@ -184,7 +202,6 @@ describe("Open VSX themes", () => {
publisher: "demo",
description: "",
downloadCount: 1,
- iconUrl: null,
license: "MIT",
manifestUrl: `${ASSET_ROOT}/package.json`,
sha256Url: `${ASSET_ROOT}/demo.theme-1.0.0.sha256`,
diff --git a/apps/web/src/openVsxThemes.ts b/apps/web/src/openVsxThemes.ts
index eb0a63b400..302fefc5f5 100644
--- a/apps/web/src/openVsxThemes.ts
+++ b/apps/web/src/openVsxThemes.ts
@@ -39,7 +39,6 @@ export type OpenVsxThemeExtension = {
publisher: string;
description: string;
downloadCount: number;
- iconUrl: string | null;
manifestUrl: string;
sha256Url: string;
vsixUrl: string;
@@ -96,7 +95,6 @@ function extensionFromDetail(value: unknown): OpenVsxThemeExtension | null {
typeof value.downloadCount === "number" && Number.isFinite(value.downloadCount)
? value.downloadCount
: 0,
- iconUrl: trustedOpenVsxUrl(value.files.icon),
manifestUrl,
sha256Url,
vsixUrl,
@@ -141,7 +139,7 @@ export async function searchOpenVsxThemes(
identities.slice(0, 16).map(async ([namespace, name]) => {
const detailUrl = `https://open-vsx.org/api/${encodeURIComponent(namespace)}/${encodeURIComponent(name)}`;
const detailResponse = await fetch(detailUrl, signal ? { signal } : {});
- if (!detailResponse.ok) return null;
+ if (!detailResponse.ok) throw new Error("Open VSX theme details are unavailable.");
const detailBytes = await readCappedResponse(
detailResponse,
MAX_DETAIL_BYTES,
@@ -155,9 +153,11 @@ export async function searchOpenVsxThemes(
}),
);
if (signal?.aborted) throw new DOMException("The operation was aborted.", "AbortError");
- return details
- .flatMap((result) => (result.status === "fulfilled" && result.value ? [result.value] : []))
- .slice(0, 8);
+ const completedDetails = details.filter((result) => result.status === "fulfilled");
+ if (identities.length > 0 && completedDetails.length === 0) {
+ throw new Error("Open VSX theme details are unavailable right now.");
+ }
+ return completedDetails.flatMap((result) => (result.value ? [result.value] : [])).slice(0, 8);
}
function parseJsoncObject(source: string, description: string): Record