The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
Merge remote-tracking branch 'origin/main' into ethie/pm-clean
ethernetc78a805d4992
diff --cc apps/desktop/src/app/settings/uninstall-section.test.tsxindex 8a2feeb42f2,7c5f00196b8..68a7605380d--- a/apps/desktop/src/app/settings/uninstall-section.test.tsx+++ b/apps/desktop/src/app/settings/uninstall-section.test.tsx@@@ -1,74 -1,44 +1,109 @@@-import { act, cleanup, fireEvent, render, screen } from '@testing-library/react'+import { act, cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react'import { afterEach, expect, it, vi } from 'vitest'+import type { DesktopUninstallSummary } from '@/global'+ import { I18nProvider, TRANSLATIONS, useI18n } from '@/i18n'+ import type { I18nContextValue } from '@/i18n'import { UninstallSection } from './uninstall-section'+ let i18n: I18nContextValue+-function Surface() {++function Surface(): React.JSX.Element {+ i18n = useI18n()++ return <UninstallSection />+ }+-afterEach(() => {+function summary(allowed: boolean): DesktopUninstallSummary {+ return {+ code_removal_allowed: allowed,+ hermes_home: '/test/home',+ agent_installed: true,+ gui_installed: true,+ source_built_artifacts: [],+ packaged_app_paths: [],+ userdata_dir: '/test/desktop',+ userdata_exists: true,+ platform: 'linux'+ }+}++afterEach((): void => {cleanup()vi.unstubAllGlobals()})++it.each(['external', '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> => {+ const getSummary: ReturnType<typeof vi.fn> = vi.fn(async (): Promise<DesktopUninstallSummary> => {+ if (state === 'probe-failed') {+ throw new Error('IPC unavailable')+ }++ if (state === 'loading') {+ return new Promise<DesktopUninstallSummary>((): void => {})+ }++ if (state === 'missing-policy') {+ const { code_removal_allowed: _ignored, ...oldSummary }: ReturnType<typeof summary> = summary(true)++ return oldSummary as DesktopUninstallSummary+ }++ return summary(false)+ })++ const run: ReturnType<typeof vi.fn> = vi.fn()++ vi.stubGlobal('hermesDesktop', { uninstall: { summary: getSummary, run } })+ await act(async (): Promise<void> => {+ render(<UninstallSection />)+ })+ expect(getSummary).toHaveBeenCalledOnce()+ expect(screen.queryByText('Uninstall Hermes')).toBeNull()+ expect(screen.queryByRole('button', { name: /Uninstall/ })).toBeNull()+ expect(screen.queryByText('Danger zone')).toBeNull()+ expect(run).not.toHaveBeenCalled()+ }+)++it('keeps owned-install removal modes and confirms the selected mode', async (): Promise<void> => {+ const run: ReturnType<typeof vi.fn> = vi.fn().mockResolvedValue({ ok: true })+ vi.stubGlobal('hermesDesktop', {+ uninstall: { summary: async (): Promise<DesktopUninstallSummary> => summary(true), run }+ })+ render(<UninstallSection />)+ fireEvent.click(await screen.findByRole('button', { name: /Uninstall Chat GUI only/ }))+ expect(run).not.toHaveBeenCalled()+ fireEvent.click(screen.getByRole('button', { name: 'Yes, uninstall' }))+ await waitFor((): void => {+ expect(run).toHaveBeenCalledWith('gui')+ })+})+++ it.each(['gui', 'lite', 'full'] as const)(+ 'localizes confirmation for %s without changing mode or running before confirmation',- async mode => {- const run = vi.fn().mockResolvedValue({ ok: false })++ async (mode: 'gui' | 'lite' | 'full'): Promise<void> => {++ const run: ReturnType<typeof vi.fn> = vi.fn().mockResolvedValue({ ok: false })+ vi.stubGlobal('hermesDesktop', {- uninstall: { summary: async () => ({ agent_installed: true, running_app_path: '/fixture/Hermes.app' }), run }++ uninstall: { summary: async (): Promise<DesktopUninstallSummary> => summary(true), run }+ })+ render(+ <I18nProvider configClient={null} initialLocale="zh">+ <Surface />+ </I18nProvider>+ )- const zh = TRANSLATIONS.zh.settings.uninstallSection++ const zh: (typeof TRANSLATIONS)['zh']['settings']['uninstallSection'] = TRANSLATIONS.zh.settings.uninstallSection+ await screen.findByText(zh.uninstallHermes)+ fireEvent.click(screen.getByRole('button', { name: new RegExp(zh.options[mode].title) }))+ expect(screen.getByText(zh.confirmBody(zh.options[mode].consequence))).toBeTruthy()+ expect(run).not.toHaveBeenCalled()- await act(() => i18n.setLocale('ja'))- const ja = TRANSLATIONS.ja.settings.uninstallSection++ await act((): Promise<void> => i18n.setLocale('ja'))++ const ja: (typeof TRANSLATIONS)['ja']['settings']['uninstallSection'] = TRANSLATIONS.ja.settings.uninstallSection+ expect(screen.getByText(ja.confirmBody(ja.options[mode].consequence))).toBeTruthy()+ fireEvent.click(screen.getByRole('button', { name: ja.yesUninstall }))+ expect(run).toHaveBeenCalledWith(mode)+ }+ )diff --cc apps/desktop/src/app/settings/uninstall-section.tsxindex 4d33e62b539,abdb27a7db2..dd7b5ded5d0--- a/apps/desktop/src/app/settings/uninstall-section.tsx+++ b/apps/desktop/src/app/settings/uninstall-section.tsx@@@ -18,47 -18,52 +18,49 @@@ interface ModeOptionneedsAgent: boolean}- const OPTIONS: ModeOption[] = [- {- mode: 'gui',- title: 'Uninstall Chat GUI only',- description: 'Remove this desktop app. The Hermes agent, your config, and chats all stay.',- consequence: 'the desktop Chat GUI (this app and its data)',- needsAgent: false- },- {- mode: 'lite',- title: 'Uninstall GUI + agent, keep my data',- description: 'Remove the app and the Hermes agent, but keep config, chats, and secrets for a future reinstall.',- consequence: 'the Chat GUI and the Hermes agent (config, chats, and secrets are kept)',- needsAgent: true- },- {- mode: 'full',- title: 'Uninstall everything',- description: 'Remove the app, the agent, and all user data — config, chats, scheduled jobs, secrets, logs.',- consequence: 'EVERYTHING — the Chat GUI, the Hermes agent, and all of your config, chats, secrets, and logs',- // full removes the agent (and user data), so it's an agent-removing option:- // hide it on a lite client with no local agent, same as lite. A lite client- // connecting to a remote backend has no local agent OR local user data the- // GUI installed, so gui-only is the correct (and only) option there.- needsAgent: true- }- ]--export function UninstallSection() {+export function UninstallSection(): ReactElement | null {const hasBreadcrumb = useContext(SettingsBreadcrumbContext)const { t } = useI18n()+ const u = t.settings.uninstallSection++ const options: ModeOption[] = [+ {+ mode: 'gui',+ title: u.options.gui.title,+ description: u.options.gui.description,+ consequence: u.options.gui.consequence,+ needsAgent: false+ },+ {+ mode: 'lite',+ title: u.options.lite.title,+ description: u.options.lite.description,+ consequence: u.options.lite.consequence,+ needsAgent: true+ },+ {+ mode: 'full',+ title: u.options.full.title,+ description: u.options.full.description,+ consequence: u.options.full.consequence,+ // full removes the agent (and user data), so it's an agent-removing option:+ // hide it on a lite client with no local agent, same as lite. A lite client+ // connecting to a remote backend has no local agent OR local user data the+ // GUI installed, so gui-only is the correct (and only) option there.+ needsAgent: true+ }+ ]+const [summary, setSummary] = useState<DesktopUninstallSummary | null>(null)- const [loading, setLoading] = useState(true)const [pending, setPending] = useState<DesktopUninstallMode | null>(null)- const [running, setRunning] = useState(false)+ const [running, setRunning] = useState<boolean>(false)const [error, setError] = useState<string | null>(null)- useEffect(() => {- let alive = true- const bridge = window.hermesDesktop?.uninstall+ useEffect((): (() => void) | undefined => {+ let alive: boolean = true+ const bridge: Window['hermesDesktop']['uninstall'] | undefined = window.hermesDesktop?.uninstallif (!bridge) {- setLoading(false)-return}@@@ -87,11 -94,12 +89,11 @@@return null}- // Gate the agent-removing options on whether an agent is actually present.- // A future lite client that ships without the bundled agent shows GUI-only.- const agentInstalled = summary?.agent_installed ?? false- const visibleOptions = options.filter(opt => agentInstalled || !opt.needsAgent)+ // 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)++ const visibleOptions: ModeOption[] = options.filter((opt: ModeOption): boolean => agentInstalled || !opt.needsAgent)- const handleConfirm = async () => {+ const handleConfirm: () => Promise<void> = async (): Promise<void> => {if (!pending) {return}@@@ -100,10 -108,10 +102,10 @@@setError(null)try {- const result = await bridge.run(pending)+ const result: DesktopUninstallResult = await bridge.run(pending)if (!result.ok) {- setError(result.message || result.error || 'Uninstall could not start.')+ setError(result.message || result.error || u.couldNotStart)setRunning(false)setPending(null)}@@@ -115,41 -123,44 +117,39 @@@}}- const pendingOption: ModeOption | null = OPTIONS.find((opt: ModeOption): boolean => opt.mode === pending) ?? null- const pendingOption = options.find(opt => opt.mode === pending) ?? null++ const pendingOption: ModeOption | null = options.find((opt: ModeOption): boolean => opt.mode === pending) ?? nullreturn (<div className={cn('mx-auto w-full max-w-2xl', !hasBreadcrumb && 'mt-8')}><SectionHeading icon={AlertTriangle} page title={t.settings.uninstallSection.dangerZone} /><div className="rounded-xl border border-destructive/30 bg-destructive/5 px-4 py-3">- {loading ? (- <div className="flex items-center gap-2 py-2 text-sm text-muted-foreground">- <Loader2 className="size-3.5 animate-spin" />- {u.checkingInstalled}- </div>- ) : pendingOption ? (+ {pendingOption ? (<div><p className="text-sm font-medium text-destructive">{t.settings.uninstallSection.confirmUninstall}</p>- <p className="mt-1 text-xs text-muted-foreground">- This removes {pendingOption.consequence}. This can't be undone.- </p>+ <p className="mt-1 text-xs text-muted-foreground">{u.confirmBody(pendingOption.consequence)}</p>{summary?.running_app_path && (- <p className="mt-1 font-mono text-[0.68rem] text-muted-foreground/60">App: {summary.running_app_path}</p>+ <p className="mt-1 font-mono text-[0.68rem] text-muted-foreground/60">+ {u.appLabel} {summary.running_app_path}+ </p>)}{error && <p className="mt-2 text-xs text-destructive">{error}</p>}<div className="mt-3 flex flex-wrap items-center gap-3">- <Button disabled={running} onClick={() => void handleConfirm()} size="sm" variant="destructive">+ <Button disabled={running} onClick={(): void => void handleConfirm()} size="sm" variant="destructive">{running && <Loader2 className="size-3 animate-spin" />}- {running ? 'Uninstalling…' : 'Yes, uninstall'}+ {running ? u.uninstalling : u.yesUninstall}</Button>- <Button disabled={running} onClick={() => setPending(null)} size="sm" variant="text">+ <Button disabled={running} onClick={(): void => setPending(null)} size="sm" variant="text">- Cancel+ {t.common.cancel}</Button></div></div>) : (<div className="flex flex-col gap-2"><p className="text-sm font-medium">{t.settings.uninstallSection.uninstallHermes}</p>- <p className="text-xs text-muted-foreground">- Choose how much to remove. The app closes to finish the job; reopen the installer any time to come back.- </p>+ <p className="text-xs text-muted-foreground">{u.chooseHowMuch}</p><div className="mt-1 flex flex-col gap-2">- {visibleOptions.map(opt => (+ {visibleOptions.map((opt: ModeOption): ReactElement => (<buttonclassName={cn('flex items-start gap-3 rounded-lg border border-border/60 bg-background/40 px-3 py-2.5 text-left transition',