Real-usage feedback after visually testing the previous in-window overlay approach: both the chat panel and the pipeline stepper must be their own independently movable windows, like the existing login window, not absolutely-positioned divs sharing the avatar window. - src/main/chatWindow.ts, src/main/stepperWindow.ts: singleton BrowserWindow pattern (same as auth/loginWindow.ts), frameless, transparent, always-on-top, loading the renderer bundle on their own #chat/#stepper hash route. - The chat window toggles via a new "toggle-chat-window" IPC (replacing the previous in-window chatOpen-only toggle); its "closed" event is relayed back to the avatar window so the context menu's checkmark stays in sync if it's closed externally (Alt+F4). - The stepper window is opened/closed by the main process itself, right where it already knows a session was created (sessions:create) or ended (new "session-ended" IPC) - not by the renderer polling session state, since the stepper has no business logic of its own. - New "session-status-changed" broadcast: the stepper window runs in its own isolated renderer process with no access to the chat window's Zustand store, so the main process relays session.status to every window whenever sessions:create/confirm-objective actually change it server-side. - Removed the previous window-resize-to-make-room approach entirely (set-pipeline-panel-visible is gone) - each panel now lives in its own right-sized window instead. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
88 lines
2.3 KiB
TypeScript
88 lines
2.3 KiB
TypeScript
import { describe, it, expect, vi, beforeEach } from 'vitest'
|
|
import { EventEmitter } from 'node:events'
|
|
|
|
vi.mock('@electron-toolkit/utils', () => ({ is: { dev: false } }))
|
|
|
|
class FakeWebContents extends EventEmitter {}
|
|
|
|
class FakeBrowserWindow extends EventEmitter {
|
|
webContents = new FakeWebContents()
|
|
show = vi.fn()
|
|
focus = vi.fn()
|
|
setAlwaysOnTop = vi.fn()
|
|
loadURL = vi.fn()
|
|
loadFile = vi.fn()
|
|
close = vi.fn()
|
|
destroyed = false
|
|
isDestroyed(): boolean {
|
|
return this.destroyed
|
|
}
|
|
}
|
|
|
|
let lastWindow: FakeBrowserWindow | null = null
|
|
function createBrowserWindow(): FakeBrowserWindow {
|
|
const window = new FakeBrowserWindow()
|
|
lastWindow = window
|
|
return window
|
|
}
|
|
|
|
vi.mock('electron', () => ({
|
|
BrowserWindow: vi.fn(createBrowserWindow)
|
|
}))
|
|
|
|
const { openStepperWindow, closeStepperWindow, isStepperWindowOpen } =
|
|
await import('../../src/main/stepperWindow')
|
|
|
|
describe('stepperWindow', () => {
|
|
beforeEach(() => {
|
|
lastWindow?.emit('closed')
|
|
vi.clearAllMocks()
|
|
lastWindow = null
|
|
})
|
|
|
|
describe('openStepperWindow()', () => {
|
|
it('should create and load a window on the #stepper hash', () => {
|
|
openStepperWindow()
|
|
|
|
expect(lastWindow?.loadFile).toHaveBeenCalledWith(
|
|
expect.stringContaining('index.html'),
|
|
expect.objectContaining({ hash: 'stepper' })
|
|
)
|
|
expect(isStepperWindowOpen()).toBe(true)
|
|
})
|
|
|
|
it('should do nothing (not reopen/focus) when one is already open', () => {
|
|
openStepperWindow()
|
|
const firstWindow = lastWindow
|
|
openStepperWindow()
|
|
|
|
expect(lastWindow).toBe(firstWindow)
|
|
expect(firstWindow?.show).not.toHaveBeenCalled()
|
|
})
|
|
|
|
it('should open a new window once the previous one was closed', () => {
|
|
openStepperWindow()
|
|
const firstWindow = lastWindow
|
|
firstWindow?.emit('closed')
|
|
|
|
openStepperWindow()
|
|
|
|
expect(lastWindow).not.toBe(firstWindow)
|
|
})
|
|
})
|
|
|
|
describe('closeStepperWindow()', () => {
|
|
it('should close the window when one is open', () => {
|
|
openStepperWindow()
|
|
closeStepperWindow()
|
|
|
|
expect(lastWindow?.close).toHaveBeenCalled()
|
|
})
|
|
|
|
it('should do nothing when no window is open', () => {
|
|
expect(() => closeStepperWindow()).not.toThrow()
|
|
expect(isStepperWindowOpen()).toBe(false)
|
|
})
|
|
})
|
|
})
|