Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(desktop): handle review gaps in session paging
Josué879b862ba543
diff --git a/desktop-app/package-lock.json b/desktop-app/package-lock.jsonindex d196b6df8..b8086e168 100644--- a/desktop-app/package-lock.json+++ b/desktop-app/package-lock.json@@ -1,12 +1,12 @@{"name": "evenfire",- "version": "0.1.325",+ "version": "0.1.326","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "evenfire",- "version": "0.1.325",+ "version": "0.1.326","license": "MPL-2.0","dependencies": {"@tanstack/react-query": "5.100.10",diff --git a/desktop-app/package.json b/desktop-app/package.jsonindex 96f27f76d..2743ff9ff 100644--- a/desktop-app/package.json+++ b/desktop-app/package.json@@ -1,7 +1,7 @@{"name": "evenfire","productName": "Evenfire",- "version": "0.1.325",+ "version": "0.1.326","private": true,"license": "MPL-2.0","description": "Evenfire desktop client for secure agent and workflow access",diff --git a/desktop-app/src/__tests__/chatStore.test.ts b/desktop-app/src/__tests__/chatStore.test.tsindex 57c68f15a..e8ae2343a 100644--- a/desktop-app/src/__tests__/chatStore.test.ts+++ b/desktop-app/src/__tests__/chatStore.test.ts@@ -38,6 +38,36 @@ async function readJsonFile<T = Record<string, unknown>>(path: string): Promise<return JSON.parse(await fs.readFile(path, 'utf-8')) as T}+async function writePagedSnapshotDir(chatId: string, dir: string, messages: ChatMessage[]) {+ await fs.mkdir(join(dir, 'pages'), { recursive: true })+ await fs.writeFile(+ join(dir, 'pages', '000001.json'),+ JSON.stringify({+ version: 1,+ chatId,+ pageNumber: 1,+ messages,+ })+ )+ await fs.writeFile(+ join(dir, 'meta.json'),+ JSON.stringify({+ version: 1,+ chatId,+ pageSize: 100,+ messageCount: messages.length,+ localMessageCount: messages.length,+ pages: [+ {+ file: '000001.json',+ count: messages.length,+ serverSynced: false,+ },+ ],+ })+ )+}+// ── listChats ────────────────────────────────────────────────────────────────describe('listChats', () => {@@ -362,6 +392,48 @@ describe('messages', () => {await expect(fs.access(chatMetaPath('switch-recovery'))).resolves.toBeUndefined()})+ it('completes recovery from a fully written next snapshot after a mid-swap crash', async () => {+ const pagedStore = new ChatStore(tempDir, {+ pageSize: 2,+ maxLocalSyncedMessages: Number.POSITIVE_INFINITY,+ })+ await pagedStore.createChat('agent-1', 'next-recovery')+ await pagedStore.saveMessages('agent-1', 'next-recovery', [+ { id: 'old-0', role: 'user', content: 'old-0', timestamp: 0 },+ ])++ const nextDir = `${chatCacheDir('next-recovery')}.next-test`+ await writePagedSnapshotDir('next-recovery', nextDir, [+ { id: 'new-0', role: 'user', content: 'new-0', timestamp: 1 },+ { id: 'new-1', role: 'assistant', content: 'new-1', timestamp: 2 },+ ])+ await fs.rename(chatCacheDir('next-recovery'), `${chatCacheDir('next-recovery')}.previous-test`)++ const reloaded = await pagedStore.loadMessages('agent-1', 'next-recovery')+ expect(reloaded.map(message => message.id)).toEqual(['new-0', 'new-1'])+ await expect(fs.access(`${chatCacheDir('next-recovery')}.next-test`)).rejects.toThrow()+ await expect(fs.access(`${chatCacheDir('next-recovery')}.previous-test`)).rejects.toThrow()+ })++ it('cleans stale snapshot siblings when the active paged snapshot is healthy', async () => {+ const pagedStore = new ChatStore(tempDir, {+ pageSize: 2,+ maxLocalSyncedMessages: Number.POSITIVE_INFINITY,+ })+ await pagedStore.createChat('agent-1', 'stale-snapshots')+ await pagedStore.saveMessages('agent-1', 'stale-snapshots', [+ { id: 'm0', role: 'user', content: 'msg-0', timestamp: 0 },+ ])++ await fs.mkdir(`${chatCacheDir('stale-snapshots')}.next-stale`, { recursive: true })+ await fs.mkdir(`${chatCacheDir('stale-snapshots')}.previous-stale`, { recursive: true })++ const reloaded = await pagedStore.loadMessages('agent-1', 'stale-snapshots')+ expect(reloaded.map(message => message.id)).toEqual(['m0'])+ await expect(fs.access(`${chatCacheDir('stale-snapshots')}.next-stale`)).rejects.toThrow()+ await expect(fs.access(`${chatCacheDir('stale-snapshots')}.previous-stale`)).rejects.toThrow()+ })+it('prunes only old pages whose messages are known to exist on the server', async () => {const prunedStore = new ChatStore(tempDir, {pageSize: 2,diff --git a/desktop-app/src/chatStore.ts b/desktop-app/src/chatStore.tsindex a12c46a8c..eea544794 100644--- a/desktop-app/src/chatStore.ts+++ b/desktop-app/src/chatStore.ts@@ -398,28 +398,84 @@ export class ChatStore {private async recoverPagedChatUnlocked(agentRef: string, chatId: string): Promise<void> {const activeDir = this.chatDirPath(agentRef, chatId)- if (await this.readPagedMeta(agentRef, chatId)) return+ const chatsDir = join(this.agentDir(agentRef), 'chats')+ const activeMeta = await this.readPagedMeta(agentRef, chatId)++ if (activeMeta) {+ await this.removePagedChatSnapshotSiblings(chatsDir, chatId)+ return+ }let entries: Array<{ name: string; isDirectory: () => boolean }>try {- entries = await fs.readdir(join(this.agentDir(agentRef), 'chats'), { withFileTypes: true })+ entries = await fs.readdir(chatsDir, { withFileTypes: true })} catch {return}- const backups = entries- .filter(entry => entry.isDirectory() && entry.name.startsWith(`${chatId}.previous-`))- .map(entry => join(this.agentDir(agentRef), 'chats', entry.name))- .sort()- .reverse()+ const snapshots = await Promise.all(+ entries+ .filter(entry => entry.isDirectory())+ .map(async entry => {+ const kind = entry.name.startsWith(`${chatId}.next-`)+ ? 'next'+ : entry.name.startsWith(`${chatId}.previous-`)+ ? 'previous'+ : null+ if (!kind) return null+ const dir = join(chatsDir, entry.name)+ const meta = await this.readPagedMetaAtPath(this.chatMetaPathFromChatDir(dir), chatId)+ if (!meta) return null+ const stat = await fs.stat(dir).catch(() => null)+ return {+ dir,+ kind,+ mtimeMs: stat?.mtimeMs ?? 0,+ }+ })+ )+ const validSnapshots = snapshots+ .filter(+ (snapshot): snapshot is { dir: string; kind: 'next' | 'previous'; mtimeMs: number } =>+ snapshot !== null+ )+ .sort((a, b) => b.mtimeMs - a.mtimeMs)++ const candidates = [+ ...validSnapshots.filter(snapshot => snapshot.kind === 'next'),+ ...validSnapshots.filter(snapshot => snapshot.kind === 'previous'),+ ]++ for (const snapshot of candidates) {+ try {+ await fs.rm(activeDir, { recursive: true, force: true })+ await fs.rename(snapshot.dir, activeDir)+ await this.removePagedChatSnapshotSiblings(chatsDir, chatId)+ return+ } catch {+ // Try the next complete snapshot, if one exists.+ }+ }+ }- for (const backupDir of backups) {- const meta = await this.readPagedMetaAtPath(this.chatMetaPathFromChatDir(backupDir), chatId)- if (!meta) continue- await fs.rm(activeDir, { recursive: true, force: true })- await fs.rename(backupDir, activeDir)+ private async removePagedChatSnapshotSiblings(chatsDir: string, chatId: string): Promise<void> {+ let entries: Array<{ name: string; isDirectory: () => boolean }>+ try {+ entries = await fs.readdir(chatsDir, { withFileTypes: true })+ } catch {return}++ await Promise.all(+ entries+ .filter(+ entry =>+ entry.isDirectory() &&+ (entry.name.startsWith(`${chatId}.next-`) ||+ entry.name.startsWith(`${chatId}.previous-`))+ )+ .map(entry => fs.rm(join(chatsDir, entry.name), { recursive: true, force: true }))+ )}private async writePagedChatUnlocked(diff --git a/desktop-app/ui/src/App.tsx b/desktop-app/ui/src/App.tsxindex cffc632c0..59f0b648a 100644--- a/desktop-app/ui/src/App.tsx+++ b/desktop-app/ui/src/App.tsx@@ -494,8 +494,11 @@ export function App() {activeChatId: vm.activeChatId,chatList: vm.chatList,chatListLoading: vm.chatListLoading,+ chatListMoreLoading: vm.chatListMoreLoading,+ chatListHasMoreRemoteSessions: vm.chatListHasMoreRemoteSessions,latestChatSessions: vm.latestChatSessions,latestChatSessionsLoading: vm.latestChatSessionsLoading,+ loadMoreChatSessions: vm.loadMoreChatSessions,sessionStateByChatId: vm.sessionStateByChatId,sessionStateByChatKey: vm.sessionStateByChatKey,}),@@ -503,8 +506,11 @@ export function App() {vm.activeChatId,vm.chatList,vm.chatListLoading,+ vm.chatListMoreLoading,+ vm.chatListHasMoreRemoteSessions,vm.latestChatSessions,vm.latestChatSessionsLoading,+ vm.loadMoreChatSessions,vm.sessionStateByChatId,vm.sessionStateByChatKey,]diff --git a/desktop-app/ui/src/components/agents/ChatThread.tsx b/desktop-app/ui/src/components/agents/ChatThread.tsxindex 035cfd256..461ff205c 100644--- a/desktop-app/ui/src/components/agents/ChatThread.tsx+++ b/desktop-app/ui/src/components/agents/ChatThread.tsx@@ -252,7 +252,14 @@ export function ChatThread({ showAgentLabel = false }: ChatThreadProps) {activityByMessageId,progressByMessageId,} = useChatThreadStateContext()- const { chatList, chatListLoading, sessionStateByChatId } = useChatListContext()+ const {+ chatList,+ chatListLoading,+ chatListMoreLoading = false,+ chatListHasMoreRemoteSessions = false,+ loadMoreChatSessions,+ sessionStateByChatId,+ } = useChatListContext()const {chatEndRef,handleSelectChat: onSelectChat,@@ -316,7 +323,8 @@ export function ChatThread({ showAgentLabel = false }: ChatThreadProps) {),[chatList])- const hasMoreSessions = sortedChats.length > SESSION_PREVIEW_LIMIT+ const hasMoreSessions =+ sortedChats.length > SESSION_PREVIEW_LIMIT || chatListHasMoreRemoteSessionsconst visibleChats = showAllSessions ? sortedChats : sortedChats.slice(0, SESSION_PREVIEW_LIMIT)const isDedicatedAgentView = !activeChatId@@ -341,7 +349,11 @@ export function ChatThread({ showAgentLabel = false }: ChatThreadProps) {}, [])useEffect(() => {- if (chatList.length <= SESSION_PREVIEW_LIMIT && showAllSessions) {+ if (+ chatList.length <= SESSION_PREVIEW_LIMIT &&+ !chatListHasMoreRemoteSessions &&+ showAllSessions+ ) {setShowAllSessions(false)}if (sessionMenuChatId && !chatList.some(chat => chat.id === sessionMenuChatId)) {@@ -351,7 +363,13 @@ export function ChatThread({ showAgentLabel = false }: ChatThreadProps) {setRenamingSessionId(null)setSessionRenameValue('')}- }, [chatList, renamingSessionId, sessionMenuChatId, showAllSessions])+ }, [+ chatList,+ chatListHasMoreRemoteSessions,+ renamingSessionId,+ sessionMenuChatId,+ showAllSessions,+ ])useEffect(() => {if (!sessionMenuChatId) return@@ -907,14 +925,37 @@ export function ChatThread({ showAgentLabel = false }: ChatThreadProps) {<span className="agent-dedicated-sessions-meta">{sortedChats.length} {sortedChats.length === 1 ? 'session' : 'sessions'}</span>- {hasMoreSessions && (+ {hasMoreSessions && !showAllSessions && (+ <Button+ color="neutral"+ onClick={() => setShowAllSessions(true)}+ size="xs"+ variant="text"+ >+ Show more+ </Button>+ )}+ {showAllSessions && sortedChats.length > SESSION_PREVIEW_LIMIT && (+ <Button+ color="neutral"+ onClick={() => setShowAllSessions(false)}+ size="xs"+ variant="text"+ >+ Show less+ </Button>+ )}+ {showAllSessions && chatListHasMoreRemoteSessions && loadMoreChatSessions && (<Buttoncolor="neutral"- onClick={() => setShowAllSessions(previous => !previous)}+ disabled={chatListMoreLoading}+ onClick={() => {+ void loadMoreChatSessions()+ }}size="xs"variant="text">- {showAllSessions ? 'Show less' : 'Show more'}+ {chatListMoreLoading ? 'Loading…' : 'Load more'}</Button>)}</div>diff --git a/desktop-app/ui/src/contexts/ChatListContext/types.ts b/desktop-app/ui/src/contexts/ChatListContext/types.tsindex 6684c5db0..bf185d2e7 100644--- a/desktop-app/ui/src/contexts/ChatListContext/types.ts+++ b/desktop-app/ui/src/contexts/ChatListContext/types.ts@@ -14,8 +14,11 @@ export interface ChatListContextValue {activeChatId: string | nullchatList: SidebarChatEntry[]chatListLoading: boolean+ chatListMoreLoading?: boolean+ chatListHasMoreRemoteSessions?: booleanlatestChatSessions: LatestSidebarChatEntry[]latestChatSessionsLoading: boolean+ loadMoreChatSessions?: () => Promise<void>/** Per-chat session lifecycle, keyed by chatId. Drives D.5 badges/banners. */sessionStateByChatId: Record<string, SessionStateLite>/**diff --git a/desktop-app/ui/src/hooks/domain/__tests__/useAgentChatController.test.tsx b/desktop-app/ui/src/hooks/domain/__tests__/useAgentChatController.test.tsxindex 8503d3b32..503e013b3 100644--- a/desktop-app/ui/src/hooks/domain/__tests__/useAgentChatController.test.tsx+++ b/desktop-app/ui/src/hooks/domain/__tests__/useAgentChatController.test.tsx@@ -1011,6 +1011,62 @@ describe('useAgentChatController — characterization (D.0)', () => {expect(result.current.latestChatSessionsLoading).toBe(false)})+ it('loads the next remote session page only when requested', async () => {+ clerum.rpc.listSessions.mockImplementation(+ async (_hostRef: string, _teamId: string | undefined, query?: { cursor?: string }) => {+ if (query?.cursor === 'cursor-2') {+ return {+ items: [+ {+ agent: 'agent-x',+ chatId: 'remote-page-2',+ turnCount: 3,+ lastActivityAt: '2026-05-02T00:00:00Z',+ },+ ],+ }+ }+ return {+ items: [+ {+ agent: 'agent-x',+ chatId: 'remote-page-1',+ turnCount: 2,+ lastActivityAt: '2026-05-03T00:00:00Z',+ },+ ],+ nextCursor: 'cursor-2',+ }+ }+ )++ const { result } = renderController()++ await waitFor(() =>+ expect(result.current.chatList.some(chat => chat.id === 'remote-page-1')).toBe(true)+ )+ expect(result.current.chatListHasMoreRemoteSessions).toBe(true)+ expect(+ clerum.rpc.listSessions.mock.calls.some(+ call => (call[2] as { cursor?: string } | undefined)?.cursor === 'cursor-2'+ )+ ).toBe(false)++ await act(async () => {+ await result.current.loadMoreChatSessions()+ })++ await waitFor(() =>+ expect(result.current.chatList.some(chat => chat.id === 'remote-page-2')).toBe(true)+ )+ expect(result.current.chatListHasMoreRemoteSessions).toBe(false)+ expect(+ clerum.rpc.listSessions.mock.calls.some(+ call => (call[2] as { cursor?: string } | undefined)?.cursor === 'cursor-2'+ )+ ).toBe(true)+ })+it('GAP-A persists the outgoing user message to the chat store on send', async () => {// Eager user-message persistence (dev) → D.3 must keep persisting it// (post-D.3 it carries task_id; here we only pin that it IS persisted).diff --git a/desktop-app/ui/src/hooks/domain/useAgentChatController.ts b/desktop-app/ui/src/hooks/domain/useAgentChatController.tsindex bfb3c4da8..458b343c8 100644--- a/desktop-app/ui/src/hooks/domain/useAgentChatController.ts+++ b/desktop-app/ui/src/hooks/domain/useAgentChatController.ts@@ -284,9 +284,12 @@ export function useAgentChatController({const {chatList,chatListLoading,+ chatListMoreLoading,+ chatListHasMoreRemoteSessions,latestChatSessions,latestChatSessionsLoading,loadChatList,+ loadMoreChatSessions,setChatListLoading,clearList,markUnreadInList,@@ -2538,6 +2541,8 @@ export function useAgentChatController({activeChatId,chatList,chatListLoading,+ chatListMoreLoading,+ chatListHasMoreRemoteSessions,latestChatSessions,latestChatSessionsLoading,chatMessages,@@ -2572,6 +2577,7 @@ export function useAgentChatController({handleDeleteChatForAgent,handleSelectChat,handleLoadOlderMessages,+ loadMoreChatSessions,handleSendAgentMessage,handleRetryFailedAgentSend,clearComposerSendError,diff --git a/desktop-app/ui/src/hooks/domain/useChatListController.ts b/desktop-app/ui/src/hooks/domain/useChatListController.tsindex 7cbc9b946..557f244e3 100644--- a/desktop-app/ui/src/hooks/domain/useChatListController.ts+++ b/desktop-app/ui/src/hooks/domain/useChatListController.ts@@ -5,6 +5,8 @@ import { scheduleAfterFirstPaint } from '../scheduleAfterFirstPaint'import type { useChatStore } from '../useChatStore'import { type SessionFsmEvent, type SessionFsmStore, seedSessionSnapshots } from './sessionFsm'+const SESSION_CATALOG_PAGE_LIMIT = 50+/*** useChatListController (spec-v2 §4.4) — owns the whole sidebar chat-list* subsystem extracted from the god-hook:@@ -92,12 +94,16 @@ export function useChatListController({// Per-agent list for the SELECTED agent (the sidebar's chat list).const [chatList, setChatList] = useState<SidebarChatEntry[]>([])const [chatListLoading, setChatListLoading] = useState(false)+ const [chatListMoreLoading, setChatListMoreLoading] = useState(false)+ const [chatListHasMoreRemoteSessions, setChatListHasMoreRemoteSessions] = useState(false)// Cross-agent "Latest sessions" list (badges live in the FSM, seeded below).const [latestChatSessions, setLatestChatSessions] = useState<LatestSidebarChatEntry[]>([])const [latestChatSessionsLoading, setLatestChatSessionsLoading] = useState(false)// Selection requested for an agent before its chats have loaded, consumed by// the parent's agent-selection effect. Ref (not state): imperative, per-agent.const pendingChatSelectionByAgentRef = useRef<Record<string, PendingChatSelection>>({})+ const chatListNextCursorByAgentRef = useRef<Record<string, string | null | undefined>>({})+ const chatListLoadingMoreByAgentRef = useRef<Set<string>>(new Set())// Live `selectedAgent` for the stable callbacks below (they gate a chatList// write on "is this the selected agent"). A ref keeps the callbacks stable@@ -105,6 +111,12 @@ export function useChatListController({const selectedAgentRef = useRef(selectedAgent)useEffect(() => {selectedAgentRef.current = selectedAgent+ setChatListHasMoreRemoteSessions(+ Boolean(selectedAgent && chatListNextCursorByAgentRef.current[selectedAgent])+ )+ setChatListMoreLoading(+ Boolean(selectedAgent && chatListLoadingMoreByAgentRef.current.has(selectedAgent))+ )return () => {if (selectedAgentRef.current === selectedAgent) {selectedAgentRef.current = null@@ -140,11 +152,13 @@ export function useChatListController({scheduleAfterFirstPaint(async () => {const serverResult = await chatStore- .listSessions(agentRef, { limit: 50 })- .catch(() => ({ items: [] }))+ .listSessions(agentRef, { limit: SESSION_CATALOG_PAGE_LIMIT })+ .catch((): SessionsListResult => ({ items: [] }))if (selectedAgentRef.current !== agentRef) returnconst serverSessions = serverResult.items.filter(s => s.agent === agentRef)+ chatListNextCursorByAgentRef.current[agentRef] = serverResult.nextCursor ?? null+ setChatListHasMoreRemoteSessions(Boolean(serverResult.nextCursor))// Seed sidebar session state (state/activeTaskId/pendingApproval/tokens)// for badges via SERVER_SNAPSHOT (D4 / §4.1 R2 owns "never degrade a live@@ -191,6 +205,65 @@ export function useChatListController({[chatStore.getIndex, chatStore.listSessions, chatStore.reconcileServerSessions, fsm])+ const loadMoreChatSessions = useCallback(async () => {+ const agentRef = selectedAgentRef.current+ if (!agentRef) return++ const cursor = chatListNextCursorByAgentRef.current[agentRef]+ if (!cursor) {+ setChatListHasMoreRemoteSessions(false)+ return+ }+ if (chatListLoadingMoreByAgentRef.current.has(agentRef)) return++ chatListLoadingMoreByAgentRef.current.add(agentRef)+ setChatListMoreLoading(true)+ try {+ const serverResult = await chatStore+ .listSessions(agentRef, { limit: SESSION_CATALOG_PAGE_LIMIT, cursor }, { force: true })+ .catch(() => null)+ if (!serverResult) return++ const serverSessions = serverResult.items.filter(s => s.agent === agentRef)+ chatListNextCursorByAgentRef.current[agentRef] = serverResult.nextCursor ?? null+ if (selectedAgentRef.current !== agentRef) return++ setChatListHasMoreRemoteSessions(Boolean(serverResult.nextCursor))+ seedSessionSnapshots(fsm, agentRef, serverSessions)+ setChatList(previous => {+ const dedupedPrevious = dedupeSidebarChats(previous)+ const knownIds = new Set(dedupedPrevious.map(c => c.id))+ const fromServerOnly: SidebarChatEntry[] = serverSessions+ .filter(s => !knownIds.has(s.chatId))+ .map(s => ({+ id: s.chatId,+ title: `Chat ${s.chatId.slice(0, 8)}`,+ createdAt: s.lastActivityAt,+ updatedAt: s.lastActivityAt,+ messageCount: s.turnCount * 2,+ turnCount: s.turnCount,+ }))+ return [...dedupedPrevious, ...fromServerOnly].sort(byUpdatedDesc)+ })++ try {+ void chatStore+ .reconcileServerSessions(+ agentRef,+ serverSessions.map(s => ({ chatId: s.chatId, lastActivityAt: s.lastActivityAt }))+ )+ .catch(() => undefined)+ } catch {+ // ignore — reconciliation is best-effort freshness only+ }+ } finally {+ chatListLoadingMoreByAgentRef.current.delete(agentRef)+ if (selectedAgentRef.current === agentRef) {+ setChatListMoreLoading(false)+ }+ }+ }, [chatStore.listSessions, chatStore.reconcileServerSessions, fsm])+const loadChatList = useCallback(async (agentRef: string): Promise<{ index: ChatIndex; merged: SidebarChatEntry[] } | null> => {// One retry with a short backoff: during boot a concurrent team-switch /@@ -218,7 +291,13 @@ export function useChatListController({// ─── Narrow chatList mutation API (called by the parent's remaining flows) ───/** Reset the selected agent's list (logout teardown / load failure). */- const clearList = useCallback(() => setChatList([]), [])+ const clearList = useCallback(() => {+ const agentRef = selectedAgentRef.current+ if (agentRef) chatListNextCursorByAgentRef.current[agentRef] = null+ setChatList([])+ setChatListMoreLoading(false)+ setChatListHasMoreRemoteSessions(false)+ }, [])/** Sidebar badge mirror: mark/clear the `unreadTerminal` flag by chat id. */const markUnreadInList = useCallback((chatId: string) => {@@ -470,9 +549,12 @@ export function useChatListController({const sessionGroups = await Promise.all(agentNames.map(async agentRef => {+ // This feeds only the cross-agent sidebar preview. Do not follow+ // cursors here; the selected-agent session list exposes explicit+ // on-demand pagination through `loadMoreChatSessions`.const serverResult: SessionsListResult = await chatStore- .listSessions(agentRef, { limit: 50 })- .catch(() => ({ items: [] }))+ .listSessions(agentRef, { limit: SESSION_CATALOG_PAGE_LIMIT })+ .catch((): SessionsListResult => ({ items: [] }))return {agentRef,sessions: serverResult.items.filter(session => session.agent === agentRef),@@ -521,6 +603,8 @@ export function useChatListController({// State (public contract, re-exported unchanged by the parent).chatList,chatListLoading,+ chatListMoreLoading,+ chatListHasMoreRemoteSessions,latestChatSessions,latestChatSessionsLoading,// CRUD (public contract).@@ -531,6 +615,7 @@ export function useChatListController({handleDeleteChatForAgent,// Loader + list-loading control (parent agent-selection effect).loadChatList,+ loadMoreChatSessions,setChatListLoading,clearList,// Narrow chatList ops (parent flows).diff --git a/desktop-app/ui/src/hooks/useAppController.ts b/desktop-app/ui/src/hooks/useAppController.tsindex 3b4954474..70768dd4a 100644--- a/desktop-app/ui/src/hooks/useAppController.ts+++ b/desktop-app/ui/src/hooks/useAppController.ts@@ -1137,6 +1137,8 @@ export function useAppController() {sessionStateByChatId: chat.sessionStateByChatId,sessionStateByChatKey: chat.sessionStateByChatKey,chatListLoading: chat.chatListLoading,+ chatListMoreLoading: chat.chatListMoreLoading,+ chatListHasMoreRemoteSessions: chat.chatListHasMoreRemoteSessions,latestChatSessions: chat.latestChatSessions,latestChatSessionsLoading: chat.latestChatSessionsLoading,chatMessages: chat.chatMessages,@@ -1160,6 +1162,7 @@ export function useAppController() {handleDeleteChatForAgent: chat.handleDeleteChatForAgent,handleSelectChat: chat.handleSelectChat,handleLoadOlderMessages: chat.handleLoadOlderMessages,+ loadMoreChatSessions: chat.loadMoreChatSessions,handleSendAgentMessage: chat.handleSendAgentMessage,handleRetryFailedAgentSend: chat.handleRetryFailedAgentSend,clearComposerSendError: chat.clearComposerSendError,