Skip to content

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

TypeScript

fix(desktop): withdraw deleted and held transcripts from the memo

Alfredo Lopez941ee014d1d7
diff --git a/desktop-app/ui/src/hooks/domain/__tests__/__fixtures__/catalogFixtures.ts b/desktop-app/ui/src/hooks/domain/__tests__/__fixtures__/catalogFixtures.ts
index 8d0a9d6c4..6ec09b9cd 100644
--- a/desktop-app/ui/src/hooks/domain/__tests__/__fixtures__/catalogFixtures.ts
+++ b/desktop-app/ui/src/hooks/domain/__tests__/__fixtures__/catalogFixtures.ts
@@ -8,7 +8,7 @@ export const CATALOG_NOW = '2026-09-12T00:00:00.000Z'
* from the producer instead of hand-built parsed shapes.
*/
export function serverSessions(
- items: Array<{ agent: string; chatId: string; title?: string }>,
+ items: Array<{ agent: string; chatId: string; title?: string; lastActivityAt?: string }>,
nextCursor?: string
): SessionsListResult {
return parseSessionsListResult({
@@ -16,7 +16,7 @@ export function serverSessions(
agent: i.agent,
chatId: i.chatId,
turnCount: 1,
- lastActivityAt: CATALOG_NOW,
+ lastActivityAt: i.lastActivityAt ?? CATALOG_NOW,
...(i.title !== undefined ? { title: i.title } : {}),
})),
...(nextCursor !== undefined ? { nextCursor } : {}),
diff --git a/desktop-app/ui/src/hooks/domain/__tests__/chatListPerHostPublication.test.tsx b/desktop-app/ui/src/hooks/domain/__tests__/chatListPerHostPublication.test.tsx
index 126ba08cd..47f79604a 100644
--- a/desktop-app/ui/src/hooks/domain/__tests__/chatListPerHostPublication.test.tsx
+++ b/desktop-app/ui/src/hooks/domain/__tests__/chatListPerHostPublication.test.tsx
@@ -89,6 +89,52 @@ describe('per-Host Latest sessions publication', () => {
})
})
+ it.each([
+ [HOST_A, HOST_B],
+ [HOST_B, HOST_A],
+ ])(
+ 'interleaves %s and %s rows by last activity whichever Host arrives last',
+ async (first, last) => {
+ const at = (minute: number) => `2026-10-14T11:0${minute}:00.000Z`
+ const pages: Record<string, SessionsListResult> = {
+ [HOST_A]: serverSessions([
+ { agent: HOST_A, chatId: 'a-3', lastActivityAt: at(3) },
+ { agent: HOST_A, chatId: 'a-1', lastActivityAt: at(1) },
+ ]),
+ [HOST_B]: serverSessions([
+ { agent: HOST_B, chatId: 'b-4', lastActivityAt: at(4) },
+ { agent: HOST_B, chatId: 'b-2', lastActivityAt: at(2) },
+ ]),
+ }
+ const pendingLast = deferred<SessionsListResult>()
+ clerum.chat.getIndex.mockResolvedValue(localIndex([]))
+ clerum.rpc.listSessions.mockImplementation((agentRef: string) =>
+ agentRef === last ? pendingLast.promise : Promise.resolve(pages[agentRef]!)
+ )
+ const controller = renderController({ selectedAgent: null, agentNames: HOSTS })
+ await waitFor(() =>
+ expect(controller.result.current.latestChatSessions.map(chat => chat.agentRef)).toEqual([
+ first,
+ first,
+ ])
+ )
+
+ await act(async () => {
+ pendingLast.resolve(pages[last]!)
+ await pendingLast.promise
+ })
+
+ await waitFor(() =>
+ expect(controller.result.current.latestChatSessions.map(chat => chat.id)).toEqual([
+ 'b-4',
+ 'a-3',
+ 'b-2',
+ 'a-1',
+ ])
+ )
+ }
+ )
+
it('discards a cancelled Host response while retaining the remaining Host rows', async () => {
const pendingB = deferred<SessionsListResult>()
let bResolved = false
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 4b825f6f2..fd1bf36b6 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
@@ -195,6 +195,40 @@ describe('switchToChat transcript memo (#1091 A9)', () => {
}
)
+ it.each(HOSTS)(
+ 'b3. %s: a full disk page of the same length but shifted by a new reply replaces the remembered transcript',
+ async host => {
+ const disk = { 'chat-a': transcript('chat-a', 80), 'chat-b': transcript('chat-b') }
+ serveDisk(disk)
+ const controller = mount(host)
+ await settleMount()
+ await open(controller, host, 'chat-a')
+ await open(controller, host, 'chat-b')
+ const remembered = disk['chat-a']
+ // One reply persisted while A was hidden: the newest page keeps its
+ // length (80) but starts one message later.
+ disk['chat-a'] = transcript('chat-a', 81)
+ const shiftedPage = disk['chat-a'].slice(-80)
+ expect(shiftedPage).toHaveLength(remembered.length)
+
+ const diskRead = deferred<AgentChatMessage[]>()
+ clerum.chat.loadMessages.mockImplementationOnce(() => diskRead.promise)
+ const reopenStart = frames.length
+ let reopen!: Promise<void>
+ await act(async () => {
+ reopen = controller.result.current.switchToChat(host, 'chat-a')
+ })
+ // Witness: the reopen painted the remembered transcript first.
+ expectOnlyTranscript(frames.slice(reopenStart), 'chat-a', remembered)
+
+ await act(async () => {
+ diskRead.resolve(shiftedPage)
+ await reopen
+ })
+ expect(contentsOf(controller.result.current.chatMessages)).toEqual(contentsOf(shiftedPage))
+ }
+ )
+
it.each(HOSTS)(
'b2. %s: an empty disk page (a tombstone this session has not loaded) drops the remembered transcript',
async host => {
@@ -450,65 +484,159 @@ describe('switchToChat transcript memo (#1091 A9)', () => {
}
)
- it('stateless wake: a failed reconcile keeps the remembered transcript and holds nothing', async () => {
- const host = 'chatllm-stateless'
- const disk = { 'chat-a': transcript('chat-a'), 'chat-b': transcript('chat-b') }
- serveDisk(disk)
- const onHostAccessRevoked = vi.fn()
- const onHostAuthorityUncertain = vi.fn()
- const controller = mount(host, {
- onHostAccessRevoked,
- onHostAuthorityUncertain,
- isHostAccessBlocked: () => false,
- })
- await settleMount()
- await open(controller, host, '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 unavailable = await ipcHttpError('rpc:loadSessionMessages', 503, 'Service Unavailable', {
- code: 'host_waking',
- })
- const notFound = await ipcHttpError('rpc:loadSessionMessages', 404, 'Not Found', {
- error: 'not found',
- })
- const chatAReads = () =>
- clerum.rpc.loadSessionMessages.mock.calls.filter(call => call[2] === 'chat-a').length
- for (const failure of [unavailable, notFound]) {
+ 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 => {
+ const otherHost = 'other-host'
+ const disk = { 'chat-a': transcript('chat-a', 81), 'chat-b': transcript('chat-b') }
+ serveDisk(disk)
+ const controller = mount(host, { agentNames: [host, otherHost] })
+ await settleMount()
+ await open(controller, host, 'chat-a')
await open(controller, host, 'chat-b')
- const readsBefore = chatAReads()
- // Every read of A fails while the Host wakes, including the reconcile's retries.
- clerum.rpc.loadSessionMessages.mockImplementation(
- async (_hostRef: string, _agent: string, chatId: string) => {
- if (chatId === 'chat-a') throw failure
- return { agent: host, chatId, state: 'idle', turns: [] }
+ const denial = await ipcGenericForbidden('rpc:loadSessionMessages')
+ clerum.rpc.loadSessionMessages.mockImplementationOnce(async () => {
+ throw denial
+ })
+ await open(controller, host, 'chat-a')
+ // Witness: the reconcile's denial put the Host on an uncertain hold with A visible.
+ expect(controller.hostAuthority.isBlocked(host)).toBe(true)
+ expect(controller.result.current.activeChatId).toBe('chat-a')
+ expect(controller.result.current.chatMessages).toHaveLength(80)
+
+ // The user pages older messages while the Host is held.
+ await act(async () => {
+ await controller.result.current.handleLoadOlderMessages()
+ })
+ expect(controller.result.current.chatMessages).toHaveLength(81)
+
+ act(() => controller.rerender({ selectedAgent: otherHost, agentNames: [host, otherHost] }))
+ await waitFor(() => expect(clerum.chat.getIndex).toHaveBeenCalledWith(otherHost))
+ controller.hostAuthority.release(host)
+ expect(controller.hostAuthority.isBlocked(host)).toBe(false)
+ // The other Host opens a chat, as the chat route does on selection.
+ await open(controller, otherHost, 'chat-o')
+
+ const diskRead = deferred<AgentChatMessage[]>()
+ clerum.chat.loadMessages.mockImplementationOnce(() => diskRead.promise)
+ const returnStart = frames.length
+ act(() => controller.result.current.setPendingChatSelection(host, 'chat-a'))
+ act(() => controller.rerender({ selectedAgent: host, agentNames: [host, otherHost] }))
+ // Witness: the reopen after release reads the disk page.
+ await waitFor(() =>
+ expect(clerum.chat.loadMessages).toHaveBeenLastCalledWith(host, 'chat-a', 80, undefined)
+ )
+ expect(blankFrame(frames.slice(returnStart), 'chat-a')).toBe(true)
+ await act(async () => {
+ diskRead.resolve(disk['chat-a'].slice(-80))
+ })
+ await waitFor(() => expect(controller.result.current.chatMessages).toHaveLength(80))
+ }
+ )
+
+ it.each(HOSTS)(
+ '%s: a failed reconcile while the Host wakes keeps the remembered transcript and holds nothing',
+ async host => {
+ const disk = { 'chat-a': transcript('chat-a'), 'chat-b': transcript('chat-b') }
+ serveDisk(disk)
+ const onHostAccessRevoked = vi.fn()
+ const onHostAuthorityUncertain = vi.fn()
+ const controller = mount(host, {
+ onHostAccessRevoked,
+ onHostAuthorityUncertain,
+ isHostAccessBlocked: () => false,
+ })
+ await settleMount()
+ await open(controller, host, 'chat-a')
+
+ const unavailable = await ipcHttpError(
+ 'rpc:loadSessionMessages',
+ 503,
+ 'Service Unavailable',
+ {
+ code: 'host_waking',
}
)
+ const notFound = await ipcHttpError('rpc:loadSessionMessages', 404, 'Not Found', {
+ error: 'not found',
+ })
+ const chatAReads = () =>
+ clerum.rpc.loadSessionMessages.mock.calls.filter(call => call[2] === 'chat-a').length
+ for (const failure of [unavailable, notFound]) {
+ await open(controller, host, 'chat-b')
+ const readsBefore = chatAReads()
+ // Every read of A fails while the Host wakes, including the reconcile's retries.
+ clerum.rpc.loadSessionMessages.mockImplementation(
+ async (_hostRef: string, _agent: string, chatId: string) => {
+ if (chatId === 'chat-a') throw failure
+ return { agent: host, chatId, state: 'idle', turns: [] }
+ }
+ )
+ const reopenStart = frames.length
+ await open(controller, host, 'chat-a')
+ // Witness: the reconcile did reach the Host and fail.
+ expect(chatAReads()).toBeGreaterThan(readsBefore)
+ expectOnlyTranscript(frames.slice(reopenStart), 'chat-a', disk['chat-a'])
+ }
+ await waitFor(() =>
+ expect(
+ controller.result.current.sessionFsmStore.getState(makeTaskKey(host, 'chat-a'))?.phase
+ ).toBe('offline')
+ )
+ expect(onHostAccessRevoked).not.toHaveBeenCalled()
+ expect(onHostAuthorityUncertain).not.toHaveBeenCalled()
+
+ // A third reopen is still served from memory.
+ await open(controller, host, 'chat-b')
+ const diskRead = deferred<AgentChatMessage[]>()
+ clerum.chat.loadMessages.mockImplementationOnce(() => diskRead.promise)
const reopenStart = frames.length
- await open(controller, host, 'chat-a')
- // Witness: the reconcile did reach the Host and fail.
- expect(chatAReads()).toBeGreaterThan(readsBefore)
+ let reopen!: Promise<void>
+ await act(async () => {
+ reopen = controller.result.current.switchToChat(host, 'chat-a')
+ })
expectOnlyTranscript(frames.slice(reopenStart), 'chat-a', disk['chat-a'])
+ await act(async () => {
+ diskRead.resolve(disk['chat-a'])
+ await reopen
+ })
}
- await waitFor(() =>
- expect(
- controller.result.current.sessionFsmStore.getState(makeTaskKey(host, 'chat-a'))?.phase
- ).toBe('offline')
- )
- expect(onHostAccessRevoked).not.toHaveBeenCalled()
- expect(onHostAuthorityUncertain).not.toHaveBeenCalled()
-
- // A third reopen is still served from memory.
- await open(controller, host, 'chat-b')
- const diskRead = deferred<AgentChatMessage[]>()
- clerum.chat.loadMessages.mockImplementationOnce(() => diskRead.promise)
- const reopenStart = frames.length
- let reopen!: Promise<void>
- await act(async () => {
- reopen = controller.result.current.switchToChat(host, 'chat-a')
- })
- expectOnlyTranscript(frames.slice(reopenStart), 'chat-a', disk['chat-a'])
- await act(async () => {
- diskRead.resolve(disk['chat-a'])
- await reopen
- })
- })
+ )
})
diff --git a/desktop-app/ui/src/hooks/domain/transcriptMemo.ts b/desktop-app/ui/src/hooks/domain/transcriptMemo.ts
index 03eaed9f5..e70b53a21 100644
--- a/desktop-app/ui/src/hooks/domain/transcriptMemo.ts
+++ b/desktop-app/ui/src/hooks/domain/transcriptMemo.ts
@@ -15,6 +15,7 @@ export interface TranscriptMemoEntry {
export interface TranscriptMemo {
get: (key: string) => TranscriptMemoEntry | undefined
set: (key: string, entry: TranscriptMemoEntry) => void
+ delete: (key: string) => void
deleteAgent: (agentRef: string) => void
clear: () => void
}
@@ -67,6 +68,9 @@ export function createTranscriptMemo(limits: TranscriptMemoLimits): TranscriptMe
entries.delete(entries.keys().next().value!)
}
},
+ delete(key) {
+ entries.delete(key)
+ },
deleteAgent(agentRef) {
for (const key of entries.keys()) {
if (key.split('\u0000')[1] === agentRef) entries.delete(key)
diff --git a/desktop-app/ui/src/hooks/domain/useAgentChatController.ts b/desktop-app/ui/src/hooks/domain/useAgentChatController.ts
index 6d289b2b5..c6bbc3934 100644
--- a/desktop-app/ui/src/hooks/domain/useAgentChatController.ts
+++ b/desktop-app/ui/src/hooks/domain/useAgentChatController.ts
@@ -644,9 +644,11 @@ export function useAgentChatController({
// Every change to the visible transcript (send, stream, hydrate, older page)
// goes through `chatMessages`, so recording each settled commit keeps the memo
// current. A commit whose state does not match the visible selection is a
- // transition between chats and is skipped.
+ // transition between chats and is skipped. A held Host or a deleted chat is
+ // never recorded: its entry was withdrawn and must not come back on release.
useEffect(() => {
if (chatMessagesLoading || !activeChatId || !selectedAgent) return
+ if (isHostAccessBlocked(selectedAgent) || isChatDeleted(selectedAgent, activeChatId)) return
const visible = activeChatVisibilityRef.current
if (visible.activeChatId !== activeChatId || visible.selectedAgent !== selectedAgent) return
transcriptMemo.set(chatTranscriptMemoKey(selectedAgent, activeChatId), {
@@ -660,6 +662,8 @@ export function useAgentChatController({
chatMessagesLoading,
chatTranscriptMemoKey,
hasOlderMessages,
+ isChatDeleted,
+ isHostAccessBlocked,
selectedAgent,
transcriptMemo,
])
@@ -1043,7 +1047,22 @@ export function useAgentChatController({
// chat, and a task in flight is rejoined via the tracker D.3 already mounts.
const switchToChat = useCallback(
async (agentRef: string, chatId: string) => {
- if (isHostAccessBlocked(agentRef) || isChatDeleted(agentRef, chatId)) return
+ 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)
const visibleBeforeSwitch = activeChatVisibilityRef.current
const reopeningActiveChat =
@@ -1213,6 +1232,9 @@ export function useAgentChatController({
clearUnreadInList,
rememberedTranscript,
presentSelectedTranscript,
+ transcriptMemo,
+ chatTranscriptMemoKey,
+ cancelOlderMessagesLoad,
chatStore.setLastActive,
chatStore.loadMessages,
chatStore.clearUnreadTerminal,
diff --git a/desktop-app/ui/src/hooks/domain/useChatListController.ts b/desktop-app/ui/src/hooks/domain/useChatListController.ts
index 7cb3a65b8..8eaa39e72 100644
--- a/desktop-app/ui/src/hooks/domain/useChatListController.ts
+++ b/desktop-app/ui/src/hooks/domain/useChatListController.ts
@@ -1,6 +1,6 @@
import { type MutableRefObject, useCallback, useEffect, useMemo, useRef, useState } from 'react'
import { makeTaskKey } from '@contexts/AgentTaskTrackerContext'
-import { byUpdatedDesc, mergeCatalogPage } from '@lib/catalogMerge'
+import { byUpdatedDesc, mergeByUpdatedDesc, mergeCatalogPage } from '@lib/catalogMerge'
import { agentChatPlaceholder, remotePlaceholder } from '@lib/chatTitle'
import type { PendingRename } from '@lib/resolveSessionTitle'
import type {
@@ -1456,8 +1456,9 @@ export function useChatListController({
// A hold is enforced synchronously (the published list below filters held
// Hosts, and every in-flight read compares its Host's epoch), so holding a
- // Host needs no reload. Releasing one does: its sessions were dropped while
- // it was held, so the cross-agent list reloads when a held Host comes back.
+ // Host needs no reload. The stored list may still hold that Host's rows, but
+ // its reads were discarded while it was held and those rows can be stale, so
+ // the cross-agent list reloads when a held Host comes back.
const [latestReloadRevision, setLatestReloadRevision] = useState(0)
const heldAgentsRef = useRef(new Set<string>())
useEffect(() => {
@@ -1614,8 +1615,11 @@ export function useChatListController({
agentRef: session.agentRef,
}),
})
- return [...merged, ...previous.filter(item => item.agentRef !== agentRef)].sort(
- byUpdatedDesc
+ // Every writer keeps `previous` sorted, so the other Hosts' rows
+ // stay sorted after the filter and one linear merge suffices.
+ return mergeByUpdatedDesc(
+ merged,
+ previous.filter(item => item.agentRef !== agentRef)
)
})
diff --git a/desktop-app/ui/src/lib/__tests__/catalogMerge.prop.test.ts b/desktop-app/ui/src/lib/__tests__/catalogMerge.prop.test.ts
index bb0cd63d8..0ec8df028 100644
--- a/desktop-app/ui/src/lib/__tests__/catalogMerge.prop.test.ts
+++ b/desktop-app/ui/src/lib/__tests__/catalogMerge.prop.test.ts
@@ -1,6 +1,6 @@
import { describe, expect, it } from 'vitest'
import fc from 'fast-check'
-import { byUpdatedDesc, mergeCatalogPage } from '../catalogMerge'
+import { byUpdatedDesc, mergeByUpdatedDesc, mergeCatalogPage } from '../catalogMerge'
import type { PendingRename } from '../resolveSessionTitle'
/**
@@ -285,3 +285,24 @@ describe('mergeCatalogPage', () => {
expect(merge(cached, sessions, {})[0]?.title).toBe('Server plan')
})
})
+
+describe('mergeByUpdatedDesc', () => {
+ const rowsArb = (side: string) =>
+ fc
+ .array(timestampArb, { maxLength: 12 })
+ .map(stamps =>
+ stamps
+ .map((updatedAt, index) => ({ id: `${side}-${index}`, updatedAt }))
+ .sort(byUpdatedDesc)
+ )
+
+ it('equals a stable sort of both sorted lists, first list first on ties', () => {
+ fc.assert(
+ fc.property(rowsArb('first'), rowsArb('second'), (first, second) => {
+ const merged = mergeByUpdatedDesc(first, second)
+ expect(merged).toEqual([...first, ...second].sort(byUpdatedDesc))
+ expect(merged).toHaveLength(first.length + second.length)
+ })
+ )
+ })
+})
diff --git a/desktop-app/ui/src/lib/catalogMerge.ts b/desktop-app/ui/src/lib/catalogMerge.ts
index 1061b84bd..544d99965 100644
--- a/desktop-app/ui/src/lib/catalogMerge.ts
+++ b/desktop-app/ui/src/lib/catalogMerge.ts
@@ -56,6 +56,25 @@ export function byUpdatedDesc(a: { updatedAt: string }, b: { updatedAt: string }
return sortableTimestamp(b.updatedAt) - sortableTimestamp(a.updatedAt)
}
+/**
+ * Merges two lists already sorted by `byUpdatedDesc` in linear time. Ties keep
+ * `first` ahead of `second`, the order a stable sort of `[...first, ...second]`
+ * gives.
+ */
+export function mergeByUpdatedDesc<T extends { updatedAt: string }>(first: T[], second: T[]): T[] {
+ const merged: T[] = []
+ let j = 0
+ for (const item of first) {
+ let next = second[j]
+ while (next !== undefined && byUpdatedDesc(item, next) > 0) {
+ merged.push(next)
+ next = second[++j]
+ }
+ merged.push(item)
+ }
+ return merged.concat(second.slice(j))
+}
+
export function mergeCatalogPage<E extends CatalogMergeEntry, S extends CatalogMergeSession>(
input: CatalogMergeInput<E, S>
): E[] {