feat(windows): route chat/stepper content to their own windows, fix status badge position
- ChatPanel now fills its own window instead of being absolutely positioned over the avatar; its interactive regions (messages, input bar, objective card) opt out of the window's drag region so they stay clickable/selectable while the rest of the panel can be used to move the window. - New StepperView: the #stepper window's root component, relays "session-status-changed" from the main process into its own Zustand store instance (new setStatus action) since this window has no direct access to the chat window's state. - App.tsx no longer renders ChatPanel/PipelineStepper at all (they live in separate windows now) or resizes itself - it only toggles the chat window via IPC and keeps a local optimistic flag for the context menu's checkmark, resynced if the window is closed externally. - Fixed AvatarStatusIndicator's position: .avatar-status-anchor used to be computed from the in-window chat panel's height (bottom: calc(2% + 64vh + ...)), which misplaced it once that panel stopped living in this window. It now mirrors .thinking's simple fixed anchor above the avatar's head. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
4da3254d0a
commit
c1440f83c0
@@ -35,7 +35,9 @@ const setWindowPosition = vi.fn()
|
||||
const openLoginWindow = vi.fn()
|
||||
const logout = vi.fn()
|
||||
const quitApp = vi.fn()
|
||||
const setPipelinePanelVisible = vi.fn()
|
||||
const toggleChatWindow = vi.fn()
|
||||
const notifySessionEnded = vi.fn()
|
||||
let onChatWindowClosedCb: (() => void) | undefined
|
||||
const sessionsCreate = vi.fn()
|
||||
const sessionsSendObjectiveMessage = vi.fn()
|
||||
const getAuthStatus = vi.fn(async (): Promise<{ loggedIn: boolean; email: string | null }> => ({
|
||||
@@ -55,13 +57,19 @@ function setupWindowApi(): void {
|
||||
}),
|
||||
onToggleListening: vi.fn(() => () => {}),
|
||||
onProactiveSpeech: vi.fn(() => () => {}),
|
||||
onChatWindowClosed: vi.fn((cb: () => void) => {
|
||||
onChatWindowClosedCb = cb
|
||||
return () => {}
|
||||
}),
|
||||
onSessionStatusChanged: vi.fn(() => () => {}),
|
||||
getWindowBounds,
|
||||
setWindowPosition,
|
||||
getAuthStatus,
|
||||
openLoginWindow,
|
||||
logout,
|
||||
quitApp,
|
||||
setPipelinePanelVisible,
|
||||
toggleChatWindow,
|
||||
notifySessionEnded,
|
||||
sessions: {
|
||||
create: sessionsCreate,
|
||||
get: vi.fn(),
|
||||
@@ -175,20 +183,16 @@ describe('<App />', () => {
|
||||
expect(getWindowBounds).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('should not show the chat panel when logged out', async () => {
|
||||
it('should disable the "Ecrire un message" menu item when logged out', async () => {
|
||||
getAuthStatus.mockResolvedValue({ loggedIn: false, email: null })
|
||||
render(<App />)
|
||||
await waitFor(() => expect(getAuthStatus).toHaveBeenCalled())
|
||||
expect(screen.queryByLabelText('Message')).not.toBeInTheDocument()
|
||||
const container = screen.getByTestId('avatar-viewer').parentElement!
|
||||
fireEvent.contextMenu(container)
|
||||
expect(screen.getByRole('menuitem', { name: 'Ecrire un message' })).toBeDisabled()
|
||||
})
|
||||
|
||||
it('should not show the chat panel right after login, until "Ecrire un message" is used', async () => {
|
||||
getAuthStatus.mockResolvedValue({ loggedIn: true, email: 'william@example.com' })
|
||||
render(<App />)
|
||||
await waitFor(() => expect(getAuthStatus).toHaveBeenCalled())
|
||||
expect(screen.queryByLabelText('Message')).not.toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('should open the chat panel via the context menu and shrink the pipeline panel back on toggle off', async () => {
|
||||
it('should toggle the separate chat window via the context menu (chat is its own Electron window, not rendered here)', async () => {
|
||||
getAuthStatus.mockResolvedValue({ loggedIn: true, email: 'william@example.com' })
|
||||
render(<App />)
|
||||
await waitFor(() => expect(getAuthStatus).toHaveBeenCalled())
|
||||
@@ -196,43 +200,47 @@ describe('<App />', () => {
|
||||
const container = screen.getByTestId('avatar-viewer').parentElement!
|
||||
fireEvent.contextMenu(container)
|
||||
fireEvent.click(screen.getByRole('menuitem', { name: 'Ecrire un message' }))
|
||||
|
||||
expect(await screen.findByLabelText('Message')).toBeInTheDocument()
|
||||
expect(toggleChatWindow).toHaveBeenCalledOnce()
|
||||
|
||||
fireEvent.contextMenu(container)
|
||||
fireEvent.click(screen.getByRole('menuitem', { name: 'Ecrire un message' }))
|
||||
expect(screen.queryByLabelText('Message')).not.toBeInTheDocument()
|
||||
const menuItem = screen.getByRole('menuitem', { name: 'Ecrire un message' })
|
||||
expect(menuItem.querySelector('.context-menu__check')).not.toBeNull()
|
||||
fireEvent.click(menuItem)
|
||||
expect(toggleChatWindow).toHaveBeenCalledTimes(2)
|
||||
})
|
||||
|
||||
it('should not show the pipeline stepper before a session exists', async () => {
|
||||
it('should resync the menu when the chat window is closed externally (e.g. Alt+F4)', async () => {
|
||||
getAuthStatus.mockResolvedValue({ loggedIn: true, email: 'william@example.com' })
|
||||
render(<App />)
|
||||
await waitFor(() => expect(getAuthStatus).toHaveBeenCalled())
|
||||
expect(onChatWindowClosedCb).toBeTypeOf('function')
|
||||
|
||||
const container = screen.getByTestId('avatar-viewer').parentElement!
|
||||
fireEvent.contextMenu(container)
|
||||
fireEvent.click(screen.getByRole('menuitem', { name: 'Ecrire un message' }))
|
||||
|
||||
act(() => onChatWindowClosedCb?.())
|
||||
|
||||
fireEvent.contextMenu(container)
|
||||
const menuItem = screen.getByRole('menuitem', { name: 'Ecrire un message' })
|
||||
expect(menuItem.querySelector('.context-menu__check')).toBeNull()
|
||||
})
|
||||
|
||||
it('should not render the pipeline stepper or chat panel in this window (they live in their own windows)', async () => {
|
||||
getAuthStatus.mockResolvedValue({ loggedIn: true, email: 'william@example.com' })
|
||||
render(<App />)
|
||||
await waitFor(() => expect(getAuthStatus).toHaveBeenCalled())
|
||||
expect(screen.queryByText('Objectif')).not.toBeInTheDocument()
|
||||
expect(setPipelinePanelVisible).toHaveBeenCalledWith(false)
|
||||
expect(screen.queryByLabelText('Message')).not.toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('should show the pipeline stepper and widen the window once a session is created', async () => {
|
||||
it('should open the chat window automatically if a session starts without it (safety net)', async () => {
|
||||
getAuthStatus.mockResolvedValue({ loggedIn: true, email: 'william@example.com' })
|
||||
sessionsCreate.mockResolvedValueOnce({ id: 1, status: 'objective_discovery' })
|
||||
sessionsSendObjectiveMessage.mockResolvedValueOnce({
|
||||
reply: 'Quel est ton sujet ?',
|
||||
ready: false
|
||||
})
|
||||
|
||||
render(<App />)
|
||||
await waitFor(() => expect(getAuthStatus).toHaveBeenCalled())
|
||||
|
||||
const container = screen.getByTestId('avatar-viewer').parentElement!
|
||||
fireEvent.contextMenu(container)
|
||||
fireEvent.click(screen.getByRole('menuitem', { name: 'Ecrire un message' }))
|
||||
act(() => useSessionStore.setState({ sessionId: 1, status: 'objective_discovery' }))
|
||||
|
||||
fireEvent.change(await screen.findByLabelText('Message'), {
|
||||
target: { value: 'Je veux apprendre' }
|
||||
})
|
||||
fireEvent.click(screen.getByRole('button', { name: 'Envoyer le message' }))
|
||||
|
||||
await waitFor(() => expect(screen.getByText('Objectif')).toBeInTheDocument())
|
||||
expect(setPipelinePanelVisible).toHaveBeenCalledWith(true)
|
||||
expect(toggleChatWindow).toHaveBeenCalledOnce()
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user