Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Dockerfile.test
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ ENV PATH="/root/.bun/bin:$PATH"
# lockfile change and fails.
COPY package.json bun.lock ./
COPY packages/parsers/package.json packages/parsers/package.json
# The share workspace typechecks this subpath during bun install.
COPY packages/parsers/src/privatePath.ts packages/parsers/src/privatePath.ts
# The share prepare script typechecks its parser imports during bun install.
COPY packages/parsers/src/ packages/parsers/src/
COPY packages/lint/package.json packages/lint/package.json
COPY packages/studio-server/package.json packages/studio-server/package.json
COPY packages/core/package.json packages/core/package.json
Expand Down
6 changes: 6 additions & 0 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 26 additions & 7 deletions docs/developers/share-source.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ description: "Choose whether a CLI review includes the project files used by its
`hyperframes share` can attach editable project files to the same review page
used by Desktop. Source upload requires `--include-source` for each upload, including updates.
Without it, terminal, JSON and unattended commands share video only.
Local Studio offers an unchecked **Include editable project files** option with
a disclosure of the upload scope before creating or updating a share.
Studio attaches an already-synced snapshot when it matches the saved project and the video in the selected workspace. With no match, Share uploads the video alone. Choose **Sync project files** to upload portable files before creating or updating a share. Syncing files does not create a link.

<Frame caption="Studio lists referenced hidden assets beside Sync project files. Update shared version publishes the video.">
<img src="/public/images/sharing/sync-project-files.png" alt="Studio sharing panel with two referenced assets and a separate Sync project files button" />
</Frame>

Source is available when the workspace's sharing and
Composition Sync permissions allow it. The recipient's access still depends on
Expand All @@ -31,8 +34,20 @@ through `hyperframes share --manage`.
Source uses the same portable project policy as Desktop: authored HTML, scripts,
styles, assets, and supported Studio edit metadata. Known credential filenames
(such as `.env`, `.npmrc`, and `*.pem`), dependency directories, chat
history, local sharing state, and recorded render outputs stay out. Files ending in `.key` stay local,
including Keynote decks.
history, local sharing state, and recorded render outputs stay out. Git workflow files and supported Studio edit metadata are portable.

If a project uses a Keynote deck, export the slides as images or video and reference that export
in the composition. Editable shares now leave every `.key` file on the sender’s computer.

The CLI lists referenced hidden assets before uploading editable source. Studio shows these paths beside **Sync project files**. For example, a composition that loads
`brand/.fonts/Inter.woff2` can include that font when you share the project files.
The same applies to a script loaded with `<script src="effects/.modules/fade.js"></script>`.
That script travels with the editable project. An unused script beside it stays local.
Source capture follows literal local asset references. For an asset whose path is computed at runtime,
declare its path with a preload link in your HTML, such as `<link rel="preload" as="image" href="art/.images/logo.png">`.
A literal font source such as `new FontFace("Brand", "url(brand/.fonts/Inter.woff2)")` is discovered automatically.
Unreferenced assets in unrecognized hidden folders stay local. Known private paths stay
excluded even when the composition references them.

These are filename rules, not a secret scanner. `.gitignore` does not control
source capture. Other regular files can be included even if Git ignores them. For example,
Expand Down Expand Up @@ -85,9 +100,13 @@ the command explains why it stopped. Retry after resolving the problem, or pass
`--video-only` to share just the rendered video. An unexpected source upload
failure never silently turns an eligible source share into video-only. If the
server confirms an upload expired or failed, a retry starts a new upload. If
the files changed while an earlier upload was still pending, the CLI cancels
that upload before starting a new one. It waits for uploads already under
verification and preserves conflicts for explicit resolution.
the files changed while an earlier upload was still pending, the CLI uses its upload ID
to cancel it before starting a new one. If the connection dropped before the CLI received
that ID, it can recover the ID by sending the original manifest again. This requires every
path to pass the current policy and every marked hidden asset to remain in the current
share with the same contents. Otherwise, the CLI starts fresh and any earlier pending upload
expires on the server. The CLI waits for uploads already under verification when it can
identify them, and preserves conflicts for explicit resolution.

A video-only retry does not resume an interrupted video upload that already
includes source. Check its status before retrying. To publish the same render as
Expand Down
Binary file added docs/public/images/sharing/sync-project-files.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
56 changes: 56 additions & 0 deletions packages/cli/src/commands/share.test.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
import { SourceIgnoreError, ReviewFailed } from "@hyperframes/share";
import { referencedHiddenDigest } from "@hyperframes/share/projectSnapshot.mjs";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { runCommand } from "citty";
import { consumeCommandResult } from "../utils/commandResult.js";
const mocks = vi.hoisted(() => ({
run: vi.fn(),
status: vi.fn(),
confirm: vi.fn(),
hiddenAssets: vi.fn(),
received: null as null | "unchecked" | { path: string; listed: string[]; hashes: string[] },
unattended: true,
progress: undefined as undefined | ((value: { step: string; slow?: boolean } | null) => void),
}));
vi.mock("@hyperframes/share/projectSnapshot.mjs", async (original) => ({
...(await original<typeof import("@hyperframes/share/projectSnapshot.mjs")>()),
listReferencedHiddenSourceAssets: mocks.hiddenAssets,
}));
vi.mock("../utils/project.js", () => ({ resolveProjectOrThrow: () => ({ dir: "/project" }) }));
vi.mock("../utils/privateProjectFile.js", () => ({
receivedRecordStatus: () => mocks.received,
Expand All @@ -36,6 +42,7 @@ beforeEach(() => {
mocks.run.mockReset();
mocks.status.mockReset();
mocks.confirm.mockReset();
mocks.hiddenAssets.mockReset().mockResolvedValue([]);
mocks.received = null;
mocks.unattended = true;
mocks.run.mockResolvedValue({
Expand Down Expand Up @@ -410,3 +417,52 @@ it("prints the earlier version's link with control characters as visible escapes
"Previous shared version: https://hyperframes.dev/review/b\\x1b[2J",
);
});

it.each([false, true])(
"reports referenced hidden assets on stderr without another prompt (json=%s)",
async (json) => {
const paths = ["brand/.fonts/Inter.woff2", "assets/.images/lo\u200bgo.png"];
mocks.hiddenAssets.mockResolvedValue(paths);
const err = vi.spyOn(console, "error").mockImplementation(() => {});
const out = vi.spyOn(console, "log").mockImplementation(() => {});
await runCommand(command, {
rawArgs: ["--public", "--include-source", ...(json ? ["--json"] : [])],
});
expect(err).toHaveBeenCalledWith(
[
"Editable source includes these referenced hidden assets",
'"brand/.fonts/Inter.woff2"',
'"assets/.images/lo\\u200bgo.png"',
].join("\n"),
);
expect(mocks.confirm).not.toHaveBeenCalled();
expect(mocks.run).toHaveBeenCalledOnce();
expect(mocks.run).toHaveBeenCalledWith(
expect.objectContaining({
expectedReferencedHiddenDigest: referencedHiddenDigest(paths),
}),
);
expect(out.mock.calls.flat().join(" ")).not.toContain("Inter.woff2");
},
);

it("does not enumerate or report hidden source paths for video-only shares", async () => {
await runCommand(command, { rawArgs: ["--public", "--video-only", "--json"] });
expect(mocks.hiddenAssets).not.toHaveBeenCalled();
});

it("checks an empty hidden asset summary and skips sharing when discovery fails", async () => {
vi.spyOn(console, "log").mockImplementation(() => {});
const rawArgs = ["--public", "--include-source", "--json"];
await runCommand(command, { rawArgs });
expect(mocks.run).toHaveBeenCalledWith(
expect.objectContaining({
expectedReferencedHiddenDigest: referencedHiddenDigest([]),
}),
);
mocks.run.mockClear();
mocks.hiddenAssets.mockRejectedValue(new Error("Could not verify the referenced assets."));
await runCommand(command, { rawArgs });
expect(mocks.run).not.toHaveBeenCalled();
expect(consumeCommandResult().exitCode).toBe(1);
});
19 changes: 19 additions & 0 deletions packages/cli/src/commands/share.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ import {
type ShareState,
type ShareService,
} from "../share/service.js";
import {
listReferencedHiddenSourceAssets,
referencedHiddenDigest,
} from "@hyperframes/share/projectSnapshot.mjs";
import { quotedFilePath, terminalLines } from "@hyperframes/core/terminal-text";
import { shareError } from "../share/errors.js";
import { jsonFailure } from "../utils/jsonError.js";
import { parsePositiveIntegerArg } from "../utils/integerArg.js";
Expand Down Expand Up @@ -92,6 +97,8 @@ export default defineCommand({
});
await confirmNamedReview(input, args, service, project.dir);
await chooseAudience(input, args, service);
if (input.includeSource)
input.expectedReferencedHiddenDigest = await showReferencedHiddenAssets(project.dir);
const result = await service.run(input);
await presentResult(result, input, Boolean(args.json));
} catch (error) {
Expand All @@ -106,6 +113,18 @@ export default defineCommand({
},
});

async function showReferencedHiddenAssets(dir: string) {
const paths = await listReferencedHiddenSourceAssets(dir);
if (paths.length) {
const lines = [
"Editable source includes these referenced hidden assets",
...paths.map(quotedFilePath),
];
console.error(terminalLines(lines.join("\n")));
}
return referencedHiddenDigest(paths);
}

interface ShareArgs {
public?: boolean;
team?: boolean;
Expand Down
11 changes: 10 additions & 1 deletion packages/cli/src/server/shareEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,16 @@ function settingInteraction(value: object & { event: unknown }): LocalShareInter
return destination === undefined ? null : { event: value.event, destination };
}
case "share_action_clicked": {
const action = choice(field("action"), "share", "update", "access", "off", "on", "login");
const action = choice(
field("action"),
"share",
"update",
"access",
"off",
"on",
"login",
"sync",
);
return action === undefined ? null : { event: value.event, action };
}
default:
Expand Down
74 changes: 63 additions & 11 deletions packages/cli/src/server/shareRoutes.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { describe, expect, it, vi } from "vitest";
import { mkdir, mkdtemp, rm, writeFile } from "node:fs/promises";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { Hono } from "hono";
import type { ShareService, ShareState } from "../share/service.js";
import { mountShareRoutes } from "./shareRoutes.js";
Expand All @@ -20,7 +23,7 @@ const state: ShareState = {
reviewId: null,
reviewTitle: null,
};
function fixture() {
function fixture(dir = "/fixed/project") {
const service: ShareService = {
checkSession: vi.fn(async () => ({
token: "secret",
Expand All @@ -29,6 +32,8 @@ function fixture() {
heygenApi: "https://api.heygen.com",
})),
status: vi.fn(async () => state),
sourceStatus: vi.fn(async () => "needs_sync" as const),
syncProjectFiles: vi.fn(async () => state),
run: vi.fn(async () => state),
spaces: vi.fn(async () => []),
capabilities: vi.fn(async () => ({ versionSharing: true, shareFiles: false })),
Expand All @@ -40,7 +45,7 @@ function fixture() {
const create = vi.fn(async () => service);
const login = vi.fn(async () => {});
const track = vi.fn();
mountShareRoutes(app, "/fixed/project", create, login, track);
mountShareRoutes(app, dir, create, login, track);
return { app, service, create, login, track };
}
const LOCAL_PEER = { incoming: { socket: { remoteAddress: "127.0.0.1" } } };
Expand Down Expand Up @@ -457,17 +462,27 @@ it("shows a completed login's admission failure to its initiating panel", async
});
});

it.each([undefined, true])("forwards only explicit source consent (%s)", async (includeSource) => {
it("only the sync action can upload project files", async () => {
const { app, service } = fixture();
const csrf = await token(app);
const response = await request(app, "actions", csrf, {
action: "share",
audience: "public",
includeSource,
});
expect(response.status).toBe(202);
await new Promise((resolve) => setTimeout(resolve, 0));
expect(service.run).toHaveBeenCalledWith(expect.objectContaining({ includeSource }));
const digest = "a".repeat(64);
for (const body of [
{ action: "share", audience: "public", includeSource: true },
{ action: "update", expectedReferencedHiddenDigest: digest },
{ action: "sync", space: "team1" },
])
expect((await request(app, "actions", csrf, body)).status).toBe(400);
expect(
(
await request(app, "actions", csrf, {
action: "sync",
space: "team1",
expectedReferencedHiddenDigest: digest,
})
).status,
).toBe(202);
await vi.waitFor(() => expect(service.syncProjectFiles).toHaveBeenCalledWith("team1", digest));
expect(service.run).not.toHaveBeenCalled();
});

describe("share actions need the review the person confirmed", () => {
Expand Down Expand Up @@ -543,3 +558,40 @@ describe("share actions need the review the person confirmed", () => {
await vi.waitFor(() => expect(login).toHaveBeenCalled());
});
});

it("lists referenced hidden assets only in the local sharing session", async () => {
const dir = await mkdtemp(join(tmpdir(), "hf-share-summary-"));
try {
const font = "brand/.fonts/Inter.woff2";
const logo = "brand/.images/logo.png";
for (const path of ["brand/.fonts", "brand/.images", "styles", "modules"])
await mkdir(join(dir, path), { recursive: true });
await mkdir(join(dir, ".ssh"));
await writeFile(join(dir, font), "font");
await writeFile(join(dir, logo), "logo");
await writeFile(
join(dir, "styles/theme.css"),
`@font-face{font-family:Inter;src:url("../${font}")}`,
);
await writeFile(join(dir, "modules/brand.mjs"), `new URL("../${logo}", import.meta.url)`);
await writeFile(join(dir, "brand/.fonts/Unused.woff2"), "unused");
await writeFile(join(dir, ".ssh/photo.png"), "private");
await writeFile(
join(dir, "index.html"),
'<link rel="stylesheet" href="styles/theme.css"><script type="module" src="modules/brand.mjs"></script><img src=".ssh/photo.png">',
);
const { app } = fixture(dir);
expect((await request(app, "project-files?space=team1", "")).status).toBe(403);
const csrf = await token(app);
const summary = await (await request(app, "project-files?space=team1", csrf)).json();
expect(summary).toEqual({
state: "needs_sync",
paths: [font, logo],
digest: expect.stringMatching(/^[0-9a-f]{64}$/),
});
const missing = await request(app, "actions", csrf, { action: "update", includeSource: true });
expect(missing.status).toBe(400);
} finally {
await rm(dir, { recursive: true, force: true });
}
});
Loading
Loading