Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(desktop): surface dropped malformed sessions instead of losing them silently (R1-H1)
Diego Zacariasece890913431
diff --git a/desktop-app/package-lock.json b/desktop-app/package-lock.jsonindex 22cb99b82..73b5128c3 100644--- a/desktop-app/package-lock.json+++ b/desktop-app/package-lock.json@@ -1,12 +1,12 @@{"name": "evenfire",- "version": "0.1.347",+ "version": "0.1.348","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "evenfire",- "version": "0.1.347",+ "version": "0.1.348","license": "MPL-2.0","dependencies": {"@tanstack/react-query": "5.100.10",diff --git a/desktop-app/package.json b/desktop-app/package.jsonindex 1ad6e8bdb..19c8bd19a 100644--- a/desktop-app/package.json+++ b/desktop-app/package.json@@ -1,7 +1,7 @@{"name": "evenfire","productName": "Evenfire",- "version": "0.1.347",+ "version": "0.1.348","private": true,"license": "MPL-2.0","description": "Evenfire desktop client for secure agent and workflow access",diff --git a/desktop-app/src/__tests__/rpcProxyClient.test.ts b/desktop-app/src/__tests__/rpcProxyClient.test.tsindex d24c25eba..7777003cc 100644--- a/desktop-app/src/__tests__/rpcProxyClient.test.ts+++ b/desktop-app/src/__tests__/rpcProxyClient.test.ts@@ -139,9 +139,58 @@ describe('RpcProxyClient.listSessions', () => {lastActivityAt: '2026-01-02T00:00:00Z',},],+ droppedItemCount: 1,})})+ it('surfaces a dropped malformed session instead of losing it silently (R1-H1)', async () => {+ // Wire response the server (mcp-host) would send: 3 sessions, the 2nd corrupt+ // (turnCount is a non-integer, which the parser rejects). A silent partial parse+ // would return only the 2 valid ones with no trace — a user's chat vanishing from+ // "Latest sessions" with no way for the renderer to know. The parser must instead+ // keep the valid items AND make the loss observable (warn with the index + a+ // droppedItemCount on the result).+ const warnSpy = vi.spyOn(console, 'warn').mockImplementation(() => {})+ vi.stubGlobal(+ 'fetch',+ vi.fn().mockResolvedValue({+ ok: true,+ json: async () => ({+ items: [+ {+ agent: 'agent-a',+ chatId: 'chat-a',+ turnCount: 1,+ lastActivityAt: '2026-01-01T00:00:00.000Z',+ },+ {+ agent: 'agent-a',+ chatId: 'chat-corrupt',+ turnCount: 1.5,+ lastActivityAt: '2026-01-02T00:00:00.000Z',+ },+ {+ agent: 'agent-a',+ chatId: 'chat-b',+ turnCount: 2,+ lastActivityAt: '2026-01-03T00:00:00.000Z',+ },+ ],+ }),+ })+ )++ const result = await client.listSessions('token', 'host')++ // Observable result (T4): the two valid chats are returned...+ expect(result.items.map(item => item.chatId)).toEqual(['chat-a', 'chat-b'])+ // ...and the loss is observable — a count on the result the renderer can read...+ expect(result.droppedItemCount).toBe(1)+ // ...and a warn carrying the index of the dropped item in main-process logs.+ expect(warnSpy).toHaveBeenCalledTimes(1)+ expect(warnSpy).toHaveBeenCalledWith(expect.stringContaining('index 1'), expect.anything())+ })+it.each([NaN, Infinity, 1.5, -1, Number.MAX_SAFE_INTEGER + 1])('rejects invalid session catalog counts: %s',async invalidCount => {diff --git a/desktop-app/src/rpcProxyClient.ts b/desktop-app/src/rpcProxyClient.tsindex 60ff061cc..f76eae2ab 100644--- a/desktop-app/src/rpcProxyClient.ts+++ b/desktop-app/src/rpcProxyClient.ts@@ -125,6 +125,7 @@ function parseSessionsListResult(value: unknown): SessionsListResult {const record = wireObject(value, 'sessions response')if (!Array.isArray(record.items)) throw new Error('Invalid sessions response.items')let firstItemError: unknown+ let droppedItemCount = 0const items = record.items.flatMap((item, index): SessionsListResult['items'] => {try {const entry = wireObject(item, `sessions response.items[${index}]`)@@ -175,12 +176,24 @@ function parseSessionsListResult(value: unknown): SessionsListResult {]} catch (error) {firstItemError ??= error+ droppedItemCount += 1+ // R1-H1: a tolerant partial parse must not lose a session silently. A single+ // corrupt entry should not blank the whole sidebar (we still return the valid+ // items), but the drop has to leave a trace — otherwise a user's chat vanishes+ // from "Latest sessions" with no signal. Log the index + item error so the loss+ // is traceable in main-process logs, and count it into `droppedItemCount` below+ // so the renderer can observe that `items` is shorter than the server sent.+ console.warn(+ `[RpcProxyClient] Dropped malformed session catalog item at index ${index}:`,+ error+ )return []}})if (record.items.length > 0 && items.length === 0 && firstItemError) throw firstItemErrorreturn {items,+ ...(droppedItemCount > 0 ? { droppedItemCount } : {}),...(record.nextCursor != null? { nextCursor: wireString(record.nextCursor, 'sessions response.nextCursor') }: {}),diff --git a/desktop-app/src/types.ts b/desktop-app/src/types.tsindex e1cc88033..a2b2cff63 100644--- a/desktop-app/src/types.ts+++ b/desktop-app/src/types.ts@@ -898,6 +898,14 @@ export interface SessionsListResult {tokens?: SessionTokensLite}>nextCursor?: string+ /**+ * Number of wire items the parser dropped as malformed (R1-H1). Present only+ * when > 0. A session catalog is parsed tolerantly — one corrupt entry must not+ * blank the whole sidebar — but the drop must stay observable: this count lets a+ * consumer see that the returned `items` is shorter than what the server sent,+ * instead of a chat vanishing with no trace.+ */+ droppedItemCount?: number}// F5 compile-time guard: `SessionMessagesResult` MUST keep carrying the recovery