Skip to content
Merged
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
10 changes: 5 additions & 5 deletions electron/ai-edition/chat-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// `toolEnd` lifecycle + `error` events into the renderer through the
// ChatEventSink.

import { v4 as uuidv4 } from "uuid";
import { randomUUID } from "node:crypto";
import {
type AxcutTimelineOperation,
applyTimelineOperation,
Expand Down Expand Up @@ -160,7 +160,7 @@ export function listSessions(projectId: string): ChatSessionSummary[] {

export function createSession(projectId: string, title?: string): ChatSessionSummary {
const m = getProjectSessions(projectId);
const id = `sess_${uuidv4()}`;
const id = `sess_${randomUUID()}`;
const now = new Date().toISOString();
const session: ChatSession = {
id,
Expand Down Expand Up @@ -278,7 +278,7 @@ export async function runChat(
}

const userMessage: AiEditionChatMessage = {
id: uuidv4(),
id: randomUUID(),
role: "user",
content: message,
createdAt: new Date().toISOString(),
Expand Down Expand Up @@ -369,7 +369,7 @@ export async function runChat(
}

const assistantMessage: AiEditionChatMessage = {
id: uuidv4(),
id: randomUUID(),
role: "assistant",
content: result.text,
createdAt: new Date().toISOString(),
Expand Down Expand Up @@ -494,7 +494,7 @@ export async function runTimelineOperation(

if (conversationMessage.trim() && session) {
const assistantMessage: AiEditionChatMessage = {
id: `msg_${uuidv4()}`,
id: `msg_${randomUUID()}`,
role: "assistant",
content: conversationMessage.trim(),
createdAt: new Date().toISOString(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import type {
NativeCursorAsset,
NativeCursorType,
} from "../../../../src/native/contracts";
import { clamp } from "../../../../src/utils/math";
import type { CursorRecordingSession } from "./session";

interface MacCursorAssetPayload {
Expand Down Expand Up @@ -173,10 +174,6 @@ export async function requestMacCursorAccessibilityAccess() {
);
}

function clamp(value: number, min: number, max: number) {
return Math.min(max, Math.max(min, value));
}

function normalizeCursorType(value: unknown): NativeCursorType | null {
return value === "arrow" || value === "pointer" || value === "text" ? value : null;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { type Rectangle, screen } from "electron";
import type { CursorRecordingData, CursorRecordingSample } from "../../../../src/native/contracts";
import { clamp } from "../../../../src/utils/math";
import type { CursorRecordingSession } from "./session";

interface TelemetryRecordingSessionOptions {
Expand All @@ -9,10 +10,6 @@ interface TelemetryRecordingSessionOptions {
startTimeMs?: number;
}

function clamp(value: number, min: number, max: number) {
return Math.min(max, Math.max(min, value));
}

export class TelemetryRecordingSession implements CursorRecordingSession {
private samples: CursorRecordingSample[] = [];
private interval: NodeJS.Timeout | null = null;
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@
"sonner": "^2.0.7",
"tailwind-merge": "^3.5.0",
"tailwindcss-animate": "^1.0.7",
"uuid": "^13.0.0",
"web-demuxer": "^4.0.0",
"zod": "^4.1.12",
"zustand": "^5.0.8"
Expand Down
115 changes: 5 additions & 110 deletions scripts/build-windows-compositor-addon.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,125 +15,20 @@
// shipped, and require() fails at runtime even with the right dir on PATH.
// See poc-d3d/.cargo/config.toml for the pin.

import { spawn, spawnSync } from "node:child_process";
import fs from "node:fs";
import path from "node:path";
import { fileURLToPath } from "node:url";
import { findVcVarsAll, run as spawnStep } from "./msvcEnv.mjs";

const __dirname = path.dirname(fileURLToPath(import.meta.url));
const ROOT = path.join(__dirname, "..");
const POC_D3D_DIR = path.join(ROOT, "poc-d3d");
const BUILD_OUT_DIR = path.join(ROOT, "electron", "native", "compositor-view", "build");

function findVcVarsAll() {
const explicit = process.env.VCVARSALL;
if (explicit && fs.existsSync(explicit)) {
return explicit;
}

const vswhere = "C:\\Program Files (x86)\\Microsoft Visual Studio\\Installer\\vswhere.exe";
if (fs.existsSync(vswhere)) {
const result = spawnSync(
vswhere,
[
"-latest",
"-products",
"*",
"-requires",
"Microsoft.VisualStudio.Component.VC.Tools.x86.x64",
"-property",
"installationPath",
],
{ encoding: "utf8", windowsHide: true },
);
const installPath = result.stdout?.trim();
if (result.status === 0 && installPath) {
const candidate = path.join(installPath, "VC", "Auxiliary", "Build", "vcvarsall.bat");
if (fs.existsSync(candidate)) {
return candidate;
}
}
}

if (process.env.VSINSTALLDIR) {
const candidate = path.join(
process.env.VSINSTALLDIR,
"VC",
"Auxiliary",
"Build",
"vcvarsall.bat",
);
if (fs.existsSync(candidate)) {
return candidate;
}
}

// vswhere doesn't always enumerate pre-release channels (e.g. "Insiders"
// builds) — walk the install roots generically so new VS releases and
// preview channels are found automatically (same policy as the wgc-capture
// helper build script).
const editions = ["Community", "Professional", "Enterprise", "BuildTools"];
const installRoots = [
"C:\\Program Files\\Microsoft Visual Studio",
"C:\\Program Files (x86)\\Microsoft Visual Studio",
];

const listDirs = (dir) => {
try {
return fs
.readdirSync(dir, { withFileTypes: true })
.filter((entry) => entry.isDirectory())
.map((entry) => path.join(dir, entry.name));
} catch {
return [];
}
};

for (const installRoot of installRoots) {
for (const versionDir of listDirs(installRoot)) {
for (const channelDir of [versionDir, ...listDirs(versionDir)]) {
const direct = path.join(channelDir, "VC", "Auxiliary", "Build", "vcvarsall.bat");
if (fs.existsSync(direct)) {
return direct;
}
for (const edition of editions) {
const nested = path.join(
channelDir,
edition,
"VC",
"Auxiliary",
"Build",
"vcvarsall.bat",
);
if (fs.existsSync(nested)) {
return nested;
}
}
}
}
}

return null;
}

function run(command, args, options = {}) {
return new Promise((resolve, reject) => {
const child = spawn(command, args, {
cwd: POC_D3D_DIR,
stdio: "inherit",
windowsHide: true,
...options,
});
child.once("error", reject);
child.once("exit", (code) => {
if (code === 0) {
resolve();
} else {
reject(new Error(`${command} ${args.join(" ")} failed with code ${code}`));
}
});
});
}
// cwd defaults to poc-d3d/, not ROOT: cargo reads FFMPEG_DIR and LIBCLANG_PATH
// from poc-d3d/.cargo/config.toml, which only applies when it runs from there.
const run = (command, args, options = {}) =>
spawnStep(command, args, { cwd: POC_D3D_DIR, ...options });

async function runInVsEnv(command) {
const vcvarsAll = findVcVarsAll();
Expand Down
116 changes: 2 additions & 114 deletions scripts/build-windows-wgc-helper.mjs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { spawn, spawnSync } from "node:child_process";
import fs from "node:fs";
import os from "node:os";
import path from "node:path";
import { fileURLToPath } from "node:url";
import { findVcVarsAll, run as spawnStep } from "./msvcEnv.mjs";

const __dirname = path.dirname(fileURLToPath(import.meta.url));
const ROOT = path.join(__dirname, "..");
Expand All @@ -12,101 +12,6 @@ const COMPAT_LIB_DIR = path.join(BUILD_DIR, "compat-libs");
const BIN_DIR = path.join(ROOT, "electron", "native", "bin", "win32-x64");
const CMAKE = process.env.CMAKE_EXE ?? "cmake";

function findVcVarsAll() {
const explicit = process.env.VCVARSALL;
if (explicit && fs.existsSync(explicit)) {
return explicit;
}

const vswhere = "C:\\Program Files (x86)\\Microsoft Visual Studio\\Installer\\vswhere.exe";
if (fs.existsSync(vswhere)) {
const result = spawnSync(
vswhere,
[
"-latest",
"-products",
"*",
"-requires",
"Microsoft.VisualStudio.Component.VC.Tools.x86.x64",
"-property",
"installationPath",
],
{ encoding: "utf8", windowsHide: true },
);
const installPath = result.stdout?.trim();
if (result.status === 0 && installPath) {
const candidate = path.join(installPath, "VC", "Auxiliary", "Build", "vcvarsall.bat");
if (fs.existsSync(candidate)) {
return candidate;
}
}
}

if (process.env.VSINSTALLDIR) {
const candidate = path.join(
process.env.VSINSTALLDIR,
"VC",
"Auxiliary",
"Build",
"vcvarsall.bat",
);
if (fs.existsSync(candidate)) {
return candidate;
}
}

// vswhere doesn't always enumerate pre-release channels (e.g. "Insiders"
// builds), and the on-disk layout for those isn't a stable "<year>\<edition>"
// path -- Visual Studio 2026 Insiders installs under a numeric product
// version folder like "18\Insiders\<edition>" instead of "2026\<edition>".
// Walk the install roots generically instead of hard-coding version/channel
// names so new VS releases and preview channels are found automatically.
const editions = ["Community", "Professional", "Enterprise", "BuildTools"];
const installRoots = [
"C:\\Program Files\\Microsoft Visual Studio",
"C:\\Program Files (x86)\\Microsoft Visual Studio",
];

const listDirs = (dir) => {
try {
return fs
.readdirSync(dir, { withFileTypes: true })
.filter((entry) => entry.isDirectory())
.map((entry) => path.join(dir, entry.name));
} catch {
return [];
}
};

for (const installRoot of installRoots) {
for (const versionDir of listDirs(installRoot)) {
// versionDir is either an edition directly ("2022\Community") or a
// channel that nests editions ("18\Insiders\Community").
for (const channelDir of [versionDir, ...listDirs(versionDir)]) {
const direct = path.join(channelDir, "VC", "Auxiliary", "Build", "vcvarsall.bat");
if (fs.existsSync(direct)) {
return direct;
}
for (const edition of editions) {
const nested = path.join(
channelDir,
edition,
"VC",
"Auxiliary",
"Build",
"vcvarsall.bat",
);
if (fs.existsSync(nested)) {
return nested;
}
}
}
}
}

return null;
}

function findWindowsSdkUmLibDir() {
const sdkLibRoot = "C:\\Program Files (x86)\\Windows Kits\\10\\Lib";
if (!fs.existsSync(sdkLibRoot)) {
Expand All @@ -122,24 +27,7 @@ function findWindowsSdkUmLibDir() {
.at(-1);
}

function run(command, args, options = {}) {
return new Promise((resolve, reject) => {
const child = spawn(command, args, {
cwd: ROOT,
stdio: "inherit",
windowsHide: true,
...options,
});
child.once("error", reject);
child.once("exit", (code) => {
if (code === 0) {
resolve();
} else {
reject(new Error(`${command} ${args.join(" ")} failed with code ${code}`));
}
});
});
}
const run = (command, args, options = {}) => spawnStep(command, args, { cwd: ROOT, ...options });

async function runInVsEnv(command) {
const vcvarsAll = findVcVarsAll();
Expand Down
Loading
Loading