The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): keep storage corruption UI structural
etherneta219dde7cc8d
diff --git a/apps/desktop/src/api/sessions.test.ts b/apps/desktop/src/api/sessions.test.tsindex ef9d652b03b..feb260f9b56 100644--- a/apps/desktop/src/api/sessions.test.ts+++ b/apps/desktop/src/api/sessions.test.ts@@ -1,5 +1,7 @@import { beforeEach, describe, expect, it, vi } from 'vitest'+import type { SidebarSessionsResponse } from './sessions'+vi.mock('@/lib/gateway-rpc', () => ({ isMissingRestEndpoint: () => false }))vi.mock('@/store/transcript-tail', () => ({ recordTranscriptTail: vi.fn() }))vi.mock('./client', () => ({@@ -221,13 +223,17 @@ describe('listSidebarSessions remote ownership', () => {describe('listSidebarSessions storage health', () => {it('passes the backend corrupt-store map through so the sidebar can say why it is empty', async () => {- hermesApi.mockResolvedValue({+ const response = {cron: { sessions: [] },errors: [{ error: 'database disk image is malformed', profile: 'default' }],messaging: { sessions: [] },recents: { sessions: [] },storage: { default: 'corrupt' }- } as never)+ } satisfies SidebarSessionsResponse++ // SAFETY: vi cannot infer a concrete return from the generic hermesApi signature;+ // `satisfies` above checks the exact endpoint contract before it crosses the mock boundary.+ hermesApi.mockResolvedValue(response as never)const result = await listSidebarSessions({recentsProfile: 'all',diff --git a/apps/desktop/src/api/sessions.ts b/apps/desktop/src/api/sessions.tsindex ae37d6b55cf..e01f58fe2e7 100644--- a/apps/desktop/src/api/sessions.ts+++ b/apps/desktop/src/api/sessions.ts@@ -257,8 +257,7 @@ async function listSidebarSessionsLegacy(req: SidebarSessionsRequest): Promise<Sconst storage = { ...recents.storage, ...cron.storage, ...messaging.storage }- return {- ...(Object.keys(storage).length ? { storage } : {}),+ const response: SidebarSessionsResponse = {recents: {profiles_truncated: profilesTruncatedFrom(recents.sessions, req.recentsLimit),sessions: recents.sessions,@@ -273,6 +272,12 @@ async function listSidebarSessionsLegacy(req: SidebarSessionsRequest): Promise<S...(messagingErrors.length ? { errors: messagingErrors } : {})}}++ if (Object.keys(storage).length > 0) {+ response.storage = storage+ }++ return response}/** The PR each of these sessions opened, recovered from its own transcript —diff --git a/apps/desktop/src/app/chat/sidebar/section-states.tsx b/apps/desktop/src/app/chat/sidebar/section-states.tsxindex e0bbf2e9076..362a541b07b 100644--- a/apps/desktop/src/app/chat/sidebar/section-states.tsx+++ b/apps/desktop/src/app/chat/sidebar/section-states.tsx@@ -83,10 +83,16 @@ export function SidebarLoadErrorState({ onRetry }: { onRetry: () => void }) {const SESSION_STORAGE_RECOVERY_URL ='https://hermes-agent.nousresearch.com/docs/user-guide/session-storage-recovery#when-the-three-steps-do-not-work'+interface SidebarStorageCorruptNoticeProps {+ openRecoveryGuide?: (url: string) => void+}+// A structurally corrupt state.db empties (or thins out) the list below it,// which reads as deleted history (#72046). Persistent while the backend// reports the store corrupt; there is nothing to dismiss until it is recovered.-export function SidebarStorageCorruptNotice() {+export function SidebarStorageCorruptNotice({+ openRecoveryGuide = openExternalLink+}: SidebarStorageCorruptNoticeProps) {const profiles = useStore($corruptSessionStores)const { t } = useI18n()const copy = t.sidebar.storageCorrupt@@ -108,7 +114,7 @@ export function SidebarStorageCorruptNotice() {</code><ButtonclassName="-ml-1 mt-0.5 text-(--ui-text-secondary)"- onClick={() => openExternalLink(SESSION_STORAGE_RECOVERY_URL)}+ onClick={() => openRecoveryGuide(SESSION_STORAGE_RECOVERY_URL)}size="sm"variant="ghost">diff --git a/apps/desktop/src/app/chat/sidebar/storage-corrupt-notice.test.tsx b/apps/desktop/src/app/chat/sidebar/storage-corrupt-notice.test.tsxindex f9044a1633c..86c848a3bba 100644--- a/apps/desktop/src/app/chat/sidebar/storage-corrupt-notice.test.tsx+++ b/apps/desktop/src/app/chat/sidebar/storage-corrupt-notice.test.tsx@@ -5,13 +5,11 @@ import { $corruptSessionStores, setCorruptSessionStores } from '@/store/session'import { SidebarStorageCorruptNotice } from './section-states'-const openExternalLink = vi.fn()--vi.mock('@/lib/external-link', () => ({ openExternalLink: (href: string) => openExternalLink(href) }))+const openRecoveryGuide = vi.fn<(href: string) => void>()beforeEach(() => {$corruptSessionStores.set([])- openExternalLink.mockClear()+ openRecoveryGuide.mockClear()})afterEach(cleanup)@@ -28,7 +26,7 @@ describe('SidebarStorageCorruptNotice', () => {it('names the damaged profile and gives the non-destructive recovery path', () => {setCorruptSessionStores({ default: 'corrupt' })- render(<SidebarStorageCorruptNotice />)+ render(<SidebarStorageCorruptNotice openRecoveryGuide={openRecoveryGuide} />)const notice = screen.getByTestId('storage-corrupt-notice')@@ -41,7 +39,7 @@ describe('SidebarStorageCorruptNotice', () => {expect(notice.textContent).not.toContain('sessions repair')screen.getByRole('button', { name: /recovery guide/i }).click()- expect(openExternalLink).toHaveBeenCalledWith(expect.stringContaining('/user-guide/session-storage-recovery'))+ expect(openRecoveryGuide).toHaveBeenCalledWith(expect.stringContaining('/user-guide/session-storage-recovery'))})it('keeps atom identity when a refresh reports the same stores', () => {