Skip to content

The agent that grows with you

fix(desktop): install dialog reports a refused desktop half as failed

Teknium5b4468b159db
diff --git a/apps/desktop/electron/desktop-plugins-root.test.ts b/apps/desktop/electron/desktop-plugins-root.test.ts
index a1ce00675aa..0135079d4ce 100644
--- a/apps/desktop/electron/desktop-plugins-root.test.ts
+++ b/apps/desktop/electron/desktop-plugins-root.test.ts
@@ -8,6 +8,7 @@ import {
materializeDesktopHalf,
migrateProfileScopedDesktopPlugins,
PACKAGE_MARKER,
+ reconcileDesktopHalvesReport,
reconcileUnifiedDesktopHalves
} from './desktop-plugins-root'
@@ -482,4 +483,30 @@ describe('desktop tree publication', () => {
expect(fs.readFileSync(path.join(appRoot, 'media', 'asset.txt'), 'utf8')).toBe('checkout file')
}
)
+
+ it.skipIf(process.platform === 'win32')(
+ 'names each refused package and its reason beside the halves it did publish',
+ async () => {
+ // The install dialog reads this to report a refused desktop half as failed, not installed.
+ const home = makeHome()
+ const appRoot = path.join(home, 'desktop-plugins')
+ const pkg = path.join(home, 'plugins', 'media')
+ write(path.join(pkg, 'assets', 'asset.txt'), 'package file')
+ write(path.join(pkg, 'desktop', 'plugin.js'), 'export default {}')
+ fs.symlinkSync('../assets/asset.txt', path.join(pkg, 'desktop', 'asset.txt'))
+ write(path.join(home, 'plugins', 'good', 'desktop', 'plugin.js'), 'export default {}')
+ const warn = vi.spyOn(console, 'warn').mockImplementation(() => undefined)
+
+ try {
+ expect(await reconcileDesktopHalvesReport(home, appRoot)).toEqual({
+ published: [path.join(appRoot, 'good')],
+ refused: [
+ { name: 'media', reason: 'The desktop plugin contains a symbolic link (asset.txt); it is not installed.' }
+ ]
+ })
+ } finally {
+ warn.mockRestore()
+ }
+ }
+ )
})
diff --git a/apps/desktop/electron/desktop-plugins-root.ts b/apps/desktop/electron/desktop-plugins-root.ts
index b981b902637..99eaea9fdb2 100644
--- a/apps/desktop/electron/desktop-plugins-root.ts
+++ b/apps/desktop/electron/desktop-plugins-root.ts
@@ -500,12 +500,31 @@ async function sourceGone(name: string, entry: string): Promise<boolean> {
* desktop half. First home wins for a name that appears in several profiles
* (the default home is first). Also drops root copies whose source package
* is gone — an uninstalled agent package must not leave a ghost pane. */
-export function reconcileUnifiedDesktopHalves(hermesHome: string, appRoot: string): Promise<string[]> {
+export async function reconcileUnifiedDesktopHalves(hermesHome: string, appRoot: string): Promise<string[]> {
+ return (await reconcileDesktopHalvesReport(hermesHome, appRoot)).published
+}
+
+/** A package whose desktop half this pass did not publish, and why (the plain-tree check, an unreadable folder). */
+export interface RefusedDesktopHalf {
+ name: string
+ reason: string
+}
+
+/** `published`: the root copies written or pruned. `refused`: packages whose desktop half was not published. */
+export interface DesktopReconcileReport {
+ published: string[]
+ refused: RefusedDesktopHalf[]
+}
+
+/** `reconcileUnifiedDesktopHalves`, also naming each package it refused, so an install that just put one
+ * down can report its desktop half as failed instead of done. */
+export function reconcileDesktopHalvesReport(hermesHome: string, appRoot: string): Promise<DesktopReconcileReport> {
return withDesktopPluginsRoot(appRoot, () => reconcilePass(hermesHome, appRoot))
}
-async function reconcilePass(hermesHome: string, appRoot: string): Promise<string[]> {
+async function reconcilePass(hermesHome: string, appRoot: string): Promise<DesktopReconcileReport> {
const touched: string[] = []
+ const refused: RefusedDesktopHalf[] = []
const seen = new Set<string>()
for (const home of await localHomes(hermesHome)) {
@@ -526,6 +545,7 @@ async function reconcilePass(hermesHome: string, appRoot: string): Promise<strin
// never resolve and EVERY desktop plugin would silently stop loading.
// A desktop half refused by the plain-tree check lands here too.
console.warn(`[desktop-plugins] skipping package ${name}: ${String(error)}`)
+ refused.push({ name, reason: error instanceof Error ? error.message : String(error) })
continue
}
@@ -552,5 +572,5 @@ async function reconcilePass(hermesHome: string, appRoot: string): Promise<strin
}
}
- return touched
+ return { published: touched, refused }
}
diff --git a/apps/desktop/electron/fs-ipc.ts b/apps/desktop/electron/fs-ipc.ts
index f31530591ee..6dda7ad2852 100644
--- a/apps/desktop/electron/fs-ipc.ts
+++ b/apps/desktop/electron/fs-ipc.ts
@@ -15,6 +15,7 @@ import {
DESKTOP_PLUGINS_DIR,
ensureDir,
migrateProfileScopedDesktopPlugins,
+ reconcileDesktopHalvesReport,
reconcileUnifiedDesktopHalves
} from './desktop-plugins-root'
import { DESKTOP_PROFILE_NAME_RE } from './desktop-profile'
@@ -154,11 +155,12 @@ export function registerFsIpc({
// Re-run the unified-half reconcile on demand (after an agent-plugin install /
// update / uninstall through the gateway) so the app-level copy tracks the
- // package without waiting for the next root resolution.
+ // package without waiting for the next root resolution. Answers which
+ // packages' halves it refused too, so the install dialog can say so.
ipcMain.handle('hermes:fs:reconcileDesktopPlugins', async () => {
const root = await ensureDir(path.join(hermesHome, DESKTOP_PLUGINS_DIR))
- return reconcileUnifiedDesktopHalves(hermesHome, root)
+ return reconcileDesktopHalvesReport(hermesHome, root)
})
// The LOCAL logs root (`<HERMES_HOME>/logs`, profile-aware) — the error
diff --git a/apps/desktop/electron/preload.ts b/apps/desktop/electron/preload.ts
index 33494d336a5..bdf5679e2c5 100644
--- a/apps/desktop/electron/preload.ts
+++ b/apps/desktop/electron/preload.ts
@@ -488,7 +488,8 @@ contextBridge.exposeInMainWorld('hermesDesktop', {
revealPath: targetPath => ipcRenderer.invoke('hermes:fs:reveal', targetPath),
openDir: dirPath => ipcRenderer.invoke('hermes:fs:openDir', dirPath),
desktopPluginsRoot: () => ipcRenderer.invoke('hermes:fs:desktopPluginsRoot'),
- reconcileDesktopPlugins: () => ipcRenderer.invoke('hermes:fs:reconcileDesktopPlugins'),
+ reconcileDesktopPlugins: async () => (await ipcRenderer.invoke('hermes:fs:reconcileDesktopPlugins')).published,
+ reconcileDesktopPluginsReport: () => ipcRenderer.invoke('hermes:fs:reconcileDesktopPlugins'),
logsRoot: (profile?: string) => ipcRenderer.invoke('hermes:fs:logsRoot', profile),
renamePath: (targetPath, newName) => ipcRenderer.invoke('hermes:fs:rename', targetPath, newName),
writeTextFile: (filePath, content) => ipcRenderer.invoke('hermes:fs:writeText', filePath, content),
diff --git a/apps/desktop/src/app/settings/plugin-install-modal.test.tsx b/apps/desktop/src/app/settings/plugin-install-modal.test.tsx
index 3e12c8034ec..ab7d84b663f 100644
--- a/apps/desktop/src/app/settings/plugin-install-modal.test.tsx
+++ b/apps/desktop/src/app/settings/plugin-install-modal.test.tsx
@@ -20,6 +20,7 @@ vi.mock('@/hermes', async importOriginal => ({
import { $pluginDecisions, $pluginRecords, dropPlugin, patchPlugin, publishPlugin } from '@/contrib/plugins-store'
import { queryClient } from '@/lib/query-client'
+import { $notifications } from '@/store/notifications'
import {
$pluginInstallRequest,
closePluginInstallRequest,
@@ -439,4 +440,35 @@ describe('Unified package desktop half on a local backend', () => {
expect(screen.queryByRole('button', { name: 'Retry' })).toBeNull()
expect(installButton().disabled).toBe(true)
})
+
+ it('reports the desktop half as failed when the reconcile refused the package it just installed', async () => {
+ // A combined package whose desktop/ folder holds a symlink: the agent half installs, the reconcile
+ // refuses to publish the desktop half, and the dialog must say so instead of "installed".
+ const reason = 'The desktop plugin contains a symbolic link (asset.txt); it is not installed.'
+ const reconcileDesktopPluginsReport = vi.fn(async () => ({ published: [], refused: [{ name: 'pkg', reason }] }))
+ $notifications.set([])
+ probePluginRepo.mockResolvedValue({ ok: true, agent: true, agentName: 'pkg', desktop: true, warnings: [] })
+ requestGateway.mockImplementation(async (method, params) =>
+ method === 'plugins.manage' && params?.action === 'install'
+ ? { ok: true, plugin_name: 'pkg', enabled: false }
+ : { plugins: [] }
+ )
+ vi.stubGlobal('hermesDesktop', {
+ installDesktopPlugin,
+ probePluginRepo,
+ reconcileDesktopPlugins,
+ reconcileDesktopPluginsReport
+ })
+ renderFlow()
+ act(() => openPluginInstallRequest({ repo: 'https://github.com/example/pkg' }))
+ expect(await screen.findByText('This package includes')).toBeTruthy()
+ await waitFor(() => expect(installButton().disabled).toBe(false))
+ fireEvent.click(installButton())
+
+ expect(await screen.findByText(reason)).toBeTruthy()
+ const toasts = $notifications.get().map(n => n.message)
+ expect(toasts).toContain('Agent plugin pkg installed')
+ expect(toasts).not.toContain('Desktop plugin pkg installed')
+ expect(installDesktopPlugin).not.toHaveBeenCalled()
+ })
})
diff --git a/apps/desktop/src/app/settings/plugin-install-run.ts b/apps/desktop/src/app/settings/plugin-install-run.ts
index 5d4531c2428..1ad61436676 100644
--- a/apps/desktop/src/app/settings/plugin-install-run.ts
+++ b/apps/desktop/src/app/settings/plugin-install-run.ts
@@ -229,6 +229,20 @@ async function desktopHalfLanded(name: string, touched: readonly string[]): Prom
}
}
+/** Refresh unified packages' desktop halves. `refusal` is why the half of package `name` was not published
+ * (a symlink in its tree, too big, unreadable). */
+async function reconcilePackageHalf(name: string): Promise<{ refusal?: string; touched: string[] }> {
+ const desktop = window.hermesDesktop
+
+ if (desktop?.reconcileDesktopPluginsReport) {
+ const { published, refused } = await desktop.reconcileDesktopPluginsReport()
+
+ return { refusal: refused.find(entry => entry.name === name)?.reason, touched: published }
+ }
+
+ return { touched: (await desktop?.reconcileDesktopPlugins?.()) ?? [] }
+}
+
async function installDesktopHalf(
plan: InstallPlan,
components: InstallComponents,
@@ -241,10 +255,13 @@ async function installDesktopHalf(
// follows updates/uninstall) whether or not the agent install succeeded. A package already on disk
// answers "already exists" without Force, and cloning would land desktop-plugins/<git-name>/ beside
// the package copy (#100412).
- const touched = (await window.hermesDesktop?.reconcileDesktopPlugins?.()) ?? []
const name = agentResult?.pluginName ?? plan.probe.agentName ?? plan.request.repo
+ const { refusal, touched } = await reconcilePackageHalf(name)
- if (await desktopHalfLanded(name, touched)) {
+ if (refusal) {
+ // The pass refused this package's tree (a symlink in it, too big): its reason is the dialog's failure.
+ report.errors.push(refusal)
+ } else if (await desktopHalfLanded(name, touched)) {
report.successes.push(deps.copy.desktopSuccess(name))
} else if (agentResult?.ok) {
// The agent half is in, but the host copied no desktop half out of it: never report one installed.
diff --git a/apps/desktop/src/global.d.ts b/apps/desktop/src/global.d.ts
index 76e2ffa92f9..115ddd6b974 100644
--- a/apps/desktop/src/global.d.ts
+++ b/apps/desktop/src/global.d.ts
@@ -522,6 +522,11 @@ declare global {
desktopPluginsRoot?: () => Promise<string>
/** Refresh unified packages' desktop halves and return the touched paths. */
reconcileDesktopPlugins?: () => Promise<string[]>
+ /** The same refresh, also naming each package whose desktop half it refused and why. */
+ reconcileDesktopPluginsReport?: () => Promise<{
+ published: string[]
+ refused: { name: string; reason: string }[]
+ }>
/** LOCAL `<HERMES_HOME>/logs` of `profile` (default: the active Desktop
* profile) — error card "Open Logs". */
logsRoot?: (profile?: string) => Promise<string>