mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-24 16:06:34 +00:00
* feat(studio,cli): add an Edit with Framey button and `hyperframes open` for HyperFrames Studio
Point people from the CLI and the Studio preview to HyperFrames Studio, the desktop app.
- Studio header: an "Edit with Framey" button with Framey, the app's cursor mascot (the eye
follows the pointer, a wiggle on hover, honours reduced motion). Until the app opens
handed-over projects (HANDOFF_READY), a press shows a "Meet Framey" card with the download.
The button shows only where the preview server answers GET /api/open-in-desktop on macOS,
so the desktop app's own embedded Studio never shows it.
- `hyperframes open [dir]`: hands the project folder to the app with `open -b` (released app,
then Canary) and points to the download when neither is installed. When run by Claude Code
or Codex it leaves .hyperframes/agent-handoff.json (CLAUDE_CODE_SESSION_ID / CODEX_THREAD_ID)
so the app's first chat can pick up that conversation.
- render and preview print one line about the app: the download until HANDOFF_READY, then
`hyperframes open` when the app is installed. Nothing for a draft render, a batch row, or a
run inside the app (HYPERFRAMES_DESKTOP_PROJECT).
* fix(studio,cli): gate `hyperframes open` too, guard the open-in-desktop POST, keep one gate
Review of #4951 at 58934a34.
- One gate: HANDOFF_READY lives only in the CLI. `GET /api/open-in-desktop` now says
`handoff`, and Studio's button reads it, so the gate cannot be half-flipped.
- While gated nothing opens and nothing is written: `openInDesktop` returns
`handoff-unavailable` (so `hyperframes open` prints the download line and the POST route
answers with it), and no `.hyperframes/agent-handoff.json` can sit waiting for a later release.
- The POST answers only Studio's own same-origin request (loopback Host, matching Origin,
Sec-Fetch-Site same-origin); a cross-site or rebound-host POST gets 403. Routes moved to
server/desktopRoutes.ts with their own tests.
- `hyperframes open`: exits 1 when nothing opened, answers in JSON under --json for a bad
directory, and tells a missing app from one macOS could not open (`open-failed`). A project
that cannot be written still opens, with nothing handed over.
- Tests drive the live path through `ready`, are path-portable for Windows, and cover the draft
and batch-row hint skips (`wantsDesktopHint`, `batchRowRenderOptions`).
- The load smoke mocks the route.
* feat(cli,studio): hand off on macos now, and open the app on windows and linux
The released Mac app (b254) takes a handed-over folder and its conversation, so
HANDOFF_READY turns on for macOS. Windows and Linux stay on the download until the
desktop change that reads a folder from the command line ships.
- `hyperframes open` finds the app off macOS: the per-user install on Windows, and
on Linux the AppImage the app records in launcher.json; it starts it with the folder
- download links follow the machine: the DMG on macOS, the AppImage on Linux, and
nothing on Windows, which has no public download yet
- the Studio button shows wherever there is a download or an installed app; the card
no longer says "for macOS"
- every render prints the app line except batch rows: music-to-video delivers a draft
- the success line names the app that took the folder (Canary included)
* fix(studio): the edit-with-framey button asks its route through studioApiFetch
* fix(cli,studio): name the app the hyperframes desktop app, apart from the studio preview
* fix(cli,studio): fewer comment lines, so no file's comment share rises
131 lines
4.3 KiB
TypeScript
131 lines
4.3 KiB
TypeScript
// @vitest-environment happy-dom
|
|
|
|
/**
|
|
* "Edit with Framey": shown where the preview server has the app or its download to offer; a press opens the project in the app,
|
|
* or introduces Framey with the download while the app cannot take it or is missing.
|
|
*/
|
|
import React, { act } from "react";
|
|
import { createRoot, type Root } from "react-dom/client";
|
|
import { afterEach, beforeEach, expect, it, vi } from "vitest";
|
|
|
|
(globalThis as unknown as { IS_REACT_ACT_ENVIRONMENT: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
|
|
|
|
const showToast = vi.fn();
|
|
vi.mock("../contexts/StudioContext", () => ({ useStudioShellContext: () => ({ showToast }) }));
|
|
vi.mock("../utils/studioTelemetry", () => ({ trackStudioEvent: vi.fn() }));
|
|
|
|
const { OpenInDesktopButton } = await import("./OpenInDesktopButton");
|
|
|
|
const DOWNLOAD = "https://hyperframes.dev/studio/download";
|
|
let mounted: { root: Root; host: HTMLElement } | null = null;
|
|
let posts: number;
|
|
|
|
function serve(get: Response | null, post?: unknown) {
|
|
posts = 0;
|
|
vi.stubGlobal(
|
|
"fetch",
|
|
vi.fn(async (_url: string, init?: RequestInit) => {
|
|
if (init?.method === "POST") {
|
|
posts += 1;
|
|
return Response.json(post);
|
|
}
|
|
return get ?? new Response("Not found", { status: 404 });
|
|
}),
|
|
);
|
|
}
|
|
|
|
async function mount(): Promise<HTMLElement> {
|
|
const host = document.createElement("div");
|
|
document.body.append(host);
|
|
const root = createRoot(host);
|
|
mounted = { root, host };
|
|
await act(async () => root.render(<OpenInDesktopButton />));
|
|
return host;
|
|
}
|
|
|
|
const downloadHref = () =>
|
|
[...document.querySelectorAll("a")]
|
|
.find((a) => a.textContent?.includes("Get the desktop app"))
|
|
?.getAttribute("href");
|
|
|
|
const button = () =>
|
|
document.querySelector<HTMLButtonElement>('[data-testid="header-open-in-desktop"]');
|
|
|
|
beforeEach(() => showToast.mockReset());
|
|
|
|
afterEach(() => {
|
|
vi.unstubAllGlobals();
|
|
if (!mounted) return;
|
|
const { root, host } = mounted;
|
|
mounted = null;
|
|
act(() => root.unmount());
|
|
host.remove();
|
|
});
|
|
|
|
it("stays hidden where the server has no hand-off (the desktop's own Studio)", async () => {
|
|
serve(null);
|
|
await mount();
|
|
expect(button()).toBeNull();
|
|
});
|
|
|
|
it("stays hidden when the app has no build for this machine (Windows)", async () => {
|
|
serve(Response.json({ available: false, handoff: true, downloadUrl: null }));
|
|
await mount();
|
|
expect(button()).toBeNull();
|
|
});
|
|
|
|
it("with the app installed but no download (Windows), shows only once the app can take the project", async () => {
|
|
serve(Response.json({ available: true, handoff: false, downloadUrl: null }));
|
|
await mount();
|
|
expect(button()).toBeNull();
|
|
});
|
|
|
|
it("opens the project in an installed app that has no download (Windows)", async () => {
|
|
serve(Response.json({ available: true, handoff: true, downloadUrl: null }), {
|
|
opened: true,
|
|
app: "the HyperFrames desktop app",
|
|
});
|
|
await mount();
|
|
await act(async () => button()!.click());
|
|
expect(posts).toBe(1);
|
|
});
|
|
|
|
it("while the app cannot take a project yet, introduces Framey with the download and opens nothing", async () => {
|
|
const linux = `${DOWNLOAD}?os=linux`;
|
|
serve(Response.json({ available: true, handoff: false, downloadUrl: linux }), { opened: true });
|
|
await mount();
|
|
await act(async () => button()!.click());
|
|
expect(posts).toBe(0);
|
|
expect(document.body.textContent).toContain("Meet Framey");
|
|
expect(downloadHref()).toBe(linux);
|
|
});
|
|
|
|
it("opens the project in the app and says so", async () => {
|
|
serve(Response.json({ available: true, handoff: true, downloadUrl: DOWNLOAD }), {
|
|
opened: true,
|
|
app: "the HyperFrames desktop app",
|
|
});
|
|
await mount();
|
|
await act(async () => button()!.click());
|
|
expect(posts).toBe(1);
|
|
expect(showToast).toHaveBeenCalledWith(
|
|
"Framey is opening this project in the HyperFrames desktop app",
|
|
"info",
|
|
);
|
|
expect(button()!.dataset.opening).toBe("true");
|
|
expect(document.body.textContent).not.toContain("Meet Framey");
|
|
});
|
|
|
|
it("introduces Framey and offers the download when the app is missing", async () => {
|
|
serve(Response.json({ available: true, handoff: true, downloadUrl: DOWNLOAD }), {
|
|
opened: false,
|
|
reason: "not-installed",
|
|
downloadUrl: DOWNLOAD,
|
|
});
|
|
await mount();
|
|
await act(async () => button()!.click());
|
|
expect(showToast).not.toHaveBeenCalled();
|
|
expect(document.body.textContent).toContain("Meet Framey");
|
|
expect(downloadHref()).toBe(DOWNLOAD);
|
|
});
|