mirror of
https://github.com/NanmiCoder/claude-code-haha.git
synced 2026-10-10 03:43:11 +08:00
386a41e606
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:package: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
30 lines
784 B
TypeScript
30 lines
784 B
TypeScript
import * as electron from 'electron'
|
|
import { ELECTRON_INTERNAL_CHANNELS } from './ipc/channels'
|
|
import { shouldForwardPreviewMessage } from './ipc/previewMessage'
|
|
|
|
const { contextBridge, ipcRenderer } = electron
|
|
|
|
function isTopFrame(): boolean {
|
|
try {
|
|
return window.top === window
|
|
} catch {
|
|
return false
|
|
}
|
|
}
|
|
|
|
export function installPreviewPostBridge(): void {
|
|
if (!contextBridge?.exposeInMainWorld || !ipcRenderer?.send) return
|
|
contextBridge.exposeInMainWorld('__DESKTOP_PREVIEW_POST__', (raw: unknown) => {
|
|
if (!shouldForwardPreviewMessage({
|
|
raw,
|
|
href: window.location.href,
|
|
isTopFrame: isTopFrame(),
|
|
})) {
|
|
return
|
|
}
|
|
ipcRenderer.send(ELECTRON_INTERNAL_CHANNELS.previewMessageFromView, raw)
|
|
})
|
|
}
|
|
|
|
installPreviewPostBridge()
|