Skip to content

chore: adding electron example app#1132

Merged
joker23 merged 5 commits intomainfrom
skz/electron-example-app
Feb 27, 2026
Merged

chore: adding electron example app#1132
joker23 merged 5 commits intomainfrom
skz/electron-example-app

Conversation

@joker23
Copy link
Contributor

@joker23 joker23 commented Feb 25, 2026

  • chore: adding electron example app
  • test: make it example test conform with specs

Note

Medium Risk
Adds a new Electron Forge app (with Electron/Vite dependencies) and wires it into the monorepo, which may impact install/build times and workspace tooling. CI changes are currently comment-only but introduce scaffolding for future scheduled/example runs.

Overview
Adds a new packages/sdk/electron/example workspace (@internal/electron-example) scaffolded with Electron Forge + Vite/TypeScript to demonstrate the Electron SDK, including main/renderer/preload wiring via @launchdarkly/electron-client-sdk bridge and build-time injection of LAUNCHDARKLY_MOBILE_KEY/LAUNCHDARKLY_FLAG_KEY.

Registers the example in the root package.json workspaces and updates the Electron GitHub Actions workflow with commented-out scheduling and placeholder (disabled) example test job setup.

Written by Cursor Bugbot for commit d96f2d3. This will update automatically on new commits. Configure here.

@joker23 joker23 requested a review from a team as a code owner February 25, 2026 22:21
@github-actions
Copy link
Contributor

@launchdarkly/js-sdk-common size report
This is the brotli compressed size of the ESM build.
Compressed size: 25462 bytes
Compressed size limit: 26000
Uncompressed size: 124854 bytes

@github-actions
Copy link
Contributor

github-actions bot commented Feb 25, 2026

@launchdarkly/browser size report
This is the brotli compressed size of the ESM build.
Compressed size: 171758 bytes
Compressed size limit: 200000
Uncompressed size: 799367 bytes

@github-actions
Copy link
Contributor

@launchdarkly/js-client-sdk-common size report
This is the brotli compressed size of the ESM build.
Compressed size: 19742 bytes
Compressed size limit: 20000
Uncompressed size: 103795 bytes

@github-actions
Copy link
Contributor

github-actions bot commented Feb 25, 2026

@launchdarkly/js-client-sdk size report
This is the brotli compressed size of the ESM build.
Compressed size: 23692 bytes
Compressed size limit: 25000
Uncompressed size: 82252 bytes

@joker23 joker23 changed the title skz/electron example app chore: adding electron example app Feb 25, 2026
branches: [main, 'feat/**']
paths-ignore:
- '**.md'
# TODO: re-enable this when we set up the example tests.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

By this I mean when I put in the contract tests since I imagine both tests will use some headless emulator

import { createClient } from '@launchdarkly/electron-client-sdk';
import type { LDContextStrict, LDOptions } from '@launchdarkly/electron-client-sdk';

app.disableHardwareAcceleration();
Copy link
Member

Choose a reason for hiding this comment

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

Is this to help with running headless? We probably want a comment that explains why we are doing this, and not to copy it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah yes - this was my attempts to try to enable the example app testing


const flagKey = process.env.LAUNCHDARKLY_FLAG_KEY || 'sample-feature';

const launchDarklyUser: LDContextStrict = {
Copy link
Member

Choose a reason for hiding this comment

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

Can this be LDContext instead?

launchDarklyOptions,
);
await launchDarklyMainProcessClient.start();

Copy link
Member

Choose a reason for hiding this comment

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

Should we check and log the start result?

// Quit when all windows are closed, except on macOS. There, it's common
// for applications and their menu bar to stay active until the user quits
// explicitly with Cmd + Q.
app.on('window-all-closed', () => {
Copy link
Member

Choose a reason for hiding this comment

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

Ah, the feature that causes mac users to leave all apps they even use open.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

lol, this is actually part of the electron-forge scaffolding. My thought processes is that people like things that look familiar :) but could remove if you have strong feelings about this.

Copy link
Member

Choose a reason for hiding this comment

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

It doesn't hurt anything because we aren't shipping a real app. (In a previous real app I did work on it also made this scaffolding, and I think we eventually made the app close when it didn't have remaining windows open.

@joker23 joker23 force-pushed the skz/electron-example-app branch from 5c173f3 to f9c7408 Compare February 27, 2026 16:28
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

// LAUNCHDARKLY_MOBILE_KEY from the environment is inlined into the renderer bundle at build time.
const launchDarklyClientId = process.env.LAUNCHDARKLY_MOBILE_KEY ?? 'example-client-id';

const launchDarklyFlagKey = process.env.LAUNCHDARKLY_FLAG_KEY ?? 'sample-feature';
Copy link

Choose a reason for hiding this comment

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

Inconsistent nullish operators for environment variable defaults

Low Severity

main.ts reads env vars with || while vite.renderer.config.ts uses ??. Since || treats empty string as falsy but ?? does not, an empty LAUNCHDARKLY_FLAG_KEY env var would result in 'sample-feature' in the main process but '' in the renderer — causing the two processes to evaluate different flag keys. Using the same operator in both places would keep them in sync.

Additional Locations (1)

Fix in Cursor Fix in Web

launchDarklyMainProcessClient.on('error', (error: Error) => {
// eslint-disable-next-line no-console
console.error('error event received', error);
});
Copy link

Choose a reason for hiding this comment

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

Error event handler receives context instead of error

Medium Severity

The SDK emits error events with (context, error) — context first, then the actual error. But this handler declares only (error: Error), so the parameter named error actually receives the LDContext object. The real Error (second argument) is silently discarded. The console.error call will log the context object instead of the error, making debugging misleading. Since this is an example app that users will copy, the incorrect handler signature will propagate.

Fix in Cursor Fix in Web

@joker23 joker23 merged commit 8f9b6f5 into main Feb 27, 2026
40 checks passed
@joker23 joker23 deleted the skz/electron-example-app branch February 27, 2026 17:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants