Two pieces of direct user feedback, addressed together since they touch the same files: 1. ObjectiveValidationCard now lives in its own dedicated, movable window (objectiveWindow.ts / ObjectiveWindowRoot.tsx), independent of the text input window. Confirming an objective must never depend on opening that window, including when the whole exchange happens by voice. Both sendTextTurn and voice-turn open/feed this window through the same shared handleRouteMessageResult code path, so text and voice behave identically - no more special-casing one channel. 2. The "chat window" was never meant to be a chat: it's an alternate text entry point for the exact same voice pipeline. Removed the message history/ChatBubble display and the old sessions:route-message + voice-turn-synced plumbing that existed to sync a conversation transcript across windows. Replaced with a new text-turn IPC handler mirroring voice-turn (routeMessage -> handleRouteMessageResult -> synthesizeSpeech) minus the STT step; the reply is relayed to the avatar window via the existing proactive-speech channel and spoken aloud, never displayed. The input window shrinks accordingly (560px -> 100px tall) and no longer auto-opens when a session starts, since there is nothing to show there anymore - it only opens on explicit user request. useProactiveSpeech now accepts an onStateChange callback so the avatar status indicator correctly flips back to idle once a text-turn reply finishes playing (it previously only ever got set to 'speaking', never reset - a latent gap this reuse surfaced). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
79 lines
2.1 KiB
TypeScript
79 lines
2.1 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 { openObjectiveWindow, closeObjectiveWindow, isObjectiveWindowOpen } =
|
|
await import('../../src/main/objectiveWindow')
|
|
|
|
describe('objectiveWindow', () => {
|
|
beforeEach(() => {
|
|
lastWindow?.emit('closed')
|
|
vi.clearAllMocks()
|
|
lastWindow = null
|
|
})
|
|
|
|
describe('openObjectiveWindow()', () => {
|
|
it('should create and load a window on the #objective hash', () => {
|
|
openObjectiveWindow()
|
|
|
|
expect(lastWindow?.loadFile).toHaveBeenCalledWith(
|
|
expect.stringContaining('index.html'),
|
|
expect.objectContaining({ hash: 'objective' })
|
|
)
|
|
expect(isObjectiveWindowOpen()).toBe(true)
|
|
})
|
|
|
|
it('should reuse the existing window and bring it to front on a second call', () => {
|
|
openObjectiveWindow()
|
|
const firstWindow = lastWindow
|
|
openObjectiveWindow()
|
|
|
|
expect(lastWindow).toBe(firstWindow)
|
|
expect(firstWindow?.show).toHaveBeenCalled()
|
|
expect(firstWindow?.focus).toHaveBeenCalled()
|
|
})
|
|
})
|
|
|
|
describe('closeObjectiveWindow()', () => {
|
|
it('should close the window when one is open', () => {
|
|
openObjectiveWindow()
|
|
closeObjectiveWindow()
|
|
|
|
expect(lastWindow?.close).toHaveBeenCalled()
|
|
})
|
|
|
|
it('should do nothing when no window is open', () => {
|
|
expect(() => closeObjectiveWindow()).not.toThrow()
|
|
expect(isObjectiveWindowOpen()).toBe(false)
|
|
})
|
|
})
|
|
})
|