diff --git a/webview-ui/src/components/chat/AutoApproveMenu.tsx b/webview-ui/src/components/chat/AutoApproveMenu.tsx index 4f67cad914..caa5ac73fb 100644 --- a/webview-ui/src/components/chat/AutoApproveMenu.tsx +++ b/webview-ui/src/components/chat/AutoApproveMenu.tsx @@ -213,16 +213,25 @@ const AutoApproveMenu = ({ style }: AutoApproveMenuProps) => { }}> {!effectiveAutoApprovalEnabled || !hasEnabledOptions ? t("chat:autoApprove.none") - : enabledIcons.map((icon, index) => ( - - ))} + : enabledIcons.map((icon, index) => { + // Find the config for this icon to get the label + const config = Object.values(autoApproveSettingsConfig).find( + (cfg) => cfg.icon === icon, + ) + const tooltipContent = config ? t(config.labelKey) : "" + + return ( + + + + ) + })} ({ @@ -230,6 +231,37 @@ describe("AutoApproveMenu", () => { expect(container?.querySelector(".codicon-terminal")).toBeInTheDocument() // Execute }) + it("should display tooltips on icons in collapsed view", async () => { + const user = userEvent.setup() + + ;(useExtensionState as ReturnType).mockReturnValue({ + ...defaultExtensionState, + autoApprovalEnabled: true, + alwaysAllowReadOnly: true, + alwaysAllowWrite: true, + alwaysAllowExecute: true, + }) + + render() + + // Find the icons + const container = screen.getByText("Auto-approve").parentElement?.parentElement + const eyeIcon = container?.querySelector(".codicon-eye") as HTMLElement + const editIcon = container?.querySelector(".codicon-edit") as HTMLElement + const terminalIcon = container?.querySelector(".codicon-terminal") as HTMLElement + + // Verify icons are present + expect(eyeIcon).toBeInTheDocument() + expect(editIcon).toBeInTheDocument() + expect(terminalIcon).toBeInTheDocument() + + // Test read-only icon tooltip + await user.hover(eyeIcon) + await waitFor(() => { + expect(screen.getByRole("tooltip")).toHaveTextContent("Read-only operations") + }) + }) + it("should handle enabling first option when none selected", async () => { const mockSetAutoApprovalEnabled = vi.fn() const mockSetAlwaysAllowReadOnly = vi.fn()