mirror of
https://github.com/Untrivial-ai/agent-orchestrator.git
synced 2026-11-23 16:21:31 +08:00
feat(share): publish videos browsers can play (#8796)
* feat(share): publish videos browsers can play Videos were refused on this computer before anything was sent. Now only .avi and .mkv, which browsers cannot play, are refused here, with a message naming the formats that work. Any other video goes to the control plane, which publishes it once it serves videos and refuses it with 415 until then; that refusal still shows "Publishing videos is coming soon." A page's playable videos are no longer left out up front. A video the control plane refuses is skipped and the page publishes with its other files, recorded as missing so a later republish includes it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(share): don't publish .ogv videos .ogv is Theora, which Chrome and Firefox no longer play, so a shared one showed a player that could not start. It is refused before upload with the format message, as .avi and .mkv are; the control plane refuses it too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test(share): cover .ogv on the Publish button and in a page's files Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat(share): leave out a page's video over the size limit The control plane now refuses a video over its size limit with 413 artifact_share_video_too_large. For a video a page includes, the file is left out and the page publishes with the rest, as for a video the control plane does not serve; a link's own video shows the control plane's message. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs(contract): describe shared video publishing and playback The cloud contract still said share links refuse every video. A control plane that serves videos publishes them (but .ogv, .avi and .mkv), caps them by size with 413 artifact_share_video_too_large, redirects a video's contentUrl to a signed URL on a separate video host, and answers 503 artifact_share_video_unavailable for a published video while that host is off. Regenerates the cloud client's schema comments. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs(contract): name the uploaded files when a page leaves one out An update without files keeps the files the link served, so a client that leaves a refused video out must send the rest, or an empty list. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(share): play a shared video in the app's preview "Open in Orchestrator" shows a link shared with you in the Artifacts page's preview, which framed its contentUrl. A video's contentUrl redirects to a signed URL on the video host, and the frame loaded it as a document: a video stored without its type became a download the sandbox refuses, so nothing played. Play videos in a video element, as the link's web page does, and let media load from the share content origins, where the file host and video host live. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
0d22e2cd06
commit
20595bca93
28 files changed
+347
-85
No files matched your search
@@ -420,11 +420,17 @@ paths:
|
||||
address and serves the file under that name. The
|
||||
file goes in partCount parts of partSize bytes, the last one shorter:
|
||||
presign them with presignArtifactShareParts, PUT each, then
|
||||
finalizeArtifactShare. There is no file size limit. Nothing reaches
|
||||
storage when the upload is refused: 415
|
||||
artifact_share_type_unsupported for video, 409
|
||||
artifact_share_limit_reached for a new or restored document over the
|
||||
free plan's link limit. Paid plans have no link limit. An older
|
||||
finalizeArtifactShare. There is no file size limit but for video.
|
||||
Nothing reaches storage when the upload is refused: 415
|
||||
artifact_share_type_unsupported for a video the control plane does
|
||||
not serve (any video while it serves none; .ogv, .avi and .mkv, which
|
||||
browsers do not play, always), 413 artifact_share_video_too_large for
|
||||
a video over its size limit (1 GiB by default; the message names
|
||||
it), 409 artifact_share_limit_reached for a new or restored document
|
||||
over the free plan's link limit. A video's contentUrl answers 302 to
|
||||
a signed URL on a separate video host, which the browser's player
|
||||
follows; with the control plane's video host turned off, a video
|
||||
already published answers 503 artifact_share_video_unavailable. Paid plans have no link limit. An older
|
||||
control plane refuses an update with another name with 409
|
||||
artifact_share_name_changed. The images and other files an HTML
|
||||
page refers to by relative path are uploaded under this upload
|
||||
@@ -493,8 +499,8 @@ paths:
|
||||
createArtifactShareUpload) refers to by relative path, such as an
|
||||
image. The link serves it at path under its root, so
|
||||
<img src="images/a.png"> in the page loads the file whose path is
|
||||
images/a.png. Any file type but video may be included, and there is
|
||||
no file size limit. Its parts go as the page's do
|
||||
images/a.png. Any file type may be included, and there is no file
|
||||
size limit but for video, as for a link's own file. Its parts go as the page's do
|
||||
(presignArtifactShareParts, PUT each, abortArtifactShareUpload to
|
||||
cancel); finish it with completeArtifactShareFileUpload. 400
|
||||
invalid_request for a path that is absolute, has an empty, "." or
|
||||
@@ -502,8 +508,12 @@ paths:
|
||||
(raw, or under _ao/ or a first segment starting with ~); 429
|
||||
artifact_share_rate_limited past the hourly allowance. A control
|
||||
plane that predates included files answers 404. 415
|
||||
artifact_share_type_unsupported for video (.mp4, .m4v, .mov, .webm,
|
||||
.ogv, .avi, .mkv), as for a link's own file.
|
||||
artifact_share_type_unsupported for a video the control plane does
|
||||
not serve, and 413 artifact_share_video_too_large for one over its
|
||||
size limit, as for a link's own file: a client leaves that file out
|
||||
and publishes the page with the rest, naming them in
|
||||
finalizeArtifactShare's files (an empty list when none uploaded),
|
||||
since an update without files keeps the files the link served.
|
||||
requestBody:
|
||||
required: true
|
||||
content:
|
||||
@@ -2058,7 +2068,9 @@ paths:
|
||||
member of the organization or the session holds no file at path; 409
|
||||
artifact_share_source_changed when the session's file is no longer
|
||||
the sha256 the caller was shown (inspect it again); 415
|
||||
artifact_share_type_unsupported for a video.
|
||||
artifact_share_type_unsupported for a video the control plane does
|
||||
not serve, 413 artifact_share_video_too_large for one over its size
|
||||
limit, as for a local file (createArtifactShareUpload).
|
||||
|
||||
Only a person publishes: the route accepts only a signed-in account
|
||||
session, the bearer token of every user route. Worker, sandbox and
|
||||
|
||||
@@ -26,6 +26,8 @@ beforeEach(async () => {
|
||||
await fs.mkdir(path.join(dataDir, "artifacts", "sess-1", "docs"), { recursive: true });
|
||||
await fs.writeFile(path.join(dataDir, "artifacts", "sess-1", "docs", "report.html"), "<h1>quarterly</h1>!!");
|
||||
await fs.writeFile(path.join(dataDir, "artifacts", "sess-1", "clip.mp4"), "video");
|
||||
await fs.writeFile(path.join(dataDir, "artifacts", "sess-1", "clip.mkv"), "video");
|
||||
await fs.writeFile(path.join(dataDir, "artifacts", "sess-1", "clip.ogv"), "video");
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
@@ -38,7 +40,7 @@ const HOST_PROXY = "http://127.0.0.1:9/proxy-token";
|
||||
/** A remote host's artifact as its daemon serves it: bytes, and the modification time its tag names. */
|
||||
type HostArtifact = { body: string; mtimeNs: bigint; tag?: boolean; shortBy?: number; served?: () => void };
|
||||
|
||||
function setup(options: { token?: string | null; finalizeStatus?: number; finalizeCode?: string; shareStatus?: number; shareCode?: string; listStatus?: number; unreachable?: boolean; shares?: unknown[]; listGate?: Promise<void>; hostFiles?: Map<string, HostArtifact>; files?: boolean } = {}) {
|
||||
function setup(options: { token?: string | null; finalizeStatus?: number; finalizeCode?: string; shareStatus?: number; shareCode?: string; listStatus?: number; unreachable?: boolean; shares?: unknown[]; listGate?: Promise<void>; hostFiles?: Map<string, HostArtifact>; files?: boolean; refuseVideos?: boolean } = {}) {
|
||||
const handlers = new Map<string, (event: unknown, ...args: unknown[]) => unknown>();
|
||||
const requests: string[] = [];
|
||||
const bodies = new Map<string, unknown>();
|
||||
@@ -86,16 +88,23 @@ function setup(options: { token?: string | null; finalizeStatus?: number; finali
|
||||
if (options.listGate) await options.listGate;
|
||||
return json({ shares, limit: 3, used: 1 });
|
||||
}
|
||||
// A control plane that does not serve videos yet (its CDN is off) refuses them.
|
||||
const video = (name: string) => options.refuseVideos && /\.(mp4|webm)$/.test(name);
|
||||
if (pathname.endsWith("/uploads/files") && options.files) {
|
||||
const { path: served } = JSON.parse(String(init.body)) as { path: string };
|
||||
if (served === "") return json({ code: "invalid_request", message: "path" }, 400);
|
||||
if (video(served)) return json({ code: "artifact_share_type_unsupported", message: "Videos can't be included in a shared page yet." }, 415);
|
||||
return json({ uploadToken: `file:${served}`, partSize: 1024, partCount: 1 }, 201);
|
||||
}
|
||||
if (pathname.endsWith("/uploads/files/complete") && options.files) {
|
||||
const { uploadToken } = JSON.parse(String(init.body)) as { uploadToken: string };
|
||||
return json({ fileToken: `ft:${uploadToken.slice("file:".length)}`, path: uploadToken.slice("file:".length), expiresAt: "" });
|
||||
}
|
||||
if (pathname.endsWith("/uploads")) return json({ uploadToken: "tok", partSize: 1024, partCount: 1 }, 201);
|
||||
if (pathname.endsWith("/uploads")) {
|
||||
const { name } = JSON.parse(String(init.body)) as { name: string };
|
||||
if (video(name)) return json({ code: "artifact_share_type_unsupported", message: "Sharing videos is coming soon." }, 415);
|
||||
return json({ uploadToken: "tok", partSize: 1024, partCount: 1 }, 201);
|
||||
}
|
||||
if (pathname.endsWith("/uploads/parts")) return json({ parts: [{ partNumber: 1, method: "PUT", url: "https://s3.test/p", headers: {}, size: 20 }] });
|
||||
if (pathname === "/p") return new Response("", { headers: { etag: '"e1"' } });
|
||||
if (pathname.endsWith("/finalize")) {
|
||||
@@ -312,9 +321,24 @@ describe("cloudShare IPC", () => {
|
||||
});
|
||||
|
||||
it("turns refusals into results the dialog can act on", async () => {
|
||||
const video = setup();
|
||||
await expect(video.invoke("cloudShare:publish", { ...video.file, path: "clip.mp4" })).resolves.toMatchObject({ status: "unsupported" });
|
||||
expect(video.requests).toEqual([]);
|
||||
// A video browsers cannot play is refused before anything is sent.
|
||||
const unplayable = setup();
|
||||
for (const name of ["clip.mkv", "clip.ogv"]) {
|
||||
await expect(unplayable.invoke("cloudShare:inspect", { ...unplayable.file, path: name })).resolves.toMatchObject({ unsupported: true });
|
||||
await expect(unplayable.invoke("cloudShare:publish", { ...unplayable.file, path: name })).resolves.toEqual({
|
||||
status: "unsupported", message: "This video format can't be played in a browser. Use MP4, MOV or WebM.",
|
||||
});
|
||||
}
|
||||
expect(unplayable.requests).toEqual([]);
|
||||
|
||||
// A playable video goes to the control plane, which refuses it while it serves none.
|
||||
const video = setup({ refuseVideos: true });
|
||||
await expect(video.invoke("cloudShare:inspect", { ...video.file, path: "clip.mp4" })).resolves.toMatchObject({ unsupported: false });
|
||||
await expect(video.publish({ ...video.file, path: "clip.mp4" })).resolves.toEqual({ status: "unsupported", message: "Sharing videos is coming soon." });
|
||||
|
||||
// One that serves videos publishes it as any other file.
|
||||
const served = setup();
|
||||
await expect(served.publish({ ...served.file, path: "clip.mp4" })).resolves.toMatchObject({ status: "published" });
|
||||
|
||||
const limit = setup({ finalizeStatus: 409, finalizeCode: "artifact_share_limit_reached" });
|
||||
await expect(limit.publish()).resolves.toEqual({
|
||||
@@ -387,9 +411,13 @@ describe("cloudShare IPC", () => {
|
||||
await expect(unseen.invoke("cloudShare:publish", unseen.cloudFile)).resolves.toMatchObject({ status: "changed" });
|
||||
expect(unseen.requests.filter((request) => request.endsWith("/share"))).toEqual([]);
|
||||
|
||||
const video = setup();
|
||||
await expect(video.invoke("cloudShare:publish", { ...video.cloudFile, path: "demo.mp4" })).resolves.toMatchObject({ status: "unsupported" });
|
||||
expect(video.requests).toEqual([]);
|
||||
const unplayable = setup();
|
||||
await expect(unplayable.invoke("cloudShare:publish", { ...unplayable.cloudFile, path: "demo.mkv" })).resolves.toMatchObject({ status: "unsupported" });
|
||||
expect(unplayable.requests).toEqual([]);
|
||||
|
||||
// A playable one is the control plane's to refuse.
|
||||
const video = setup({ shareStatus: 415, shareCode: "artifact_share_type_unsupported" });
|
||||
await expect(video.publish(video.cloudFile)).resolves.toEqual({ status: "unsupported", message: "Refused." });
|
||||
|
||||
const signedOut = setup({ token: null });
|
||||
await expect(signedOut.invoke("cloudShare:publish", signedOut.cloudFile)).resolves.toEqual({ status: "signed_out" });
|
||||
@@ -407,19 +435,35 @@ describe("cloudShare IPC", () => {
|
||||
await fs.writeFile(path.join(docs, "photo.jpg"), "jpeg");
|
||||
await fs.writeFile(path.join(docs, "clip.webm"), "video");
|
||||
await fs.writeFile(path.join(docs, "report.html"), `<img src="images/chart.png"><img src="photo.jpg"><video src="clip.webm"></video><img src="../clip.mp4"><img src="https://cdn.test/x.png">`);
|
||||
const { publish, requests, bodies, sent } = setup({ files: true });
|
||||
const { publish, requests, bodies, sent, records } = setup({ files: true, refuseVideos: true });
|
||||
const result = await publish();
|
||||
// The video is refused by a control plane that serves none yet; the page goes without it.
|
||||
expect(result).toMatchObject({ status: "published", pageFiles: { included: 2, skipped: 2, videos: 1, unsupported: false } });
|
||||
const starts = requests.filter((request) => request.endsWith("/uploads/files"));
|
||||
expect(starts).toHaveLength(2);
|
||||
expect(starts).toHaveLength(3);
|
||||
// Recorded as missing, so the control plane taking videos later offers a republish.
|
||||
expect((await records.publishedPageFiles(JSON.stringify(["https://cp.test", "sess-1", "docs/report.html"])))?.["docs/clip.webm"]).toBe("");
|
||||
expect(bodies.get("/api/cloud/v1/me/artifact-shares/finalize")).toMatchObject({ files: [{ fileToken: "ft:images/chart.png" }, { fileToken: "ft:photo.jpg" }] });
|
||||
// Progress ends at the page's and its files' bytes, copied and sent.
|
||||
const last = sent.at(-1) as { sentBytes: number; totalBytes: number };
|
||||
const pageSize = (await fs.stat(path.join(docs, "report.html"))).size;
|
||||
expect(last).toMatchObject({ sentBytes: (pageSize + 3 + 4) * 2, totalBytes: (pageSize + 3 + 4) * 2 });
|
||||
expect(last).toMatchObject({ sentBytes: (pageSize + 3 + 4 + 5) * 2, totalBytes: (pageSize + 3 + 4 + 5) * 2 });
|
||||
expect(await snapshots()).toEqual([]);
|
||||
});
|
||||
|
||||
it("uploads a page's video with it once the control plane serves videos", async () => {
|
||||
const docs = path.join(dataDir, "artifacts", "sess-1", "docs");
|
||||
await fs.writeFile(path.join(docs, "clip.webm"), "video");
|
||||
await fs.writeFile(path.join(docs, "take.mkv"), "video");
|
||||
await fs.writeFile(path.join(docs, "theora.ogv"), "video");
|
||||
await fs.writeFile(path.join(docs, "report.html"), `<video src="clip.webm"></video><video src="take.mkv"></video><video src="theora.ogv"></video>`);
|
||||
const { publish, bodies, requests } = setup({ files: true });
|
||||
// A format browsers cannot play is left out, though not as a video the control plane refused.
|
||||
await expect(publish()).resolves.toMatchObject({ status: "published", pageFiles: { included: 1, skipped: 2, videos: 0, unsupported: false } });
|
||||
expect(requests.filter((request) => request.endsWith("/uploads/files"))).toHaveLength(1);
|
||||
expect(bodies.get("/api/cloud/v1/me/artifact-shares/finalize")).toMatchObject({ files: [{ fileToken: "ft:clip.webm" }] });
|
||||
});
|
||||
|
||||
it("leaves out a page's file that is removed before it is copied, and still publishes the page", async () => {
|
||||
const docs = path.join(dataDir, "artifacts", "sess-1", "docs");
|
||||
await fs.writeFile(path.join(docs, "photo.jpg"), "jpeg");
|
||||
@@ -453,9 +497,9 @@ describe("cloudShare IPC", () => {
|
||||
|
||||
it("says what a page left out though the control plane cannot take its files", async () => {
|
||||
const docs = path.join(dataDir, "artifacts", "sess-1", "docs");
|
||||
await fs.writeFile(path.join(docs, "report.html"), `<video src="clip.mp4"></video><img src="../outside.png">`);
|
||||
await fs.writeFile(path.join(docs, "report.html"), `<video src="clip.mkv"></video><img src="../outside.png">`);
|
||||
const { publish } = setup();
|
||||
await expect(publish()).resolves.toMatchObject({ status: "published", pageFiles: { included: 0, skipped: 2, videos: 1, unsupported: false } });
|
||||
await expect(publish()).resolves.toMatchObject({ status: "published", pageFiles: { included: 0, skipped: 2, videos: 0, unsupported: false } });
|
||||
});
|
||||
|
||||
it("offers to republish a page when a file it uses changes, appears or goes, though the page did not", async () => {
|
||||
|
||||
@@ -13,6 +13,7 @@ import type { IpcMain, IpcMainInvokeEvent } from "electron";
|
||||
import {
|
||||
artifactShareUrl,
|
||||
CLOUD_SHARE_PROGRESS_CHANNEL,
|
||||
isUnplayableShareVideo,
|
||||
sameShareFingerprint,
|
||||
type CloudShareAccess,
|
||||
type CloudShareFile,
|
||||
@@ -113,11 +114,12 @@ export interface CloudShareIpcDeps extends CloudShareApi {
|
||||
fetchHost: HostFetch;
|
||||
}
|
||||
|
||||
const VIDEO_EXTENSIONS = new Set([".mp4", ".m4v", ".mov", ".webm", ".ogv", ".avi", ".mkv"]);
|
||||
|
||||
function isVideo(name: string): boolean {
|
||||
return VIDEO_EXTENSIONS.has(path.extname(name).toLowerCase());
|
||||
}
|
||||
/**
|
||||
* Refuses a video browsers cannot play before anything is uploaded. Any other
|
||||
* video goes to the control plane, which refuses it (415, shown as coming
|
||||
* soon) while it does not serve videos.
|
||||
*/
|
||||
const UNPLAYABLE_VIDEO_MESSAGE = "This video format can't be played in a browser. Use MP4, MOV or WebM.";
|
||||
|
||||
function accessArgument(value: unknown): CloudShareAccess | undefined {
|
||||
if (value === undefined) return undefined;
|
||||
@@ -316,7 +318,7 @@ export function registerCloudShareIpc(deps: CloudShareIpcDeps): void {
|
||||
return {
|
||||
name,
|
||||
...(listed ? { size: listed.size } : {}),
|
||||
unsupported: isVideo(name),
|
||||
unsupported: isUnplayableShareVideo(name),
|
||||
fingerprint: listed?.sha256 ?? file.fingerprint ?? "",
|
||||
...(shareId ? { shareId } : {}),
|
||||
...(publishedFingerprint ? { publishedFingerprint } : {}),
|
||||
@@ -324,7 +326,7 @@ export function registerCloudShareIpc(deps: CloudShareIpcDeps): void {
|
||||
};
|
||||
|
||||
const publishCloudFile = async (file: CloudSessionShareFile): Promise<CloudSharePublishResult> => {
|
||||
if (isVideo(file.path)) return { status: "unsupported", message: "Sharing videos is coming soon." };
|
||||
if (isUnplayableShareVideo(file.path)) return { status: "unsupported", message: UNPLAYABLE_VIDEO_MESSAGE };
|
||||
if (!(await deps.getToken())) return { status: "signed_out" };
|
||||
if (!file.fingerprint) return { status: "changed", inspection: await inspectCloudFile(file, true) };
|
||||
try {
|
||||
@@ -364,7 +366,7 @@ export function registerCloudShareIpc(deps: CloudShareIpcDeps): void {
|
||||
return {
|
||||
name: info.name,
|
||||
size: info.size,
|
||||
unsupported: isVideo(info.name),
|
||||
unsupported: isUnplayableShareVideo(info.name),
|
||||
fingerprint: info.fingerprint,
|
||||
...(shareId ? { shareId } : {}),
|
||||
...(publishedFingerprint ? { publishedFingerprint } : {}),
|
||||
@@ -375,7 +377,7 @@ export function registerCloudShareIpc(deps: CloudShareIpcDeps): void {
|
||||
// uploaded as a local file is. Downloading is the first half of the
|
||||
// progress, uploading the second.
|
||||
const publishHostFile = async (file: CloudHostShareFile, sender: IpcMainInvokeEvent["sender"], controller: AbortController): Promise<CloudSharePublishResult> => {
|
||||
if (isVideo(file.path)) return { status: "unsupported", message: "Sharing videos is coming soon." };
|
||||
if (isUnplayableShareVideo(file.path)) return { status: "unsupported", message: UNPLAYABLE_VIDEO_MESSAGE };
|
||||
if (!(await deps.getToken())) return { status: "signed_out" };
|
||||
const located = hostFile(file);
|
||||
const key = await hostRecordKey(file, located.relativePath);
|
||||
@@ -442,7 +444,7 @@ export function registerCloudShareIpc(deps: CloudShareIpcDeps): void {
|
||||
return {
|
||||
name: resolved.name,
|
||||
size: resolved.size,
|
||||
unsupported: isVideo(resolved.name),
|
||||
unsupported: isUnplayableShareVideo(resolved.name),
|
||||
fingerprint: await statShareFile(resolved),
|
||||
...(shareId ? { shareId } : {}),
|
||||
...(publishedFingerprint ? { publishedFingerprint } : {}),
|
||||
@@ -542,7 +544,7 @@ export function registerCloudShareIpc(deps: CloudShareIpcDeps): void {
|
||||
const fileSnapshots: ShareSnapshot[] = [];
|
||||
try {
|
||||
const resolved = await resolveShareFile(deps.daemonDataDir(), file.sessionId, file.path);
|
||||
if (isVideo(resolved.name)) return { status: "unsupported", message: "Sharing videos is coming soon." };
|
||||
if (isUnplayableShareVideo(resolved.name)) return { status: "unsupported", message: UNPLAYABLE_VIDEO_MESSAGE };
|
||||
if (!(await deps.getToken())) return { status: "signed_out" };
|
||||
const progress = (sentBytes: number, totalBytes: number) => {
|
||||
if (!sender.isDestroyed()) sender.send(CLOUD_SHARE_PROGRESS_CHANNEL, { sessionId: file.sessionId, path: file.path, sentBytes, totalBytes });
|
||||
@@ -586,12 +588,14 @@ export function registerCloudShareIpc(deps: CloudShareIpcDeps): void {
|
||||
if (!file.fingerprint || !sameShareFingerprint(taken.fingerprint, file.fingerprint)) return await changed();
|
||||
if (controller.signal.aborted) return { status: "cancelled" };
|
||||
let copied = taken.size;
|
||||
let pageFiles: { files: PageFileSnapshot[]; skipped: PageFileSkip[]; fingerprints: Record<string, string> } | undefined;
|
||||
let pageFiles: { files: PageFileSnapshot[]; skipped: PageFileSkip[]; fingerprints: Record<string, string>; referenced: Map<string, string> } | undefined;
|
||||
if (found) {
|
||||
const files: PageFileSnapshot[] = [];
|
||||
const skipped = [...found.skipped];
|
||||
// What each file held as it was copied, and what was missing, so a later change shows.
|
||||
const fingerprints: Record<string, string> = {};
|
||||
// Which file the page names by each included path.
|
||||
const referenced = new Map<string, string>();
|
||||
for (const skip of found.skipped) if (skip.relativePath) fingerprints[skip.relativePath] = "";
|
||||
for (const used of found.files) {
|
||||
if (controller.signal.aborted) return { status: "cancelled" };
|
||||
@@ -603,6 +607,7 @@ export function registerCloudShareIpc(deps: CloudShareIpcDeps): void {
|
||||
});
|
||||
fileSnapshots.push(copy);
|
||||
files.push({ path: used.path, snapshot: copy });
|
||||
referenced.set(used.path, used.referencedPath);
|
||||
fingerprints[used.referencedPath] = pageFileVersion(used.file, copy.fingerprint);
|
||||
} catch (error) {
|
||||
// A file gone or rewritten while it was copied is left out, not the page.
|
||||
@@ -612,7 +617,7 @@ export function registerCloudShareIpc(deps: CloudShareIpcDeps): void {
|
||||
}
|
||||
copied = before + used.file.size;
|
||||
}
|
||||
pageFiles = { files, skipped, fingerprints };
|
||||
pageFiles = { files, skipped, fingerprints, referenced };
|
||||
}
|
||||
// The document is the file's path in its session's artifacts, in its project.
|
||||
const folder = path.posix.dirname(resolved.relativePath);
|
||||
@@ -627,6 +632,19 @@ export function registerCloudShareIpc(deps: CloudShareIpcDeps): void {
|
||||
emails: file.emails,
|
||||
...(pageFiles ? { page: { files: pageFiles.files } } : {}),
|
||||
}, (sentBytes) => progress(copied + sentBytes, total), controller.signal);
|
||||
// A video the control plane refused was left out, as a missing file is.
|
||||
if (pageFiles && result.pageFiles) {
|
||||
const left = [
|
||||
...result.pageFiles.refusedVideos.map((refused) => [refused, "video"] as const),
|
||||
...result.pageFiles.tooLargeVideos.map((refused) => [refused, "too_large"] as const),
|
||||
];
|
||||
for (const [refused, reason] of left) {
|
||||
const relativePath = pageFiles.referenced.get(refused);
|
||||
pageFiles.skipped.push({ reference: refused, reason, ...(relativePath ? { relativePath } : {}) });
|
||||
// A video refused now is offered again once the control plane takes it.
|
||||
if (relativePath && reason === "video") pageFiles.fingerprints[relativePath] = "";
|
||||
}
|
||||
}
|
||||
// The link serves the page's files only when the control plane took them.
|
||||
const served = pageFiles && result.pageFiles && !result.pageFiles.unsupported ? pageFiles.fingerprints : undefined;
|
||||
await deps.records.set(key, result.share.id, taken.fingerprint, artifactShareUrl(result.share), shareAccess(result.share), served);
|
||||
|
||||
@@ -7,7 +7,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
vi.mock("electron", () => ({ ipcMain: {} }));
|
||||
vi.mock("./cloud-auth", () => ({ getCloudAccessToken: vi.fn(async () => "token-1") }));
|
||||
|
||||
import { collectPageFiles, isSharePage, isShareVideo, MAX_PAGE_FILES, pageFileReferences, servedPath } from "./cloud-share-page-files";
|
||||
import { collectPageFiles, isSharePage, MAX_PAGE_FILES, pageFileReferences, servedPath } from "./cloud-share-page-files";
|
||||
|
||||
describe("pageFileReferences", () => {
|
||||
it("finds what the page's markup and styles load", () => {
|
||||
@@ -61,10 +61,9 @@ describe("servedPath", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("page and video names", () => {
|
||||
it("tells a page and a video by extension", () => {
|
||||
describe("page names", () => {
|
||||
it("tells a page by extension", () => {
|
||||
expect([isSharePage("a.html"), isSharePage("A.HTM"), isSharePage("a.svg")]).toEqual([true, true, false]);
|
||||
expect([isShareVideo("a.MP4"), isShareVideo("x/a.webm"), isShareVideo("a.png")]).toEqual([true, true, false]);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -90,15 +89,17 @@ describe("collectPageFiles", () => {
|
||||
|
||||
it("includes the files beside the page once each and says what it leaves out", async () => {
|
||||
const html = `<img src="images/a.png"><img src="./images/a.png"><img src="b.jpg"><img src="report.html">
|
||||
<video src="clip.mp4" poster="b.jpg"></video><img src="../top.png"><img src="missing.png"><img src="link.png">
|
||||
<video src="clip.mp4" poster="b.jpg"></video><video src="take.mkv"></video><video src="theora.ogv"></video><img src="../top.png"><img src="missing.png"><img src="link.png">
|
||||
<img src="https://cdn.test/x.png"><img src="_ao/x.png">`;
|
||||
const { files, skipped } = await collectPageFiles(dataDir, "sess-1", "docs/report.html", html);
|
||||
expect(files.map((file) => [file.path, file.file.relativePath, file.file.size])).toEqual([
|
||||
["images/a.png", "docs/images/a.png", 1],
|
||||
["b.jpg", "docs/b.jpg", 2],
|
||||
["clip.mp4", "docs/clip.mp4", 5],
|
||||
]);
|
||||
expect(skipped).toEqual([
|
||||
{ reference: "clip.mp4", reason: "video" },
|
||||
{ reference: "take.mkv", reason: "video_format" },
|
||||
{ reference: "theora.ogv", reason: "video_format" },
|
||||
{ reference: "../top.png", reason: "outside" },
|
||||
{ reference: "missing.png", reason: "missing", relativePath: "docs/missing.png" },
|
||||
{ reference: "link.png", reason: "outside" },
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
*/
|
||||
|
||||
import path from "node:path";
|
||||
import { isUnplayableShareVideo } from "../shared/cloud-share";
|
||||
import { CloudShareError, resolveShareFile, type ResolvedShareFile } from "./cloud-share";
|
||||
|
||||
/** The most files a link serves beside its own (the control plane's limit). */
|
||||
@@ -23,8 +24,12 @@ export const MAX_PAGE_FILES = 200;
|
||||
|
||||
/** Why a file the page uses is not included. */
|
||||
export type PageFileSkipReason =
|
||||
/** Video is not shared yet. */
|
||||
/** A video the control plane refused: it does not serve videos yet. */
|
||||
| "video"
|
||||
/** A video in a format browsers do not play (isUnplayableShareVideo). */
|
||||
| "video_format"
|
||||
/** A video over the control plane's size limit. */
|
||||
| "too_large"
|
||||
/** Outside the page's folder, by "..", or an absolute path. */
|
||||
| "outside"
|
||||
/** Not a file in the session's artifacts. */
|
||||
@@ -65,17 +70,11 @@ export interface PageReference {
|
||||
svgUse?: true;
|
||||
}
|
||||
|
||||
const VIDEO_EXTENSIONS = new Set([".mp4", ".m4v", ".mov", ".webm", ".ogv", ".avi", ".mkv"]);
|
||||
|
||||
/** Whether a file is shared as a page whose files go with it. */
|
||||
export function isSharePage(name: string): boolean {
|
||||
return /\.html?$/i.test(name);
|
||||
}
|
||||
|
||||
export function isShareVideo(name: string): boolean {
|
||||
return VIDEO_EXTENSIONS.has(path.extname(name).toLowerCase());
|
||||
}
|
||||
|
||||
const ENTITIES: Record<string, string> = { amp: "&", quot: '"', apos: "'", lt: "<", gt: ">" };
|
||||
|
||||
function decodeEntities(value: string): string {
|
||||
@@ -237,8 +236,9 @@ export async function collectPageFiles(
|
||||
continue;
|
||||
}
|
||||
const served = result.path;
|
||||
if (isShareVideo(served)) {
|
||||
skipped.push({ reference, reason: "video" });
|
||||
// A playable video goes to the control plane, which may still refuse it.
|
||||
if (isUnplayableShareVideo(served)) {
|
||||
skipped.push({ reference, reason: "video_format" });
|
||||
continue;
|
||||
}
|
||||
const relative = folder === "." ? served : `${folder}/${served}`;
|
||||
|
||||
@@ -173,7 +173,7 @@ interface Call {
|
||||
body?: string | Uint8Array;
|
||||
}
|
||||
|
||||
function fakeControlPlane(partSize: number, options: { failPart?: number; finalizeError?: { status: number; code: string }; files?: boolean; failFile?: string } = {}) {
|
||||
function fakeControlPlane(partSize: number, options: { failPart?: number; finalizeError?: { status: number; code: string }; files?: boolean; failFile?: string; refuseVideos?: boolean; maxVideoBytes?: number } = {}) {
|
||||
const calls: Call[] = [];
|
||||
const stored = new Map<number, Uint8Array>();
|
||||
// An included file's bytes, by the path it is served at.
|
||||
@@ -195,6 +195,10 @@ function fakeControlPlane(partSize: number, options: { failPart?: number; finali
|
||||
const request = JSON.parse(body as string) as { uploadToken: string; path: string; size: number };
|
||||
if (request.uploadToken !== "tok") return json({ code: "artifact_share_upload_invalid", message: "bad" }, 400);
|
||||
if (request.path === "") return json({ code: "invalid_request", message: "path" }, 400);
|
||||
if (options.refuseVideos && request.path.endsWith(".mp4")) return json({ code: "artifact_share_type_unsupported", message: "Videos can't be included in a shared page yet." }, 415);
|
||||
if (options.maxVideoBytes !== undefined && request.path.endsWith(".mp4") && request.size > options.maxVideoBytes) {
|
||||
return json({ code: "artifact_share_video_too_large", message: "Videos over 1 GiB can't be shared." }, 413);
|
||||
}
|
||||
return json({ uploadToken: `file:${request.path}`, partSize, partCount: Math.max(1, Math.ceil(request.size / partSize)) }, 201);
|
||||
}
|
||||
if (pathname.endsWith("/uploads/files/complete") && options.files) {
|
||||
@@ -361,7 +365,7 @@ describe("uploadShare", () => {
|
||||
const control = fakeControlPlane(4, { files: true });
|
||||
const progress: number[] = [];
|
||||
const result = await uploadShare(control.api, { baseUrl: "https://cp.test", snapshot: page, name: "page.html", project: "p", feature: "f", page: { files } }, (sent) => progress.push(sent));
|
||||
expect(result.pageFiles).toEqual({ included: 2, unsupported: false });
|
||||
expect(result.pageFiles).toEqual({ included: 2, unsupported: false, refusedVideos: [], tooLargeVideos: [] });
|
||||
expect(Object.fromEntries(control.files)).toEqual({ "images/a.png": "aaaaaa", "b.svg": "bb" });
|
||||
const starts = control.calls.filter((call) => call.url.endsWith("/uploads/files")).map((call) => JSON.parse(call.body as string));
|
||||
expect(starts).toEqual([
|
||||
@@ -374,11 +378,49 @@ describe("uploadShare", () => {
|
||||
expect(progress.at(-1)).toBe(6 + 2 + 15);
|
||||
});
|
||||
|
||||
it("leaves out a video the control plane refuses and publishes the page with the rest", async () => {
|
||||
const page = await snapshotOf("<img src=a.png><video src=clip.mp4>", "page.html");
|
||||
const files = [
|
||||
{ path: "clip.mp4", snapshot: await snapshotOf("vvvv", "clip.mp4") },
|
||||
{ path: "a.png", snapshot: await snapshotOf("aa", "a.png") },
|
||||
];
|
||||
const control = fakeControlPlane(4, { files: true, refuseVideos: true });
|
||||
const progress: number[] = [];
|
||||
const result = await uploadShare(control.api, { baseUrl: "https://cp.test", snapshot: page, name: "page.html", project: "p", feature: "f", page: { files } }, (sent) => progress.push(sent));
|
||||
expect(result.pageFiles).toEqual({ included: 1, unsupported: false, refusedVideos: ["clip.mp4"], tooLargeVideos: [] });
|
||||
expect(Object.fromEntries(control.files)).toEqual({ "a.png": "aa" });
|
||||
const finalize = JSON.parse(control.calls.find((call) => call.url.endsWith("/finalize"))!.body as string);
|
||||
expect(finalize.files).toEqual([{ fileToken: "ft:a.png" }]);
|
||||
// The refused video still counts toward progress, so it reaches the total.
|
||||
expect(progress.at(-1)).toBe(page.size + 4 + 2);
|
||||
});
|
||||
|
||||
it("leaves out a page's video over the control plane's size limit and publishes the rest", async () => {
|
||||
const page = await snapshotOf("<img src=a.png><video src=clip.mp4>", "page.html");
|
||||
const files = [
|
||||
{ path: "clip.mp4", snapshot: await snapshotOf("vvvvvvvv", "clip.mp4") },
|
||||
{ path: "a.png", snapshot: await snapshotOf("aa", "a.png") },
|
||||
];
|
||||
const control = fakeControlPlane(4, { files: true, maxVideoBytes: 4 });
|
||||
const result = await uploadShare(control.api, { baseUrl: "https://cp.test", snapshot: page, name: "page.html", project: "p", feature: "f", page: { files } }, () => undefined);
|
||||
expect(result.pageFiles).toEqual({ included: 1, unsupported: false, refusedVideos: [], tooLargeVideos: ["clip.mp4"] });
|
||||
expect(Object.fromEntries(control.files)).toEqual({ "a.png": "aa" });
|
||||
});
|
||||
|
||||
it("uploads a page's video when the control plane takes it", async () => {
|
||||
const page = await snapshotOf("<video src=clip.mp4>", "page.html");
|
||||
const files = [{ path: "clip.mp4", snapshot: await snapshotOf("vvvv", "clip.mp4") }];
|
||||
const control = fakeControlPlane(4, { files: true });
|
||||
const result = await uploadShare(control.api, { baseUrl: "https://cp.test", snapshot: page, name: "page.html", project: "p", feature: "f", page: { files } }, () => undefined);
|
||||
expect(result.pageFiles).toEqual({ included: 1, unsupported: false, refusedVideos: [], tooLargeVideos: [] });
|
||||
expect(Object.fromEntries(control.files)).toEqual({ "clip.mp4": "vvvv" });
|
||||
});
|
||||
|
||||
it("clears a page's files with an empty list, once the control plane serves them", async () => {
|
||||
const page = await snapshotOf("<p>no images</p>", "page.html");
|
||||
const control = fakeControlPlane(4, { files: true });
|
||||
const result = await uploadShare(control.api, { baseUrl: "https://cp.test", snapshot: page, name: "page.html", project: "p", feature: "f", page: { files: [] } }, () => undefined);
|
||||
expect(result.pageFiles).toEqual({ included: 0, unsupported: false });
|
||||
expect(result.pageFiles).toEqual({ included: 0, unsupported: false, refusedVideos: [], tooLargeVideos: [] });
|
||||
const finalize = JSON.parse(control.calls.find((call) => call.url.endsWith("/finalize"))!.body as string);
|
||||
expect(finalize.files).toEqual([]);
|
||||
});
|
||||
@@ -388,7 +430,7 @@ describe("uploadShare", () => {
|
||||
for (const files of [[], [{ path: "a.png", snapshot: await snapshotOf("aaaa", "a.png") }]]) {
|
||||
const control = fakeControlPlane(4);
|
||||
const result = await uploadShare(control.api, { baseUrl: "https://cp.test", snapshot: page, name: "page.html", project: "p", feature: "f", page: { files } }, () => undefined);
|
||||
expect(result.pageFiles).toEqual({ included: 0, unsupported: true });
|
||||
expect(result.pageFiles).toEqual({ included: 0, unsupported: true, refusedVideos: [], tooLargeVideos: [] });
|
||||
const finalize = JSON.parse(control.calls.find((call) => call.url.endsWith("/finalize"))!.body as string);
|
||||
expect(finalize).not.toHaveProperty("files");
|
||||
}
|
||||
|
||||
@@ -663,6 +663,13 @@ export interface PageFilesOutcome {
|
||||
* page was published alone, and an active link kept the files it had.
|
||||
*/
|
||||
unsupported: boolean;
|
||||
/**
|
||||
* The paths of the videos the control plane refused to include (it does
|
||||
* not serve videos yet): left out, as a page's missing files are.
|
||||
*/
|
||||
refusedVideos: string[];
|
||||
/** The paths of the videos over the control plane's size limit: left out too. */
|
||||
tooLargeVideos: string[];
|
||||
}
|
||||
|
||||
interface UploadStart {
|
||||
@@ -768,12 +775,31 @@ function isMissingRoute(error: unknown): boolean {
|
||||
return error instanceof CloudShareError && error.status === 404;
|
||||
}
|
||||
|
||||
/** Whether a refusal says the control plane does not publish this type: a video while it serves none. */
|
||||
function isRefusedType(error: unknown): boolean {
|
||||
return error instanceof CloudShareError && error.code === "artifact_share_type_unsupported";
|
||||
}
|
||||
|
||||
/** Whether a refusal says a video is over the control plane's size limit. */
|
||||
function isVideoTooLarge(error: unknown): boolean {
|
||||
return error instanceof CloudShareError && error.code === "artifact_share_video_too_large";
|
||||
}
|
||||
|
||||
/** The file tokens of a page's uploaded files, and the videos the control plane refused. */
|
||||
interface UploadedPageFiles {
|
||||
tokens: string[];
|
||||
refusedVideos: string[];
|
||||
tooLargeVideos: string[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Uploads the files a page uses under the page's upload (pageToken) and
|
||||
* returns their file tokens for finalizing, or null when the control plane
|
||||
* predates included files: it then cannot take a files list either, since it
|
||||
* refuses fields it does not know. With no files, one request that is refused
|
||||
* either way tells which: an unknown route (404) or a path it checks (400).
|
||||
* A video the control plane refuses (415: it serves no videos yet) is left
|
||||
* out and the page is published without it.
|
||||
*/
|
||||
async function uploadPageFiles(
|
||||
api: CloudShareApi,
|
||||
@@ -782,19 +808,21 @@ async function uploadPageFiles(
|
||||
files: PageFileSnapshot[],
|
||||
onSent: (bytes: number) => void,
|
||||
signal?: AbortSignal,
|
||||
): Promise<string[] | null> {
|
||||
): Promise<UploadedPageFiles | null> {
|
||||
if (files.length === 0) {
|
||||
try {
|
||||
await callApi<unknown>(api, baseUrl, "POST", "/me/artifact-shares/uploads/files",
|
||||
{ uploadToken: pageToken, path: "", size: 0, sha256: "0".repeat(64) }, signal);
|
||||
} catch (error) {
|
||||
if (isMissingRoute(error)) return null;
|
||||
if (error instanceof CloudShareError && error.status === 400) return [];
|
||||
if (error instanceof CloudShareError && error.status === 400) return { tokens: [], refusedVideos: [], tooLargeVideos: [] };
|
||||
throw error;
|
||||
}
|
||||
return [];
|
||||
return { tokens: [], refusedVideos: [], tooLargeVideos: [] };
|
||||
}
|
||||
const tokens: string[] = [];
|
||||
const refusedVideos: string[] = [];
|
||||
const tooLargeVideos: string[] = [];
|
||||
for (const [index, file] of files.entries()) {
|
||||
let start: UploadStart;
|
||||
try {
|
||||
@@ -802,6 +830,11 @@ async function uploadPageFiles(
|
||||
{ uploadToken: pageToken, path: file.path, size: file.snapshot.size, sha256: file.snapshot.sha256 }, signal);
|
||||
} catch (error) {
|
||||
if (index === 0 && isMissingRoute(error)) return null;
|
||||
if (isRefusedType(error) || isVideoTooLarge(error)) {
|
||||
(isRefusedType(error) ? refusedVideos : tooLargeVideos).push(file.path);
|
||||
onSent(file.snapshot.size);
|
||||
continue;
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
try {
|
||||
@@ -814,7 +847,7 @@ async function uploadPageFiles(
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
return tokens;
|
||||
return { tokens, refusedVideos, tooLargeVideos };
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -844,7 +877,8 @@ export async function uploadShare(
|
||||
onProgress(sent);
|
||||
};
|
||||
try {
|
||||
const fileTokens = input.page ? await uploadPageFiles(api, baseUrl, start.uploadToken, input.page.files, onSent, signal) : null;
|
||||
const uploaded = input.page ? await uploadPageFiles(api, baseUrl, start.uploadToken, input.page.files, onSent, signal) : null;
|
||||
const fileTokens = uploaded?.tokens ?? null;
|
||||
const parts = await putSnapshotParts(api, baseUrl, start, snapshot, onSent, signal);
|
||||
const result = await callApi<{ share: CloudShareLink; replaced: boolean }>(api, baseUrl, "POST", "/me/artifact-shares/finalize", {
|
||||
uploadToken: start.uploadToken,
|
||||
@@ -853,7 +887,7 @@ export async function uploadShare(
|
||||
...(fileTokens ? { files: fileTokens.map((fileToken) => ({ fileToken })) } : {}),
|
||||
}, signal, SHARE_TIMEOUTS.publish);
|
||||
if (!input.page) return result;
|
||||
return { ...result, pageFiles: { included: fileTokens?.length ?? 0, unsupported: fileTokens === null } };
|
||||
return { ...result, pageFiles: { included: fileTokens?.length ?? 0, unsupported: uploaded === null, refusedVideos: uploaded?.refusedVideos ?? [], tooLargeVideos: uploaded?.tooLargeVideos ?? [] } };
|
||||
} catch (error) {
|
||||
// The upload was never finalized: discard its parts. Finalize itself
|
||||
// failing leaves nothing to discard but aborting is harmless.
|
||||
|
||||
@@ -28,8 +28,8 @@ import { useArtifactsViewStore } from "../stores/artifacts-view-store";
|
||||
import type { SessionArtifact, WorkspaceSession } from "../types/workspace";
|
||||
import { ConfirmDialog } from "./ConfirmDialog";
|
||||
import { Button } from "./ui/button";
|
||||
import { ShareArtifactMenuPopover, VIDEO_FILE, useHostShareLinks, useShareAccess, useShareAvailable } from "./ShareArtifactPopover";
|
||||
import type { CloudShareFile } from "../../shared/cloud-share";
|
||||
import { ShareArtifactMenuPopover, useHostShareLinks, useShareAccess, useShareAvailable } from "./ShareArtifactPopover";
|
||||
import { isUnplayableShareVideo, type CloudShareFile } from "../../shared/cloud-share";
|
||||
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger } from "./ui/dropdown-menu";
|
||||
import { Tooltip, TooltipContent, TooltipTrigger } from "./ui/tooltip";
|
||||
|
||||
@@ -140,7 +140,7 @@ export function ArtifactActionsMenu({
|
||||
const published = Boolean(artifact.shareUrl);
|
||||
const sharing = useRef(false);
|
||||
const shareAvailable = useShareAvailable();
|
||||
const canShare = Boolean(share) && iconOnly && shareAvailable && !VIDEO_FILE.test(artifact.path);
|
||||
const canShare = Boolean(share) && iconOnly && shareAvailable && !isUnplayableShareVideo(artifact.path);
|
||||
const actionClassName = cn(className, (menuOpen || shareOpen) && "opacity-100 [@media(hover:hover)]:opacity-100");
|
||||
// The artifact directory is on this machine only for a local session.
|
||||
const local = !hostId && !session.cloud;
|
||||
|
||||
@@ -1041,11 +1041,11 @@ describe("SessionArtifactsView", () => {
|
||||
expect(screen.getByRole("button", { name: "Publish: notes.md" })).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("disables Publish for a video and says why", async () => {
|
||||
const video: SessionArtifact = { kind: "file", name: "clip.mp4", path: "clip.mp4", size: 2, updatedAt: "2026-09-24T00:00:00Z" };
|
||||
renderView(<SessionArtifactsView request={{ key: 1, path: "clip.mp4" }} session={session([video])} />);
|
||||
it("disables Publish for a video browsers cannot play and says why", async () => {
|
||||
const video: SessionArtifact = { kind: "file", name: "clip.mkv", path: "clip.mkv", size: 2, updatedAt: "2026-09-24T00:00:00Z" };
|
||||
renderView(<SessionArtifactsView request={{ key: 1, path: "clip.mkv" }} session={session([video])} />);
|
||||
|
||||
expect(await screen.findByRole("button", { name: "Publish: clip.mp4" })).toBeDisabled();
|
||||
expect(await screen.findByRole("button", { name: "Publish: clip.mkv" })).toBeDisabled();
|
||||
});
|
||||
|
||||
it("copies a markdown artifact as Markdown", async () => {
|
||||
|
||||
@@ -831,9 +831,14 @@ describe("ShareArtifactButton states", () => {
|
||||
expect(screen.getByRole("button", { name: "Publish: report.html" })).toBeTruthy();
|
||||
});
|
||||
|
||||
it("disables Publish for a video", async () => {
|
||||
it.each(["clip.mkv", "clip.avi", "clip.ogv"])("disables Publish for %s, a video browsers cannot play", async (name) => {
|
||||
renderButton({ ...localFile, path: name }, name);
|
||||
expect(await screen.findByRole("button", { name: `Publish: ${name}` })).toBeDisabled();
|
||||
});
|
||||
|
||||
it("offers Publish for a video browsers play", async () => {
|
||||
renderButton({ ...localFile, path: "clip.mp4" }, "clip.mp4");
|
||||
expect(await screen.findByRole("button", { name: "Publish: clip.mp4" })).toBeDisabled();
|
||||
expect(await screen.findByRole("button", { name: "Publish: clip.mp4" })).toBeEnabled();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -998,6 +1003,28 @@ describe("publish telemetry", () => {
|
||||
expect(publishSpy).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("says videos are coming soon when the control plane refuses a playable one", async () => {
|
||||
const video = { ...cloudFile, path: "docs/clip.mp4" };
|
||||
stub({ ...inspection, name: "clip.mp4" }, links, { status: "unsupported", message: "Sharing videos is coming soon." });
|
||||
const dialog = await openPopover(video, "clip.mp4");
|
||||
expect(await within(dialog).findByText("Publishing videos is coming soon.")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("says why a video format browsers cannot play is not published", async () => {
|
||||
const video = { ...cloudFile, path: "docs/clip.mkv" };
|
||||
const { publishSpy } = stub({ ...inspection, name: "clip.mkv", unsupported: true }, links);
|
||||
render(
|
||||
<QueryClientProvider client={new QueryClient()}><TooltipProvider>
|
||||
<ShareArtifactMenuPopover file={video} intent="publish" name="clip.mkv" open onOpenChange={() => undefined}>
|
||||
<button type="button">menu</button>
|
||||
</ShareArtifactMenuPopover>
|
||||
</TooltipProvider></QueryClientProvider>,
|
||||
);
|
||||
const dialog = await screen.findByRole("dialog");
|
||||
expect(await within(dialog).findByText("This video format can't be played in a browser. Use MP4, MOV or WebM.")).toBeInTheDocument();
|
||||
expect(publishSpy).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("counts an unsupported file that already has a live link as a blocked republish", async () => {
|
||||
const { publishSpy } = stub({ ...inspection, shareId: SHARE_ID, unsupported: true }, { ...links, shares: [share] });
|
||||
await openPopover(cloudFile, "report.html", "Published");
|
||||
|
||||
@@ -15,6 +15,7 @@ import {
|
||||
type HostShareLink,
|
||||
artifactShareUrl,
|
||||
isPrivateShare,
|
||||
isUnplayableShareVideo,
|
||||
sameShareFingerprint,
|
||||
} from "../../shared/cloud-share";
|
||||
import { useCloudMeUserId } from "../hooks/useCloudMeUserId";
|
||||
@@ -75,8 +76,6 @@ type Phase =
|
||||
| { kind: "unpublished" }
|
||||
| { kind: "error"; message: string };
|
||||
|
||||
/** Videos are not shared yet: there is no partial-file serving for them. */
|
||||
export const VIDEO_FILE = /\.(mp4|m4v|mov|webm|ogv|avi|mkv)$/i;
|
||||
const COPIED_MS = 2_000;
|
||||
|
||||
/**
|
||||
@@ -546,7 +545,9 @@ export function ShareArtifactButton({ file, name, className, iconOnly = false, r
|
||||
const recheck = useCallback(() => setChecks((count) => count + 1), []);
|
||||
const available = useShareAvailable();
|
||||
const { baseUrl, signedIn, scope } = useShareAccess();
|
||||
const video = VIDEO_FILE.test(file.path);
|
||||
// A video browsers cannot play is never published. Any other video is
|
||||
// offered: a control plane that does not serve videos yet refuses it.
|
||||
const video = isUnplayableShareVideo(file.path);
|
||||
const publishing = usePublishing(pendingKey(baseUrl, file));
|
||||
const { share, outdated, checked } = usePublishedShare(available && signedIn && !video ? { ...file, baseUrl } : null, scope, `${revision}:${checks}:${publishing}`);
|
||||
// What the panel does on opening is fixed when it opens, so a check that
|
||||
@@ -591,7 +592,7 @@ export function ShareArtifactButton({ file, name, className, iconOnly = false, r
|
||||
</Button>
|
||||
</span>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent side="bottom">{t("artifacts.share.videoSoon")}</TooltipContent>
|
||||
<TooltipContent side="bottom">{t("artifacts.share.videoFormat")}</TooltipContent>
|
||||
</Tooltip>
|
||||
);
|
||||
}
|
||||
@@ -1121,7 +1122,7 @@ function SharePanel({
|
||||
</>
|
||||
);
|
||||
case "unsupported":
|
||||
return <>{titled(t("artifacts.share.title.publish"))}{status(t("artifacts.share.videoSoon"))}</>;
|
||||
return <>{titled(t("artifacts.share.title.publish"))}{status(t(isUnplayableShareVideo(name) ? "artifacts.share.videoFormat" : "artifacts.share.videoSoon"))}</>;
|
||||
case "notOwner":
|
||||
return <>{titled(t("artifacts.share.title.publish"))}{status(t("artifacts.share.notOwner"))}</>;
|
||||
case "limit":
|
||||
|
||||
@@ -26,6 +26,28 @@ describe("SharedArtifactFrame", () => {
|
||||
expect(mocks.view).toHaveBeenCalledWith("q3-report", expect.anything());
|
||||
});
|
||||
|
||||
it("plays a shared video in a video element, not a frame", async () => {
|
||||
mocks.view.mockResolvedValue({ linkId: "q3-report", name: "demo.mp4", contentType: "video/mp4", size: 1, updatedAt: "", contentUrl: "https://q3-report.share.test/?vt=token" });
|
||||
renderFrame();
|
||||
const video = await screen.findByLabelText("q3.html");
|
||||
expect(video.tagName).toBe("VIDEO");
|
||||
expect(video).toHaveAttribute("src", "https://q3-report.share.test/?vt=token");
|
||||
expect(video).toHaveAttribute("controls");
|
||||
expect(screen.queryByTitle("q3.html")).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("plays a video stored without its type, by its name", async () => {
|
||||
mocks.view.mockResolvedValue({ linkId: "q3-report", name: "demo.MOV", contentType: "binary/octet-stream", size: 1, updatedAt: "", contentUrl: "https://q3-report.share.test/" });
|
||||
renderFrame();
|
||||
expect((await screen.findByLabelText("q3.html")).tagName).toBe("VIDEO");
|
||||
});
|
||||
|
||||
it("frames anything else, even with a video's name but another type", async () => {
|
||||
mocks.view.mockResolvedValue({ linkId: "q3-report", name: "demo.mp4", contentType: "text/html", size: 1, updatedAt: "", contentUrl: "https://q3-report.share.test/" });
|
||||
renderFrame();
|
||||
expect((await screen.findByTitle("q3.html")).tagName).toBe("IFRAME");
|
||||
});
|
||||
|
||||
it("says when the link no longer opens for this person", async () => {
|
||||
mocks.view.mockRejectedValue(new CloudCpError("not found", { status: 404, code: "not_found" }));
|
||||
renderFrame();
|
||||
|
||||
@@ -2,6 +2,7 @@ import { useQuery } from "@tanstack/react-query";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { useCloudCp } from "../hooks/useCloudCp";
|
||||
import { CloudCpError } from "../lib/cloud-cp";
|
||||
import { fileMediaKind } from "../lib/file-media";
|
||||
import { PanelMessage, RetryButton } from "./WorkspaceDiffView";
|
||||
|
||||
/**
|
||||
@@ -12,6 +13,11 @@ import { PanelMessage, RetryButton } from "./WorkspaceDiffView";
|
||||
* host's own Content-Security-Policy sandboxes the page and blocks its network
|
||||
* requests. A token outlives the frame's load, so an open page keeps showing;
|
||||
* reopening takes a fresh one.
|
||||
*
|
||||
* A video plays in a video element, as on the link's web page: its file host
|
||||
* redirects to a signed URL on the video host, and a frame would load that as
|
||||
* a document, which a video stored without its type turns into a refused
|
||||
* download.
|
||||
*/
|
||||
export function SharedArtifactFrame({ linkId, title }: { linkId: string; title: string }) {
|
||||
const { t } = useTranslation();
|
||||
@@ -29,6 +35,22 @@ export function SharedArtifactFrame({ linkId, title }: { linkId: string; title:
|
||||
if (view.error instanceof CloudCpError && view.error.status === 404) return <PanelMessage>{t("artifacts.sharedUnavailable")}</PanelMessage>;
|
||||
if (view.isError) return <PanelMessage action={<RetryButton onClick={() => { void view.refetch(); }} />}>{t("artifacts.accessError")}</PanelMessage>;
|
||||
if (!view.data) return <PanelMessage>{t("files.loading")}</PanelMessage>;
|
||||
if (isSharedVideo(view.data.contentType, view.data.name)) {
|
||||
return (
|
||||
<div className="flex h-full w-full items-center justify-center bg-background">
|
||||
<video
|
||||
aria-label={title}
|
||||
className="max-h-full max-w-full"
|
||||
controls
|
||||
controlsList="nodownload"
|
||||
key={view.data.contentUrl}
|
||||
playsInline
|
||||
preload="metadata"
|
||||
src={view.data.contentUrl}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<iframe
|
||||
className="h-full w-full border-0 bg-background"
|
||||
@@ -40,3 +62,10 @@ export function SharedArtifactFrame({ linkId, title }: { linkId: string; title:
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
/** Whether a shared link is a video: by its type, or by its name when stored without one. */
|
||||
function isSharedVideo(contentType: string | undefined, name: string): boolean {
|
||||
const type = contentType?.split(";")[0]?.trim().toLowerCase() ?? "";
|
||||
if (type.startsWith("video/")) return true;
|
||||
return (type === "" || type === "application/octet-stream" || type === "binary/octet-stream") && fileMediaKind(name) === "video";
|
||||
}
|
||||
@@ -3712,6 +3712,7 @@
|
||||
"artifacts.share.upgradeTitle": "Upgrade, um mehr zu teilen",
|
||||
"artifacts.share.limitReached": "Kostenloser Plan: bis zu {{limit}} aktive Links. Führe ein Upgrade durch, um mehr zu teilen.",
|
||||
"artifacts.share.upgrade": "Upgrade",
|
||||
"artifacts.share.videoFormat": "Dieses Videoformat kann im Browser nicht abgespielt werden. Verwende MP4, MOV oder WebM.",
|
||||
"artifacts.share.videoSoon": "Das Teilen von Videos ist bald verfügbar.",
|
||||
"artifacts.share.notOwner": "Nur die Person, die diese Sitzung gestartet hat, kann ihre Dateien teilen.",
|
||||
"artifacts.share.copyLink": "Link kopieren",
|
||||
|
||||
@@ -3689,6 +3689,7 @@
|
||||
"artifacts.share.upgradeTitle": "Upgrade to publish more",
|
||||
"artifacts.share.limitReached": "Free plan: up to {{limit}} active links. Upgrade to publish more.",
|
||||
"artifacts.share.upgrade": "Upgrade",
|
||||
"artifacts.share.videoFormat": "This video format can't be played in a browser. Use MP4, MOV or WebM.",
|
||||
"artifacts.share.videoSoon": "Publishing videos is coming soon.",
|
||||
"artifacts.share.notOwner": "Only the person who started this session can publish its files.",
|
||||
"artifacts.share.copyLink": "Copy link",
|
||||
|
||||
@@ -3802,6 +3802,7 @@
|
||||
"artifacts.share.upgradeTitle": "Mejora tu plan para compartir más",
|
||||
"artifacts.share.limitReached": "Plan gratuito: hasta {{limit}} enlaces activos. Mejora tu plan para compartir más.",
|
||||
"artifacts.share.upgrade": "Mejorar plan",
|
||||
"artifacts.share.videoFormat": "Este formato de vídeo no se puede reproducir en un navegador. Usa MP4, MOV o WebM.",
|
||||
"artifacts.share.videoSoon": "Pronto podrás compartir vídeos.",
|
||||
"artifacts.share.notOwner": "Solo quien inició esta sesión puede compartir sus archivos.",
|
||||
"artifacts.share.copyLink": "Copiar enlace",
|
||||
|
||||
@@ -3802,6 +3802,7 @@
|
||||
"artifacts.share.upgradeTitle": "Passez à une offre supérieure pour partager plus",
|
||||
"artifacts.share.limitReached": "Offre gratuite : jusqu’à {{limit}} liens actifs. Passez à une offre supérieure pour partager plus.",
|
||||
"artifacts.share.upgrade": "Mettre à niveau",
|
||||
"artifacts.share.videoFormat": "Ce format vidéo ne peut pas être lu dans un navigateur. Utilisez MP4, MOV ou WebM.",
|
||||
"artifacts.share.videoSoon": "Le partage de vidéos arrive bientôt.",
|
||||
"artifacts.share.notOwner": "Seule la personne qui a démarré cette session peut partager ses fichiers.",
|
||||
"artifacts.share.copyLink": "Copier le lien",
|
||||
|
||||
@@ -3712,6 +3712,7 @@
|
||||
"artifacts.share.upgradeTitle": "アップグレードしてさらに共有",
|
||||
"artifacts.share.limitReached": "無料プラン: 有効なリンクは {{limit}} 件まで。アップグレードするとさらに共有できます。",
|
||||
"artifacts.share.upgrade": "アップグレード",
|
||||
"artifacts.share.videoFormat": "この動画形式はブラウザで再生できません。MP4、MOV、WebM を使用してください。",
|
||||
"artifacts.share.videoSoon": "動画の共有は近日対応予定です。",
|
||||
"artifacts.share.notOwner": "このセッションのファイルを共有できるのは、セッションを開始した人だけです。",
|
||||
"artifacts.share.copyLink": "リンクをコピー",
|
||||
|
||||
@@ -3712,6 +3712,7 @@
|
||||
"artifacts.share.upgradeTitle": "업그레이드하여 더 공유하기",
|
||||
"artifacts.share.limitReached": "무료 플랜: 활성 링크는 최대 {{limit}}개입니다. 업그레이드하면 더 공유할 수 있습니다.",
|
||||
"artifacts.share.upgrade": "업그레이드",
|
||||
"artifacts.share.videoFormat": "이 동영상 형식은 브라우저에서 재생할 수 없습니다. MP4, MOV 또는 WebM을 사용하세요.",
|
||||
"artifacts.share.videoSoon": "동영상 공유는 곧 지원될 예정입니다.",
|
||||
"artifacts.share.notOwner": "이 세션의 파일은 세션을 시작한 사람만 공유할 수 있습니다.",
|
||||
"artifacts.share.copyLink": "링크 복사",
|
||||
|
||||
@@ -3802,6 +3802,7 @@
|
||||
"artifacts.share.upgradeTitle": "Faça upgrade para compartilhar mais",
|
||||
"artifacts.share.limitReached": "Plano gratuito: até {{limit}} links ativos. Faça upgrade para compartilhar mais.",
|
||||
"artifacts.share.upgrade": "Fazer upgrade",
|
||||
"artifacts.share.videoFormat": "Este formato de vídeo não pode ser reproduzido em um navegador. Use MP4, MOV ou WebM.",
|
||||
"artifacts.share.videoSoon": "O compartilhamento de vídeos chegará em breve.",
|
||||
"artifacts.share.notOwner": "Somente quem iniciou esta sessão pode compartilhar os arquivos dela.",
|
||||
"artifacts.share.copyLink": "Copiar link",
|
||||
|
||||
@@ -3877,6 +3877,7 @@
|
||||
"artifacts.share.upgradeTitle": "Перейдите на платный план, чтобы делиться больше",
|
||||
"artifacts.share.limitReached": "Бесплатный план: до {{limit}} активных ссылок. Перейдите на платный план, чтобы делиться больше.",
|
||||
"artifacts.share.upgrade": "Перейти на платный план",
|
||||
"artifacts.share.videoFormat": "Этот формат видео не воспроизводится в браузере. Используйте MP4, MOV или WebM.",
|
||||
"artifacts.share.videoSoon": "Возможность делиться видео скоро появится.",
|
||||
"artifacts.share.notOwner": "Делиться файлами этой сессии может только тот, кто её начал.",
|
||||
"artifacts.share.copyLink": "Копировать ссылку",
|
||||
|
||||
@@ -3689,6 +3689,7 @@
|
||||
"artifacts.share.upgradeTitle": "Daha fazla yayımlamak için planınızı yükseltin",
|
||||
"artifacts.share.limitReached": "Ücretsiz planda en fazla {{limit}} etkin bağlantı olabilir. Daha fazla yayımlamak için planınızı yükseltin.",
|
||||
"artifacts.share.upgrade": "Planı yükselt",
|
||||
"artifacts.share.videoFormat": "Bu video biçimi tarayıcıda oynatılamıyor. MP4, MOV veya WebM kullanın.",
|
||||
"artifacts.share.videoSoon": "Video yayımlama yakında kullanıma sunulacak.",
|
||||
"artifacts.share.notOwner": "Bu oturumun dosyalarını yalnızca oturumu başlatan kişi yayımlayabilir.",
|
||||
"artifacts.share.copyLink": "Bağlantıyı kopyala",
|
||||
|
||||
@@ -3694,6 +3694,7 @@
|
||||
"artifacts.share.upgradeTitle": "升级以分享更多",
|
||||
"artifacts.share.limitReached": "免费版:最多 {{limit}} 个有效链接。升级即可分享更多。",
|
||||
"artifacts.share.upgrade": "升级",
|
||||
"artifacts.share.videoFormat": "此视频格式无法在浏览器中播放。请使用 MP4、MOV 或 WebM。",
|
||||
"artifacts.share.videoSoon": "视频分享即将推出。",
|
||||
"artifacts.share.notOwner": "只有发起此会话的人才能分享其文件。",
|
||||
"artifacts.share.copyLink": "复制链接",
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { isUnplayableShareVideo } from "./cloud-share";
|
||||
|
||||
describe("isUnplayableShareVideo", () => {
|
||||
it.each(["a.avi", "a.MKV", "clips/a.ogv"])("refuses %s", (name) => expect(isUnplayableShareVideo(name)).toBe(true));
|
||||
it.each(["a.mp4", "a.MOV", "a.m4v", "a.webm", "a.png", "a.ogg"])("lets %s through", (name) => expect(isUnplayableShareVideo(name)).toBe(false));
|
||||
});
|
||||
@@ -183,6 +183,18 @@ export interface CloudShareLinks {
|
||||
privateLinks: boolean;
|
||||
}
|
||||
|
||||
const UNPLAYABLE_VIDEO = /\.(avi|mkv|ogv)$/i;
|
||||
|
||||
/**
|
||||
* Whether a file is a video in a format browsers do not play. A share link
|
||||
* has no download, so its viewer could show nothing of one: it is never
|
||||
* published. The control plane refuses it too. .ogv is Theora, which Chrome
|
||||
* and Firefox no longer play.
|
||||
*/
|
||||
export function isUnplayableShareVideo(name: string): boolean {
|
||||
return UNPLAYABLE_VIDEO.test(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* What the share popover and the Publish button know about a file, read
|
||||
* without opening it: from this computer's publish record and the file's
|
||||
@@ -192,7 +204,7 @@ export interface CloudShareInspection {
|
||||
name: string;
|
||||
/** Known for a local file, and for a cloud file whose list was read. */
|
||||
size?: number;
|
||||
/** Video is not shared yet. */
|
||||
/** A video in a format browsers do not play (see isUnplayableShareVideo). */
|
||||
unsupported: boolean;
|
||||
/** The link this file was last published to from this computer, if any. */
|
||||
shareId?: string;
|
||||
@@ -228,11 +240,12 @@ export interface CloudSharePageFiles {
|
||||
/** How many the link serves beside the page now. */
|
||||
included: number;
|
||||
/**
|
||||
* How many the page uses that were left out: video (not shared yet), a
|
||||
* file outside the page's folder or missing, or past the link's limit.
|
||||
* How many the page uses that were left out: a video the control plane
|
||||
* does not publish or browsers cannot play, a file outside the page's
|
||||
* folder or missing, or past the link's limit.
|
||||
*/
|
||||
skipped: number;
|
||||
/** How many of skipped are video. */
|
||||
/** How many of skipped are video the control plane does not publish yet. */
|
||||
videos: number;
|
||||
/** The control plane predates included files: the page was published alone. */
|
||||
unsupported: boolean;
|
||||
|
||||
@@ -6,7 +6,7 @@ import { contentSecurityPolicy } from "./vite.renderer.config";
|
||||
describe("packaged renderer CSP", () => {
|
||||
it.each(["build", "serve"] as const)("allows media from the app, loopback preview and control-plane origins in %s", (mode) => {
|
||||
expect(contentSecurityPolicy(mode).split("; ").filter((directive) => directive.startsWith("media-src")))
|
||||
.toEqual(["media-src 'self' blob: http://127.0.0.1:* http://*.localhost:* https://staging-api.aoagents.dev https://api.aoagents.dev"]);
|
||||
.toEqual(["media-src 'self' blob: http://127.0.0.1:* http://*.localhost:* https://staging-api.aoagents.dev https://api.aoagents.dev https://*.orchestratorusercontent-staging.com https://*.orchestratorusercontent.com"]);
|
||||
});
|
||||
|
||||
// A just-sent attachment's tile draws from the composer's object URL. Without
|
||||
|
||||
@@ -144,8 +144,10 @@ export function contentSecurityPolicy(mode: "build" | "serve"): string {
|
||||
// show as plain images (main/artifact-snapshots.ts). 'self' is only the app:// origin, so
|
||||
// without it every cached card is refused in a packaged build and falls back to live.
|
||||
`img-src 'self' data: blob: http://127.0.0.1:* http://*.localhost:* https: ${ARTIFACT_SNAPSHOT_SCHEME}:`,
|
||||
// A cloud session's audio and video artifacts stream from its control plane.
|
||||
["media-src 'self' blob: http://127.0.0.1:* http://*.localhost:*", ...CLOUD_CP_ORIGINS].join(" "),
|
||||
// A cloud session's audio and video artifacts stream from its control plane;
|
||||
// a shared video plays from its link's file host, which redirects to the
|
||||
// video host (both under the share content origins).
|
||||
["media-src 'self' blob: http://127.0.0.1:* http://*.localhost:*", ...CLOUD_CP_ORIGINS, ...SHARE_CONTENT_ORIGINS].join(" "),
|
||||
"font-src 'self' data:",
|
||||
[
|
||||
"connect-src",
|
||||
|
||||
@@ -215,7 +215,7 @@ export interface paths {
|
||||
};
|
||||
get?: never;
|
||||
put?: never;
|
||||
/** @description Starts uploading one file from a local session straight to storage, for a new document (project, feature, name), a revoked document to restore, or an update of an active link (shareId). An update may give the link a new name, after the file was renamed: the link keeps its address and serves the file under that name. The file goes in partCount parts of partSize bytes, the last one shorter: presign them with presignArtifactShareParts, PUT each, then finalizeArtifactShare. There is no file size limit. Nothing reaches storage when the upload is refused: 415 artifact_share_type_unsupported for video, 409 artifact_share_limit_reached for a new or restored document over the free plan's link limit. Paid plans have no link limit. An older control plane refuses an update with another name with 409 artifact_share_name_changed. The images and other files an HTML page refers to by relative path are uploaded under this upload with createArtifactShareFileUpload and listed when finalizing. */
|
||||
/** @description Starts uploading one file from a local session straight to storage, for a new document (project, feature, name), a revoked document to restore, or an update of an active link (shareId). An update may give the link a new name, after the file was renamed: the link keeps its address and serves the file under that name. The file goes in partCount parts of partSize bytes, the last one shorter: presign them with presignArtifactShareParts, PUT each, then finalizeArtifactShare. There is no file size limit but for video. Nothing reaches storage when the upload is refused: 415 artifact_share_type_unsupported for a video the control plane does not serve (any video while it serves none; .ogv, .avi and .mkv, which browsers do not play, always), 413 artifact_share_video_too_large for a video over its size limit (1 GiB by default; the message names it), 409 artifact_share_limit_reached for a new or restored document over the free plan's link limit. A video's contentUrl answers 302 to a signed URL on a separate video host, which the browser's player follows; with the control plane's video host turned off, a video already published answers 503 artifact_share_video_unavailable. Paid plans have no link limit. An older control plane refuses an update with another name with 409 artifact_share_name_changed. The images and other files an HTML page refers to by relative path are uploaded under this upload with createArtifactShareFileUpload and listed when finalizing. */
|
||||
post: operations["createArtifactShareUpload"];
|
||||
delete?: never;
|
||||
options?: never;
|
||||
@@ -266,7 +266,7 @@ export interface paths {
|
||||
};
|
||||
get?: never;
|
||||
put?: never;
|
||||
/** @description Starts uploading one file the page being uploaded (uploadToken, from createArtifactShareUpload) refers to by relative path, such as an image. The link serves it at path under its root, so <img src="images/a.png"> in the page loads the file whose path is images/a.png. Any file type but video may be included, and there is no file size limit. Its parts go as the page's do (presignArtifactShareParts, PUT each, abortArtifactShareUpload to cancel); finish it with completeArtifactShareFileUpload. 400 invalid_request for a path that is absolute, has an empty, "." or ".." segment, a backslash or a control character, or is reserved (raw, or under _ao/ or a first segment starting with ~); 429 artifact_share_rate_limited past the hourly allowance. A control plane that predates included files answers 404. 415 artifact_share_type_unsupported for video (.mp4, .m4v, .mov, .webm, .ogv, .avi, .mkv), as for a link's own file. */
|
||||
/** @description Starts uploading one file the page being uploaded (uploadToken, from createArtifactShareUpload) refers to by relative path, such as an image. The link serves it at path under its root, so <img src="images/a.png"> in the page loads the file whose path is images/a.png. Any file type may be included, and there is no file size limit but for video, as for a link's own file. Its parts go as the page's do (presignArtifactShareParts, PUT each, abortArtifactShareUpload to cancel); finish it with completeArtifactShareFileUpload. 400 invalid_request for a path that is absolute, has an empty, "." or ".." segment, a backslash or a control character, or is reserved (raw, or under _ao/ or a first segment starting with ~); 429 artifact_share_rate_limited past the hourly allowance. A control plane that predates included files answers 404. 415 artifact_share_type_unsupported for a video the control plane does not serve, and 413 artifact_share_video_too_large for one over its size limit, as for a link's own file: a client leaves that file out and publishes the page with the rest, naming them in finalizeArtifactShare's files (an empty list when none uploaded), since an update without files keeps the files the link served. */
|
||||
post: operations["createArtifactShareFileUpload"];
|
||||
delete?: never;
|
||||
options?: never;
|
||||
@@ -1185,7 +1185,7 @@ export interface paths {
|
||||
};
|
||||
get?: never;
|
||||
put?: never;
|
||||
/** @description Publishes one of this session's committed artifact files as a share link, as finalizeArtifactShare publishes a local file: the same link limit (409 artifact_share_limit_reached), one link per file, and shareId to point an existing link at the file's current version. The link serves a copy of the file, so it outlives the session's file; unpublishing deletes only the copy. 404 when the caller is not a member of the organization or the session holds no file at path; 409 artifact_share_source_changed when the session's file is no longer the sha256 the caller was shown (inspect it again); 415 artifact_share_type_unsupported for a video.
|
||||
/** @description Publishes one of this session's committed artifact files as a share link, as finalizeArtifactShare publishes a local file: the same link limit (409 artifact_share_limit_reached), one link per file, and shareId to point an existing link at the file's current version. The link serves a copy of the file, so it outlives the session's file; unpublishing deletes only the copy. 404 when the caller is not a member of the organization or the session holds no file at path; 409 artifact_share_source_changed when the session's file is no longer the sha256 the caller was shown (inspect it again); 415 artifact_share_type_unsupported for a video the control plane does not serve, 413 artifact_share_video_too_large for one over its size limit, as for a local file (createArtifactShareUpload).
|
||||
* Only a person publishes: the route accepts only a signed-in account session, the bearer token of every user route. Worker, sandbox and host credentials get 401, so a cloud session's agent cannot publish its own files. Only the person who created the session shares its files, under their own link limit: another member of the organization, who may read them, gets 403 artifact_share_not_owner, as does anyone for a session with no creator on record; a guest of a shared project gets 404. */
|
||||
post: operations["shareSessionArtifact"];
|
||||
delete?: never;
|
||||
|
||||
Reference in new issue
Block a user