From 84a3520ea8ab075eda5921bb8a0f95f47bafce6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=B7=E7=94=B5=E8=8A=BD=E8=A1=A3?= Date: Fri, 17 Apr 2026 09:44:46 -0400 Subject: [PATCH] fix(ipc): register credentials + oauth handlers in main runtime MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The `registerCredentialIpcHandlers` and `registerOAuthIpcHandlers` entry points existed in `ipc-credentials-handlers.ts` and `ipc-oauth-handlers.ts` but were never called — `registerHandlers()` in `main-runtime-support.ts` only wired `registerCoreHandlers` and `registerDomainHandlers`. The result: every renderer call to `credentials:list` / `credentials:save` / `credentials:remove` / `credentials:test` / `oauth:start` / `oauth:cancel` / `oauth:prompt-response` / `oauth:manual-code-response` crashed with "No handler registered". Wire both handler families against the PiRuntimeServices container (credentialStore, credentialResolver, oauthLoginService) already exposed via `serviceGraph.getPiRuntime()`. The refreshConnectorHealth callback reuses the existing connectorHealthService so status badges flip between `ready` and `auth_required` immediately after a save/login. typecheck 0 / lint 0-0 / build 0-0 / test:unit 508/508 preserved. --- src/main/main-runtime-support.ts | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/main/main-runtime-support.ts b/src/main/main-runtime-support.ts index b87bddb0..8d535187 100644 --- a/src/main/main-runtime-support.ts +++ b/src/main/main-runtime-support.ts @@ -9,6 +9,9 @@ import type { AppDatabase } from "./database"; import { seedDefaultAutomationRules as seedDefaultAutomationRulesImpl } from "./default-automation-rules"; import { registerCoreHandlers } from "./ipc-core-handlers"; import { registerDomainHandlers } from "./ipc-domain-handlers"; +import { registerCredentialIpcHandlers } from "./ipc-credentials-handlers"; +import { registerOAuthIpcHandlers } from "./ipc-oauth-handlers"; +import { fail } from "./ipc-core-common"; import type { ThreadIntegrationService } from "./thread-integration"; type BootstrapResult = Awaited>; @@ -187,6 +190,30 @@ export function createMainRuntimeSupport(state: MainRuntimeState) { publishDomainChanged(); }, }); + + const piRuntime = requireServiceGraph().getPiRuntime(); + if (!piRuntime) { + throw new Error("Pi-mono runtime services are not initialized."); + } + + registerCredentialIpcHandlers({ + store: piRuntime.credentialStore, + resolver: piRuntime.credentialResolver, + registerHandle: requireIpcSupport().registerHandle, + emitEvent, + refreshConnectorHealth: async (connectorId) => { + await requireConnectorHealthService().checkConnector(connectorId as ConnectorId); + }, + fail, + logger: log, + }); + + registerOAuthIpcHandlers({ + service: piRuntime.oauthLoginService, + registerHandle: requireIpcSupport().registerHandle, + fail, + logger: log, + }); } return {