Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions apps/desktop/src/app/DesktopEarlyElectronStartup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,25 @@ export function resolveLinuxDisableFeaturesSwitch(input: {
: `${input.disableFeatures},${WAYLAND_COLOR_MANAGER_FEATURE}`;
}

// Playwright enables this when it launches Chromium; T3 launches Electron itself and attaches
// over CDP, so preview snapshots would otherwise use the legacy capture path that can stall.
const CDP_SCREENSHOT_NEW_SURFACE_FEATURE = "CDPScreenshotNewSurface";

export function resolveEnableFeaturesSwitch(input: {
readonly enableFeatures: string | null;
readonly disableFeatures: string | null;
}): string | null {
if (featureListNames(input.enableFeatures).includes(CDP_SCREENSHOT_NEW_SURFACE_FEATURE)) {
return null;
}
if (featureListNames(input.disableFeatures).includes(CDP_SCREENSHOT_NEW_SURFACE_FEATURE)) {
return null;
}
return input.enableFeatures === null
? CDP_SCREENSHOT_NEW_SURFACE_FEATURE
: `${input.enableFeatures},${CDP_SCREENSHOT_NEW_SURFACE_FEATURE}`;
}

export function resolveEarlyLinuxElectronOptions(
input: EarlyLinuxElectronOptionsInput,
): EarlyLinuxElectronOptions {
Expand Down
54 changes: 53 additions & 1 deletion apps/desktop/src/app/DesktopPreReadyPlatform.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,55 @@ describe("DesktopPreReadyPlatform", () => {
);
});

const launchWithCommandLine = (
platform: NodeJS.Platform,
initialSwitches: ReadonlyArray<readonly [string, string]>,
) => {
const commandLine = new Map(initialSwitches);
hasSwitchMock.mockImplementation((name: string) => commandLine.has(name));
getSwitchValueMock.mockImplementation((name: string) => commandLine.get(name) ?? "");
appendSwitchMock.mockImplementation((name: string, value: string) => {
commandLine.set(name, value);
});
return DesktopPreReadyPlatform.make.pipe(
Effect.provideService(HostProcess.Platform, platform),
Effect.as(commandLine),
);
};

it.effect.each(["darwin", "win32", "linux"] as const)(
"enables a fresh capture surface for CDP screenshots on %s",
(platform) =>
Effect.gen(function* () {
const commandLine = yield* launchWithCommandLine(platform, []);
assert.sameMembers(commandLine.get("enable-features")?.split(",") ?? [], [
"CDPScreenshotNewSurface",
]);
}),
);

it.effect("keeps features already enabled on the command line", () =>
Effect.gen(function* () {
const commandLine = yield* launchWithCommandLine("darwin", [
["enable-features", "WebRTCPipeWireCapturer,UseOzonePlatform"],
]);
assert.sameMembers(commandLine.get("enable-features")?.split(",") ?? [], [
"WebRTCPipeWireCapturer",
"UseOzonePlatform",
"CDPScreenshotNewSurface",
]);
}),
);

it.effect("respects a user who disabled the fresh capture surface", () =>
Effect.gen(function* () {
const commandLine = yield* launchWithCommandLine("darwin", [
["disable-features", "CDPScreenshotNewSurface"],
]);
assert.isFalse(commandLine.has("enable-features"));
}),
);

it.effect.each([
{ previousEntry: undefined, label: "missing" },
{ previousEntry: 'Exec="/Applications/deleted-previous.AppImage" %U', label: "stale" },
Expand Down Expand Up @@ -243,7 +292,10 @@ describe("DesktopPreReadyPlatform", () => {
});
assert.deepEqual(events, ["pre-ready", "clerk"]);
assert.equal(registerSchemesMock.mock.calls.length, 1);
assert.equal(appendSwitchMock.mock.calls.length, 0);
assert.deepEqual(
appendSwitchMock.mock.calls.map(([name]) => name),
["enable-features"],
);
Comment on lines +295 to +298

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This mock-call assertion repeats the feature-switch test and makes the unrelated startup-order test depend on the exact switch list. Could it be removed?

-        assert.deepEqual(
-          appendSwitchMock.mock.calls.map(([name]) => name),
-          ["enable-features"],
-        );

Posted via Macroscope — Test Signal

Comment thread
macroscopeapp[bot] marked this conversation as resolved.
Resolved
assert.equal(setDesktopNameMock.mock.calls.length, 0);
}),
);
Expand Down
8 changes: 8 additions & 0 deletions apps/desktop/src/app/DesktopPreReadyPlatform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,14 @@ export const make = Effect.gen(function* () {
}
}

const enableFeatures = DesktopEarlyElectronStartup.resolveEnableFeaturesSwitch({
enableFeatures: readCommandLineSwitchValue(Electron.app.commandLine, "enable-features"),
disableFeatures: readCommandLineSwitchValue(Electron.app.commandLine, "disable-features"),
});
if (enableFeatures !== null) {
Electron.app.commandLine.appendSwitch("enable-features", enableFeatures);
}

return { linux, linuxPasswordStoreCommandLine };
});
}).pipe(Effect.withSpan("desktop.electron.configureBeforeReady"));
Expand Down
Loading