diff --git a/src/renderer/src/components/settings/ChatBehaviorSetting.test.tsx b/src/renderer/src/components/settings/ChatBehaviorSetting.test.tsx index af6b4743c9b7..eed7605218e1 100644 --- a/src/renderer/src/components/settings/ChatBehaviorSetting.test.tsx +++ b/src/renderer/src/components/settings/ChatBehaviorSetting.test.tsx @@ -7,6 +7,7 @@ import type { GlobalSettings } from '../../../../shared/global-settings-types' import { AGENT_SESSION_QUEUED_MESSAGES_RUNTIME_CAPABILITY } from '../../../../shared/protocol-version' import { setLocalRuntimeCapabilitiesForTests } from '@/runtime/local-runtime-capabilities' import { ChatBehaviorSetting } from './ChatBehaviorSetting' +import { TooltipProvider } from '../ui/tooltip' afterEach(() => { cleanup() @@ -18,11 +19,13 @@ const SHELL_ENV_TOGGLE = '[aria-label="Toggle using your shell environment"]' const NAME_INPUT = '#settings-native-chat-shell-environment-name' function renderSetting(overrides: Partial, updateSettings = vi.fn()) { + // The wrapper also covers rerender: the permission picker's tooltip needs the app's provider. return render( + />, + { wrapper: TooltipProvider } ) } @@ -221,3 +224,17 @@ describe('ChatBehaviorSetting resume after restart', () => { expect(updateSettings).toHaveBeenCalledWith({ nativeChatResumeWorkOnRestart: true }) }) }) + +describe('ChatBehaviorSetting permissions', () => { + it('shows the new-chat permission picker as the first Behavior row', () => { + const { container } = renderSetting({ nativeChatPermissionMode: 'full-access' }) + const rows = container.querySelectorAll('.divide-y > *') + expect(rows[0]?.id).toBe('chat-permissions') + expect(container.querySelector('button[aria-label="Permissions Full access"]')).not.toBeNull() + }) + + it('leaves the row out when the host has no value', () => { + const { container } = renderSetting({ nativeChatPermissionMode: undefined }) + expect(container.querySelector('#chat-permissions')).toBeNull() + }) +}) diff --git a/src/renderer/src/components/settings/ChatBehaviorSetting.tsx b/src/renderer/src/components/settings/ChatBehaviorSetting.tsx index ab4a1f96ab65..a81971726f7c 100644 --- a/src/renderer/src/components/settings/ChatBehaviorSetting.tsx +++ b/src/renderer/src/components/settings/ChatBehaviorSetting.tsx @@ -4,10 +4,12 @@ import type { RuntimeClientTarget } from '../../../../shared/runtime-client-targ import { useStructuredAgentSessionHostQueuesMessages } from '@/runtime/structured-agent-session-host-capability' import { useAppStore } from '../../store' import { Card, CardContent } from '../ui/card' +import { ChatPermissionSetting } from './ChatPermissionSetting' import { NativeChatShellEnvironmentSetting } from './NativeChatShellEnvironmentSetting' import { SearchableSetting } from './SearchableSetting' import { SettingsSubsectionHeader, SettingsSwitchRow } from './SettingsFormControls' import { getChatBehaviorEntriesByKey, getChatBehaviorTitle } from './chat-behavior-search' +import { getChatPermissionSearchEntry } from './chat-permission-search' import { matchesSettingsSearch } from './settings-search' // This screen edits this machine's settings, so it asks this machine's runtime; a paired host that @@ -30,6 +32,7 @@ export function ChatBehaviorSetting({ const hostQueuesMessages = useStructuredAgentSessionHostQueuesMessages(STRUCTURED_CHAT_HOST) const entries = getChatBehaviorEntriesByKey() const rows = [ + ...(settings.nativeChatPermissionMode !== undefined ? [getChatPermissionSearchEntry()] : []), entries.resumeOnRestart, ...(hostQueuesMessages ? [entries.queueFollowUps] : []), entries.shellEnvironment @@ -45,6 +48,11 @@ export function ChatBehaviorSetting({
+ - {isMounted ? (
- {matchesSettingsSearch(query, [{ title }, ...getChatAppearanceSearchEntries()]) ? (