Skip to content

Commit 454c9c8

Browse files
committed
fix(mcp): say when device names need a permission, refuse GIF flags on an MP4
Part of #1180
1 parent 47b8daa commit 454c9c8

4 files changed

Lines changed: 20 additions & 2 deletions

File tree

‎electron/cli/args.test.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,10 @@ describe("parseCliArgs", () => {
172172
expect(parse(["export", "a.openscreen", "--format", "gif", "--fps", "30"])).toMatchObject({
173173
kind: "error",
174174
});
175+
expect(parse(["export", "a.openscreen", "-o", "a.mp4", "--no-gif-loop"])).toMatchObject({
176+
kind: "error",
177+
message: "--no-gif-loop is only supported for GIF exports",
178+
});
175179
});
176180

177181
it("parses --auto-zoom", () => {

‎electron/cli/args.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,13 @@ function parseExport(args: string[], cwd: string): CliCommand {
334334
if (request.format === "gif" && args.includes("--fps")) {
335335
throw new Error("--fps is only supported for MP4 exports (use --gif-fps)");
336336
}
337+
// And the GIF options, on an MP4 they would not change.
338+
const gifFlag = ["--gif-fps", "--gif-size", "--gif-loop", "--no-gif-loop"].find((flag) =>
339+
args.includes(flag),
340+
);
341+
if (request.format === "mp4" && gifFlag) {
342+
throw new Error(`${gifFlag} is only supported for GIF exports`);
343+
}
337344
return request;
338345
}
339346

‎electron/mcp/media-tools.test.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,11 @@ describe("recording", () => {
327327
},
328328
};
329329
const listed = JSON.parse(textOf(await call("listSources")));
330-
expect(listed).toMatchObject({ microphones: ["USB Mic"], cameras: ["Logitech BRIO"] });
330+
expect(listed).toMatchObject({
331+
microphones: ["USB Mic"],
332+
cameras: ["Logitech BRIO"],
333+
cameraLabelsUnavailable: false,
334+
});
331335
});
332336

333337
it("says where the take is when it cannot become a project", async () => {

‎electron/mcp/media-tools.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ export function createMediaTools(deps: MediaToolDeps): MediaTools {
541541
server.registerTool(
542542
"listSources",
543543
{
544-
description: `List the displays and windows OpenScreen can record, the microphones and the cameras. Pass startRecording a display's index or part of a window's title, and part of a microphone's or a camera's name. ${HIDDEN_WINDOWS_NOTE}`,
544+
description: `List the displays and windows OpenScreen can record, the microphones and the cameras. Pass startRecording a display's index or part of a window's title, and part of a microphone's or a camera's name. microphoneLabelsUnavailable or cameraLabelsUnavailable true means their names need a permission the user has not granted, so the list is empty: ask the user to allow it. ${HIDDEN_WINDOWS_NOTE}`,
545545
inputSchema: z.object({}),
546546
annotations: READ_ONLY,
547547
},
@@ -557,6 +557,9 @@ export function createMediaTools(deps: MediaToolDeps): MediaTools {
557557
windows: windows.map((window) => window.name),
558558
microphones: microphones.map((mic) => mic.label),
559559
cameras: cameras.map((camera) => camera.label),
560+
// An empty list is not "none" when the names need a permission: say which.
561+
microphoneLabelsUnavailable: result.sources.microphoneLabelsUnavailable,
562+
cameraLabelsUnavailable: result.sources.cameraLabelsUnavailable,
560563
}),
561564
);
562565
},

0 commit comments

Comments
 (0)