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(cli): let the Linux portal select recording sources
mcmah309feb6c9271a94
diff --git a/src/cli/CliRecordRunner.test.tsx b/src/cli/CliRecordRunner.test.tsxindex 3e01a0d47..ac5e14ffc 100644--- a/src/cli/CliRecordRunner.test.tsx+++ b/src/cli/CliRecordRunner.test.tsx@@ -52,6 +52,8 @@ describe("CliRecordRunner", () => {recorder.startRecordingImmediately.mockClear();recorder.toggleRecording.mockClear();window.electronAPI = {+ getPlatform: vi.fn(() => "win32"),+ isNativeLinuxCaptureAvailable: vi.fn(async () => ({ success: true, available: false })),cliGetRequest: vi.fn(async () => request),cliLog: vi.fn(),cliDone: vi.fn(async () => undefined),@@ -81,4 +83,41 @@ describe("CliRecordRunner", () => {await waitFor(() => expect(recorder.startRecordingImmediately).toHaveBeenCalledTimes(1));expect(window.electronAPI.cliDone).not.toHaveBeenCalled();});++ it("keeps source selection for Linux without the native helper", async () => {+ vi.mocked(window.electronAPI.getPlatform).mockReturnValue("linux");+ render(<CliRecordRunner />);+ await waitFor(() => expect(recorder.startRecordingImmediately).toHaveBeenCalledTimes(1));+ expect(window.electronAPI.getSources).toHaveBeenCalledTimes(1);+ expect(window.electronAPI.selectSource).toHaveBeenCalledWith(screenSource, { persist: false });+ });++ it("reports missing sources in the browser fallback", async () => {+ vi.mocked(window.electronAPI.getPlatform).mockReturnValue("linux");+ vi.mocked(window.electronAPI.getSources).mockResolvedValueOnce([]);+ render(<CliRecordRunner />);+ await waitFor(() =>+ expect(window.electronAPI.cliDone).toHaveBeenCalledWith(+ expect.objectContaining({+ success: false,+ error: expect.stringContaining("Display index 0 not found"),+ }),+ ),+ );+ expect(recorder.startRecordingImmediately).not.toHaveBeenCalled();+ });++ it("lets the native Linux portal choose the source without Chromium enumeration", async () => {+ vi.mocked(window.electronAPI.getPlatform).mockReturnValue("linux");+ vi.mocked(window.electronAPI.isNativeLinuxCaptureAvailable).mockResolvedValue({+ success: true,+ available: true,+ });+ vi.mocked(window.electronAPI.getSources).mockResolvedValueOnce([]);+ render(<CliRecordRunner />);+ await waitFor(() => expect(recorder.startRecordingImmediately).toHaveBeenCalledTimes(1));+ expect(window.electronAPI.getSources).not.toHaveBeenCalled();+ expect(window.electronAPI.selectSource).not.toHaveBeenCalled();+ expect(window.electronAPI.cliDone).not.toHaveBeenCalled();+ });});diff --git a/src/cli/CliRecordRunner.tsx b/src/cli/CliRecordRunner.tsxindex b7325120b..44aa53423 100644--- a/src/cli/CliRecordRunner.tsx+++ b/src/cli/CliRecordRunner.tsx@@ -9,6 +9,7 @@ import {} from "@/components/video-editor/projectPersistence";import { useScreenRecorder } from "@/hooks/useScreenRecorder";import type { CliRecordRequest } from "@/lib/cliContracts";+import { portalOwnsSourceSelection } from "@/lib/nativeLinuxRecording";import { DEFAULT_PROJECT_APPEARANCE } from "@/lib/projectDefaults";type Phase = "init" | "recording" | "stopping" | "done";@@ -164,15 +165,19 @@ export function CliRecordRunner() {}requestRef.current = request;- const source = await pickSource(request);- const selected = await window.electronAPI.selectSource(source, { persist: false });- if (!selected) {- throw new Error(- `Recording source "${source.name}" (${source.id}) is no longer available. ` +- "Re-list sources with `openscreen sources` and pick one that is currently shared.",- );+ // The native Linux helper asks the portal to choose a source. Enumerating+ // Chromium sources first opens a redundant picker and can return no screens.+ if (!(await portalOwnsSourceSelection(window.electronAPI))) {+ const source = await pickSource(request);+ const selected = await window.electronAPI.selectSource(source, { persist: false });+ if (!selected) {+ throw new Error(+ `Recording source "${source.name}" (${source.id}) is no longer available. ` ++ "Re-list sources with `openscreen sources` and pick one that is currently shared.",+ );+ }+ window.electronAPI.cliLog("info", `Recording source: ${selected.name}`);}- window.electronAPI.cliLog("info", `Recording source: ${selected.name}`);setMicrophoneEnabled(Boolean(request.mic));if (request.mic) {