Skip to content

Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.

test(mcp): check openscreen mcp forwards the update notice

EtienneLescotaf4280322c14
diff --git a/electron/cli/cliMain.test.ts b/electron/cli/cliMain.test.ts
index 85ef7e352..745108a2c 100644
--- a/electron/cli/cliMain.test.ts
+++ b/electron/cli/cliMain.test.ts
@@ -2,17 +2,25 @@
// counts as active. runCli runs for real here; only Electron and the heavy services around
// the MCP server are stubbed.
-import { mkdtempSync, rmSync } from "node:fs";
+import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
import os from "node:os";
import path from "node:path";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { sendUsagePing, setUsagePingEnabled } from "../usage-ping";
import { runCli } from "./cliMain";
-const mocks = vi.hoisted(() => ({ userData: "", serve: vi.fn(async () => undefined) }));
+const mocks = vi.hoisted(() => ({
+ userData: "",
+ isPackaged: false,
+ serve: vi.fn(async (_options: { updateNotice?: string }) => undefined),
+ netFetch: vi.fn(),
+}));
vi.mock("electron", () => ({
app: {
+ get isPackaged() {
+ return mocks.isPackaged;
+ },
getPath: () => mocks.userData,
getVersion: () => "2.1.0",
exit: vi.fn(),
@@ -23,6 +31,7 @@ vi.mock("electron", () => ({
BrowserWindow: class {},
ipcMain: { handle: vi.fn() },
Menu: { setApplicationMenu: vi.fn(), buildFromTemplate: vi.fn() },
+ net: { fetch: mocks.netFetch },
session: {
defaultSession: {
setPermissionCheckHandler: vi.fn(),
@@ -32,7 +41,10 @@ vi.mock("electron", () => ({
},
systemPreferences: {},
}));
-vi.mock("../install-channel", () => ({ getInstallChannel: () => "nsis" }));
+vi.mock("../install-channel", () => ({
+ getInstallChannel: () => "nsis",
+ ownsItsUpdates: (channel: string) => channel === "nsis",
+}));
vi.mock("../ipc/handlers", () => ({
getSelectedDesktopSource: () => null,
registerIpcHandlers: () => ({ agentServices: {} }),
@@ -50,7 +62,9 @@ let stdoutWrite: ReturnType<typeof vi.spyOn>;
beforeEach(() => {
mocks.userData = mkdtempSync(path.join(os.tmpdir(), "cli-usage-ping-"));
+ mocks.isPackaged = false;
mocks.serve.mockClear();
+ mocks.netFetch.mockReset();
fetchMock.mockClear();
vi.stubGlobal("fetch", fetchMock);
vi.stubEnv("DO_NOT_TRACK", "");
@@ -107,3 +121,31 @@ describe("openscreen mcp usage ping", () => {
expect(fetchMock).not.toHaveBeenCalled();
});
});
+
+// The user who only reaches OpenScreen through an agent: the notice the cache holds has to reach
+// the server it starts, or it is never said.
+describe("openscreen mcp update notice", () => {
+ function cacheLookup(latestVersion: string) {
+ writeFileSync(
+ path.join(mocks.userData, "mcp-update-check.json"),
+ JSON.stringify({ latestVersion, checkedAt: Date.now() }),
+ );
+ }
+
+ it("hands the cached newer version to the server on an install that updates itself", async () => {
+ mocks.isPackaged = true;
+ cacheLookup("9.9.9");
+ await runMcp();
+ expect(mocks.serve.mock.calls[0][0].updateNotice).toContain(
+ "OpenScreen 9.9.9 is available; this is 2.1.0.",
+ );
+ // The cache is fresh, so the background lookup did not go out.
+ expect(mocks.netFetch).not.toHaveBeenCalled();
+ });
+
+ it("says nothing from a dev build, which a package manager may own", async () => {
+ cacheLookup("9.9.9");
+ await runMcp();
+ expect(mocks.serve.mock.calls[0][0].updateNotice).toBeUndefined();
+ });
+});
diff --git a/technical-documentation/architecture/mcp-server.md b/technical-documentation/architecture/mcp-server.md
index b9b9f2286..cfd7a7660 100644
--- a/technical-documentation/architecture/mcp-server.md
+++ b/technical-documentation/architecture/mcp-server.md
@@ -64,7 +64,7 @@ The server's one resource, `openscreen://effects/contract` ([`effects-contract.t
Every text a client reads must be true on the server that serves it, so the texts are composed rather than shared verbatim. `McpToolDeps.transport` (`"http"` or `"stdio"`) selects them:
- **Instructions** (`mcpInstructions`): the media tools' capability block (`mediaPreamble`), then the projects-and-checkpoints rules of the transport, then how long checkpoints live there, then `buildSystemPrompt`. The checkpoint rule is in both. Over HTTP the media block says a take goes through the app's recording bar and opens in the editor, and the rules speak of the editor and its undo stack; while **MCP edits** is off, a line says `startRecording`, `exportVideo` and `createProject` are refused too. Over stdio the media block says the takes land in the app's project list, and the rules say that calls go through the app while it runs (the open project live, with `Ctrl/Cmd+Z`), and to the files when it does not.
-- **A newer OpenScreen** (`update-notice.ts`), stdio only, and only on an install that updates itself (a Store, Flathub, Snap or Nix copy is kept current by its package manager). A user who reaches OpenScreen only through an agent never sees the app's update button, so `openscreen mcp` looks the latest release up on GitHub, at most every six hours, in the background and cached in `mcp-update-check.json`. When the cache names a newer version, a line opens the instructions: tell the user once that the app shows an update button for it once they open it, and never update OpenScreen yourself. The process itself updates nothing: its stdout is the protocol, its lifetime is the client's, and the NSIS installer would end it. The lookup never holds the handshake back, so the session that finds a release says nothing and the next one does.
+- **A newer OpenScreen** (`update-notice.ts`), stdio only, and only on an install that updates itself (a Store, Flathub, Snap or Nix copy is kept current by its package manager). A user who reaches OpenScreen only through an agent never sees the app's update button, so `openscreen mcp` looks the latest release up on GitHub in the background and caches the answer in `mcp-update-check.json`. A successful lookup holds the next one off for six hours; a failed one (offline, rate-limited) writes nothing, so the next session tries again. When the cache names a newer version, a line opens the instructions: tell the user once that the app shows an update button for it once they open it, and never update OpenScreen yourself. The process itself updates nothing: its stdout is the protocol, its lifetime is the client's, and the NSIS installer would end it. The lookup never holds the handshake back, so the session that finds a release says nothing and the next one does.
- **`buildSystemPrompt`** takes the transport's facts as options: `editsSetting` names the switch its consent block points to (the MCP server's **MCP edits**, not the in-app agent's **Agent edits**), and `canExport` drops "exporting" from its examples of a request with no tool, since both serve `exportVideo`.
- **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.