Skip to content

Open source CapCut alternative.

TypeScript

feat(site): wall full cloud drops once and offer a move [rebuild]

David Le8a09f983e7a2
diff --git a/site/src/cut/components/Editor.tsx b/site/src/cut/components/Editor.tsx
index 3c1b284b..f08e4e1e 100644
--- a/site/src/cut/components/Editor.tsx
+++ b/site/src/cut/components/Editor.tsx
@@ -18,6 +18,7 @@ import { Button } from "@/components/ui/button";
import {
apiFetch,
bindCutMode,
+ getBackend,
hasLocalCompute,
releaseCutMode,
subscribeCutMode,
@@ -35,6 +36,7 @@ import { copyTimelineSelection, pasteCutPayload, payloadFromHtml } from "@/cut/l
import { useLibrary } from "@/cut/lib/queries";
import { copyableRefs } from "@/cut/lib/refCopy";
import { startUpload } from "@/cut/lib/importQueue";
+import { checkImportRoom } from "@/cut/lib/importRoom";
import { enrichAsset, importFileToProject, isMediaFile, prepareImport } from "@/cut/lib/media";
import { isLinkedFile, uploadLinkedFile } from "@/cut/lib/linkedLibrary";
import { copiedFrameFile, hasCopiedFrame } from "@/cut/lib/stageFrame";
@@ -791,6 +793,9 @@ export function Editor({
// afterwards, so the first Space after an import went to that control.
// Typing is never interrupted: a focused text field keeps the keyboard.
focusShell();
+ // A drop that won't fit the account's cloud storage says so once, up
+ // front; the files still land here.
+ checkImportRoom(list);
setImporting((n) => n + list.length);
// What landed, by kind, for the one import report after the run.
const kinds = new Set<MediaAsset["type"]>();
@@ -804,7 +809,7 @@ export function Editor({
// browser cannot decode goes the plain way: the project converts it
// first, and the asset is built from what comes back.
const pending = await prepareImport(projectId, file);
- const asset = pending?.asset ?? (await importFileToProject(projectId, file));
+ const asset = pending?.asset ?? (await importFileToProject(projectId, file, getBackend(), "caller"));
if (!asset) {
opts?.onOutcome?.({ file, failed: true });
continue;
@@ -1354,7 +1359,7 @@ export function Editor({
</Button>
</div>
)}
- {!chatgpt && <StorageUpgradeDialog />}
+ {!chatgpt && <StorageUpgradeDialog surface="editor" />}
{!chatgpt && <UpgradeDialog />}
<Lightbox />
</div>
diff --git a/site/src/cut/components/PlansDialog.tsx b/site/src/cut/components/PlansDialog.tsx
index 8c684567..7df2f595 100644
--- a/site/src/cut/components/PlansDialog.tsx
+++ b/site/src/cut/components/PlansDialog.tsx
@@ -35,6 +35,7 @@ export function PlansDialog({
title,
body,
notice,
+ aside,
dismissLabel,
onClose,
}: {
@@ -47,6 +48,9 @@ export function PlansDialog({
body?: React.ReactNode;
// A warning under the message, such as storage about to be reclaimed.
notice?: React.ReactNode;
+ // A way forward under the plans that buys nothing, such as moving the
+ // project to this computer.
+ aside?: React.ReactNode;
// The way out as a text button at the bottom right, in place of the close
// button. Onboarding ends on the plans, and free is one of its answers.
dismissLabel?: string;
@@ -140,6 +144,7 @@ export function PlansDialog({
</div>
</DialogBody>
<div className="flex flex-col gap-3 px-6 pt-5 pb-6 sm:px-10">
+ {aside}
{error ? (
<p className="text-center text-sm text-destructive">
{apiErrorText(error, tBilling("billingUnavailable"))}
diff --git a/site/src/cut/components/StorageUpgradeDialog.tsx b/site/src/cut/components/StorageUpgradeDialog.tsx
index 43b7ecd6..2fa722f4 100644
--- a/site/src/cut/components/StorageUpgradeDialog.tsx
+++ b/site/src/cut/components/StorageUpgradeDialog.tsx
@@ -1,9 +1,12 @@
"use client";
// The storage-quota wall's face: opens when an upload is rejected for space
-// anywhere in the app, or when the top bar's pill is clicked, and lays out the
-// plans with more room — or just explains, on the plan with the most.
+// anywhere in the app, when a drop won't fit, or when the top bar's pill is
+// clicked, and lays out the plans with more room — or just explains, on the
+// plan with the most. In the editor on a cloud project it also offers to move
+// the project to this computer, where cloud storage doesn't limit it.
import { useEffect, useState } from "react";
+import { Loader2 } from "lucide-react";
import { useLocale, useTranslations } from "next-intl";
import { Button } from "@/components/ui/button";
import {
@@ -25,18 +28,29 @@ import type { UpgradeEntry } from "@/cut/lib/upgrade";
import { track } from "@/lib/analytics";
import { PAID_PLANS } from "@/lib/billing/plans";
import { useProSubscription } from "@/queries/billing";
-import { useCloudUsage } from "@/cut/lib/backend/hooks";
+import { supportsBrowserStore } from "@/cut/lib/backend/browser/opfs";
+import { useCloudUsage, useCutMode, useLocalCompute } from "@/cut/lib/backend/hooks";
+import { projectHref, useCutBase } from "@/cut/lib/nav";
import { onOperationFailure } from "@/cut/lib/operationFailure";
+import { moveOpenProject } from "@/cut/lib/projectMove";
+import type { Residency } from "@/cut/lib/residency";
+import { useEditor } from "@/cut/lib/store";
+import { useDescribeError } from "@/i18n/describeError";
import { formatBytes } from "@/lib/bytes";
// What raised the storage wall, as the plans name where they were met.
const STORAGE_ENTRY: Record<StorageQuotaDetail["source"], UpgradeEntry> = {
"quota-413": "storage_refused",
+ import: "storage_import",
render: "render_refused",
pill: "storage_pill",
};
-export function StorageUpgradeDialog() {
+// Where the wall is mounted: the editor, which can move its open project off
+// the cloud, or the projects home, which has no project open.
+type WallSurface = "editor" | "home";
+
+export function StorageUpgradeDialog({ surface = "home" }: { surface?: WallSurface }) {
const [detail, setDetail] = useState<StorageQuotaDetail | null>(null);
useEffect(
@@ -59,14 +73,28 @@ export function StorageUpgradeDialog() {
};
if (!detail) return null;
- return <OpenDialog detail={detail} onClose={close} />;
+ return <OpenDialog detail={detail} surface={surface} onClose={close} />;
}
// Split so the billing query only runs while the dialog is up.
-function OpenDialog({ detail, onClose }: { detail: StorageQuotaDetail; onClose: () => void }) {
+function OpenDialog({
+ detail,
+ surface,
+ onClose,
+}: {
+ detail: StorageQuotaDetail;
+ surface: WallSurface;
+ onClose: () => void;
+}) {
const t = useTranslations("billing");
const locale = useLocale();
const subscription = useProSubscription();
+ const move = useMoveOffCloud(surface);
+ // A move under way finishes on the project it lands; the wall stays up
+ // until then.
+ const leave = () => {
+ if (!move?.moving) onClose();
+ };
const onTopPlan = subscription.data?.plan === PAID_PLANS[PAID_PLANS.length - 1];
// A wall raised by a queued render carries no numbers — it failed in the
// worker, hours from the request. The account's own meter fills them in, so
@@ -79,8 +107,24 @@ function OpenDialog({ detail, onClose }: { detail: StorageQuotaDetail; onClose:
bytes !== undefined && quotaBytes !== undefined
? { used: formatBytes(bytes, locale), quota: formatBytes(quotaBytes, locale) }
: null;
- const used = meter ? t("storage.used", meter) : null;
- const title = detail.source === "pill" ? t("storage.title") : t("storage.fullTitle");
+ // A drop checked before its upload says what it needs and what is free.
+ const need =
+ detail.needBytes !== undefined && bytes !== undefined && quotaBytes !== undefined
+ ? t("storage.importNeed", {
+ need: formatBytes(detail.needBytes, locale),
+ free: formatBytes(Math.max(0, quotaBytes - bytes), locale),
+ quota: formatBytes(quotaBytes, locale),
+ })
+ : null;
+ const used = need ?? (meter ? t("storage.used", meter) : null);
+ const title =
+ detail.source === "pill"
+ ? t("storage.title")
+ : detail.source === "import"
+ ? t("storage.importTitle")
+ : t("storage.fullTitle");
+ const fullTitle = detail.source === "import" ? t("storage.importTitle") : t("storage.fullTitle");
+ const keepLocal = move ? <KeepLocal move={move} /> : null;
const graceDays = detail.grace ? daysUntil(detail.grace.deadline) : null;
const grace =
detail.grace && graceDays !== null
@@ -94,7 +138,7 @@ function OpenDialog({ detail, onClose }: { detail: StorageQuotaDetail; onClose:
if (!subscription.data) return null;
if (onTopPlan) {
return (
- <Dialog open onOpenChange={(open) => !open && onClose()}>
+ <Dialog open onOpenChange={(open) => !open && leave()}>
<DialogContent className="sm:max-w-sm">
<DialogHeader>
<DialogTitle>{title}</DialogTitle>
@@ -103,8 +147,9 @@ function OpenDialog({ detail, onClose }: { detail: StorageQuotaDetail; onClose:
{used && <p>{used}</p>}
<p>{t("storage.proBody")}</p>
</div>
+ {keepLocal}
<DialogFooter className="mt-2">
- <Button className="w-full" onClick={onClose}>
+ <Button className="w-full" disabled={move?.moving} onClick={leave}>
{t("ok")}
</Button>
</DialogFooter>
@@ -117,10 +162,77 @@ function OpenDialog({ detail, onClose }: { detail: StorageQuotaDetail; onClose:
<PlansDialog
source="storage"
entry={STORAGE_ENTRY[detail.source]}
- title={detail.source === "pill" ? t("storage.moreTitle") : t("storage.fullTitle")}
+ title={detail.source === "pill" ? t("storage.moreTitle") : fullTitle}
body={used}
notice={grace}
- onClose={onClose}
+ aside={keepLocal}
+ onClose={leave}
/>
);
}
+
+type MoveOffCloud = {
+ to: Residency;
+ moving: boolean;
+ progress: { done: number; total: number } | null;
+ error: string | null;
+ start: () => void;
+};
+
+/** The move off the cloud the wall offers: the open cloud project to this
+ * Mac's engine when it answers, else to this browser's own storage. Null
+ * where there is no project to move or nowhere on this computer to put it. */
+function useMoveOffCloud(surface: WallSurface): MoveOffCloud | null {
+ const t = useTranslations("billing");
+ const describeError = useDescribeError();
+ const base = useCutBase();
+ const mode = useCutMode();
+ const engineUp = useLocalCompute();
+ const projectId = useEditor((s) => s.projectId);
+ const [moving, setMoving] = useState(false);
+ const [progress, setProgress] = useState<MoveOffCloud["progress"]>(null);
+ const [error, setError] = useState<string | null>(null);
+ const to: Residency | null = engineUp ? "local" : supportsBrowserStore() ? "browser" : null;
+ if (surface !== "editor" || mode !== "cloud" || !projectId || !to) return null;
+
+ // The copy opens in place of the original once it has landed.
+ const start = () => {
+ setMoving(true);
+ setError(null);
+ track("cut_storage_move_started", { to });
+ moveOpenProject("cloud", to, (done, total) => setProgress({ done, total }))
+ .then((newId) => {
+ track("cut_storage_move_done", { to });
+ window.location.href = projectHref(base, newId, "projects", null);
+ })
+ .catch((e: unknown) => {
+ setError(describeError(e, t("storage.moveFailed")));
+ setMoving(false);
+ setProgress(null);
+ });
+ };
+ return { to, moving, progress, error, start };
+}
+
+/** The wall's free way forward: move the project to this computer and keep
+ * editing it there. */
+function KeepLocal({ move }: { move: MoveOffCloud }) {
+ const t = useTranslations("billing");
+ const label = !move.moving
+ ? t("storage.keepLocal")
+ : move.progress
+ ? t("storage.moving", move.progress)
+ : t("storage.moveStarting");
+ return (
+ <div className="flex flex-col gap-3 border-t pt-5 sm:flex-row sm:items-center sm:justify-between">
+ <div className="space-y-1 text-sm">
+ <p className="text-muted-foreground">{t("storage.keepLocalBody", { to: move.to })}</p>
+ {move.error ? <p className="text-destructive">{move.error}</p> : null}
+ </div>
+ <Button variant="outline" className="shrink-0" disabled={move.moving} onClick={move.start}>
+ {move.moving ? <Loader2 className="animate-spin" data-icon="inline-start" /> : null}
+ {label}
+ </Button>
+ </div>
+ );
+}
diff --git a/site/src/cut/components/TopBar.tsx b/site/src/cut/components/TopBar.tsx
index 90371a40..5d6bd95e 100644
--- a/site/src/cut/components/TopBar.tsx
+++ b/site/src/cut/components/TopBar.tsx
@@ -31,16 +31,12 @@ import {
TooltipProvider,
TooltipTrigger,
} from "@/components/ui/tooltip";
-import { cloudBackend } from "@/cut/lib/backend/cloud";
import { useDescribeError } from "@/i18n/describeError";
import { cloudUsageQueryKey, useCutMode } from "@/cut/lib/backend/hooks";
-import { browserBackend } from "@/cut/lib/backend/browser";
-import { localBackend } from "@/cut/lib/backend/local";
-import { clearProjectThreads } from "@/cut/lib/chatThreads";
import { retryFailedUploads } from "@/cut/lib/importQueue";
import { backTarget, projectHref, useCutBase } from "@/cut/lib/nav";
import { useTourHoldsStarter } from "@/cut/lib/tourLock";
-import { copyProjectAcross } from "@/cut/lib/projectCopy";
+import { moveOpenProject } from "@/cut/lib/projectMove";
import { projectDuration, useEditor } from "@/cut/lib/store";
import { useEnvironment } from "@/cut/lib/environment";
import { openThroughHost, projectPageUrl, requestHostFullscreen, useHostDisplayMode } from "@/cut/lib/hostBridge";
@@ -333,25 +329,13 @@ export function TopBar({
const [moveError, setMoveError] = useState<string | null>(null);
const moveToCloud = async () => {
- const projectId = useEditor.getState().projectId;
- if (!projectId) return;
+ if (!useEditor.getState().projectId) return;
setMoving(true);
setMoveError(null);
try {
- // Let a pending autosave land so the copy reads the current cut.
- for (let i = 0; i < 40 && useEditor.getState().saveState !== "saved"; i++) {
- await new Promise((r) => setTimeout(r, 250));
- }
- const src = cutMode === "browser" ? browserBackend : localBackend;
- const newId = await copyProjectAcross(src, cloudBackend, projectId, {
- onProgress: (done, total) => setMoveProgress(t("movingMedia", { done, total })),
- });
- await src
- .fetch(`/api/cut/projects/${projectId}`, { method: "DELETE" })
- .catch(() => {});
- // The chat history moved with the project; the old project's copy goes
- // with the project itself.
- clearProjectThreads(projectId);
+ const newId = await moveOpenProject(cutMode === "browser" ? "browser" : "local", "cloud", (done, total) =>
+ setMoveProgress(t("movingMedia", { done, total }))
+ );
window.location.href = projectHref(base, newId, "projects", null);
} catch (e) {
setMoveError(describeError(e, t("moveFailed")));
diff --git a/site/src/cut/lib/backend/cloud.ts b/site/src/cut/lib/backend/cloud.ts
index 3adc41b3..c86d9130 100644
--- a/site/src/cut/lib/backend/cloud.ts
+++ b/site/src/cut/lib/backend/cloud.ts
@@ -6,7 +6,14 @@
import { throttleWait } from "../network";
import { observeOperationResponse, operationFailure } from "../operationFailure";
import { UserError } from "../userError";
-import { DOC_SEQ_HEADER, DOC_WRITER_HEADER, HTTP_CONFLICT, type CutBackend, type CutRequestInit } from "./types";
+import {
+ DOC_SEQ_HEADER,
+ DOC_WRITER_HEADER,
+ HTTP_CONFLICT,
+ type CutBackend,
+ type CutRequestInit,
+ type StorageFull,
+} from "./types";
const cloudPath = (path: string) => path.replace(/^\/api\/cut\//, "/api/cut-cloud/");
@@ -23,7 +30,12 @@ export function bindCloudSession(base: string, headers: Record<string, string>)
* page, the bound session's origin and headers in a headless process. */
type CloudSession = { base: string; headers: Record<string, string> } | null;
-async function requestWithSession(bound: CloudSession, path: string, init?: RequestInit): Promise<Response> {
+async function requestWithSession(
+ bound: CloudSession,
+ path: string,
+ init?: RequestInit,
+ storageFull: StorageFull = "wall"
+): Promise<Response> {
const headers = new Headers(bound?.headers);
new Headers(init?.headers).forEach((value, key) => headers.set(key, value));
@@ -35,11 +47,11 @@ async function requestWithSession(bound: CloudSession, path: string, init?: Requ
const res = await fetch((bound?.base ?? "") + path, { ...init, headers });
const wait = throttleWait(res);
if (wait === null || !firewallRefusal(res)) {
- return observeOperationResponse(res);
+ return observeOperationResponse(res, storageFull);
}
holdFirewall(wait);
if (attempt > FIREWALL_RETRIES || !resendable(init?.body) || init?.signal?.aborted) {
- return observeOperationResponse(res);
+ return observeOperationResponse(res, storageFull);
}
await res.body?.cancel().catch(() => {});
}
@@ -81,8 +93,25 @@ const firewallRefusal = (res: Response) => !/json/i.test(res.headers.get("conten
* read, e.g. a piped upload. */
const resendable = (body: RequestInit["body"]) => !(typeof ReadableStream !== "undefined" && body instanceof ReadableStream);
-export function cloudRequest(path: string, init?: RequestInit): Promise<Response> {
- return requestWithSession(session, path, init);
+export type CloudUsage = {
+ bytes: number;
+ /** null = unlimited. */
+ quotaBytes: number | null;
+ /** Present when the account's Pro ended and it holds more than the free cap:
+ * the sweep reclaims storage after `deadline` unless `overBytes` is freed. */
+ grace?: { deadline: string; overBytes: number };
+};
+
+/** The account's cloud storage usage — cloud-only by construction, so it hits
+ * the hosted route directly on the session cookie. */
+export async function fetchCloudUsage(): Promise<CloudUsage> {
+ const res = await fetch("/api/cut-cloud/usage");
+ if (!res.ok) throw new Error(`usage ${res.status}`);
+ return (await res.json()) as CloudUsage;
+}
+
+export function cloudRequest(path: string, init?: RequestInit, storageFull?: StorageFull): Promise<Response> {
+ return requestWithSession(session, path, init, storageFull);
}
/** Capture transport credentials for work that outlives the active project. */
@@ -91,7 +120,8 @@ export function captureCloudBackend(): CutBackend {
const writer = newWriter();
return {
...cloudBackend,
- fetch: (path, init) => cloudFetch(path, init, (url, options) => requestWithSession(bound, url, options), writer),
+ fetch: (path, init) =>
+ cloudFetch(path, init, (url, options, storageFull) => requestWithSession(bound, url, options, storageFull), writer),
url: (path) => (bound?.base ?? "") + cloudPath(path),
};
}
@@ -158,10 +188,10 @@ async function cloudFetch(
request = cloudRequest,
writer = sessionWriter
): Promise<Response> {
- const { observe, ...init } = options ?? {};
+ const { observe, storageFull, ...init } = options ?? {};
const doc = PROJECT_DOC.exec(path);
const method = (init?.method ?? "GET").toUpperCase();
- if (observe || !doc || (method !== "GET" && method !== "PUT")) return request(cloudPath(path), init);
+ if (observe || !doc || (method !== "GET" && method !== "PUT")) return request(cloudPath(path), init, storageFull);
const projectId = decodeURIComponent(doc[1]);
if (method === "GET") {
diff --git a/site/src/cut/lib/backend/hooks.ts b/site/src/cut/lib/backend/hooks.ts
index ce52b97c..643c1068 100644
--- a/site/src/cut/lib/backend/hooks.ts
+++ b/site/src/cut/lib/backend/hooks.ts
@@ -5,6 +5,7 @@ import { useSyncExternalStore } from "react";
import { currentEngineUser, subscribeEngineUser } from "../api";
import { listedResidencies, type Residency } from "../residency";
+import { fetchCloudUsage, type CloudUsage } from "./cloud";
import { cutMode, getBackend, hasLocalCompute, subscribeCutMode } from "./index";
import type { CutCaps, CutMode } from "./types";
@@ -49,15 +50,6 @@ export function useCutCaps(): CutCaps {
export const cloudUsageQueryKey = ["cut", "cloud-usage"] as const;
-export type CloudUsage = {
- bytes: number;
- /** null = unlimited. */
- quotaBytes: number | null;
- /** Present when the account's Pro ended and it holds more than the free cap:
- * the sweep reclaims storage after `deadline` unless `overBytes` is freed. */
- grace?: { deadline: string; overBytes: number };
-};
-
/** The account's cloud storage usage — cloud-only by construction, so it hits
* the hosted route directly on the session cookie. `poll` is for the editor's
* live meter; readers that only need the number once should leave it off. */
@@ -65,11 +57,7 @@ export function useCloudUsage(enabled: boolean, opts?: { poll?: boolean }) {
return useQuery<CloudUsage>({
enabled,
queryKey: cloudUsageQueryKey,
- queryFn: async () => {
- const res = await fetch("/api/cut-cloud/usage");
- if (!res.ok) throw new Error(`usage ${res.status}`);
- return (await res.json()) as CloudUsage;
- },
+ queryFn: fetchCloudUsage,
...(opts?.poll ? { refetchInterval: 60_000 } : {}),
});
}
diff --git a/site/src/cut/lib/backend/types.ts b/site/src/cut/lib/backend/types.ts
index e152fb34..0775e878 100644
--- a/site/src/cut/lib/backend/types.ts
+++ b/site/src/cut/lib/backend/types.ts
@@ -26,7 +26,11 @@ export type CutCaps = {
};
/** Observational reads leave the next document save based on the loaded version. */
-export type CutRequestInit = RequestInit & { observe?: boolean };
+/** Who answers a storage refusal (413): the app-wide storage wall, or the
+ * caller, which raises the wall its own way (an import raises one per drop). */
+export type StorageFull = "wall" | "caller";
+
+export type CutRequestInit = RequestInit & { observe?: boolean; storageFull?: StorageFull };
export interface CutBackend {
kind: CutMode;
@@ -46,3 +50,6 @@ export const DOC_SEQ_HEADER = "x-cut-doc-seq";
/** The status a versioned doc save answers when another writer moved on. */
export const HTTP_CONFLICT = 409;
+
+/** The status a write answers when the account's storage has no room for it. */
+export const HTTP_PAYLOAD_TOO_LARGE = 413;
diff --git a/site/src/cut/lib/importRoom.ts b/site/src/cut/lib/importRoom.ts
new file mode 100644
index 00000000..e3c390eb
--- /dev/null
+++ b/site/src/cut/lib/importRoom.ts
@@ -0,0 +1,50 @@
+// The size check before a drop on a cloud project uploads anything. The drop
+// still lands on screen and in this browser's store; when the account's cloud
+// storage can't take it, the storage wall goes up once, with the drop's own
+// numbers, before the first upload is refused. Every refusal that follows
+// from the same drop stays quiet (storageQuota.ts).
+import { getBackend } from "./backend";
+import { fetchCloudUsage } from "./backend/cloud";
+import { emitImportWall, startImportWall } from "./storageQuota";
+import { useEditor } from "./store";
+
+/** Starts a drop's one storage wall, and raises it now when the drop won't
+ * fit. Never holds the drop: the read runs beside its imports. */
+export function checkImportRoom(files: File[]): void {
+ if (getBackend().kind !== "cloud" || files.length === 0) {
+ return;
+ }
+ startImportWall();
+
+ // Uploads still on their way count too: the drop lands after them. Read
+ // now, before this drop's own files join them.
+ const pending = useEditor
+ .getState()
+ .assets.filter((a) => a.upload)
+ .reduce((sum, a) => sum + (a.sizeBytes ?? 0), 0);
+ void fitsCloud(files, pending).then((detail) => {
+ if (detail) {
+ emitImportWall({ source: "import", ...detail });
+ }
+ });
+}
+
+/** The wall's numbers when the drop won't fit, or null when it will (or the
+ * usage can't be read, where the uploads' own refusal raises the wall). */
+async function fitsCloud(
+ files: File[],
+ pending: number
+): Promise<{ bytes: number; quotaBytes: number; needBytes: number } | null> {
+ const usage = await fetchCloudUsage().catch(() => null);
+ if (!usage) {
+ return null;
+ }
+ const quotaBytes = usage.quotaBytes;
+ if (quotaBytes === null) {
+ return null;
+ }
+
+ const needBytes = files.reduce((sum, f) => sum + f.size, 0);
+ const bytes = usage.bytes + pending;
+ return bytes + needBytes > quotaBytes ? { bytes, quotaBytes, needBytes } : null;
+}
diff --git a/site/src/cut/lib/media.ts b/site/src/cut/lib/media.ts
index d0f2712e..10707c73 100644
--- a/site/src/cut/lib/media.ts
+++ b/site/src/cut/lib/media.ts
@@ -4,6 +4,7 @@ import { scanBeats, scanLevel, scanSilence, scanSpeech, type BeatScan, type Leve
import { syncSound, type SyncAnswer } from "./soundSync";
import { LoudnessMeter, type LoudnessMeasure } from "./loudness";
import { apiFetch, apiJson, getBackend, type CutBackend } from "./backend";
+import { HTTP_PAYLOAD_TOO_LARGE, type StorageFull } from "./backend/types";
import { registerBlobFile } from "./backend/browser/registry";
import { cloudBackend } from "./backend/cloud";
import { pollCloudJob } from "./cloudJob";
@@ -16,6 +17,7 @@ import { ConnectionLostError } from "./network";
import { downloadFromUrl } from "./download";
import { FONT_RE, LUT_RE } from "./libraryFileType";
import { markUploadStored, startUpload, uploadInFlight } from "./importQueue";
+import { emitImportWall } from "./storageQuota";
import { convertProjectFile, dropProjectFile, mp4DisplayName } from "./mediaConvert";
import { awaitsCompat, ensureProxy } from "./mediaProxy";
import { noteUndecoded } from "./codecSupport";
@@ -223,13 +225,15 @@ export async function presignUpload(
file: Blob,
name: string,
backend: CutBackend = getBackend(),
- extra: Record<string, unknown> = {}
+ extra: Record<string, unknown> = {},
+ storageFull: StorageFull = "wall"
): Promise<{ key: string; url: string; fileName: string }> {
const mime = file.type || "application/octet-stream";
const res = await backend.fetch(presignPath, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ fileName: name, mime, bytes: file.size, ...extra }),
+ storageFull,
});
const body = await apiJson<{ key?: string; url?: string; fileName?: string }>(res);
if (!res.ok || !body.key || !body.url) {
@@ -340,7 +344,7 @@ export async function uploadProjectMediaTo(
projectId: string,
file: Blob,
name: string,
- opts?: { onProgress?: (fraction: number) => void; signal?: AbortSignal }
+ opts?: { onProgress?: (fraction: number) => void; signal?: AbortSignal; storageFull?: StorageFull }
): Promise<string> {
if (backend.kind !== "cloud") {
const form = new FormData();
@@ -361,7 +365,9 @@ export async function uploadProjectMediaTo(
`/api/cut/projects/${projectId}/media/presign`,
file,
name,
- backend
+ backend,
+ {},
+ opts?.storageFull
);
await putSigned(signed.url, file, file.type || "application/octet-stream", opts);
const key = signed.key;
@@ -713,10 +719,12 @@ function sendCloudImport(
file,
file.name,
backend,
- avoid.length > 0 ? { avoid } : {}
+ avoid.length > 0 ? { avoid } : {},
+ "caller"
);
} catch (err) {
- if ((err as { status?: number }).status !== 413) throw err;
+ if ((err as { status?: number }).status !== HTTP_PAYLOAD_TOO_LARGE) throw err;
+ emitImportWall({ source: "quota-413" });
}
if (signed) {
const storedUrl = await stashCloudMedia(projectId, file, signed.fileName);
@@ -785,7 +793,11 @@ export function sendStoredUpload(
resume: true,
...(avoid.length > 0 ? { avoid } : {}),
}),
+ storageFull: "caller",
});
+ // A drain the account has no room for: the drop it came from raises the
+ // wall once, and the asset carries the refusal for its retry.
+ if (res.status === HTTP_PAYLOAD_TOO_LARGE) emitImportWall({ source: "quota-413" });
const body = await apiJson<{ key?: string; url?: string; fileName?: string; done?: boolean }>(
res
);
@@ -860,12 +872,21 @@ export async function resumePendingUploads(
export async function importFileToProject(
projectId: string,
file: File,
- backend: CutBackend = getBackend()
+ backend: CutBackend = getBackend(),
+ storageFull: StorageFull = "wall"
): Promise<MediaAsset | null> {
const type = assetTypeOf(file);
if (!type) return null;
- let fileName = await uploadProjectMediaTo(backend, projectId, file, file.name);
+ // A file from a drop answers a storage refusal with the drop's one wall.
+ let fileName = await uploadProjectMediaTo(backend, projectId, file, file.name, { storageFull }).catch(
+ (err: unknown) => {
+ if (storageFull === "caller" && (err as { status?: number }).status === HTTP_PAYLOAD_TOO_LARGE) {
+ emitImportWall({ source: "quota-413" });
+ }
+ throw err;
+ }
+ );
const originalFileName = fileName;
let name = file.name;
// Probe the bytes in hand: the same file the upload just wrote, with no
diff --git a/site/src/cut/lib/operationFailure.test.ts b/site/src/cut/lib/operationFailure.test.ts
index 2b232e1c..b2f121a4 100644
--- a/site/src/cut/lib/operationFailure.test.ts
+++ b/site/src/cut/lib/operationFailure.test.ts
@@ -19,3 +19,15 @@ test("size limits are distinct from account storage and generation credits from
expect(operationFailure(402, {})?.code).toBe("insufficient_credits");
expect(operationFailure(401, null)?.code).toBe("authentication_required");
});
+
+test("a caller that answers storage refusals itself keeps them from the wall", async () => {
+ const failures: unknown[] = [];
+ const stop = onOperationFailure((failure) => failures.push(failure));
+ try {
+ const refused = () => new Response(JSON.stringify({ error: "storage_quota_exceeded" }), { status: 413 });
+ await observeOperationResponse(refused(), "caller");
+ expect(failures).toEqual([]);
+ await observeOperationResponse(new Response("{}", { status: 402 }), "caller");
+ expect(failures).toHaveLength(1);
+ } finally { stop(); }
+});
diff --git a/site/src/cut/lib/operationFailure.ts b/site/src/cut/lib/operationFailure.ts
index e57995f7..bc7d9540 100644
--- a/site/src/cut/lib/operationFailure.ts
+++ b/site/src/cut/lib/operationFailure.ts
@@ -42,10 +42,17 @@ export function onOperationFailure(listener: (failure: OperationFailure) => void
return () => { listeners.delete(listener); };
}
-/** Hosts opt into presentation. Reading a response never consumes its body. */
-export async function observeOperationResponse(response: Response): Promise<Response> {
+/** Hosts opt into presentation. Reading a response never consumes its body.
+ * A caller that answers storage refusals itself passes "caller", and its 413
+ * reaches no listener. */
+export async function observeOperationResponse(
+ response: Response,
+ storageFull: "wall" | "caller" = "wall"
+): Promise<Response> {
if (![401, 402, 413].includes(response.status)) return response;
const failure = operationFailure(response.status, await response.clone().json().catch(() => null));
- if (failure) for (const listener of listeners) listener(failure);
+ if (!failure) return response;
+ if (failure.code === "storage_quota_exceeded" && storageFull === "caller") return response;
+ for (const listener of listeners) listener(failure);
return response;
}
diff --git a/site/src/cut/lib/projectMove.ts b/site/src/cut/lib/projectMove.ts
new file mode 100644
index 00000000..c9a05dd4
--- /dev/null
+++ b/site/src/cut/lib/projectMove.ts
@@ -0,0 +1,43 @@
+// Moving the open project to another residency: the top bar's Move to Cloud
+// and the storage wall's move to this computer. The copy lands first, which is
+// what makes deleting the original safe.
+import { backendFor, type Residency } from "./residency";
+import { clearProjectThreads } from "./chatThreads";
+import { dropLocalProjectCopy } from "./mediaSync";
+import { copyProjectAcross } from "./projectCopy";
+import { useEditor } from "./store";
+
+// How long the move waits for a pending autosave, so the copy reads the
+// current cut: this many checks, this far apart.
+const SAVE_CHECKS = 40;
+const SAVE_CHECK_MS = 250;
+
+/** Copies the open project to `to` and drops the original; returns the
+ * copy's id. */
+export async function moveOpenProject(
+ from: Residency,
+ to: Residency,
+ onProgress?: (done: number, total: number) => void
+): Promise<string> {
+ const projectId = useEditor.getState().projectId;
+ if (!projectId) {
+ throw new Error("No project is open.");
+ }
+ for (let i = 0; i < SAVE_CHECKS && useEditor.getState().saveState !== "saved"; i++) {
+ await new Promise((r) => setTimeout(r, SAVE_CHECK_MS));
+ }
+
+ const newId = await copyProjectAcross(backendFor(from), backendFor(to), projectId, { onProgress });
+ await backendFor(from)
+ .fetch(`/api/cut/projects/${projectId}`, { method: "DELETE" })
+ .catch(() => {});
+
+ // The chat history moved with the project; the old project's copy goes
+ // with the project itself, as does a cloud project's browser-store copy
+ // (an import the cloud refused waits there, and the copy took it along).
+ clearProjectThreads(projectId);
+ if (from === "cloud") {
+ await dropLocalProjectCopy(projectId).catch(() => {});
+ }
+ return newId;
+}
diff --git a/site/src/cut/lib/refMedia.ts b/site/src/cut/lib/refMedia.ts
index 99c2234c..f0577cf9 100644
--- a/site/src/cut/lib/refMedia.ts
+++ b/site/src/cut/lib/refMedia.ts
@@ -2,6 +2,8 @@
import { isCatalogRef, refFromAsset, refFromTextFile, type AssetRef } from "./assetRef";
import { tagChatAsset } from "./chatAssets";
+import { getBackend } from "./backend";
+import { checkImportRoom } from "./importRoom";
import { startUpload } from "./importQueue";
import {
enrichAsset,
@@ -318,6 +320,7 @@ export async function refsFromDroppedFiles(
opts?: { chatId?: string }
): Promise<AssetRef[]> {
const refs: AssetRef[] = [];
+ checkImportRoom(files.filter(isMediaFile));
for (const file of files) {
try {
if (isTextFile(file) && !isMediaFile(file)) {
@@ -325,7 +328,7 @@ export async function refsFromDroppedFiles(
continue;
}
const pending = await prepareImport(projectId, file);
- const asset = pending?.asset ?? (await importFileToProject(projectId, file));
+ const asset = pending?.asset ?? (await importFileToProject(projectId, file, getBackend(), "caller"));
if (!asset) continue;
useEditor.getState().addAsset(asset);
if (opts?.chatId) tagChatAsset(asset.id, opts.chatId);
diff --git a/site/src/cut/lib/storageQuota.test.ts b/site/src/cut/lib/storageQuota.test.ts
index 7c923c80..1e06f816 100644
--- a/site/src/cut/lib/storageQuota.test.ts
+++ b/site/src/cut/lib/storageQuota.test.ts
@@ -1,9 +1,11 @@
import { afterEach, expect, test } from "bun:test";
import {
clearStorageQuotaWall,
+ emitImportWall,
emitStorageQuota,
onStorageQuota,
openStorageUpgrade,
+ startImportWall,
type StorageQuotaDetail,
} from "./storageQuota";
@@ -11,6 +13,7 @@ const offs: (() => void)[] = [];
afterEach(() => {
for (const off of offs.splice(0)) off();
clearStorageQuotaWall();
+ startImportWall();
});
function listen() {
@@ -39,3 +42,33 @@ test("a deliberate click opens past a standing wall", () => {
openStorageUpgrade({ source: "pill" });
expect(seen.map((d) => d.source)).toEqual(["render", "pill"]);
});
+
+test("a drop meets the wall once, however many of its uploads are refused", () => {
+ const seen = listen();
+ startImportWall();
+ emitImportWall({ source: "import", needBytes: 300 });
+ clearStorageQuotaWall();
+ emitImportWall({ source: "quota-413" });
+ emitImportWall({ source: "quota-413" });
+ expect(seen.map((d) => d.source)).toEqual(["import"]);
+});
+
+test("the next drop meets the wall again", () => {
+ const seen = listen();
+ startImportWall();
+ emitImportWall({ source: "quota-413" });
+ clearStorageQuotaWall();
+ startImportWall();
+ emitImportWall({ source: "quota-413" });
+ expect(seen).toHaveLength(2);
+});
+
+test("a drop refused while another wall stands stays quiet once that one closes", () => {
+ const seen = listen();
+ startImportWall();
+ emitStorageQuota({ source: "pill" });
+ emitImportWall({ source: "quota-413" });
+ clearStorageQuotaWall();
+ emitImportWall({ source: "quota-413" });
+ expect(seen.map((d) => d.source)).toEqual(["pill"]);
+});
diff --git a/site/src/cut/lib/storageQuota.ts b/site/src/cut/lib/storageQuota.ts
index cb02eeed..fb90b85d 100644
--- a/site/src/cut/lib/storageQuota.ts
+++ b/site/src/cut/lib/storageQuota.ts
@@ -1,9 +1,12 @@
export type StorageQuotaDetail = {
bytes?: number;
quotaBytes?: number;
- /** What raised the wall: a rejected write, a render refused its space, or
- * the top bar's pill. */
- source: "quota-413" | "render" | "pill";
+ /** What a drop of files would add, when the check before its upload found
+ * it won't fit. */
+ needBytes?: number;
+ /** What raised the wall: a rejected write, a drop checked before its
+ * upload, a render refused its space, or the top bar's pill. */
+ source: "quota-413" | "import" | "render" | "pill";
grace?: { deadline: string; overBytes: number };
};
@@ -24,6 +27,23 @@ export function emitStorageQuota(detail: StorageQuotaDetail): boolean {
return true;
}
+// A drop of files meets the wall once. The check before its upload raises it,
+// or failing that the first refusal among its uploads; every later refusal
+// from the same drop (each file's claim, each retry) stays quiet, and the next
+// drop starts over.
+let importAnswered = false;
+
+/** A new drop of files: its first refusal is news again. */
+export function startImportWall(): void {
+ importAnswered = false;
+}
+
+/** Raise the wall for a drop of files, once per drop. */
+export function emitImportWall(detail: StorageQuotaDetail): void {
+ if (importAnswered) return;
+ if (emitStorageQuota(detail) || walled) importAnswered = true;
+}
+
/** Open the dialog from a deliberate click, past any standing wall. */
export function openStorageUpgrade(detail: StorageQuotaDetail): void {
walled = false;
diff --git a/site/src/cut/lib/upgrade.ts b/site/src/cut/lib/upgrade.ts
index 2d6d0e9a..8250dc07 100644
--- a/site/src/cut/lib/upgrade.ts
+++ b/site/src/cut/lib/upgrade.ts
@@ -15,6 +15,7 @@ export type UpgradeEntry =
| "project_limit"
| "storage_pill"
| "storage_refused"
+ | "storage_import"
| "render_refused"
| "onboarding_tour";
diff --git a/site/src/i18n/messages/.source-lock.json b/site/src/i18n/messages/.source-lock.json
index b16ecefe..45af5a03 100644
--- a/site/src/i18n/messages/.source-lock.json
+++ b/site/src/i18n/messages/.source-lock.json
@@ -76,6 +76,13 @@
"storage.graceDays": "ed6cc54e50ac",
"storage.proBody": "e71312927238",
"storage.moreTitle": "2693c538224e",
+ "storage.importTitle": "fb50c502bec5",
+ "storage.importNeed": "ef20b0350597",
+ "storage.keepLocal": "548757fd3955",
+ "storage.keepLocalBody": "da78fceedfc4",
+ "storage.moving": "618a29b1536e",
+ "storage.moveStarting": "09701b49542f",
+ "storage.moveFailed": "d09ed18008ad",
"subscribeBonus.daysLeft": "cd68d04927cc",
"subscribeBonus.hoursLeft": "e13c0d72cf69",
"subscribeBonus.minutesLeft": "689650c998da",
@@ -3108,6 +3115,13 @@
"storage.graceDays": "ed6cc54e50ac",
"storage.proBody": "e71312927238",
"storage.moreTitle": "2693c538224e",
+ "storage.importTitle": "fb50c502bec5",
+ "storage.importNeed": "ef20b0350597",
+ "storage.keepLocal": "548757fd3955",
+ "storage.keepLocalBody": "da78fceedfc4",
+ "storage.moving": "618a29b1536e",
+ "storage.moveStarting": "09701b49542f",
+ "storage.moveFailed": "d09ed18008ad",
"subscribeBonus.daysLeft": "cd68d04927cc",
"subscribeBonus.hoursLeft": "e13c0d72cf69",
"subscribeBonus.minutesLeft": "689650c998da",
@@ -6140,6 +6154,13 @@
"storage.graceDays": "ed6cc54e50ac",
"storage.proBody": "e71312927238",
"storage.moreTitle": "2693c538224e",
+ "storage.importTitle": "fb50c502bec5",
+ "storage.importNeed": "ef20b0350597",
+ "storage.keepLocal": "548757fd3955",
+ "storage.keepLocalBody": "da78fceedfc4",
+ "storage.moving": "618a29b1536e",
+ "storage.moveStarting": "09701b49542f",
+ "storage.moveFailed": "d09ed18008ad",
"subscribeBonus.daysLeft": "cd68d04927cc",
"subscribeBonus.hoursLeft": "e13c0d72cf69",
"subscribeBonus.minutesLeft": "689650c998da",
@@ -9172,6 +9193,13 @@
"storage.graceDays": "ed6cc54e50ac",
"storage.proBody": "e71312927238",
"storage.moreTitle": "2693c538224e",
+ "storage.importTitle": "fb50c502bec5",
+ "storage.importNeed": "ef20b0350597",
+ "storage.keepLocal": "548757fd3955",
+ "storage.keepLocalBody": "da78fceedfc4",
+ "storage.moving": "618a29b1536e",
+ "storage.moveStarting": "09701b49542f",
+ "storage.moveFailed": "d09ed18008ad",
"subscribeBonus.daysLeft": "cd68d04927cc",
"subscribeBonus.hoursLeft": "e13c0d72cf69",
"subscribeBonus.minutesLeft": "689650c998da",
@@ -12204,6 +12232,13 @@
"storage.graceDays": "ed6cc54e50ac",
"storage.proBody": "e71312927238",
"storage.moreTitle": "2693c538224e",
+ "storage.importTitle": "fb50c502bec5",
+ "storage.importNeed": "ef20b0350597",
+ "storage.keepLocal": "548757fd3955",
+ "storage.keepLocalBody": "da78fceedfc4",
+ "storage.moving": "618a29b1536e",
+ "storage.moveStarting": "09701b49542f",
+ "storage.moveFailed": "d09ed18008ad",
"subscribeBonus.daysLeft": "cd68d04927cc",
"subscribeBonus.hoursLeft": "e13c0d72cf69",
"subscribeBonus.minutesLeft": "689650c998da",
@@ -15236,6 +15271,13 @@
"storage.graceDays": "ed6cc54e50ac",
"storage.proBody": "e71312927238",
"storage.moreTitle": "2693c538224e",
+ "storage.importTitle": "fb50c502bec5",
+ "storage.importNeed": "ef20b0350597",
+ "storage.keepLocal": "548757fd3955",
+ "storage.keepLocalBody": "da78fceedfc4",
+ "storage.moving": "618a29b1536e",
+ "storage.moveStarting": "09701b49542f",
+ "storage.moveFailed": "d09ed18008ad",
"subscribeBonus.daysLeft": "cd68d04927cc",
"subscribeBonus.hoursLeft": "e13c0d72cf69",
"subscribeBonus.minutesLeft": "689650c998da",
@@ -18268,6 +18310,13 @@
"storage.graceDays": "ed6cc54e50ac",
"storage.proBody": "e71312927238",
"storage.moreTitle": "2693c538224e",
+ "storage.importTitle": "fb50c502bec5",
+ "storage.importNeed": "ef20b0350597",
+ "storage.keepLocal": "548757fd3955",
+ "storage.keepLocalBody": "da78fceedfc4",
+ "storage.moving": "618a29b1536e",
+ "storage.moveStarting": "09701b49542f",
+ "storage.moveFailed": "d09ed18008ad",
"subscribeBonus.daysLeft": "cd68d04927cc",
"subscribeBonus.hoursLeft": "e13c0d72cf69",
"subscribeBonus.minutesLeft": "689650c998da",
diff --git a/site/src/i18n/messages/de/billing.json b/site/src/i18n/messages/de/billing.json
index 705312ff..88d4f16c 100644
--- a/site/src/i18n/messages/de/billing.json
+++ b/site/src/i18n/messages/de/billing.json
@@ -43,7 +43,14 @@
"graceToday": "Dein Pro-Abo ist abgelaufen. Deine ältesten Cloud-Projekte werden heute gelöscht, sofern du kein Upgrade durchführst oder {bytes} freigibst.",
"graceDays": "Dein Pro-Abo ist abgelaufen. Deine ältesten Cloud-Projekte werden in {days, plural, one {# Tag} other {# Tagen}} gelöscht, sofern du kein Upgrade durchführst oder {bytes} freigibst.",
"proBody": "Gib Speicherplatz frei, indem du nicht mehr benötigte Projekte oder Medien löschst.",
- "moreTitle": "Hol dir mehr Cloud-Speicher"
+ "moreTitle": "Hol dir mehr Cloud-Speicher",
+ "importTitle": "Diese Dateien passen nicht in deinen Cloud-Speicher",
+ "importNeed": "Sie benötigen {need}, und du hast noch {free} von {quota} frei.",
+ "keepLocal": "Auf diesem Computer weiterbearbeiten",
+ "keepLocalBody": "{to, select, local {Speichere dieses Projekt stattdessen auf deinem Mac, ohne Cloud-Speicherlimits.} other {Speichere dieses Projekt stattdessen in diesem Browser, ohne Cloud-Speicherlimits.}}",
+ "moving": "{done} von {total} werden verschoben …",
+ "moveStarting": "Wird verschoben …",
+ "moveFailed": "Projekt konnte nicht verschoben werden."
},
"subscribeBonus": {
"daysLeft": "{count}d übrig",
diff --git a/site/src/i18n/messages/en/billing.json b/site/src/i18n/messages/en/billing.json
index 157ac50d..67e6c12b 100644
--- a/site/src/i18n/messages/en/billing.json
+++ b/site/src/i18n/messages/en/billing.json
@@ -43,7 +43,14 @@
"graceToday": "Your Pro plan ended. Your oldest cloud projects will be deleted today unless you upgrade or free {bytes}.",
"graceDays": "Your Pro plan ended. Your oldest cloud projects will be deleted in {days, plural, one {# day} other {# days}} unless you upgrade or free {bytes}.",
"proBody": "Free up space by deleting projects or media you no longer need.",
- "moreTitle": "Get more cloud storage"
+ "moreTitle": "Get more cloud storage",
+ "importTitle": "These files don't fit in your cloud storage",
+ "importNeed": "They take {need}, and you have {free} of {quota} free.",
+ "keepLocal": "Keep editing on this computer",
+ "keepLocalBody": "{to, select, local {Store this project on your Mac instead, with no cloud storage limits.} other {Store this project in this browser instead, with no cloud storage limits.}}",
+ "moving": "Moving {done} of {total}…",
+ "moveStarting": "Moving…",
+ "moveFailed": "Could not move the project."
},
"subscribeBonus": {
"daysLeft": "{count}d left",
diff --git a/site/src/i18n/messages/es/billing.json b/site/src/i18n/messages/es/billing.json
index 0dfc8344..a712575e 100644
--- a/site/src/i18n/messages/es/billing.json
+++ b/site/src/i18n/messages/es/billing.json
@@ -43,7 +43,14 @@
"graceToday": "Tu plan Pro terminó. Tus proyectos más antiguos en la nube se eliminarán hoy a menos que mejores tu plan o liberes {bytes}.",
"graceDays": "Tu plan Pro terminó. Tus proyectos más antiguos en la nube se eliminarán en {days, plural, one {# día} other {# días}} a menos que mejores tu plan o liberes {bytes}.",
"proBody": "Libera espacio eliminando proyectos o multimedia que ya no necesites.",
- "moreTitle": "Obtén más almacenamiento en la nube"
+ "moreTitle": "Obtén más almacenamiento en la nube",
+ "importTitle": "Estos archivos no caben en tu almacenamiento en la nube",
+ "importNeed": "Ocupan {need} y tienes {free} de {quota} libres.",
+ "keepLocal": "Sigue editando en esta computadora",
+ "keepLocalBody": "{to, select, local {En su lugar, guarda este proyecto en tu Mac, sin límites de almacenamiento en la nube.} other {En su lugar, guarda este proyecto en este navegador, sin límites de almacenamiento en la nube.}}",
+ "moving": "Moviendo {done} de {total}…",
+ "moveStarting": "Moviendo…",
+ "moveFailed": "No se pudo mover el proyecto."
},
"subscribeBonus": {
"daysLeft": "Quedan {count} d",
diff --git a/site/src/i18n/messages/fr/billing.json b/site/src/i18n/messages/fr/billing.json
index 3111b75a..2d0b9f7f 100644
--- a/site/src/i18n/messages/fr/billing.json
+++ b/site/src/i18n/messages/fr/billing.json
@@ -43,7 +43,14 @@
"graceToday": "Votre forfait Pro a pris fin. Vos projets cloud les plus anciens seront supprimés aujourd'hui, sauf si vous passez à l'offre supérieure ou libérez {bytes}.",
"graceDays": "Votre forfait Pro a pris fin. Vos projets cloud les plus anciens seront supprimés dans {days, plural, one {# jour} other {# jours}}, sauf si vous passez à l'offre supérieure ou libérez {bytes}.",
"proBody": "Libérez de l'espace en supprimant les projets ou médias dont vous n'avez plus besoin.",
- "moreTitle": "Obtenez plus d'espace de stockage cloud"
+ "moreTitle": "Obtenez plus d'espace de stockage cloud",
+ "importTitle": "Ces fichiers ne rentrent pas dans votre stockage cloud",
+ "importNeed": "Ils nécessitent {need}, et il vous reste {free} libres sur {quota}.",
+ "keepLocal": "Continuer à modifier sur cet ordinateur",
+ "keepLocalBody": "{to, select, local {Stockez plutôt ce projet sur votre Mac, sans limite de stockage dans le cloud.} other {Stockez plutôt ce projet dans ce navigateur, sans limite de stockage dans le cloud.}}",
+ "moving": "Déplacement de {done} sur {total}…",
+ "moveStarting": "Déplacement…",
+ "moveFailed": "Impossible de déplacer le projet."
},
"subscribeBonus": {
"daysLeft": "{count} j restants",
diff --git a/site/src/i18n/messages/ja/billing.json b/site/src/i18n/messages/ja/billing.json
index 12b4fd65..72cede00 100644
--- a/site/src/i18n/messages/ja/billing.json
+++ b/site/src/i18n/messages/ja/billing.json
@@ -43,7 +43,14 @@
"graceToday": "Proプランが終了しました。アップグレードするか{bytes}の空き容量を確保しない限り、最も古いクラウドプロジェクトは本日削除されます。",
"graceDays": "Proプランが終了しました。アップグレードするか{bytes}の空き容量を確保しない限り、最も古いクラウドプロジェクトは{days, plural, other {#日後}}に削除されます。",
"proBody": "不要になったプロジェクトやメディアを削除して空き容量を増やしてください。",
- "moreTitle": "クラウドストレージを増量"
+ "moreTitle": "クラウドストレージを増量",
+ "importTitle": "これらのファイルはクラウドストレージに収まりません",
+ "importNeed": "{need}必要ですが、空き容量は{quota}中{free}です。",
+ "keepLocal": "このコンピュータで編集を続ける",
+ "keepLocalBody": "{to, select, local {代わりにこのプロジェクトをMacに保存します。クラウドストレージの制限はありません。} other {代わりにこのプロジェクトをこのブラウザに保存します。クラウドストレージの制限はありません。}}",
+ "moving": "{total}中{done}を移動中…",
+ "moveStarting": "移動中…",
+ "moveFailed": "プロジェクトを移動できませんでした。"
},
"subscribeBonus": {
"daysLeft": "残り{count}日",
diff --git a/site/src/i18n/messages/ko/billing.json b/site/src/i18n/messages/ko/billing.json
index e05e0b7b..6ad71682 100644
--- a/site/src/i18n/messages/ko/billing.json
+++ b/site/src/i18n/messages/ko/billing.json
@@ -43,7 +43,14 @@
"graceToday": "Pro 요금제가 종료되었어요. 업그레이드하거나 {bytes}를 확보하지 않으면 가장 오래된 클라우드 프로젝트가 오늘 삭제돼요.",
"graceDays": "Pro 요금제가 종료되었어요. 업그레이드하거나 {bytes}를 확보하지 않으면 가장 오래된 클라우드 프로젝트가 {days, plural, other {#일 후에}} 삭제돼요.",
"proBody": "더 이상 필요 없는 프로젝트나 미디어를 삭제해 공간을 확보하세요.",
- "moreTitle": "클라우드 저장 공간 추가하기"
+ "moreTitle": "클라우드 저장 공간 추가하기",
+ "importTitle": "이 파일들을 클라우드 저장 공간에 담을 수 없어요",
+ "importNeed": "파일 크기는 {need}이지만, 남은 용량은 {quota} 중 {free}예요.",
+ "keepLocal": "이 컴퓨터에서 계속 편집하기",
+ "keepLocalBody": "{to, select, local {대신 클라우드 스토리지 제한 없이 이 프로젝트를 Mac에 저장하세요.} other {대신 클라우드 스토리지 제한 없이 이 프로젝트를 이 브라우저에 저장하세요.}}",
+ "moving": "이동 중 ({total} 중 {done})…",
+ "moveStarting": "이동 중…",
+ "moveFailed": "프로젝트를 이동하지 못했어요."
},
"subscribeBonus": {
"daysLeft": "{count}일 남음",
diff --git a/site/src/i18n/messages/pt-BR/billing.json b/site/src/i18n/messages/pt-BR/billing.json
index a75e8921..270a0252 100644
--- a/site/src/i18n/messages/pt-BR/billing.json
+++ b/site/src/i18n/messages/pt-BR/billing.json
@@ -43,7 +43,14 @@
"graceToday": "Seu plano Pro expirou. Seus projetos mais antigos na nuvem serão excluídos hoje, a menos que faça upgrade ou libere {bytes}.",
"graceDays": "Seu plano Pro expirou. Seus projetos mais antigos na nuvem serão excluídos em {days, plural, one {# dia} other {# dias}}, a menos que faça upgrade ou libere {bytes}.",
"proBody": "Libere espaço excluindo projetos ou mídias que não usa mais.",
- "moreTitle": "Obtenha mais armazenamento em nuvem"
+ "moreTitle": "Obtenha mais armazenamento em nuvem",
+ "importTitle": "Esses arquivos não cabem no seu armazenamento na nuvem",
+ "importNeed": "Eles ocupam {need}, e você tem {free} de {quota} livres.",
+ "keepLocal": "Continuar editando neste computador",
+ "keepLocalBody": "{to, select, local {Em vez disso, armazene este projeto no seu Mac, sem limites de armazenamento na nuvem.} other {Em vez disso, armazene este projeto neste navegador, sem limites de armazenamento na nuvem.}}",
+ "moving": "Movendo {done} de {total}…",
+ "moveStarting": "Movendo…",
+ "moveFailed": "Não foi possível mover o projeto."
},
"subscribeBonus": {
"daysLeft": "{count}d restantes",
diff --git a/site/src/i18n/messages/zh-CN/billing.json b/site/src/i18n/messages/zh-CN/billing.json
index 948f7b8d..7d1e5995 100644
--- a/site/src/i18n/messages/zh-CN/billing.json
+++ b/site/src/i18n/messages/zh-CN/billing.json
@@ -43,7 +43,14 @@
"graceToday": "你的 Pro 方案已结束。除非升级或释放 {bytes} 空间,否则你最早的云端项目将于今天被删除。",
"graceDays": "你的 Pro 方案已结束。除非升级或释放 {bytes} 空间,否则你最早的云端项目将在 {days, plural, other {# 天}}后被删除。",
"proBody": "删除不再需要的项目或媒体以释放空间。",
- "moreTitle": "获取更多云存储空间"
+ "moreTitle": "获取更多云存储空间",
+ "importTitle": "这些文件超出了你的云存储空间容量",
+ "importNeed": "它们需要占用 {need},而你在 {quota} 中仅剩 {free} 可用空间。",
+ "keepLocal": "在此电脑上继续编辑",
+ "keepLocalBody": "{to, select, local {改为将此项目保存在你的 Mac 上,无云存储限制。} other {改为将此项目保存在此浏览器中,无云存储限制。}}",
+ "moving": "正在移动 {done} / {total}…",
+ "moveStarting": "正在移动…",
+ "moveFailed": "无法移动项目。"
},
"subscribeBonus": {
"daysLeft": "还剩 {count} 天",
diff --git a/site/src/lib/analytics.ts b/site/src/lib/analytics.ts
index 281723a1..0a1fdae2 100644
--- a/site/src/lib/analytics.ts
+++ b/site/src/lib/analytics.ts
@@ -91,7 +91,11 @@ export type AnalyticsEvents = {
cut_storage_pill_clicked: void;
// The top bar's credits pill.
cut_credits_pill_clicked: { credits: number; dollars: number };
- cut_storage_upgrade_shown: { source: "quota-413" | "render" | "pill" };
+ cut_storage_upgrade_shown: { source: "quota-413" | "import" | "render" | "pill" };
+ // The storage wall's move of a cloud project to this computer: started, and
+ // landed (the copy opens next).
+ cut_storage_move_started: { to: "local" | "browser" | "cloud" };
+ cut_storage_move_done: { to: "local" | "browser" | "cloud" };
// The plans modal: shown, and closed without a checkout after `seconds` up.
// entry is the button or limit that raised it; intro is the open discount's
// percent, 0 for none.