Skip to content

Commit acb2d3d

Browse files
committed
fix(mcp): let the editor read an imported .oga, keep a created project's id when its checkpoint fails, check an existing video for private content
Part of #1180
1 parent 04c7c49 commit acb2d3d

3 files changed

Lines changed: 22 additions & 8 deletions

File tree

‎electron/ipc/handlers.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,7 @@ const ALLOWED_IMPORT_AUDIO_EXTENSIONS = new Set([
274274
".aac",
275275
".flac",
276276
".ogg",
277+
".oga",
277278
".opus",
278279
]);
279280

‎electron/mcp/media-tools.ts‎

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -443,11 +443,17 @@ export function createMediaTools(deps: MediaToolDeps): MediaTools {
443443

444444
/** A fresh project's checkpoint, so a client can edit it at once and take it back in one step. */
445445
async function checkpointOf(projectId: string): Promise<string | null> {
446-
const checkpoint = await deps.runTool("createCheckpoint", { projectId });
447-
const checkpointText = checkpoint.content[0]?.type === "text" ? checkpoint.content[0].text : "";
448-
return checkpoint.isError
449-
? null
450-
: ((JSON.parse(checkpointText) as { checkpointId?: string }).checkpointId ?? null);
446+
// Never fails the call: the project exists either way, and its id is the answer.
447+
try {
448+
const checkpoint = await deps.runTool("createCheckpoint", { projectId });
449+
const checkpointText =
450+
checkpoint.content[0]?.type === "text" ? checkpoint.content[0].text : "";
451+
return checkpoint.isError
452+
? null
453+
: ((JSON.parse(checkpointText) as { checkpointId?: string }).checkpointId ?? null);
454+
} catch {
455+
return null;
456+
}
451457
}
452458

453459
/** Stops the take, then hands back its project with a checkpoint of it. */
@@ -838,8 +844,15 @@ export function createMediaTools(deps: MediaToolDeps): MediaTools {
838844
}
839845
const title = args.title?.trim();
840846
if (args.videoPath === undefined) {
841-
const created = await deps.documents.createProject(title ?? "");
842-
const projectId = created.project.id;
847+
let projectId: string;
848+
try {
849+
projectId = (await deps.documents.createProject(title ?? "")).project.id;
850+
} catch (error) {
851+
return text(
852+
`No project was created: ${error instanceof Error ? error.message : String(error)}`,
853+
true,
854+
);
855+
}
843856
return text(JSON.stringify({ projectId, checkpointId: await checkpointOf(projectId) }));
844857
}
845858
const videoPath = args.videoPath;

‎skills/openscreen-demo/SKILL.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ Write a storyboard and show it to the user in a few lines, then carry on unless
6868
- **Real mouse** (computer-use, or any tool that moves the actual pointer): OpenScreen records the pointer, draws a clean cursor and already zooms on the clicks (see *Zoom on the action* below). If your mouse tool cannot click in the app's window (some only read browsers, for one), drive it from a script instead.
6969
- **A script** (Playwright, CDP): the screen pointer never moves, so the take has no cursor and no zoom. In the script, log every action as it runs: `at` is `Date.now()`, `x` and `y` are the action's position as fractions of the window, `click` is true for a click. Hand the log to `setPointerTrack` after `stopRecording`; its description gives the formula from a page's coordinates. A script also gives the cleanest take: same timing on every run, no hesitation.
7070

71-
**A video you already have** needs no recording: `createProject` with its absolute `videoPath` lays it out as a project, and returns a `projectId` and a `checkpointId` as `stopRecording` does. Then go on from step 6.
71+
**A video you already have** needs no recording: `createProject` with its absolute `videoPath` lays it out as a project, and returns a `projectId` and a `checkpointId` as `stopRecording` does. Check it as a take in step 5, its `videoPath` included, then go on from step 6.
7272

7373
## 5. Check the take
7474

0 commit comments

Comments
 (0)