Skip to content

The agent that grows with you

fix(desktop): reconcile of unified plugin halves survives one unreadable package

teknium1b915405f92a5
diff --git a/apps/desktop/electron/desktop-plugins-root.test.ts b/apps/desktop/electron/desktop-plugins-root.test.ts
index ddcf42d96eb..c51fd7a394f 100644
--- a/apps/desktop/electron/desktop-plugins-root.test.ts
+++ b/apps/desktop/electron/desktop-plugins-root.test.ts
@@ -2,7 +2,7 @@ import fs from 'node:fs'
import os from 'node:os'
import path from 'node:path'
-import { afterEach, describe, expect, it } from 'vitest'
+import { afterEach, describe, expect, it, vi } from 'vitest'
import {
migrateProfileScopedDesktopPlugins,
@@ -101,6 +101,29 @@ describe('reconcileUnifiedDesktopHalves', () => {
expect(fs.existsSync(path.join(appRoot, 'media'))).toBe(false)
})
+ it.skipIf(process.platform === 'win32' || process.getuid?.() === 0)(
+ 'skips a package the app cannot read and still materializes its siblings',
+ async () => {
+ // #111804: one unreadable plugin folder rejected the whole reconcile, so the
+ // desktop-plugins root never resolved and no desktop plugin loaded.
+ const home = makeHome()
+ const appRoot = path.join(home, 'desktop-plugins')
+ const denied = path.join(home, 'plugins', 'denied', 'desktop', 'plugin.js')
+ write(denied, 'x')
+ write(path.join(home, 'plugins', 'good', 'desktop', 'plugin.js'), 'y')
+ fs.chmodSync(denied, 0)
+ const warn = vi.spyOn(console, 'warn').mockImplementation(() => undefined)
+
+ try {
+ expect(await reconcileUnifiedDesktopHalves(home, appRoot)).toEqual([path.join(appRoot, 'good')])
+ expect(warn).toHaveBeenCalledWith(expect.stringContaining('skipping unreadable package denied'))
+ } finally {
+ warn.mockRestore()
+ fs.chmodSync(denied, 0o600)
+ }
+ }
+ )
+
it('stamps the package origin (catalog sidecar, else git remote) so "Install here" can reinstall the agent half', async () => {
const home = makeHome()
const appRoot = path.join(home, 'desktop-plugins')
diff --git a/apps/desktop/electron/desktop-plugins-root.ts b/apps/desktop/electron/desktop-plugins-root.ts
index 1932a0cf9bf..f3864af68bf 100644
--- a/apps/desktop/electron/desktop-plugins-root.ts
+++ b/apps/desktop/electron/desktop-plugins-root.ts
@@ -218,7 +218,18 @@ export async function reconcileUnifiedDesktopHalves(hermesHome: string, appRoot:
continue
}
- const result = await materializeDesktopHalf(path.join(pluginsRoot, name), appRoot, name)
+ let result: null | string
+
+ try {
+ result = await materializeDesktopHalf(path.join(pluginsRoot, name), appRoot, name)
+ } catch (error) {
+ // One package the app cannot read (Windows ACL EPERM on lstat/copy, a
+ // mode-000 folder) must not reject the whole reconcile — the root would
+ // never resolve and EVERY desktop plugin would silently stop loading.
+ console.warn(`[desktop-plugins] skipping unreadable package ${name}: ${String(error)}`)
+
+ continue
+ }
if (result || fs.existsSync(path.join(pluginsRoot, name, 'desktop', 'plugin.js'))) {
seen.add(name)