Skip to content

The agent that grows with you

fix(desktop): restore error logging and repair UI regressions

ethernet0877e014f806
diff --git a/apps/desktop/electron/preload-flags.test.ts b/apps/desktop/electron/preload-flags.test.ts
index 81fc510ea06..4d31802ee07 100644
--- a/apps/desktop/electron/preload-flags.test.ts
+++ b/apps/desktop/electron/preload-flags.test.ts
@@ -2,6 +2,7 @@ import { expect, it, vi } from 'vitest'
const host = vi.hoisted(() => ({
exposeInMainWorld: vi.fn(),
+ send: vi.fn<(channel: string, line: string) => void>(),
sendSync: vi.fn((channel: string): unknown => channel === 'hermes:feature-flags'
? { localModels: true, guestOnboarding: true }
: {})
@@ -9,7 +10,7 @@ const host = vi.hoisted(() => ({
vi.mock('electron', () => ({
contextBridge: { exposeInMainWorld: host.exposeInMainWorld },
- ipcRenderer: { sendSync: host.sendSync },
+ ipcRenderer: { send: host.send, sendSync: host.sendSync },
webFrame: {},
webUtils: {}
}))
@@ -22,3 +23,14 @@ it('publishes the feature flags answered by main before the renderer starts', as
expect(registration![1]).toMatchObject({ localModelsEnabled: true, guestOnboardingEnabled: true })
expect(host.sendSync).toHaveBeenCalledWith('hermes:feature-flags')
})
+
+it('forwards full renderer error lines through the exposed bridge', async (): Promise<void> => {
+ await import('./preload')
+ const registration = host.exposeInMainWorld.mock.calls.find(([name]): boolean => name === 'hermesDesktop')
+ const bridge = registration?.[1] as { logLine?: (line: string) => void } | undefined
+ const line: string = '[renderer error:main] Prompt failed: database is locked\n at saveSession (session.ts:12)'
+
+ expect(bridge?.logLine).toBeTypeOf('function')
+ bridge?.logLine?.(line)
+ expect(host.send).toHaveBeenCalledExactlyOnceWith('hermes:logs:renderer-line', line)
+})
diff --git a/apps/desktop/electron/preload.ts b/apps/desktop/electron/preload.ts
index 0e3581f6db2..a14c7b827fd 100644
--- a/apps/desktop/electron/preload.ts
+++ b/apps/desktop/electron/preload.ts
@@ -345,6 +345,7 @@ contextBridge.exposeInMainWorld('hermesDesktop', {
// Fire-and-forget: persists a renderer error-boundary catch (with component
// stack) to desktop.log so crashes survive the window (#79428).
reportRendererError: report => ipcRenderer.send('hermes:logs:renderer-error', report),
+ logLine: (line: string): void => ipcRenderer.send('hermes:logs:renderer-line', line),
readDir: dirPath => ipcRenderer.invoke('hermes:fs:readDir', dirPath),
gitRoot: startPath => ipcRenderer.invoke('hermes:fs:gitRoot', startPath),
revealPath: targetPath => ipcRenderer.invoke('hermes:fs:reveal', targetPath),
diff --git a/apps/desktop/src/app/gateway/hooks/use-gateway-boot.test.tsx b/apps/desktop/src/app/gateway/hooks/use-gateway-boot.test.tsx
index 9ea5cf1d6bc..945aed7b11a 100644
--- a/apps/desktop/src/app/gateway/hooks/use-gateway-boot.test.tsx
+++ b/apps/desktop/src/app/gateway/hooks/use-gateway-boot.test.tsx
@@ -1,7 +1,7 @@
import { act, cleanup, render } from '@testing-library/react'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
-import type { DesktopConnectionsRegistry } from '@/global'
+import type { DesktopBootstrapState, DesktopConnectionsRegistry } from '@/global'
import { createClientSessionState } from '@/lib/chat-runtime'
import { $desktopBoot } from '@/store/boot'
import {
@@ -470,6 +470,18 @@ describe('primary failure foreground isolation', () => {
const desktop = Object.assign(fakeDesktop(), {
getRecentLogs: vi.fn(async () => ({ lines: [] })),
+ getBootstrapState: vi.fn(async (): Promise<DesktopBootstrapState> => ({
+ active: false,
+ manifest: null,
+ stages: {},
+ error: null,
+ log: [],
+ startedAt: null,
+ completedAt: null,
+ setupChoice: null,
+ unsupportedPlatform: null,
+ bundled: false
+ })),
getConnectionConfig: vi.fn(async () => ({ mode: 'cloud', remoteAuthMode: 'oauth', remoteUrl: cloud.baseUrl })),
getConnectionFor: vi.fn(async () => ({
...coderConn,
diff --git a/apps/desktop/src/i18n/ar.ts b/apps/desktop/src/i18n/ar.ts
index 129d3a82af4..88577d1101a 100644
--- a/apps/desktop/src/i18n/ar.ts
+++ b/apps/desktop/src/i18n/ar.ts
@@ -2004,8 +2004,7 @@ export const ar = defineLocale({
skills: 'المهارات',
messaging: 'المراسلة',
artifacts: 'العناصر',
- cron: 'المهام المجدولة',
- agents: 'الوكلاء'
+ cron: 'المهام المجدولة'
},
searchAria: 'البحث في الجلسات',
searchPlaceholder: 'البحث في الجلسات...',
diff --git a/apps/desktop/src/store/notifications.test.ts b/apps/desktop/src/store/notifications.test.ts
index 60e20100811..14e9a693ff1 100644
--- a/apps/desktop/src/store/notifications.test.ts
+++ b/apps/desktop/src/store/notifications.test.ts
@@ -82,6 +82,20 @@ test('notifyError posts the full error to desktop.log, not the summary', () => {
}
})
+test.each(['missing', 'closed'] as const)('notifyError still shows a toast when the log bridge is %s', (state: 'missing' | 'closed'): void => {
+ vi.stubGlobal('hermesDesktop', state === 'missing' ? undefined : {
+ logLine: (): never => { throw new Error('IPC channel closed') }
+ })
+
+ try {
+ const id: string = notifyError(new Error('database is locked'), 'Prompt failed')
+
+ expect($notifications.get()[0]).toMatchObject({ id, kind: 'error', message: 'database is locked' })
+ } finally {
+ vi.unstubAllGlobals()
+ }
+})
+
test('code-skew 503 unwraps to a restart-required summary, not raw IPC JSON', () => {
notifyError(
new Error(
diff --git a/apps/desktop/src/store/notifications.ts b/apps/desktop/src/store/notifications.ts
index 55ce13f047e..12eb4e09b1f 100644
--- a/apps/desktop/src/store/notifications.ts
+++ b/apps/desktop/src/store/notifications.ts
@@ -194,9 +194,22 @@ export function notify(input: NotificationInput): string {
return id
}
+// Toast copy can omit the stack or shorten the message. Keep both in desktop.log.
+function logErrorToDesktopLog(error: unknown, fallback: string): void {
+ try {
+ const label: string = new URLSearchParams(window.location.search).get('win') ?? 'main'
+ const raw: string = error instanceof Error ? (error.stack ?? error.message) : typeof error === 'string' ? error : fallback
+
+ window.hermesDesktop?.logLine?.(`[renderer error:${label}] ${fallback}: ${raw}`)
+ } catch {
+ // A missing or closed IPC bridge must not prevent the error toast.
+ }
+}
+
export function notifyError(error: unknown, fallback: string): string {
const readable = readableError(error, fallback)
const poolSlotTimeout = isLocalBackendSlotWaitTimeout(error)
+ logErrorToDesktopLog(error, fallback)
return notify({
action: poolSlotTimeout