Skip to content

Commit cfa2081

Browse files
committed
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
1 parent 228c9c7 commit cfa2081

File tree

2 files changed

+51
-10
lines changed

2 files changed

+51
-10
lines changed

webview-ui/src/components/chat/AutoApproveMenu.tsx

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -213,16 +213,25 @@ const AutoApproveMenu = ({ style }: AutoApproveMenuProps) => {
213213
}}>
214214
{!effectiveAutoApprovalEnabled || !hasEnabledOptions
215215
? t("chat:autoApprove.none")
216-
: enabledIcons.map((icon, index) => (
217-
<span
218-
key={index}
219-
className={`codicon codicon-${icon}`}
220-
style={{
221-
fontSize: "14px",
222-
flexShrink: 0,
223-
}}
224-
/>
225-
))}
216+
: enabledIcons.map((icon, index) => {
217+
// Find the config for this icon to get the label
218+
const config = Object.values(autoApproveSettingsConfig).find(
219+
(cfg) => cfg.icon === icon,
220+
)
221+
const tooltipContent = config ? t(config.labelKey) : ""
222+
223+
return (
224+
<StandardTooltip key={index} content={tooltipContent}>
225+
<span
226+
className={`codicon codicon-${icon}`}
227+
style={{
228+
fontSize: "14px",
229+
flexShrink: 0,
230+
}}
231+
/>
232+
</StandardTooltip>
233+
)
234+
})}
226235
</span>
227236
<span
228237
className={`codicon codicon-chevron-${isExpanded ? "down" : "right"}`}

webview-ui/src/components/chat/__tests__/AutoApproveMenu.spec.tsx

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { render, fireEvent, screen, waitFor } from "@/utils/test-utils"
22
import { useExtensionState } from "@src/context/ExtensionStateContext"
33
import { vscode } from "@src/utils/vscode"
44
import AutoApproveMenu from "../AutoApproveMenu"
5+
import userEvent from "@testing-library/user-event"
56

67
// Mock vscode API
78
vi.mock("@src/utils/vscode", () => ({
@@ -230,6 +231,37 @@ describe("AutoApproveMenu", () => {
230231
expect(container?.querySelector(".codicon-terminal")).toBeInTheDocument() // Execute
231232
})
232233

234+
it("should display tooltips on icons in collapsed view", async () => {
235+
const user = userEvent.setup()
236+
237+
;(useExtensionState as ReturnType<typeof vi.fn>).mockReturnValue({
238+
...defaultExtensionState,
239+
autoApprovalEnabled: true,
240+
alwaysAllowReadOnly: true,
241+
alwaysAllowWrite: true,
242+
alwaysAllowExecute: true,
243+
})
244+
245+
render(<AutoApproveMenu />)
246+
247+
// Find the icons
248+
const container = screen.getByText("Auto-approve").parentElement?.parentElement
249+
const eyeIcon = container?.querySelector(".codicon-eye") as HTMLElement
250+
const editIcon = container?.querySelector(".codicon-edit") as HTMLElement
251+
const terminalIcon = container?.querySelector(".codicon-terminal") as HTMLElement
252+
253+
// Verify icons are present
254+
expect(eyeIcon).toBeInTheDocument()
255+
expect(editIcon).toBeInTheDocument()
256+
expect(terminalIcon).toBeInTheDocument()
257+
258+
// Test read-only icon tooltip
259+
await user.hover(eyeIcon)
260+
await waitFor(() => {
261+
expect(screen.getByRole("tooltip")).toHaveTextContent("Read-only operations")
262+
})
263+
})
264+
233265
it("should handle enabling first option when none selected", async () => {
234266
const mockSetAutoApprovalEnabled = vi.fn()
235267
const mockSetAlwaysAllowReadOnly = vi.fn()

0 commit comments

Comments
 (0)