mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-18 16:08:56 +00:00
feat(studio): the desktop-app button says Install the desktop app and never dead-ends (#5854)
* feat(studio): the header's desktop-app button says Install the desktop app and never dead-ends The button now reads "Install the desktop app" beside Framey drawn as the app draws it. Where the app is installed, a press opens this project in it; a folder preview serves from a bare index.html gets its hyperframes.json first, so the app no longer refuses it. Without the app, the button links straight to hyperframes.dev's download, and a failed open lands there too. Platforms with no build of the app show no button. Telemetry now records eligibility, one impression, the click and the press outcome, with OS, app installed and download available. * feat(studio): the desktop-app button records eligibility, impression, click and outcome * feat(studio): a desktop-app press carries its page id to the download and the app hand-off * chore(studio): describe Framey's drawing without internal names * feat(studio): the desktop-app button opens a guide that walks download, install and open Without the app, the header button opens a card where Framey walks three steps: the download opens in a new tab, the install is found by asking the preview server while the card is open, and the project opens through the existing hand-off. A failed hand-off shows the folder to copy and Try again. With the app ready the press opens the project directly. Each step change is recorded through trackStudioEvent; a download is never counted as an install. * fix(studio): the desktop-app guide counts one install per page The app removed and found again on the same page recorded install_detected twice; a page latch keeps it to one, as the telemetry contract says.
This commit is contained in:
@@ -1,6 +1,15 @@
|
||||
import { chmodSync, existsSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
||||
import {
|
||||
chmodSync,
|
||||
existsSync,
|
||||
mkdtempSync,
|
||||
readdirSync,
|
||||
readFileSync,
|
||||
rmSync,
|
||||
writeFileSync,
|
||||
} from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join, resolve, win32 } from "node:path";
|
||||
import { isHyperframesProject } from "@hyperframes/core";
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { readSeen } from "./appHistory.js";
|
||||
import {
|
||||
@@ -43,6 +52,48 @@ describe("openInDesktop", () => {
|
||||
expect(asked).toEqual([`dev.hyperframes.desktop ${FILM}`]);
|
||||
});
|
||||
|
||||
it("hands over a folder preview serves from a bare index.html as a project the app accepts", () => {
|
||||
const dir = mkdtempSync(join(tmpdir(), "hf-bare-"));
|
||||
try {
|
||||
writeFileSync(join(dir, "index.html"), "<html></html>");
|
||||
let marked: boolean | null = null;
|
||||
const result = openInDesktop(dir, {
|
||||
...LIVE,
|
||||
open: (_id, folder) => ((marked = isHyperframesProject(readdirSync(folder))), true),
|
||||
});
|
||||
expect(result).toMatchObject({ opened: true });
|
||||
expect(marked).toBe(true);
|
||||
} finally {
|
||||
rmSync(dir, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
it("leaves the press's page id for the app only when the app took the folder", () => {
|
||||
const dir = mkdtempSync(join(tmpdir(), "hf-cta-"));
|
||||
const record = join(dir, ".hyperframes", "desktop-cta.json");
|
||||
try {
|
||||
writeFileSync(join(dir, "index.html"), "<html></html>");
|
||||
openInDesktop(dir, { ...LIVE, cta: "page-1", open: () => false, installed: () => false });
|
||||
expect(existsSync(record)).toBe(false);
|
||||
openInDesktop(dir, { ...LIVE, cta: "page-1", open: () => true });
|
||||
expect(JSON.parse(readFileSync(record, "utf8"))).toMatchObject({ cta: "page-1" });
|
||||
} finally {
|
||||
rmSync(dir, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
it("leaves a project's own marker file alone", () => {
|
||||
const dir = mkdtempSync(join(tmpdir(), "hf-marked-"));
|
||||
try {
|
||||
writeFileSync(join(dir, "index.html"), "<html></html>");
|
||||
writeFileSync(join(dir, "meta.json"), "{}");
|
||||
openInDesktop(dir, { ...LIVE, open: () => true });
|
||||
expect(existsSync(join(dir, "hyperframes.json"))).toBe(false);
|
||||
} finally {
|
||||
rmSync(dir, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
it("falls back to Canary when only Canary is installed", () => {
|
||||
const result = openInDesktop(FILM, { ...LIVE, open: (id) => id.endsWith(".canary") });
|
||||
expect(result).toMatchObject({ opened: true, app: "HyperFrames Canary" });
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
import { spawn, spawnSync } from "node:child_process";
|
||||
import { existsSync, readFileSync } from "node:fs";
|
||||
import { existsSync, readdirSync, readFileSync } from "node:fs";
|
||||
import { homedir } from "node:os";
|
||||
import { basename, isAbsolute, join, relative, win32 } from "node:path";
|
||||
import { isHyperframesProject } from "@hyperframes/core";
|
||||
import { addCatchUpNote, markSeen, readSeen } from "./appHistory.js";
|
||||
import { createProjectConfig } from "./projectConfig.js";
|
||||
import { writeRecord } from "./projectRecords.js";
|
||||
|
||||
// The HyperFrames desktop app (not "Studio"): `open -b` on macOS, its executable elsewhere; released, then Canary.
|
||||
@@ -32,6 +34,8 @@ export interface AgentSession {
|
||||
}
|
||||
|
||||
export const AGENT_HANDOFF_FILE = join(".hyperframes", "agent-handoff.json");
|
||||
/** The Studio page's telemetry `tab_id`, left for the app to report its first open and export against. */
|
||||
const DESKTOP_CTA_RECORD = "desktop-cta.json";
|
||||
|
||||
// ponytail: Claude Code, then Codex, then Grok; an agent started inside another's shell carries both, unsorted.
|
||||
export function agentSession(env: NodeJS.ProcessEnv = process.env): AgentSession | null {
|
||||
@@ -131,6 +135,17 @@ function leaveHandoff(dir: string, session: AgentSession | null): AgentSession |
|
||||
return session;
|
||||
}
|
||||
|
||||
function markBareIndexAsProject(dir: string): void {
|
||||
try {
|
||||
if (existsSync(join(dir, "index.html")) && !isHyperframesProject(readdirSync(dir)))
|
||||
createProjectConfig(dir);
|
||||
} catch (error) {
|
||||
console.warn(
|
||||
`◇ Couldn't add hyperframes.json to ${dir}, so the app may not open it: ${error}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// ponytail: success on Windows and Linux means the spawn started, not that the app took the folder; wait for the
|
||||
// app's own acknowledgement if a broken install ever needs reporting.
|
||||
export function openInDesktop(
|
||||
@@ -142,8 +157,10 @@ export function openInDesktop(
|
||||
launch = launchApp,
|
||||
installed = () => desktopInstalled({ platform }),
|
||||
env = process.env,
|
||||
cta,
|
||||
...where
|
||||
}: AppLookup & {
|
||||
cta?: string;
|
||||
ready?: boolean;
|
||||
open?: (bundleId: string, dir: string) => boolean;
|
||||
launch?: (executable: string, dir: string) => boolean;
|
||||
@@ -157,12 +174,16 @@ export function openInDesktop(
|
||||
reason,
|
||||
downloadUrl: desktopDownloadUrl(platform) ?? STUDIO_PAGE,
|
||||
});
|
||||
const opened = (canary: boolean): DesktopOpenResult => ({
|
||||
opened: true,
|
||||
app: canary ? "HyperFrames Canary" : "the HyperFrames desktop app",
|
||||
handedOver: leaveHandoff(dir, agentSession(env)),
|
||||
});
|
||||
const opened = (canary: boolean): DesktopOpenResult => {
|
||||
if (cta) writeRecord(dir, DESKTOP_CTA_RECORD, JSON.stringify({ cta, at: Date.now() }));
|
||||
return {
|
||||
opened: true,
|
||||
app: canary ? "HyperFrames Canary" : "the HyperFrames desktop app",
|
||||
handedOver: leaveHandoff(dir, agentSession(env)),
|
||||
};
|
||||
};
|
||||
if (!ready) return notOpened("handoff-unavailable");
|
||||
markBareIndexAsProject(dir);
|
||||
if (platform === "darwin") {
|
||||
const bundleId = DESKTOP_BUNDLE_IDS.find((id) => open(id, dir));
|
||||
if (!bundleId) return notOpened(installed() ? "open-failed" : "not-installed");
|
||||
|
||||
Reference in New Issue
Block a user