Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(desktop-ui): r13-l3 exercise producer-backed scope and mode fixtures
Josué439bdbce8fdf
diff --git a/desktop-app/ui/src/hooks/domain/__tests__/__fixtures__/chatActionConsumerHarness.tsx b/desktop-app/ui/src/hooks/domain/__tests__/__fixtures__/chatActionConsumerHarness.tsxindex 58626c780..a239dd62e 100644--- a/desktop-app/ui/src/hooks/domain/__tests__/__fixtures__/chatActionConsumerHarness.tsx+++ b/desktop-app/ui/src/hooks/domain/__tests__/__fixtures__/chatActionConsumerHarness.tsx@@ -10,7 +10,7 @@ import { NotificationsContext } from '@contexts/NotificationsContext'import { QueryClient, QueryClientProvider } from '@tanstack/react-query'import { render, waitFor } from '@testing-library/react'import { ToastStack } from '@components/Common'-import { buildChatMessageSemanticModel } from '@lib/chatMessageSemantics'+import { buildLoadedChatSemanticModels } from '@lib/chatMessageSemantics'import { useAgentChatActionsValue } from '../../../useAgentChatActionsValue'import { useAppController } from '../../../useAppController'@@ -43,9 +43,9 @@ export async function renderChatActionConsumer(children: ReactNode) {localSearchQuery: '',localSearchCurrentMatch: null,semanticModelsByMessageId: new Map(- vm.activeMessages.map(message => [- message.id,- buildChatMessageSemanticModel(message),+ buildLoadedChatSemanticModels(vm.activeMessages).map(model => [+ model.messageId,+ model,])),}}diff --git a/desktop-app/ui/src/hooks/domain/__tests__/createSuccessScopeWindow.r12.test.tsx b/desktop-app/ui/src/hooks/domain/__tests__/createSuccessScopeWindow.r12.test.tsxindex 52826cbfb..20803ed53 100644--- a/desktop-app/ui/src/hooks/domain/__tests__/createSuccessScopeWindow.r12.test.tsx+++ b/desktop-app/ui/src/hooks/domain/__tests__/createSuccessScopeWindow.r12.test.tsx@@ -19,6 +19,7 @@ afterEach(() => {it('does not open or publish an old-team successful create delivered in the new render layout effect', async () => {const clerum = installMockClerum()await clerum.chat.create('agent-x', 'chat-a')+ clerum.chat.getIndex.mockImplementation(clerum.readIndex)await clerum.persistLastActive('agent-x', 'chat-a')clerum.chat.setLastActive.mockImplementation(clerum.persistLastActive)expect((await clerum.readIndex('agent-x')).lastActiveChatId).toBe('chat-a')@@ -56,6 +57,7 @@ it('does not open or publish an old-team successful create delivered in the new{ wrapper: ({ children }) => <AgentTaskTrackerProvider>{children}</AgentTaskTrackerProvider> })await waitFor(() => expect(app.result.current.controller.chatListLoading).toBe(false))+ expect(app.result.current.controller.chatList.map(chat => chat.id)).toEqual(['chat-a'])const createProducer = clerum.chat.create.getMockImplementation()!clerum.chat.create.mockImplementationOnce(async (agentRef, chatId) => {const created = await createProducer(agentRef, chatId)@@ -79,6 +81,10 @@ it('does not open or publish an old-team successful create delivered in the newtrue)resolveInLayout = true+ const nextCatalog = deferred<Awaited<ReturnType<typeof clerum.readIndex>>>()+ // Production binds storage by environment/user, NOT by team. Hold the next+ // real index to distinguish early create publication from authorized reload.+ clerum.chat.getIndex.mockReturnValueOnce(nextCatalog.promise)// Normal-priority state commits: layout delivers real already-persisted create// metadata before passive effects invalidate the old request generation.app.result.current.setTeam('team-2')@@ -93,4 +99,14 @@ it('does not open or publish an old-team successful create delivered in the newexpect(app.result.current.controller.chatMessages).toEqual([])expect(app.result.current.controller.chatMessagesLoading).toBe(false)expect(spies.pushToast).not.toHaveBeenCalled()+ await act(async () => {+ nextCatalog.resolve(await clerum.readIndex('agent-x'))+ })+ await waitFor(() => expect(app.result.current.controller.chatListLoading).toBe(false))+ expect(app.result.current.controller.chatList.map(chat => chat.id).sort()).toEqual(+ ['chat-a', metadata.id].sort()+ )+ expect((await clerum.readIndex('agent-x')).chats.map(chat => chat.id).sort()).toEqual(+ ['chat-a', metadata.id].sort()+ )})diff --git a/desktop-app/ui/src/hooks/domain/__tests__/pendingSelectionMode.r12.test.tsx b/desktop-app/ui/src/hooks/domain/__tests__/pendingSelectionMode.r12.test.tsxindex 75fbd3891..cfe1e0d4b 100644--- a/desktop-app/ui/src/hooks/domain/__tests__/pendingSelectionMode.r12.test.tsx+++ b/desktop-app/ui/src/hooks/domain/__tests__/pendingSelectionMode.r12.test.tsx@@ -1,10 +1,12 @@// @vitest-environment jsdomimport { afterEach, expect, it, vi } from 'vitest'import { act, cleanup, waitFor } from '@testing-library/react'-import { DESKTOP_ROUTES } from '@constants/navigation'+import {+ installAppControllerClerum,+ renderAppController,+} from './__fixtures__/appControllerHarness'import { deferred } from './__fixtures__/catalogFixtures'-import { renderController } from './__fixtures__/controllerHarness'-import { installMockClerum, uninstallMockClerum } from './__fixtures__/mockClerum'+import { uninstallMockClerum } from './__fixtures__/mockClerum'afterEach(() => {cleanup()@@ -12,49 +14,67 @@ afterEach(() => {uninstallMockClerum()})-it.each(['notification', 'explicit clear', 'latest', 'suppressed target'] as const)(- '%s owns its declared selection mode without conflating no-chat intent',+it.each(['notification', 'explicit clear', 'latest'] as const)(+ '%s uses actual app producers, including their explicit clear behavior',async producer => {- const clerum = installMockClerum()+ const { clerum } = installAppControllerClerum()+ await clerum.chat.create('agent-x', 'before')+ await clerum.chat.upsertMessages('agent-x', 'before', [+ { id: 'before-history', role: 'user', content: 'previous real history', timestamp: 1 },+ ])await clerum.chat.create('agent-x', 'visible')await clerum.chat.upsertMessages('agent-x', 'visible', [{ id: 'actual-history', role: 'user', content: 'visible real history', timestamp: 1 },])- const controller = renderController({ navItem: DESKTOP_ROUTES.chat, loadMenuData: false })- await waitFor(() => expect(controller.result.current.chatListLoading).toBe(false))+ clerum.chat.getIndex.mockImplementation(clerum.readIndex)+ clerum.chat.setLastActive.mockImplementation(clerum.persistLastActive)+ const app = renderAppController()+ await waitFor(() => expect(app.result.current.initialExperienceLoading).toBe(false))+ act(() => app.result.current.handleSelectChatAgent('agent-x', { chatId: 'before' }))+ await waitFor(() => expect(app.result.current.activeMessages[0]?.id).toBe('before-history'))const gate = deferred<void>()- clerum.chat.setLastActive.mockImplementationOnce(() => gate.promise)- let request!: Promise<void>- act(() => {- request = controller.result.current.switchToChat('agent-x', 'visible')+ const entered = deferred<void>()+ const persisted = deferred<void>()+ clerum.chat.setLastActive.mockImplementationOnce(async (agent, id) => {+ entered.resolve()+ await gate.promise+ await clerum.persistLastActive(agent, id)+ persisted.resolve()})- expect(controller.result.current.chatMessagesLoading).toBe(true)- act(() => {- if (producer === 'latest') {- controller.result.current.setPendingChatSelection('agent-x', null, { selectLatest: true })- } else if (producer === 'suppressed target') {- // Supported public API combination: suppressing a named target records- // none but is not the no-chat notification's view-preserving intent.- controller.result.current.setPendingChatSelection('agent-x', 'other', {- suppressAutoSelect: true,+ act(() => app.result.current.handleSelectChatAgent('agent-x', { chatId: 'visible' }))+ await act(async () => entered.promise)+ expect(app.result.current.chatMessagesLoading).toBe(true)+ await act(async () => {+ if (producer === 'notification') {+ await app.result.current.handleOpenNotification({+ id: 'no-chat-notification',+ kind: 'approval_required',+ agentName: 'agent-x',+ teamId: 'team-1',+ text: 'Open agent',+ timestamp: Date.now(),+ read: false,+ approval: { taskId: 'task', requestId: 'request' },})} else {- controller.result.current.setPendingChatSelection('agent-x', null)- if (producer === 'explicit clear') controller.result.current.clearActiveChat()+ app.result.current.handleSelectChatAgent('agent-x', {+ selectLatest: producer === 'latest',+ })}})- expect(controller.result.current.chatMessagesLoading).toBe(producer === 'notification')+ expect(app.result.current.chatMessagesLoading).toBe(producer === 'notification')await act(async () => {gate.resolve()- await request+ await persisted.promise})- expect(controller.result.current.activeChatId).toBe(- producer === 'explicit clear' ? null : 'visible'- )- expect(controller.result.current.chatMessages).toEqual(- producer === 'notification' ? [expect.objectContaining({ id: 'actual-history' })] : []+ await waitFor(() => expect(app.result.current.chatMessagesLoading).toBe(false))+ expect(app.result.current.activeChatId).toBe(producer === 'notification' ? 'visible' : null)+ expect(app.result.current.activeMessages.map(message => message.content)).toEqual(+ producer === 'notification' ? ['visible real history'] : [])- expect(controller.result.current.chatMessagesLoading).toBe(false)- expect(controller.spies.pushToast).not.toHaveBeenCalled()+ expect(app.result.current.chatList.map(chat => chat.id).sort()).toEqual(['before', 'visible'])+ expect((await clerum.readIndex('agent-x')).lastActiveChatId).toBe('visible')+ expect(app.result.current.toasts).toEqual([])+ app.queryClient.clear()})