Skip to content

The agent that grows with you

Packaged installs show how to uninstall instead of an empty page (#130047)

Siddharth Balyan72ffe398c045
diff --git a/apps/desktop/electron/desktop-uninstall-ipc.test.ts b/apps/desktop/electron/desktop-uninstall-ipc.test.ts
index 79fee6235d0..4c11a223397 100644
--- a/apps/desktop/electron/desktop-uninstall-ipc.test.ts
+++ b/apps/desktop/electron/desktop-uninstall-ipc.test.ts
@@ -4,7 +4,7 @@ import { registerDesktopUninstallIpc } from './desktop-uninstall'
import type { DesktopUninstallIpcDeps, DesktopUninstallSummary } from './desktop-uninstall'
import type { InstallStamp } from './install-stamp'
-const fallbackSummary: Omit<DesktopUninstallSummary, 'code_removal_allowed'> = {
+const fallbackSummary: Omit<DesktopUninstallSummary, 'code_removal_allowed' | 'native_removal_instructions'> = {
hermes_home: '/test/.hermes',
agent_installed: true,
gui_installed: true,
@@ -31,7 +31,8 @@ function captureIpc(stamp: DesktopUninstallIpcDeps['stamp']): CapturedIpc {
const probeSummary: CapturedIpc['probeSummary'] = vi.fn(async (): Promise<DesktopUninstallSummary> => ({
...fallbackSummary,
probe: 'python',
- code_removal_allowed: true
+ code_removal_allowed: true,
+ native_removal_instructions: null
}))
const runUninstall: CapturedIpc['runUninstall'] = vi.fn<DesktopUninstallIpcDeps['runUninstall']>(
@@ -48,7 +49,15 @@ function captureIpc(stamp: DesktopUninstallIpcDeps['stamp']): CapturedIpc {
}
}
- registerDesktopUninstallIpc({ ipcMain, stamp, fallbackSummary: localSummary, probeSummary, runUninstall })
+ registerDesktopUninstallIpc({
+ ipcMain,
+ stamp,
+ fallbackSummary: localSummary,
+ probeSummary,
+ runUninstall,
+ removableAppPath: (): null => null,
+ openAppsSettings: async (): Promise<void> => {}
+ })
return {
probeSummary,
@@ -78,9 +87,10 @@ test('excluded artifact owners block every uninstall IPC before a Python probe o
for (const stamp of stamps) {
const ipc: CapturedIpc = captureIpc(stamp)
- expect(await ipc.invoke('hermes:uninstall:summary')).toEqual({
+ expect(await ipc.invoke('hermes:uninstall:summary')).toMatchObject({
...fallbackSummary,
- code_removal_allowed: false
+ code_removal_allowed: false,
+ native_removal_instructions: expect.any(String)
})
expect(ipc.probeSummary).not.toHaveBeenCalled()
@@ -101,16 +111,22 @@ test('self-managed installs retain summary and uninstall IPC behavior under Elec
for (const stamp of [null, { payload: 'bootstrap', updateMechanism: 'self' }] as const) {
const ipc: CapturedIpc = captureIpc(stamp)
- ipc.probeSummary.mockResolvedValue({ ...fallbackSummary, probe: 'python', code_removal_allowed: false })
+ ipc.probeSummary.mockResolvedValue({
+ ...fallbackSummary,
+ probe: 'python',
+ code_removal_allowed: false,
+ native_removal_instructions: null
+ })
expect(await ipc.invoke('hermes:uninstall:summary')).toEqual({
...fallbackSummary,
probe: 'python',
- code_removal_allowed: true
+ code_removal_allowed: true,
+ native_removal_instructions: null
})
expect(ipc.probeSummary).toHaveBeenCalledOnce()
expect(ipc.localSummary).not.toHaveBeenCalled()
- ipc.probeSummary.mockResolvedValue({ ...fallbackSummary, code_removal_allowed: false })
+ ipc.probeSummary.mockResolvedValue({ ...fallbackSummary, code_removal_allowed: false, native_removal_instructions: null })
expect(await ipc.invoke('hermes:uninstall:summary')).toMatchObject({
probe: 'fallback',
code_removal_allowed: true
diff --git a/apps/desktop/electron/desktop-uninstall.ts b/apps/desktop/electron/desktop-uninstall.ts
index ae51e549b02..452d8408e3d 100644
--- a/apps/desktop/electron/desktop-uninstall.ts
+++ b/apps/desktop/electron/desktop-uninstall.ts
@@ -44,6 +44,8 @@ export interface UninstallSummaryDetails {
export interface DesktopUninstallSummary extends UninstallSummaryDetails {
code_removal_allowed: boolean
+ /** Set only when the OS or package manager owns removal; the renderer shows it verbatim. */
+ native_removal_instructions: string | null
}
export interface DesktopUninstallResult {
@@ -63,6 +65,8 @@ export interface DesktopUninstallIpcDeps {
fallbackSummary: () => UninstallSummaryDetails
probeSummary: () => Promise<UninstallSummaryDetails>
runUninstall: (mode: string) => Promise<DesktopUninstallResult>
+ removableAppPath: () => string | null
+ openAppsSettings: () => Promise<void>
}
export function registerDesktopUninstallIpc({
@@ -70,7 +74,9 @@ export function registerDesktopUninstallIpc({
stamp,
fallbackSummary,
probeSummary,
- runUninstall
+ runUninstall,
+ removableAppPath,
+ openAppsSettings
}: DesktopUninstallIpcDeps): void {
const kind: InstallKind = resolveInstallKind(stamp ?? {})
const codeRemovalAllowed: boolean = installKindAllowsCodeRemoval(kind)
@@ -78,8 +84,23 @@ export function registerDesktopUninstallIpc({
ipcMain.handle('hermes:uninstall:summary', async (): Promise<DesktopUninstallSummary> => {
const summary: UninstallSummaryDetails = codeRemovalAllowed ? await probeSummary() : fallbackSummary()
- // The local artifact owns this decision, not the Python summary.
- return { ...summary, code_removal_allowed: codeRemovalAllowed }
+ // The local artifact owns this decision, not the Python summary. When
+ // removal belongs to the OS, the main process also supplies the canonical
+ // instructions so the renderer never guesses platform or install kind.
+ return {
+ ...summary,
+ code_removal_allowed: codeRemovalAllowed,
+ native_removal_instructions: codeRemovalAllowed
+ ? null
+ : nativeRemovalInstructions(kind, summary.platform, removableAppPath())
+ }
+ })
+ ipcMain.handle('hermes:uninstall:openAppsSettings', async (): Promise<void> => {
+ // The generic openExternal bridge admits web schemes only; this one
+ // deep link is fixed here so the renderer cannot pass a URL.
+ if (!codeRemovalAllowed && process.platform === 'win32') {
+ await openAppsSettings()
+ }
})
ipcMain.handle(
'hermes:uninstall:run',
diff --git a/apps/desktop/electron/main.ts b/apps/desktop/electron/main.ts
index 964c7bca9e0..ef8b20db9c0 100644
--- a/apps/desktop/electron/main.ts
+++ b/apps/desktop/electron/main.ts
@@ -19019,7 +19019,9 @@ registerDesktopUninstallIpc({
stamp: INSTALL_STAMP,
fallbackSummary: fallbackUninstallSummary,
probeSummary: probeUninstallSummary,
- runUninstall: runDesktopUninstall
+ runUninstall: runDesktopUninstall,
+ removableAppPath: () => resolveRemovableAppPath(process.execPath, process.platform, process.env),
+ openAppsSettings: () => shell.openExternal('ms-settings:appsfeatures')
})
// Download a VS Code Marketplace extension and return the raw color-theme JSON
diff --git a/apps/desktop/electron/preload.ts b/apps/desktop/electron/preload.ts
index 70858e128bf..d9210b746a2 100644
--- a/apps/desktop/electron/preload.ts
+++ b/apps/desktop/electron/preload.ts
@@ -617,7 +617,8 @@ contextBridge.exposeInMainWorld('hermesDesktop', {
getRemoteDisplayReason: () => ipcRenderer.invoke('hermes:get-remote-display-reason'),
uninstall: {
summary: () => ipcRenderer.invoke('hermes:uninstall:summary'),
- run: mode => ipcRenderer.invoke('hermes:uninstall:run', { mode })
+ run: mode => ipcRenderer.invoke('hermes:uninstall:run', { mode }),
+ openAppsSettings: () => ipcRenderer.invoke('hermes:uninstall:openAppsSettings')
},
updates: {
check: opts => ipcRenderer.invoke('hermes:updates:check', opts),
diff --git a/apps/desktop/src/app/settings/uninstall-section.test.tsx b/apps/desktop/src/app/settings/uninstall-section.test.tsx
index 68a7605380d..9f800ae0119 100644
--- a/apps/desktop/src/app/settings/uninstall-section.test.tsx
+++ b/apps/desktop/src/app/settings/uninstall-section.test.tsx
@@ -18,6 +18,7 @@ function Surface(): React.JSX.Element {
function summary(allowed: boolean): DesktopUninstallSummary {
return {
code_removal_allowed: allowed,
+ native_removal_instructions: allowed ? null : 'Quit the app and drag Hermes.app from Applications to the Trash.',
hermes_home: '/test/home',
agent_installed: true,
gui_installed: true,
@@ -34,9 +35,9 @@ afterEach((): void => {
vi.unstubAllGlobals()
})
-it.each(['external', 'missing-policy', 'probe-failed', 'loading'] as const)(
+it.each(['missing-policy', 'probe-failed', 'loading'] as const)(
'does not offer uninstall actions when ownership is %s',
- async (state: 'external' | 'missing-policy' | 'probe-failed' | 'loading'): Promise<void> => {
+ async (state: 'missing-policy' | 'probe-failed' | 'loading'): Promise<void> => {
const getSummary: ReturnType<typeof vi.fn> = vi.fn(async (): Promise<DesktopUninstallSummary> => {
if (state === 'probe-failed') {
throw new Error('IPC unavailable')
@@ -107,3 +108,27 @@ it.each(['gui', 'lite', 'full'] as const)(
expect(run).toHaveBeenCalledWith(mode)
}
)
+
+it('shows native removal steps, data location, and Apps settings on a managed Windows install', async (): Promise<void> => {
+ const run: ReturnType<typeof vi.fn> = vi.fn()
+ const openAppsSettings: ReturnType<typeof vi.fn> = vi.fn().mockResolvedValue(undefined)
+
+ vi.stubGlobal('hermesDesktop', {
+ uninstall: {
+ summary: async (): Promise<DesktopUninstallSummary> => ({
+ ...summary(false),
+ platform: 'win32',
+ native_removal_instructions: 'To uninstall, go to Windows Settings → Apps → Installed apps.'
+ }),
+ run,
+ openAppsSettings
+ }
+ })
+ render(<UninstallSection />)
+ expect(await screen.findByText(/Installed apps/)).toBeTruthy()
+ expect(screen.getByText(/\/test\/home/)).toBeTruthy()
+ fireEvent.click(screen.getByRole('button', { name: 'Open Apps settings' }))
+ expect(openAppsSettings).toHaveBeenCalledOnce()
+ expect(run).not.toHaveBeenCalled()
+ expect(screen.queryByRole('button', { name: /Uninstall/ })).toBeNull()
+})
diff --git a/apps/desktop/src/app/settings/uninstall-section.tsx b/apps/desktop/src/app/settings/uninstall-section.tsx
index dd7b5ded5d0..e632341eef0 100644
--- a/apps/desktop/src/app/settings/uninstall-section.tsx
+++ b/apps/desktop/src/app/settings/uninstall-section.tsx
@@ -85,10 +85,35 @@ export function UninstallSection(): ReactElement | null {
const bridge: Window['hermesDesktop']['uninstall'] | undefined = window.hermesDesktop?.uninstall
- if (!bridge || summary?.code_removal_allowed !== true) {
+ if (!bridge || !summary) {
return null
}
+ if (!summary.code_removal_allowed) {
+ // The OS or package manager owns removal; show how, never a destructive fallback.
+ if (!summary.native_removal_instructions) {
+ return null
+ }
+
+ return (
+ <div className={cn('mx-auto w-full max-w-2xl', !hasBreadcrumb && 'mt-8')}>
+ <SectionHeading icon={AlertTriangle} page title={u.uninstallHermes} />
+ <div className="flex flex-col gap-2 rounded-xl border border-border/60 bg-background/40 px-4 py-3">
+ <p className="text-xs text-muted-foreground">{u.managedBody}</p>
+ <p className="text-sm font-medium">{summary.native_removal_instructions}</p>
+ <p className="text-xs text-muted-foreground">{u.dataKept(summary.hermes_home)}</p>
+ {summary.platform === 'win32' && (
+ <div className="mt-1">
+ <Button onClick={(): void => void bridge.openAppsSettings()} size="sm" variant="outline">
+ {u.openAppsSettings}
+ </Button>
+ </div>
+ )}
+ </div>
+ </div>
+ )
+ }
+
// An owned GUI can remain after its local agent has been removed.
const agentInstalled: boolean = summary.agent_installed
const visibleOptions: ModeOption[] = options.filter((opt: ModeOption): boolean => agentInstalled || !opt.needsAgent)
diff --git a/apps/desktop/src/global.d.ts b/apps/desktop/src/global.d.ts
index 103756aa18d..cda711574c4 100644
--- a/apps/desktop/src/global.d.ts
+++ b/apps/desktop/src/global.d.ts
@@ -615,6 +615,7 @@ declare global {
uninstall: {
summary: () => Promise<DesktopUninstallSummary>
run: (mode: DesktopUninstallMode) => Promise<DesktopUninstallResult>
+ openAppsSettings: () => Promise<void>
}
themes: {
// Download a VS Code Marketplace extension and return the raw color
@@ -774,6 +775,8 @@ export type DesktopUninstallMode = 'full' | 'gui' | 'lite'
export interface DesktopUninstallSummary {
/** Local package ownership, resolved by Electron before offering removal. */
code_removal_allowed: boolean
+ /** Native removal steps when the OS or a package manager owns removal. */
+ native_removal_instructions: null | string
hermes_home: string
agent_installed: boolean
gui_installed: boolean
diff --git a/apps/desktop/src/i18n/en.ts b/apps/desktop/src/i18n/en.ts
index 4f239d04771..397989dfdd8 100644
--- a/apps/desktop/src/i18n/en.ts
+++ b/apps/desktop/src/i18n/en.ts
@@ -1324,6 +1324,9 @@ export const en: Translations = {
dangerZone: 'Danger zone',
checkingInstalled: 'Checking what’s installed…',
uninstallHermes: 'Uninstall Hermes',
+ managedBody: 'This install is managed by your system, so Hermes cannot remove itself.',
+ dataKept: path => `Your config, chats, and secrets live in ${path}. Removing the app does not delete them.`,
+ openAppsSettings: 'Open Apps settings',
chooseHowMuch:
'Choose how much to remove. The app closes to finish the job; reopen the installer any time to come back.',
confirmUninstall: 'Confirm uninstall',
diff --git a/apps/desktop/src/i18n/types.ts b/apps/desktop/src/i18n/types.ts
index 0ebfdb36700..7dabe0fa233 100644
--- a/apps/desktop/src/i18n/types.ts
+++ b/apps/desktop/src/i18n/types.ts
@@ -1111,6 +1111,9 @@ export interface Translations {
dangerZone: string
checkingInstalled: string
uninstallHermes: string
+ managedBody: string
+ dataKept: (path: string) => string
+ openAppsSettings: string
chooseHowMuch: string
confirmUninstall: string
confirmBody: (what: string) => string