Keep Codex and Claude signed in across Orca restarts (#5639)

This commit is contained in:
Brennan Benson
2026-06-17 16:20:37 -07:00
committed by GitHub
parent 8eb96c4ec5
commit 0f240533e1
15 changed files with 744 additions and 28 deletions
@@ -1,5 +1,6 @@
/* eslint-disable max-lines -- Why: attachMainWindowServices centralizes main-window IPC wiring; keeping its integration-style mocks together avoids brittle cross-file setup. */
import { beforeEach, describe, expect, it, vi } from 'vitest'
import type { Store } from '../persistence'
const {
onMock,
@@ -133,8 +134,8 @@ function createMainWindow(extraWebContents: { on?: MockFn; send?: MockFn } = {})
}
}
function createStore(): never {
return { flush: vi.fn() } as never
function createStore(): Store & { flush: MockFn } {
return { flush: vi.fn() } as Store & { flush: MockFn }
}
function createRuntime(): RuntimeStub {
@@ -231,6 +232,36 @@ describe('attachMainWindowServices', () => {
expect(hydrateLocalPtyRegistryAtBootMock).toHaveBeenLastCalledWith(store)
})
it('passes injected update quit cleanup to the auto-updater', async () => {
const onBeforeUpdateQuit = vi.fn()
const store = createStore()
attachMainWindowServices(
createMainWindow() as never,
store,
createRuntime() as never,
undefined,
undefined,
{ onBeforeUpdateQuit }
)
expect(setupAutoUpdaterMock).toHaveBeenCalledTimes(1)
await setupAutoUpdaterMock.mock.calls[0][1].onBeforeQuit()
expect(onBeforeUpdateQuit).toHaveBeenCalledTimes(1)
expect(store.flush).toHaveBeenCalledTimes(1)
})
it('flushes the store before update quit when no cleanup is injected', async () => {
const store = createStore()
attachMainWindowServices(createMainWindow() as never, store, createRuntime() as never)
await setupAutoUpdaterMock.mock.calls[0][1].onBeforeQuit()
expect(store.flush).toHaveBeenCalledTimes(1)
})
it('ignores app reload requests from non-main webContents', async () => {
const onBeforeRendererReload = vi.fn()
const mainWindow = createMainWindow()
@@ -53,6 +53,7 @@ export function attachMainWindowServices(
options?: {
awaitLocalPtyStartup?: () => Promise<void>
onBeforeRendererReload?: (args: { webContentsId: number; ignoreCache: boolean }) => void
onBeforeUpdateQuit?: () => void | Promise<void>
}
): void {
registerAppReloadHandler(mainWindow, options?.onBeforeRendererReload)
@@ -109,7 +110,13 @@ export function attachMainWindowServices(
registerFileDropRelay(mainWindow)
setupAutoUpdater(mainWindow, {
getLastUpdateCheckAt: () => store.getUI().lastUpdateCheckAt,
onBeforeQuit: () => store.flush(),
onBeforeQuit: async () => {
try {
await options?.onBeforeUpdateQuit?.()
} finally {
store.flush()
}
},
setLastUpdateCheckAt: (timestamp) => {
store.updateUI({ lastUpdateCheckAt: timestamp })
},