From cfa2081ffa64378c8237606926e325d3cd33b2e7 Mon Sep 17 00:00:00 2001 From: Roo Code Date: Tue, 5 Aug 2025 21:45:28 +0000 Subject: [PATCH] feat: add tooltips to auto-approve icons in collapsed view - Wrapped each icon in StandardTooltip component - Tooltips display the label for each auto-approve option - Added test to verify tooltips appear on hover - Helps users identify icons more easily in collapsed state --- .../src/components/chat/AutoApproveMenu.tsx | 29 +++++++++++------ .../chat/__tests__/AutoApproveMenu.spec.tsx | 32 +++++++++++++++++++ 2 files changed, 51 insertions(+), 10 deletions(-) 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()