Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

fix(web): show native download copy only after 0.6.1 is published

Cursor Agentde1c86227d15
diff --git a/apps/web/__tests__/unit/native-release.test.ts b/apps/web/__tests__/unit/native-release.test.ts
new file mode 100644
index 000000000..a1941020b
--- /dev/null
+++ b/apps/web/__tests__/unit/native-release.test.ts
@@ -0,0 +1,27 @@
+import { describe, expect, it } from "vitest";
+import { nativeDesktopReleaseIsLive } from "@/utils/native-release";
+
+describe("native desktop release messaging", () => {
+ it("stays off while the published releases are still the original app", () => {
+ expect(nativeDesktopReleaseIsLive([])).toBe(false);
+ expect(nativeDesktopReleaseIsLive([{ version: "0.6.0" }])).toBe(false);
+ expect(
+ nativeDesktopReleaseIsLive([{ version: "0.6.0" }, { version: "0.5.24" }]),
+ ).toBe(false);
+ expect(nativeDesktopReleaseIsLive([{ version: "0.6.1-nightly.1" }])).toBe(
+ false,
+ );
+ });
+
+ it("turns on once a published release is 0.6.1 or newer", () => {
+ expect(nativeDesktopReleaseIsLive([{ version: "0.6.1" }])).toBe(true);
+ expect(
+ nativeDesktopReleaseIsLive([{ version: "0.6.1" }, { version: "0.6.0" }]),
+ ).toBe(true);
+ expect(nativeDesktopReleaseIsLive([{ version: "0.6.2" }])).toBe(true);
+ expect(nativeDesktopReleaseIsLive([{ version: "v0.7.0" }])).toBe(true);
+ expect(
+ nativeDesktopReleaseIsLive([{ version: "0.6.0" }, { version: "0.6.1" }]),
+ ).toBe(true);
+ });
+});
diff --git a/apps/web/app/(site)/download/page.tsx b/apps/web/app/(site)/download/page.tsx
index 94f58dfc3..a7ac43ae0 100644
--- a/apps/web/app/(site)/download/page.tsx
+++ b/apps/web/app/(site)/download/page.tsx
@@ -1,6 +1,8 @@
import type { Metadata } from "next";
import { DownloadPage } from "@/components/pages/DownloadPage";
import { buildMarketingMetadata } from "@/lib/og/url";
+import { nativeDesktopReleaseIsLive } from "@/utils/native-release";
+import { getGitHubReleases } from "@/utils/releases";
export const metadata: Metadata = buildMarketingMetadata({
title: "Download — Cap",
@@ -9,6 +11,11 @@ export const metadata: Metadata = buildMarketingMetadata({
ogTag: "Download",
});
-export default function App() {
- return <DownloadPage />;
+export const revalidate = 60;
+
+export default async function App() {
+ const releases = await getGitHubReleases().catch(() => []);
+ return (
+ <DownloadPage nativeReleaseLive={nativeDesktopReleaseIsLive(releases)} />
+ );
}
diff --git a/apps/web/app/(site)/download/versions/page.tsx b/apps/web/app/(site)/download/versions/page.tsx
index cbcf7ea52..33bb02a88 100644
--- a/apps/web/app/(site)/download/versions/page.tsx
+++ b/apps/web/app/(site)/download/versions/page.tsx
@@ -2,6 +2,10 @@ import { format, parseISO } from "date-fns";
import type { Metadata } from "next";
import Link from "next/link";
import { buildMarketingMetadata } from "@/lib/og/url";
+import {
+ LAST_TAURI_VERSION,
+ nativeDesktopReleaseIsLive,
+} from "@/utils/native-release";
import {
getGitHubReleases,
hasDownloads,
@@ -20,8 +24,6 @@ export const metadata: Metadata = buildMarketingMetadata({
export const revalidate = 60;
-const LAST_TAURI_VERSION = "0.6.0";
-
function DownloadLinks({
downloads,
isLatest,
@@ -200,9 +202,11 @@ function LinuxIcon() {
function ReleaseRow({
release,
isLatest,
+ nativeReleaseLive,
}: {
release: Release;
isLatest: boolean;
+ nativeReleaseLive: boolean;
}) {
return (
<div
@@ -219,7 +223,7 @@ function ReleaseRow({
Latest
</span>
)}
- {release.version === LAST_TAURI_VERSION && (
+ {nativeReleaseLive && release.version === LAST_TAURI_VERSION && (
<span className="px-2 py-0.5 text-xs font-medium whitespace-nowrap rounded-full border border-gray-5 bg-gray-2 text-gray-11">
Last Tauri version
</span>
@@ -252,6 +256,8 @@ export default async function VersionsPage() {
error = e instanceof Error ? e.message : "Failed to fetch releases";
}
+ const nativeReleaseLive = nativeDesktopReleaseIsLive(releases);
+
return (
<div className="py-24 md:py-32 wrapper wrapper-sm">
<div className="space-y-6">
@@ -280,17 +286,19 @@ export default async function VersionsPage() {
</p>
</div>
- <div className="p-4 rounded-lg border border-gray-5 bg-gray-2">
- <h2 className="text-sm font-medium text-gray-12">
- Cap is now a fully native app
- </h2>
- <p className="mt-1 text-sm leading-6 text-gray-11">
- From 0.6.1, Cap is built natively for macOS, Windows, and Linux.
- Version {LAST_TAURI_VERSION} is the last release of the original
- app, which was built with Tauri. It stays available below, along
- with every earlier version.
- </p>
- </div>
+ {nativeReleaseLive && (
+ <div className="p-4 rounded-lg border border-gray-5 bg-gray-2">
+ <h2 className="text-sm font-medium text-gray-12">
+ Cap is now a fully native app
+ </h2>
+ <p className="mt-1 text-sm leading-6 text-gray-11">
+ From 0.6.1, Cap is built natively for macOS, Windows, and Linux.
+ Version {LAST_TAURI_VERSION} is the last release of the original
+ app, which was built with Tauri. It stays available below, along
+ with every earlier version.
+ </p>
+ </div>
+ )}
{error ? (
<div className="p-4 rounded-lg border border-red-5 bg-red-2 text-red-11">
@@ -307,6 +315,7 @@ export default async function VersionsPage() {
key={release.tagName}
release={release}
isLatest={index === 0}
+ nativeReleaseLive={nativeReleaseLive}
/>
))}
</div>
diff --git a/apps/web/components/pages/DownloadPage.tsx b/apps/web/components/pages/DownloadPage.tsx
index 157de734b..28b7e0201 100644
--- a/apps/web/components/pages/DownloadPage.tsx
+++ b/apps/web/components/pages/DownloadPage.tsx
@@ -10,6 +10,7 @@ import {
CAP_CHROME_EXTENSION_URL,
CHROME_EXTENSION_BUTTON_CLASS,
} from "@/lib/chrome-extension";
+import { LAST_TAURI_VERSION } from "@/utils/native-release";
import {
getDownloadButtonText,
getDownloadUrl,
@@ -18,8 +19,6 @@ import {
PlatformIcons,
} from "@/utils/platform";
-const LAST_TAURI_VERSION = "0.6.0";
-
const BADGE_LOOP =
"M 22 33 C 19 15, 84 7, 150 7.5 C 222 8, 289 14, 287 31 C 285 49, 214 55, 146 54 C 78 53, 12 47, 14 29 C 15.5 18, 44 10.5, 76 9";
const BADGE_SPARKS = [
@@ -125,7 +124,11 @@ function InkUnderline({
);
}
-export const DownloadPage = () => {
+export const DownloadPage = ({
+ nativeReleaseLive = false,
+}: {
+ nativeReleaseLive?: boolean;
+}) => {
const { platform, isIntel } = useDetectPlatform();
const [copiedCliCommand, setCopiedCliCommand] = useState(false);
const boil = useId().replace(/[^a-zA-Z0-9_-]/g, "");
@@ -163,19 +166,28 @@ export const DownloadPage = () => {
return (
<div className="py-32 md:py-40 wrapper wrapper-sm">
- <BoilFilter id={boil} />
+ {nativeReleaseLive && <BoilFilter id={boil} />}
<div className="space-y-4 text-center">
- <div className="flex justify-center items-center h-8 fade-in-down">
- <NativeAnnouncement boil={boil} />
- </div>
+ {nativeReleaseLive && (
+ <div className="flex justify-center items-center h-8 fade-in-down">
+ <NativeAnnouncement boil={boil} />
+ </div>
+ )}
<h1 className="text-2xl fade-in-down animate-delay-1 md:text-4xl">
Download Cap
</h1>
- <p className="px-4 mx-auto max-w-xl text-sm fade-in-down text-gray-11 animate-delay-2 md:text-base md:px-0">
- The quickest way to share your screen, now a{" "}
- <InkUnderline boil={boil}>fully native app</InkUnderline>. It opens
- faster and stays light on your computer while you record.
- </p>
+ {nativeReleaseLive ? (
+ <p className="px-4 mx-auto max-w-xl text-sm fade-in-down text-gray-11 animate-delay-2 md:text-base md:px-0">
+ The quickest way to share your screen, now a{" "}
+ <InkUnderline boil={boil}>fully native app</InkUnderline>. It opens
+ faster and stays light on your computer while you record.
+ </p>
+ ) : (
+ <p className="px-4 text-sm fade-in-down text-gray-11 animate-delay-2 md:text-base md:px-0">
+ The quickest way to share your screen. Pin to your dock or taskbar
+ and record in seconds.
+ </p>
+ )}
<div className="flex flex-col justify-center items-center space-y-4 fade-in-up animate-delay-2">
<div className="flex flex-col items-center space-y-4">
<div className="flex flex-col gap-3 justify-center items-center w-full sm:flex-row sm:gap-4">
@@ -210,23 +222,25 @@ export const DownloadPage = () => {
{getVersionText(platform)}
</div>
- <p className="text-xs text-gray-10">
- Looking for the original app?{" "}
- <Link
- href={`/download/versions#v${LAST_TAURI_VERSION}`}
- onClick={() =>
- trackDownloadClick(
- "last_tauri_version",
- "/download/versions",
- "tauri_app",
- )
- }
- className="underline underline-offset-2 hover:text-gray-12"
- >
- Cap {LAST_TAURI_VERSION}
- </Link>{" "}
- is still available.
- </p>
+ {nativeReleaseLive && (
+ <p className="text-xs text-gray-10">
+ Looking for the original app?{" "}
+ <Link
+ href={`/download/versions#v${LAST_TAURI_VERSION}`}
+ onClick={() =>
+ trackDownloadClick(
+ "last_tauri_version",
+ "/download/versions",
+ "tauri_app",
+ )
+ }
+ className="underline underline-offset-2 hover:text-gray-12"
+ >
+ Cap {LAST_TAURI_VERSION}
+ </Link>{" "}
+ is still available.
+ </p>
+ )}
{/* Windows SmartScreen video and instructions */}
{platform === "windows" && (
diff --git a/apps/web/utils/native-release.ts b/apps/web/utils/native-release.ts
new file mode 100644
index 000000000..2983296eb
--- /dev/null
+++ b/apps/web/utils/native-release.ts
@@ -0,0 +1,14 @@
+import { isAtLeastSemver } from "@/utils/desktop";
+
+export const LAST_TAURI_VERSION = "0.6.0";
+
+const FIRST_NATIVE_DESKTOP_VERSION = [0, 6, 1] as const;
+
+export function nativeDesktopReleaseIsLive(
+ releases: readonly { version: string }[],
+): boolean {
+ const [major, minor, patch] = FIRST_NATIVE_DESKTOP_VERSION;
+ return releases.some((release) =>
+ isAtLeastSemver(release.version, major, minor, patch),
+ );
+}