The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): don't offer the real-profile consent prompt on remote backends
Austin Picketta266cf5e60cc
diff --git a/apps/desktop/src/app/chat/right-rail/real-profile-consent-dialog.test.tsx b/apps/desktop/src/app/chat/right-rail/real-profile-consent-dialog.test.tsxindex 4f06db5b0ba..7f1feeae410 100644--- a/apps/desktop/src/app/chat/right-rail/real-profile-consent-dialog.test.tsx+++ b/apps/desktop/src/app/chat/right-rail/real-profile-consent-dialog.test.tsx@@ -2,13 +2,15 @@import { act, cleanup, fireEvent, render, screen } from '@testing-library/react'import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'+import type { HermesConnection } from '@/global'import {$realProfilePromptClaim,$realProfilePromptDismissed,$realProfilePromptMuted} from '@/store/real-profile-consent'+import { $connection } from '@/store/session'-import { RealProfileConsentDialog } from './real-profile-consent-dialog'+import { RealProfileConsentDialog, shouldOfferRealProfilePrompt } from './real-profile-consent-dialog'const mocks = vi.hoisted(() => ({cache: vi.fn(),@@ -61,6 +63,46 @@ vi.mock('../../hooks/use-config-record', () => ({useHermesConfigRecord: () => ({ data: mocks.loadedConfig })}))+const localConnection = { mode: 'local' } as HermesConnection+const remoteConnection = { mode: 'remote', remoteKind: 'ssh' } as HermesConnection++const openGate = {+ claim: 'tab-1',+ configLoaded: true,+ connection: localConnection,+ dismissed: false,+ enabled: false,+ muted: false,+ tabId: 'tab-1'+}++describe('shouldOfferRealProfilePrompt', () => {+ it('offers the prompt for a local backend with the feature off', () => {+ expect(shouldOfferRealProfilePrompt(openGate)).toBe(true)+ })++ it('never offers it for a remote backend (#119398)', () => {+ for (const remoteKind of ['ssh', 'url', 'cloud'] as const) {+ expect(+ shouldOfferRealProfilePrompt({ ...openGate, connection: { mode: 'remote', remoteKind } as HermesConnection })+ ).toBe(false)+ }+ })++ it('fails closed while the connection is unresolved', () => {+ expect(shouldOfferRealProfilePrompt({ ...openGate, connection: null })).toBe(false)+ expect(shouldOfferRealProfilePrompt({ ...openGate, connection: {} as HermesConnection })).toBe(false)+ })++ it('keeps the existing gates', () => {+ expect(shouldOfferRealProfilePrompt({ ...openGate, configLoaded: false })).toBe(false)+ expect(shouldOfferRealProfilePrompt({ ...openGate, enabled: true })).toBe(false)+ expect(shouldOfferRealProfilePrompt({ ...openGate, dismissed: true })).toBe(false)+ expect(shouldOfferRealProfilePrompt({ ...openGate, muted: true })).toBe(false)+ expect(shouldOfferRealProfilePrompt({ ...openGate, claim: 'tab-2' })).toBe(false)+ })+})+describe('RealProfileConsentDialog', () => {beforeEach(() => {mocks.loadedConfig = { browser: { allow_private_urls: false }, model: { provider: 'nous' } }@@ -68,6 +110,7 @@ describe('RealProfileConsentDialog', () => {$realProfilePromptDismissed.set(false)$realProfilePromptMuted.set(false)$realProfilePromptClaim.set(null)+ $connection.set(localConnection)})afterEach(() => {@@ -102,6 +145,14 @@ describe('RealProfileConsentDialog', () => {expect(screen.queryByText(promptCopy.title)).toBeNull()})+ it('does not show, or write, for a remote backend (#119398)', () => {+ $connection.set(remoteConnection)+ render(<RealProfileConsentDialog tabId="tab-1" />)++ expect(screen.queryByText(promptCopy.title)).toBeNull()+ expect(mocks.save).not.toHaveBeenCalled()+ })+it('does not show before the config record loads', () => {mocks.loadedConfig = undefinedrender(<RealProfileConsentDialog tabId="tab-1" />)diff --git a/apps/desktop/src/app/chat/right-rail/real-profile-consent-dialog.tsx b/apps/desktop/src/app/chat/right-rail/real-profile-consent-dialog.tsxindex 893e8e290db..aa656696cb4 100644--- a/apps/desktop/src/app/chat/right-rail/real-profile-consent-dialog.tsx+++ b/apps/desktop/src/app/chat/right-rail/real-profile-consent-dialog.tsx@@ -11,6 +11,7 @@ import {DialogHeader,DialogTitle} from '@/components/ui/dialog'+import type { HermesConnection } from '@/global'import { saveHermesConfigRecord } from '@/hermes'import { useI18n } from '@/i18n'import { Check, Globe } from '@/lib/icons'@@ -22,6 +23,7 @@ import {claimRealProfilePrompt,releaseRealProfilePrompt} from '@/store/real-profile-consent'+import { $connection } from '@/store/session'import { hermesConfigCacheWriter, useHermesConfigRecord } from '../../hooks/use-config-record'@@ -31,6 +33,39 @@ interface RealProfileConsentDialogProps {tabId: string}+interface RealProfilePromptGate {+ claim: null | string+ configLoaded: boolean+ connection: HermesConnection | null+ dismissed: boolean+ enabled: boolean+ muted: boolean+ tabId: string+}++/**+ * Whether this pane should offer the real-profile consent prompt.+ *+ * Only for a backend on THIS machine: real-profile mode snapshots the+ * backend host's default browser, and the prompt promises "your" profile and+ * "nothing leaves this computer". Over a remote/SSH/cloud connection that is+ * another machine's browser (often a headless box with none), and "Enable"+ * would write `browser.use_real_profile` into the remote config.yaml — which+ * unregisters its browser tools and re-appears after every reset (#119398).+ * An unresolved connection fails closed. Remote users can still opt in from+ * the Capabilities → Tools → Browser toggle.+ */+export function shouldOfferRealProfilePrompt(gate: RealProfilePromptGate): boolean {+ return (+ gate.connection?.mode === 'local' &&+ gate.configLoaded &&+ !gate.enabled &&+ !gate.dismissed &&+ !gate.muted &&+ gate.claim === gate.tabId+ )+}+/*** First-open consent prompt for real-profile browsing. Mounts with a Browser* pane (docked tab and `?win=browser` popout alike) and offers to turn on@@ -41,7 +76,8 @@ interface RealProfileConsentDialogProps {* query cache the toggle reads, so the Capabilities toggle flips on the spot* with no refetch. "Not now" mutes the prompt for this app run; "Don't show* again" persists the opt-out across launches. Turning the toggle off later- * does NOT resurrect the prompt inside the same run.+ * does NOT resurrect the prompt inside the same run. Never offered for a+ * remote backend (see shouldOfferRealProfilePrompt).*/export function RealProfileConsentDialog({ tabId }: RealProfileConsentDialogProps) {const { t } = useI18n()@@ -50,6 +86,7 @@ export function RealProfileConsentDialog({ tabId }: RealProfileConsentDialogPropconst dismissed = useStore($realProfilePromptDismissed)const muted = useStore($realProfilePromptMuted)const claim = useStore($realProfilePromptClaim)+ const connection = useStore($connection)const { data: config, writeScope } = useHermesConfigRecord()const setConfig = hermesConfigCacheWriter()const [busy, setBusy] = useState(false)@@ -91,10 +128,18 @@ export function RealProfileConsentDialog({ tabId }: RealProfileConsentDialogProp}}, [busy, config, copy, setConfig, writeScope])- // Config not loaded yet, feature already on, opted out, or another pane- // owns the prompt — render nothing. `enabled` flipping true after a- // successful save is also what closes the dialog.- const open = Boolean(config) && !enabled && !dismissed && !muted && claim === tabId+ // Remote backend, config not loaded yet, feature already on, opted out, or+ // another pane owns the prompt — render nothing. `enabled` flipping true+ // after a successful save is also what closes the dialog.+ const open = shouldOfferRealProfilePrompt({+ claim,+ configLoaded: Boolean(config),+ connection,+ dismissed,+ enabled,+ muted,+ tabId+ })if (!open) {return null