程序员阿江(Relakkes) 386a41e606 feat(desktop): enable Electron migration path
Introduce the Electron desktop shell alongside the existing React renderer and local Bun server boundary. The migration keeps the DesktopHost contract explicit across Tauri, Electron, and browser runtimes while adding Electron main/preload services for dialogs, shell, notifications, updates, tray/window lifecycle, terminal, preview WebContentsView, app mode, and release/package validation.

The commit also carries the latest local main desktop command updates, including agent slash entries and hidden-by-default markdown thinking details, so the packaged Electron build matches the current main UX surface.

Constraint: React renderer, local Bun server, REST/WebSocket, and sidecar boundaries must remain reusable during the migration
Constraint: macOS dev packages are ad-hoc signed and cannot prove Developer ID notarization or Gatekeeper release launch
Rejected: Browser-only smoke validation | it cannot exercise native dialogs, keychain prompts, notification behavior, or packaged app startup
Confidence: medium
Scope-risk: broad
Directive: Do not remove Tauri host support until signed Electron release artifacts pass native OS smoke on macOS, Windows, and Linux
Tested: bun run check:desktop
Tested: cd desktop && bun run check:electron
Tested: CSC_IDENTITY_AUTO_DISCOVERY=false bun run electron📦dir
Tested: bun run test:package-smoke --platform macos --package-kind dir --artifacts-dir desktop/build-artifacts/electron
Tested: Computer Use read packaged Electron app window at desktop/build-artifacts/electron/mac-arm64/Claude Code Haha.app
Not-tested: Developer ID signed/notarized Gatekeeper launch
Not-tested: Real OS notification click-to-session action
Not-tested: Windows and Linux packaged app smoke on real hosts
2026-06-01 22:43:16 +08:00

22 lines
779 B
TypeScript

type ElectronAppWithCommandLine = {
commandLine: {
appendSwitch(name: string, value?: string): void
}
}
/**
* Chromium creates a per-app "Safe Storage" key in macOS Keychain for browser
* profile encryption. Claude Code Haha does not rely on Chromium cookies or
* password storage for auth secrets; OAuth tokens live in the desktop sidecar
* files instead. Using Chromium's mock keychain avoids repeated macOS password
* prompts when dev/unsigned Electron builds cannot reuse the old Keychain ACL.
*/
export function installMacOsChromiumKeychainPromptGuard(
app: ElectronAppWithCommandLine,
platform: NodeJS.Platform = process.platform,
): boolean {
if (platform !== 'darwin') return false
app.commandLine.appendSwitch('use-mock-keychain')
return true
}