refactor(desktop): classify electron exports#10266

merged1
cleanup-desktop/runtime-core
cleanup-desktop/electron-helpers
openedSep 6, 2026byJJulius Marminge
View on GitHubTwo-way sync enabledPR last imported 4d ago

Electron modules had 15 unclassified runtime exports. This marks ten canonical Effect service constructors as intentional public APIs, narrows four protocol implementation exports, and removes one unused safe-storage predicate without changing the exported error schema.

This is layer 2 of 5 in the desktop Knip cleanup stack.

Verification after the full stack: desktop typecheck; desktop Knip export audit; 831 desktop tests; changed-file lint and format checks. The native libsecret test cannot start on this machine because the system libsecret-1 development package is unavailable.

Model: gpt-6 astra. Harness: Codex in T3 Code.

Note

Make electron helper functions and constants private across desktop modules

  • Changes PRODUCTION_SCHEME, DEVELOPMENT_SCHEME, getDesktopOrigin, and registerDesktopSchemePrivilegesSync in ElectronProtocol.ts from named exports to module-private bindings.
  • Removes the isElectronSafeStorageError named export from ElectronSafeStorage.ts.
  • Adds public API documentation comments to the make service construction export across all electron service modules.
  • Behavioral Change: isElectronSafeStorageError, the protocol scheme constants, getDesktopOrigin, and registerDesktopSchemePrivilegesSync are no longer importable from their modules; any out-of-tree consumers must update.

Macroscope summarized bf20c62.

Summary by CodeRabbit

  • Documentation
    • Added public API documentation for desktop service construction APIs.
    • Clarified canonical entry points for Electron services.
  • Refactor
    • Restricted visibility of internal desktop protocol helpers and constants.
    • Removed an internal safe-storage error predicate from the public API.
Synced from GitHub

Approvability

Verdict: Approved at eca58d0

Macroscope's review found this PR approvable β€” This is a narrowly scoped Electron export cleanup: service construction remains intact, internal protocol helpers are no longer exported, and an unused safe-storage guard is removed. The diff does not change request-path behavior, product defaults, schemas, or production workflows.

No code changes detected at bf20c62. Prior analysis still applies.

You can add or adjust custom eligibility rules. Learn more.

Synced from GitHub

Thread transfer impact

βœ… Thread transfer remains within every enforced ceiling.

ℹ️ No successful main baseline artifact is available yet. This run establishes the initial measurement.

ProviderMetricMain baselineThis PRImpactPR ceiling
CodexTotal thread wireβ€”13.6 KiBβ€”15.1 KiBβœ…
CodexThread snapshot wireβ€”7.0 KiBβ€”7.3 KiBβœ…
CodexLive turn WebSocket wireβ€”6.6 KiBβ€”7.8 KiBβœ…
CodexLive turn WebSocket decodedβ€”57.1 KiBβ€”66.4 KiBβœ…
CodexLive turn messagesβ€”10β€”21βœ…
ClaudeTotal thread wireβ€”13.5 KiBβ€”15.1 KiBβœ…
ClaudeThread snapshot wireβ€”7.0 KiBβ€”7.3 KiBβœ…
ClaudeLive turn WebSocket wireβ€”6.5 KiBβ€”7.8 KiBβœ…
ClaudeLive turn WebSocket decodedβ€”57.8 KiBβ€”66.4 KiBβœ…
ClaudeLive turn messagesβ€”8β€”21βœ…

Baseline: unavailable Β· PR result: bf20c62 Β· Source CI: success

Scenario and decoded snapshot size

10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

  • Codex decoded thread snapshot: 113.9 KiB
  • Claude decoded thread snapshot: 114.6 KiB

Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

MmacroscopeappBotreviewed Β· 1 inline threadSep 6, 2026
Synced from GitHub

The same change (export const make β†’ const make) is applied in nine other service modules in this PR: ElectronDialog.ts, ElectronMenu.ts, ElectronPowerMonitor.ts, ElectronProtocol.ts, ElectronSafeStorage.ts, ElectronShell.ts, ElectronTheme.ts, ElectronUpdater.ts, ElectronWindow.ts. The inline note below applies to each of them. The other unexports in this PR (DESKTOP_PRODUCTION_SCHEME, DESKTOP_DEVELOPMENT_SCHEME, getDesktopOrigin, registerDesktopSchemePrivilegesSync) are module-local pure helpers, not part of a service's public shape, so narrowing those looks correct.

Posted via Macroscope β€” Effect Service Conventions

apps/desktop/src/electron/ElectronApp.tsline 101Outdated Β· ad29bf1Open thread
……@@ -98,7 +98,7 @@ const addScopedAppListener = <Args extends ReadonlyArray<unknown>>(
9999 ).pipe(Effect.asVoid);
100100
101-export const make = ElectronApp.of({
101+const make = ElectronApp.of({
MmacroscopeappBoton line 101Sep 6, 2026

electron/ElectronApp.ts:101

make is part of the canonical public shape of a service module that owns construction (Foo.Foo, Foo.make, Foo.layer), so consider keeping it exported even though only the local layer consumes it today β€” that is what packages/client-runtime/src/connection/driver.ts does, where the unused-export lint is silenced with a tag comment (/** @public Service construction is part of the canonical Effect module API. */) rather than by dropping export.

suggestion
1export const make = ElectronApp.of({

No longer relevant as of eca58d022256cf5584ba343ff8925a02aecc00bb

Added 1 commit

  • refactor(desktop): keep electron helpers privatebf20c62
Synced from GitHub

Review Change Stack

No actionable comments were generated in the recent review. πŸŽ‰

ℹ️ Recent review info
βš™οΈ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Team

Run ID: a750c205-3c45-4e63-bc05-f571da6a19aa

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between fe8fffac36e33a6872351f261b8d21745b409df2 and bf20c623db759b3d1f960d3250dacadb6cf348cf.

πŸ“’ Files selected for processing (10)
  • apps/desktop/src/electron/ElectronApp.ts
  • apps/desktop/src/electron/ElectronDialog.ts
  • apps/desktop/src/electron/ElectronMenu.ts
  • apps/desktop/src/electron/ElectronPowerMonitor.ts
  • apps/desktop/src/electron/ElectronProtocol.ts
  • apps/desktop/src/electron/ElectronSafeStorage.ts
  • apps/desktop/src/electron/ElectronShell.ts
  • apps/desktop/src/electron/ElectronTheme.ts
  • apps/desktop/src/electron/ElectronUpdater.ts
  • apps/desktop/src/electron/ElectronWindow.ts

Included review availability: 7 reviews are currently available. Your included PR review attempts over the past 7 days set your current allowance at 10 reviews per hour.


πŸ“ Walkthrough

Walkthrough

The change documents Electron service constructors as public Effect APIs. It also makes selected protocol helpers module-private and removes the exported safe-storage error predicate.

Changes

Electron API surface cleanup

Layer / File(s)Summary
Document Electron service constructors
apps/desktop/src/electron/ElectronApp.ts, ElectronDialog.ts, ElectronMenu.ts, ElectronPowerMonitor.ts, ElectronProtocol.ts, ElectronSafeStorage.ts, ElectronShell.ts, ElectronTheme.ts, ElectronUpdater.ts, ElectronWindow.ts
Public API documentation comments were added to the Electron service constructors.
Restrict internal Electron helpers
apps/desktop/src/electron/ElectronProtocol.ts, ElectronSafeStorage.ts
Selected Electron protocol declarations and isElectronSafeStorageError are no longer exported.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Merge Risk: βšͺ Minimal Β· up to bf20c

This change clarifies the Electron service API surface and removes internal or unused exports. No current merge-readiness risk remains.

πŸš₯ Pre-merge checks | βœ… 4 | ❌ 1

❌ Failed checks (1 warning)

Check nameStatusExplanationResolution
Docstring Coverage⚠️ WarningDocstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 10 files.Write docstrings for the functions missing them to satisfy the coverage threshold.
βœ… Passed checks (4 passed)
Check nameStatusExplanation
Linked Issues checkβœ… PassedCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes checkβœ… PassedCheck skipped because no linked issues were found for this pull request.
Title checkβœ… PassedThe title clearly summarizes the main change: refactoring and classifying Electron exports.
Description checkβœ… PassedThe description explains the export changes, rationale, scope, verification, and known test limitation. It does not use the template headings or checklist, but it is mostly complete and directly relat…
  • Fix all pre-merge checks with AI
✨ Finishing Touches πŸ’‘ 1
πŸ“ Generate docstrings πŸ’‘
  • Create stacked PR
  • Commit on current branch
πŸ§ͺ Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch cleanup-desktop/electron-helpers

Comment @coderabbitai help to get the list of available commands.