Skip to content

Commit 228c9c7

Browse files
committed
feat: replace auto-approve text labels with icons in collapsed view
- Updated AutoApproveMenu component to display icons instead of text labels when collapsed - Added enabledIcons computed value to extract icon names from enabled toggles - Modified the display span to render icons with proper styling - Updated tests to check for icon presence instead of text content - Removed unused displayText and enabledActionsList variables - Maintains the same functionality while providing a more compact visual representation
1 parent 74672fa commit 228c9c7

File tree

2 files changed

+29
-17
lines changed

2 files changed

+29
-17
lines changed

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

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -129,18 +129,12 @@ const AutoApproveMenu = ({ style }: AutoApproveMenuProps) => {
129129
setIsExpanded((prev) => !prev)
130130
}, [])
131131

132-
const enabledActionsList = Object.entries(toggles)
133-
.filter(([_key, value]) => !!value)
134-
.map(([key]) => t(autoApproveSettingsConfig[key as AutoApproveSetting].labelKey))
135-
.join(", ")
136-
137-
// Update displayed text logic
138-
const displayText = useMemo(() => {
139-
if (!effectiveAutoApprovalEnabled || !hasEnabledOptions) {
140-
return t("chat:autoApprove.none")
141-
}
142-
return enabledActionsList || t("chat:autoApprove.none")
143-
}, [effectiveAutoApprovalEnabled, hasEnabledOptions, enabledActionsList, t])
132+
// Get enabled icons for display
133+
const enabledIcons = useMemo(() => {
134+
return Object.entries(toggles)
135+
.filter(([_key, value]) => !!value)
136+
.map(([key]) => autoApproveSettingsConfig[key as AutoApproveSetting].icon)
137+
}, [toggles])
144138

145139
const handleOpenSettings = useCallback(
146140
() =>
@@ -213,8 +207,22 @@ const AutoApproveMenu = ({ style }: AutoApproveMenuProps) => {
213207
whiteSpace: "nowrap",
214208
flex: 1,
215209
minWidth: 0,
210+
display: "flex",
211+
alignItems: "center",
212+
gap: "6px",
216213
}}>
217-
{displayText}
214+
{!effectiveAutoApprovalEnabled || !hasEnabledOptions
215+
? 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+
))}
218226
</span>
219227
<span
220228
className={`codicon codicon-chevron-${isExpanded ? "down" : "right"}`}

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,9 @@ describe("AutoApproveMenu", () => {
111111

112112
render(<AutoApproveMenu />)
113113

114-
// Check that the text shows the enabled option
115-
expect(screen.getByText("Read-only operations")).toBeInTheDocument()
114+
// Check that the icon for read-only operations is shown
115+
const container = screen.getByText("Auto-approve").parentElement?.parentElement
116+
expect(container?.querySelector(".codicon-eye")).toBeInTheDocument()
116117
})
117118

118119
it("should not allow toggling master checkbox when no options are selected", () => {
@@ -222,8 +223,11 @@ describe("AutoApproveMenu", () => {
222223

223224
render(<AutoApproveMenu />)
224225

225-
// Should show all enabled options in the summary
226-
expect(screen.getByText("Read-only operations, Write operations, Execute operations")).toBeInTheDocument()
226+
// Should show icons for all enabled options
227+
const container = screen.getByText("Auto-approve").parentElement?.parentElement
228+
expect(container?.querySelector(".codicon-eye")).toBeInTheDocument() // Read
229+
expect(container?.querySelector(".codicon-edit")).toBeInTheDocument() // Write
230+
expect(container?.querySelector(".codicon-terminal")).toBeInTheDocument() // Execute
227231
})
228232

229233
it("should handle enabling first option when none selected", async () => {

0 commit comments

Comments
 (0)