Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.
TypeScript cross-platformelectronffmpegopen-sourceproduct-demorustscreen-capturescreen-recorderscreen-recordingscreen-studioscreencastspeech-to-texttypescriptvideo-editingvideo-editorwaylandwgpuwhisper
fix(mcp): leave the user's recording settings as they were when an in-app take fails or the app quits
EtienneLescot682862dd9583
diff --git a/electron/ipc/handlers.ts b/electron/ipc/handlers.tsindex 13c48543a..2df583509 100644--- a/electron/ipc/handlers.ts+++ b/electron/ipc/handlers.ts@@ -5081,25 +5081,7 @@ export function registerIpcHandlers(* user's own source and settings are what their next take starts from.*/async function pointHudAtTake(request: RecordRequest): Promise<() => void> {- const before = { source: selectedSource, live: selectedDesktopSource };- if (process.platform === "linux" && findPipeWireCursorHelperPath()) {- // The portal asks the user once the take starts: nothing here to select.- } else if (macPickerOwnsSources()) {- // Apple's picker asks for this take: an earlier pick must not stand in for it.- selectedSource = null;- selectedDesktopSource = null;- broadcastSelectedSource(null);- } else {- // The list listSources shows, in its order: its display indexes are this list's.- const sources = await getSourcesForPickers({- types: ["screen", "window"],- thumbnailSize: { width: 0, height: 0 },- });- const picked = pickRecordingSource(sources, request);- if (!(await selectSource(picked, { persist: false }))) {- throw new Error(`"${picked.name}" can no longer be recorded. Call listSources again.`);- }- }+ // The microphone first: finding it changes nothing, so a miss leaves all as it was.let microphone: Pick<RecordingPrefs, "micDeviceId" | "micDeviceName"> = {micDeviceId: null,micDeviceName: null,@@ -5119,6 +5101,38 @@ export function registerIpcHandlers(}microphone = { micDeviceId: match.deviceId ?? null, micDeviceName: match.label };}++ const before = { source: selectedSource, live: selectedDesktopSource };+ const restoreSource = () => {+ selectedSource = before.source;+ selectedDesktopSource = before.live;+ broadcastSelectedSource(before.source);+ };+ if (process.platform === "linux" && findPipeWireCursorHelperPath()) {+ // The portal asks the user once the take starts: nothing here to select.+ } else if (macPickerOwnsSources()) {+ // Apple's picker asks for this take: an earlier pick must not stand in for it.+ selectedSource = null;+ selectedDesktopSource = null;+ broadcastSelectedSource(null);+ } else {+ try {+ // The list listSources shows, in its order: its display indexes are this list's.+ const sources = await getSourcesForPickers({+ types: ["screen", "window"],+ thumbnailSize: { width: 0, height: 0 },+ });+ const picked = pickRecordingSource(sources, request);+ if (!(await selectSource(picked, { persist: false }))) {+ throw new Error(`"${picked.name}" can no longer be recorded. Call listSources again.`);+ }+ } catch (error) {+ // A failed pick may have cleared the selection: the user's comes back.+ restoreSource();+ throw error;+ }+ }+const prefs = recordingPrefs.get();recordingPrefs.set({micEnabled: request.mic,@@ -5126,7 +5140,10 @@ export function registerIpcHandlers(systemAudioEnabled: request.systemAudio,cursorCaptureMode: "editable-overlay",});- return () => {+ // The prefs are saved to disk: a quit mid-take must not leave the client's for the next+ // launch. ponytail: a crash still does; keep them in memory only if that bites.+ const restore = () => {+ app.off("will-quit", restore);recordingPrefs.set({micEnabled: prefs.micEnabled,micDeviceId: prefs.micDeviceId,@@ -5134,10 +5151,10 @@ export function registerIpcHandlers(systemAudioEnabled: prefs.systemAudioEnabled,cursorCaptureMode: prefs.cursorCaptureMode,});- selectedSource = before.source;- selectedDesktopSource = before.live;- broadcastSelectedSource(before.source);+ restoreSource();};+ app.once("will-quit", restore);+ return restore;}const mcpAppRecorder = createAppRecorder({diff --git a/electron/mcp/media-tools.test.ts b/electron/mcp/media-tools.test.tsindex fa8a391b4..3b9c01d76 100644--- a/electron/mcp/media-tools.test.ts+++ b/electron/mcp/media-tools.test.ts@@ -594,6 +594,16 @@ describe("getFrames on a project", () => {);});+ it("still shows the last export of a project deleted since", async () => {+ const { projectId } = await recordTake();+ runners.results.export = { success: true, outputPath: path.join(dir, "demo.mp4") };+ await call("exportVideo", { projectId, path: path.join(dir, "demo.mp4") });+ await documents.deleteProject(projectId);+ const frames = await call("getFrames", { projectId, atSec: [1] });+ expect(frames.isError).toBeFalsy();+ expect(frames.content.filter((part) => part.type === "image")).toHaveLength(1);+ });+it("takes a project or a file, not both", async () => {expect((await call("getFrames", {})).isError).toBe(true);expect((await call("getFrames", { projectId: "p", path: "x.mp4" })).isError).toBe(true);diff --git a/electron/mcp/media-tools.ts b/electron/mcp/media-tools.tsindex 54b6fe5d3..675abff3b 100644--- a/electron/mcp/media-tools.ts+++ b/electron/mcp/media-tools.ts@@ -749,8 +749,9 @@ export function createMediaTools(deps: MediaToolDeps): MediaTools {videoPath = exported.path;toVideoSec = (sec) => programmeSecOf(rendered, sec);rulerEndSec = Math.max(0, ...rendered.timeline.clips.map((clip) => clip.timelineEndSec));- const current = await deps.documents.getProject(args.projectId);- if (Date.parse(current.project.updatedAt) > exported.at.getTime()) {+ // A project deleted since still left its export on disk: show it, unflagged.+ const current = await deps.documents.getProject(args.projectId).catch(() => null);+ if (current && Date.parse(current.project.updatedAt) > exported.at.getTime()) {note = " The project changed after this export: export it again to see the changes.";}} else {diff --git a/skills/openscreen-demo/SKILL.md b/skills/openscreen-demo/SKILL.mdindex a88b499ae..13272926b 100644--- a/skills/openscreen-demo/SKILL.md+++ b/skills/openscreen-demo/SKILL.md@@ -89,7 +89,7 @@ Keep the rest as it is: the background, padding, shadow and cursor style are cho## 7. Export and review-1. `exportVideo` with the `projectId` and the absolute path of, say, `demo/demo.mp4` in the working directory: the server in the app takes only absolute paths. For a pull request video, pass `quality: "medium"` (720p) to keep the file small.+1. `exportVideo` with the `projectId` and an absolute path: resolve, say, `demo/demo.mp4` against your working directory first, since the server in the app refuses a relative path. For a pull request video, pass `quality: "medium"` (720p) to keep the file small.2. `getFrames` with the `projectId`, at the ruler seconds of your beats.3. Check every frame:- Is each callout readable and clear of the action?diff --git a/technical-documentation/architecture/mcp-server.md b/technical-documentation/architecture/mcp-server.mdindex 5a3c56a2d..a5208678c 100644--- a/technical-documentation/architecture/mcp-server.md+++ b/technical-documentation/architecture/mcp-server.md@@ -51,7 +51,7 @@ Every text a client reads must be true on the server that serves it, so the text- **Tool descriptions**: `projectId` is "omit it for the open project" over HTTP and "omit it only for the open project, while the app runs" over stdio. `startRecording` and `stopRecording` say how each server makes a take ([below](#the-media-tools)), and the paths of `exportVideo` and `getFrames` must be absolute over HTTP: the app has no working directory of the client's.- **Messages**: no project to fall back on, a checkpoint required, an unknown checkpoint, edits turned off. Each has a version per transport, or exists only on the one that can produce it. The stdio versions are only met with no app answering, and say so.-The in-app chat agent keeps `buildSystemPrompt`'s defaults: its own switch, no export. The app's channel for `openscreen mcp` registers no media tools, so its instructions have no media block: no agent reads them.+The in-app chat agent keeps `buildSystemPrompt`'s defaults: its own switch, no export. The app's channel for `openscreen mcp` registers none of the media tools, only a `setPointerTrack` of its own ([below](#the-media-tools)), so its instructions have no media block: no agent reads them.**Writes on the in-app server are a second opt-in.** MCP clients have their own **MCP edits** switch, `allowEdits` in `mcp-server.json`, **off by default** and independent of the in-app agent's **Agent edits** (`allowAgentEdits`). Turning the server on therefore grants read access only. The value is read on every call; while it is off every mutating tool and `setPointerTrack` are refused with the executor's `consent_required` payload naming **MCP edits**, `restoreCheckpoint` with its own refusal text naming it too, `startRecording` and `exportVideo` with theirs, and the consent block of the system prompt is in the instructions. It is independent because `allowAgentEdits` defaults to allowed and lives in the provider form, so a user with no provider configured could never have turned MCP writes off. Toggling it does not restart the server. `openscreen mcp` has no such switch: the client started it itself, and there is no other caller to keep out. Its calls forwarded to the app keep that: the runner takes `editsAllowed` per call.@@ -127,7 +127,7 @@ What differs between the two servers is who records, handed in as a `TakeRecorde| Recorder | `createAppRecorder` (app-recorder.ts) | `runnerRecorder` (media-tools.ts) || `startRecording` | Points the recording bar at the request, as the editor's Record mode does before it hands over: the source, picked from the list `listSources` shows (`pickRecordingSource`, as `openscreen record`), and the microphone, system audio and editable cursor in the recording prefs. Then hands over as the editor's Record button does (`start-new-recording`): the editor closes, the HUD starts the take with its countdown and its camera setting. Returns once `set-recording-state` says it records. Refused while the editor has unsaved changes, since the editor closes. Where the system's picker owns the choice (the Linux portal, Apple's picker on macOS 15.2+), the request picks nothing: that picker asks the user. | A hidden `cli-record` runner of its own process, as `openscreen record`. || `stopRecording` | Presses the HUD's Stop, as the tray does. The HUD saves the take and hands it to the editor (`set-current-recording-session`), which imports it as for any take: one clip, measured, and the zooms on its clicks when Record mode's *Auto-zoom after recording* is on. The recorder waits for the editor's document to hold the take with its real length, then for its revision to hold still for 1.5 s, and returns that project, open in the editor. A `title` is applied through the editor. | Stops the runner and makes the project here (`createProjectFromVideo`): a fresh id no editor can hold, the zooms planned from the clicks. |-| The user's settings | The source, microphone, system audio and cursor mode the user had come back once the take is captured. | Untouched: the runner never saves them. |+| The user's settings | The source, microphone, system audio and cursor mode the user had come back once the take is captured, or as the app quits mid-take. A request that fails before the take changes none of them. | Untouched: the runner never saves them. |Then both servers carry on alike: