From 3db1ed9dc5b58ccb1244e502914c2aa4450428b1 Mon Sep 17 00:00:00 2001 From: lucaronin Date: Wed, 29 Apr 2026 10:44:20 +0200 Subject: [PATCH] fix: split ai permission tooltips --- src/components/AiPanel.test.tsx | 15 ++++++++++++--- src/components/AiPanelChrome.tsx | 11 ++++++++--- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/components/AiPanel.test.tsx b/src/components/AiPanel.test.tsx index c9657102..f85b38f6 100644 --- a/src/components/AiPanel.test.tsx +++ b/src/components/AiPanel.test.tsx @@ -1,5 +1,5 @@ import { describe, it, expect, vi } from 'vitest' -import { render as rtlRender, screen, fireEvent, act } from '@testing-library/react' +import { render as rtlRender, screen, fireEvent, act, waitFor } from '@testing-library/react' import { AiPanel } from './AiPanel' import { UNSUPPORTED_INLINE_PASTE_MESSAGE } from './InlineWikilinkInput' import { TooltipProvider } from '@/components/ui/tooltip' @@ -152,7 +152,7 @@ describe('AiPanel', () => { expect(screen.getByRole('radio', { name: 'Power User' })).toBeDisabled() }) - it('renders the permission mode toggle with high contrast selected state and explanatory tooltip', async () => { + it('renders the permission mode toggle with high contrast selected state and per-mode tooltips', async () => { render() expect(screen.getByTestId('ai-permission-mode-toggle')).toHaveClass('border', 'bg-muted') @@ -166,8 +166,17 @@ describe('AiPanel', () => { fireEvent.focus(safeMode) expect(await screen.findByTestId('ai-permission-mode-tooltip')).toHaveTextContent( - 'Vault Safe keeps agents to file, search, and edit tools. Power User also allows local shell commands for this vault.', + 'Vault Safe keeps agents limited to file, search, and edit tools.', ) + + fireEvent.blur(safeMode) + fireEvent.focus(powerUserMode) + + await waitFor(() => { + expect(screen.getByTestId('ai-permission-mode-tooltip')).toHaveTextContent( + 'Power User also allows local shell commands for this vault.', + ) + }) }) it('renders data-testid ai-panel', () => { diff --git a/src/components/AiPanelChrome.tsx b/src/components/AiPanelChrome.tsx index ffdab2e5..76af9a34 100644 --- a/src/components/AiPanelChrome.tsx +++ b/src/components/AiPanelChrome.tsx @@ -16,8 +16,13 @@ import type { AiAgentReadiness } from '../lib/aiAgents' import type { NoteReference } from '../utils/ai-context' import type { VaultEntry } from '../types' -const AI_PERMISSION_MODE_TOOLTIP = { - label: 'Vault Safe keeps agents to file, search, and edit tools. Power User also allows local shell commands for this vault.', +const AI_PERMISSION_MODE_TOOLTIPS: Record = { + safe: { + label: 'Vault Safe keeps agents limited to file, search, and edit tools.', + }, + power_user: { + label: 'Power User also allows local shell commands for this vault.', + }, } interface AiPanelHeaderProps { @@ -228,7 +233,7 @@ function AiPermissionModeToggle({ return (