Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript

fix(desktop): leave selection seeds to the spec-06 path

Alfredo Lopezd94532904b14
diff --git a/desktop-app/ui/src/hooks/domain/__tests__/switchToChat.transcriptMemo.test.tsx b/desktop-app/ui/src/hooks/domain/__tests__/switchToChat.transcriptMemo.test.tsx
index f04f34118..c658c50b7 100644
--- a/desktop-app/ui/src/hooks/domain/__tests__/switchToChat.transcriptMemo.test.tsx
+++ b/desktop-app/ui/src/hooks/domain/__tests__/switchToChat.transcriptMemo.test.tsx
@@ -10,7 +10,7 @@ import { makeTaskKey } from '@contexts/AgentTaskTrackerContext/types'
import { act, cleanup, waitFor } from '@testing-library/react'
import { resetComposerDraftStore } from '@lib/composerDraftStore'
import type { AgentChatMessage } from '../../../uiTypes'
-import { deferred, localIndex } from './__fixtures__/catalogFixtures'
+import { deferred } from './__fixtures__/catalogFixtures'
import { type RenderControllerResult, renderController } from './__fixtures__/controllerHarness'
import { ipcGenericForbidden, ipcHostAccessRevoked, ipcHttpError } from './__fixtures__/ipcErrors'
import { type MockClerum, installMockClerum, uninstallMockClerum } from './__fixtures__/mockClerum'
@@ -498,79 +498,6 @@ describe('switchToChat transcript memo (#1091 A9)', () => {
}
)
- it.each(HOSTS)(
- "g. %s: a 'specific' open from another Host shows the remembered chat while the index loads",
- async host => {
- const otherHost = 'other-host'
- const disk = { 'chat-a': transcript('chat-a') }
- serveDisk(disk)
- const controller = mount(host, { agentNames: [host, otherHost] })
- await settleMount()
- await open(controller, host, 'chat-a')
- act(() => controller.rerender({ selectedAgent: otherHost, agentNames: [host, otherHost] }))
- await waitFor(() => expect(clerum.chat.getIndex).toHaveBeenCalledWith(otherHost))
-
- const hostIndex = deferred<ReturnType<typeof localIndex>>()
- const defaultIndex = clerum.chat.getIndex.getMockImplementation()
- clerum.chat.getIndex.mockImplementation((agentRef: string) =>
- agentRef === host ? hostIndex.promise : defaultIndex?.(agentRef)
- )
- const returnStart = frames.length
- act(() => controller.result.current.setPendingChatSelection(host, 'chat-a'))
- act(() => controller.rerender({ selectedAgent: host, agentNames: [host, otherHost] }))
- await waitFor(() => expect(clerum.chat.getIndex).toHaveBeenLastCalledWith(host))
- // The index read (behind the deleted-chat cleanup on a rebind) is pending.
- expectOnlyTranscript(frames.slice(returnStart), 'chat-a', disk['chat-a'])
-
- const hostReadsBefore = clerum.rpc.loadSessionMessages.mock.calls.length
- await act(async () => {
- hostIndex.resolve(localIndex([{ id: 'chat-a', title: 'Chat A' }]))
- })
- await waitFor(() =>
- expect(clerum.rpc.loadSessionMessages.mock.calls.length).toBeGreaterThan(hostReadsBefore)
- )
- expect(lastHostReadChatId()).toBe('chat-a')
- expectOnlyTranscript(frames.slice(returnStart), 'chat-a', disk['chat-a'])
- }
- )
-
- it.each(HOSTS)(
- "h. %s: a 'specific' selection whose tombstone arrives with the index withdraws the remembered chat",
- async host => {
- const otherHost = 'other-host'
- const disk = { 'chat-a': transcript('chat-a') }
- serveDisk(disk)
- const controller = mount(host, { agentNames: [host, otherHost] })
- await settleMount()
- await open(controller, host, 'chat-a')
- act(() => controller.rerender({ selectedAgent: otherHost, agentNames: [host, otherHost] }))
- await waitFor(() => expect(clerum.chat.getIndex).toHaveBeenCalledWith(otherHost))
-
- const hostIndex = deferred<ReturnType<typeof localIndex>>()
- const defaultIndex = clerum.chat.getIndex.getMockImplementation()
- clerum.chat.getIndex.mockImplementation((agentRef: string) =>
- agentRef === host ? hostIndex.promise : defaultIndex?.(agentRef)
- )
- const returnStart = frames.length
- act(() => controller.result.current.setPendingChatSelection(host, 'chat-a'))
- act(() => controller.rerender({ selectedAgent: host, agentNames: [host, otherHost] }))
- await waitFor(() => expect(clerum.chat.getIndex).toHaveBeenLastCalledWith(host))
- // Witness: the seed painted the remembered transcript before the index arrived.
- expectOnlyTranscript(frames.slice(returnStart), 'chat-a', disk['chat-a'])
-
- const hostReadsBefore = clerum.rpc.loadSessionMessages.mock.calls.length
- const tombstoneStart = frames.length
- await act(async () => {
- hostIndex.resolve(localIndex([], ['chat-a']))
- })
- await waitFor(() => expect(controller.result.current.chatMessages).toEqual([]))
- const after = frames.slice(tombstoneStart)
- expect(after.at(-1)).toEqual({ activeChatId: 'chat-a', contents: [], loading: false })
- // The deleted chat is never read from the Host.
- expect(clerum.rpc.loadSessionMessages.mock.calls.length).toBe(hostReadsBefore)
- }
- )
-
it.each(HOSTS)(
'i. %s: a transcript that changes during an uncertain hold is not remembered after release',
async host => {
diff --git a/desktop-app/ui/src/hooks/domain/useAgentChatController.ts b/desktop-app/ui/src/hooks/domain/useAgentChatController.ts
index 81019914c..5cdc3c755 100644
--- a/desktop-app/ui/src/hooks/domain/useAgentChatController.ts
+++ b/desktop-app/ui/src/hooks/domain/useAgentChatController.ts
@@ -1049,18 +1049,7 @@ export function useAgentChatController({
async (agentRef: string, chatId: string) => {
if (isHostAccessBlocked(agentRef)) return
if (isChatDeleted(agentRef, chatId)) {
- // A selection seed may already have painted this chat from the memo
- // before its tombstone arrived; withdraw both the entry and the view.
transcriptMemo.delete(chatTranscriptMemoKey(agentRef, chatId))
- const visible = activeChatVisibilityRef.current
- if (visible.selectedAgent === agentRef && visible.activeChatId === chatId) {
- chatMessagesRef.current = []
- setChatMessages([])
- setChatMessagesLoading(false)
- setHasOlderMessages(false)
- cancelOlderMessagesLoad()
- loadedLocalMessageCountRef.current = 0
- }
return
}
const key = makeTaskKey(agentRef, chatId)
@@ -1461,7 +1450,7 @@ export function useAgentChatController({
selectedAgent,
}
setActiveChatId(requestedSelection.chatId)
- presentSelectedTranscript(rememberedTranscript(selectedAgent, requestedSelection.chatId))
+ presentSelectedTranscript(undefined)
if (requestedSelection.title) {
upsertProvisionalEntry(
requestedSelection.chatId,
@@ -1557,7 +1546,6 @@ export function useAgentChatController({
selectedAgent,
isHostAccessBlocked,
presentSelectedTranscript,
- rememberedTranscript,
])
// ─── Activity / progress state updaters (hoisted from sendAgentMessage so the
@@ -3928,14 +3916,13 @@ export function useAgentChatController({
selectedAgent: agentName,
}
setActiveChatId(chatId)
- presentSelectedTranscript(rememberedTranscript(agentName, chatId))
+ presentSelectedTranscript(undefined)
if (options.title) {
upsertProvisionalEntry(chatId, options.title, options.isRemote === true)
}
},
[
presentSelectedTranscript,
- rememberedTranscript,
currentTeamId,
writePendingSelection,
upsertProvisionalEntry,